diff --git a/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs index 688854d6c74f..3cb75e41825e 100644 --- a/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs @@ -23,16 +23,7 @@ impl SingleAttributeParser for OptimizeParser { const TEMPLATE: AttributeTemplate = template!(List: &["size", "speed", "none"]); fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option { - let Some(list) = args.list() else { - let attr_span = cx.attr_span; - cx.adcx().expected_list(attr_span, args); - return None; - }; - - let Some(single) = list.single() else { - cx.adcx().expected_single_argument(list.span, list.len()); - return None; - }; + let single = cx.single_element_list(args, cx.attr_span)?; let res = match single.meta_item().and_then(|i| i.path().word().map(|i| i.name)) { Some(sym::size) => OptimizeAttr::Size, @@ -84,22 +75,13 @@ impl SingleAttributeParser for CoverageParser { const TEMPLATE: AttributeTemplate = template!(OneOf: &[sym::off, sym::on]); fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option { - let Some(args) = args.list() else { - let attr_span = cx.attr_span; - cx.adcx().expected_specific_argument_and_list(attr_span, &[sym::on, sym::off]); - return None; - }; - - let Some(arg) = args.single() else { - cx.adcx().expected_single_argument(args.span, args.len()); - return None; - }; + let arg = cx.single_element_list(args, cx.attr_span)?; let mut fail_incorrect_argument = |span| cx.adcx().expected_specific_argument(span, &[sym::on, sym::off]); let Some(arg) = arg.meta_item() else { - fail_incorrect_argument(args.span); + fail_incorrect_argument(arg.span()); return None; }; diff --git a/compiler/rustc_attr_parsing/src/attributes/debugger.rs b/compiler/rustc_attr_parsing/src/attributes/debugger.rs index 06180e74c9e2..65e9b968e946 100644 --- a/compiler/rustc_attr_parsing/src/attributes/debugger.rs +++ b/compiler/rustc_attr_parsing/src/attributes/debugger.rs @@ -20,15 +20,7 @@ fn extend( cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser, ) -> impl IntoIterator { - let Some(l) = args.list() else { - let attr_span = cx.attr_span; - cx.adcx().expected_list(attr_span, args); - return None; - }; - let Some(single) = l.single() else { - cx.adcx().expected_single_argument(l.span, l.len()); - return None; - }; + let single = cx.single_element_list(args, cx.attr_span)?; let Some(mi) = single.meta_item() else { cx.adcx().expected_name_value(single.span(), None); return None; diff --git a/compiler/rustc_attr_parsing/src/attributes/instruction_set.rs b/compiler/rustc_attr_parsing/src/attributes/instruction_set.rs index 00e2241f2e70..4003aba76af8 100644 --- a/compiler/rustc_attr_parsing/src/attributes/instruction_set.rs +++ b/compiler/rustc_attr_parsing/src/attributes/instruction_set.rs @@ -20,11 +20,7 @@ impl SingleAttributeParser for InstructionSetParser { fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option { const POSSIBLE_SYMBOLS: &[Symbol] = &[sym::arm_a32, sym::arm_t32]; const POSSIBLE_ARM_SYMBOLS: &[Symbol] = &[sym::a32, sym::t32]; - let Some(maybe_meta_item) = args.list().and_then(MetaItemListParser::single) else { - let attr_span = cx.attr_span; - cx.adcx().expected_specific_argument(attr_span, POSSIBLE_SYMBOLS); - return None; - }; + let maybe_meta_item = cx.single_element_list(args, cx.attr_span)?; let Some(meta_item) = maybe_meta_item.meta_item() else { cx.adcx().expected_specific_argument(maybe_meta_item.span(), POSSIBLE_SYMBOLS); diff --git a/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs index 5989f4100b7e..8aa7759daa04 100644 --- a/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs @@ -388,12 +388,7 @@ fn parse_link_cfg( cx.adcx().duplicate_key(item.span(), sym::cfg); return true; } - let Some(link_cfg) = item.args().list() else { - cx.adcx().expected_list(item.span(), item.args()); - return true; - }; - let Some(link_cfg) = link_cfg.single() else { - cx.adcx().expected_single_argument(item.span(), link_cfg.len()); + let Some(link_cfg) = cx.single_element_list(item.args(), item.span()) else { return true; }; if !features.link_cfg() { diff --git a/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs index 4a2ef91ba83d..a0ded93180eb 100644 --- a/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs @@ -175,15 +175,7 @@ impl SingleAttributeParser for CollapseDebugInfoParser { const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::MacroDef)]); fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option { - let Some(list) = args.list() else { - let attr_span = cx.attr_span; - cx.adcx().expected_list(attr_span, args); - return None; - }; - let Some(single) = list.single() else { - cx.adcx().expected_single_argument(list.span, list.len()); - return None; - }; + let single = cx.single_element_list(args, cx.attr_span)?; let Some(mi) = single.meta_item() else { cx.adcx().expected_not_literal(single.span()); return None; diff --git a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs index 31531a02d688..b45b2405ea8e 100644 --- a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs +++ b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs @@ -195,11 +195,7 @@ impl SingleAttributeParser for RustcLintOptDenyFieldAccessParser { const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Field)]); const TEMPLATE: AttributeTemplate = template!(Word); fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option { - let Some(arg) = args.list().and_then(MetaItemListParser::single) else { - let attr_span = cx.attr_span; - cx.adcx().expected_single_argument(attr_span, 2); - return None; - }; + let arg = cx.single_element_list(args, cx.attr_span)?; let MetaItemOrLitParser::Lit(MetaItemLit { kind: LitKind::Str(lint_message, _), .. }) = arg else { @@ -375,19 +371,10 @@ impl SingleAttributeParser for RustcDeprecatedSafe2024Parser { const TEMPLATE: AttributeTemplate = template!(List: &[r#"audit_that = "...""#]); fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option { - let Some(args) = args.list() else { - let attr_span = cx.attr_span; - cx.adcx().expected_list(attr_span, args); - return None; - }; - - let Some(single) = args.single() else { - cx.adcx().expected_single_argument(args.span, args.len()); - return None; - }; + let single = cx.single_element_list(args, cx.attr_span)?; let Some(arg) = single.meta_item() else { - cx.adcx().expected_name_value(args.span, None); + cx.adcx().expected_name_value(single.span(), None); return None; }; @@ -1082,11 +1069,7 @@ fn extend( if !cx.cx.sess.opts.unstable_opts.query_dep_graph { cx.emit_err(AttributeRequiresOpt { span: cx.attr_span, opt: "-Z query-dep-graph" }); } - let Some(item) = args.list().and_then(|l| l.single()) else { - let inner_span = cx.inner_span; - cx.adcx().expected_single_argument(inner_span, 2); - return None; - }; + let item = cx.single_element_list(args, cx.attr_span)?; let Some(ident) = item.meta_item().and_then(|item| item.ident()) else { cx.adcx().expected_identifier(item.span()); return None; diff --git a/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs index 7657b3738305..4fe0f079bc83 100644 --- a/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs @@ -208,16 +208,7 @@ impl SingleAttributeParser for TestRunnerParser { const TEMPLATE: AttributeTemplate = template!(List: &["path"]); fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser) -> Option { - let Some(list) = args.list() else { - let attr_span = cx.attr_span; - cx.adcx().expected_list(attr_span, args); - return None; - }; - - let Some(single) = list.single() else { - cx.adcx().expected_single_argument(list.span, list.len()); - return None; - }; + let single = cx.single_element_list(args, cx.attr_span)?; let Some(meta) = single.meta_item() else { cx.adcx().expected_not_literal(single.span()); diff --git a/compiler/rustc_attr_parsing/src/attributes/util.rs b/compiler/rustc_attr_parsing/src/attributes/util.rs index 392942ce31e9..98f8cc23b500 100644 --- a/compiler/rustc_attr_parsing/src/attributes/util.rs +++ b/compiler/rustc_attr_parsing/src/attributes/util.rs @@ -41,15 +41,7 @@ pub(crate) fn parse_single_integer( cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser, ) -> Option { - let Some(list) = args.list() else { - let attr_span = cx.attr_span; - cx.adcx().expected_list(attr_span, args); - return None; - }; - let Some(single) = list.single() else { - cx.adcx().expected_single_argument(list.span, list.len()); - return None; - }; + let single = cx.single_element_list(args, cx.attr_span)?; let Some(lit) = single.lit() else { cx.adcx().expected_integer_literal(single.span()); return None; diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index 4176b59984a4..46e255af2270 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -60,7 +60,7 @@ use crate::attributes::traits::*; use crate::attributes::transparency::*; use crate::attributes::{AttributeParser as _, Combine, Single, WithoutArgs}; -use crate::parser::{ArgParser, RefPathParser}; +use crate::parser::{ArgParser, MetaItemOrLitParser, RefPathParser}; use crate::session_diagnostics::{ AttributeParseError, AttributeParseErrorReason, AttributeParseErrorSuggestions, ParsedDescription, @@ -502,6 +502,36 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> { pub(crate) fn adcx(&mut self) -> AttributeDiagnosticContext<'_, 'f, 'sess, S> { AttributeDiagnosticContext { ctx: self, custom_suggestions: Vec::new() } } + + /// Asserts that this MetaItem is a list that contains a single element. Emits an error and + /// returns `None` if it is not the case. + /// + /// Some examples: + /// + /// - In `#[allow(warnings)]`, `warnings` is returned + /// - In `#[cfg_attr(docsrs, doc = "foo")]`, `None` is returned, "expected a single argument + /// here" is emitted. + /// - In `#[cfg()]`, `None` is returned, "expected an argument here" is emitted. + /// + /// The provided span is used as a fallback for diagnostic generation in case `arg` does not + /// contain any. It should be the span of the node that contains `arg`. + pub(crate) fn single_element_list<'arg>( + &mut self, + arg: &'arg ArgParser, + span: Span, + ) -> Option<&'arg MetaItemOrLitParser> { + let ArgParser::List(l) = arg else { + self.adcx().expected_list(span, arg); + return None; + }; + + let Some(single) = l.single() else { + self.adcx().expected_single_argument(l.span, l.len()); + return None; + }; + + Some(single) + } } impl<'f, 'sess, S: Stage> Deref for AcceptContext<'f, 'sess, S> { @@ -689,6 +719,8 @@ pub(crate) fn expected_integer_literal_in_range( ) } + /// The provided span is used as a fallback in case `args` does not contain any. It should be + /// the span of the node that contains `args`. pub(crate) fn expected_list(&mut self, span: Span, args: &ArgParser) -> ErrorGuaranteed { let span = match args { ArgParser::NoArgs => span, @@ -745,7 +777,7 @@ pub(crate) fn duplicate_key(&mut self, span: Span, key: Symbol) -> ErrorGuarante self.emit_parse_error(span, AttributeParseErrorReason::DuplicateKey(key)) } - /// An error that should be emitted when a [`MetaItemOrLitParser`](crate::parser::MetaItemOrLitParser) + /// An error that should be emitted when a [`MetaItemOrLitParser`] /// was expected *not* to be a literal, but instead a meta item. pub(crate) fn expected_not_literal(&mut self, span: Span) -> ErrorGuaranteed { self.emit_parse_error(span, AttributeParseErrorReason::ExpectedNotLiteral) diff --git a/tests/ui/attributes/malformed-attrs.stderr b/tests/ui/attributes/malformed-attrs.stderr index c344db0bf218..ab9de6f797f5 100644 --- a/tests/ui/attributes/malformed-attrs.stderr +++ b/tests/ui/attributes/malformed-attrs.stderr @@ -314,7 +314,7 @@ error[E0539]: malformed `coverage` attribute input --> $DIR/malformed-attrs.rs:92:1 | LL | #[coverage] - | ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument + | ^^^^^^^^^^^ expected this to be a list | help: try changing it to one of the following valid forms of the attribute | @@ -353,7 +353,7 @@ error[E0539]: malformed `instruction_set` attribute input LL | #[instruction_set] | ^^^^^^^^^^^^^^^^^^ | | - | valid arguments are `arm::a32` or `arm::t32` + | expected this to be a list | help: must be of the form: `#[instruction_set(set)]` | = note: for more information, visit diff --git a/tests/ui/coverage-attr/bad-attr-ice.feat.stderr b/tests/ui/coverage-attr/bad-attr-ice.feat.stderr index 5a003af42da5..ee4011b9d773 100644 --- a/tests/ui/coverage-attr/bad-attr-ice.feat.stderr +++ b/tests/ui/coverage-attr/bad-attr-ice.feat.stderr @@ -2,7 +2,7 @@ error[E0539]: malformed `coverage` attribute input --> $DIR/bad-attr-ice.rs:11:1 | LL | #[coverage] - | ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument + | ^^^^^^^^^^^ expected this to be a list | help: try changing it to one of the following valid forms of the attribute | diff --git a/tests/ui/coverage-attr/bad-attr-ice.nofeat.stderr b/tests/ui/coverage-attr/bad-attr-ice.nofeat.stderr index 4501e5e9dc82..7feef95a7930 100644 --- a/tests/ui/coverage-attr/bad-attr-ice.nofeat.stderr +++ b/tests/ui/coverage-attr/bad-attr-ice.nofeat.stderr @@ -12,7 +12,7 @@ error[E0539]: malformed `coverage` attribute input --> $DIR/bad-attr-ice.rs:11:1 | LL | #[coverage] - | ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument + | ^^^^^^^^^^^ expected this to be a list | help: try changing it to one of the following valid forms of the attribute | diff --git a/tests/ui/coverage-attr/bad-syntax.stderr b/tests/ui/coverage-attr/bad-syntax.stderr index 8e36e9593028..522dd06e87b0 100644 --- a/tests/ui/coverage-attr/bad-syntax.stderr +++ b/tests/ui/coverage-attr/bad-syntax.stderr @@ -26,7 +26,7 @@ error[E0539]: malformed `coverage` attribute input --> $DIR/bad-syntax.rs:17:1 | LL | #[coverage] - | ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument + | ^^^^^^^^^^^ expected this to be a list | help: try changing it to one of the following valid forms of the attribute | @@ -39,7 +39,9 @@ error[E0539]: malformed `coverage` attribute input --> $DIR/bad-syntax.rs:20:1 | LL | #[coverage = true] - | ^^^^^^^^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument + | ^^^^^^^^^^^------^ + | | + | expected this to be a list | help: try changing it to one of the following valid forms of the attribute | diff --git a/tests/ui/coverage-attr/name-value.stderr b/tests/ui/coverage-attr/name-value.stderr index 06e59e5a8646..d15be83465fd 100644 --- a/tests/ui/coverage-attr/name-value.stderr +++ b/tests/ui/coverage-attr/name-value.stderr @@ -2,7 +2,9 @@ error[E0539]: malformed `coverage` attribute input --> $DIR/name-value.rs:12:1 | LL | #[coverage = "off"] - | ^^^^^^^^^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument + | ^^^^^^^^^^^-------^ + | | + | expected this to be a list | help: try changing it to one of the following valid forms of the attribute | @@ -17,7 +19,9 @@ error[E0539]: malformed `coverage` attribute input --> $DIR/name-value.rs:17:5 | LL | #![coverage = "off"] - | ^^^^^^^^^^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument + | ^^^^^^^^^^^^-------^ + | | + | expected this to be a list | help: try changing it to one of the following valid forms of the attribute | @@ -32,7 +36,9 @@ error[E0539]: malformed `coverage` attribute input --> $DIR/name-value.rs:21:1 | LL | #[coverage = "off"] - | ^^^^^^^^^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument + | ^^^^^^^^^^^-------^ + | | + | expected this to be a list | help: try changing it to one of the following valid forms of the attribute | @@ -55,7 +61,9 @@ error[E0539]: malformed `coverage` attribute input --> $DIR/name-value.rs:26:1 | LL | #[coverage = "off"] - | ^^^^^^^^^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument + | ^^^^^^^^^^^-------^ + | | + | expected this to be a list | help: try changing it to one of the following valid forms of the attribute | @@ -70,7 +78,9 @@ error[E0539]: malformed `coverage` attribute input --> $DIR/name-value.rs:29:5 | LL | #[coverage = "off"] - | ^^^^^^^^^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument + | ^^^^^^^^^^^-------^ + | | + | expected this to be a list | help: try changing it to one of the following valid forms of the attribute | @@ -93,7 +103,9 @@ error[E0539]: malformed `coverage` attribute input --> $DIR/name-value.rs:35:1 | LL | #[coverage = "off"] - | ^^^^^^^^^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument + | ^^^^^^^^^^^-------^ + | | + | expected this to be a list | help: try changing it to one of the following valid forms of the attribute | @@ -116,7 +128,9 @@ error[E0539]: malformed `coverage` attribute input --> $DIR/name-value.rs:39:5 | LL | #[coverage = "off"] - | ^^^^^^^^^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument + | ^^^^^^^^^^^-------^ + | | + | expected this to be a list | help: try changing it to one of the following valid forms of the attribute | @@ -139,7 +153,9 @@ error[E0539]: malformed `coverage` attribute input --> $DIR/name-value.rs:44:5 | LL | #[coverage = "off"] - | ^^^^^^^^^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument + | ^^^^^^^^^^^-------^ + | | + | expected this to be a list | help: try changing it to one of the following valid forms of the attribute | @@ -162,7 +178,9 @@ error[E0539]: malformed `coverage` attribute input --> $DIR/name-value.rs:50:1 | LL | #[coverage = "off"] - | ^^^^^^^^^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument + | ^^^^^^^^^^^-------^ + | | + | expected this to be a list | help: try changing it to one of the following valid forms of the attribute | @@ -177,7 +195,9 @@ error[E0539]: malformed `coverage` attribute input --> $DIR/name-value.rs:53:5 | LL | #[coverage = "off"] - | ^^^^^^^^^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument + | ^^^^^^^^^^^-------^ + | | + | expected this to be a list | help: try changing it to one of the following valid forms of the attribute | @@ -200,7 +220,9 @@ error[E0539]: malformed `coverage` attribute input --> $DIR/name-value.rs:58:5 | LL | #[coverage = "off"] - | ^^^^^^^^^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument + | ^^^^^^^^^^^-------^ + | | + | expected this to be a list | help: try changing it to one of the following valid forms of the attribute | @@ -223,7 +245,9 @@ error[E0539]: malformed `coverage` attribute input --> $DIR/name-value.rs:64:1 | LL | #[coverage = "off"] - | ^^^^^^^^^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument + | ^^^^^^^^^^^-------^ + | | + | expected this to be a list | help: try changing it to one of the following valid forms of the attribute | diff --git a/tests/ui/coverage-attr/word-only.stderr b/tests/ui/coverage-attr/word-only.stderr index 05478695256f..481010415237 100644 --- a/tests/ui/coverage-attr/word-only.stderr +++ b/tests/ui/coverage-attr/word-only.stderr @@ -2,7 +2,7 @@ error[E0539]: malformed `coverage` attribute input --> $DIR/word-only.rs:12:1 | LL | #[coverage] - | ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument + | ^^^^^^^^^^^ expected this to be a list | help: try changing it to one of the following valid forms of the attribute | @@ -15,7 +15,7 @@ error[E0539]: malformed `coverage` attribute input --> $DIR/word-only.rs:17:5 | LL | #![coverage] - | ^^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument + | ^^^^^^^^^^^^ expected this to be a list | help: try changing it to one of the following valid forms of the attribute | @@ -28,7 +28,7 @@ error[E0539]: malformed `coverage` attribute input --> $DIR/word-only.rs:21:1 | LL | #[coverage] - | ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument + | ^^^^^^^^^^^ expected this to be a list | help: try changing it to one of the following valid forms of the attribute | @@ -49,7 +49,7 @@ error[E0539]: malformed `coverage` attribute input --> $DIR/word-only.rs:26:1 | LL | #[coverage] - | ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument + | ^^^^^^^^^^^ expected this to be a list | help: try changing it to one of the following valid forms of the attribute | @@ -62,7 +62,7 @@ error[E0539]: malformed `coverage` attribute input --> $DIR/word-only.rs:29:5 | LL | #[coverage] - | ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument + | ^^^^^^^^^^^ expected this to be a list | help: try changing it to one of the following valid forms of the attribute | @@ -83,7 +83,7 @@ error[E0539]: malformed `coverage` attribute input --> $DIR/word-only.rs:35:1 | LL | #[coverage] - | ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument + | ^^^^^^^^^^^ expected this to be a list | help: try changing it to one of the following valid forms of the attribute | @@ -104,7 +104,7 @@ error[E0539]: malformed `coverage` attribute input --> $DIR/word-only.rs:39:5 | LL | #[coverage] - | ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument + | ^^^^^^^^^^^ expected this to be a list | help: try changing it to one of the following valid forms of the attribute | @@ -125,7 +125,7 @@ error[E0539]: malformed `coverage` attribute input --> $DIR/word-only.rs:44:5 | LL | #[coverage] - | ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument + | ^^^^^^^^^^^ expected this to be a list | help: try changing it to one of the following valid forms of the attribute | @@ -146,7 +146,7 @@ error[E0539]: malformed `coverage` attribute input --> $DIR/word-only.rs:50:1 | LL | #[coverage] - | ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument + | ^^^^^^^^^^^ expected this to be a list | help: try changing it to one of the following valid forms of the attribute | @@ -159,7 +159,7 @@ error[E0539]: malformed `coverage` attribute input --> $DIR/word-only.rs:53:5 | LL | #[coverage] - | ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument + | ^^^^^^^^^^^ expected this to be a list | help: try changing it to one of the following valid forms of the attribute | @@ -180,7 +180,7 @@ error[E0539]: malformed `coverage` attribute input --> $DIR/word-only.rs:58:5 | LL | #[coverage] - | ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument + | ^^^^^^^^^^^ expected this to be a list | help: try changing it to one of the following valid forms of the attribute | @@ -201,7 +201,7 @@ error[E0539]: malformed `coverage` attribute input --> $DIR/word-only.rs:64:1 | LL | #[coverage] - | ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument + | ^^^^^^^^^^^ expected this to be a list | help: try changing it to one of the following valid forms of the attribute | diff --git a/tests/ui/link-native-libs/issue-43926.stderr b/tests/ui/link-native-libs/issue-43926.stderr index db718d3b0d18..161754f32003 100644 --- a/tests/ui/link-native-libs/issue-43926.stderr +++ b/tests/ui/link-native-libs/issue-43926.stderr @@ -2,9 +2,9 @@ error[E0805]: malformed `link` attribute input --> $DIR/issue-43926.rs:1:1 | LL | #[link(name = "foo", cfg())] - | ^^^^^^^^^^^^^^^^^^^^^-----^^ - | | - | expected an argument here + | ^^^^^^^^^^^^^^^^^^^^^^^^--^^ + | | + | expected an argument here | = note: for more information, visit