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

Visibility of inherent associated types is not checked on access #104243

Closed
fmease opened this issue Nov 10, 2022 · 1 comment · Fixed by #104348
Closed

Visibility of inherent associated types is not checked on access #104243

fmease opened this issue Nov 10, 2022 · 1 comment · Fixed by #104348
Assignees
Labels
A-associated-items Area: Associated items (types, constants & functions) A-visibility Area: Visibility / privacy C-bug Category: This is a bug. F-inherent_associated_types `#![feature(inherent_associated_types)]` requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@fmease
Copy link
Member

fmease commented Nov 10, 2022

In the following code, I can successfully refer to the private inherent associated type m::T::P:

#![feature(inherent_associated_types)]
#![allow(dead_code, incomplete_features)]

mod m {
    pub struct T;
    impl T {
        type P = ();
    }
}
type U = m::T::P;

I expected to see an error denying the access.

If the associated item was a constant, this would indeed be the case:

error[E0624]: associated constant `P` is private
  --> src/lib.rs:10:21
   |
7  |         const P: () = ();
   |         ----------- private associated constant defined here
...
10 | const U: () = m::T::P;
   |                     ^ private associated constant

Meta

rustc --version --verbose:

rustc 1.67.0-nightly (85f4f41de 2022-11-08)
binary: rustc
commit-hash: 85f4f41deb1557ca8ab228319d33003dd2f20f45
commit-date: 2022-11-08
host: x86_64-unknown-linux-gnu
release: 1.67.0-nightly
LLVM version: 15.0.4

@rustbot label T-compiler requires-nightly A-associated-items A-visibility F-inherent_associated_types

@fmease fmease added the C-bug Category: This is a bug. label Nov 10, 2022
@fmease fmease changed the title Visibility of inherent associated types is not checked when accessed Visibility of inherent associated types is not checked on access Nov 10, 2022
@rustbot rustbot added A-associated-items Area: Associated items (types, constants & functions) A-visibility Area: Visibility / privacy F-inherent_associated_types `#![feature(inherent_associated_types)]` requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 10, 2022
@fmease
Copy link
Member Author

fmease commented Nov 10, 2022

@rustbot claim

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 16, 2022
Respect visibility & stability of inherent associated types

As discussed in rust-lang#103621, this probably won't be the final location of the code that resolves inherent associated types. Still, I think it's valuable to push correctness fixes for this feature (in regards to visibility and stability).

Let me know if I should write a translatable diagnostic instead and if I should move the tests to `privacy/` and `stability-attribute/` respectively.

Fixes rust-lang#104243.
`@rustbot` label A-visibility F-inherent_associated_types
r? `@cjgillot` (since you reviewed rust-lang#103621, feel free to reroll though)
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Nov 16, 2022
Respect visibility & stability of inherent associated types

As discussed in rust-lang#103621, this probably won't be the final location of the code that resolves inherent associated types. Still, I think it's valuable to push correctness fixes for this feature (in regards to visibility and stability).

Let me know if I should write a translatable diagnostic instead and if I should move the tests to `privacy/` and `stability-attribute/` respectively.

Fixes rust-lang#104243.
``@rustbot`` label A-visibility F-inherent_associated_types
r? ``@cjgillot`` (since you reviewed rust-lang#103621, feel free to reroll though)
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 16, 2022
Respect visibility & stability of inherent associated types

As discussed in rust-lang#103621, this probably won't be the final location of the code that resolves inherent associated types. Still, I think it's valuable to push correctness fixes for this feature (in regards to visibility and stability).

Let me know if I should write a translatable diagnostic instead and if I should move the tests to `privacy/` and `stability-attribute/` respectively.

Fixes rust-lang#104243.
```@rustbot``` label A-visibility F-inherent_associated_types
r? ```@cjgillot``` (since you reviewed rust-lang#103621, feel free to reroll though)
@bors bors closed this as completed in 3a8cacd Nov 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items (types, constants & functions) A-visibility Area: Visibility / privacy C-bug Category: This is a bug. F-inherent_associated_types `#![feature(inherent_associated_types)]` requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants