Skip to content

Commit 5e28944

Browse files
Stop using IllFormedAttributeInputLint for macro_export
1 parent b835228 commit 5e28944

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
use rustc_errors::DiagArgValue;
21
use rustc_hir::attrs::MacroUseArgs;
32
use rustc_session::lint::builtin::INVALID_MACRO_EXPORT_ARGUMENTS;
43

54
use super::prelude::*;
6-
use crate::session_diagnostics::{AttributeParseErrorReason, IllFormedAttributeInputLint};
5+
use crate::session_diagnostics::AttributeParseErrorReason;
76

87
pub(crate) struct MacroEscapeParser;
98
impl<S: Stage> NoArgsAttributeParser<S> for MacroEscapeParser {
@@ -158,15 +157,7 @@ impl<S: Stage> SingleAttributeParser<S> for MacroExportParser {
158157
}
159158
}
160159
ArgParser::NameValue(_) => {
161-
let span = cx.attr_span;
162-
let suggestions = cx.suggestions();
163-
cx.emit_err(IllFormedAttributeInputLint {
164-
num_suggestions: suggestions.len(),
165-
suggestions: DiagArgValue::StrListSepByAnd(
166-
suggestions.into_iter().map(|s| format!("`{s}`").into()).collect(),
167-
),
168-
span,
169-
});
160+
cx.emit_parse_error(cx.attr_span, AttributeParseErrorReason::ExpectedListOrNoArgs);
170161
return None;
171162
}
172163
};

tests/ui/attributes/malformed-attrs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ extern crate wloop;
219219
//~^ ERROR can't find crate for `wloop` [E0463]
220220

221221
#[macro_export = 18]
222-
//~^ ERROR valid forms for the attribute are
222+
//~^ ERROR malformed
223223
#[allow_internal_unsafe = 1]
224224
//~^ ERROR malformed
225225
//~| ERROR allow_internal_unsafe side-steps the unsafe_code lint

tests/ui/attributes/malformed-attrs.stderr

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,11 +630,20 @@ LL - #[macro_use = 1]
630630
LL + #[macro_use]
631631
|
632632

633-
error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]`
633+
error[E0539]: malformed `macro_export` attribute input
634634
--> $DIR/malformed-attrs.rs:221:1
635635
|
636636
LL | #[macro_export = 18]
637-
| ^^^^^^^^^^^^^^^^^^^^
637+
| ^^^^^^^^^^^^^^^^^^^^ expected a list or no arguments here
638+
|
639+
help: try changing it to one of the following valid forms of the attribute
640+
|
641+
LL - #[macro_export = 18]
642+
LL + #[macro_export(local_inner_macros)]
643+
|
644+
LL - #[macro_export = 18]
645+
LL + #[macro_export]
646+
|
638647

639648
error[E0565]: malformed `allow_internal_unsafe` attribute input
640649
--> $DIR/malformed-attrs.rs:223:1

0 commit comments

Comments
 (0)