about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2024-11-01 22:19:42 +0100
committerRalf Jung <post@ralfj.de>2024-11-04 23:27:45 +0100
commit10723c28964d582814ea8e07dbd8fa7367e0eaee (patch)
tree425157ebf9ee29e2fed5476e5bbbc4d5f4579c6c
parent7934f26613980e2dfed24551e816601b8a74879b (diff)
downloadrust-10723c28964d582814ea8e07dbd8fa7367e0eaee.tar.gz
rust-10723c28964d582814ea8e07dbd8fa7367e0eaee.zip
remove support for extern-block const intrinsics
-rw-r--r--compiler/rustc_attr/src/builtin.rs10
-rw-r--r--compiler/rustc_const_eval/src/const_eval/fn_queries.rs12
-rw-r--r--compiler/rustc_passes/src/stability.rs15
-rw-r--r--tests/rustdoc/const-intrinsic.rs28
-rw-r--r--tests/ui/closures/coerce-unsafe-to-closure.stderr4
-rw-r--r--tests/ui/consts/auxiliary/unstable_intrinsic.rs31
-rw-r--r--tests/ui/consts/const-eval/simd/insert_extract.rs20
-rw-r--r--tests/ui/consts/const-unstable-intrinsic.rs54
-rw-r--r--tests/ui/consts/const-unstable-intrinsic.stderr99
-rw-r--r--tests/ui/consts/copy-intrinsic.rs20
-rw-r--r--tests/ui/consts/copy-intrinsic.stderr8
-rw-r--r--tests/ui/intrinsics/reify-intrinsic.stderr4
-rw-r--r--tests/ui/repr/16-bit-repr-c-enum.rs11
-rw-r--r--tests/ui/stability-attribute/missing-const-stability.rs6
-rw-r--r--tests/ui/target-feature/feature-hierarchy.rs10
-rw-r--r--tests/ui/target-feature/no-llvm-leaks.rs10
16 files changed, 118 insertions, 224 deletions
diff --git a/compiler/rustc_attr/src/builtin.rs b/compiler/rustc_attr/src/builtin.rs
index 6af75bc94bb..2753ac529d1 100644
--- a/compiler/rustc_attr/src/builtin.rs
+++ b/compiler/rustc_attr/src/builtin.rs
@@ -273,8 +273,7 @@ pub fn find_stability(
 /// Collects stability info from `rustc_const_stable`/`rustc_const_unstable`/`rustc_promotable`
 /// attributes in `attrs`. Returns `None` if no stability attributes are found.
 ///
-/// `is_const_fn` indicates whether this is a function marked as `const`. It will always
-/// be false for intrinsics in an `extern` block!
+/// `is_const_fn` indicates whether this is a function marked as `const`.
 pub fn find_const_stability(
     sess: &Session,
     attrs: &[Attribute],
@@ -330,7 +329,7 @@ pub fn find_const_stability(
         }
     }
 
-    // Merge promotable and not_exposed_on_stable into stability info
+    // Merge promotable and const_stable_indirect into stability info
     if promotable {
         match &mut const_stab {
             Some((stab, _)) => stab.promotable = promotable,
@@ -352,10 +351,7 @@ pub fn find_const_stability(
                     })
                 }
             }
-            _ => {
-                // We ignore the `#[rustc_const_stable_indirect]` here, it should be picked up by
-                // the `default_const_unstable` logic.
-            }
+            _ => {}
         }
     }
     // Make sure if `const_stable_indirect` is present, that is recorded. Also make sure all `const
diff --git a/compiler/rustc_const_eval/src/const_eval/fn_queries.rs b/compiler/rustc_const_eval/src/const_eval/fn_queries.rs
index 037fdcbcf9b..beff0cd99fc 100644
--- a/compiler/rustc_const_eval/src/const_eval/fn_queries.rs
+++ b/compiler/rustc_const_eval/src/const_eval/fn_queries.rs
@@ -25,15 +25,9 @@ fn constness(tcx: TyCtxt<'_>, def_id: LocalDefId) -> hir::Constness {
             hir::Constness::Const
         }
         hir::Node::Item(hir::Item { kind: hir::ItemKind::Impl(impl_), .. }) => impl_.constness,
