Skip to content

Commit adf1717

Browse files
committed
Ensure valid local_data is set for custom mir building
MIR unsafety checking requires this to be valid
1 parent f03c2ae commit adf1717

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

compiler/rustc_mir_build/src/build/custom/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use rustc_ast::Attribute;
2121
use rustc_data_structures::fx::FxHashMap;
2222
use rustc_hir::def_id::DefId;
23+
use rustc_hir::HirId;
2324
use rustc_index::vec::IndexVec;
2425
use rustc_middle::{
2526
mir::*,
@@ -33,6 +34,7 @@ mod parse;
3334
pub(super) fn build_custom_mir<'tcx>(
3435
tcx: TyCtxt<'tcx>,
3536
did: DefId,
37+
hir_id: HirId,
3638
thir: &Thir<'tcx>,
3739
expr: ExprId,
3840
params: &IndexVec<ParamId, Param<'tcx>>,
@@ -67,7 +69,10 @@ pub(super) fn build_custom_mir<'tcx>(
6769
parent_scope: None,
6870
inlined: None,
6971
inlined_parent_scope: None,
70-
local_data: ClearCrossCrate::Clear,
72+
local_data: ClearCrossCrate::Set(SourceScopeLocalData {
73+
lint_root: hir_id,
74+
safety: Safety::Safe,
75+
}),
7176
});
7277
body.injection_phase = Some(parse_attribute(attr));
7378

compiler/rustc_mir_build/src/build/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ fn construct_fn<'tcx>(
487487
return custom::build_custom_mir(
488488
tcx,
489489
fn_def.did.to_def_id(),
490+
fn_id,
490491
thir,
491492
expr,
492493
arguments,

0 commit comments

Comments
 (0)