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

Remove pub from core::{unicode,cmath,stackwalk,rt} #6226

Merged
merged 1 commit into from
May 7, 2013

Conversation

alexcrichton
Copy link
Member

I just removed pub mod from core.rc and then got everything to compile again. One thing I'm worried about is an import like this:

use a;
use a::b;

mod a {
  pub type b = int;
}
mod b {
  use a;    // bad
  use a::b; // good
}

I'm not sure if use a::b being valid is a bug or intended behavior (same question about use a). If it's intended behavior, then I got around these modules not being public by only importing the specific members that are necessary. Otherwise that probably needs an open issue.

@catamorphism
Copy link
Contributor

I think use a::b shouldn't be allowed if a is private, regardless of whether b is public.

@alexcrichton
Copy link
Member Author

If you can't use anything out of a non-pub mod, then what's the point of having one?

@alexcrichton
Copy link
Member Author

cc #6199

@brson
Copy link
Contributor

brson commented May 6, 2013

@alexcrichton siblings can access items in private mods

mod a { fn foo() { } }
// I can access foo
a::foo()

@brson
Copy link
Contributor

brson commented May 6, 2013

I r+'d because I want those modules to be private, but I do think this is exploiting a resolve bug.

I think that absolute path resolution always assumes that private mods are inaccessible, even when the path is stated in a module that should have access to the path. e.g.

priv mod a { pub fn b() }
priv mod c {
    use a::b; // a is private so resolve thinks we can't access it, even though `c` is a sibling of `a`
}

Relative paths do work

priv mod a { pub fn b() }
priv mod c {
    use super::a::b;
}

imo this is bogus, and visibility should be interpreted the same way for either absolute or relative paths.

@alexcrichton
Copy link
Member Author

So just out of curiosity, let's say that there's a private module m.

  • This means that within m, all members (not sub-modules) can access any private/public member of m.
  • All child modules of m (and their children) cannot access private members of m, but they can access public members?
  • All siblings of the module m can access all the public members of m
  • Nothing else can access any member of m

Are those true? Additionally, is there a section in the manual or some documentation explaining all this? If not, I'd be willing to take a stab at writing something up (in addition to looking into the resolve bugs if they exist).

bors added a commit that referenced this pull request May 7, 2013
I just removed `pub mod` from `core.rc` and then got everything to compile again. One thing I'm worried about is an import like this:

```rust
use a;
use a::b;

mod a {
  pub type b = int;
}
mod b {
  use a;    // bad
  use a::b; // good
}
```

I'm not sure if `use a::b` being valid is a bug or intended behavior (same question about `use a`). If it's intended behavior, then I got around these modules not being public by only importing the specific members that are necessary. Otherwise that probably needs an open issue.
@bors bors closed this May 7, 2013
@bors bors merged commit 24cda9f into rust-lang:incoming May 7, 2013
@alexcrichton alexcrichton deleted the issue-6199 branch May 7, 2013 03:49
@alexcrichton
Copy link
Member Author

I opened a subsequent issue to deal with the resolve bugs (cc'd previously)

flip1995 pushed a commit to flip1995/rust that referenced this pull request Nov 3, 2020
Add lint for comparing to empty slices instead of using .is_empty()

Hey first time making a clippy lint

I added the implementation of the lint the `len_zero` since it shared a lot of the code, I would otherwise have to rewrite. Just tell me if the lint should use it's own file instead

changelog: Add lint for comparing to empty slices

Fixes rust-lang#6217
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants