-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Do not allow extern unsized_fn_param #123894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// https://github.com/rust-lang/rust/issues/123887 | ||
// Do not ICE on unsized extern parameter | ||
//@ compile-flags: -Clink-dead-code --emit=link | ||
#![feature(extern_types, unsized_fn_params)] | ||
|
||
extern "C" { | ||
type ExternType; | ||
} | ||
|
||
struct Wrapper<T: ?Sized>(T); | ||
fn f(_: impl ?Sized) {} | ||
fn g(x: Box<Wrapper<ExternType>>) { | ||
f(*x); //~ ERROR unsized arguments must not be `extern` types | ||
} | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
error: unsized arguments must not be `extern` types | ||
--> $DIR/extern-parameter-issue-123887-generic-wrapped.rs:13:5 | ||
| | ||
LL | f(*x); | ||
| ^^^^^ | ||
|
||
error: aborting due to 1 previous error | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// https://github.com/rust-lang/rust/issues/123887 | ||
// Do not ICE on unsized extern parameter | ||
//@ compile-flags: -Clink-dead-code --emit=link | ||
#![feature(extern_types, unsized_fn_params)] | ||
|
||
extern "C" { | ||
type ExternType; | ||
} | ||
|
||
fn f(_: impl ?Sized) {} | ||
fn g(x: Box<ExternType>) { | ||
f(*x); //~ ERROR unsized arguments must not be `extern` types | ||
} | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
error: unsized arguments must not be `extern` types | ||
--> $DIR/extern-parameter-issue-123887-generic.rs:12:5 | ||
| | ||
LL | f(*x); | ||
| ^^^^^ | ||
|
||
error: aborting due to 1 previous error | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// https://github.com/rust-lang/rust/issues/123887 | ||
// Do not ICE on unsized extern parameter | ||
//@ compile-flags: -Clink-dead-code --emit=link | ||
#![feature(extern_types, unsized_fn_params)] | ||
|
||
extern "C" { | ||
type ExternType; | ||
} | ||
|
||
struct Wrapper<T: ?Sized>(T); | ||
fn f(_: Wrapper<ExternType>) {} //~ ERROR the size for values of type `ExternType` cannot be known at compilation time | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
error[E0277]: the size for values of type `ExternType` cannot be known at compilation time | ||
--> $DIR/extern-parameter-issue-123887-wrapped.rs:11:6 | ||
| | ||
LL | fn f(_: Wrapper<ExternType>) {} | ||
| ^ doesn't have a size known at compile-time | ||
| | ||
= help: within `Wrapper<ExternType>`, the trait `Sized` is not implemented for `ExternType`, which is required by `Wrapper<ExternType>: Sized` | ||
note: required because it appears within the type `Wrapper<ExternType>` | ||
--> $DIR/extern-parameter-issue-123887-wrapped.rs:10:8 | ||
| | ||
LL | struct Wrapper<T: ?Sized>(T); | ||
| ^^^^^^^ | ||
help: function arguments must have a statically known size, borrowed types always have a known size | ||
| | ||
LL | fn f(_: &Wrapper<ExternType>) {} | ||
| + | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// https://github.com/rust-lang/rust/issues/123887 | ||
// Do not ICE on unsized extern parameter | ||
//@ compile-flags: -Clink-dead-code --emit=link | ||
#![feature(extern_types, unsized_fn_params)] | ||
|
||
extern "C" { | ||
type ExternType; | ||
} | ||
|
||
fn f(_: ExternType) {} //~ ERROR the size for values of type `ExternType` cannot be known at compilation time | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, what happens when we monomorphize some There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another good point! I'm not hugely familiar with the monomorphization code, but have pushed a solution d98f42b. I'm not hugely comfortable with it though:
|
||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
error[E0277]: the size for values of type `ExternType` cannot be known at compilation time | ||
--> $DIR/extern-parameter-issue-123887.rs:10:6 | ||
| | ||
LL | fn f(_: ExternType) {} | ||
| ^ doesn't have a size known at compile-time | ||
| | ||
= help: the trait `Sized` is not implemented for `ExternType` | ||
help: function arguments must have a statically known size, borrowed types always have a known size | ||
| | ||
LL | fn f(_: &ExternType) {} | ||
| + | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
Uh oh!
There was an error while loading. Please reload this page.