diff options
| author | Michael Goulet <michael@errs.io> | 2024-03-31 22:33:36 -0400 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2024-03-31 22:34:00 -0400 |
| commit | 4ff8a9bd6b64e32703603cf8bc8cb5cb221d4889 (patch) | |
| tree | 9aaaaad86c8ff55e79d9ad0ce0b5bff2acc49086 /compiler/rustc_const_eval/src/interpret/intern.rs | |
| parent | 66de6111960571ab7b030c205b6176801c7ecbfc (diff) | |
| download | rust-4ff8a9bd6b64e32703603cf8bc8cb5cb221d4889.tar.gz rust-4ff8a9bd6b64e32703603cf8bc8cb5cb221d4889.zip | |
Don't inherit codegen attrs from parent static
Diffstat (limited to 'compiler/rustc_const_eval/src/interpret/intern.rs')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/intern.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/intern.rs b/compiler/rustc_const_eval/src/interpret/intern.rs index 58eaef65e55..f4e46c9499e 100644 --- a/compiler/rustc_const_eval/src/interpret/intern.rs +++ b/compiler/rustc_const_eval/src/interpret/intern.rs @@ -18,6 +18,7 @@ use rustc_ast::Mutability; use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; use rustc_errors::ErrorGuaranteed; use rustc_hir as hir; +use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs; use rustc_middle::mir::interpret::{ConstAllocation, CtfeProvenance, InterpResult}; use rustc_middle::query::TyCtxtAt; use rustc_middle::ty::layout::TyAndLayout; @@ -106,13 +107,17 @@ fn intern_as_new_static<'tcx>( DefKind::Static { mutability: alloc.0.mutability, nested: true }, ); tcx.set_nested_alloc_id_static(alloc_id, feed.def_id()); - feed.codegen_fn_attrs(tcx.codegen_fn_attrs(static_id).clone()); + + // These do not inherit the codegen attrs of the parent static allocation, since + // it doesn't make sense for them to inherit their `#[no_mangle]` and `#[link_name = ..]` + // and the like. + feed.codegen_fn_attrs(CodegenFnAttrs::new()); + feed.eval_static_initializer(Ok(alloc)); feed.generics_of(tcx.generics_of(static_id).clone()); feed.def_ident_span(tcx.def_ident_span(static_id)); feed.explicit_predicates_of(tcx.explicit_predicates_of(static_id)); - - feed.feed_hir() + feed.feed_hir(); } /// How a constant value should be interned. |
