mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 23:12:02 +00:00
[improper_ctypes] Point at definition of non-FFI-safe type if possible
This commit is contained in:
parent
22a171609b
commit
9d493c897b
@ -666,6 +666,11 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
||||
if let Some(s) = help {
|
||||
diag.help(s);
|
||||
}
|
||||
if let ty::TyAdt(def, _) = unsafe_ty.sty {
|
||||
if let Some(sp) = self.cx.tcx.hir.span_if_local(def.did) {
|
||||
diag.span_note(sp, "type defined here");
|
||||
}
|
||||
}
|
||||
diag.emit();
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,11 @@ note: lint level defined here
|
||||
11 | #![deny(improper_ctypes)]
|
||||
| ^^^^^^^^^^^^^^^
|
||||
= help: consider adding a #[repr(C)] or #[repr(transparent)] attribute to this struct
|
||||
note: type defined here
|
||||
--> $DIR/lint-ctypes.rs:32:1
|
||||
|
|
||||
32 | pub struct Foo;
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: `extern` block uses type `Foo` which is not FFI-safe: this struct has unspecified layout
|
||||
--> $DIR/lint-ctypes.rs:55:28
|
||||
@ -18,6 +23,11 @@ error: `extern` block uses type `Foo` which is not FFI-safe: this struct has uns
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= help: consider adding a #[repr(C)] or #[repr(transparent)] attribute to this struct
|
||||
note: type defined here
|
||||
--> $DIR/lint-ctypes.rs:32:1
|
||||
|
|
||||
32 | pub struct Foo;
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: `extern` block uses type `[u32]` which is not FFI-safe: slices have no C equivalent
|
||||
--> $DIR/lint-ctypes.rs:56:26
|
||||
@ -94,6 +104,11 @@ error: `extern` block uses type `ZeroSize` which is not FFI-safe: this struct ha
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= help: consider adding a member to this struct
|
||||
note: type defined here
|
||||
--> $DIR/lint-ctypes.rs:28:1
|
||||
|
|
||||
28 | pub struct ZeroSize;
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `extern` block uses type `ZeroSizeWithPhantomData` which is not FFI-safe: composed only of PhantomData
|
||||
--> $DIR/lint-ctypes.rs:66:33
|
||||
|
Loading…
Reference in New Issue
Block a user