Skip to content

Commit 775ee4e

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 23358c3 commit 775ee4e

File tree

49 files changed

+265
-65
lines changed

Some content is hidden

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

49 files changed

+265
-65
lines changed

compiler/rustc/src/main.rs

Lines changed: 1 addition & 1 deletion
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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,21 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
200200
);
201201
}
202202
}
203+
// Check unstable flavors of the `#[unix_sigpipe]` attribute.
204+
if attr.has_name(sym::unix_sigpipe)
205+
&& let Some(value) = attr.value_str()
206+
&& (value == sym::sig_ign || value == sym::inherit)
207+
{
208+
gate!(
209+
self,
210+
unix_sigpipe,
211+
attr.span,
212+
format!(
213+
"the `#[unix_sigpipe = \"{}\"]` attribute is an experimental feature",
214+
value.as_str()
215+
)
216+
);
217+
}
203218
if !attr.is_doc_comment()
204219
&& let [seg, _] = attr.get_normal_item().path.segments.as_slice()
205220
&& seg.ident.name == sym::diagnostic

compiler/rustc_feature/src/builtin_attrs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
364364
),
365365

366366
// Entry point:
367-
gated!(unix_sigpipe, Normal, template!(Word, NameValueStr: "inherit|sig_ign|sig_dfl"), ErrorFollowing, experimental!(unix_sigpipe)),
367+
ungated!(unix_sigpipe, Normal, template!(Word, NameValueStr: "inherit|sig_ign|sig_dfl"), ErrorFollowing),
368368
ungated!(start, Normal, template!(Word), WarnFollowing),
369369
ungated!(no_start, CrateLevel, template!(Word), WarnFollowing),
370370
ungated!(no_main, CrateLevel, template!(Word), WarnFollowing),

compiler/rustc_passes/messages.ftl

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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() {
Lines changed: 4 additions & 2 deletions
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

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
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+
Lines changed: 8 additions & 0 deletions
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+
Lines changed: 3 additions & 1 deletion
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() {}

0 commit comments

Comments
 (0)