Skip to content

Commit 59ba802

Browse files
authored
Rollup merge of rust-lang#120502 - clubby789:remove-ffi-returns-twice, r=compiler-errors
Remove `ffi_returns_twice` feature The [tracking issue](rust-lang#58314) and [RFC](rust-lang/rfcs#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.
2 parents 0a4702d + 7331315 commit 59ba802

File tree

20 files changed

+19
-120
lines changed

20 files changed

+19
-120
lines changed

compiler/rustc_codegen_gcc/src/attributes.rs

-3
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,6 @@ pub fn from_fn_attrs<'gcc, 'tcx>(
6262
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::COLD) {
6363
func.add_attribute(FnAttribute::Cold);
6464
}
65-
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::FFI_RETURNS_TWICE) {
66-
func.add_attribute(FnAttribute::ReturnsTwice);
67-
}
6865
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::FFI_PURE) {
6966
func.add_attribute(FnAttribute::Pure);
7067
}

compiler/rustc_codegen_llvm/src/attributes.rs

-3
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,6 @@ pub fn from_fn_attrs<'ll, 'tcx>(
356356
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::COLD) {
357357
to_add.push(AttributeKind::Cold.create_attr(cx.llcx));
358358
}
359-
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::FFI_RETURNS_TWICE) {
360-
to_add.push(AttributeKind::ReturnsTwice.create_attr(cx.llcx));
361-
}
362359
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::FFI_PURE) {
363360
to_add.push(MemoryEffects::ReadOnly.create_attr(cx.llcx));
364361
}

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ pub enum AttributeKind {
184184
SanitizeMemory = 22,
185185
NonLazyBind = 23,
186186
OptimizeNone = 24,
187-
ReturnsTwice = 25,
188187
ReadNone = 26,
189188
SanitizeHWAddress = 28,
190189
WillReturn = 29,

compiler/rustc_codegen_ssa/src/codegen_attrs.rs

-3
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,6 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
103103
match name {
104104
sym::cold => codegen_fn_attrs.flags |= CodegenFnAttrFlags::COLD,
105105
sym::rustc_allocator => codegen_fn_attrs.flags |= CodegenFnAttrFlags::ALLOCATOR,
106-
sym::ffi_returns_twice => {
107-
codegen_fn_attrs.flags |= CodegenFnAttrFlags::FFI_RETURNS_TWICE
108-
}
109106
sym::ffi_pure => codegen_fn_attrs.flags |= CodegenFnAttrFlags::FFI_PURE,
110107
sym::ffi_const => codegen_fn_attrs.flags |= CodegenFnAttrFlags::FFI_CONST,
111108
sym::rustc_nounwind => codegen_fn_attrs.flags |= CodegenFnAttrFlags::NEVER_UNWIND,

compiler/rustc_error_codes/src/error_codes/E0724.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
#### Note: this error code is no longer emitted by the compiler.
2+
3+
14
`#[ffi_returns_twice]` was used on something other than a foreign function
25
declaration.
36

47
Erroneous code example:
58

6-
```compile_fail,E0724
9+
```compile_fail
710
#![feature(ffi_returns_twice)]
811
#![crate_type = "lib"]
912
@@ -15,7 +18,7 @@ pub fn foo() {}
1518
For example, we might correct the previous example by declaring
1619
the function inside of an `extern` block.
1720

18-
```
21+
```compile_fail
1922
#![feature(ffi_returns_twice)]
2023
2124
extern "C" {

compiler/rustc_feature/src/builtin_attrs.rs

-3
Original file line numberDiff line numberDiff line change
@@ -440,9 +440,6 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
440440
experimental!(optimize),
441441
),
442442

443-
gated!(
444-
ffi_returns_twice, Normal, template!(Word), WarnFollowing, experimental!(ffi_returns_twice)
445-
),
446443
gated!(ffi_pure, Normal, template!(Word), WarnFollowing, experimental!(ffi_pure)),
447444
gated!(ffi_const, Normal, template!(Word), WarnFollowing, experimental!(ffi_const)),
448445
gated!(

compiler/rustc_feature/src/removed.rs

+3
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ declare_features! (
9797
/// Allows `#[doc(include = "some-file")]`.
9898
(removed, external_doc, "1.54.0", Some(44732),
9999
Some("use #[doc = include_str!(\"filename\")] instead, which handles macro invocations")),
100+
/// Allows using `#[ffi_returns_twice]` on foreign functions.
101+
(removed, ffi_returns_twice, "CURRENT_RUSTC_VERSION", Some(58314),
102+
Some("being investigated by the ffi-unwind project group")),
100103
/// Allows generators to be cloned.
101104
(removed, generator_clone, "1.65.0", Some(95360), Some("renamed to `coroutine_clone`")),
102105
/// Allows defining generators.

compiler/rustc_feature/src/unstable.rs

-2
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,6 @@ declare_features! (
465465
(unstable, ffi_const, "1.45.0", Some(58328)),
466466
/// Allows the use of `#[ffi_pure]` on foreign functions.
467467
(unstable, ffi_pure, "1.45.0", Some(58329)),
468-
/// Allows using `#[ffi_returns_twice]` on foreign functions.
469-
(unstable, ffi_returns_twice, "1.34.0", Some(58314)),
470468
/// Allows using `#[repr(align(...))]` on function items
471469
(unstable, fn_align, "1.53.0", Some(82232)),
472470
/// Support delegating implementation of functions to other already implemented functions.

compiler/rustc_llvm/llvm-wrapper/LLVMWrapper.h

-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ enum LLVMRustAttribute {
7676
SanitizeMemory = 22,
7777
NonLazyBind = 23,
7878
OptimizeNone = 24,
79-
ReturnsTwice = 25,
8079
ReadNone = 26,
8180
SanitizeHWAddress = 28,
8281
WillReturn = 29,

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,6 @@ static Attribute::AttrKind fromRust(LLVMRustAttribute Kind) {
250250
return Attribute::NonLazyBind;
251251
case OptimizeNone:
252252
return Attribute::OptimizeNone;
253-
case ReturnsTwice:
254-
return Attribute::ReturnsTwice;
255253
case ReadNone:
256254
return Attribute::ReadNone;
257255
case SanitizeHWAddress:

compiler/rustc_middle/src/middle/codegen_fn_attrs.rs

+10-13
Original file line numberDiff line numberDiff line change
@@ -74,35 +74,32 @@ bitflags! {
7474
/// `#[used]`: indicates that LLVM can't eliminate this function (but the
7575
/// linker can!).
7676
const USED = 1 << 9;
77-
/// `#[ffi_returns_twice]`, indicates that an extern function can return
78-
/// multiple times
79-
const FFI_RETURNS_TWICE = 1 << 10;
8077
/// `#[track_caller]`: allow access to the caller location
81-
const TRACK_CALLER = 1 << 11;
78+
const TRACK_CALLER = 1 << 10;
8279
/// #[ffi_pure]: applies clang's `pure` attribute to a foreign function
8380
/// declaration.
84-
const FFI_PURE = 1 << 12;
81+
const FFI_PURE = 1 << 11;
8582
/// #[ffi_const]: applies clang's `const` attribute to a foreign function
8683
/// declaration.
87-
const FFI_CONST = 1 << 13;
84+
const FFI_CONST = 1 << 12;
8885
/// #[cmse_nonsecure_entry]: with a TrustZone-M extension, declare a
8986
/// function as an entry function from Non-Secure code.
90-
const CMSE_NONSECURE_ENTRY = 1 << 14;
87+
const CMSE_NONSECURE_ENTRY = 1 << 13;
9188
/// `#[coverage(off)]`: indicates that the function should be ignored by
9289
/// the MIR `InstrumentCoverage` pass and not added to the coverage map
9390
/// during codegen.
94-
const NO_COVERAGE = 1 << 15;
91+
const NO_COVERAGE = 1 << 14;
9592
/// `#[used(linker)]`:
9693
/// indicates that neither LLVM nor the linker will eliminate this function.
97-
const USED_LINKER = 1 << 16;
94+
const USED_LINKER = 1 << 15;
9895
/// `#[rustc_deallocator]`: a hint to LLVM that the function only deallocates memory.
99-
const DEALLOCATOR = 1 << 17;
96+
const DEALLOCATOR = 1 << 16;
10097
/// `#[rustc_reallocator]`: a hint to LLVM that the function only reallocates memory.
101-
const REALLOCATOR = 1 << 18;
98+
const REALLOCATOR = 1 << 17;
10299
/// `#[rustc_allocator_zeroed]`: a hint to LLVM that the function only allocates zeroed memory.
103-
const ALLOCATOR_ZEROED = 1 << 19;
100+
const ALLOCATOR_ZEROED = 1 << 18;
104101
/// `#[no_builtins]`: indicates that disable implicit builtin knowledge of functions for the function.
105-
const NO_BUILTINS = 1 << 20;
102+
const NO_BUILTINS = 1 << 19;
106103
}
107104
}
108105
rustc_data_structures::external_bitflags_debug! { CodegenFnAttrFlags }

compiler/rustc_passes/messages.ftl

-3
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,6 @@ passes_ffi_const_invalid_target =
323323
passes_ffi_pure_invalid_target =
324324
`#[ffi_pure]` may only be used on foreign functions
325325
326-
passes_ffi_returns_twice_invalid_target =
327-
`#[ffi_returns_twice]` may only be used on foreign functions
328-
329326
passes_has_incoherent_inherent_impl =
330327
`rustc_has_incoherent_inherent_impls` attribute should be applied to types or traits.
331328
.label = only adts, extern types and traits are supported

compiler/rustc_passes/src/check_attr.rs

-10
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
192192
}
193193
sym::ffi_pure => self.check_ffi_pure(attr.span, attrs, target),
194194
sym::ffi_const => self.check_ffi_const(attr.span, target),
195-
sym::ffi_returns_twice => self.check_ffi_returns_twice(attr.span, target),
196195
sym::rustc_const_unstable
197196
| sym::rustc_const_stable
198197
| sym::unstable
@@ -1309,15 +1308,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
13091308
}
13101309
}
13111310

1312-
fn check_ffi_returns_twice(&self, attr_span: Span, target: Target) -> bool {
1313-
if target == Target::ForeignFn {
1314-
true
1315-
} else {
1316-
self.dcx().emit_err(errors::FfiReturnsTwiceInvalidTarget { attr_span });
1317-
false
1318-
}
1319-
}
1320-
13211311
/// Warns against some misuses of `#[must_use]`
13221312
fn check_must_use(&self, hir_id: HirId, attr: &Attribute, target: Target) -> bool {
13231313
if !matches!(

compiler/rustc_passes/src/errors.rs

-7
Original file line numberDiff line numberDiff line change
@@ -390,13 +390,6 @@ pub struct FfiConstInvalidTarget {
390390
pub attr_span: Span,
391391
}
392392

393-
#[derive(Diagnostic)]
394-
#[diag(passes_ffi_returns_twice_invalid_target, code = E0724)]
395-
pub struct FfiReturnsTwiceInvalidTarget {
396-
#[primary_span]
397-
pub attr_span: Span,
398-
}
399-
400393
#[derive(LintDiagnostic)]
401394
#[diag(passes_must_use_async)]
402395
pub struct MustUseAsync {

src/tools/tidy/src/ui_tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use std::path::{Path, PathBuf};
1414
// #73494.
1515
const ENTRY_LIMIT: usize = 900;
1616
const ISSUES_ENTRY_LIMIT: usize = 1807;
17-
const ROOT_ENTRY_LIMIT: usize = 870;
17+
const ROOT_ENTRY_LIMIT: usize = 868;
1818

1919
const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
2020
"rs", // test source files

tests/codegen/cffi/ffi-returns-twice.rs

-11
This file was deleted.

tests/ui/feature-gates/feature-gate-ffi_returns_twice.rs

-6
This file was deleted.

tests/ui/feature-gates/feature-gate-ffi_returns_twice.stderr

-13
This file was deleted.

tests/ui/ffi_returns_twice.rs

-15
This file was deleted.

tests/ui/ffi_returns_twice.stderr

-21
This file was deleted.

0 commit comments

Comments
 (0)