Skip to content

Commit b6d7e9d

Browse files
committed
Stabilize #[unix_sigpipe = "sig_dfl"] on fn main()
The attribute is used like this: #[unix_sigpipe = "sig_dfl"] fn main() { // ... } When used, `SIGPIPE` will be set to `SIG_DFL` before `fn main()` is invoked, rather than being set to `SIG_IGN` which is the default. This commit does NOT stabilize `#[unix_sigpipe = "sig_ign"]` or `#[unix_sigpipe = "inherit"]`. See the PR for more info.
1 parent fcc64f2 commit b6d7e9d

File tree

48 files changed

+272
-64
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+272
-64
lines changed

compiler/rustc/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(unix_sigpipe)]
1+
#![cfg_attr(bootstrap, feature(unix_sigpipe))]
22

33
// A note about jemalloc: rustc uses jemalloc when built for CI and
44
// distribution. The obvious way to do this is with the `#[global_allocator]`

compiler/rustc_ast_passes/src/feature_gate.rs

+15
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,21 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
206206
);
207207
}
208208
}
209+
// Check unstable flavors of the `#[unix_sigpipe]` attribute.
210+
if attr.has_name(sym::unix_sigpipe)
211+
&& let Some(value) = attr.value_str()
212+
&& (value == sym::sig_ign || value == sym::inherit)
213+
{
214+
gate!(
215+
self,
216+
unix_sigpipe,
217+
attr.span,
218+
format!(
219+
"the `#[unix_sigpipe = \"{}\"]` attribute is an experimental feature",
220+
value.as_str()
221+
)
222+
);
223+
}
209224

210225
// Emit errors for non-staged-api crates.
211226
if !self.features.staged_api {

compiler/rustc_feature/src/builtin_attrs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
389389
),
390390

391391
// Entry point:
392-
gated!(unix_sigpipe, Normal, template!(Word, NameValueStr: "inherit|sig_ign|sig_dfl"), ErrorFollowing, experimental!(unix_sigpipe)),
392+
ungated!(unix_sigpipe, Normal, template!(Word, NameValueStr: "inherit|sig_ign|sig_dfl"), ErrorFollowing),
393393
ungated!(start, Normal, template!(Word), WarnFollowing, @only_local: true),
394394
ungated!(no_start, CrateLevel, template!(Word), WarnFollowing, @only_local: true),
395395
ungated!(no_main, CrateLevel, template!(Word), WarnFollowing, @only_local: true),

compiler/rustc_passes/messages.ftl

+1-1
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ passes_undefined_naked_function_abi =
692692
Rust ABI is unsupported in naked functions
693693
694694
passes_unix_sigpipe_values =
695-
valid values for `#[unix_sigpipe = "..."]` are `inherit`, `sig_ign`, or `sig_dfl`
695+
the only valid variant of the `unix_sigpipe` attribute is `#[unix_sigpipe = "sig_dfl"]`
696696
697697
passes_unknown_external_lang_item =
698698
unknown external lang item: `{$lang_item}`

src/tools/rustdoc/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(unix_sigpipe)]
1+
#![cfg_attr(bootstrap, feature(unix_sigpipe))]
22

