summaryrefslogtreecommitdiffstats
path: root/src/test/ui/lang-items
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/lang-items')
-rw-r--r--src/test/ui/lang-items/fn-fn_mut-call-ill-formed.rs27
-rw-r--r--src/test/ui/lang-items/fn-fn_mut-call-ill-formed.stderr14
-rw-r--r--src/test/ui/lang-items/issue-19660.rs15
-rw-r--r--src/test/ui/lang-items/issue-19660.stderr4
-rw-r--r--src/test/ui/lang-items/issue-31076.rs17
-rw-r--r--src/test/ui/lang-items/issue-31076.stderr19
-rw-r--r--src/test/ui/lang-items/issue-83471.rs23
-rw-r--r--src/test/ui/lang-items/issue-83471.stderr51
-rw-r--r--src/test/ui/lang-items/issue-86238.rs16
-rw-r--r--src/test/ui/lang-items/issue-86238.stderr10
-rw-r--r--src/test/ui/lang-items/issue-87573.rs28
-rw-r--r--src/test/ui/lang-items/issue-87573.stderr21
-rw-r--r--src/test/ui/lang-items/lang-item-generic-requirements.rs61
-rw-r--r--src/test/ui/lang-items/lang-item-generic-requirements.stderr74
-rw-r--r--src/test/ui/lang-items/lang-item-missing-generator.rs19
-rw-r--r--src/test/ui/lang-items/lang-item-missing-generator.stderr8
-rw-r--r--src/test/ui/lang-items/lang-item-missing.rs12
-rw-r--r--src/test/ui/lang-items/lang-item-missing.stderr4
-rw-r--r--src/test/ui/lang-items/no_owned_box_lang_item.rs16
-rw-r--r--src/test/ui/lang-items/no_owned_box_lang_item.stderr4
-rw-r--r--src/test/ui/lang-items/required-lang-item.rs11
-rw-r--r--src/test/ui/lang-items/required-lang-item.stderr4
22 files changed, 458 insertions, 0 deletions
diff --git a/src/test/ui/lang-items/fn-fn_mut-call-ill-formed.rs b/src/test/ui/lang-items/fn-fn_mut-call-ill-formed.rs
new file mode 100644
index 000000000..52bd8136d
--- /dev/null
+++ b/src/test/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/src/test/ui/lang-items/fn-fn_mut-call-ill-formed.stderr b/src/test/ui/lang-items/fn-fn_mut-call-ill-formed.stderr
new file mode 100644
index 000000000..82bdae270
--- /dev/null
+++ b/src/test/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/src/test/ui/lang-items/issue-19660.rs b/src/test/ui/lang-items/issue-19660.rs
new file mode 100644
index 000000000..400ac310b
--- /dev/null
+++ b/src/test/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/src/test/ui/lang-items/issue-19660.stderr b/src/test/ui/lang-items/issue-19660.stderr
new file mode 100644
index 000000000..f5d903f38
--- /dev/null
+++ b/src/test/ui/lang-items/issue-19660.stderr
@@ -0,0 +1,4 @@
+error: requires `copy` lang_item
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/lang-items/issue-31076.rs b/src/test/ui/lang-items/issue-31076.rs
new file mode 100644
index 000000000..cdb196d4f
--- /dev/null
+++ b/src/test/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/src/test/ui/lang-items/issue-31076.stderr b/src/test/ui/lang-items/issue-31076.stderr
new file mode 100644
index 000000000..ac0d9dc75
--- /dev/null
+++ b/src/test/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/src/test/ui/lang-items/issue-83471.rs b/src/test/ui/lang-items/issue-83471.rs
new file mode 100644
index 000000000..b32aa0341
--- /dev/null
+++ b/src/test/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/src/test/ui/lang-items/issue-83471.stderr b/src/test/ui/lang-items/issue-83471.stderr
new file mode 100644
index 000000000..6d796fe7f
--- /dev/null
+++ b/src/test/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[E0425]: cannot find function `a` in this scope
+ --> $DIR/issue-83471.rs:21:5
+ |
+LL | a()
+ | ^ not found in this scope
+
+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`
+ |
+ = note: `#[warn(anonymous_parameters)]` on by default
+ = 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>
+
+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: 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/src/test/ui/lang-items/issue-86238.rs b/src/test/ui/lang-items/issue-86238.rs
new file mode 100644
index 000000000..509f94f38
--- /dev/null
+++ b/src/test/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/src/test/ui/lang-items/issue-86238.stderr b/src/test/ui/lang-items/issue-86238.stderr
new file mode 100644
index 000000000..767e6de22
--- /dev/null
+++ b/src/test/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/src/test/ui/lang-items/issue-87573.rs b/src/test/ui/lang-items/issue-87573.rs
new file mode 100644
index 000000000..aeb0c245a
--- /dev/null
+++ b/src/test/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/src/test/ui/lang-items/issue-87573.stderr b/src/test/ui/lang-items/issue-87573.stderr
new file mode 100644
index 000000000..25560cfa0
--- /dev/null
+++ b/src/test/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/src/test/ui/lang-items/lang-item-generic-requirements.rs b/src/test/ui/lang-items/lang-item-generic-requirements.rs
new file mode 100644
index 000000000..fbb56e528
--- /dev/null
+++ b/src/test/ui/lang-items/lang-item-generic-requirements.rs
@@ -0,0 +1,61 @@
+// 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>;
+//~^ ERROR parameter `T` is never used
+//~| ERROR parameter `U` is never used
+
+#[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/src/test/ui/lang-items/lang-item-generic-requirements.stderr b/src/test/ui/lang-items/lang-item-generic-requirements.stderr
new file mode 100644
index 000000000..326f5b0d5
--- /dev/null
+++ b/src/test/ui/lang-items/lang-item-generic-requirements.stderr
@@ -0,0 +1,74 @@
+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:28: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:34:1
+ |
+LL | #[lang = "start"]
+ | ^^^^^^^^^^^^^^^^^
+LL |
+LL | fn start(_: *const u8, _: isize, _: *const *const u8) -> isize {
+ | - this function has 0 generic arguments
+
+error[E0392]: parameter `T` is never used
+ --> $DIR/lang-item-generic-requirements.rs:24:22
+ |
+LL | struct MyPhantomData<T, U>;
+ | ^ unused parameter
+ |
+ = help: consider removing `T` or referring to it in a field
+ = help: if you intended `T` to be a const parameter, use `const T: usize` instead
+
+error[E0392]: parameter `U` is never used
+ --> $DIR/lang-item-generic-requirements.rs:24:25
+ |
+LL | struct MyPhantomData<T, U>;
+ | ^ unused parameter
+ |
+ = help: consider removing `U` or referring to it in a field
+ = help: if you intended `U` to be a const parameter, use `const U: usize` instead
+
+error: aborting due to 8 previous errors
+
+Some errors have detailed explanations: E0392, E0718.
+For more information about an error, try `rustc --explain E0392`.
diff --git a/src/test/ui/lang-items/lang-item-missing-generator.rs b/src/test/ui/lang-items/lang-item-missing-generator.rs
new file mode 100644
index 000000000..0c3295429
--- /dev/null
+++ b/src/test/ui/lang-items/lang-item-missing-generator.rs
@@ -0,0 +1,19 @@
+// error-pattern: requires `generator` lang_item
+#![feature(no_core, lang_items, unboxed_closures)]
+#![no_core]
+
+#[lang = "sized"] pub trait Sized { }
+
+#[lang = "fn_once"]
+#[rustc_paren_sugar]
+pub trait FnOnce<Args> {
+ type Output;
+
+ extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
+}
+
+pub fn abc() -> impl FnOnce(f32) {
+ |_| {}
+}
+
+fn main() {}
diff --git a/src/test/ui/lang-items/lang-item-missing-generator.stderr b/src/test/ui/lang-items/lang-item-missing-generator.stderr
new file mode 100644
index 000000000..fa13bf0b1
--- /dev/null
+++ b/src/test/ui/lang-items/lang-item-missing-generator.stderr
@@ -0,0 +1,8 @@
+error: requires `generator` lang_item
+ --> $DIR/lang-item-missing-generator.rs:15:17
+ |
+LL | pub fn abc() -> impl FnOnce(f32) {
+ | ^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/lang-items/lang-item-missing.rs b/src/test/ui/lang-items/lang-item-missing.rs
new file mode 100644
index 000000000..4e2634324
--- /dev/null
+++ b/src/test/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/src/test/ui/lang-items/lang-item-missing.stderr b/src/test/ui/lang-items/lang-item-missing.stderr
new file mode 100644
index 000000000..f7516c7d3
--- /dev/null
+++ b/src/test/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/src/test/ui/lang-items/no_owned_box_lang_item.rs b/src/test/ui/lang-items/no_owned_box_lang_item.rs
new file mode 100644
index 000000000..c22b44ffc
--- /dev/null
+++ b/src/test/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/src/test/ui/lang-items/no_owned_box_lang_item.stderr b/src/test/ui/lang-items/no_owned_box_lang_item.stderr
new file mode 100644
index 000000000..c55c246b5
--- /dev/null
+++ b/src/test/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/src/test/ui/lang-items/required-lang-item.rs b/src/test/ui/lang-items/required-lang-item.rs
new file mode 100644
index 000000000..3b17c5b72
--- /dev/null
+++ b/src/test/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/src/test/ui/lang-items/required-lang-item.stderr b/src/test/ui/lang-items/required-lang-item.stderr
new file mode 100644
index 000000000..83764a91a
--- /dev/null
+++ b/src/test/ui/lang-items/required-lang-item.stderr
@@ -0,0 +1,4 @@
+error: requires `start` lang_item
+
+error: aborting due to previous error
+