@@ -17,7 +17,7 @@ use rustc_middle::mir::*;
1717use rustc_middle:: ty:: layout:: { LayoutError , LayoutOf , LayoutOfHelpers , TyAndLayout } ;
1818use rustc_middle:: ty:: InternalSubsts ;
1919use rustc_middle:: ty:: { self , ConstKind , Instance , ParamEnv , Ty , TyCtxt , TypeVisitableExt } ;
20- use rustc_span:: { def_id:: DefId , Span } ;
20+ use rustc_span:: { def_id:: DefId , Span , DUMMY_SP } ;
2121use rustc_target:: abi:: { self , Align , HasDataLayout , Size , TargetDataLayout } ;
2222use rustc_target:: spec:: abi:: Abi as CallAbi ;
2323use rustc_trait_selection:: traits;
@@ -328,9 +328,6 @@ struct ConstPropagator<'mir, 'tcx> {
328328 tcx : TyCtxt < ' tcx > ,
329329 param_env : ParamEnv < ' tcx > ,
330330 local_decls : & ' mir IndexVec < Local , LocalDecl < ' tcx > > ,
331- // Because we have `MutVisitor` we can't obtain the `SourceInfo` from a `Location`. So we store
332- // the last known `SourceInfo` here and just keep revisiting it.
333- source_info : Option < SourceInfo > ,
334331}
335332
336333impl < ' tcx > LayoutOfHelpers < ' tcx > for ConstPropagator < ' _ , ' tcx > {
@@ -411,13 +408,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
411408 )
412409 . expect ( "failed to push initial stack frame" ) ;
413410
414- ConstPropagator {
415- ecx,
416- tcx,
417- param_env,
418- local_decls : & dummy_body. local_decls ,
419- source_info : None ,
420- }
411+ ConstPropagator { ecx, tcx, param_env, local_decls : & dummy_body. local_decls }
421412 }
422413
423414 fn get_const ( & self , place : Place < ' tcx > ) -> Option < OpTy < ' tcx > > {
@@ -495,7 +486,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
495486 * operand = self . operand_from_scalar (
496487 scalar,
497488 value. layout . ty ,
498- self . source_info . unwrap ( ) . span ,
489+ DUMMY_SP ,
499490 ) ;
500491 }
501492 }
@@ -629,12 +620,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
629620 } ) )
630621 }
631622
632- fn replace_with_const (
633- & mut self ,
634- rval : & mut Rvalue < ' tcx > ,
635- value : & OpTy < ' tcx > ,
636- source_info : SourceInfo ,
637- ) {
623+ fn replace_with_const ( & mut self , rval : & mut Rvalue < ' tcx > , value : & OpTy < ' tcx > ) {
638624 if let Rvalue :: Use ( Operand :: Constant ( c) ) = rval {
639625 match c. literal {
640626 ConstantKind :: Ty ( c) if matches ! ( c. kind( ) , ConstKind :: Unevaluated ( ..) ) => { }
@@ -664,11 +650,8 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
664650 if let Some ( Right ( imm) ) = imm {
665651 match * imm {
666652 interpret:: Immediate :: Scalar ( scalar) => {
667- * rval = Rvalue :: Use ( self . operand_from_scalar (
668- scalar,
669- value. layout . ty ,
670- source_info. span ,
671- ) ) ;
653+ * rval =
654+ Rvalue :: Use ( self . operand_from_scalar ( scalar, value. layout . ty , DUMMY_SP ) ) ;
672655 }
673656 Immediate :: ScalarPair ( ..) => {
674657 // Found a value represented as a pair. For now only do const-prop if the type
@@ -701,7 +684,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
701684 let const_val = ConstValue :: ByRef { alloc, offset : Size :: ZERO } ;
702685 let literal = ConstantKind :: Val ( const_val, ty) ;
703686 * rval = Rvalue :: Use ( Operand :: Constant ( Box :: new ( Constant {
704- span : source_info . span ,
687+ span : DUMMY_SP ,
705688 user_ty : None ,
706689 literal,
707690 } ) ) ) ;
@@ -894,8 +877,6 @@ impl<'tcx> MutVisitor<'tcx> for ConstPropagator<'_, 'tcx> {
894877
895878 fn visit_statement ( & mut self , statement : & mut Statement < ' tcx > , location : Location ) {
896879 trace ! ( "visit_statement: {:?}" , statement) ;
897- let source_info = statement. source_info ;
898- self . source_info = Some ( source_info) ;
899880 match statement. kind {
900881 StatementKind :: Assign ( box ( place, ref mut rval) ) => {
901882 let can_const_prop = self . ecx . machine . can_const_prop [ place. local ] ;
@@ -905,7 +886,7 @@ impl<'tcx> MutVisitor<'tcx> for ConstPropagator<'_, 'tcx> {
905886 // consists solely of uninitialized memory (so it doesn't capture any locals).
906887 if let Some ( ref value) = self . get_const ( place) && self . should_const_prop ( value) {
907888 trace ! ( "replacing {:?} with {:?}" , rval, value) ;
908- self . replace_with_const ( rval, value, source_info ) ;
889+ self . replace_with_const ( rval, value) ;
909890 if can_const_prop == ConstPropMode :: FullConstProp
910891 || can_const_prop == ConstPropMode :: OnlyInsideOwnBlock
911892 {
@@ -977,8 +958,6 @@ impl<'tcx> MutVisitor<'tcx> for ConstPropagator<'_, 'tcx> {
977958 }
978959
979960 fn visit_terminator ( & mut self , terminator : & mut Terminator < ' tcx > , location : Location ) {
980- let source_info = terminator. source_info ;
981- self . source_info = Some ( source_info) ;
982961 self . super_terminator ( terminator, location) ;
983962
984963 match & mut terminator. kind {
@@ -991,7 +970,7 @@ impl<'tcx> MutVisitor<'tcx> for ConstPropagator<'_, 'tcx> {
991970 * cond = self . operand_from_scalar (
992971 value_const,
993972 self . tcx . types . bool ,
994- source_info . span ,
973+ DUMMY_SP ,
995974 ) ;
996975 }
997976 }
0 commit comments