diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2020-04-30 14:07:52 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-30 14:07:52 +0200 |
| commit | 4e6772b52bc9832bb47bedba61abdcfb4ba0128e (patch) | |
| tree | 490b2013b130114b20396cefc0f1f89057e7c556 /src/test/ui/macros | |
| parent | bf459752d41a93eb6df0e9513de4ef807883a80c (diff) | |
| parent | 6c700dc11c72993d5fa5905355a69c6524e960d3 (diff) | |
| download | rust-4e6772b52bc9832bb47bedba61abdcfb4ba0128e.tar.gz rust-4e6772b52bc9832bb47bedba61abdcfb4ba0128e.zip | |
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
Diffstat (limited to 'src/test/ui/macros')
| -rw-r--r-- | src/test/ui/macros/issue-68060.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/macros/issue-68060.stderr | 6 |
2 files changed, 3 insertions, 5 deletions
diff --git a/src/test/ui/macros/issue-68060.rs b/src/test/ui/macros/issue-68060.rs index 85ebd66b66c..bc70f8ffec2 100644 --- a/src/test/ui/macros/issue-68060.rs +++ b/src/test/ui/macros/issue-68060.rs @@ -1,5 +1,3 @@ -// build-fail - #![feature(track_caller)] fn main() { diff --git a/src/test/ui/macros/issue-68060.stderr b/src/test/ui/macros/issue-68060.stderr index 230867410d9..3ea49e614e6 100644 --- a/src/test/ui/macros/issue-68060.stderr +++ b/src/test/ui/macros/issue-68060.stderr @@ -1,5 +1,5 @@ error: `#[target_feature(..)]` can only be applied to `unsafe` functions - --> $DIR/issue-68060.rs:8:13 + --> $DIR/issue-68060.rs:6:13 | LL | #[target_feature(enable = "")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can only be applied to `unsafe` functions @@ -8,13 +8,13 @@ LL | |_| (), | ------ not an `unsafe` function error: the feature named `` is not valid for this target - --> $DIR/issue-68060.rs:8:30 + --> $DIR/issue-68060.rs:6:30 | LL | #[target_feature(enable = "")] | ^^^^^^^^^^^ `` is not valid for this target error[E0737]: `#[track_caller]` requires Rust ABI - --> $DIR/issue-68060.rs:11:13 + --> $DIR/issue-68060.rs:9:13 | LL | #[track_caller] | ^^^^^^^^^^^^^^^ |
