@@ -29,8 +29,8 @@ use rustc_middle::ty::adjustment::CustomCoerceUnsized;
2929use rustc_middle:: ty:: adjustment:: PointerCast ;
3030use rustc_middle:: ty:: TypeAndMut ;
3131use rustc_middle:: ty:: {
32- self , Closure , ClosureKind , Const , ConstKind , Instance , InstanceDef , ParamEnv , TraitRef , Ty ,
33- TyCtxt , TyKind , TypeFoldable , VtblEntry ,
32+ self , Closure , ClosureKind , ConstKind , Instance , InstanceDef , ParamEnv , TraitRef , Ty , TyCtxt ,
33+ TyKind , TypeFoldable , VtblEntry ,
3434} ;
3535use rustc_span:: def_id:: DefId ;
3636use tracing:: { debug, debug_span, trace, warn} ;
@@ -337,22 +337,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MonoItemsFnCollector<'a, 'tcx> {
337337 ConstantKind :: Val ( const_val, _) => const_val,
338338 ConstantKind :: Ty ( ct) => match ct. kind ( ) {
339339 ConstKind :: Value ( v) => self . tcx . valtree_to_const_val ( ( ct. ty ( ) , v) ) ,
340- ConstKind :: Unevaluated ( un_eval) => {
341- // Thread local fall into this category.
342- match self . tcx . const_eval_resolve ( ParamEnv :: reveal_all ( ) , un_eval, None ) {
343- // The `monomorphize` call should have evaluated that constant already.
344- Ok ( const_val) => const_val,
345- Err ( ErrorHandled :: TooGeneric ) => span_bug ! (
346- self . body. source_info( location) . span,
347- "Unexpected polymorphic constant: {:?}" ,
348- literal
349- ) ,
350- Err ( error) => {
351- warn ! ( ?error, "Error already reported" ) ;
352- return ;
353- }
354- }
355- }
340+ ConstKind :: Unevaluated ( _) => unreachable ! ( ) ,
356341 // Nothing to do
357342 ConstKind :: Param ( ..) | ConstKind :: Infer ( ..) | ConstKind :: Error ( ..) => return ,
358343
@@ -361,15 +346,26 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MonoItemsFnCollector<'a, 'tcx> {
361346 unreachable ! ( "Unexpected constant type {:?} ({:?})" , ct, ct. kind( ) )
362347 }
363348 } ,
349+ ConstantKind :: Unevaluated ( un_eval, _) => {
350+ // Thread local fall into this category.
351+ match self . tcx . const_eval_resolve ( ParamEnv :: reveal_all ( ) , un_eval, None ) {
352+ // The `monomorphize` call should have evaluated that constant already.
353+ Ok ( const_val) => const_val,
354+ Err ( ErrorHandled :: TooGeneric ) => span_bug ! (
355+ self . body. source_info( location) . span,
356+ "Unexpected polymorphic constant: {:?}" ,
357+ literal
358+ ) ,
359+ Err ( error) => {
360+ warn ! ( ?error, "Error already reported" ) ;
361+ return ;
362+ }
363+ }
364+ }
364365 } ;
365366 self . collect_const_value ( val) ;
366367 }
367368
368- fn visit_const ( & mut self , constant : Const < ' tcx > , location : Location ) {
369- trace ! ( ?constant, ?location, "visit_const" ) ;
370- self . super_const ( constant) ;
371- }
372-
373369 /// Collect function calls.
374370 fn visit_terminator ( & mut self , terminator : & Terminator < ' tcx > , location : Location ) {
375371 trace ! ( ?terminator, ?location, "visit_terminator" ) ;
0 commit comments