@@ -29,11 +29,7 @@ crate fn mir_built<'tcx>(
2929 return tcx. mir_built ( def) ;
3030 }
3131
32- let mut body = mir_build ( tcx, def) ;
33- if def. const_param_did . is_some ( ) {
34- assert ! ( matches!( body. source. instance, ty:: InstanceDef :: Item ( _) ) ) ;
35- body. source = MirSource :: from_instance ( ty:: InstanceDef :: Item ( def. to_global ( ) ) ) ;
36- }
32+ let body = mir_build ( tcx, def) ;
3733
3834 tcx. alloc_steal_mir ( body)
3935}
@@ -302,7 +298,7 @@ struct Builder<'a, 'tcx> {
302298 hir : Cx < ' a , ' tcx > ,
303299 cfg : CFG < ' tcx > ,
304300
305- def_id : DefId ,
301+ def : ty :: WithOptConstParam < DefId > ,
306302 fn_span : Span ,
307303 arg_count : usize ,
308304 generator_kind : Option < GeneratorKind > ,
@@ -604,7 +600,7 @@ where
604600
605601 let mut builder = Builder :: new (
606602 hir,
607- fn_def_id. to_def_id ( ) ,
603+ ty :: WithOptConstParam :: unknown ( fn_def_id. to_def_id ( ) ) ,
608604 span_with_body,
609605 arguments. len ( ) ,
610606 safety,
@@ -685,7 +681,16 @@ fn construct_const<'a, 'tcx>(
685681 let owner_id = tcx. hir ( ) . body_owner ( body_id) ;
686682 let def_id = tcx. hir ( ) . local_def_id ( owner_id) ;
687683 let span = tcx. hir ( ) . span ( owner_id) ;
688- let mut builder = Builder :: new ( hir, def_id. to_def_id ( ) , span, 0 , Safety :: Safe , const_ty, const_ty_span, None ) ;
684+ let mut builder = Builder :: new (
685+ hir,
686+ ty:: WithOptConstParam :: unknown ( def_id. to_def_id ( ) ) ,
687+ span,
688+ 0 ,
689+ Safety :: Safe ,
690+ const_ty,
691+ const_ty_span,
692+ None
693+ ) ;
689694
690695 let mut block = START_BLOCK ;
691696 let ast_expr = & tcx. hir ( ) . body ( body_id) . value ;
@@ -732,7 +737,16 @@ fn construct_error<'a, 'tcx>(hir: Cx<'a, 'tcx>, body_id: hir::BodyId) -> Body<'t
732737 hir:: BodyOwnerKind :: Const => 0 ,
733738 hir:: BodyOwnerKind :: Static ( _) => 0 ,
734739 } ;
735- let mut builder = Builder :: new ( hir, def_id. to_def_id ( ) , span, num_params, Safety :: Safe , ty, span, None ) ;
740+ let mut builder = Builder :: new (
741+ hir,
742+ ty:: WithOptConstParam :: unknown ( def_id. to_def_id ( ) ) ,
743+ span,
744+ num_params,
745+ Safety :: Safe ,
746+ ty,
747+ span,
748+ None
749+ ) ;
736750 let source_info = builder. source_info ( span) ;
737751 // Some MIR passes will expect the number of parameters to match the
738752 // function declaration.
@@ -750,7 +764,7 @@ fn construct_error<'a, 'tcx>(hir: Cx<'a, 'tcx>, body_id: hir::BodyId) -> Body<'t
750764impl < ' a , ' tcx > Builder < ' a , ' tcx > {
751765 fn new (
752766 hir : Cx < ' a , ' tcx > ,
753- def_id : DefId ,
767+ def : ty :: WithOptConstParam < DefId > ,
754768 span : Span ,
755769 arg_count : usize ,
756770 safety : Safety ,
@@ -761,7 +775,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
761775 let lint_level = LintLevel :: Explicit ( hir. root_lint_level ) ;
762776 let mut builder = Builder {
763777 hir,
764- def_id ,
778+ def ,
765779 cfg : CFG { basic_blocks : IndexVec :: new ( ) } ,
766780 fn_span : span,
767781 arg_count,
@@ -802,7 +816,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
802816 }
803817
804818 Body :: new (
805- MirSource :: item ( self . def_id ) ,
819+ MirSource :: from_instance ( ty :: InstanceDef :: Item ( self . def ) ) ,
806820 self . cfg . basic_blocks ,
807821 self . source_scopes ,
808822 self . local_decls ,
0 commit comments