mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
Rollup merge of #120502 - clubby789:remove-ffi-returns-twice, r=compiler-errors
Remove `ffi_returns_twice` feature The [tracking issue](https://github.com/rust-lang/rust/issues/58314) and [RFC](https://github.com/rust-lang/rfcs/pull/2633) have been closed for a couple of years. There is also an attribute gate in R-A which should be removed if this lands.
This commit is contained in:
commit
59ba8024af
@ -62,9 +62,6 @@ pub fn from_fn_attrs<'gcc, 'tcx>(
|
||||
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::COLD) {
|
||||
func.add_attribute(FnAttribute::Cold);
|
||||
}
|
||||
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::FFI_RETURNS_TWICE) {
|
||||
func.add_attribute(FnAttribute::ReturnsTwice);
|
||||
}
|
||||
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::FFI_PURE) {
|
||||
func.add_attribute(FnAttribute::Pure);
|
||||
}
|
||||
|
@ -356,9 +356,6 @@ pub fn from_fn_attrs<'ll, 'tcx>(
|
||||
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::COLD) {
|
||||
to_add.push(AttributeKind::Cold.create_attr(cx.llcx));
|
||||
}
|
||||
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::FFI_RETURNS_TWICE) {
|
||||
to_add.push(AttributeKind::ReturnsTwice.create_attr(cx.llcx));
|
||||
}
|
||||
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::FFI_PURE) {
|
||||
to_add.push(MemoryEffects::ReadOnly.create_attr(cx.llcx));
|
||||
}
|
||||
|
@ -184,7 +184,6 @@ pub enum AttributeKind {
|
||||
SanitizeMemory = 22,
|
||||
NonLazyBind = 23,
|
||||
OptimizeNone = 24,
|
||||
ReturnsTwice = 25,
|
||||
ReadNone = 26,
|
||||
SanitizeHWAddress = 28,
|
||||
WillReturn = 29,
|
||||
|
@ -103,9 +103,6 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||
match name {
|
||||
sym::cold => codegen_fn_attrs.flags |= CodegenFnAttrFlags::COLD,
|
||||
sym::rustc_allocator => codegen_fn_attrs.flags |= CodegenFnAttrFlags::ALLOCATOR,
|
||||
sym::ffi_returns_twice => {
|
||||
codegen_fn_attrs.flags |= CodegenFnAttrFlags::FFI_RETURNS_TWICE
|
||||
}
|
||||
sym::ffi_pure => codegen_fn_attrs.flags |= CodegenFnAttrFlags::FFI_PURE,
|
||||
sym::ffi_const => codegen_fn_attrs.flags |= CodegenFnAttrFlags::FFI_CONST,
|
||||
sym::rustc_nounwind => codegen_fn_attrs.flags |= CodegenFnAttrFlags::NEVER_UNWIND,
|
||||
|
@ -1,9 +1,12 @@
|
||||
#### Note: this error code is no longer emitted by the compiler.
|
||||
|
||||
|
||||
`#[ffi_returns_twice]` was used on something other than a foreign function
|
||||
declaration.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0724
|
||||
```compile_fail
|
||||
#![feature(ffi_returns_twice)]
|
||||
#![crate_type = "lib"]
|
||||
|
||||
@ -15,7 +18,7 @@ pub fn foo() {}
|
||||
For example, we might correct the previous example by declaring
|
||||
the function inside of an `extern` block.
|
||||
|
||||
```
|
||||
```compile_fail
|
||||
#![feature(ffi_returns_twice)]
|
||||
|
||||
extern "C" {
|
||||
|
@ -440,9 +440,6 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
|
||||
experimental!(optimize),
|
||||
),
|
||||
|
||||
gated!(
|
||||
ffi_returns_twice, Normal, template!(Word), WarnFollowing, experimental!(ffi_returns_twice)
|
||||
),
|
||||
gated!(ffi_pure, Normal, template!(Word), WarnFollowing, experimental!(ffi_pure)),
|
||||
gated!(ffi_const, Normal, template!(Word), WarnFollowing, experimental!(ffi_const)),
|
||||
gated!(
|
||||
|
@ -97,6 +97,9 @@ declare_features! (
|
||||
/// Allows `#[doc(include = "some-file")]`.
|
||||
(removed, external_doc, "1.54.0", Some(44732),
|
||||
Some("use #[doc = include_str!(\"filename\")] instead, which handles macro invocations")),
|
||||
/// Allows using `#[ffi_returns_twice]` on foreign functions.
|
||||
(removed, ffi_returns_twice, "CURRENT_RUSTC_VERSION", Some(58314),
|
||||
Some("being investigated by the ffi-unwind project group")),
|
||||
/// Allows generators to be cloned.
|
||||
(removed, generator_clone, "1.65.0", Some(95360), Some("renamed to `coroutine_clone`")),
|
||||
/// Allows defining generators.
|
||||
|
@ -465,8 +465,6 @@ declare_features! (
|
||||
(unstable, ffi_const, "1.45.0", Some(58328)),
|
||||
/// Allows the use of `#[ffi_pure]` on foreign functions.
|
||||
(unstable, ffi_pure, "1.45.0", Some(58329)),
|
||||
/// Allows using `#[ffi_returns_twice]` on foreign functions.
|
||||
(unstable, ffi_returns_twice, "1.34.0", Some(58314)),
|
||||
/// Allows using `#[repr(align(...))]` on function items
|
||||
(unstable, fn_align, "1.53.0", Some(82232)),
|
||||
/// Support delegating implementation of functions to other already implemented functions.
|
||||
|
@ -76,7 +76,6 @@ enum LLVMRustAttribute {
|
||||
SanitizeMemory = 22,
|
||||
NonLazyBind = 23,
|
||||
OptimizeNone = 24,
|
||||
ReturnsTwice = 25,
|
||||
ReadNone = 26,
|
||||
SanitizeHWAddress = 28,
|
||||
WillReturn = 29,
|
||||
|
@ -250,8 +250,6 @@ static Attribute::AttrKind fromRust(LLVMRustAttribute Kind) {
|
||||
return Attribute::NonLazyBind;
|
||||
case OptimizeNone:
|
||||
return Attribute::OptimizeNone;
|
||||
case ReturnsTwice:
|
||||
return Attribute::ReturnsTwice;
|
||||
case ReadNone:
|
||||
return Attribute::ReadNone;
|
||||
case SanitizeHWAddress:
|
||||
|
@ -74,35 +74,32 @@ bitflags! {
|
||||
/// `#[used]`: indicates that LLVM can't eliminate this function (but the
|
||||
/// linker can!).
|
||||
const USED = 1 << 9;
|
||||
/// `#[ffi_returns_twice]`, indicates that an extern function can return
|
||||
/// multiple times
|
||||
const FFI_RETURNS_TWICE = 1 << 10;
|
||||
/// `#[track_caller]`: allow access to the caller location
|
||||
const TRACK_CALLER = 1 << 11;
|
||||
const TRACK_CALLER = 1 << 10;
|
||||
/// #[ffi_pure]: applies clang's `pure` attribute to a foreign function
|
||||
/// declaration.
|
||||
const FFI_PURE = 1 << 12;
|
||||
const FFI_PURE = 1 << 11;
|
||||
/// #[ffi_const]: applies clang's `const` attribute to a foreign function
|
||||
/// declaration.
|
||||
const FFI_CONST = 1 << 13;
|
||||
const FFI_CONST = 1 << 12;
|
||||
/// #[cmse_nonsecure_entry]: with a TrustZone-M extension, declare a
|
||||
/// function as an entry function from Non-Secure code.
|
||||
const CMSE_NONSECURE_ENTRY = 1 << 14;
|
||||
const CMSE_NONSECURE_ENTRY = 1 << 13;
|
||||
/// `#[coverage(off)]`: indicates that the function should be ignored by
|
||||
/// the MIR `InstrumentCoverage` pass and not added to the coverage map
|
||||
/// during codegen.
|
||||
const NO_COVERAGE = 1 << 15;
|
||||
const NO_COVERAGE = 1 << 14;
|
||||
/// `#[used(linker)]`:
|
||||
/// indicates that neither LLVM nor the linker will eliminate this function.
|
||||
const USED_LINKER = 1 << 16;
|
||||
const USED_LINKER = 1 << 15;
|
||||
/// `#[rustc_deallocator]`: a hint to LLVM that the function only deallocates memory.
|
||||
const DEALLOCATOR = 1 << 17;
|
||||
const DEALLOCATOR = 1 << 16;
|
||||
/// `#[rustc_reallocator]`: a hint to LLVM that the function only reallocates memory.
|
||||
const REALLOCATOR = 1 << 18;
|
||||
const REALLOCATOR = 1 << 17;
|
||||
/// `#[rustc_allocator_zeroed]`: a hint to LLVM that the function only allocates zeroed memory.
|
||||
const ALLOCATOR_ZEROED = 1 << 19;
|
||||
const ALLOCATOR_ZEROED = 1 << 18;
|
||||
/// `#[no_builtins]`: indicates that disable implicit builtin knowledge of functions for the function.
|
||||
const NO_BUILTINS = 1 << 20;
|
||||
const NO_BUILTINS = 1 << 19;
|
||||
}
|
||||
}
|
||||
rustc_data_structures::external_bitflags_debug! { CodegenFnAttrFlags }
|
||||
|
@ -323,9 +323,6 @@ passes_ffi_const_invalid_target =
|
||||
passes_ffi_pure_invalid_target =
|
||||
`#[ffi_pure]` may only be used on foreign functions
|
||||
|
||||
passes_ffi_returns_twice_invalid_target =
|
||||
`#[ffi_returns_twice]` may only be used on foreign functions
|
||||
|
||||
passes_has_incoherent_inherent_impl =
|
||||
`rustc_has_incoherent_inherent_impls` attribute should be applied to types or traits.
|
||||
.label = only adts, extern types and traits are supported
|
||||
|
@ -192,7 +192,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
||||
}
|
||||
sym::ffi_pure => self.check_ffi_pure(attr.span, attrs, target),
|
||||
sym::ffi_const => self.check_ffi_const(attr.span, target),
|
||||
sym::ffi_returns_twice => self.check_ffi_returns_twice(attr.span, target),
|
||||
sym::rustc_const_unstable
|
||||
| sym::rustc_const_stable
|
||||
| sym::unstable
|
||||
@ -1309,15 +1308,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
fn check_ffi_returns_twice(&self, attr_span: Span, target: Target) -> bool {
|
||||
if target == Target::ForeignFn {
|
||||
true
|
||||
} else {
|
||||
self.dcx().emit_err(errors::FfiReturnsTwiceInvalidTarget { attr_span });
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
/// Warns against some misuses of `#[must_use]`
|
||||
fn check_must_use(&self, hir_id: HirId, attr: &Attribute, target: Target) -> bool {
|
||||
if !matches!(
|
||||
|
@ -390,13 +390,6 @@ pub struct FfiConstInvalidTarget {
|
||||
pub attr_span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(passes_ffi_returns_twice_invalid_target, code = E0724)]
|
||||
pub struct FfiReturnsTwiceInvalidTarget {
|
||||
#[primary_span]
|
||||
pub attr_span: Span,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(passes_must_use_async)]
|
||||
pub struct MustUseAsync {
|
||||
|
@ -14,7 +14,7 @@ use std::path::{Path, PathBuf};
|
||||
// #73494.
|
||||
const ENTRY_LIMIT: usize = 900;
|
||||
const ISSUES_ENTRY_LIMIT: usize = 1807;
|
||||
const ROOT_ENTRY_LIMIT: usize = 870;
|
||||
const ROOT_ENTRY_LIMIT: usize = 868;
|
||||
|
||||
const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
|
||||
"rs", // test source files
|
||||
|
@ -1,11 +0,0 @@
|
||||
// compile-flags: -C no-prepopulate-passes
|
||||
#![crate_type = "lib"]
|
||||
#![feature(ffi_returns_twice)]
|
||||
|
||||
pub fn bar() { unsafe { foo() } }
|
||||
|
||||
extern "C" {
|
||||
// CHECK: declare{{( dso_local)?}} void @foo(){{.*}}[[ATTRS:#[0-9]+]]
|
||||
// CHECK: attributes [[ATTRS]] = { {{.*}}returns_twice{{.*}} }
|
||||
#[ffi_returns_twice] pub fn foo();
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
#![crate_type = "lib"]
|
||||
|
||||
extern "C" {
|
||||
#[ffi_returns_twice] //~ ERROR the `#[ffi_returns_twice]` attribute is an experimental feature
|
||||
pub fn foo();
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
error[E0658]: the `#[ffi_returns_twice]` attribute is an experimental feature
|
||||
--> $DIR/feature-gate-ffi_returns_twice.rs:4:5
|
||||
|
|
||||
LL | #[ffi_returns_twice]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #58314 <https://github.com/rust-lang/rust/issues/58314> for more information
|
||||
= help: add `#![feature(ffi_returns_twice)]` 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: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
@ -1,15 +0,0 @@
|
||||
#![feature(ffi_returns_twice)]
|
||||
#![crate_type = "lib"]
|
||||
|
||||
#[ffi_returns_twice] //~ ERROR `#[ffi_returns_twice]` may only be used on foreign functions
|
||||
pub fn foo() {}
|
||||
|
||||
#[ffi_returns_twice] //~ ERROR `#[ffi_returns_twice]` may only be used on foreign functions
|
||||
macro_rules! bar {
|
||||
() => ()
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
#[ffi_returns_twice] //~ ERROR `#[ffi_returns_twice]` may only be used on foreign functions
|
||||
static INT: i32;
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
error[E0724]: `#[ffi_returns_twice]` may only be used on foreign functions
|
||||
--> $DIR/ffi_returns_twice.rs:4:1
|
||||
|
|
||||
LL | #[ffi_returns_twice]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0724]: `#[ffi_returns_twice]` may only be used on foreign functions
|
||||
--> $DIR/ffi_returns_twice.rs:7:1
|
||||
|
|
||||
LL | #[ffi_returns_twice]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0724]: `#[ffi_returns_twice]` may only be used on foreign functions
|
||||
--> $DIR/ffi_returns_twice.rs:13:5
|
||||
|
|
||||
LL | #[ffi_returns_twice]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0724`.
|
Loading…
Reference in New Issue
Block a user