summaryrefslogtreecommitdiffstats
path: root/tests/ui/lang-items
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
commit218caa410aa38c29984be31a5229b9fa717560ee (patch)
treec54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/ui/lang-items
parentReleasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz
rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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
-rw-r--r--tests/ui/lang-items/start_lang_item_args.argc.stderr8
-rw-r--r--tests/ui/lang-items/start_lang_item_args.argv.stderr8
-rw-r--r--tests/ui/lang-items/start_lang_item_args.argv_inner_ptr.stderr13
-rw-r--r--tests/ui/lang-items/start_lang_item_args.main_args.stderr13
-rw-r--r--tests/ui/lang-items/start_lang_item_args.main_ret.stderr13
-rw-r--r--tests/ui/lang-items/start_lang_item_args.main_ty.stderr8
-rw-r--r--tests/ui/lang-items/start_lang_item_args.missing_all_args.stderr11
-rw-r--r--tests/ui/lang-items/start_lang_item_args.missing_ret.stderr8
-rw-r--r--tests/ui/lang-items/start_lang_item_args.missing_sigpipe_arg.stderr11
-rw-r--r--tests/ui/lang-items/start_lang_item_args.rs101
-rw-r--r--tests/ui/lang-items/start_lang_item_args.sigpipe.stderr8
-rw-r--r--tests/ui/lang-items/start_lang_item_args.start_ret.stderr8
-rw-r--r--tests/ui/lang-items/start_lang_item_args.too_many_args.stderr17
37 files changed, 714 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 000000000..52bd8136d
--- /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 000000000..82bdae270
--- /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 000000000..400ac310b
--- /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 000000000..f5d903f38
--- /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 000000000..cdb196d4f
--- /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 000000000..ac0d9dc75
--- /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 000000000..b32aa0341
--- /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 000000000..b315df179
--- /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 000000000..509f94f38
--- /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 000000000..767e6de22
--- /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 000000000..aeb0c245a
--- /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 000000000..25560cfa0
--- /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 000000000..3d33adf68
--- /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 000000000..4d349a25f
--- /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 000000000..9b9aff38e
--- /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 000000000..a24fdb5fb
--- /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 000000000..4e2634324
--- /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 000000000..f7516c7d3
--- /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 000000000..e8290c009
--- /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 000000000..35783a1be
--- /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 000000000..c22b44ffc
--- /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 000000000..c55c246b5
--- /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 000000000..3b17c5b72
--- /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 000000000..83764a91a
--- /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
+
diff --git a/tests/ui/lang-items/start_lang_item_args.argc.stderr b/tests/ui/lang-items/start_lang_item_args.argc.stderr
new file mode 100644
index 000000000..65c99a93c
--- /dev/null
+++ b/tests/ui/lang-items/start_lang_item_args.argc.stderr
@@ -0,0 +1,8 @@
+error: parameter 2 of the `start` lang item is incorrect
+ --> $DIR/start_lang_item_args.rs:75:38
+ |
+LL | fn start<T>(_main: fn() -> T, _argc: i8, _argv: *const *const u8, _sigpipe: u8) -> isize {
+ | ^^ help: change the type from `i8` to `isize`
+
+error: aborting due to previous error
+
diff --git a/tests/ui/lang-items/start_lang_item_args.argv.stderr b/tests/ui/lang-items/start_lang_item_args.argv.stderr
new file mode 100644
index 000000000..f0947a9b3
--- /dev/null
+++ b/tests/ui/lang-items/start_lang_item_args.argv.stderr
@@ -0,0 +1,8 @@
+error: parameter 3 of the `start` lang item is incorrect
+ --> $DIR/start_lang_item_args.rs:89:52
+ |
+LL | fn start<T>(_main: fn() -> T, _argc: isize, _argv: u8, _sigpipe: u8) -> isize {
+ | ^^ help: change the type from `u8` to `*const *const u8`
+
+error: aborting due to previous error
+
diff --git a/tests/ui/lang-items/start_lang_item_args.argv_inner_ptr.stderr b/tests/ui/lang-items/start_lang_item_args.argv_inner_ptr.stderr
new file mode 100644
index 000000000..08efd5088
--- /dev/null
+++ b/tests/ui/lang-items/start_lang_item_args.argv_inner_ptr.stderr
@@ -0,0 +1,13 @@
+error: parameter 3 of the `start` lang item is incorrect
+ --> $DIR/start_lang_item_args.rs:82:52
+ |
+LL | fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const usize, _sigpipe: u8) -> isize {
+ | ^^^^^^^^^^^^^^^^^^^
+ |
+help: change the type from `*const *const usize` to `*const *const u8`
+ |
+LL | fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> isize {
+ | ~~~~~~~~~~~~~~~~
+
+error: aborting due to previous error
+
diff --git a/tests/ui/lang-items/start_lang_item_args.main_args.stderr b/tests/ui/lang-items/start_lang_item_args.main_args.stderr
new file mode 100644
index 000000000..c20a74466
--- /dev/null
+++ b/tests/ui/lang-items/start_lang_item_args.main_args.stderr
@@ -0,0 +1,13 @@
+error: parameter 1 of the `start` lang item is incorrect
+ --> $DIR/start_lang_item_args.rs:61:20
+ |
+LL | fn start<T>(_main: fn(i32) -> T, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> isize {
+ | ^^^^^^^^^^^^
+ |
+help: change the type from `fn(i32) -> T` to `fn() -> T`
+ |
+LL | fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> isize {
+ | ~~~~~~~~~
+
+error: aborting due to previous error
+
diff --git a/tests/ui/lang-items/start_lang_item_args.main_ret.stderr b/tests/ui/lang-items/start_lang_item_args.main_ret.stderr
new file mode 100644
index 000000000..8f967252f
--- /dev/null
+++ b/tests/ui/lang-items/start_lang_item_args.main_ret.stderr
@@ -0,0 +1,13 @@
+error: parameter 1 of the `start` lang item is incorrect
+ --> $DIR/start_lang_item_args.rs:68:20
+ |
+LL | fn start<T>(_main: fn() -> u16, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> isize {
+ | ^^^^^^^^^^^
+ |
+help: change the type from `fn() -> u16` to `fn() -> T`
+ |
+LL | fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> isize {
+ | ~~~~~~~~~
+
+error: aborting due to previous error
+
diff --git a/tests/ui/lang-items/start_lang_item_args.main_ty.stderr b/tests/ui/lang-items/start_lang_item_args.main_ty.stderr
new file mode 100644
index 000000000..deb37b868
--- /dev/null
+++ b/tests/ui/lang-items/start_lang_item_args.main_ty.stderr
@@ -0,0 +1,8 @@
+error: parameter 1 of the `start` lang item is incorrect
+ --> $DIR/start_lang_item_args.rs:54:20
+ |
+LL | fn start<T>(_main: u64, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> isize {
+ | ^^^ help: change the type from `u64` to `fn() -> T`
+
+error: aborting due to previous error
+
diff --git a/tests/ui/lang-items/start_lang_item_args.missing_all_args.stderr b/tests/ui/lang-items/start_lang_item_args.missing_all_args.stderr
new file mode 100644
index 000000000..004c2a67f
--- /dev/null
+++ b/tests/ui/lang-items/start_lang_item_args.missing_all_args.stderr
@@ -0,0 +1,11 @@
+error: incorrect number of parameters for the `start` lang item
+ --> $DIR/start_lang_item_args.rs:15:1
+ |
+LL | fn start<T>() -> isize {
+ | ^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: the `start` lang item should have four parameters, but found 0
+ = note: the `start` lang item should have the signature `fn(fn() -> T, isize, *const *const u8, u8) -> isize`
+
+error: aborting due to previous error
+
diff --git a/tests/ui/lang-items/start_lang_item_args.missing_ret.stderr b/tests/ui/lang-items/start_lang_item_args.missing_ret.stderr
new file mode 100644
index 000000000..1d8285b59
--- /dev/null
+++ b/tests/ui/lang-items/start_lang_item_args.missing_ret.stderr
@@ -0,0 +1,8 @@
+error: the return type of the `start` lang item is incorrect
+ --> $DIR/start_lang_item_args.rs:29:84
+ |
+LL | fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8, _sigpipe: u8) {}
+ | ^ help: change the type from `()` to `isize`
+
+error: aborting due to previous error
+
diff --git a/tests/ui/lang-items/start_lang_item_args.missing_sigpipe_arg.stderr b/tests/ui/lang-items/start_lang_item_args.missing_sigpipe_arg.stderr
new file mode 100644
index 000000000..e545a750f
--- /dev/null
+++ b/tests/ui/lang-items/start_lang_item_args.missing_sigpipe_arg.stderr
@@ -0,0 +1,11 @@
+error: incorrect number of parameters for the `start` lang item
+ --> $DIR/start_lang_item_args.rs:22:1
+ |
+LL | fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8) -> isize {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: the `start` lang item should have four parameters, but found 3
+ = note: the `start` lang item should have the signature `fn(fn() -> T, isize, *const *const u8, u8) -> isize`
+
+error: aborting due to previous error
+
diff --git a/tests/ui/lang-items/start_lang_item_args.rs b/tests/ui/lang-items/start_lang_item_args.rs
new file mode 100644
index 000000000..0dbfba39c
--- /dev/null
+++ b/tests/ui/lang-items/start_lang_item_args.rs
@@ -0,0 +1,101 @@
+// check-fail
+// revisions: missing_all_args missing_sigpipe_arg missing_ret start_ret too_many_args
+// revisions: main_ty main_args main_ret argc argv_inner_ptr argv sigpipe
+
+#![feature(lang_items, no_core)]
+#![no_core]
+
+#[lang = "copy"]
+pub trait Copy {}
+#[lang = "sized"]
+pub trait Sized {}
+
+#[cfg(missing_all_args)]
+#[lang = "start"]
+fn start<T>() -> isize {
+ //[missing_all_args]~^ ERROR incorrect number of parameters
+ 100
+}
+
+#[cfg(missing_sigpipe_arg)]
+#[lang = "start"]
+fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8) -> isize {
+ //[missing_sigpipe_arg]~^ ERROR incorrect number of parameters
+ 100
+}
+
+#[cfg(missing_ret)]
+#[lang = "start"]
+fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8, _sigpipe: u8) {}
+//[missing_ret]~^ ERROR the return type of the `start` lang item is incorrect
+
+#[cfg(start_ret)]
+#[lang = "start"]
+fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> u8 {
+ //[start_ret]~^ ERROR the return type of the `start` lang item is incorrect
+ 100
+}
+
+#[cfg(too_many_args)]
+#[lang = "start"]
+fn start<T>(
+ //[too_many_args]~^ ERROR incorrect number of parameters
+ _main: fn() -> T,
+ _argc: isize,
+ _argv: *const *const u8,
+ _sigpipe: u8,
+ _extra_arg: (),
+) -> isize {
+ 100
+}
+
+#[cfg(main_ty)]
+#[lang = "start"]
+fn start<T>(_main: u64, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> isize {
+ //[main_ty]~^ ERROR parameter 1 of the `start` lang item is incorrect
+ 100
+}
+
+#[cfg(main_args)]
+#[lang = "start"]
+fn start<T>(_main: fn(i32) -> T, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> isize {
+ //[main_args]~^ ERROR parameter 1 of the `start` lang item is incorrect
+ 100
+}
+
+#[cfg(main_ret)]
+#[lang = "start"]
+fn start<T>(_main: fn() -> u16, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> isize {
+ //[main_ret]~^ ERROR parameter 1 of the `start` lang item is incorrect
+ 100
+}
+
+#[cfg(argc)]
+#[lang = "start"]
+fn start<T>(_main: fn() -> T, _argc: i8, _argv: *const *const u8, _sigpipe: u8) -> isize {
+ //[argc]~^ ERROR parameter 2 of the `start` lang item is incorrect
+ 100
+}
+
+#[cfg(argv_inner_ptr)]
+#[lang = "start"]
+fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const usize, _sigpipe: u8) -> isize {
+ //[argv_inner_ptr]~^ ERROR parameter 3 of the `start` lang item is incorrect
+ 100
+}
+
+#[cfg(argv)]
+#[lang = "start"]
+fn start<T>(_main: fn() -> T, _argc: isize, _argv: u8, _sigpipe: u8) -> isize {
+ //[argv]~^ ERROR parameter 3 of the `start` lang item is incorrect
+ 100
+}
+
+#[cfg(sigpipe)]
+#[lang = "start"]
+fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8, _sigpipe: i64) -> isize {
+ //[sigpipe]~^ ERROR parameter 4 of the `start` lang item is incorrect
+ 100
+}
+
+fn main() {}
diff --git a/tests/ui/lang-items/start_lang_item_args.sigpipe.stderr b/tests/ui/lang-items/start_lang_item_args.sigpipe.stderr
new file mode 100644
index 000000000..b20ae3128
--- /dev/null
+++ b/tests/ui/lang-items/start_lang_item_args.sigpipe.stderr
@@ -0,0 +1,8 @@
+error: parameter 4 of the `start` lang item is incorrect
+ --> $DIR/start_lang_item_args.rs:96:80
+ |
+LL | fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8, _sigpipe: i64) -> isize {
+ | ^^^ help: change the type from `i64` to `u8`
+
+error: aborting due to previous error
+
diff --git a/tests/ui/lang-items/start_lang_item_args.start_ret.stderr b/tests/ui/lang-items/start_lang_item_args.start_ret.stderr
new file mode 100644
index 000000000..935d5f3c8
--- /dev/null
+++ b/tests/ui/lang-items/start_lang_item_args.start_ret.stderr
@@ -0,0 +1,8 @@
+error: the return type of the `start` lang item is incorrect
+ --> $DIR/start_lang_item_args.rs:34:87
+ |
+LL | fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> u8 {
+ | ^^ help: change the type from `u8` to `isize`
+
+error: aborting due to previous error
+
diff --git a/tests/ui/lang-items/start_lang_item_args.too_many_args.stderr b/tests/ui/lang-items/start_lang_item_args.too_many_args.stderr
new file mode 100644
index 000000000..30a7ed18a
--- /dev/null
+++ b/tests/ui/lang-items/start_lang_item_args.too_many_args.stderr
@@ -0,0 +1,17 @@
+error: incorrect number of parameters for the `start` lang item
+ --> $DIR/start_lang_item_args.rs:41:1
+ |
+LL | / fn start<T>(
+LL | |
+LL | | _main: fn() -> T,
+LL | | _argc: isize,
+... |
+LL | | _extra_arg: (),
+LL | | ) -> isize {
+ | |__________^
+ |
+ = note: the `start` lang item should have four parameters, but found 5
+ = note: the `start` lang item should have the signature `fn(fn() -> T, isize, *const *const u8, u8) -> isize`
+
+error: aborting due to previous error
+