Skip to content

Commit 57a5e3b

Browse files
Fix duplicate errors for link_section, rustc_layout_scalar_valid_range_start and rustc_layout_scalar_valid_range_end
1 parent d22ce4c commit 57a5e3b

File tree

3 files changed

+39
-20
lines changed

3 files changed

+39
-20
lines changed

compiler/rustc_parse/src/validate_attr.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,9 @@ fn emit_malformed_attribute(
305305
| sym::link_name
306306
| sym::export_name
307307
| sym::rustc_macro_transparency
308+
| sym::link_section
309+
| sym::rustc_layout_scalar_valid_range_start
310+
| sym::rustc_layout_scalar_valid_range_end
308311
) {
309312
return;
310313
}

tests/ui/attributes/malformed-attrs.stderr

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,6 @@ error: malformed `export_stable` attribute input
5252
LL | #[export_stable = 1]
5353
| ^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[export_stable]`
5454

55-
error: malformed `link_section` attribute input
56-
--> $DIR/malformed-attrs.rs:86:1
57-
|
58-
LL | #[link_section]
59-
| ^^^^^^^^^^^^^^^ help: must be of the form: `#[link_section = "name"]`
60-
6155
error: malformed `coverage` attribute input
6256
--> $DIR/malformed-attrs.rs:88:1
6357
|
@@ -119,18 +113,6 @@ error: malformed `proc_macro_derive` attribute input
119113
LL | #[proc_macro_derive]
120114
| ^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]`
121115

122-
error: malformed `rustc_layout_scalar_valid_range_start` attribute input
123-
--> $DIR/malformed-attrs.rs:126:1
124-
|
125-
LL | #[rustc_layout_scalar_valid_range_start]
126-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_layout_scalar_valid_range_start(value)]`
127-
128-
error: malformed `rustc_layout_scalar_valid_range_end` attribute input
129-
--> $DIR/malformed-attrs.rs:128:1
130-
|
131-
LL | #[rustc_layout_scalar_valid_range_end]
132-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_layout_scalar_valid_range_end(value)]`
133-
134116
error: malformed `must_not_suspend` attribute input
135117
--> $DIR/malformed-attrs.rs:130:1
136118
|
@@ -523,6 +505,12 @@ error[E0539]: malformed `link_name` attribute input
523505
LL | #[link_name]
524506
| ^^^^^^^^^^^^ help: must be of the form: `#[link_name = "name"]`
525507

508+
error[E0539]: malformed `link_section` attribute input
509+
--> $DIR/malformed-attrs.rs:86:1
510+
|
511+
LL | #[link_section]
512+
| ^^^^^^^^^^^^^^^ help: must be of the form: `#[link_section = "name"]`
513+
526514
error[E0539]: malformed `must_use` attribute input
527515
--> $DIR/malformed-attrs.rs:117:1
528516
|
@@ -540,6 +528,24 @@ LL - #[must_use = 1]
540528
LL + #[must_use]
541529
|
542530

531+
error[E0539]: malformed `rustc_layout_scalar_valid_range_start` attribute input
532+
--> $DIR/malformed-attrs.rs:126:1
533+
|
534+
LL | #[rustc_layout_scalar_valid_range_start]
535+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
536+
| |
537+
| expected this to be a list
538+
| help: must be of the form: `#[rustc_layout_scalar_valid_range_start(start)]`
539+
540+
error[E0539]: malformed `rustc_layout_scalar_valid_range_end` attribute input
541+
--> $DIR/malformed-attrs.rs:128:1
542+
|
543+
LL | #[rustc_layout_scalar_valid_range_end]
544+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
545+
| |
546+
| expected this to be a list
547+
| help: must be of the form: `#[rustc_layout_scalar_valid_range_end(end)]`
548+
543549
warning: `#[diagnostic::do_not_recommend]` does not expect any arguments
544550
--> $DIR/malformed-attrs.rs:147:1
545551
|

tests/ui/parser/bad-lit-suffixes.stderr

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,16 @@ LL - #[must_use = "string"suffix]
167167
LL + #[must_use]
168168
|
169169

170-
error: aborting due to 21 previous errors; 2 warnings emitted
170+
error[E0805]: malformed `rustc_layout_scalar_valid_range_start` attribute input
171+
--> $DIR/bad-lit-suffixes.rs:43:1
172+
|
173+
LL | #[rustc_layout_scalar_valid_range_start(0suffix)]
174+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------^
175+
| | |
176+
| | expected a single argument here
177+
| help: must be of the form: `#[rustc_layout_scalar_valid_range_start(start)]`
178+
179+
error: aborting due to 22 previous errors; 2 warnings emitted
171180

172-
For more information about this error, try `rustc --explain E0539`.
181+
Some errors have detailed explanations: E0539, E0805.
182+
For more information about an error, try `rustc --explain E0539`.

0 commit comments

Comments
 (0)