Remove some dead or leftover code related to rustc-intrinsic abi removal
This commit is contained in:
parent
c6c179662d
commit
b2aa9d0620
6 changed files with 13 additions and 60 deletions
|
@ -1,8 +1,10 @@
|
||||||
|
#### Note: this error code is no longer emitted by the compiler.
|
||||||
|
|
||||||
An intrinsic was declared without being a function.
|
An intrinsic was declared without being a function.
|
||||||
|
|
||||||
Erroneous code example:
|
Erroneous code example:
|
||||||
|
|
||||||
```compile_fail,E0622
|
```no_run
|
||||||
#![feature(intrinsics)]
|
#![feature(intrinsics)]
|
||||||
#![allow(internal_features)]
|
#![allow(internal_features)]
|
||||||
|
|
||||||
|
|
|
@ -397,7 +397,7 @@ E0618: 0618,
|
||||||
E0619: 0619,
|
E0619: 0619,
|
||||||
E0620: 0620,
|
E0620: 0620,
|
||||||
E0621: 0621,
|
E0621: 0621,
|
||||||
E0622: 0622,
|
E0622: 0622, // REMOVED: rustc-intrinsic ABI was removed
|
||||||
E0623: 0623,
|
E0623: 0623,
|
||||||
E0624: 0624,
|
E0624: 0624,
|
||||||
E0625: 0625,
|
E0625: 0625,
|
||||||
|
|
|
@ -719,7 +719,6 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
||||||
def_id,
|
def_id,
|
||||||
tcx.def_ident_span(def_id).unwrap(),
|
tcx.def_ident_span(def_id).unwrap(),
|
||||||
i.name,
|
i.name,
|
||||||
ExternAbi::Rust,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -787,16 +786,6 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
||||||
for item in items {
|
for item in items {
|
||||||
let def_id = item.id.owner_id.def_id;
|
let def_id = item.id.owner_id.def_id;
|
||||||
|
|
||||||
if tcx.has_attr(def_id, sym::rustc_intrinsic) {
|
|
||||||
intrinsic::check_intrinsic_type(
|
|
||||||
tcx,
|
|
||||||
item.id.owner_id.def_id,
|
|
||||||
item.span,
|
|
||||||
item.ident.name,
|
|
||||||
abi,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
let generics = tcx.generics_of(def_id);
|
let generics = tcx.generics_of(def_id);
|
||||||
let own_counts = generics.own_counts();
|
let own_counts = generics.own_counts();
|
||||||
if generics.own_params.len() - own_counts.lifetimes != 0 {
|
if generics.own_params.len() - own_counts.lifetimes != 0 {
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
//! Type-checking for the `#[rustc_intrinsic]` intrinsics that the compiler exposes.
|
//! Type-checking for the `#[rustc_intrinsic]` intrinsics that the compiler exposes.
|
||||||
|
|
||||||
use rustc_abi::ExternAbi;
|
use rustc_abi::ExternAbi;
|
||||||
use rustc_errors::codes::*;
|
use rustc_errors::DiagMessage;
|
||||||
use rustc_errors::{DiagMessage, struct_span_code_err};
|
use rustc_hir::{self as hir};
|
||||||
use rustc_hir::{self as hir, Safety};
|
|
||||||
use rustc_middle::bug;
|
use rustc_middle::bug;
|
||||||
use rustc_middle::traits::{ObligationCause, ObligationCauseCode};
|
use rustc_middle::traits::{ObligationCause, ObligationCauseCode};
|
||||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||||
|
@ -26,17 +25,10 @@ fn equate_intrinsic_type<'tcx>(
|
||||||
sig: ty::PolyFnSig<'tcx>,
|
sig: ty::PolyFnSig<'tcx>,
|
||||||
) {
|
) {
|
||||||
let (generics, span) = match tcx.hir_node_by_def_id(def_id) {
|
let (generics, span) = match tcx.hir_node_by_def_id(def_id) {
|
||||||
hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn { generics, .. }, .. })
|
hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn { generics, .. }, .. }) => {
|
||||||
| hir::Node::ForeignItem(hir::ForeignItem {
|
(tcx.generics_of(def_id), generics.span)
|
||||||
kind: hir::ForeignItemKind::Fn(_, _, generics),
|
|
||||||
..
|
|
||||||
}) => (tcx.generics_of(def_id), generics.span),
|
|
||||||
_ => {
|
|
||||||
struct_span_code_err!(tcx.dcx(), span, E0622, "intrinsic must be a function")
|
|
||||||
.with_span_label(span, "expected a function")
|
|
||||||
.emit();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
_ => tcx.dcx().span_bug(span, "intrinsic must be a function"),
|
||||||
};
|
};
|
||||||
let own_counts = generics.own_counts();
|
let own_counts = generics.own_counts();
|
||||||
|
|
||||||
|
@ -70,13 +62,7 @@ fn equate_intrinsic_type<'tcx>(
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the unsafety of the given intrinsic.
|
/// Returns the unsafety of the given intrinsic.
|
||||||
pub fn intrinsic_operation_unsafety(tcx: TyCtxt<'_>, intrinsic_id: LocalDefId) -> hir::Safety {
|
fn intrinsic_operation_unsafety(tcx: TyCtxt<'_>, intrinsic_id: LocalDefId) -> hir::Safety {
|
||||||
let has_safe_attr = if tcx.has_attr(intrinsic_id, sym::rustc_intrinsic) {
|
|
||||||
tcx.fn_sig(intrinsic_id).skip_binder().safety()
|
|
||||||
} else {
|
|
||||||
// Old-style intrinsics are never safe
|
|
||||||
Safety::Unsafe
|
|
||||||
};
|
|
||||||
let is_in_list = match tcx.item_name(intrinsic_id.into()) {
|
let is_in_list = match tcx.item_name(intrinsic_id.into()) {
|
||||||
// When adding a new intrinsic to this list,
|
// When adding a new intrinsic to this list,
|
||||||
// it's usually worth updating that intrinsic's documentation
|
// it's usually worth updating that intrinsic's documentation
|
||||||
|
@ -148,7 +134,7 @@ pub fn intrinsic_operation_unsafety(tcx: TyCtxt<'_>, intrinsic_id: LocalDefId) -
|
||||||
_ => hir::Safety::Unsafe,
|
_ => hir::Safety::Unsafe,
|
||||||
};
|
};
|
||||||
|
|
||||||
if has_safe_attr != is_in_list {
|
if tcx.fn_sig(intrinsic_id).skip_binder().safety() != is_in_list {
|
||||||
tcx.dcx().struct_span_err(
|
tcx.dcx().struct_span_err(
|
||||||
tcx.def_span(intrinsic_id),
|
tcx.def_span(intrinsic_id),
|
||||||
DiagMessage::from(format!(
|
DiagMessage::from(format!(
|
||||||
|
@ -163,12 +149,11 @@ pub fn intrinsic_operation_unsafety(tcx: TyCtxt<'_>, intrinsic_id: LocalDefId) -
|
||||||
|
|
||||||
/// Remember to add all intrinsics here, in `compiler/rustc_codegen_llvm/src/intrinsic.rs`,
|
/// Remember to add all intrinsics here, in `compiler/rustc_codegen_llvm/src/intrinsic.rs`,
|
||||||
/// and in `library/core/src/intrinsics.rs`.
|
/// and in `library/core/src/intrinsics.rs`.
|
||||||
pub fn check_intrinsic_type(
|
pub(crate) fn check_intrinsic_type(
|
||||||
tcx: TyCtxt<'_>,
|
tcx: TyCtxt<'_>,
|
||||||
intrinsic_id: LocalDefId,
|
intrinsic_id: LocalDefId,
|
||||||
span: Span,
|
span: Span,
|
||||||
intrinsic_name: Symbol,
|
intrinsic_name: Symbol,
|
||||||
abi: ExternAbi,
|
|
||||||
) {
|
) {
|
||||||
let generics = tcx.generics_of(intrinsic_id);
|
let generics = tcx.generics_of(intrinsic_id);
|
||||||
let param = |n| {
|
let param = |n| {
|
||||||
|
@ -706,7 +691,7 @@ pub fn check_intrinsic_type(
|
||||||
};
|
};
|
||||||
(n_tps, 0, n_cts, inputs, output, safety)
|
(n_tps, 0, n_cts, inputs, output, safety)
|
||||||
};
|
};
|
||||||
let sig = tcx.mk_fn_sig(inputs, output, false, safety, abi);
|
let sig = tcx.mk_fn_sig(inputs, output, false, safety, ExternAbi::Rust);
|
||||||
let sig = ty::Binder::bind_with_vars(sig, bound_vars);
|
let sig = ty::Binder::bind_with_vars(sig, bound_vars);
|
||||||
equate_intrinsic_type(tcx, span, intrinsic_id, n_tps, n_lts, n_cts, sig)
|
equate_intrinsic_type(tcx, span, intrinsic_id, n_tps, n_lts, n_cts, sig)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
#![feature(intrinsics)]
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
|
|
||||||
#[rustc_intrinsic]
|
|
||||||
pub static atomic_singlethreadfence_seqcst: unsafe extern "C" fn();
|
|
||||||
//~^ ERROR intrinsic must be a function [E0622]
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
unsafe {
|
|
||||||
atomic_singlethreadfence_seqcst();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
error[E0622]: intrinsic must be a function
|
|
||||||
--> $DIR/E0622.rs:6:5
|
|
||||||
|
|
|
||||||
LL | pub static atomic_singlethreadfence_seqcst: unsafe extern "C" fn();
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected a function
|
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0622`.
|
|
Loading…
Add table
Add a link
Reference in a new issue