Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should not be able to declare mod item and type item (e.g. an enum) in same scope #15205

Closed
pnkfelix opened this issue Jun 26, 2014 · 4 comments · Fixed by #15443
Closed

Should not be able to declare mod item and type item (e.g. an enum) in same scope #15205

pnkfelix opened this issue Jun 26, 2014 · 4 comments · Fixed by #15443
Labels
A-resolve Area: Path resolution
Milestone

Comments

@pnkfelix
Copy link
Member

Illustrative code provided by cmr:

mod Foo {
    pub static X: int = 42;
}

#[deriving(Show)]
enum Foo {
    X
}

fn main() {
    println!("{}", Foo::X);
    let x: Foo = X;
    println!("{}", x);
}

The above should not be legal: one should not be able to declare the mod Foo item in the same scope as the enum Foo item.

But the following playpen appears to accept it, at the moment.

@pnkfelix
Copy link
Member Author

Nominating for 1.0, P-backcompat-lang.

@pnkfelix
Copy link
Member Author

(This is relevant to rust-lang/rfcs#94 )

@pnkfelix
Copy link
Member Author

pnkfelix commented Jul 3, 2014

Assigning P-backcompat-lang, to the 1.0 milestone.

@pnkfelix pnkfelix added this to the 1.0 milestone Jul 3, 2014
pcwalton added a commit to pcwalton/rust that referenced this issue Jul 7, 2014
This will break code that looks like:

    struct Foo {
        ...
    }

    mod Foo {
        ...
    }

Change this code to:

    struct Foo {
        ...
    }

    impl Foo {
        ...
    }

Or rename the module.

Closes rust-lang#15205.

[breaking-change]
bors added a commit that referenced this issue Jul 8, 2014
…r=nick29581

This will break code that looks like:

    struct Foo {
        ...
    }

    mod Foo {
        ...
    }

Change this code to:

    struct Foo {
        ...
    }

    impl Foo {
        ...
    }

Or rename the module.

Closes #15205.

[breaking-change]

r? @nick29581
@whyisthisfieldhere
Copy link

This isn't fully fixed in 0.12:

This generates an error:

#[deriving(Show)]
mod Foo {
    pub static X: int = 42;
}
type Foo = u32;

fn main() {
    println!("{}", Foo::X);
}

While this doesn't: (all that changed is the order of type and mod)

type Foo = u32;

#[deriving(Show)]
mod Foo {
    pub static X: int = 42;
}

fn main() {
    println!("{}", Foo::X);
}

(I'm not too sure if the first example is intended to generate errors or not, but the inconsistency is definitely unexpected)

bors added a commit to rust-lang-ci/rust that referenced this issue Jul 17, 2023
Split out project loading capabilities from rust-analyzer crate

External tools currently depend on the entire lsp infra for no good reason so let's lift that out so those tools have something better to depend on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-resolve Area: Path resolution
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants