Skip to content
2 changes: 1 addition & 1 deletion compiler/rustc_attr_parsing/src/attributes/crate_level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ impl CombineAttributeParser for RegisterToolParser {
const PATH: &[Symbol] = &[sym::register_tool];
type Item = Ident;
const CONVERT: ConvertFn<Self::Item> = |tools, _span| AttributeKind::RegisterTool(tools);
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(ALL_TARGETS);
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
const TEMPLATE: AttributeTemplate = template!(List: &["tool1, tool2, ..."]);
const STABILITY: AttributeStability = unstable!(register_tool);

Expand Down
5 changes: 5 additions & 0 deletions library/alloc/src/vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3810,6 +3810,11 @@ unsafe impl<T, A: Allocator> ops::DerefPure for Vec<T, A> {}
#[cfg(not(no_global_oom_handling))]
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Clone, A: Allocator + Clone> Clone for Vec<T, A> {
/// Creates a new `Vec` by deep-copying the contents of an existing `Vec`.
///
/// This method will allocate a new `Vec` and `clone` all of `self`'s contents
/// into it. The capacity of the duplicate `Vec` is not forced to match the
/// capacity of the original.
fn clone(&self) -> Self {
let alloc = self.allocator().clone();
<[T]>::to_vec_in(&**self, alloc)
Expand Down
4 changes: 4 additions & 0 deletions tests/ui/attributes/attr-on-mac-call.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//@ check-fail
// Regression test for https://github.com/rust-lang/rust/issues/145779
#![warn(unused_attributes)]
#![feature(register_tool)]
#![feature(sanitize)]

fn main() {
Expand Down Expand Up @@ -106,4 +107,7 @@ fn main() {
//~^ WARN attribute cannot be used on macro calls
//~| WARN previously accepted
unreachable!();
#[register_tool(xyz)]
//~^ WARN crate-level attribute should be an inner attribute
unreachable!();
}
78 changes: 45 additions & 33 deletions tests/ui/attributes/attr-on-mac-call.stderr
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
error: `#[sanitize]` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:76:5
--> $DIR/attr-on-mac-call.rs:77:5
|
LL | #[sanitize(address = "off")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: `#[sanitize]` can be applied to crates, functions, impl blocks, modules, and statics

warning: `#[export_name]` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:7:5
--> $DIR/attr-on-mac-call.rs:8:5
|
LL | #[export_name = "x"]
| ^^^^^^^^^^^^^^^^^^^^
Expand All @@ -21,7 +21,7 @@ LL | #![warn(unused_attributes)]
| ^^^^^^^^^^^^^^^^^

warning: `#[naked]` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:10:5
--> $DIR/attr-on-mac-call.rs:11:5
|
LL | #[unsafe(naked)]
| ^^^^^^^^^^^^^^^^
Expand All @@ -30,7 +30,7 @@ LL | #[unsafe(naked)]
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!

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

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

warning: `#[target_feature]` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:19:5
--> $DIR/attr-on-mac-call.rs:20:5
|
LL | #[target_feature(enable = "x")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -57,7 +57,7 @@ LL | #[target_feature(enable = "x")]
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!

warning: `#[deprecated]` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:22:5
--> $DIR/attr-on-mac-call.rs:23:5
|
LL | #[deprecated]
| ^^^^^^^^^^^^^
Expand All @@ -66,7 +66,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!

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

warning: `#[link_name]` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:28:5
--> $DIR/attr-on-mac-call.rs:29:5
|
LL | #[link_name = "x"]
| ^^^^^^^^^^^^^^^^^^
Expand All @@ -84,7 +84,7 @@ LL | #[link_name = "x"]
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!

warning: `#[link_section]` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:31:5
--> $DIR/attr-on-mac-call.rs:32:5
|
LL | #[link_section = "__TEXT,__text"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -93,7 +93,7 @@ LL | #[link_section = "__TEXT,__text"]
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!

warning: `#[link_ordinal]` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:34:5
--> $DIR/attr-on-mac-call.rs:35:5
|
LL | #[link_ordinal(42)]
| ^^^^^^^^^^^^^^^^^^^
Expand All @@ -102,7 +102,7 @@ LL | #[link_ordinal(42)]
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!

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

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

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

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

warning: `#[deprecated]` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:49:5
--> $DIR/attr-on-mac-call.rs:50:5
|
LL | #[deprecated]
| ^^^^^^^^^^^^^
Expand All @@ -147,7 +147,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!

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

warning: `#[macro_use]` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:55:5
--> $DIR/attr-on-mac-call.rs:56:5
|
LL | #[macro_use]
| ^^^^^^^^^^^^
Expand All @@ -165,7 +165,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!

warning: `#[must_use]` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:58:5
--> $DIR/attr-on-mac-call.rs:59:5
|
LL | #[must_use]
| ^^^^^^^^^^^
Expand All @@ -174,7 +174,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!

warning: `#[no_implicit_prelude]` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:61:5
--> $DIR/attr-on-mac-call.rs:62:5
|
LL | #[no_implicit_prelude]
| ^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -183,7 +183,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!

warning: `#[path]` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:64:5
--> $DIR/attr-on-mac-call.rs:65:5
|
LL | #[path = ""]
| ^^^^^^^^^^^^
Expand All @@ -192,7 +192,7 @@ LL | #[path = ""]
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!

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

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

warning: `#[link_name]` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:73:5
--> $DIR/attr-on-mac-call.rs:74:5
|
LL | #[link_name = "x"]
| ^^^^^^^^^^^^^^^^^^
Expand All @@ -219,7 +219,7 @@ LL | #[link_name = "x"]
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!

warning: `#[repr()]` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:80:5
--> $DIR/attr-on-mac-call.rs:81:5
|
LL | #[repr()]
| ^^^^^^^^^
Expand All @@ -228,15 +228,15 @@ LL | #[repr()]
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!

warning: unused attribute
--> $DIR/attr-on-mac-call.rs:80:5
--> $DIR/attr-on-mac-call.rs:81:5
|
LL | #[repr()]
| ^^^^^^^^^ help: remove this attribute
|
= note: using `repr` with an empty list has no effect

warning: `#[repr(u8)]` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:85:5
--> $DIR/attr-on-mac-call.rs:86:5
|
LL | #[repr(u8)]
| ^^^^^^^^^^^
Expand All @@ -245,7 +245,7 @@ LL | #[repr(u8)]
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!

warning: `#[repr(align(...))]` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:89:5
--> $DIR/attr-on-mac-call.rs:90:5
|
LL | #[repr(align(8))]
| ^^^^^^^^^^^^^^^^^
Expand All @@ -254,7 +254,7 @@ LL | #[repr(align(8))]
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!

warning: `#[repr(packed)]` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:93:5
--> $DIR/attr-on-mac-call.rs:94:5
|
LL | #[repr(packed)]
| ^^^^^^^^^^^^^^^
Expand All @@ -263,7 +263,7 @@ LL | #[repr(packed)]
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!

warning: `#[repr(C)]` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:97:5
--> $DIR/attr-on-mac-call.rs:98:5
|
LL | #[repr(C)]
| ^^^^^^^^^^
Expand All @@ -272,7 +272,7 @@ LL | #[repr(C)]
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!

warning: `#[repr(Rust)]` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:101:5
--> $DIR/attr-on-mac-call.rs:102:5
|
LL | #[repr(Rust)]
| ^^^^^^^^^^^^^
Expand All @@ -281,13 +281,25 @@ LL | #[repr(Rust)]
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!

warning: `#[repr(simd)]` attribute cannot be used on macro calls
--> $DIR/attr-on-mac-call.rs:105:5
--> $DIR/attr-on-mac-call.rs:106:5
|
LL | #[repr(simd)]
| ^^^^^^^^^^^^^
|
= help: `#[repr(simd)]` can only be applied to structs
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!

error: aborting due to 1 previous error; 31 warnings emitted
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![register_tool]`
--> $DIR/attr-on-mac-call.rs:110:5
|
LL | #[register_tool(xyz)]
| ^^^^^^^^^^^^^^^^^^^^^
|
note: this attribute does not have an `!`, which means it is applied to this macro call
--> $DIR/attr-on-mac-call.rs:112:5
|
LL | unreachable!();
| ^^^^^^^^^^^^^^

error: aborting due to 1 previous error; 32 warnings emitted

4 changes: 4 additions & 0 deletions tests/ui/attributes/malformed-attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
//~^ ERROR malformed
#[optimize]
//~^ ERROR malformed
#[optimize(none, none)]
//~^ ERROR malformed
#[optimize(none, speed)]
//~^ ERROR malformed
#[cold = 1]
//~^ ERROR malformed
#[must_use()]
Expand Down
Loading
Loading