-
Notifications
You must be signed in to change notification settings - Fork 13.4k
passes: prohibit invalid attrs on generic params #79073
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#![deny(unused_attributes)] | ||
#![feature(min_const_generics)] | ||
|
||
use std::marker::PhantomData; | ||
|
||
pub struct Foo<#[inline] const N: usize>; | ||
//~^ ERROR attribute should be applied to function or closure | ||
pub struct Bar<#[cold] const N: usize>; | ||
//~^ ERROR attribute should be applied to a function | ||
//~| WARN this was previously accepted | ||
pub struct Baz<#[repr(C)] const N: usize>; | ||
//~^ ERROR attribute should be applied to a struct, enum, or union | ||
// | ||
pub struct Foo2<#[inline] 'a>(PhantomData<&'a ()>); | ||
//~^ ERROR attribute should be applied to function or closure | ||
pub struct Bar2<#[cold] 'a>(PhantomData<&'a ()>); | ||
//~^ ERROR attribute should be applied to a function | ||
//~| WARN this was previously accepted | ||
pub struct Baz2<#[repr(C)] 'a>(PhantomData<&'a ()>); | ||
//~^ ERROR attribute should be applied to a struct, enum, or union | ||
// | ||
pub struct Foo3<#[inline] T>(PhantomData<T>); | ||
//~^ ERROR attribute should be applied to function or closure | ||
pub struct Bar3<#[cold] T>(PhantomData<T>); | ||
//~^ ERROR attribute should be applied to a function | ||
//~| WARN this was previously accepted | ||
pub struct Baz3<#[repr(C)] T>(PhantomData<T>); | ||
//~^ ERROR attribute should be applied to a struct, enum, or union | ||
|
||
fn main() {} | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
error[E0518]: attribute should be applied to function or closure | ||
--> $DIR/issue-78957.rs:6:16 | ||
| | ||
LL | pub struct Foo<#[inline] const N: usize>; | ||
| ^^^^^^^^^ - not a function or closure | ||
|
||
error: attribute should be applied to a function | ||
--> $DIR/issue-78957.rs:8:16 | ||
| | ||
LL | pub struct Bar<#[cold] const N: usize>; | ||
| ^^^^^^^ - not a function | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/issue-78957.rs:1:9 | ||
| | ||
LL | #![deny(unused_attributes)] | ||
| ^^^^^^^^^^^^^^^^^ | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So it seems like we always just emit a future compat lint if It would be nice to increase that lint to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll leave this for a follow-up. |
||
|
||
error[E0517]: attribute should be applied to a struct, enum, or union | ||
--> $DIR/issue-78957.rs:11:23 | ||
| | ||
LL | pub struct Baz<#[repr(C)] const N: usize>; | ||
| ^ - not a struct, enum, or union | ||
|
||
error[E0518]: attribute should be applied to function or closure | ||
--> $DIR/issue-78957.rs:14:17 | ||
| | ||
LL | pub struct Foo2<#[inline] 'a>(PhantomData<&'a ()>); | ||
| ^^^^^^^^^ -- not a function or closure | ||
|
||
error: attribute should be applied to a function | ||
--> $DIR/issue-78957.rs:16:17 | ||
| | ||
LL | pub struct Bar2<#[cold] 'a>(PhantomData<&'a ()>); | ||
| ^^^^^^^ -- not a function | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
|
||
error[E0517]: attribute should be applied to a struct, enum, or union | ||
--> $DIR/issue-78957.rs:19:24 | ||
| | ||
LL | pub struct Baz2<#[repr(C)] 'a>(PhantomData<&'a ()>); | ||
| ^ -- not a struct, enum, or union | ||
|
||
error[E0518]: attribute should be applied to function or closure | ||
--> $DIR/issue-78957.rs:22:17 | ||
| | ||
LL | pub struct Foo3<#[inline] T>(PhantomData<T>); | ||
| ^^^^^^^^^ - not a function or closure | ||
|
||
error: attribute should be applied to a function | ||
--> $DIR/issue-78957.rs:24:17 | ||
| | ||
LL | pub struct Bar3<#[cold] T>(PhantomData<T>); | ||
| ^^^^^^^ - not a function | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
|
||
error[E0517]: attribute should be applied to a struct, enum, or union | ||
--> $DIR/issue-78957.rs:27:24 | ||
| | ||
LL | pub struct Baz3<#[repr(C)] T>(PhantomData<T>); | ||
| ^ - not a struct, enum, or union | ||
|
||
error: aborting due to 9 previous errors | ||
|
||
Some errors have detailed explanations: E0517, E0518. | ||
For more information about an error, try `rustc --explain E0517`. |
Uh oh!
There was an error while loading. Please reload this page.