Skip to content

Commit 594a2fc

Browse files
committed
Add test for issue #83474
1 parent 634770c commit 594a2fc

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

src/test/ui/lang-items/lang-item-generic-requirements.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// Checks that declaring a lang item with the wrong number
2-
// of generic arguments errors rather than crashing (issue #83893, #87573, part of #9307, #79559).
1+
// Checks that declaring a lang item with the wrong number of generic arguments errors rather than
2+
// crashing (issue #83474, #83893, #87573, part of #9307, #79559).
33

44
#![feature(lang_items, no_core)]
55
#![no_core]
@@ -25,6 +25,10 @@ struct MyPhantomData<T, U>;
2525
//~^ ERROR parameter `T` is never used
2626
//~| ERROR parameter `U` is never used
2727

28+
#[lang = "owned_box"]
29+
//~^ ERROR `owned_box` language item must be applied to a struct with at least 1 generic argument
30+
struct Foo;
31+
2832
// When the `start` lang item is missing generics very odd things can happen, especially when
2933
// it comes to cross-crate monomorphization
3034
#[lang = "start"]
@@ -48,6 +52,9 @@ fn ice() {
4852

4953
// Use phantomdata
5054
let _ = MyPhantomData::<(), i32>;
55+
56+
// Use Foo
57+
let _: () = Foo;
5158
}
5259

5360
// use `start`

src/test/ui/lang-items/lang-item-generic-requirements.stderr

+11-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,17 @@ LL |
3232
LL | struct MyPhantomData<T, U>;
3333
| ------ this struct has 2 generic arguments
3434

35+
error[E0718]: `owned_box` language item must be applied to a struct with at least 1 generic argument
36+
--> $DIR/lang-item-generic-requirements.rs:28:1
37+
|
38+
LL | #[lang = "owned_box"]
39+
| ^^^^^^^^^^^^^^^^^^^^^
40+
LL |
41+
LL | struct Foo;
42+
| - this struct has 0 generic arguments
43+
3544
error[E0718]: `start` language item must be applied to a function with 1 generic argument
36-
--> $DIR/lang-item-generic-requirements.rs:30:1
45+
--> $DIR/lang-item-generic-requirements.rs:34:1
3746
|
3847
LL | #[lang = "start"]
3948
| ^^^^^^^^^^^^^^^^^
@@ -59,7 +68,7 @@ LL | struct MyPhantomData<T, U>;
5968
= help: consider removing `U` or referring to it in a field
6069
= help: if you intended `U` to be a const parameter, use `const U: usize` instead
6170

62-
error: aborting due to 7 previous errors
71+
error: aborting due to 8 previous errors
6372

6473
Some errors have detailed explanations: E0392, E0718.
6574
For more information about an error, try `rustc --explain E0392`.

0 commit comments

Comments
 (0)