Rollup merge of #122293 - Enselic:no-bare-unix_sigpipe, r=fmease
diagnostics: Do not suggest using `#[unix_sigpipe]` without a value Remove `Word` from the `unix_sigpipe` attribute template so that plain `#[unix_sigpipe]` is not included in suggestions of valid forms of the attribute. Also re-arrange diagnostics code slightly to avoid duplicate diagnostics. Tracking issue is https://github.com/rust-lang/rust/issues/97889.
This commit is contained in:
commit
c4b159c4a0
5 changed files with 9 additions and 16 deletions
|
@ -389,7 +389,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
|
||||||
),
|
),
|
||||||
|
|
||||||
// Entry point:
|
// Entry point:
|
||||||
gated!(unix_sigpipe, Normal, template!(Word, NameValueStr: "inherit|sig_ign|sig_dfl"), ErrorFollowing, experimental!(unix_sigpipe)),
|
gated!(unix_sigpipe, Normal, template!(NameValueStr: "inherit|sig_ign|sig_dfl"), ErrorFollowing, experimental!(unix_sigpipe)),
|
||||||
ungated!(start, Normal, template!(Word), WarnFollowing, @only_local: true),
|
ungated!(start, Normal, template!(Word), WarnFollowing, @only_local: true),
|
||||||
ungated!(no_start, CrateLevel, 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),
|
ungated!(no_main, CrateLevel, template!(Word), WarnFollowing, @only_local: true),
|
||||||
|
|
|
@ -156,13 +156,13 @@ fn sigpipe(tcx: TyCtxt<'_>, def_id: DefId) -> u8 {
|
||||||
(Some(sym::inherit), None) => sigpipe::INHERIT,
|
(Some(sym::inherit), None) => sigpipe::INHERIT,
|
||||||
(Some(sym::sig_ign), None) => sigpipe::SIG_IGN,
|
(Some(sym::sig_ign), None) => sigpipe::SIG_IGN,
|
||||||
(Some(sym::sig_dfl), None) => sigpipe::SIG_DFL,
|
(Some(sym::sig_dfl), None) => sigpipe::SIG_DFL,
|
||||||
(_, Some(_)) => {
|
(Some(_), None) => {
|
||||||
// Keep going so that `fn emit_malformed_attribute()` can print
|
tcx.dcx().emit_err(UnixSigpipeValues { span: attr.span });
|
||||||
// an excellent error message
|
|
||||||
sigpipe::DEFAULT
|
sigpipe::DEFAULT
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
tcx.dcx().emit_err(UnixSigpipeValues { span: attr.span });
|
// Keep going so that `fn emit_malformed_attribute()` can print
|
||||||
|
// an excellent error message
|
||||||
sigpipe::DEFAULT
|
sigpipe::DEFAULT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#![feature(unix_sigpipe)]
|
#![feature(unix_sigpipe)]
|
||||||
|
|
||||||
#[unix_sigpipe] //~ error: valid values for `#[unix_sigpipe = "..."]` are `inherit`, `sig_ign`, or `sig_dfl`
|
#[unix_sigpipe] //~ error: malformed `unix_sigpipe` attribute input
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
error: valid values for `#[unix_sigpipe = "..."]` are `inherit`, `sig_ign`, or `sig_dfl`
|
error: malformed `unix_sigpipe` attribute input
|
||||||
--> $DIR/unix_sigpipe-bare.rs:3:1
|
--> $DIR/unix_sigpipe-bare.rs:3:1
|
||||||
|
|
|
|
||||||
LL | #[unix_sigpipe]
|
LL | #[unix_sigpipe]
|
||||||
| ^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^ help: must be of the form: `#[unix_sigpipe = "inherit|sig_ign|sig_dfl"]`
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,7 @@ error: malformed `unix_sigpipe` attribute input
|
||||||
--> $DIR/unix_sigpipe-list.rs:3:1
|
--> $DIR/unix_sigpipe-list.rs:3:1
|
||||||
|
|
|
|
||||||
LL | #[unix_sigpipe(inherit)]
|
LL | #[unix_sigpipe(inherit)]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[unix_sigpipe = "inherit|sig_ign|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
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue