Skip to content

Commit

Permalink
[improper_ctypes] Don't suggest raw pointers when encountering trait …
Browse files Browse the repository at this point in the history
…objects

It's unhelpful since raw pointers to trait objects are also FFI-unsafe and casting to a thin raw pointer loses the vtable. There are working solutions that _involve_ raw pointers but they're too complex to explain in one line and have serious trade offs.
  • Loading branch information
Robin Kruppe committed Feb 15, 2018
1 parent 9d493c8 commit 051ea5c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
2 changes: 1 addition & 1 deletion src/librustc_lint/types.rs
Expand Up @@ -577,7 +577,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
ty::TyDynamic(..) => FfiUnsafe {
ty: ty,
reason: "trait objects have no C equivalent",
help: Some("consider using a raw pointer instead"),
help: None,
},

ty::TyStr => FfiUnsafe {
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/lint-ctypes.stderr
Expand Up @@ -78,8 +78,6 @@ error: `extern` block uses type `std::clone::Clone` which is not FFI-safe: trait
|
62 | pub fn trait_type(p: &Clone); //~ ERROR uses type `std::clone::Clone`
| ^^^^^^
|
= help: consider using a raw pointer instead

error: `extern` block uses type `(i32, i32)` which is not FFI-safe: tuples have unspecified layout
--> $DIR/lint-ctypes.rs:63:26
Expand Down

0 comments on commit 051ea5c

Please sign in to comment.