Skip to content

improper_ctypes incorrectly warns on projections featuring opaque types #73251

Closed
@lcnr

Description

@lcnr

cc @davidtwco

#![feature(type_alias_impl_trait)]

pub trait Foo {
    type Assoc;
}

impl Foo for () {
    type Assoc = u32;
}

type Bar = impl Foo;

fn assign() -> Bar {}

extern "C" {
    pub fn lint_me() -> <Bar as Foo>::Assoc;
}

Gives the following incorrect warning:

warning: `extern` block uses type `Bar`, which is not FFI-safe
  --> src/lib.rs:16:25
   |
16 |     pub fn lint_me() -> <Bar as Foo>::Assoc;
   |                         ^^^^^^^^^^^^^^^^^^^ not FFI-safe
   |
   = note: `#[warn(improper_ctypes)]` on by default
   = note: opaque types have no C equivalent

warning: 1 warning emitted

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions