about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2018-03-08 11:25:59 -0800
committerGitHub <noreply@github.com>2018-03-08 11:25:59 -0800
commitc8a73e438ad8f0f258fdfa2bf6722bfb656d91d0 (patch)
treec79e290712c0a1debd1575b82348a9242e1f69a7 /src/test
parent7c581b08fa9a9b843ecee2a8af82b346da6fd42b (diff)
parent4bde92c17674ba5ac8de4123e0c1023d1e29a60f (diff)
downloadrust-c8a73e438ad8f0f258fdfa2bf6722bfb656d91d0.tar.gz
rust-c8a73e438ad8f0f258fdfa2bf6722bfb656d91d0.zip
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.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/target-feature-wrong.rs4
-rw-r--r--src/test/ui/target-feature-wrong.stderr11
2 files changed, 14 insertions, 1 deletions
diff --git a/src/test/ui/target-feature-wrong.rs b/src/test/ui/target-feature-wrong.rs
index e70d549ed57..c1e6245d24b 100644
--- a/src/test/ui/target-feature-wrong.rs
+++ b/src/test/ui/target-feature-wrong.rs
@@ -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();
diff --git a/src/test/ui/target-feature-wrong.stderr b/src/test/ui/target-feature-wrong.stderr
index 07bad482591..0fa6910f2bb 100644
--- a/src/test/ui/target-feature-wrong.stderr
+++ b/src/test/ui/target-feature-wrong.stderr
@@ -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