@@ -29,11 +29,7 @@ crate fn mir_built<'tcx>(
29
29
return tcx. mir_built ( def) ;
30
30
}
31
31
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) ;
37
33
38
34
tcx. alloc_steal_mir ( body)
39
35
}
@@ -302,7 +298,7 @@ struct Builder<'a, 'tcx> {
302
298
hir : Cx < ' a , ' tcx > ,
303
299
cfg : CFG < ' tcx > ,
304
300
305
- def_id : DefId ,
301
+ def : ty :: WithOptConstParam < DefId > ,
306
302
fn_span : Span ,
307
303
arg_count : usize ,
308
304
generator_kind : Option < GeneratorKind > ,
@@ -604,7 +600,7 @@ where
604
600
605
601
let mut builder = Builder :: new (
606
602
hir,
607
- fn_def_id. to_def_id ( ) ,
603
+ ty :: WithOptConstParam :: unknown ( fn_def_id. to_def_id ( ) ) ,
608
604
span_with_body,
609
605
arguments. len ( ) ,
610
606
safety,
@@ -685,7 +681,16 @@ fn construct_const<'a, 'tcx>(
685
681
let owner_id = tcx. hir ( ) . body_owner ( body_id) ;
686
682
let def_id = tcx. hir ( ) . local_def_id ( owner_id) ;
687
683
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
+ ) ;
689
694
690
695
let mut block = START_BLOCK ;
691
696
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
732
737
hir:: BodyOwnerKind :: Const => 0 ,
733
738
hir:: BodyOwnerKind :: Static ( _) => 0 ,
734
739
} ;
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
+ ) ;
736
750
let source_info = builder. source_info ( span) ;
737
751
// Some MIR passes will expect the number of parameters to match the
738
752
// function declaration.
@@ -750,7 +764,7 @@ fn construct_error<'a, 'tcx>(hir: Cx<'a, 'tcx>, body_id: hir::BodyId) -> Body<'t
750
764
impl < ' a , ' tcx > Builder < ' a , ' tcx > {
751
765
fn new (
752
766
hir : Cx < ' a , ' tcx > ,
753
- def_id : DefId ,
767
+ def : ty :: WithOptConstParam < DefId > ,
754
768
span : Span ,
755
769
arg_count : usize ,
756
770
safety : Safety ,
@@ -761,7 +775,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
761
775
let lint_level = LintLevel :: Explicit ( hir. root_lint_level ) ;
762
776
let mut builder = Builder {
763
777
hir,
764
- def_id ,
778
+ def ,
765
779
cfg : CFG { basic_blocks : IndexVec :: new ( ) } ,
766
780
fn_span : span,
767
781
arg_count,
@@ -802,7 +816,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
802
816
}
803
817
804
818
Body :: new (
805
- MirSource :: item ( self . def_id ) ,
819
+ MirSource :: from_instance ( ty :: InstanceDef :: Item ( self . def ) ) ,
806
820
self . cfg . basic_blocks ,
807
821
self . source_scopes ,
808
822
self . local_decls ,
0 commit comments