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

use super as some_name is invalid #73647

Closed
surma opened this issue Jun 23, 2020 · 1 comment
Closed

use super as some_name is invalid #73647

surma opened this issue Jun 23, 2020 · 1 comment
Labels
C-bug Category: This is a bug.

Comments

@surma
Copy link

surma commented Jun 23, 2020

I tried this code (playground):

pub mod mod1 {
    pub const thing: bool = true;
    pub mod mod2 {
        use super as my_super;

        pub fn print() {
            println!("{}", my_super::thing);
        } 
    }
}

fn main() {
    mod1::mod2::print();
}

I expected to see this happen: It should compile and run.

Instead, this happened: It fails with

error[E0432]: unresolved import `super`
 --> mytest.rs:4:13
  |
4 |         use super as my_super;
  |             ^^^^^^^^^^^^^^^^^ no `super` in the root

Looking at the relevant part of the reference, it seems the above is at least grammatically correct.

I would love for this to work. However, if this is supposed to not work, a better error message would be great.

Meta

rustc --version --verbose:

rustc 1.44.1 (c7087fe00 2020-06-17)
binary: rustc
commit-hash: c7087fe00d2ba919df1d813c040a5d47e43b0fe7
commit-date: 2020-06-17
host: x86_64-unknown-linux-gnu
release: 1.44.1
LLVM version: 9.0
@surma surma added the C-bug Category: This is a bug. label Jun 23, 2020
@petrochenkov
Copy link
Contributor

Duplicate of #35612 #29036 #37156

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

3 participants