about summary refs log tree commit diff
path: root/tests/ui/lang-items
diff options
context:
space:
mode:
authorAlbert Larsan <74931857+albertlarsan68@users.noreply.github.com>2023-01-05 09:13:28 +0100
committerAlbert Larsan <74931857+albertlarsan68@users.noreply.github.com>2023-01-11 09:32:08 +0000
commitcf2dff2b1e3fa55fa5415d524200070d0d7aacfe (patch)
tree40a88d9a46aaf3e8870676eb2538378b75a263eb /tests/ui/lang-items
parentca855e6e42787ecd062d81d53336fe6788ef51a9 (diff)
downloadrust-cf2dff2b1e3fa55fa5415d524200070d0d7aacfe.tar.gz
rust-cf2dff2b1e3fa55fa5415d524200070d0d7aacfe.zip
Move /src/test to /tests
Diffstat (limited to 'tests/ui/lang-items')
-rw-r--r--tests/ui/lang-items/fn-fn_mut-call-ill-formed.rs27
-rw-r--r--tests/ui/lang-items/fn-fn_mut-call-ill-formed.stderr14
-rw-r--r--tests/ui/lang-items/issue-19660.rs15
-rw-r--r--tests/ui/lang-items/issue-19660.stderr4
-rw-r--r--tests/ui/lang-items/issue-31076.rs17
-rw-r--r--tests/ui/lang-items/issue-31076.stderr19
-rw-r--r--tests/ui/lang-items/issue-83471.rs23
-rw-r--r--tests/ui/lang-items/issue-83471.stderr51
-rw-r--r--tests/ui/lang-items/issue-86238.rs16
-rw-r--r--tests/ui/lang-items/issue-86238.stderr10
-rw-r--r--tests/ui/lang-items/issue-87573.rs28
-rw-r--r--tests/ui/lang-items/issue-87573.stderr21
-rw-r--r--tests/ui/lang-items/lang-item-generic-requirements.rs59
-rw-r--r--tests/ui/lang-items/lang-item-generic-requirements.stderr55
-rw-r--r--tests/ui/lang-items/lang-item-missing-generator.rs21
-rw-r--r--tests/ui/lang-items/lang-item-missing-generator.stderr15
-rw-r--r--tests/ui/lang-items/lang-item-missing.rs12
-rw-r--r--tests/ui/lang-items/lang-item-missing.stderr4
-rw-r--r--tests/ui/lang-items/missing-clone-for-suggestion.rs20
-rw-r--r--tests/ui/lang-items/missing-clone-for-suggestion.stderr21
-rw-r--r--tests/ui/lang-items/no_owned_box_lang_item.rs16
-rw-r--r--tests/ui/lang-items/no_owned_box_lang_item.stderr4
-rw-r--r--tests/ui/lang-items/required-lang-item.rs11
-rw-r--r--tests/ui/lang-items/required-lang-item.stderr4
24 files changed, 487 insertions, 0 deletions
diff --git a/tests/ui/lang-items/fn-fn_mut-call-ill-formed.rs b/tests/ui/lang-items/fn-fn_mut-call-ill-formed.rs
new file mode 100644
index 00000000000..52bd8136d9c
--- /dev/null
+++ b/tests/ui/lang-items/fn-fn_mut-call-ill-formed.rs
@@ -0,0 +1,27 @@
+// Make sure that an error is reported if the `call` function of the
+// `fn`/`fn_mut` lang item is grossly ill-formed.
+
+#![feature(lang_items)]
+#![feature(no_core)]
+#![no_core]
+
+#[lang = "fn"]
+trait MyFn<T> {
+    const call: i32 = 42;
+    //~^ ERROR: `call` trait item in `fn` lang item must be a function
+}
+
+#[lang = "fn_mut"]
+trait MyFnMut<T> {
+    fn call(i: i32, j: i32) -> i32 { i + j }
+    //~^ ERROR: first argument of `call` in `fn_mut` lang item must be a reference
+}
+
+fn main() {
+    let a = || 42;
+    a();
+
+    let mut i = 0;
+    let mut b = || { i += 1; };
+    b();
+}
diff --git a/tests/ui/lang-items/fn-fn_mut-call-ill-formed.stderr b/tests/ui/lang-items/fn-fn_mut-call-ill-formed.stderr
new file mode 100644
index 00000000000..82bdae270c8
--- /dev/null
+++ b/tests/ui/lang-items/fn-fn_mut-call-ill-formed.stderr
@@ -0,0 +1,14 @@
+error: `call` trait item in `fn` lang item must be a function
+  --> $DIR/fn-fn_mut-call-ill-formed.rs:10:5
+   |
+LL |     const call: i32 = 42;
+   |     ^^^^^^^^^^^^^^^^^^^^^
+
+error: first argument of `call` in `fn_mut` lang item must be a reference
+  --> $DIR/fn-fn_mut-call-ill-formed.rs:16:16
+   |
+LL |     fn call(i: i32, j: i32) -> i32 { i + j }
+   |                ^^^
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/ui/lang-items/issue-19660.rs b/tests/ui/lang-items/issue-19660.rs
new file mode 100644
index 00000000000..400ac310b96
--- /dev/null
+++ b/tests/ui/lang-items/issue-19660.rs
@@ -0,0 +1,15 @@
+// error-pattern: requires `copy` lang_item
+
+#![feature(lang_items, start, no_core)]
+#![no_core]
+
+#[lang = "sized"]
+trait Sized { }
+
+struct S;
+
+#[start]
+fn main(_: isize, _: *const *const u8) -> isize {
+    let _ = S;
+    0
+}
diff --git a/tests/ui/lang-items/issue-19660.stderr b/tests/ui/lang-items/issue-19660.stderr
new file mode 100644
index 00000000000..f5d903f38eb
--- /dev/null
+++ b/tests/ui/lang-items/issue-19660.stderr
@@ -0,0 +1,4 @@
+error: requires `copy` lang_item
+
+error: aborting due to previous error
+
diff --git a/tests/ui/lang-items/issue-31076.rs b/tests/ui/lang-items/issue-31076.rs
new file mode 100644
index 00000000000..cdb196d4ff2
--- /dev/null
+++ b/tests/ui/lang-items/issue-31076.rs
@@ -0,0 +1,17 @@
+#![feature(no_core, lang_items)]
+#![no_core]
+
+#[lang="sized"]
+trait Sized {}
+
+#[lang="add"]
+trait Add<T> {}
+
+impl Add<i32> for i32 {}
+
+fn main() {
+    let x = 5 + 6;
+    //~^ ERROR cannot add `i32` to `{integer}`
+    let y = 5i32 + 6i32;
+    //~^ ERROR cannot add `i32` to `i32`
+}
diff --git a/tests/ui/lang-items/issue-31076.stderr b/tests/ui/lang-items/issue-31076.stderr
new file mode 100644
index 00000000000..ac0d9dc7528
--- /dev/null
+++ b/tests/ui/lang-items/issue-31076.stderr
@@ -0,0 +1,19 @@
+error[E0369]: cannot add `i32` to `{integer}`
+  --> $DIR/issue-31076.rs:13:15
+   |
+LL |     let x = 5 + 6;
+   |             - ^ - i32
+   |             |
+   |             {integer}
+
+error[E0369]: cannot add `i32` to `i32`
+  --> $DIR/issue-31076.rs:15:18
+   |
+LL |     let y = 5i32 + 6i32;
+   |             ---- ^ ---- i32
+   |             |
+   |             i32
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0369`.
diff --git a/tests/ui/lang-items/issue-83471.rs b/tests/ui/lang-items/issue-83471.rs
new file mode 100644
index 00000000000..b32aa034151
--- /dev/null
+++ b/tests/ui/lang-items/issue-83471.rs
@@ -0,0 +1,23 @@
+// Regression test for the ICE reported in issue #83471.
+
+#![crate_type="lib"]
+#![feature(no_core)]
+#![no_core]
+
+#[lang = "sized"]
+//~^ ERROR: language items are subject to change [E0658]
+trait Sized {}
+
+#[lang = "fn"]
+//~^ ERROR: language items are subject to change [E0658]
+//~| ERROR: `fn` language item must be applied to a trait with 1 generic argument
+trait Fn {
+    fn call(export_name);
+    //~^ ERROR: expected type
+    //~| WARNING: anonymous parameters are deprecated
+    //~| WARNING: this is accepted in the current edition
+}
+fn call_through_fn_trait() {
+    a()
+    //~^ ERROR: cannot find function
+}
diff --git a/tests/ui/lang-items/issue-83471.stderr b/tests/ui/lang-items/issue-83471.stderr
new file mode 100644
index 00000000000..b315df179d0
--- /dev/null
+++ b/tests/ui/lang-items/issue-83471.stderr
@@ -0,0 +1,51 @@
+error[E0573]: expected type, found built-in attribute `export_name`
+  --> $DIR/issue-83471.rs:15:13
+   |
+LL |     fn call(export_name);
+   |             ^^^^^^^^^^^ not a type
+
+error[E0658]: language items are subject to change
+  --> $DIR/issue-83471.rs:7:1
+   |
+LL | #[lang = "sized"]
+   | ^^^^^^^^^^^^^^^^^
+   |
+   = help: add `#![feature(lang_items)]` to the crate attributes to enable
+
+error[E0658]: language items are subject to change
+  --> $DIR/issue-83471.rs:11:1
+   |
+LL | #[lang = "fn"]
+   | ^^^^^^^^^^^^^^
+   |
+   = help: add `#![feature(lang_items)]` to the crate attributes to enable
+
+warning: anonymous parameters are deprecated and will be removed in the next edition
+  --> $DIR/issue-83471.rs:15:13
+   |
+LL |     fn call(export_name);
+   |             ^^^^^^^^^^^ help: try naming the parameter or explicitly ignoring it: `_: export_name`
+   |
+   = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
+   = note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686>
+   = note: `#[warn(anonymous_parameters)]` on by default
+
+error[E0718]: `fn` language item must be applied to a trait with 1 generic argument
+  --> $DIR/issue-83471.rs:11:1
+   |
+LL | #[lang = "fn"]
+   | ^^^^^^^^^^^^^^
+...
+LL | trait Fn {
+   |         - this trait has 0 generic arguments
+
+error[E0425]: cannot find function `a` in this scope
+  --> $DIR/issue-83471.rs:21:5
+   |
+LL |     a()
+   |     ^ not found in this scope
+
+error: aborting due to 5 previous errors; 1 warning emitted
+
+Some errors have detailed explanations: E0425, E0573, E0658, E0718.
+For more information about an error, try `rustc --explain E0425`.
diff --git a/tests/ui/lang-items/issue-86238.rs b/tests/ui/lang-items/issue-86238.rs
new file mode 100644
index 00000000000..509f94f3834
--- /dev/null
+++ b/tests/ui/lang-items/issue-86238.rs
@@ -0,0 +1,16 @@
+// Regression test for the ICE described in issue #86238.
+
+#![feature(lang_items)]
+#![feature(no_core)]
+
+#![no_core]
+fn main() {
+    let one = || {};
+    one()
+    //~^ ERROR: failed to find an overloaded call trait for closure call
+    //~| HELP: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined
+}
+#[lang = "sized"]
+trait Sized {}
+#[lang = "copy"]
+trait Copy {}
diff --git a/tests/ui/lang-items/issue-86238.stderr b/tests/ui/lang-items/issue-86238.stderr
new file mode 100644
index 00000000000..767e6de2263
--- /dev/null
+++ b/tests/ui/lang-items/issue-86238.stderr
@@ -0,0 +1,10 @@
+error: failed to find an overloaded call trait for closure call
+  --> $DIR/issue-86238.rs:9:5
+   |
+LL |     one()
+   |     ^^^^^
+   |
+   = help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have associated `call`/`call_mut`/`call_once` functions
+
+error: aborting due to previous error
+
diff --git a/tests/ui/lang-items/issue-87573.rs b/tests/ui/lang-items/issue-87573.rs
new file mode 100644
index 00000000000..aeb0c245a72
--- /dev/null
+++ b/tests/ui/lang-items/issue-87573.rs
@@ -0,0 +1,28 @@
+// Regression test for #87573, ensures that duplicate lang items or invalid generics
+// for lang items doesn't cause ICE.
+
+#![feature(no_core, lang_items)]
+#![no_core]
+#![crate_type = "lib"]
+
+pub static STATIC_BOOL: bool = true;
+
+#[lang = "sized"]
+trait Sized {}
+
+#[lang = "copy"]
+trait Copy {}
+
+#[lang = "sync"]
+trait Sync {}
+impl Sync for bool {}
+
+#[lang = "drop_in_place"]
+//~^ ERROR: `drop_in_place` language item must be applied to a function with at least 1 generic argument
+fn drop_fn() {
+    while false {}
+}
+
+#[lang = "start"]
+//~^ ERROR: `start` language item must be applied to a function with 1 generic argument
+fn start(){}
diff --git a/tests/ui/lang-items/issue-87573.stderr b/tests/ui/lang-items/issue-87573.stderr
new file mode 100644
index 00000000000..25560cfa0e6
--- /dev/null
+++ b/tests/ui/lang-items/issue-87573.stderr
@@ -0,0 +1,21 @@
+error[E0718]: `drop_in_place` language item must be applied to a function with at least 1 generic argument
+  --> $DIR/issue-87573.rs:20:1
+   |
+LL | #[lang = "drop_in_place"]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |
+LL | fn drop_fn() {
+   |           - this function has 0 generic arguments
+
+error[E0718]: `start` language item must be applied to a function with 1 generic argument
+  --> $DIR/issue-87573.rs:26:1
+   |
+LL | #[lang = "start"]
+   | ^^^^^^^^^^^^^^^^^
+LL |
+LL | fn start(){}
+   |         - this function has 0 generic arguments
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0718`.
diff --git a/tests/ui/lang-items/lang-item-generic-requirements.rs b/tests/ui/lang-items/lang-item-generic-requirements.rs
new file mode 100644
index 00000000000..3d33adf6831
--- /dev/null
+++ b/tests/ui/lang-items/lang-item-generic-requirements.rs
@@ -0,0 +1,59 @@
+// Checks that declaring a lang item with the wrong number of generic arguments errors rather than
+// crashing (issue #83474, #83893, #87573, part of #9307, #79559).
+
+#![feature(lang_items, no_core)]
+#![no_core]
+
+#[lang = "sized"]
+trait MySized {}
+
+#[lang = "add"]
+trait MyAdd<'a, T> {}
+//~^^ ERROR: `add` language item must be applied to a trait with 1 generic argument [E0718]
+
+#[lang = "drop_in_place"]
+//~^ ERROR `drop_in_place` language item must be applied to a function with at least 1 generic
+fn my_ptr_drop() {}
+
+#[lang = "index"]
+trait MyIndex<'a, T> {}
+//~^^ ERROR: `index` language item must be applied to a trait with 1 generic argument [E0718]
+
+#[lang = "phantom_data"]
+//~^ ERROR `phantom_data` language item must be applied to a struct with 1 generic argument
+struct MyPhantomData<T, U>;
+
+#[lang = "owned_box"]
+//~^ ERROR `owned_box` language item must be applied to a struct with at least 1 generic argument
+struct Foo;
+
+// When the `start` lang item is missing generics very odd things can happen, especially when
+// it comes to cross-crate monomorphization
+#[lang = "start"]
+//~^ ERROR `start` language item must be applied to a function with 1 generic argument [E0718]
+fn start(_: *const u8, _: isize, _: *const *const u8) -> isize {
+    0
+}
+
+fn ice() {
+    // Use add
+    let r = 5;
+    let a = 6;
+    r + a;
+
+    // Use drop in place
+    my_ptr_drop();
+
+    // Use index
+    let arr = [0; 5];
+    let _ = arr[2];
+
+    // Use phantomdata
+    let _ = MyPhantomData::<(), i32>;
+
+    // Use Foo
+    let _: () = Foo;
+}
+
+// use `start`
+fn main() {}
diff --git a/tests/ui/lang-items/lang-item-generic-requirements.stderr b/tests/ui/lang-items/lang-item-generic-requirements.stderr
new file mode 100644
index 00000000000..4d349a25f9c
--- /dev/null
+++ b/tests/ui/lang-items/lang-item-generic-requirements.stderr
@@ -0,0 +1,55 @@
+error[E0718]: `add` language item must be applied to a trait with 1 generic argument
+  --> $DIR/lang-item-generic-requirements.rs:10:1
+   |
+LL | #[lang = "add"]
+   | ^^^^^^^^^^^^^^^
+LL | trait MyAdd<'a, T> {}
+   |            ------- this trait has 2 generic arguments
+
+error[E0718]: `drop_in_place` language item must be applied to a function with at least 1 generic argument
+  --> $DIR/lang-item-generic-requirements.rs:14:1
+   |
+LL | #[lang = "drop_in_place"]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |
+LL | fn my_ptr_drop() {}
+   |               - this function has 0 generic arguments
+
+error[E0718]: `index` language item must be applied to a trait with 1 generic argument
+  --> $DIR/lang-item-generic-requirements.rs:18:1
+   |
+LL | #[lang = "index"]
+   | ^^^^^^^^^^^^^^^^^
+LL | trait MyIndex<'a, T> {}
+   |              ------- this trait has 2 generic arguments
+
+error[E0718]: `phantom_data` language item must be applied to a struct with 1 generic argument
+  --> $DIR/lang-item-generic-requirements.rs:22:1
+   |
+LL | #[lang = "phantom_data"]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^
+LL |
+LL | struct MyPhantomData<T, U>;
+   |                     ------ this struct has 2 generic arguments
+
+error[E0718]: `owned_box` language item must be applied to a struct with at least 1 generic argument
+  --> $DIR/lang-item-generic-requirements.rs:26:1
+   |
+LL | #[lang = "owned_box"]
+   | ^^^^^^^^^^^^^^^^^^^^^
+LL |
+LL | struct Foo;
+   |           - this struct has 0 generic arguments
+
+error[E0718]: `start` language item must be applied to a function with 1 generic argument
+  --> $DIR/lang-item-generic-requirements.rs:32:1
+   |
+LL | #[lang = "start"]
+   | ^^^^^^^^^^^^^^^^^
+LL |
+LL | fn start(_: *const u8, _: isize, _: *const *const u8) -> isize {
+   |         - this function has 0 generic arguments
+
+error: aborting due to 6 previous errors
+
+For more information about this error, try `rustc --explain E0718`.
diff --git a/tests/ui/lang-items/lang-item-missing-generator.rs b/tests/ui/lang-items/lang-item-missing-generator.rs
new file mode 100644
index 00000000000..9b9aff38e52
--- /dev/null
+++ b/tests/ui/lang-items/lang-item-missing-generator.rs
@@ -0,0 +1,21 @@
+// error-pattern: requires `generator` lang_item
+#![feature(no_core, lang_items, unboxed_closures, tuple_trait)]
+#![no_core]
+
+#[lang = "sized"] pub trait Sized { }
+
+#[lang = "tuple_trait"] pub trait Tuple { }
+
+#[lang = "fn_once"]
+#[rustc_paren_sugar]
+pub trait FnOnce<Args: Tuple> {
+    type Output;
+
+    extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
+}
+
+pub fn abc() -> impl FnOnce(f32) {
+    |_| {}
+}
+
+fn main() {}
diff --git a/tests/ui/lang-items/lang-item-missing-generator.stderr b/tests/ui/lang-items/lang-item-missing-generator.stderr
new file mode 100644
index 00000000000..a24fdb5fb65
--- /dev/null
+++ b/tests/ui/lang-items/lang-item-missing-generator.stderr
@@ -0,0 +1,15 @@
+error[E0635]: unknown feature `tuple_trait`
+  --> $DIR/lang-item-missing-generator.rs:2:51
+   |
+LL | #![feature(no_core, lang_items, unboxed_closures, tuple_trait)]
+   |                                                   ^^^^^^^^^^^
+
+error: requires `generator` lang_item
+  --> $DIR/lang-item-missing-generator.rs:17:17
+   |
+LL | pub fn abc() -> impl FnOnce(f32) {
+   |                 ^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0635`.
diff --git a/tests/ui/lang-items/lang-item-missing.rs b/tests/ui/lang-items/lang-item-missing.rs
new file mode 100644
index 00000000000..4e26343242e
--- /dev/null
+++ b/tests/ui/lang-items/lang-item-missing.rs
@@ -0,0 +1,12 @@
+// Test that a missing lang item (in this case `sized`) does not cause an ICE,
+// see #17392.
+
+// error-pattern: requires `sized` lang_item
+
+#![feature(start, no_core)]
+#![no_core]
+
+#[start]
+fn start(argc: isize, argv: *const *const u8) -> isize {
+    0
+}
diff --git a/tests/ui/lang-items/lang-item-missing.stderr b/tests/ui/lang-items/lang-item-missing.stderr
new file mode 100644
index 00000000000..f7516c7d377
--- /dev/null
+++ b/tests/ui/lang-items/lang-item-missing.stderr
@@ -0,0 +1,4 @@
+error: requires `sized` lang_item
+
+error: aborting due to previous error
+
diff --git a/tests/ui/lang-items/missing-clone-for-suggestion.rs b/tests/ui/lang-items/missing-clone-for-suggestion.rs
new file mode 100644
index 00000000000..e8290c0098a
--- /dev/null
+++ b/tests/ui/lang-items/missing-clone-for-suggestion.rs
@@ -0,0 +1,20 @@
+// Avoid panicking if the Clone trait is not found while building error suggestions
+// See #104870
+
+#![feature(no_core, lang_items)]
+#![no_core]
+
+#[lang = "sized"]
+trait Sized {}
+
+#[lang = "copy"]
+trait Copy {}
+
+fn g<T>(x: T) {}
+
+fn f(x: *mut u8) {
+    g(x);
+    g(x); //~ ERROR use of moved value: `x`
+}
+
+fn main() {}
diff --git a/tests/ui/lang-items/missing-clone-for-suggestion.stderr b/tests/ui/lang-items/missing-clone-for-suggestion.stderr
new file mode 100644
index 00000000000..35783a1be78
--- /dev/null
+++ b/tests/ui/lang-items/missing-clone-for-suggestion.stderr
@@ -0,0 +1,21 @@
+error[E0382]: use of moved value: `x`
+  --> $DIR/missing-clone-for-suggestion.rs:17:7
+   |
+LL | fn f(x: *mut u8) {
+   |      - move occurs because `x` has type `*mut u8`, which does not implement the `Copy` trait
+LL |     g(x);
+   |       - value moved here
+LL |     g(x);
+   |       ^ value used here after move
+   |
+note: consider changing this parameter type in function `g` to borrow instead if owning the value isn't necessary
+  --> $DIR/missing-clone-for-suggestion.rs:13:12
+   |
+LL | fn g<T>(x: T) {}
+   |    -       ^ this parameter takes ownership of the value
+   |    |
+   |    in this function
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0382`.
diff --git a/tests/ui/lang-items/no_owned_box_lang_item.rs b/tests/ui/lang-items/no_owned_box_lang_item.rs
new file mode 100644
index 00000000000..c22b44ffca2
--- /dev/null
+++ b/tests/ui/lang-items/no_owned_box_lang_item.rs
@@ -0,0 +1,16 @@
+// Test that we don't ICE when we are missing the owned_box lang item.
+
+// error-pattern: requires `owned_box` lang_item
+
+#![feature(lang_items, box_syntax)]
+#![no_std]
+
+use core::panic::PanicInfo;
+
+fn main() {
+    let x = box 1i32;
+}
+
+#[lang = "eh_personality"] extern "C" fn eh_personality() {}
+#[lang = "eh_catch_typeinfo"] static EH_CATCH_TYPEINFO: u8 = 0;
+#[lang = "panic_impl"] fn panic_impl(panic: &PanicInfo) -> ! { loop {} }
diff --git a/tests/ui/lang-items/no_owned_box_lang_item.stderr b/tests/ui/lang-items/no_owned_box_lang_item.stderr
new file mode 100644
index 00000000000..c55c246b5e1
--- /dev/null
+++ b/tests/ui/lang-items/no_owned_box_lang_item.stderr
@@ -0,0 +1,4 @@
+error: requires `owned_box` lang_item
+
+error: aborting due to previous error
+
diff --git a/tests/ui/lang-items/required-lang-item.rs b/tests/ui/lang-items/required-lang-item.rs
new file mode 100644
index 00000000000..3b17c5b7255
--- /dev/null
+++ b/tests/ui/lang-items/required-lang-item.rs
@@ -0,0 +1,11 @@
+// build-fail
+
+#![feature(lang_items, no_core)]
+#![no_core]
+
+#[lang="copy"] pub trait Copy { }
+#[lang="sized"] pub trait Sized { }
+
+// error-pattern:requires `start` lang_item
+
+fn main() {}
diff --git a/tests/ui/lang-items/required-lang-item.stderr b/tests/ui/lang-items/required-lang-item.stderr
new file mode 100644
index 00000000000..83764a91ac7
--- /dev/null
+++ b/tests/ui/lang-items/required-lang-item.stderr
@@ -0,0 +1,4 @@
+error: requires `start` lang_item
+
+error: aborting due to previous error
+