Skip to content

pub extern functions aren't considered unsafe from other crates #5844

Closed
@doy

Description

@doy
// crate.rs
#[crate_type = "lib"];

pub extern "C" {
    fn rand() -> libc::c_int;
}
// test.rs
extern mod crate;

fn main () {
    println(fmt!("%?", crate::rand()));
}

Compiling these as separate crates doesn't produce an error, but compiling them both as part of the same crate does, as does compiling a crate which uses a function from a different crate which was explicitly marked as unsafe. It seems like this should be consistent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions