diff options
| author | Ralf Jung <post@ralfj.de> | 2025-02-23 17:34:50 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2025-02-24 07:53:59 +0100 |
| commit | 6eea027aa9453b685ac636ea40fc826267afab2a (patch) | |
| tree | f5021a6137ff4a0be0a88a92cbee6d5990c4096a /compiler | |
| parent | 5a58a922e21438d70f1be738754dc257cc8c649b (diff) | |
| download | rust-6eea027aa9453b685ac636ea40fc826267afab2a.tar.gz rust-6eea027aa9453b685ac636ea40fc826267afab2a.zip | |
remove support for rustc_intrinsic_must_be_overridden from the compiler
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_codegen_cranelift/example/mini_core.rs | 65 | ||||
| -rw-r--r-- | compiler/rustc_codegen_gcc/example/mini_core.rs | 65 | ||||
| -rw-r--r-- | compiler/rustc_codegen_gcc/tests/run/abort1.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_codegen_gcc/tests/run/abort2.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_codegen_gcc/tests/run/assign.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_codegen_gcc/tests/run/mut_ref.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_codegen_gcc/tests/run/operations.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_codegen_gcc/tests/run/static.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_error_codes/src/error_codes/E0094.md | 14 | ||||
| -rw-r--r-- | compiler/rustc_feature/src/builtin_attrs.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/util.rs | 13 | ||||
| -rw-r--r-- | compiler/rustc_span/src/symbol.rs | 1 |
12 files changed, 41 insertions, 151 deletions
diff --git a/compiler/rustc_codegen_cranelift/example/mini_core.rs b/compiler/rustc_codegen_cranelift/example/mini_core.rs index 79820232496..72c9df59d83 100644 --- a/compiler/rustc_codegen_cranelift/example/mini_core.rs +++ b/compiler/rustc_codegen_cranelift/example/mini_core.rs @@ -620,70 +620,31 @@ pub union MaybeUninit<T> { pub mod intrinsics { #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - pub fn abort() -> ! { - loop {} - } + pub fn abort() -> !; #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - pub fn size_of<T>() -> usize { - loop {} - } + pub fn size_of<T>() -> usize; #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - pub unsafe fn size_of_val<T: ?::Sized>(_val: *const T) -> usize { - loop {} - } + pub unsafe fn size_of_val<T: ?::Sized>(_val: *const T) -> usize; #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - pub fn min_align_of<T>() -> usize { - loop {} - } + pub fn min_align_of<T>() -> usize; #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - pub unsafe fn min_align_of_val<T: ?::Sized>(_val: *const T) -> usize { - loop {} - } + pub unsafe fn min_align_of_val<T: ?::Sized>(_val: *const T) -> usize; #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - pub unsafe fn copy<T>(_src: *const T, _dst: *mut T, _count: usize) { - loop {} - } + pub unsafe fn copy<T>(_src: *const T, _dst: *mut T, _count: usize); #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - pub unsafe fn transmute<T, U>(_e: T) -> U { - loop {} - } + pub unsafe fn transmute<T, U>(_e: T) -> U; #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - pub unsafe fn ctlz_nonzero<T>(_x: T) -> u32 { - loop {} - } + pub unsafe fn ctlz_nonzero<T>(_x: T) -> u32; #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - pub fn needs_drop<T: ?::Sized>() -> bool { - loop {} - } + pub fn needs_drop<T: ?::Sized>() -> bool; #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - pub fn bitreverse<T>(_x: T) -> T { - loop {} - } + pub fn bitreverse<T>(_x: T) -> T; #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - pub fn bswap<T>(_x: T) -> T { - loop {} - } + pub fn bswap<T>(_x: T) -> T; #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - pub unsafe fn write_bytes<T>(_dst: *mut T, _val: u8, _count: usize) { - loop {} - } + pub unsafe fn write_bytes<T>(_dst: *mut T, _val: u8, _count: usize); #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - pub unsafe fn unreachable() -> ! { - loop {} - } + pub unsafe fn unreachable() -> !; } pub mod libc { diff --git a/compiler/rustc_codegen_gcc/example/mini_core.rs b/compiler/rustc_codegen_gcc/example/mini_core.rs index 2ff1d757fd4..3dad35bc4ce 100644 --- a/compiler/rustc_codegen_gcc/example/mini_core.rs +++ b/compiler/rustc_codegen_gcc/example/mini_core.rs @@ -591,70 +591,31 @@ pub union MaybeUninit<T> { pub mod intrinsics { #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - pub fn abort() -> ! { - loop {} - } + pub fn abort() -> !; #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - pub fn size_of<T>() -> usize { - loop {} - } + pub fn size_of<T>() -> usize; #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - pub unsafe fn size_of_val<T: ?::Sized>(_val: *const T) -> usize { - loop {} - } + pub unsafe fn size_of_val<T: ?::Sized>(_val: *const T) -> usize; #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - pub fn min_align_of<T>() -> usize { - loop {} - } + pub fn min_align_of<T>() -> usize; #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - pub unsafe fn min_align_of_val<T: ?::Sized>(_val: *const T) -> usize { - loop {} - } + pub unsafe fn min_align_of_val<T: ?::Sized>(_val: *const T) -> usize; #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - pub unsafe fn copy<T>(_src: *const T, _dst: *mut T, _count: usize) { - loop {} - } + pub unsafe fn copy<T>(_src: *const T, _dst: *mut T, _count: usize); #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - pub unsafe fn transmute<T, U>(_e: T) -> U { - loop {} - } + pub unsafe fn transmute<T, U>(_e: T) -> U; #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - pub unsafe fn ctlz_nonzero<T>(_x: T) -> u32 { - loop {} - } + pub unsafe fn ctlz_nonzero<T>(_x: T) -> u32; #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - pub fn needs_drop<T: ?::Sized>() -> bool { - loop {} - } + pub fn needs_drop<T: ?::Sized>() -> bool; #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - pub fn bitreverse<T>(_x: T) -> T { - loop {} - } + pub fn bitreverse<T>(_x: T) -> T; #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - pub fn bswap<T>(_x: T) -> T { - loop {} - } + pub fn bswap<T>(_x: T) -> T; #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - pub unsafe fn write_bytes<T>(_dst: *mut T, _val: u8, _count: usize) { - loop {} - } + pub unsafe fn write_bytes<T>(_dst: *mut T, _val: u8, _count: usize); #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - pub unsafe fn unreachable() -> ! { - loop {} - } + pub unsafe fn unreachable() -> !; } pub mod libc { diff --git a/compiler/rustc_codegen_gcc/tests/run/abort1.rs b/compiler/rustc_codegen_gcc/tests/run/abort1.rs index 385e41a6881..fe46d9ae418 100644 --- a/compiler/rustc_codegen_gcc/tests/run/abort1.rs +++ b/compiler/rustc_codegen_gcc/tests/run/abort1.rs @@ -36,10 +36,7 @@ mod intrinsics { #[rustc_nounwind] #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - pub fn abort() -> ! { - loop {} - } + pub fn abort() -> !; } /* diff --git a/compiler/rustc_codegen_gcc/tests/run/abort2.rs b/compiler/rustc_codegen_gcc/tests/run/abort2.rs index 6c66a930e07..4123f4f4bee 100644 --- a/compiler/rustc_codegen_gcc/tests/run/abort2.rs +++ b/compiler/rustc_codegen_gcc/tests/run/abort2.rs @@ -36,10 +36,7 @@ mod intrinsics { #[rustc_nounwind] #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - pub fn abort() -> ! { - loop {} - } + pub fn abort() -> !; } /* diff --git a/compiler/rustc_codegen_gcc/tests/run/assign.rs b/compiler/rustc_codegen_gcc/tests/run/assign.rs index 4d414c577a6..286155852d5 100644 --- a/compiler/rustc_codegen_gcc/tests/run/assign.rs +++ b/compiler/rustc_codegen_gcc/tests/run/assign.rs @@ -59,10 +59,7 @@ mod libc { mod intrinsics { #[rustc_nounwind] #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - pub fn abort() -> ! { - loop {} - } + pub fn abort() -> !; } #[lang = "panic"] diff --git a/compiler/rustc_codegen_gcc/tests/run/mut_ref.rs b/compiler/rustc_codegen_gcc/tests/run/mut_ref.rs index 9be64f991ee..b0215860406 100644 --- a/compiler/rustc_codegen_gcc/tests/run/mut_ref.rs +++ b/compiler/rustc_codegen_gcc/tests/run/mut_ref.rs @@ -61,10 +61,7 @@ mod libc { mod intrinsics { #[rustc_nounwind] #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - pub fn abort() -> ! { - loop {} - } + pub fn abort() -> !; } #[lang = "panic"] diff --git a/compiler/rustc_codegen_gcc/tests/run/operations.rs b/compiler/rustc_codegen_gcc/tests/run/operations.rs index c92d3cc0b8f..8ba7a4c5ed8 100644 --- a/compiler/rustc_codegen_gcc/tests/run/operations.rs +++ b/compiler/rustc_codegen_gcc/tests/run/operations.rs @@ -67,10 +67,7 @@ mod libc { mod intrinsics { #[rustc_nounwind] #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - pub fn abort() -> ! { - loop {} - } + pub fn abort() -> !; } #[lang = "panic"] diff --git a/compiler/rustc_codegen_gcc/tests/run/static.rs b/compiler/rustc_codegen_gcc/tests/run/static.rs index 80c8782c4b1..c3c8121b1e1 100644 --- a/compiler/rustc_codegen_gcc/tests/run/static.rs +++ b/compiler/rustc_codegen_gcc/tests/run/static.rs @@ -49,10 +49,7 @@ mod intrinsics { #[rustc_nounwind] #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - pub fn abort() -> ! { - loop {} - } + pub fn abort() -> !; } mod libc { diff --git a/compiler/rustc_error_codes/src/error_codes/E0094.md b/compiler/rustc_error_codes/src/error_codes/E0094.md index efbfa0851a8..909da368f2b 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0094.md +++ b/compiler/rustc_error_codes/src/error_codes/E0094.md @@ -7,12 +7,8 @@ Erroneous code example: #![allow(internal_features)] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -fn size_of<T, U>() -> usize // error: intrinsic has wrong number - // of type parameters -{ - loop {} -} +fn size_of<T, U>() -> usize; // error: intrinsic has wrong number + // of type parameters ``` Please check that you provided the right number of type parameters @@ -24,9 +20,5 @@ Example: #![allow(internal_features)] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -fn size_of<T>() -> usize // ok! -{ - loop {} -} +fn size_of<T>() -> usize; // ok! ``` diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index b2ada8fe61e..6d16dc00ef4 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -1005,10 +1005,6 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ rustc_intrinsic, Normal, template!(Word), ErrorFollowing, EncodeCrossCrate::Yes, intrinsics, "the `#[rustc_intrinsic]` attribute is used to declare intrinsics as function items", ), - gated!( - rustc_intrinsic_must_be_overridden, Normal, template!(Word), ErrorFollowing, EncodeCrossCrate::Yes, intrinsics, - "the `#[rustc_intrinsic_must_be_overridden]` attribute is used to declare intrinsics without real bodies", - ), rustc_attr!( rustc_no_mir_inline, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::Yes, "#[rustc_no_mir_inline] prevents the MIR inliner from inlining a function while not affecting codegen" diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index 88d57498542..c153f6bb7d7 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -1755,13 +1755,12 @@ pub fn intrinsic_raw(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<ty::Intrinsi && (matches!(tcx.fn_sig(def_id).skip_binder().abi(), ExternAbi::RustIntrinsic) || tcx.has_attr(def_id, sym::rustc_intrinsic)) { - let must_be_overridden = tcx.has_attr(def_id, sym::rustc_intrinsic_must_be_overridden) - || match tcx.hir_node_by_def_id(def_id) { - hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn { has_body, .. }, .. }) => { - !has_body - } - _ => true, - }; + let must_be_overridden = match tcx.hir_node_by_def_id(def_id) { + hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn { has_body, .. }, .. }) => { + !has_body + } + _ => true, + }; Some(ty::IntrinsicDef { name: tcx.item_name(def_id.into()), must_be_overridden, diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 10c79b1be82..e5457991e46 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1764,7 +1764,6 @@ symbols! { rustc_insignificant_dtor, rustc_intrinsic, rustc_intrinsic_const_stable_indirect, - rustc_intrinsic_must_be_overridden, rustc_layout, rustc_layout_scalar_valid_range_end, rustc_layout_scalar_valid_range_start, |
