Skip to content

Commit f083be2

Browse files
committed
Don't generate functions with the rustc_intrinsic_must_be_overridden attribute
1 parent 334e509 commit f083be2

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

compiler/rustc_monomorphize/src/collector.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,11 @@ fn should_codegen_locally<'tcx>(tcx: TyCtxtAt<'tcx>, instance: Instance<'tcx>) -
957957
return false;
958958
}
959959

960+
if tcx.has_attr(instance.def_id(), sym::rustc_intrinsic_must_be_overridden) {
961+
// Functions with the attribute `rustc_intrinsic_must_be_overridden` never be called.
962+
return false;
963+
}
964+
960965
if !tcx.is_mir_available(def_id) {
961966
tcx.dcx().emit_fatal(NoOptimizedMir {
962967
span: tcx.def_span(def_id),
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//@ revisions: OPT0 OPT1
2+
//@ [OPT0] compile-flags: -Copt-level=0
3+
//@ [OPT1] compile-flags: -Copt-level=1
4+
//@ compile-flags: -Cno-prepopulate-passes
5+
6+
#![crate_type = "lib"]
7+
#![feature(core_intrinsics)]
8+
9+
// CHECK-NOT: core::intrinsics::size_of_val
10+
11+
#[no_mangle]
12+
pub unsafe fn size_of_val(ptr: *const i32) -> usize {
13+
core::intrinsics::size_of_val(ptr)
14+
}

0 commit comments

Comments
 (0)