You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The associated type used in the Bar struct causes it to trigger the warning, even though the actual type FooVtable has the #[repr(C)] attribute. Using the type directly in the Baz struct works as expected so it seems that associated types don't "inherit" the attribute correctly.
Should associated types be usable in this way?
Hopefully this is just a false warning as it does seem to work correctly, but the warning is slightly worrying.
<anon>:22:38: 22:41 warning: found type without foreign-function-safe representation annotation
in foreign module, consider adding a #[repr(...)] attribute to the type, #[warn(improper_ctypes)]
on by default
<anon>:22 pub fn external_foobar(x: *const Bar);
^~~
Investigating this, seems to be caused by the following code in librustc/middle/ty.rs which classifies all associated types as (among other things) FFI unsafe. This doesn't seem correct but I don't understand it enough to try and fix it.
The associated type used in the
Bar
struct causes it to trigger the warning, even though the actual typeFooVtable
has the#[repr(C)]
attribute. Using the type directly in theBaz
struct works as expected so it seems that associated types don't "inherit" the attribute correctly.Should associated types be usable in this way?
Hopefully this is just a false warning as it does seem to work correctly, but the warning is slightly worrying.
Error:
Playground link
Tested on stable 1.0.0 and latest nightly.
The text was updated successfully, but these errors were encountered: