Skip to content

Commit b2aa9d0

Browse files
committed
Remove some dead or leftover code related to rustc-intrinsic abi removal
1 parent c6c1796 commit b2aa9d0

File tree

6 files changed

+13
-60
lines changed

6 files changed

+13
-60
lines changed

compiler/rustc_error_codes/src/error_codes/E0622.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
#### Note: this error code is no longer emitted by the compiler.
2+
13
An intrinsic was declared without being a function.
24

35
Erroneous code example:
46

5-
```compile_fail,E0622
7+
```no_run
68
#![feature(intrinsics)]
79
#![allow(internal_features)]
810

compiler/rustc_error_codes/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ E0618: 0618,
397397
E0619: 0619,
398398
E0620: 0620,
399399
E0621: 0621,
400-
E0622: 0622,
400+
E0622: 0622, // REMOVED: rustc-intrinsic ABI was removed
401401
E0623: 0623,
402402
E0624: 0624,
403403
E0625: 0625,

compiler/rustc_hir_analysis/src/check/check.rs

-11
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,6 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) {
719719
def_id,
720720
tcx.def_ident_span(def_id).unwrap(),
721721
i.name,
722-
ExternAbi::Rust,
723722
)
724723
}
725724
}
@@ -787,16 +786,6 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) {
787786
for item in items {
788787
let def_id = item.id.owner_id.def_id;
789788

790-
if tcx.has_attr(def_id, sym::rustc_intrinsic) {
791-
intrinsic::check_intrinsic_type(
792-
tcx,
793-
item.id.owner_id.def_id,
794-
item.span,
795-
item.ident.name,
796-
abi,
797-
);
798-
}
799-
800789
let generics = tcx.generics_of(def_id);
801790
let own_counts = generics.own_counts();
802791
if generics.own_params.len() - own_counts.lifetimes != 0 {

compiler/rustc_hir_analysis/src/check/intrinsic.rs

+9-24
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
//! Type-checking for the `#[rustc_intrinsic]` intrinsics that the compiler exposes.
22
33
use rustc_abi::ExternAbi;
4-
use rustc_errors::codes::*;
5-
use rustc_errors::{DiagMessage, struct_span_code_err};
6-
use rustc_hir::{self as hir, Safety};
4+
use rustc_errors::DiagMessage;
5+
use rustc_hir::{self as hir};
76
use rustc_middle::bug;
87
use rustc_middle::traits::{ObligationCause, ObligationCauseCode};
98
use rustc_middle::ty::{self, Ty, TyCtxt};
@@ -26,17 +25,10 @@ fn equate_intrinsic_type<'tcx>(
2625
sig: ty::PolyFnSig<'tcx>,
2726
) {
2827
let (generics, span) = match tcx.hir_node_by_def_id(def_id) {
29-
hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn { generics, .. }, .. })
30-
| hir::Node::ForeignItem(hir::ForeignItem {
31-
kind: hir::ForeignItemKind::Fn(_, _, generics),
32-
..
33-
}) => (tcx.generics_of(def_id), generics.span),
34-
_ => {
35-
struct_span_code_err!(tcx.dcx(), span, E0622, "intrinsic must be a function")
36-
.with_span_label(span, "expected a function")
37-
.emit();
38-
return;
28+
hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn { generics, .. }, .. }) => {
29+
(tcx.generics_of(def_id), generics.span)
3930
}
31+
_ => tcx.dcx().span_bug(span, "intrinsic must be a function"),
4032
};
4133
let own_counts = generics.own_counts();
4234

@@ -70,13 +62,7 @@ fn equate_intrinsic_type<'tcx>(
7062
}
7163

7264
/// Returns the unsafety of the given intrinsic.
73-
pub fn intrinsic_operation_unsafety(tcx: TyCtxt<'_>, intrinsic_id: LocalDefId) -> hir::Safety {
74-
let has_safe_attr = if tcx.has_attr(intrinsic_id, sym::rustc_intrinsic) {
75-
tcx.fn_sig(intrinsic_id).skip_binder().safety()
76-
} else {
77-
// Old-style intrinsics are never safe
78-
Safety::Unsafe
79-
};
65+
fn intrinsic_operation_unsafety(tcx: TyCtxt<'_>, intrinsic_id: LocalDefId) -> hir::Safety {
8066
let is_in_list = match tcx.item_name(intrinsic_id.into()) {
8167
// When adding a new intrinsic to this list,
8268
// it's usually worth updating that intrinsic's documentation
@@ -148,7 +134,7 @@ pub fn intrinsic_operation_unsafety(tcx: TyCtxt<'_>, intrinsic_id: LocalDefId) -
148134
_ => hir::Safety::Unsafe,
149135
};
150136

151-
if has_safe_attr != is_in_list {
137+
if tcx.fn_sig(intrinsic_id).skip_binder().safety() != is_in_list {
152138
tcx.dcx().struct_span_err(
153139
tcx.def_span(intrinsic_id),
154140
DiagMessage::from(format!(
@@ -163,12 +149,11 @@ pub fn intrinsic_operation_unsafety(tcx: TyCtxt<'_>, intrinsic_id: LocalDefId) -
163149

164150
/// Remember to add all intrinsics here, in `compiler/rustc_codegen_llvm/src/intrinsic.rs`,
165151
/// and in `library/core/src/intrinsics.rs`.
166-
pub fn check_intrinsic_type(
152+
pub(crate) fn check_intrinsic_type(
167153
tcx: TyCtxt<'_>,
168154
intrinsic_id: LocalDefId,
169155
span: Span,
170156
intrinsic_name: Symbol,
171-
abi: ExternAbi,
172157
) {
173158
let generics = tcx.generics_of(intrinsic_id);
174159
let param = |n| {
@@ -706,7 +691,7 @@ pub fn check_intrinsic_type(
706691
};
707692
(n_tps, 0, n_cts, inputs, output, safety)
708693
};
709-
let sig = tcx.mk_fn_sig(inputs, output, false, safety, abi);
694+
let sig = tcx.mk_fn_sig(inputs, output, false, safety, ExternAbi::Rust);
710695
let sig = ty::Binder::bind_with_vars(sig, bound_vars);
711696
equate_intrinsic_type(tcx, span, intrinsic_id, n_tps, n_lts, n_cts, sig)
712697
}

tests/ui/error-codes/E0622.rs

-14
This file was deleted.

tests/ui/error-codes/E0622.stderr

-9
This file was deleted.

0 commit comments

Comments
 (0)