-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Do not use effective_visibilities query for Adt types of a local trait while proving a where-clause #145642
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
Merged
+32
−1
Merged
Do not use effective_visibilities query for Adt types of a local trait while proving a where-clause #145642
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// This test is for regression of issue #145611 | ||
// There should not be cycle error in effective_visibilities query. | ||
|
||
trait LocalTrait {} | ||
xizheyin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
struct SomeType; | ||
fn impls_trait<T: LocalTrait>() {} | ||
fn foo() -> impl Sized { | ||
impls_trait::<SomeType>(); //~ ERROR the trait bound `SomeType: LocalTrait` is not satisfied [E0277] | ||
} | ||
|
||
fn main() {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
error[E0277]: the trait bound `SomeType: LocalTrait` is not satisfied | ||
--> $DIR/trait-bound-adt-issue-145611.rs:8:19 | ||
| | ||
LL | impls_trait::<SomeType>(); | ||
| ^^^^^^^^ the trait `LocalTrait` is not implemented for `SomeType` | ||
| | ||
help: this trait has no implementations, consider adding one | ||
--> $DIR/trait-bound-adt-issue-145611.rs:4:1 | ||
| | ||
LL | trait LocalTrait {} | ||
| ^^^^^^^^^^^^^^^^ | ||
note: required by a bound in `impls_trait` | ||
--> $DIR/trait-bound-adt-issue-145611.rs:6:19 | ||
| | ||
LL | fn impls_trait<T: LocalTrait>() {} | ||
| ^^^^^^^^^^ required by this bound in `impls_trait` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay 🤔 what does the
effective_visibilities
query actually do with theeffective_visibilities
computed by by nameres? I generally feel like it should have some more comments somewhere.cc @petrochenkov maybe?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that in versions prior to #143431,
&tcx.resolutions(()).effective_visibilities
was used in this way. As for what exactly it does, I'm not quite sure. At the time, I used this API as suggested.🤔https://github.com/rust-lang/rust/pull/143431/files#diff-c712eee556d0df70dfc5c8c66c34fa13fc94a30853854f632f5dd84acfd9c973L2778
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually calculates them.
Name resolutions can only fill the "directly public" and "exported" levels, based on modules, reexports and nominal visibility.
The query uses type information and calculates the remaining "reachable" levels too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we are only checking Level::Reexported so it's ok to use the incomplete effective visibilities from name resolver.