Skip to content

Commit 051ea5c

Browse files
author
Robin Kruppe
committed
[improper_ctypes] Don't suggest raw pointers when encountering trait 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.
1 parent 9d493c8 commit 051ea5c

File tree

2 files changed

+1
-3
lines changed

2 files changed

+1
-3
lines changed

src/librustc_lint/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
577577
ty::TyDynamic(..) => FfiUnsafe {
578578
ty: ty,
579579
reason: "trait objects have no C equivalent",
580-
help: Some("consider using a raw pointer instead"),
580+
help: None,
581581
},
582582

583583
ty::TyStr => FfiUnsafe {

src/test/ui/lint-ctypes.stderr

-2
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ error: `extern` block uses type `std::clone::Clone` which is not FFI-safe: trait
7878
|
7979
62 | pub fn trait_type(p: &Clone); //~ ERROR uses type `std::clone::Clone`
8080
| ^^^^^^
81-
|
82-
= help: consider using a raw pointer instead
8381

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

0 commit comments

Comments
 (0)