Skip to content

Strange "no extern crate" behavior on Rust 2015 #56920

Closed
@Disasm

Description

@Disasm

Assume we have rand = "0.6.1" dependency in Cargo.toml. On Rust 2015 the following example works well

fn main() {
    let _ = rand::thread_rng();
}

but the following doesn't.

use rand::thread_rng;

fn main() {
    let _ = thread_rng();
}

On Rust 2018 both examples are totally ok (as expected).
Why do we need "extern crate rand" for the second case but not for the first? Are there any reasons for such inconsistency?

% rustc --version
rustc 1.31.0 (abe02cefd 2018-12-04)

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