33
#[unix_sigpipe = "sig_dfl"]
44
fn main() {
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
#![feature(unix_sigpipe)]
1+
//@ revisions: with_feature without_feature
22

3-
#[unix_sigpipe] //~ error: valid values for `#[unix_sigpipe = "..."]` are `inherit`, `sig_ign`, or `sig_dfl`
3+
#![cfg_attr(with_feature, feature(unix_sigpipe))]
4+
5+
#[unix_sigpipe] //~ error: the only valid variant of the `unix_sigpipe` attribute is `#[unix_sigpipe = "sig_dfl"]
46
fn main() {}

tests/ui/attributes/unix_sigpipe/unix_sigpipe-bare.stderr

-8
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: the only valid variant of the `unix_sigpipe` attribute is `#[unix_sigpipe = "sig_dfl"]`
2+
--> $DIR/unix_sigpipe-bare.rs:5:1
3+
|
4+
LL | #[unix_sigpipe]
5+
| ^^^^^^^^^^^^^^^
6+
7+
error: aborting due to 1 previous error
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: the only valid variant of the `unix_sigpipe` attribute is `#[unix_sigpipe = "sig_dfl"]`
2+
--> $DIR/unix_sigpipe-bare.rs:5:1
3+
|
4+
LL | #[unix_sigpipe]
5+
| ^^^^^^^^^^^^^^^
6+
7+
error: aborting due to 1 previous error
8+
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
#![feature(unix_sigpipe)]
1+
//@ revisions: with_feature without_feature
2+
3+
#![cfg_attr(with_feature, feature(unix_sigpipe))]
24
#![unix_sigpipe = "sig_dfl"] //~ error: `unix_sigpipe` attribute cannot be used at crate level
35

46
fn main() {}

tests/ui/attributes/unix_sigpipe/unix_sigpipe-crate.stderr tests/ui/attributes/unix_sigpipe/unix_sigpipe-crate.with_feature.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: `unix_sigpipe` attribute cannot be used at crate level
2-
--> $DIR/unix_sigpipe-crate.rs:2:1
2+
--> $DIR/unix_sigpipe-crate.rs:4:1
33
|
44
LL | #![unix_sigpipe = "sig_dfl"]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error: `unix_sigpipe` attribute cannot be used at crate level
2+
--> $DIR/unix_sigpipe-crate.rs:4:1
3+
|
4+
LL | #![unix_sigpipe = "sig_dfl"]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
LL |
7+
LL | fn main() {}
8+
| ---- the inner attribute doesn't annotate this function
9+
|
10+
help: perhaps you meant to use an outer attribute
11+
|
12+
LL - #![unix_sigpipe = "sig_dfl"]
13+
LL + #[unix_sigpipe = "sig_dfl"]
14+
|
15+
16+
error: aborting due to 1 previous error
17+
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
#![feature(unix_sigpipe)]
1+
//@ revisions: with_feature without_feature
22

3-
#[unix_sigpipe = "sig_ign"]
4-
#[unix_sigpipe = "inherit"] //~ error: multiple `unix_sigpipe` attributes
3+
#![cfg_attr(with_feature, feature(unix_sigpipe))]
4+
5+
#[unix_sigpipe = "sig_dfl"]
6+
#[unix_sigpipe = "sig_ign"] //[without_feature]~ the `#[unix_sigpipe = "sig_ign"]` attribute is an experimental feature
7+
//~^ error: multiple `unix_sigpipe` attributes
58
fn main() {}

tests/ui/attributes/unix_sigpipe/unix_sigpipe-different-duplicates.stderr tests/ui/attributes/unix_sigpipe/unix_sigpipe-different-duplicates.with_feature.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error: multiple `unix_sigpipe` attributes
2-
--> $DIR/unix_sigpipe-different-duplicates.rs:4:1
2+
--> $DIR/unix_sigpipe-different-duplicates.rs:6:1
33
|
4-
LL | #[unix_sigpipe = "inherit"]
4+
LL | #[unix_sigpipe = "sig_ign"]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
66
|
77
note: attribute also specified here
8-
--> $DIR/unix_sigpipe-different-duplicates.rs:3:1
8+
--> $DIR/unix_sigpipe-different-duplicates.rs:5:1
99
|
10-
LL | #[unix_sigpipe = "sig_ign"]
10+
LL | #[unix_sigpipe = "sig_dfl"]
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212

1313
error: aborting due to 1 previous error
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
error[E0658]: the `#[unix_sigpipe = "sig_ign"]` attribute is an experimental feature
2+
--> $DIR/unix_sigpipe-different-duplicates.rs:6:1
3+
|
4+
LL | #[unix_sigpipe = "sig_ign"]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #97889 <https://github.com/rust-lang/rust/issues/97889> for more information
8+
= help: add `#![feature(unix_sigpipe)]` to the crate attributes to enable
9+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
10+
11+
error: multiple `unix_sigpipe` attributes
12+
--> $DIR/unix_sigpipe-different-duplicates.rs:6:1
13+
|
14+
LL | #[unix_sigpipe = "sig_ign"]
15+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
16+
|
17+
note: attribute also specified here
18+
--> $DIR/unix_sigpipe-different-duplicates.rs:5:1
19+
|
20+
LL | #[unix_sigpipe = "sig_dfl"]
21+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
22+
23+
error: aborting due to 2 previous errors
24+
25+
For more information about this error, try `rustc --explain E0658`.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
#![feature(unix_sigpipe)]
1+
//@ revisions: with_feature without_feature
22

3-
#[unix_sigpipe = "inherit"]
4-
#[unix_sigpipe = "inherit"] //~ error: multiple `unix_sigpipe` attributes
3+
#![cfg_attr(with_feature, feature(unix_sigpipe))]
4+
5+
#[unix_sigpipe = "sig_dfl"]
6+
#[unix_sigpipe = "sig_dfl"] //~ error: multiple `unix_sigpipe` attributes
57
fn main() {}

tests/ui/attributes/unix_sigpipe/unix_sigpipe-duplicates.stderr tests/ui/attributes/unix_sigpipe/unix_sigpipe-duplicates.with_feature.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error: multiple `unix_sigpipe` attributes
2-
--> $DIR/unix_sigpipe-duplicates.rs:4:1
2+
--> $DIR/unix_sigpipe-duplicates.rs:6:1
33
|
4-
LL | #[unix_sigpipe = "inherit"]
4+
LL | #[unix_sigpipe = "sig_dfl"]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
66
|
77
note: attribute also specified here
8-
--> $DIR/unix_sigpipe-duplicates.rs:3:1
8+
--> $DIR/unix_sigpipe-duplicates.rs:5:1
99
|
10-
LL | #[unix_sigpipe = "inherit"]
10+
LL | #[unix_sigpipe = "sig_dfl"]
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212

1313
error: aborting due to 1 previous error
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error: multiple `unix_sigpipe` attributes
2+
--> $DIR/unix_sigpipe-duplicates.rs:6:1
3+
|
4+
LL | #[unix_sigpipe = "sig_dfl"]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
6+
|
7+
note: attribute also specified here
8+
--> $DIR/unix_sigpipe-duplicates.rs:5:1
9+
|
10+
LL | #[unix_sigpipe = "sig_dfl"]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
13+
error: aborting due to 1 previous error
14+

tests/ui/attributes/unix_sigpipe/unix_sigpipe-inherit.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
//@ run-pass
1+
//@ revisions: with_feature without_feature
2+
//@ [with_feature]run-pass
3+
//@ [without_feature]check-fail
24
//@ aux-build:sigpipe-utils.rs
35

4-
#![feature(unix_sigpipe)]
6+
#![cfg_attr(with_feature, feature(unix_sigpipe))]
57

6-
#[unix_sigpipe = "inherit"]
8+
#[unix_sigpipe = "inherit"] //[without_feature]~ ERROR the `#[unix_sigpipe = "inherit"]` attribute is an experimental feature
79
fn main() {
810
extern crate sigpipe_utils;
911

tests/ui/feature-gates/feature-gate-unix_sigpipe.stderr tests/ui/attributes/unix_sigpipe/unix_sigpipe-inherit.without_feature.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
error[E0658]: the `#[unix_sigpipe]` attribute is an experimental feature
2-
--> $DIR/feature-gate-unix_sigpipe.rs:3:1
1+
error[E0658]: the `#[unix_sigpipe = "inherit"]` attribute is an experimental feature
2+
--> $DIR/unix_sigpipe-inherit.rs:8:1
33
|
44
LL | #[unix_sigpipe = "inherit"]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
#![feature(unix_sigpipe)]
1+
//@ revisions: with_feature without_feature
2+
3+
#![cfg_attr(with_feature, feature(unix_sigpipe))]
24

35
#[unix_sigpipe(sig_dfl)] //~ error: malformed `unix_sigpipe` attribute input
46
fn main() {}

tests/ui/attributes/unix_sigpipe/unix_sigpipe-list.stderr tests/ui/attributes/unix_sigpipe/unix_sigpipe-list.with_feature.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: malformed `unix_sigpipe` attribute input
2-
--> $DIR/unix_sigpipe-list.rs:3:1
2+
--> $DIR/unix_sigpipe-list.rs:5:1
33
|
44
LL | #[unix_sigpipe(sig_dfl)]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error: malformed `unix_sigpipe` attribute input
2+
--> $DIR/unix_sigpipe-list.rs:5:1
3+
|
4+
LL | #[unix_sigpipe(sig_dfl)]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
help: the following are the possible correct uses
8+
|
9+
LL | #[unix_sigpipe = "inherit|sig_ign|sig_dfl"]
10+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11+
LL | #[unix_sigpipe]
12+
| ~~~~~~~~~~~~~~~
13+
14+
error: aborting due to 1 previous error
15+

tests/ui/attributes/unix_sigpipe/unix_sigpipe-non-main-fn.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
#![feature(unix_sigpipe)]
1+
//@ revisions: with_feature without_feature
2+
3+
#![cfg_attr(with_feature, feature(unix_sigpipe))]
24

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

tests/ui/attributes/unix_sigpipe/unix_sigpipe-non-main-fn.stderr tests/ui/attributes/unix_sigpipe/unix_sigpipe-non-main-fn.with_feature.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: `unix_sigpipe` attribute can only be used on `fn main()`
2-
--> $DIR/unix_sigpipe-non-main-fn.rs:3:1
2+
--> $DIR/unix_sigpipe-non-main-fn.rs:5:1
33
|
44
LL | #[unix_sigpipe = "sig_dfl"]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: `unix_sigpipe` attribute can only be used on `fn main()`
2+
--> $DIR/unix_sigpipe-non-main-fn.rs:5:1
3+
|
4+
LL | #[unix_sigpipe = "sig_dfl"]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
7+
error: aborting due to 1 previous error
8+

tests/ui/attributes/unix_sigpipe/unix_sigpipe-non-root-main.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
#![feature(unix_sigpipe)]
1+
//@ revisions: with_feature without_feature
2+
3+
#![cfg_attr(with_feature, feature(unix_sigpipe))]
24

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

tests/ui/attributes/unix_sigpipe/unix_sigpipe-non-root-main.stderr tests/ui/attributes/unix_sigpipe/unix_sigpipe-non-root-main.with_feature.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: `unix_sigpipe` attribute can only be used on root `fn main()`
2-
--> $DIR/unix_sigpipe-non-root-main.rs:4:5
2+
--> $DIR/unix_sigpipe-non-root-main.rs:6:5
33
|
44
LL | #[unix_sigpipe = "sig_dfl"]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: `unix_sigpipe` attribute can only be used on root `fn main()`
2+
--> $DIR/unix_sigpipe-non-root-main.rs:6:5
3+
|
4+
LL | #[unix_sigpipe = "sig_dfl"]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
7+
error: aborting due to 1 previous error
8+

tests/ui/attributes/unix_sigpipe/unix_sigpipe-rustc_main.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
//@ revisions: with_feature without_feature
12
//@ run-pass
23
//@ aux-build:sigpipe-utils.rs
34

4-
#![feature(unix_sigpipe)]
5+
#![cfg_attr(with_feature, feature(unix_sigpipe))]
56
#![feature(rustc_attrs)]
67

78
#[unix_sigpipe = "sig_dfl"]

tests/ui/attributes/unix_sigpipe/unix_sigpipe-sig_dfl.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
//@ revisions: with_feature without_feature
12
//@ run-pass
23
//@ aux-build:sigpipe-utils.rs
34

4-
#![feature(unix_sigpipe)]
5+
#![cfg_attr(with_feature, feature(unix_sigpipe))]
56

67
#[unix_sigpipe = "sig_dfl"]
78
fn main() {

tests/ui/attributes/unix_sigpipe/unix_sigpipe-sig_ign.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
//@ run-pass
1+
//@ revisions: with_feature without_feature
2+
//@ [with_feature]run-pass
3+
//@ [without_feature]check-fail
24
//@ aux-build:sigpipe-utils.rs
35

4-
#![feature(unix_sigpipe)]
6+
#![cfg_attr(with_feature, feature(unix_sigpipe))]
57

6-
#[unix_sigpipe = "sig_ign"]
8+
#[unix_sigpipe = "sig_ign"] //[without_feature]~ the `#[unix_sigpipe = "sig_ign"]` attribute is an experimental feature
79
fn main() {
810
extern crate sigpipe_utils;
911

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error[E0658]: the `#[unix_sigpipe = "sig_ign"]` attribute is an experimental feature
2+
--> $DIR/unix_sigpipe-sig_ign.rs:8:1
3+
|
4+
LL | #[unix_sigpipe = "sig_ign"]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #97889 <https://github.com/rust-lang/rust/issues/97889> for more information
8+
= help: add `#![feature(unix_sigpipe)]` to the crate attributes to enable
9+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
10+
11+
error: aborting due to 1 previous error
12+
13+
For more information about this error, try `rustc --explain E0658`.

tests/ui/attributes/unix_sigpipe/unix_sigpipe-start.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
//@ revisions: with_feature without_feature
2+
13
#![feature(start)]
2-
#![feature(unix_sigpipe)]
4+
#![cfg_attr(with_feature, feature(unix_sigpipe))]
35

46
#[start]
57
#[unix_sigpipe = "sig_dfl"] //~ error: `unix_sigpipe` attribute can only be used on `fn main()`

tests/ui/attributes/unix_sigpipe/unix_sigpipe-start.stderr tests/ui/attributes/unix_sigpipe/unix_sigpipe-start.with_feature.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: `unix_sigpipe` attribute can only be used on `fn main()`
2-
--> $DIR/unix_sigpipe-start.rs:5:1
2+
--> $DIR/unix_sigpipe-start.rs:7:1
33
|
44
LL | #[unix_sigpipe = "sig_dfl"]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/ui/attributes/unix_sigpipe/unix_sigpipe-struct.stderr tests/ui/attributes/unix_sigpipe/unix_sigpipe-start.without_feature.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: `unix_sigpipe` attribute can only be used on `fn main()`
2-
--> $DIR/unix_sigpipe-struct.rs:3:1
2+
--> $DIR/unix_sigpipe-start.rs:7:1
33
|
44
LL | #[unix_sigpipe = "sig_dfl"]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)