Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stabilize #[unix_sigpipe = "sig_dfl"] on fn main() #120832

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(unix_sigpipe)]
#![cfg_attr(bootstrap, feature(unix_sigpipe))]

// A note about jemalloc: rustc uses jemalloc when built for CI and
// distribution. The obvious way to do this is with the `#[global_allocator]`
Expand Down
15 changes: 15 additions & 0 deletions compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,21 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
);
}
}
// Check unstable flavors of the `#[unix_sigpipe]` attribute.
if attr.has_name(sym::unix_sigpipe)
&& let Some(value) = attr.value_str()
&& (value == sym::sig_ign || value == sym::inherit)
{
gate!(
self,
unix_sigpipe,
attr.span,
format!(
"the `#[unix_sigpipe = \"{}\"]` attribute is an experimental feature",
value.as_str()
)
);
}

// Emit errors for non-staged-api crates.
if !self.features.staged_api {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_feature/src/builtin_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
),

// Entry point:
gated!(unix_sigpipe, Normal, template!(Word, NameValueStr: "inherit|sig_ign|sig_dfl"), ErrorFollowing, experimental!(unix_sigpipe)),
ungated!(unix_sigpipe, Normal, template!(Word, NameValueStr: "inherit|sig_ign|sig_dfl"), ErrorFollowing),
ungated!(start, Normal, template!(Word), WarnFollowing, @only_local: true),
ungated!(no_start, CrateLevel, template!(Word), WarnFollowing, @only_local: true),
ungated!(no_main, CrateLevel, template!(Word), WarnFollowing, @only_local: true),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ passes_undefined_naked_function_abi =
Rust ABI is unsupported in naked functions

passes_unix_sigpipe_values =
valid values for `#[unix_sigpipe = "..."]` are `inherit`, `sig_ign`, or `sig_dfl`
the only valid variant of the `unix_sigpipe` attribute is `#[unix_sigpipe = "sig_dfl"]`

passes_unknown_external_lang_item =
unknown external lang item: `{$lang_item}`
Expand Down
2 changes: 1 addition & 1 deletion src/tools/rustdoc/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(unix_sigpipe)]
#![cfg_attr(bootstrap, feature(unix_sigpipe))]

