Skip to content

Commit

Permalink
Add test for issue rust-lang#83474
Browse files Browse the repository at this point in the history
  • Loading branch information
Badel2 committed Dec 13, 2021
1 parent 229d0a9 commit 9820af4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/test/ui/lang-items/lang-item-generic-requirements.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Checks that declaring a lang item with the wrong number
// of generic arguments errors rather than crashing (issue #83893, #87573, part of #9307, #79559).
// 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]
Expand All @@ -25,6 +25,10 @@ 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"]
Expand All @@ -48,6 +52,9 @@ fn ice() {

// Use phantomdata
let _ = MyPhantomData::<(), i32>;

// Use Foo
let _: () = Foo;
}

// use `start`
Expand Down
13 changes: 11 additions & 2 deletions src/test/ui/lang-items/lang-item-generic-requirements.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,17 @@ 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:30:1
--> $DIR/lang-item-generic-requirements.rs:34:1
|
LL | #[lang = "start"]
| ^^^^^^^^^^^^^^^^^
Expand All @@ -59,7 +68,7 @@ LL | struct MyPhantomData<T, U>;
= 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 7 previous errors
error: aborting due to 8 previous errors

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

0 comments on commit 9820af4

Please sign in to comment.