-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #115631 - compiler-errors:ctypes-unsized, r=davidtwco
Don't ICE when computing ctype's `repr_nullable_ptr` for possibly-unsized ty We may not always be able to compute the layout of a type like `&T` when `T: ?Sized`, even if we're able to estimate its size skeleton. r? davidtwco Fixes #115628
- Loading branch information
Showing
3 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#![deny(improper_ctypes_definitions)] | ||
|
||
extern "C" fn foo<T: ?Sized + 'static>() -> Option<&'static T> { | ||
//~^ ERROR `extern` fn uses type `Option<&T>`, which is not FFI-safe | ||
None | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
error: `extern` fn uses type `Option<&T>`, which is not FFI-safe | ||
--> $DIR/lint-ctypes-option-nonnull-unsized.rs:3:45 | ||
| | ||
LL | extern "C" fn foo<T: ?Sized + 'static>() -> Option<&'static T> { | ||
| ^^^^^^^^^^^^^^^^^^ not FFI-safe | ||
| | ||
= help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum | ||
= note: enum has no representation hint | ||
note: the lint level is defined here | ||
--> $DIR/lint-ctypes-option-nonnull-unsized.rs:1:9 | ||
| | ||
LL | #![deny(improper_ctypes_definitions)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|