Skip to content

Commit

Permalink
Remove ffi_returns_twice feature
Browse files Browse the repository at this point in the history
  • Loading branch information
clubby789 committed Jan 30, 2024
1 parent 5ad7454 commit 9dd078e
Show file tree
Hide file tree
Showing 21 changed files with 21 additions and 119 deletions.
3 changes: 0 additions & 3 deletions compiler/rustc_codegen_gcc/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_codegen_llvm/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ pub enum AttributeKind {
SanitizeMemory = 22,
NonLazyBind = 23,
OptimizeNone = 24,
ReturnsTwice = 25,
ReadNone = 26,
SanitizeHWAddress = 28,
WillReturn = 29,
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_codegen_ssa/src/codegen_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion compiler/rustc_error_codes/src/error_codes/E0724.md
Original file line number Diff line number Diff line change
@@ -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,E0557
#![feature(ffi_returns_twice)]
#![crate_type = "lib"]
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_feature/src/builtin_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_feature/src/removed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,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.
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,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.
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_llvm/llvm-wrapper/LLVMWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ enum LLVMRustAttribute {
SanitizeMemory = 22,
NonLazyBind = 23,
OptimizeNone = 24,
ReturnsTwice = 25,
ReadNone = 26,
SanitizeHWAddress = 28,
WillReturn = 29,
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
23 changes: 10 additions & 13 deletions compiler/rustc_middle/src/middle/codegen_fn_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_passes/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 0 additions & 10 deletions compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,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
Expand Down Expand Up @@ -1307,15 +1306,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!(
Expand Down
7 changes: 0 additions & 7 deletions compiler/rustc_passes/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions config.toml.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Includes one of the default files in src/bootstrap/defaults
profile = "compiler"
change-id = 102579
2 changes: 1 addition & 1 deletion src/tools/tidy/src/ui_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 0 additions & 11 deletions tests/codegen/cffi/ffi-returns-twice.rs

This file was deleted.

6 changes: 0 additions & 6 deletions tests/ui/feature-gates/feature-gate-ffi_returns_twice.rs

This file was deleted.

13 changes: 0 additions & 13 deletions tests/ui/feature-gates/feature-gate-ffi_returns_twice.stderr

This file was deleted.

15 changes: 0 additions & 15 deletions tests/ui/ffi_returns_twice.rs

This file was deleted.

21 changes: 0 additions & 21 deletions tests/ui/ffi_returns_twice.stderr

This file was deleted.

0 comments on commit 9dd078e

Please sign in to comment.