Skip to content

Make extern mod xxx optional #11811

Closed
Closed
@liigo

Description

@liigo

@brson suggested me open a new issue on this idea, "it seems worth exploring", he said. He don't want this to get buried in #11745 too. See comments in #11787.

The Problem

To use a crate in rust, at least two lines are required currently:

extern mod xxx;
use xxx::a::b;

In a large project, we need to use many crates, particularly after extra's dissolution (#11787). The more crates we need, the more lines extern mod xxx need to write, which is a pain:

extern mod crate1; // do we really need to write this?
extern mod crate2; 
extern mod crate3;
extern mod crate4;
......
use crate1::*; // compiler can infers "extern mod crate1" from here
use crate2::*;
use crate3::*;
use crate4::*;
......

The Solution

Since we must write lines such as use xxx::a::b, the compiler should always knows I'm using the crate xxx. So the extern mod xxx is redundant, it should be optional, unless compiler got ambiguity in non-common situations.

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