about summary refs log tree commit diff
path: root/src/test/ui/error-codes
diff options
context:
space:
mode:
authorDavid Wood <david@davidtw.co>2018-10-11 19:36:51 +0200
committerDavid Wood <david@davidtw.co>2018-10-11 19:36:51 +0200
commit2ecce7ccc5d74eb3d6b0ff400b2a19944e2ae51a (patch)
treea22ed13d308f455b7db89d94c9aa3a8b75e5c176 /src/test/ui/error-codes
parenta534216fa6d518088ae4468f1cdc519cd79e6247 (diff)
downloadrust-2ecce7ccc5d74eb3d6b0ff400b2a19944e2ae51a.tar.gz
rust-2ecce7ccc5d74eb3d6b0ff400b2a19944e2ae51a.zip
Extend lang items to assert correct target.
This commit extends the existing lang items functionality to assert
that the `#[lang_item]` attribute is only found on the appropriate item
for any given lang item. That is, language items representing traits
must only ever have their corresponding attribute placed on a trait, for
example.
Diffstat (limited to 'src/test/ui/error-codes')
-rw-r--r--src/test/ui/error-codes/E0152.rs2
-rw-r--r--src/test/ui/error-codes/E0152.stderr4
-rw-r--r--src/test/ui/error-codes/E0718.rs17
-rw-r--r--src/test/ui/error-codes/E0718.stderr9
4 files changed, 29 insertions, 3 deletions
diff --git a/src/test/ui/error-codes/E0152.rs b/src/test/ui/error-codes/E0152.rs
index 8fbad7b3ff3..96a4d51bd24 100644
--- a/src/test/ui/error-codes/E0152.rs
+++ b/src/test/ui/error-codes/E0152.rs
@@ -10,7 +10,7 @@
 
 #![feature(lang_items)]
 
-#[lang = "panic_impl"]
+#[lang = "arc"]
 struct Foo; //~ ERROR E0152
 
 fn main() {
diff --git a/src/test/ui/error-codes/E0152.stderr b/src/test/ui/error-codes/E0152.stderr
index c7f5f362efb..a0530f24de6 100644
--- a/src/test/ui/error-codes/E0152.stderr
+++ b/src/test/ui/error-codes/E0152.stderr
@@ -1,10 +1,10 @@
-error[E0152]: duplicate lang item found: `panic_impl`.
+error[E0152]: duplicate lang item found: `arc`.
   --> $DIR/E0152.rs:14:1
    |
 LL | struct Foo; //~ ERROR E0152
    | ^^^^^^^^^^^
    |
-   = note: first defined in crate `std`.
+   = note: first defined in crate `alloc`.
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/error-codes/E0718.rs b/src/test/ui/error-codes/E0718.rs
new file mode 100644
index 00000000000..ce74e35ac6b
--- /dev/null
+++ b/src/test/ui/error-codes/E0718.rs
@@ -0,0 +1,17 @@
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(lang_items)]
+
+// Arc is expected to be a struct, so this will error.
+#[lang = "arc"]
+static X: u32 = 42;
+
+fn main() {}
diff --git a/src/test/ui/error-codes/E0718.stderr b/src/test/ui/error-codes/E0718.stderr
new file mode 100644
index 00000000000..8ce721d30a1
--- /dev/null
+++ b/src/test/ui/error-codes/E0718.stderr
@@ -0,0 +1,9 @@
+error[E0718]: `arc` language item must be applied to a struct
+  --> $DIR/E0718.rs:14:1
+   |
+LL | #[lang = "arc"]
+   | ^^^^^^^^^^^^^^^ attribute should be applied to a struct, not a static item
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0718`.