#[unix_sigpipe = "sig_dfl"]
fn main() {
Expand Down
6 changes: 4 additions & 2 deletions tests/ui/attributes/unix_sigpipe/unix_sigpipe-bare.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#![feature(unix_sigpipe)]
//@ revisions: with_feature without_feature

#[unix_sigpipe] //~ error: valid values for `#[unix_sigpipe = "..."]` are `inherit`, `sig_ign`, or `sig_dfl`
#![cfg_attr(with_feature, feature(unix_sigpipe))]

#[unix_sigpipe] //~ error: the only valid variant of the `unix_sigpipe` attribute is `#[unix_sigpipe = "sig_dfl"]
fn main() {}
8 changes: 0 additions & 8 deletions tests/ui/attributes/unix_sigpipe/unix_sigpipe-bare.stderr

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: the only valid variant of the `unix_sigpipe` attribute is `#[unix_sigpipe = "sig_dfl"]`
--> $DIR/unix_sigpipe-bare.rs:5:1
|
LL | #[unix_sigpipe]
| ^^^^^^^^^^^^^^^

error: aborting due to 1 previous error

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: the only valid variant of the `unix_sigpipe` attribute is `#[unix_sigpipe = "sig_dfl"]`
--> $DIR/unix_sigpipe-bare.rs:5:1
|
LL | #[unix_sigpipe]
| ^^^^^^^^^^^^^^^

error: aborting due to 1 previous error

6 changes: 4 additions & 2 deletions tests/ui/attributes/unix_sigpipe/unix_sigpipe-crate.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#![feature(unix_sigpipe)]
#![unix_sigpipe = "inherit"] //~ error: `unix_sigpipe` attribute cannot be used at crate level
//@ revisions: with_feature without_feature

#![cfg_attr(with_feature, feature(unix_sigpipe))]
#![unix_sigpipe = "sig_dfl"] //~ error: `unix_sigpipe` attribute cannot be used at crate level

fn main() {}
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
error: `unix_sigpipe` attribute cannot be used at crate level
--> $DIR/unix_sigpipe-crate.rs:2:1
--> $DIR/unix_sigpipe-crate.rs:4:1
|
LL | #![unix_sigpipe = "inherit"]
LL | #![unix_sigpipe = "sig_dfl"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL |
LL | fn main() {}
| ---- the inner attribute doesn't annotate this function
|
help: perhaps you meant to use an outer attribute
|
LL - #![unix_sigpipe = "inherit"]
LL + #[unix_sigpipe = "inherit"]
LL - #![unix_sigpipe = "sig_dfl"]
LL + #[unix_sigpipe = "sig_dfl"]
|

error: aborting due to 1 previous error
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
error: `unix_sigpipe` attribute cannot be used at crate level
--> $DIR/unix_sigpipe-crate.rs:4:1
|
LL | #![unix_sigpipe = "sig_dfl"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL |
LL | fn main() {}
| ---- the inner attribute doesn't annotate this function
|
help: perhaps you meant to use an outer attribute
|
LL - #![unix_sigpipe = "sig_dfl"]
LL + #[unix_sigpipe = "sig_dfl"]
|

error: aborting due to 1 previous error

Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#![feature(unix_sigpipe)]
//@ revisions: with_feature without_feature

#[unix_sigpipe = "sig_ign"]
#[unix_sigpipe = "inherit"] //~ error: multiple `unix_sigpipe` attributes
#![cfg_attr(with_feature, feature(unix_sigpipe))]

#[unix_sigpipe = "sig_dfl"]
#[unix_sigpipe = "sig_ign"] //[without_feature]~ the `#[unix_sigpipe = "sig_ign"]` attribute is an experimental feature
//~^ error: multiple `unix_sigpipe` attributes
fn main() {}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
error: multiple `unix_sigpipe` attributes
--> $DIR/unix_sigpipe-different-duplicates.rs:4:1
--> $DIR/unix_sigpipe-different-duplicates.rs:6:1
|
LL | #[unix_sigpipe = "inherit"]
LL | #[unix_sigpipe = "sig_ign"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
|
note: attribute also specified here
--> $DIR/unix_sigpipe-different-duplicates.rs:3:1
--> $DIR/unix_sigpipe-different-duplicates.rs:5:1
|
LL | #[unix_sigpipe = "sig_ign"]
LL | #[unix_sigpipe = "sig_dfl"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 1 previous error
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
error[E0658]: the `#[unix_sigpipe = "sig_ign"]` attribute is an experimental feature
--> $DIR/unix_sigpipe-different-duplicates.rs:6:1
|
LL | #[unix_sigpipe = "sig_ign"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #97889 <https://github.com/rust-lang/rust/issues/97889> for more information
= help: add `#![feature(unix_sigpipe)]` 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: multiple `unix_sigpipe` attributes
--> $DIR/unix_sigpipe-different-duplicates.rs:6:1
|
LL | #[unix_sigpipe = "sig_ign"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
|
note: attribute also specified here
--> $DIR/unix_sigpipe-different-duplicates.rs:5:1
|
LL | #[unix_sigpipe = "sig_dfl"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0658`.
8 changes: 5 additions & 3 deletions tests/ui/attributes/unix_sigpipe/unix_sigpipe-duplicates.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#![feature(unix_sigpipe)]
//@ revisions: with_feature without_feature

#[unix_sigpipe = "inherit"]
#[unix_sigpipe = "inherit"] //~ error: multiple `unix_sigpipe` attributes
#![cfg_attr(with_feature, feature(unix_sigpipe))]

#[unix_sigpipe = "sig_dfl"]
#[unix_sigpipe = "sig_dfl"] //~ error: multiple `unix_sigpipe` attributes
fn main() {}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
error: multiple `unix_sigpipe` attributes
--> $DIR/unix_sigpipe-duplicates.rs:4:1
--> $DIR/unix_sigpipe-duplicates.rs:6:1
|
LL | #[unix_sigpipe = "inherit"]
LL | #[unix_sigpipe = "sig_dfl"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
|
note: attribute also specified here
--> $DIR/unix_sigpipe-duplicates.rs:3:1
--> $DIR/unix_sigpipe-duplicates.rs:5:1
|
LL | #[unix_sigpipe = "inherit"]
LL | #[unix_sigpipe = "sig_dfl"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 1 previous error
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
error: multiple `unix_sigpipe` attributes
--> $DIR/unix_sigpipe-duplicates.rs:6:1
|
LL | #[unix_sigpipe = "sig_dfl"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
|
note: attribute also specified here
--> $DIR/unix_sigpipe-duplicates.rs:5:1
|
LL | #[unix_sigpipe = "sig_dfl"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 1 previous error

8 changes: 5 additions & 3 deletions tests/ui/attributes/unix_sigpipe/unix_sigpipe-inherit.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
//@ run-pass
//@ revisions: with_feature without_feature
//@ [with_feature]run-pass
//@ [without_feature]check-fail
//@ aux-build:sigpipe-utils.rs

#![feature(unix_sigpipe)]
#![cfg_attr(with_feature, feature(unix_sigpipe))]

#[unix_sigpipe = "inherit"]
#[unix_sigpipe = "inherit"] //[without_feature]~ ERROR the `#[unix_sigpipe = "inherit"]` attribute is an experimental feature
fn main() {
extern crate sigpipe_utils;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0658]: the `#[unix_sigpipe]` attribute is an experimental feature
--> $DIR/feature-gate-unix_sigpipe.rs:3:1
error[E0658]: the `#[unix_sigpipe = "inherit"]` attribute is an experimental feature
--> $DIR/unix_sigpipe-inherit.rs:8:1
|
LL | #[unix_sigpipe = "inherit"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
6 changes: 4 additions & 2 deletions tests/ui/attributes/unix_sigpipe/unix_sigpipe-list.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#![feature(unix_sigpipe)]
//@ revisions: with_feature without_feature

#[unix_sigpipe(inherit)] //~ error: malformed `unix_sigpipe` attribute input
#![cfg_attr(with_feature, feature(unix_sigpipe))]

#[unix_sigpipe(sig_dfl)] //~ error: malformed `unix_sigpipe` attribute input
fn main() {}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
error: malformed `unix_sigpipe` attribute input
--> $DIR/unix_sigpipe-list.rs:3:1
--> $DIR/unix_sigpipe-list.rs:5:1
|
LL | #[unix_sigpipe(inherit)]
LL | #[unix_sigpipe(sig_dfl)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
help: the following are the possible correct uses
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
error: malformed `unix_sigpipe` attribute input
--> $DIR/unix_sigpipe-list.rs:5:1
|
LL | #[unix_sigpipe(sig_dfl)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
help: the following are the possible correct uses
|
LL | #[unix_sigpipe = "inherit|sig_ign|sig_dfl"]
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
LL | #[unix_sigpipe]
| ~~~~~~~~~~~~~~~

error: aborting due to 1 previous error

6 changes: 4 additions & 2 deletions tests/ui/attributes/unix_sigpipe/unix_sigpipe-non-main-fn.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#![feature(unix_sigpipe)]
//@ revisions: with_feature without_feature

#[unix_sigpipe = "inherit"] //~ error: `unix_sigpipe` attribute can only be used on `fn main()`
#![cfg_attr(with_feature, feature(unix_sigpipe))]

#[unix_sigpipe = "sig_dfl"] //~ error: `unix_sigpipe` attribute can only be used on `fn main()`
fn f() {}

fn main() {}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
error: `unix_sigpipe` attribute can only be used on `fn main()`
--> $DIR/unix_sigpipe-non-main-fn.rs:3:1
--> $DIR/unix_sigpipe-non-main-fn.rs:5:1
|
LL | #[unix_sigpipe = "inherit"]
LL | #[unix_sigpipe = "sig_dfl"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 1 previous error
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: `unix_sigpipe` attribute can only be used on `fn main()`
--> $DIR/unix_sigpipe-non-main-fn.rs:5:1
|
LL | #[unix_sigpipe = "sig_dfl"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 1 previous error

Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#![feature(unix_sigpipe)]
//@ revisions: with_feature without_feature

#![cfg_attr(with_feature, feature(unix_sigpipe))]

mod m {
#[unix_sigpipe = "inherit"] //~ error: `unix_sigpipe` attribute can only be used on root `fn main()`
#[unix_sigpipe = "sig_dfl"] //~ error: `unix_sigpipe` attribute can only be used on root `fn main()`
fn main() {}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
error: `unix_sigpipe` attribute can only be used on root `fn main()`
--> $DIR/unix_sigpipe-non-root-main.rs:4:5
--> $DIR/unix_sigpipe-non-root-main.rs:6:5
|
LL | #[unix_sigpipe = "inherit"]
LL | #[unix_sigpipe = "sig_dfl"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 1 previous error
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: `unix_sigpipe` attribute can only be used on root `fn main()`
--> $DIR/unix_sigpipe-non-root-main.rs:6:5
|
LL | #[unix_sigpipe = "sig_dfl"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 1 previous error

3 changes: 2 additions & 1 deletion tests/ui/attributes/unix_sigpipe/unix_sigpipe-rustc_main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//@ revisions: with_feature without_feature
//@ run-pass
//@ aux-build:sigpipe-utils.rs

#![feature(unix_sigpipe)]
#![cfg_attr(with_feature, feature(unix_sigpipe))]
#![feature(rustc_attrs)]

#[unix_sigpipe = "sig_dfl"]
Expand Down
3 changes: 2 additions & 1 deletion tests/ui/attributes/unix_sigpipe/unix_sigpipe-sig_dfl.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//@ revisions: with_feature without_feature
//@ run-pass
//@ aux-build:sigpipe-utils.rs

#![feature(unix_sigpipe)]
#![cfg_attr(with_feature, feature(unix_sigpipe))]

#[unix_sigpipe = "sig_dfl"]
fn main() {
Expand Down
8 changes: 5 additions & 3 deletions tests/ui/attributes/unix_sigpipe/unix_sigpipe-sig_ign.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
//@ run-pass
//@ revisions: with_feature without_feature
//@ [with_feature]run-pass
//@ [without_feature]check-fail
//@ aux-build:sigpipe-utils.rs

#![feature(unix_sigpipe)]
#![cfg_attr(with_feature, feature(unix_sigpipe))]

#[unix_sigpipe = "sig_ign"]
#[unix_sigpipe = "sig_ign"] //[without_feature]~ the `#[unix_sigpipe = "sig_ign"]` attribute is an experimental feature
fn main() {
extern crate sigpipe_utils;

Expand Down
Loading
Loading