Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions compiler/rustc_attr_parsing/src/target_checking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,20 @@ pub(crate) fn allowed_targets_applied(
filter_targets(&mut allowed_targets, IMPL_LIKE, "impl blocks", target, &mut added_fake_targets);
filter_targets(&mut allowed_targets, ADT_LIKE, "data types", target, &mut added_fake_targets);

let mut target_strings: Vec<_> = added_fake_targets
.iter()
.copied()
.chain(allowed_targets.iter().map(|t| t.plural_name()))
.map(|i| i.to_string())
.collect();

// ensure a consistent order
target_strings.sort();

// If there is now only 1 target left, show that as the only possible target
(
added_fake_targets
.iter()
.copied()
.chain(allowed_targets.iter().map(|t| t.plural_name()))
.map(|i| i.to_string())
.collect(),
allowed_targets.len() + added_fake_targets.len() == 1,
)
let only_target = target_strings.len() == 1;

(target_strings, only_target)
}

fn filter_targets(
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/asm/naked-invalid-attr.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ error: `#[naked]` attribute cannot be used on foreign functions
LL | #[unsafe(naked)]
| ^^^^^^^^^^^^^^^^
|
= help: `#[naked]` can be applied to methods and functions
= help: `#[naked]` can be applied to functions and methods

error: `#[naked]` attribute cannot be used on structs
--> $DIR/naked-invalid-attr.rs:13:1
Expand Down Expand Up @@ -50,7 +50,7 @@ error: `#[naked]` attribute cannot be used on closures
LL | #[unsafe(naked)]
| ^^^^^^^^^^^^^^^^
|
= help: `#[naked]` can be applied to methods and functions
= help: `#[naked]` can be applied to functions and methods

error[E0736]: attribute incompatible with `#[unsafe(naked)]`
--> $DIR/naked-invalid-attr.rs:56:3
Expand Down
10 changes: 5 additions & 5 deletions tests/ui/attributes/attr-on-mac-call.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ LL | #[deprecated]
| ^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= help: `#[deprecated]` can be applied to functions, data types, modules, unions, constants, statics, macro defs, type aliases, use statements, foreign statics, struct fields, traits, associated types, associated consts, enum variants, inherent impl blocks, and crates
= help: `#[deprecated]` can be applied to associated consts, associated types, constants, crates, data types, enum variants, foreign statics, functions, inherent impl blocks, macro defs, modules, statics, struct fields, traits, type aliases, unions, and use statements

warning: `#[inline]` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:24:5
Expand Down Expand Up @@ -136,7 +136,7 @@ LL | #[deprecated]
| ^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= help: `#[deprecated]` can be applied to functions, data types, modules, unions, constants, statics, macro defs, type aliases, use statements, foreign statics, struct fields, traits, associated types, associated consts, enum variants, inherent impl blocks, and crates
= help: `#[deprecated]` can be applied to associated consts, associated types, constants, crates, data types, enum variants, foreign statics, functions, inherent impl blocks, macro defs, modules, statics, struct fields, traits, type aliases, unions, and use statements

warning: `#[automatically_derived]` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:51:5
Expand All @@ -154,7 +154,7 @@ LL | #[macro_use]
| ^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= help: `#[macro_use]` can be applied to modules, extern crates, and crates
= help: `#[macro_use]` can be applied to crates, extern crates, and modules

warning: `#[must_use]` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:57:5
Expand All @@ -163,7 +163,7 @@ LL | #[must_use]
| ^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= help: `#[must_use]` can be applied to functions, data types, unions, and traits
= help: `#[must_use]` can be applied to data types, functions, traits, and unions

warning: `#[no_implicit_prelude]` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:60:5
Expand All @@ -172,7 +172,7 @@ LL | #[no_implicit_prelude]
| ^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= help: `#[no_implicit_prelude]` can be applied to modules and crates
= help: `#[no_implicit_prelude]` can be applied to crates and modules

warning: `#[path]` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:63:5
Expand Down
12 changes: 6 additions & 6 deletions tests/ui/attributes/linkage.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,47 @@ error: `#[linkage]` attribute cannot be used on type aliases
LL | #[linkage = "weak"]
| ^^^^^^^^^^^^^^^^^^^
|
= help: `#[linkage]` can be applied to functions, statics, and foreign statics
= help: `#[linkage]` can be applied to foreign statics, functions, and statics

error: `#[linkage]` attribute cannot be used on modules
--> $DIR/linkage.rs:9:1
|
LL | #[linkage = "weak"]
| ^^^^^^^^^^^^^^^^^^^
|
= help: `#[linkage]` can be applied to functions, statics, and foreign statics
= help: `#[linkage]` can be applied to foreign statics, functions, and statics

error: `#[linkage]` attribute cannot be used on structs
--> $DIR/linkage.rs:12:1
|
LL | #[linkage = "weak"]
| ^^^^^^^^^^^^^^^^^^^
|
= help: `#[linkage]` can be applied to functions, statics, and foreign statics
= help: `#[linkage]` can be applied to foreign statics, functions, and statics

error: `#[linkage]` attribute cannot be used on inherent impl blocks
--> $DIR/linkage.rs:15:1
|
LL | #[linkage = "weak"]
| ^^^^^^^^^^^^^^^^^^^
|
= help: `#[linkage]` can be applied to functions, statics, and foreign statics
= help: `#[linkage]` can be applied to foreign statics, functions, and statics

error: `#[linkage]` attribute cannot be used on expressions
--> $DIR/linkage.rs:23:5
|
LL | #[linkage = "weak"]
| ^^^^^^^^^^^^^^^^^^^
|
= help: `#[linkage]` can be applied to functions, statics, and foreign statics
= help: `#[linkage]` can be applied to foreign statics, functions, and statics

error: `#[linkage]` attribute cannot be used on closures
--> $DIR/linkage.rs:39:13
|
LL | let _ = #[linkage = "weak"]
| ^^^^^^^^^^^^^^^^^^^
|
= help: `#[linkage]` can be applied to methods, functions, statics, foreign statics, and foreign functions
= help: `#[linkage]` can be applied to foreign functions, foreign statics, functions, methods, and statics

error: aborting due to 6 previous errors

2 changes: 1 addition & 1 deletion tests/ui/attributes/malformed-static-align.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ error: `#[rustc_align_static]` attribute cannot be used on structs
LL | #[rustc_align_static(16)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: `#[rustc_align_static]` can be applied to statics and foreign statics
= help: `#[rustc_align_static]` can be applied to foreign statics and statics

error: `#[repr(align(...))]` is not supported on statics
--> $DIR/malformed-static-align.rs:13:8
Expand Down
34 changes: 17 additions & 17 deletions tests/ui/coverage-attr/allowed-positions.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -14,135 +14,135 @@ error: `#[coverage]` attribute cannot be used on type aliases
LL | #[coverage(off)]
| ^^^^^^^^^^^^^^^^
|
= help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
= help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules

error: `#[coverage]` attribute cannot be used on traits
--> $DIR/allowed-positions.rs:17:1
|
LL | #[coverage(off)]
| ^^^^^^^^^^^^^^^^
|
= help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
= help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules

error: `#[coverage]` attribute cannot be used on associated consts
--> $DIR/allowed-positions.rs:19:5
|
LL | #[coverage(off)]
| ^^^^^^^^^^^^^^^^
|
= help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
= help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules

error: `#[coverage]` attribute cannot be used on associated types
--> $DIR/allowed-positions.rs:22:5
|
LL | #[coverage(off)]
| ^^^^^^^^^^^^^^^^
|
= help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
= help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules

error: `#[coverage]` attribute cannot be used on required trait methods
--> $DIR/allowed-positions.rs:25:5
|
LL | #[coverage(off)]
| ^^^^^^^^^^^^^^^^
|
= help: `#[coverage]` can be applied to impl blocks, functions, closures, provided trait methods, trait methods in impl blocks, inherent methods, modules, and crates
= help: `#[coverage]` can be applied to closures, crates, functions, impl blocks, inherent methods, modules, provided trait methods, and trait methods in impl blocks

error: `#[coverage]` attribute cannot be used on required trait methods
--> $DIR/allowed-positions.rs:31:5
|
LL | #[coverage(off)]
| ^^^^^^^^^^^^^^^^
|
= help: `#[coverage]` can be applied to impl blocks, functions, closures, provided trait methods, trait methods in impl blocks, inherent methods, modules, and crates
= help: `#[coverage]` can be applied to closures, crates, functions, impl blocks, inherent methods, modules, provided trait methods, and trait methods in impl blocks

error: `#[coverage]` attribute cannot be used on associated types
--> $DIR/allowed-positions.rs:39:5
|
LL | #[coverage(off)]
| ^^^^^^^^^^^^^^^^
|
= help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
= help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules

error: `#[coverage]` attribute cannot be used on associated types
--> $DIR/allowed-positions.rs:56:5
|
LL | #[coverage(off)]
| ^^^^^^^^^^^^^^^^
|
= help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
= help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules

error: `#[coverage]` attribute cannot be used on structs
--> $DIR/allowed-positions.rs:61:1
|
LL | #[coverage(off)]
| ^^^^^^^^^^^^^^^^
|
= help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
= help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules

error: `#[coverage]` attribute cannot be used on struct fields
--> $DIR/allowed-positions.rs:63:5
|
LL | #[coverage(off)]
| ^^^^^^^^^^^^^^^^
|
= help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
= help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules

error: `#[coverage]` attribute cannot be used on foreign statics
--> $DIR/allowed-positions.rs:76:5
|
LL | #[coverage(off)]
| ^^^^^^^^^^^^^^^^
|
= help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
= help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules

error: `#[coverage]` attribute cannot be used on foreign types
--> $DIR/allowed-positions.rs:79:5
|
LL | #[coverage(off)]
| ^^^^^^^^^^^^^^^^
|
= help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
= help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules

error: `#[coverage]` attribute cannot be used on foreign functions
--> $DIR/allowed-positions.rs:82:5
|
LL | #[coverage(off)]
| ^^^^^^^^^^^^^^^^
|
= help: `#[coverage]` can be applied to methods, impl blocks, functions, closures, modules, and crates
= help: `#[coverage]` can be applied to closures, crates, functions, impl blocks, methods, and modules

error: `#[coverage]` attribute cannot be used on statements
--> $DIR/allowed-positions.rs:88:5
|
LL | #[coverage(off)]
| ^^^^^^^^^^^^^^^^
|
= help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
= help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules

error: `#[coverage]` attribute cannot be used on statements
--> $DIR/allowed-positions.rs:94:5
|
LL | #[coverage(off)]
| ^^^^^^^^^^^^^^^^
|
= help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
= help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules

error: `#[coverage]` attribute cannot be used on match arms
--> $DIR/allowed-positions.rs:110:9
|
LL | #[coverage(off)]
| ^^^^^^^^^^^^^^^^
|
= help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
= help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules

error: `#[coverage]` attribute cannot be used on expressions
--> $DIR/allowed-positions.rs:114:5
|
LL | #[coverage(off)]
| ^^^^^^^^^^^^^^^^
|
= help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
= help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules

error: aborting due to 18 previous errors

Expand Down
14 changes: 7 additions & 7 deletions tests/ui/coverage-attr/name-value.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ error: `#[coverage]` attribute cannot be used on structs
LL | #[coverage = "off"]
| ^^^^^^^^^^^^^^^^^^^
|
= help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
= help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules

error[E0539]: malformed `coverage` attribute input
--> $DIR/name-value.rs:26:1
Expand Down Expand Up @@ -87,7 +87,7 @@ error: `#[coverage]` attribute cannot be used on associated consts
LL | #[coverage = "off"]
| ^^^^^^^^^^^^^^^^^^^
|
= help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
= help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules

error[E0539]: malformed `coverage` attribute input
--> $DIR/name-value.rs:35:1
Expand All @@ -110,7 +110,7 @@ error: `#[coverage]` attribute cannot be used on traits
LL | #[coverage = "off"]
| ^^^^^^^^^^^^^^^^^^^
|
= help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
= help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules

error[E0539]: malformed `coverage` attribute input
--> $DIR/name-value.rs:39:5
Expand All @@ -133,7 +133,7 @@ error: `#[coverage]` attribute cannot be used on associated consts
LL | #[coverage = "off"]
| ^^^^^^^^^^^^^^^^^^^
|
= help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
= help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules

error[E0539]: malformed `coverage` attribute input
--> $DIR/name-value.rs:44:5
Expand All @@ -156,7 +156,7 @@ error: `#[coverage]` attribute cannot be used on associated types
LL | #[coverage = "off"]
| ^^^^^^^^^^^^^^^^^^^
|
= help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
= help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules

error[E0539]: malformed `coverage` attribute input
--> $DIR/name-value.rs:50:1
Expand Down Expand Up @@ -194,7 +194,7 @@ error: `#[coverage]` attribute cannot be used on associated consts
LL | #[coverage = "off"]
| ^^^^^^^^^^^^^^^^^^^
|
= help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
= help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules

error[E0539]: malformed `coverage` attribute input
--> $DIR/name-value.rs:58:5
Expand All @@ -217,7 +217,7 @@ error: `#[coverage]` attribute cannot be used on associated types
LL | #[coverage = "off"]
| ^^^^^^^^^^^^^^^^^^^
|
= help: `#[coverage]` can be applied to functions, impl blocks, modules, and crates
= help: `#[coverage]` can be applied to crates, functions, impl blocks, and modules

error[E0539]: malformed `coverage` attribute input
--> $DIR/name-value.rs:64:1
Expand Down
Loading
Loading