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

pub use with names that conflict with standard prelude behave incorrectly #14082

Closed
LeoTestard opened this issue May 10, 2014 · 5 comments · Fixed by #14236
Closed

pub use with names that conflict with standard prelude behave incorrectly #14082

LeoTestard opened this issue May 10, 2014 · 5 comments · Fixed by #14236
Labels
P-medium Medium priority
Milestone

Comments

@LeoTestard
Copy link
Contributor

Let's say I've got the following module architecture, where I define in a sub-module a struct named GC that I wand to use from another sub-module. Because m is private, I use a pub use to make it available

pub mod foo {
    pub use self::m::GC;

    mod m {
        pub struct GC {
            a: uint
        }
    }
}

mod bar {
    use foo::GC;
}

fn main() {
}

The error message for this is absolutely weird :

main.rs:12:9: 12:16 error: unresolved import: there is no `GC` in `foo`
main.rs:12     use foo::GC;
                   ^~~~~~~
main.rs:12:9: 12:16 error: failed to resolve import `foo::GC`
main.rs:12     use foo::GC;
                   ^~~~~~~
error: aborting due to 2 previous errors

This bugs happens whenever the item I try to re-export is named like an item in the Prelude, say, GC, Vec, etc. but as long as I change it to something completely arbitrary, say Foo, it works as expected.

I don't know if it's intended that it's impossible to "re-export" with pub use names that are already in the prelude. I suspect it's not, but even if its, the error message is really not helpful, since it only points the place where the re-export is actually used, and not the pub use itself. But it should definitively be possible to override names in the prelude, I think. It's possible with "normal" use statements, so why not pub use ?

Also, I found this bug updating an old code base that was written something like 5-6 months ago (Rust was in 0.9 back then I believe), so I'm not absolutely sure but as this code hasn't changed except the changes I made to update it, I suspect that this worked before.

@alexcrichton
Copy link
Member

Nominating, resolve bugs like this are normally nasty to fix after-the-fact.

@pnkfelix
Copy link
Member

cc me

2 similar comments
@nikomatsakis
Copy link
Contributor

cc me

@emberian
Copy link
Member

cc me

@pnkfelix
Copy link
Member

assigning P-high, 1.0

@pnkfelix pnkfelix added this to the 1.0 milestone May 15, 2014
alexcrichton added a commit to alexcrichton/rust that referenced this issue May 15, 2014
The reexport didn't switch the privacy, so the reexport was actually considered
private, erroneously failing to resolve imports later on.

Closes rust-lang#14082
bors added a commit that referenced this issue May 17, 2014
The reexport didn't switch the privacy, so the reexport was actually considered
private, erroneously failing to resolve imports later on.

Closes #14082
bors added a commit to rust-lang-ci/rust that referenced this issue Feb 13, 2023
…ykril

fix: support non-ascii characters in case conversion

Fixes rust-lang#13521 (the attribute problem is tracked in another issue, as commented)

Note that other functions like `to_camel_case()` and `is_lower_snake_case()` already handle non-ascii characters.
flip1995 pushed a commit to flip1995/rust that referenced this issue Feb 6, 2025
close rust-lang#13856

changelog: [`manual_slice_fill`]: new lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P-medium Medium priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants