Skip to content

extern_types associated functions aren't visible from other crates #46665

Closed
@crumblingstatue

Description

@crumblingstatue

crate foo:

#![feature(extern_types)]

extern "C" {
    pub type Foo;
}

impl Foo {
    pub fn new() -> FooBox {
        let raw = unimplemented!("Get through ffi");
        FooBox(raw)
    }
}

pub struct FooBox(*mut Foo);

impl Drop for FooBox {
    fn drop(&mut self) {
        unimplemented!("call ffi drop");
    }
}

crate foouser:

extern crate foo;

fn main() {
    let foo = foo::Foo::new();
    println!("{:p}", &foo);
}

Error:

error[E0599]: no function or associated item named `new` found for type `foo::Foo` in the current scope
 --> foouser.rs:4:15
  |
4 |     let foo = foo::Foo::new();
  |               ^^^^^^^^^^^^^ function or associated item not found in `foo::Foo`

This error does not occur if main is located within the same crate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-bugCategory: This is a bug.F-extern_types`#![feature(extern_types)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions