@@ -70,6 +70,7 @@ mod closure;
70
70
pub mod coercion;
71
71
mod compare_method;
72
72
pub mod demand;
73
+ mod diverges;
73
74
pub mod dropck;
74
75
mod expr;
75
76
mod fn_ctxt;
@@ -86,6 +87,7 @@ mod upvar;
86
87
mod wfcheck;
87
88
pub mod writeback;
88
89
90
+ pub use diverges:: Diverges ;
89
91
pub use fn_ctxt:: FnCtxt ;
90
92
pub use inherited:: { Inherited , InheritedBuilder } ;
91
93
@@ -125,8 +127,6 @@ use rustc_trait_selection::traits::error_reporting::suggestions::ReturnsVisitor;
125
127
use rustc_trait_selection:: traits:: { self , ObligationCauseCode } ;
126
128
127
129
use std:: cell:: { Ref , RefCell , RefMut } ;
128
- use std:: cmp;
129
- use std:: ops:: { self } ;
130
130
131
131
use crate :: require_c_abi_if_c_variadic;
132
132
use crate :: util:: common:: indenter;
@@ -326,81 +326,6 @@ pub enum PlaceOp {
326
326
Index ,
327
327
}
328
328
329
- /// Tracks whether executing a node may exit normally (versus
330
- /// return/break/panic, which "diverge", leaving dead code in their
331
- /// wake). Tracked semi-automatically (through type variables marked
332
- /// as diverging), with some manual adjustments for control-flow
333
- /// primitives (approximating a CFG).
334
- #[ derive( Copy , Clone , Debug , PartialEq , Eq , PartialOrd , Ord ) ]
335
- pub enum Diverges {
336
- /// Potentially unknown, some cases converge,
337
- /// others require a CFG to determine them.
338
- Maybe ,
339
-
340
- /// Definitely known to diverge and therefore
341
- /// not reach the next sibling or its parent.
342
- Always {
343
- /// The `Span` points to the expression
344
- /// that caused us to diverge
345
- /// (e.g. `return`, `break`, etc).
346
- span : Span ,
347
- /// In some cases (e.g. a `match` expression
348
- /// where all arms diverge), we may be
349
- /// able to provide a more informative
350
- /// message to the user.
351
- /// If this is `None`, a default message
352
- /// will be generated, which is suitable
353
- /// for most cases.
354
- custom_note : Option < & ' static str > ,
355
- } ,
356
-
357
- /// Same as `Always` but with a reachability
358
- /// warning already emitted.
359
- WarnedAlways ,
360
- }
361
-
362
- // Convenience impls for combining `Diverges`.
363
-
364
- impl ops:: BitAnd for Diverges {
365
- type Output = Self ;
366
- fn bitand ( self , other : Self ) -> Self {
367
- cmp:: min ( self , other)
368
- }
369
- }
370
-
371
- impl ops:: BitOr for Diverges {
372
- type Output = Self ;
373
- fn bitor ( self , other : Self ) -> Self {
374
- cmp:: max ( self , other)
375
- }
376
- }
377
-
378
- impl ops:: BitAndAssign for Diverges {
379
- fn bitand_assign ( & mut self , other : Self ) {
380
- * self = * self & other;
381
- }
382
- }
383
-
384
- impl ops:: BitOrAssign for Diverges {
385
- fn bitor_assign ( & mut self , other : Self ) {
386
- * self = * self | other;
387
- }
388
- }
389
-
390
- impl Diverges {
391
- /// Creates a `Diverges::Always` with the provided `span` and the default note message.
392
- fn always ( span : Span ) -> Diverges {
393
- Diverges :: Always { span, custom_note : None }
394
- }
395
-
396
- fn is_always ( self ) -> bool {
397
- // Enum comparison ignores the
398
- // contents of fields, so we just
399
- // fill them in with garbage here.
400
- self >= Diverges :: Always { span : DUMMY_SP , custom_note : None }
401
- }
402
- }
403
-
404
329
pub struct BreakableCtxt < ' tcx > {
405
330
may_break : bool ,
406
331
0 commit comments