Skip to content

Well formedness of types in extern functions is not checked #73253

Closed
@lcnr

Description

@lcnr

This does only error once we actually use foo.

pub trait Unsatisfied {}

#[repr(transparent)]
pub struct Foo<T: Unsatisfied>(T);

extern "C" {
    pub fn foo() -> Foo<u32>;
}

The following errors when we declare foo

pub trait Unsatisfied {}

#[repr(transparent)]
pub struct Foo<T: Unsatisfied>(T);

trait A {
    fn test() -> Foo<u32>;
    //~^ the trait bound `u32: Unsatisfied` is not satisfied
}

Extern statics are also checked:

pub trait Unsatisfied {}

#[repr(transparent)]
pub struct Foo<T: Unsatisfied>(T);

extern "C" {
    static FOO: Foo<u32>;
    //~^ the trait bound `u32: Unsatisfied` is not satisfied
}

I expected that we also check the well formedness of function declarations in extern blocks

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-type-systemArea: Type systemC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions