Fix ICE when start
lang item has wrong generics
This commit is contained in:
parent
c3c0f80d60
commit
16c0a84510
4 changed files with 31 additions and 12 deletions
|
@ -299,7 +299,7 @@ language_item_table! {
|
||||||
Oom, sym::oom, oom, Target::Fn, GenericRequirement::None;
|
Oom, sym::oom, oom, Target::Fn, GenericRequirement::None;
|
||||||
AllocLayout, sym::alloc_layout, alloc_layout, Target::Struct, GenericRequirement::None;
|
AllocLayout, sym::alloc_layout, alloc_layout, Target::Struct, GenericRequirement::None;
|
||||||
|
|
||||||
Start, sym::start, start_fn, Target::Fn, GenericRequirement::None;
|
Start, sym::start, start_fn, Target::Fn, GenericRequirement::Exact(1);
|
||||||
|
|
||||||
EhPersonality, sym::eh_personality, eh_personality, Target::Fn, GenericRequirement::None;
|
EhPersonality, sym::eh_personality, eh_personality, Target::Fn, GenericRequirement::None;
|
||||||
EhCatchTypeinfo, sym::eh_catch_typeinfo, eh_catch_typeinfo, Target::Static, GenericRequirement::None;
|
EhCatchTypeinfo, sym::eh_catch_typeinfo, eh_catch_typeinfo, Target::Static, GenericRequirement::None;
|
||||||
|
|
|
@ -11,7 +11,7 @@ trait Sized {}
|
||||||
auto trait Freeze {}
|
auto trait Freeze {}
|
||||||
|
|
||||||
#[lang = "start"]
|
#[lang = "start"]
|
||||||
fn start(_main: *const u8, _argc: isize, _argv: *const *const u8) -> isize {
|
fn start<T>(_main: *const u8, _argc: isize, _argv: *const *const u8) -> isize {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
// Checks whether declaring a lang item with the wrong number
|
// Checks that declaring a lang item with the wrong number
|
||||||
// of generic arguments crashes the compiler (issue #83893, #87573, and part of #9307).
|
// of generic arguments errors rather than crashing (issue #83893, #87573, part of #9307, #79559).
|
||||||
|
|
||||||
#![feature(lang_items, no_core)]
|
#![feature(lang_items, no_core)]
|
||||||
#![no_core]
|
#![no_core]
|
||||||
#![crate_type = "lib"]
|
|
||||||
|
|
||||||
#[lang = "sized"]
|
#[lang = "sized"]
|
||||||
trait MySized {}
|
trait MySized {}
|
||||||
|
@ -26,6 +25,14 @@ struct MyPhantomData<T, U>;
|
||||||
//~^ ERROR parameter `T` is never used
|
//~^ ERROR parameter `T` is never used
|
||||||
//~| ERROR parameter `U` is never used
|
//~| ERROR parameter `U` is never used
|
||||||
|
|
||||||
|
// 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() {
|
fn ice() {
|
||||||
// Use add
|
// Use add
|
||||||
let r = 5;
|
let r = 5;
|
||||||
|
@ -42,3 +49,6 @@ fn ice() {
|
||||||
// Use phantomdata
|
// Use phantomdata
|
||||||
let _ = MyPhantomData::<(), i32>;
|
let _ = MyPhantomData::<(), i32>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// use `start`
|
||||||
|
fn main() {}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
error[E0718]: `add` language item must be applied to a trait with 1 generic argument
|
error[E0718]: `add` language item must be applied to a trait with 1 generic argument
|
||||||
--> $DIR/lang-item-generic-requirements.rs:11:1
|
--> $DIR/lang-item-generic-requirements.rs:10:1
|
||||||
|
|
|
|
||||||
LL | #[lang = "add"]
|
LL | #[lang = "add"]
|
||||||
| ^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^
|
||||||
|
@ -7,7 +7,7 @@ LL | trait MyAdd<'a, T> {}
|
||||||
| ------- this trait has 2 generic arguments
|
| ------- 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
|
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:15:1
|
--> $DIR/lang-item-generic-requirements.rs:14:1
|
||||||
|
|
|
|
||||||
LL | #[lang = "drop_in_place"]
|
LL | #[lang = "drop_in_place"]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -16,7 +16,7 @@ LL | fn my_ptr_drop() {}
|
||||||
| - this function has 0 generic arguments
|
| - this function has 0 generic arguments
|
||||||
|
|
||||||
error[E0718]: `index` language item must be applied to a trait with 1 generic argument
|
error[E0718]: `index` language item must be applied to a trait with 1 generic argument
|
||||||
--> $DIR/lang-item-generic-requirements.rs:19:1
|
--> $DIR/lang-item-generic-requirements.rs:18:1
|
||||||
|
|
|
|
||||||
LL | #[lang = "index"]
|
LL | #[lang = "index"]
|
||||||
| ^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
@ -24,7 +24,7 @@ LL | trait MyIndex<'a, T> {}
|
||||||
| ------- this trait has 2 generic arguments
|
| ------- this trait has 2 generic arguments
|
||||||
|
|
||||||
error[E0718]: `phantom_data` language item must be applied to a struct with 1 generic argument
|
error[E0718]: `phantom_data` language item must be applied to a struct with 1 generic argument
|
||||||
--> $DIR/lang-item-generic-requirements.rs:23:1
|
--> $DIR/lang-item-generic-requirements.rs:22:1
|
||||||
|
|
|
|
||||||
LL | #[lang = "phantom_data"]
|
LL | #[lang = "phantom_data"]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -32,8 +32,17 @@ LL |
|
||||||
LL | struct MyPhantomData<T, U>;
|
LL | struct MyPhantomData<T, U>;
|
||||||
| ------ this struct has 2 generic arguments
|
| ------ this struct has 2 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
|
||||||
|
|
|
||||||
|
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
|
error[E0392]: parameter `T` is never used
|
||||||
--> $DIR/lang-item-generic-requirements.rs:25:22
|
--> $DIR/lang-item-generic-requirements.rs:24:22
|
||||||
|
|
|
|
||||||
LL | struct MyPhantomData<T, U>;
|
LL | struct MyPhantomData<T, U>;
|
||||||
| ^ unused parameter
|
| ^ unused parameter
|
||||||
|
@ -42,7 +51,7 @@ LL | struct MyPhantomData<T, U>;
|
||||||
= help: if you intended `T` to be a const parameter, use `const T: usize` instead
|
= help: if you intended `T` to be a const parameter, use `const T: usize` instead
|
||||||
|
|
||||||
error[E0392]: parameter `U` is never used
|
error[E0392]: parameter `U` is never used
|
||||||
--> $DIR/lang-item-generic-requirements.rs:25:25
|
--> $DIR/lang-item-generic-requirements.rs:24:25
|
||||||
|
|
|
|
||||||
LL | struct MyPhantomData<T, U>;
|
LL | struct MyPhantomData<T, U>;
|
||||||
| ^ unused parameter
|
| ^ unused parameter
|
||||||
|
@ -50,7 +59,7 @@ LL | struct MyPhantomData<T, U>;
|
||||||
= help: consider removing `U` or referring to it in a field
|
= 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
|
= help: if you intended `U` to be a const parameter, use `const U: usize` instead
|
||||||
|
|
||||||
error: aborting due to 6 previous errors
|
error: aborting due to 7 previous errors
|
||||||
|
|
||||||
Some errors have detailed explanations: E0392, E0718.
|
Some errors have detailed explanations: E0392, E0718.
|
||||||
For more information about an error, try `rustc --explain E0392`.
|
For more information about an error, try `rustc --explain E0392`.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue