Rollup merge of #48752 - alexcrichton:fix-target-feature, r=michaelwoerister

rustc: Fix ICE with `#[target_feature]` on module

This commit fixes an ICE in rustc when `#[target_feature]` was applied to items
other than functions due to the way the feature was validated.
This commit is contained in:
Manish Goregaokar 2018-03-08 11:25:59 -08:00 committed by GitHub
commit c8a73e438a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 2 deletions

View file

@ -29,6 +29,10 @@ unsafe fn foo() {}
//~^ ERROR: can only be applied to `unsafe` function
fn bar() {}
#[target_feature(enable = "sse2")]
//~^ ERROR: should be applied to a function
mod another {}
fn main() {
unsafe {
foo();

View file

@ -28,5 +28,14 @@ error: #[target_feature(..)] can only be applied to `unsafe` function
LL | #[target_feature(enable = "sse2")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 4 previous errors
error: attribute should be applied to a function
--> $DIR/target-feature-wrong.rs:32:1
|
LL | #[target_feature(enable = "sse2")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | //~^ ERROR: should be applied to a function
LL | mod another {}
| -------------- not a function
error: aborting due to 5 previous errors