Rollup merge of #71205 - NeoRaider:check_attr, r=jonas-schievink
rustc: fix check_attr() for methods, closures and foreign functions This fixes an issue that previously turned up for methods in https://github.com/rust-lang/rust/pull/69274, but also exists for closures and foreign function: `check_attr` does not call `codegen_fn_attrs()` for these types when it should, meaning that incorrectly used function attributes are not diagnosed without codegen. The issue affects our UI tests, as they run with `--emit=metadata` by default, but as it turns out, this is not the only case: Function attributes are not checked on any dead code without this fix! This makes the fix a **breaking change**. The following very silly Rust programs compiles fine on stable Rust when it should not, which is fixed by this PR. ```rust fn main() { #[target_feature(enable = "sse2")] || {}; } ``` I assume any real-world program which may trigger this issue would at least emit a dead code warning, but of course that is no guarantee that such code does not exist... Fixes #70307
This commit is contained in:
commit
4e6772b52b
13 changed files with 124 additions and 22 deletions
|
|
@ -1,3 +1,5 @@
|
|||
// ignore-tidy-linelength
|
||||
|
||||
fn foo<T>() {
|
||||
struct Foo {
|
||||
x: T, //~ ERROR can't use generic parameters from outer function
|
||||
|
|
@ -5,6 +7,7 @@ fn foo<T>() {
|
|||
|
||||
impl<T> Drop for Foo<T> {
|
||||
//~^ ERROR wrong number of type arguments
|
||||
//~| ERROR the type parameter `T` is not constrained by the impl trait, self type, or predicates
|
||||
fn drop(&mut self) {}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0401]: can't use generic parameters from outer function
|
||||
--> $DIR/issue-3214.rs:3:12
|
||||
--> $DIR/issue-3214.rs:5:12
|
||||
|
|
||||
LL | fn foo<T>() {
|
||||
| --- - type parameter from outer function
|
||||
|
|
@ -10,12 +10,18 @@ LL | x: T,
|
|||
| ^ use of generic parameter from outer function
|
||||
|
||||
error[E0107]: wrong number of type arguments: expected 0, found 1
|
||||
--> $DIR/issue-3214.rs:6:26
|
||||
--> $DIR/issue-3214.rs:8:26
|
||||
|
|
||||
LL | impl<T> Drop for Foo<T> {
|
||||
| ^ unexpected type argument
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
|
||||
--> $DIR/issue-3214.rs:8:10
|
||||
|
|
||||
LL | impl<T> Drop for Foo<T> {
|
||||
| ^ unconstrained type parameter
|
||||
|
||||
Some errors have detailed explanations: E0107, E0401.
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0107, E0207, E0401.
|
||||
For more information about an error, try `rustc --explain E0107`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue