Skip to content

Commit 0f416e7

Browse files
authored
Rollup merge of #139455 - Skgland:remove_rust-intrinsic_ABI, r=oli-obk
Remove support for `extern "rust-intrinsic"` blocks Part of rust-lang/rust#132735 Looked manageable and there didn't appear to have been progress in the last two weeks, so decided to give it a try.
2 parents 9ad0782 + 899736a commit 0f416e7

File tree

6 files changed

+9
-64
lines changed

6 files changed

+9
-64
lines changed

crates/hir-ty/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,6 @@ pub enum FnAbi {
400400
Rust,
401401
RustCall,
402402
RustCold,
403-
RustIntrinsic,
404403
Stdcall,
405404
StdcallUnwind,
406405
System,
@@ -457,7 +456,6 @@ impl FnAbi {
457456
s if *s == sym::riscv_dash_interrupt_dash_s => FnAbi::RiscvInterruptS,
458457
s if *s == sym::rust_dash_call => FnAbi::RustCall,
459458
s if *s == sym::rust_dash_cold => FnAbi::RustCold,
460-
s if *s == sym::rust_dash_intrinsic => FnAbi::RustIntrinsic,
461459
s if *s == sym::Rust => FnAbi::Rust,
462460
s if *s == sym::stdcall_dash_unwind => FnAbi::StdcallUnwind,
463461
s if *s == sym::stdcall => FnAbi::Stdcall,
@@ -500,7 +498,6 @@ impl FnAbi {
500498
FnAbi::Rust => "Rust",
501499
FnAbi::RustCall => "rust-call",
502500
FnAbi::RustCold => "rust-cold",
503-
FnAbi::RustIntrinsic => "rust-intrinsic",
504501
FnAbi::Stdcall => "stdcall",
505502
FnAbi::StdcallUnwind => "stdcall-unwind",
506503
FnAbi::System => "system",

crates/hir-ty/src/mir/eval/shim.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,7 @@ impl Evaluator<'_> {
5959

6060
let function_data = self.db.function_data(def);
6161
let attrs = self.db.attrs(def.into());
62-
let is_intrinsic = attrs.by_key(&sym::rustc_intrinsic).exists()
63-
// Keep this around for a bit until extern "rustc-intrinsic" abis are no longer used
64-
|| (match &function_data.abi {
65-
Some(abi) => *abi == sym::rust_dash_intrinsic,
66-
None => match def.lookup(self.db.upcast()).container {
67-
hir_def::ItemContainerId::ExternBlockId(block) => {
68-
let id = block.lookup(self.db.upcast()).id;
69-
id.item_tree(self.db.upcast())[id.value].abi.as_ref()
70-
== Some(&sym::rust_dash_intrinsic)
71-
}
72-
_ => false,
73-
},
74-
});
62+
let is_intrinsic = attrs.by_key(&sym::rustc_intrinsic).exists();
7563

7664
if is_intrinsic {
7765
return self.exec_intrinsic(

crates/hir-ty/src/utils.rs

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use hir_def::{
1818
TypeOrConstParamId,
1919
};
2020
use hir_expand::name::Name;
21-
use intern::sym;
2221
use rustc_abi::TargetDataLayout;
2322
use rustc_hash::FxHashSet;
2423
use smallvec::{smallvec, SmallVec};
@@ -303,26 +302,13 @@ pub fn is_fn_unsafe_to_call(
303302

304303
let loc = func.lookup(db.upcast());
305304
match loc.container {
306-
hir_def::ItemContainerId::ExternBlockId(block) => {
307-
let id = block.lookup(db.upcast()).id;
308-
let is_intrinsic_block =
309-
id.item_tree(db.upcast())[id.value].abi.as_ref() == Some(&sym::rust_dash_intrinsic);
310-
if is_intrinsic_block {
311-
// legacy intrinsics
312-
// extern "rust-intrinsic" intrinsics are unsafe unless they have the rustc_safe_intrinsic attribute
313-
if db.attrs(func.into()).by_key(&sym::rustc_safe_intrinsic).exists() {
314-
Unsafety::Safe
315-
} else {
316-
Unsafety::Unsafe
317-
}
305+
hir_def::ItemContainerId::ExternBlockId(_block) => {
306+
// Function in an `extern` block are always unsafe to call, except when
307+
// it is marked as `safe`.
308+
if data.is_safe() {
309+
Unsafety::Safe
318310
} else {
319-
// Function in an `extern` block are always unsafe to call, except when
320-
// it is marked as `safe`.
321-
if data.is_safe() {
322-
Unsafety::Safe
323-
} else {
324-
Unsafety::Unsafe
325-
}
311+
Unsafety::Unsafe
326312
}
327313
}
328314
_ => Unsafety::Safe,

crates/ide-completion/src/completions/extern_abi.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ const SUPPORTED_CALLING_CONVENTIONS: &[&str] = &[
3636
"wasm",
3737
"system",
3838
"system-unwind",
39-
"rust-intrinsic",
4039
"rust-call",
4140
"unadjusted",
4241
];

crates/ide/src/hover/tests.rs

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6945,9 +6945,8 @@ fn hover_feature() {
69456945
Various intrinsics have native MIR operations that they correspond to. Instead of requiring
69466946
backends to implement both the intrinsic and the MIR operation, the `lower_intrinsics` pass
69476947
will convert the calls to the MIR operation. Backends do not need to know about these intrinsics
6948-
at all. These intrinsics only make sense without a body, and can either be declared as a "rust-intrinsic"
6949-
or as a `#[rustc_intrinsic]`. The body is never used, as calls to the intrinsic do not exist
6950-
anymore after MIR analyses.
6948+
at all. These intrinsics only make sense without a body, and can be as a `#[rustc_intrinsic]`.
6949+
The body is never used, as calls to the intrinsic do not exist anymore after MIR analyses.
69516950
69526951
## Intrinsics without fallback logic
69536952
@@ -6960,29 +6959,6 @@ fn hover_feature() {
69606959
`#[rustc_intrinsic_must_be_overridden]` to the function to ensure that backends don't
69616960
invoke the body.
69626961
6963-
### Legacy extern ABI based intrinsics
6964-
6965-
These are imported as if they were FFI functions, with the special
6966-
`rust-intrinsic` ABI. For example, if one was in a freestanding
6967-
context, but wished to be able to `transmute` between types, and
6968-
perform efficient pointer arithmetic, one would import those functions
6969-
via a declaration like
6970-
6971-
```rust
6972-
#![feature(intrinsics)]
6973-
#![allow(internal_features)]
6974-
# fn main() {}
6975-
6976-
extern "rust-intrinsic" {
6977-
fn transmute<T, U>(x: T) -> U;
6978-
6979-
fn arith_offset<T>(dst: *const T, offset: isize) -> *const T;
6980-
}
6981-
```
6982-
6983-
As with any other FFI functions, these are by default always `unsafe` to call.
6984-
You can add `#[rustc_safe_intrinsic]` to the intrinsic to make it safe to call.
6985-
69866962
"#]],
69876963
)
69886964
}

crates/intern/src/symbol/symbols.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ define_symbols! {
125125
riscv_dash_interrupt_dash_s = "riscv-interrupt-s",
126126
rust_dash_call = "rust-call",
127127
rust_dash_cold = "rust-cold",
128-
rust_dash_intrinsic = "rust-intrinsic",
129128
stdcall_dash_unwind = "stdcall-unwind",
130129
system_dash_unwind = "system-unwind",
131130
sysv64_dash_unwind = "sysv64-unwind",

0 commit comments

Comments
 (0)