@@ -70,6 +70,7 @@ mod closure;
7070pub mod coercion;
7171mod compare_method;
7272pub mod demand;
73+ mod diverges;
7374pub mod dropck;
7475mod expr;
7576mod fn_ctxt;
@@ -86,6 +87,7 @@ mod upvar;
8687mod wfcheck;
8788pub mod writeback;
8889
90+ pub use diverges:: Diverges ;
8991pub use fn_ctxt:: FnCtxt ;
9092pub use inherited:: { Inherited , InheritedBuilder } ;
9193
@@ -125,8 +127,6 @@ use rustc_trait_selection::traits::error_reporting::suggestions::ReturnsVisitor;
125127use rustc_trait_selection:: traits:: { self , ObligationCauseCode } ;
126128
127129use std:: cell:: { Ref , RefCell , RefMut } ;
128- use std:: cmp;
129- use std:: ops:: { self } ;
130130
131131use crate :: require_c_abi_if_c_variadic;
132132use crate :: util:: common:: indenter;
@@ -326,81 +326,6 @@ pub enum PlaceOp {
326326 Index ,
327327}
328328
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-
404329pub struct BreakableCtxt < ' tcx > {
405330 may_break : bool ,
406331
0 commit comments