Skip to content

can reach pub items within priv mods #5129

New issue

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

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

Already on GitHub? # to your account

Closed
ben0x539 opened this issue Feb 27, 2013 · 8 comments
Closed

can reach pub items within priv mods #5129

ben0x539 opened this issue Feb 27, 2013 · 8 comments
Labels
A-resolve Area: Name/path resolution done by `rustc_resolve` specifically

Comments

@ben0x539
Copy link
Contributor

I'm not sure I entirely grok visibility rules, but the following seems to compile when I don't think it should.

priv mod foo {
    priv mod bar {
        pub fn f() {}
    }   
}   

fn main() {
    foo::bar::f();
}   
@thestinger
Copy link
Contributor

I don't think priv does anything on mod, it's just a parser flaw.

@ILyoan
Copy link
Contributor

ILyoan commented Apr 30, 2013

Still reproducible.

@toddaaro
Copy link
Contributor

toddaaro commented Jul 3, 2013

Was able to reproduce that this compiles, but also not sure if it is a bug. @pcwalton can you look at this?

@alexcrichton
Copy link
Member

Nominating for well-defined.

I think that this is another case where it'd be awesome to have resolve rules actually written down somewhere. Currently it sounds like it's still "whatever resolve does".

@graydon
Copy link
Contributor

graydon commented Aug 8, 2013

accepted for production-ready milestone

@pnkfelix
Copy link
Member

pnkfelix commented Sep 4, 2013

Sub-bug of #6143

@pnkfelix
Copy link
Member

pnkfelix commented Sep 4, 2013

Also, there is relevant short discussion on #8215 : namely, assuming we adopt the rule stated by @bblum as "pub items in a non-pub mod are visible to the rest of the crate, but not visible to users outside the crate", then the above code is not a bug, if I understand correctly.

(However, this example also demonstrates that bblum's rule is not compatible with the fifth condition listed by @alexcrichton: "Any local-crate path which goes outside the bounds of [conditions 3 and 4] will only resolve if each component of the path is pub. For example I could reach into a child's private mod's pub items, but not the child's private mod's non-pub items." Again, that's assuming I understand correctly.)

@alexcrichton
Copy link
Member

I'm closing this in favor of #8215. This specific issue would be fixed by those rules, and otherwise the validity of this code will be determined by the decision on that bug.

bors added a commit to rust-lang-ci/rust that referenced this issue May 2, 2020
Use `checked_sub` to avoid index out of bounds

(Fixes) rust-lang#4681 (possibly)

The issue likely occurs due to `lit_snip.len() < suffix.len() + 1`. You can see similar backtrace to change it to `lit_snip.len() - suffix.len() - 1000` or something then run `cargo test --release`.
But I couldn't come up with the test so I'd leave the issue open if we want.

changelog: Fix potential ICE in `misc_early`
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-resolve Area: Name/path resolution done by `rustc_resolve` specifically
Projects
None yet
Development

No branches or pull requests

7 participants