Skip to content

Commit 0e414af

Browse files
committed
expected word diagnostic test
1 parent e259f68 commit 0e414af

File tree

6 files changed

+21
-5
lines changed

6 files changed

+21
-5
lines changed

compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl<S: Stage> SingleAttributeParser<S> for ColdParser {
4949

5050
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
5151
if !args.no_args() {
52-
cx.expected_no_args(cx.attr_span);
52+
cx.expected_no_args(args.span().unwrap_or(cx.attr_span));
5353
return None;
5454
};
5555

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,9 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
235235
})
236236
}
237237

238-
pub(crate) fn expected_no_args(&self, span: Span) -> ErrorGuaranteed {
238+
pub(crate) fn expected_no_args(&self, args_span: Span) -> ErrorGuaranteed {
239239
self.emit_err(AttributeParseError {
240-
span,
240+
span: args_span,
241241
attr_span: self.attr_span,
242242
template: self.template.clone(),
243243
attribute: self.attr_path.clone(),

compiler/rustc_parse/src/validate_attr.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ fn emit_malformed_attribute(
292292
| sym::align
293293
| sym::deprecated
294294
| sym::optimize
295+
| sym::cold
295296
) {
296297
return;
297298
}

src/rustdoc-json-types/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ pub type FxHashMap<K, V> = HashMap<K, V>; // re-export for use in src/librustdoc
3737
// will instead cause conflicts. See #94591 for more. (This paragraph and the "Latest feature" line
3838
// are deliberately not in a doc comment, because they need not be in public docs.)
3939
//
40-
// Latest feature: Pretty printing of optimize attributes changed
41-
pub const FORMAT_VERSION: u32 = 49;
40+
// Latest feature: Pretty printing of cold attributes changed
41+
pub const FORMAT_VERSION: u32 = 50;
4242

4343
/// The root of the emitted JSON blob.
4444
///

tests/ui/attributes/expected-word.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#[cold = true]
2+
//~^ ERROR malformed `cold` attribute input [E0565]
3+
fn main() {}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0565]: malformed `cold` attribute input
2+
--> $DIR/expected-word.rs:1:1
3+
|
4+
LL | #[cold = true]
5+
| ^^^^^^^------^
6+
| | |
7+
| | didn't expect any arguments here
8+
| help: must be of the form: `#[cold]`
9+
10+
error: aborting due to 1 previous error
11+
12+
For more information about this error, try `rustc --explain E0565`.

0 commit comments

Comments
 (0)