-        hir::Node::ForeignItem(hir::ForeignItem { kind: hir::ForeignItemKind::Fn(..), .. }) => {
-            // Intrinsics use `rustc_const_{un,}stable` attributes to indicate constness. All other
-            // foreign items cannot be evaluated at compile-time.
-            let is_const = if tcx.intrinsic(def_id).is_some() {
-                tcx.lookup_const_stability(def_id).is_some()
-            } else {
-                false
-            };
-            if is_const { hir::Constness::Const } else { hir::Constness::NotConst }
+        hir::Node::ForeignItem(_) => {
+            // Foreign items cannot be evaluated at compile-time.
+            hir::Constness::NotConst
         }
         hir::Node::Expr(e) if let hir::ExprKind::Closure(c) = e.kind => c.constness,
         _ => {
diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs
index 737e163efce..cd47c8ece60 100644
--- a/compiler/rustc_passes/src/stability.rs
+++ b/compiler/rustc_passes/src/stability.rs
@@ -106,7 +106,6 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
         def_id: LocalDefId,
         item_sp: Span,
         fn_sig: Option<&'tcx hir::FnSig<'tcx>>,
-        is_foreign_item: bool,
         kind: AnnotationKind,
         inherit_deprecation: InheritDeprecation,
         inherit_const_stability: InheritConstStability,
@@ -175,11 +174,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
         // implied), check if the function/method is const or the parent impl block is const.
         if let Some(fn_sig) = fn_sig
             && !fn_sig.header.is_const()
-            // We have to exclude foreign items as they might be intrinsics. Sadly we can't check
-            // their ABI; `fn_sig.abi` is *not* correct for foreign functions.
-            && !is_foreign_item
             && const_stab.is_some()
-            && (!self.in_trait_impl || !self.tcx.is_const_fn(def_id.to_def_id()))
         {
             self.tcx.dcx().emit_err(errors::MissingConstErr { fn_sig_span: fn_sig.span });
         }
@@ -398,7 +393,6 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
                         ctor_def_id,
                         i.span,
                         None,
-                        /* is_foreign_item */ false,
                         AnnotationKind::Required,
                         InheritDeprecation::Yes,
                         InheritConstStability::No,
@@ -417,7 +411,6 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
             i.owner_id.def_id,
             i.span,
             fn_sig,
-            /* is_foreign_item */ false,
             kind,
             InheritDeprecation::Yes,
             const_stab_inherit,
@@ -437,7 +430,6 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
             ti.owner_id.def_id,
             ti.span,
             fn_sig,
-            /* is_foreign_item */ false,
             AnnotationKind::Required,
             InheritDeprecation::Yes,
             InheritConstStability::No,
@@ -461,7 +453,6 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
             ii.owner_id.def_id,
             ii.span,
             fn_sig,
-            /* is_foreign_item */ false,
             kind,
             InheritDeprecation::Yes,
             InheritConstStability::No,
@@ -477,7 +468,6 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
             var.def_id,
             var.span,
             None,
-            /* is_foreign_item */ false,
             AnnotationKind::Required,
             InheritDeprecation::Yes,
             InheritConstStability::No,
@@ -488,7 +478,6 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
                         ctor_def_id,
                         var.span,
                         None,
-                        /* is_foreign_item */ false,
                         AnnotationKind::Required,
                         InheritDeprecation::Yes,
                         InheritConstStability::No,
@@ -507,7 +496,6 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
             s.def_id,
             s.span,
             None,
-            /* is_foreign_item */ false,
             AnnotationKind::Required,
             InheritDeprecation::Yes,
             InheritConstStability::No,
@@ -527,7 +515,6 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
             i.owner_id.def_id,
             i.span,
             fn_sig,
-            /* is_foreign_item */ true,
             AnnotationKind::Required,
             InheritDeprecation::Yes,
             InheritConstStability::No,
@@ -550,7 +537,6 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
             p.def_id,
             p.span,
             None,
-            /* is_foreign_item */ false,
             kind,
             InheritDeprecation::No,
             InheritConstStability::No,
@@ -712,7 +698,6 @@ fn stability_index(tcx: TyCtxt<'_>, (): ()) -> Index {
             CRATE_DEF_ID,
             tcx.hir().span(CRATE_HIR_ID),
             None,
-            /* is_foreign_item */ false,
             AnnotationKind::Required,
             InheritDeprecation::Yes,
             InheritConstStability::No,
diff --git a/tests/rustdoc/const-intrinsic.rs b/tests/rustdoc/const-intrinsic.rs
index 520e253469c..8444d4a3aa7 100644
--- a/tests/rustdoc/const-intrinsic.rs
+++ b/tests/rustdoc/const-intrinsic.rs
@@ -1,20 +1,26 @@
-#![feature(intrinsics)]
+#![feature(intrinsics, rustc_attrs)]
 #![feature(staged_api)]
 
 #![crate_name = "foo"]
 #![stable(since="1.0.0", feature="rust1")]
 
-extern "rust-intrinsic" {
-    //@ has 'foo/fn.transmute.html'
-    //@ has - '//pre[@class="rust item-decl"]' 'pub const unsafe extern "rust-intrinsic" fn transmute<T, U>(_: T) -> U'
-    #[stable(since="1.0.0", feature="rust1")]
-    #[rustc_const_stable(feature = "const_transmute", since = "1.56.0")]
-    pub fn transmute<T, U>(_: T) -> U;
+//@ has 'foo/fn.transmute.html'
+//@ has - '//pre[@class="rust item-decl"]' 'pub const unsafe fn transmute<T, U>(_: T) -> U'
+#[stable(since="1.0.0", feature="rust1")]
+#[rustc_const_stable(feature = "const_transmute", since = "1.56.0")]
+#[rustc_intrinsic]
+#[rustc_intrinsic_must_be_overridden]
+pub const unsafe fn transmute<T, U>(_: T) -> U {
+    loop {}
+}
 
-    //@ has 'foo/fn.unreachable.html'
-    //@ has - '//pre[@class="rust item-decl"]' 'pub unsafe extern "rust-intrinsic" fn unreachable() -> !'
-    #[stable(since="1.0.0", feature="rust1")]
-    pub fn unreachable() -> !;
+//@ has 'foo/fn.unreachable.html'
+//@ has - '//pre[@class="rust item-decl"]' 'pub unsafe fn unreachable() -> !'
+#[stable(since="1.0.0", feature="rust1")]
+#[rustc_intrinsic]
+#[rustc_intrinsic_must_be_overridden]
+pub unsafe fn unreachable() -> ! {
+    loop {}
 }
 
 extern "C" {
diff --git a/tests/ui/closures/coerce-unsafe-to-closure.stderr b/tests/ui/closures/coerce-unsafe-to-closure.stderr
index 2538fc0361c..013b9009da4 100644
--- a/tests/ui/closures/coerce-unsafe-to-closure.stderr
+++ b/tests/ui/closures/coerce-unsafe-to-closure.stderr
@@ -1,4 +1,4 @@
-error[E0277]: expected a `FnOnce(&str)` closure, found `unsafe extern "rust-intrinsic" fn(_) -> _ {std::intrinsics::transmute::<_, _>}`
+error[E0277]: expected a `FnOnce(&str)` closure, found `unsafe fn(_) -> _ {std::intrinsics::transmute::<_, _>}`
   --> $DIR/coerce-unsafe-to-closure.rs:2:44
    |
 LL |     let x: Option<&[u8]> = Some("foo").map(std::mem::transmute);
@@ -6,7 +6,7 @@ LL |     let x: Option<&[u8]> = Some("foo").map(std::mem::transmute);
    |                                        |
    |                                        required by a bound introduced by this call
    |
-   = help: the trait `FnOnce(&str)` is not implemented for fn item `unsafe extern "rust-intrinsic" fn(_) -> _ {std::intrinsics::transmute::<_, _>}`
+   = help: the trait `FnOnce(&str)` is not implemented for fn item `unsafe fn(_) -> _ {std::intrinsics::transmute::<_, _>}`
    = note: unsafe function cannot be called generically without an unsafe block
 note: required by a bound in `Option::<T>::map`
   --> $SRC_DIR/core/src/option.rs:LL:COL
diff --git a/tests/ui/consts/auxiliary/unstable_intrinsic.rs b/tests/ui/consts/auxiliary/unstable_intrinsic.rs
index edef499dbb1..0749e7e6df8 100644
--- a/tests/ui/consts/auxiliary/unstable_intrinsic.rs
+++ b/tests/ui/consts/auxiliary/unstable_intrinsic.rs
@@ -1,26 +1,11 @@
 #![feature(staged_api, rustc_attrs, intrinsics)]
 #![stable(since="1.0.0", feature = "stable")]
 
-#[stable(since="1.0.0", feature = "stable")]
-pub mod old_way {
-    extern "rust-intrinsic" {
-        #[unstable(feature = "unstable", issue = "42")]
-        pub fn size_of_val<T>(x: *const T) -> usize;
-
-        #[unstable(feature = "unstable", issue = "42")]
-        #[rustc_const_unstable(feature = "unstable", issue = "42")]
-        pub fn min_align_of_val<T>(x: *const T) -> usize;
-    }
-}
-
-#[stable(since="1.0.0", feature = "stable")]
-pub mod new_way {
-    #[unstable(feature = "unstable", issue = "42")]
-    #[rustc_intrinsic]
-    pub const unsafe fn size_of_val<T>(x: *const T) -> usize { 42 }
-
-    #[unstable(feature = "unstable", issue = "42")]
-    #[rustc_const_unstable(feature = "unstable", issue = "42")]
-    #[rustc_intrinsic]
-    pub const unsafe fn min_align_of_val<T>(x: *const T) -> usize { 42 }
-}
+#[unstable(feature = "unstable", issue = "42")]
+#[rustc_intrinsic]
+pub const unsafe fn size_of_val<T>(x: *const T) -> usize { 42 }
+
+#[unstable(feature = "unstable", issue = "42")]
+#[rustc_const_unstable(feature = "unstable", issue = "42")]
+#[rustc_intrinsic]
+pub const unsafe fn min_align_of_val<T>(x: *const T) -> usize { 42 }
diff --git a/tests/ui/consts/const-eval/simd/insert_extract.rs b/tests/ui/consts/const-eval/simd/insert_extract.rs
index 57d4b4888ca..e5873ea26e8 100644
--- a/tests/ui/consts/const-eval/simd/insert_extract.rs
+++ b/tests/ui/consts/const-eval/simd/insert_extract.rs
@@ -1,6 +1,6 @@
 //@ run-pass
 #![feature(repr_simd)]
-#![feature(intrinsics)]
+#![feature(intrinsics, rustc_attrs)]
 #![feature(staged_api)]
 #![stable(feature = "foo", since = "1.3.37")]
 #![allow(non_camel_case_types)]
@@ -10,14 +10,18 @@
 #[repr(simd)] struct u16x2([u16; 2]);
 #[repr(simd)] struct f32x4([f32; 4]);
 
-extern "rust-intrinsic" {
-    #[stable(feature = "foo", since = "1.3.37")]
-    #[rustc_const_stable(feature = "foo", since = "1.3.37")]
-    fn simd_insert<T, U>(x: T, idx: u32, val: U) -> T;
+#[stable(feature = "foo", since = "1.3.37")]
+#[rustc_const_stable(feature = "foo", since = "1.3.37")]
+#[rustc_intrinsic]
+const unsafe fn simd_insert<T, U>(_x: T, _idx: u32, _val: U) -> T {
+    unimplemented!()
+}
 
-    #[stable(feature = "foo", since = "1.3.37")]
-    #[rustc_const_stable(feature = "foo", since = "1.3.37")]
-    fn simd_extract<T, U>(x: T, idx: u32) -> U;
+#[stable(feature = "foo", since = "1.3.37")]
+#[rustc_const_stable(feature = "foo", since = "1.3.37")]
+#[rustc_intrinsic]
+const unsafe fn simd_extract<T, U>(_x: T, _idx: u32) -> U {
+    unimplemented!()
 }
 
 fn main() {
diff --git a/tests/ui/consts/const-unstable-intrinsic.rs b/tests/ui/consts/const-unstable-intrinsic.rs
index 5d43cdf5da6..fbe491e0671 100644
--- a/tests/ui/consts/const-unstable-intrinsic.rs
+++ b/tests/ui/consts/const-unstable-intrinsic.rs
@@ -14,63 +14,39 @@ fn main() {
 const fn const_main() {
     let x = 42;
     unsafe {
-        unstable_intrinsic::old_way::size_of_val(&x);
-        //~^ERROR: unstable library feature `unstable`
-        //~|ERROR: cannot call non-const intrinsic
-        unstable_intrinsic::old_way::min_align_of_val(&x);
-        //~^ERROR: unstable library feature `unstable`
-        //~|ERROR: not yet stable as a const intrinsic
-        unstable_intrinsic::new_way::size_of_val(&x);
+        unstable_intrinsic::size_of_val(&x);
         //~^ERROR: unstable library feature `unstable`
         //~|ERROR: cannot be (indirectly) exposed to stable
-        unstable_intrinsic::new_way::min_align_of_val(&x);
+        unstable_intrinsic::min_align_of_val(&x);
         //~^ERROR: unstable library feature `unstable`
         //~|ERROR: not yet stable as a const intrinsic
 
-        old_way::size_of_val(&x);
-        //~^ERROR: cannot call non-const intrinsic
-        old_way::min_align_of_val(&x);
-        //~^ERROR: cannot use `#[feature(local)]`
-        new_way::size_of_val(&x);
+        size_of_val(&x);
         //~^ERROR: cannot be (indirectly) exposed to stable
-        new_way::min_align_of_val(&x);
+        min_align_of_val(&x);
         //~^ERROR: cannot use `#[feature(local)]`
     }
 }
 
-#[stable(since="1.0.0", feature = "stable")]
-pub mod old_way {
-    extern "rust-intrinsic" {
-        #[unstable(feature = "local", issue = "42")]
-        pub fn size_of_val<T>(x: *const T) -> usize;
-
-        #[unstable(feature = "local", issue = "42")]
-        #[rustc_const_unstable(feature = "local", issue = "42")]
-        pub fn min_align_of_val<T>(x: *const T) -> usize;
-    }
-}
-
-#[stable(since="1.0.0", feature = "stable")]
-pub mod new_way {
-    #[unstable(feature = "local", issue = "42")]
-    #[rustc_intrinsic]
-    pub const unsafe fn size_of_val<T>(x: *const T) -> usize { 42 }
+#[unstable(feature = "local", issue = "42")]
+#[rustc_intrinsic]
+pub const unsafe fn size_of_val<T>(x: *const T) -> usize { 42 }
 
-    #[unstable(feature = "local", issue = "42")]
-    #[rustc_const_unstable(feature = "local", issue = "42")]
-    #[rustc_intrinsic]
-    pub const unsafe fn min_align_of_val<T>(x: *const T) -> usize { 42 }
-}
+#[unstable(feature = "local", issue = "42")]
+#[rustc_const_unstable(feature = "local", issue = "42")]
+#[rustc_intrinsic]
+pub const unsafe fn min_align_of_val<T>(x: *const T) -> usize { 42 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
 #[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
 #[inline]
 pub const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
     // Const stability attributes are not inherited from parent items.
-    extern "rust-intrinsic" {
-        fn copy<T>(src: *const T, dst: *mut T, count: usize);
+    #[rustc_intrinsic]
+    const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
+        unimplemented!()
     }
 
     unsafe { copy(src, dst, count) }
-    //~^ ERROR cannot call non-const intrinsic
+    //~^ ERROR cannot be (indirectly) exposed to stable
 }
diff --git a/tests/ui/consts/const-unstable-intrinsic.stderr b/tests/ui/consts/const-unstable-intrinsic.stderr
index c2e38f54dc6..a997379663d 100644
--- a/tests/ui/consts/const-unstable-intrinsic.stderr
+++ b/tests/ui/consts/const-unstable-intrinsic.stderr
@@ -1,8 +1,8 @@
 error[E0658]: use of unstable library feature `unstable`
   --> $DIR/const-unstable-intrinsic.rs:17:9
    |
-LL |         unstable_intrinsic::old_way::size_of_val(&x);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |         unstable_intrinsic::size_of_val(&x);
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: see issue #42 <https://github.com/rust-lang/rust/issues/42> for more information
    = help: add `#![feature(unstable)]` to the crate attributes to enable
@@ -11,99 +11,42 @@ LL |         unstable_intrinsic::old_way::size_of_val(&x);
 error[E0658]: use of unstable library feature `unstable`
   --> $DIR/const-unstable-intrinsic.rs:20:9
    |
-LL |         unstable_intrinsic::old_way::min_align_of_val(&x);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = note: see issue #42 <https://github.com/rust-lang/rust/issues/42> for more information
-   = help: add `#![feature(unstable)]` to the crate attributes to enable
-   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
-
-error[E0658]: use of unstable library feature `unstable`
-  --> $DIR/const-unstable-intrinsic.rs:23:9
-   |
-LL |         unstable_intrinsic::new_way::size_of_val(&x);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = note: see issue #42 <https://github.com/rust-lang/rust/issues/42> for more information
-   = help: add `#![feature(unstable)]` to the crate attributes to enable
-   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
-
-error[E0658]: use of unstable library feature `unstable`
-  --> $DIR/const-unstable-intrinsic.rs:26:9
-   |
-LL |         unstable_intrinsic::new_way::min_align_of_val(&x);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |         unstable_intrinsic::min_align_of_val(&x);
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: see issue #42 <https://github.com/rust-lang/rust/issues/42> for more information
    = help: add `#![feature(unstable)]` to the crate attributes to enable
    = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
 
-error: cannot call non-const intrinsic `size_of_val` in constant functions
+error: intrinsic `unstable_intrinsic::size_of_val` cannot be (indirectly) exposed to stable
   --> $DIR/const-unstable-intrinsic.rs:17:9
    |
-LL |         unstable_intrinsic::old_way::size_of_val(&x);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error: `min_align_of_val` is not yet stable as a const intrinsic
-  --> $DIR/const-unstable-intrinsic.rs:20:9
-   |
-LL |         unstable_intrinsic::old_way::min_align_of_val(&x);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = help: add `#![feature(unstable)]` to the crate attributes to enable
-
-error: intrinsic `unstable_intrinsic::new_way::size_of_val` cannot be (indirectly) exposed to stable
-  --> $DIR/const-unstable-intrinsic.rs:23:9
-   |
-LL |         unstable_intrinsic::new_way::size_of_val(&x);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |         unstable_intrinsic::size_of_val(&x);
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: mark the caller as `#[rustc_const_unstable]`, or mark the intrinsic `#[rustc_const_stable_indirect]` (but this requires team approval)
 
 error: `min_align_of_val` is not yet stable as a const intrinsic
-  --> $DIR/const-unstable-intrinsic.rs:26:9
+  --> $DIR/const-unstable-intrinsic.rs:20:9
    |
-LL |         unstable_intrinsic::new_way::min_align_of_val(&x);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |         unstable_intrinsic::min_align_of_val(&x);
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: add `#![feature(unstable)]` to the crate attributes to enable
 
-error: cannot call non-const intrinsic `size_of_val` in constant functions
-  --> $DIR/const-unstable-intrinsic.rs:30:9
-   |
-LL |         old_way::size_of_val(&x);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^
-
-error: const function that might be (indirectly) exposed to stable cannot use `#[feature(local)]`
-  --> $DIR/const-unstable-intrinsic.rs:32:9
-   |
-LL |         old_way::min_align_of_val(&x);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-help: if the function is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do)
+error: intrinsic `size_of_val` cannot be (indirectly) exposed to stable
+  --> $DIR/const-unstable-intrinsic.rs:24:9
    |
-LL + #[rustc_const_unstable(feature = "...", issue = "...")]
-LL | const fn const_main() {
-   |
-help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (this requires team approval)
-   |
-LL + #[rustc_allow_const_fn_unstable(local)]
-LL | const fn const_main() {
-   |
-
-error: intrinsic `new_way::size_of_val` cannot be (indirectly) exposed to stable
-  --> $DIR/const-unstable-intrinsic.rs:34:9
-   |
-LL |         new_way::size_of_val(&x);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^
+LL |         size_of_val(&x);
+   |         ^^^^^^^^^^^^^^^
    |
    = help: mark the caller as `#[rustc_const_unstable]`, or mark the intrinsic `#[rustc_const_stable_indirect]` (but this requires team approval)
 
 error: const function that might be (indirectly) exposed to stable cannot use `#[feature(local)]`
-  --> $DIR/const-unstable-intrinsic.rs:36:9
+  --> $DIR/const-unstable-intrinsic.rs:26:9
    |
-LL |         new_way::min_align_of_val(&x);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |         min_align_of_val(&x);
+   |         ^^^^^^^^^^^^^^^^^^^^
    |
 help: if the function is not (yet) meant to be exposed to stable, add `#[rustc_const_unstable]` (this is what you probably want to do)
    |
@@ -116,12 +59,14 @@ LL + #[rustc_allow_const_fn_unstable(local)]
 LL | const fn const_main() {
    |
 
-error: cannot call non-const intrinsic `copy` in constant functions
-  --> $DIR/const-unstable-intrinsic.rs:74:14
+error: intrinsic `copy::copy` cannot be (indirectly) exposed to stable
+  --> $DIR/const-unstable-intrinsic.rs:50:14
    |
 LL |     unsafe { copy(src, dst, count) }
    |              ^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: mark the caller as `#[rustc_const_unstable]`, or mark the intrinsic `#[rustc_const_stable_indirect]` (but this requires team approval)
 
-error: aborting due to 13 previous errors
+error: aborting due to 7 previous errors
 
 For more information about this error, try `rustc --explain E0658`.
diff --git a/tests/ui/consts/copy-intrinsic.rs b/tests/ui/consts/copy-intrinsic.rs
index 62917c0b98b..08fbcc107e7 100644
--- a/tests/ui/consts/copy-intrinsic.rs
+++ b/tests/ui/consts/copy-intrinsic.rs
@@ -1,17 +1,21 @@
 #![stable(feature = "dummy", since = "1.0.0")]
 
 // ignore-tidy-linelength
-#![feature(intrinsics, staged_api)]
+#![feature(intrinsics, staged_api, rustc_attrs)]
 use std::mem;
 
-extern "rust-intrinsic" {
-    #[stable(feature = "dummy", since = "1.0.0")]
-    #[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
-    fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize);
+#[stable(feature = "dummy", since = "1.0.0")]
+#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
+#[rustc_intrinsic]
+const unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize) {
+    unimplemented!()
+}
 
-    #[stable(feature = "dummy", since = "1.0.0")]
-    #[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
-    fn copy<T>(src: *const T, dst: *mut T, count: usize);
+#[stable(feature = "dummy", since = "1.0.0")]
+#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
+#[rustc_intrinsic]
+const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
+    unimplemented!()
 }
 
 const COPY_ZERO: () = unsafe {
diff --git a/tests/ui/consts/copy-intrinsic.stderr b/tests/ui/consts/copy-intrinsic.stderr
index 29a88f6270b..41af3a2cd2d 100644
--- a/tests/ui/consts/copy-intrinsic.stderr
+++ b/tests/ui/consts/copy-intrinsic.stderr
@@ -1,23 +1,23 @@
 error[E0080]: evaluation of constant value failed
-  --> $DIR/copy-intrinsic.rs:30:5
+  --> $DIR/copy-intrinsic.rs:34:5
    |
 LL |     copy_nonoverlapping(0x100 as *const i32, dangle, 1);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got 0x100[noalloc] which is a dangling pointer (it has no provenance)
 
 error[E0080]: evaluation of constant value failed
-  --> $DIR/copy-intrinsic.rs:39:5
+  --> $DIR/copy-intrinsic.rs:43:5
    |
 LL |     copy_nonoverlapping(dangle, 0x100 as *mut i32, 1);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got ALLOC0+0x28 which is at or beyond the end of the allocation of size 4 bytes
 
 error[E0080]: evaluation of constant value failed
-  --> $DIR/copy-intrinsic.rs:46:5
+  --> $DIR/copy-intrinsic.rs:50:5
    |
 LL |     copy(&x, &mut y, 1usize << (mem::size_of::<usize>() * 8 - 1));
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow computing total size of `copy`
 
 error[E0080]: evaluation of constant value failed
-  --> $DIR/copy-intrinsic.rs:52:5
+  --> $DIR/copy-intrinsic.rs:56:5
    |
 LL |     copy_nonoverlapping(&x, &mut y, 1usize << (mem::size_of::<usize>() * 8 - 1));
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow computing total size of `copy_nonoverlapping`
diff --git a/tests/ui/intrinsics/reify-intrinsic.stderr b/tests/ui/intrinsics/reify-intrinsic.stderr
index 21b7bf4e1cb..7af17147f28 100644
--- a/tests/ui/intrinsics/reify-intrinsic.stderr
+++ b/tests/ui/intrinsics/reify-intrinsic.stderr
@@ -7,9 +7,9 @@ LL |     let _: unsafe extern "rust-intrinsic" fn(isize) -> usize = std::mem::tr
    |            expected due to this
    |
    = note: expected fn pointer `unsafe extern "rust-intrinsic" fn(isize) -> usize`
-                 found fn item `unsafe extern "rust-intrinsic" fn(_) -> _ {std::intrinsics::transmute::<_, _>}`
+                 found fn item `unsafe fn(_) -> _ {std::intrinsics::transmute::<_, _>}`
 
-error[E0606]: casting `unsafe extern "rust-intrinsic" fn(_) -> _ {std::intrinsics::transmute::<_, _>}` as `unsafe extern "rust-intrinsic" fn(isize) -> usize` is invalid
+error[E0606]: casting `unsafe fn(_) -> _ {std::intrinsics::transmute::<_, _>}` as `unsafe extern "rust-intrinsic" fn(isize) -> usize` is invalid
   --> $DIR/reify-intrinsic.rs:11:13
    |
 LL |     let _ = std::mem::transmute as unsafe extern "rust-intrinsic" fn(isize) -> usize;
diff --git a/tests/ui/repr/16-bit-repr-c-enum.rs b/tests/ui/repr/16-bit-repr-c-enum.rs
index 2509416ad87..2b6bbf12650 100644
--- a/tests/ui/repr/16-bit-repr-c-enum.rs
+++ b/tests/ui/repr/16-bit-repr-c-enum.rs
@@ -21,11 +21,12 @@ enum Foo {
     Bar,
 }
 
-extern "rust-intrinsic" {
-    #[stable(feature = "intrinsics_for_test", since = "3.3.3")]
-    #[rustc_const_stable(feature = "intrinsics_for_test", since = "3.3.3")]
-    #[rustc_safe_intrinsic]
-    fn size_of<T>() -> usize;
+#[stable(feature = "intrinsics_for_test", since = "3.3.3")]
+#[rustc_const_stable(feature = "intrinsics_for_test", since = "3.3.3")]
+#[rustc_intrinsic]
+#[rustc_intrinsic_must_be_overridden]
+const fn size_of<T>() -> usize {
+    loop {}
 }
 
 #[lang="sized"]
diff --git a/tests/ui/stability-attribute/missing-const-stability.rs b/tests/ui/stability-attribute/missing-const-stability.rs
index 6d49996c3b5..10c31d79438 100644
--- a/tests/ui/stability-attribute/missing-const-stability.rs
+++ b/tests/ui/stability-attribute/missing-const-stability.rs
@@ -36,10 +36,4 @@ impl const Bar for Foo {
 pub const unsafe fn size_of_val<T>(x: *const T) -> usize { 42 }
 //~^ ERROR function has missing const stability attribute
 
-extern "rust-intrinsic" {
-    #[stable(feature = "stable", since = "1.0.0")]
-    #[rustc_const_stable_indirect]
-    pub fn min_align_of_val<T>(x: *const T) -> usize;
-}
-
 fn main() {}
diff --git a/tests/ui/target-feature/feature-hierarchy.rs b/tests/ui/target-feature/feature-hierarchy.rs
index 7f14d700ecb..d62b86693c2 100644
--- a/tests/ui/target-feature/feature-hierarchy.rs
+++ b/tests/ui/target-feature/feature-hierarchy.rs
@@ -18,10 +18,12 @@ trait Sized {}
 trait Copy {}
 impl Copy for bool {}
 
-extern "rust-intrinsic" {
-    #[stable(feature = "test", since = "1.0.0")]
-    #[rustc_const_stable(feature = "test", since = "1.0.0")]
-    fn unreachable() -> !;
+#[stable(feature = "test", since = "1.0.0")]
+#[rustc_const_stable(feature = "test", since = "1.0.0")]
+#[rustc_intrinsic]
+#[rustc_intrinsic_must_be_overridden]
+const unsafe fn unreachable() -> ! {
+    loop {}
 }
 
 #[rustc_builtin_macro]
diff --git a/tests/ui/target-feature/no-llvm-leaks.rs b/tests/ui/target-feature/no-llvm-leaks.rs
index f0c887bc1e0..10268686405 100644
--- a/tests/ui/target-feature/no-llvm-leaks.rs
+++ b/tests/ui/target-feature/no-llvm-leaks.rs
@@ -16,10 +16,12 @@ trait Sized {}
 trait Copy {}
 impl Copy for bool {}
 
-extern "rust-intrinsic" {
-    #[stable(feature = "test", since = "1.0.0")]
-    #[rustc_const_stable(feature = "test", since = "1.0.0")]
-    fn unreachable() -> !;
+#[stable(feature = "test", since = "1.0.0")]
+#[rustc_const_stable(feature = "test", since = "1.0.0")]
+#[rustc_intrinsic]
+#[rustc_intrinsic_must_be_overridden]
+const unsafe fn unreachable() -> ! {
+    loop {}
 }
 
 #[rustc_builtin_macro]