-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Don't perform selection if inherent associated types are not enabled #113286
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
Merged
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
3 changes: 3 additions & 0 deletions
3
tests/ui/associated-inherent-types/assoc-inherent-unstable.rs
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 |
---|---|---|
@@ -1,6 +1,9 @@ | ||
// aux-crate:aux=assoc-inherent-unstable.rs | ||
// edition: 2021 | ||
|
||
#![feature(inherent_associated_types)] | ||
#![allow(incomplete_features)] | ||
|
||
type Data = aux::Owner::Data; //~ ERROR use of unstable library feature 'data' | ||
|
||
fn main() {} |
2 changes: 1 addition & 1 deletion
2
tests/ui/associated-inherent-types/assoc-inherent-unstable.stderr
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
40 changes: 17 additions & 23 deletions
40
tests/ui/associated-inherent-types/bugs/cycle-iat-inside-of-adt.stderr
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 |
---|---|---|
@@ -1,49 +1,43 @@ | ||
error[E0601]: `main` function not found in crate `cycle_iat_inside_of_adt` | ||
--> $DIR/cycle-iat-inside-of-adt.rs:10:2 | ||
| | ||
LL | } | ||
| ^ consider adding a `main` function to `$DIR/cycle-iat-inside-of-adt.rs` | ||
|
||
error[E0391]: cycle detected when computing predicates of `Foo` | ||
--> $DIR/cycle-iat-inside-of-adt.rs:5:1 | ||
--> $DIR/cycle-iat-inside-of-adt.rs:7:1 | ||
| | ||
LL | struct Foo { | ||
| ^^^^^^^^^^ | ||
| | ||
note: ...which requires computing predicates of `Foo`... | ||
--> $DIR/cycle-iat-inside-of-adt.rs:5:1 | ||
--> $DIR/cycle-iat-inside-of-adt.rs:7:1 | ||
| | ||
LL | struct Foo { | ||
| ^^^^^^^^^^ | ||
note: ...which requires computing inferred outlives predicates of `Foo`... | ||
--> $DIR/cycle-iat-inside-of-adt.rs:5:1 | ||
--> $DIR/cycle-iat-inside-of-adt.rs:7:1 | ||
| | ||
LL | struct Foo { | ||
| ^^^^^^^^^^ | ||
= note: ...which requires computing the inferred outlives predicates for items in this crate... | ||
note: ...which requires computing type of `Foo::bar`... | ||
--> $DIR/cycle-iat-inside-of-adt.rs:6:5 | ||
--> $DIR/cycle-iat-inside-of-adt.rs:8:5 | ||
| | ||
LL | bar: Self::Bar, | ||
| ^^^^^^^^^^^^^^ | ||
note: ...which requires computing normalized predicates of `Foo`... | ||
--> $DIR/cycle-iat-inside-of-adt.rs:5:1 | ||
--> $DIR/cycle-iat-inside-of-adt.rs:7:1 | ||
| | ||
LL | struct Foo { | ||
| ^^^^^^^^^^ | ||
= note: ...which again requires computing predicates of `Foo`, completing the cycle | ||
note: cycle used when collecting item types in top-level module | ||
--> $DIR/cycle-iat-inside-of-adt.rs:5:1 | ||
| | ||
LL | / struct Foo { | ||
LL | | bar: Self::Bar, | ||
LL | | } | ||
LL | | impl Foo { | ||
LL | | pub type Bar = usize; | ||
LL | | } | ||
| |_^ | ||
--> $DIR/cycle-iat-inside-of-adt.rs:3:1 | ||
| | ||
LL | / #![feature(inherent_associated_types)] | ||
LL | | #![allow(incomplete_features)] | ||
LL | | // FIXME(inherent_associated_types): This should pass. | ||
LL | | | ||
... | | ||
LL | | | ||
LL | | fn main() {} | ||
| |____________^ | ||
|
||
error: aborting due to 2 previous errors | ||
error: aborting due to previous error | ||
|
||
Some errors have detailed explanations: E0391, E0601. | ||
For more information about an error, try `rustc --explain E0391`. | ||
For more information about this error, try `rustc --explain E0391`. |
17 changes: 17 additions & 0 deletions
17
tests/ui/associated-inherent-types/dont-select-if-disabled.rs
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,17 @@ | ||
// Regression test for #113265. | ||
|
||
// Don't perform selection if the feature is not enabled to prevent cycle errors | ||
// that exist due to current limitations of the implementation from masking the | ||
// feature-gate error. See the aforementioned issue. | ||
// This does lead to rustc not mentioning inherent associated types at usage-sites of | ||
// IATs that were defined in an external crate but that's acceptable for now. | ||
|
||
// FIXME(inherent_associated_types): Revisit this decision once the implementation is smarter. | ||
|
||
// The following program would currently lead to a cycle if IATs were enabled. | ||
|
||
struct S(S::P); //~ ERROR ambiguous associated type | ||
|
||
impl S { type P = (); } //~ ERROR inherent associated types are unstable | ||
|
||
fn main() {} |
24 changes: 24 additions & 0 deletions
24
tests/ui/associated-inherent-types/dont-select-if-disabled.stderr
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,24 @@ | ||
error[E0223]: ambiguous associated type | ||
--> $DIR/dont-select-if-disabled.rs:13:10 | ||
| | ||
LL | struct S(S::P); | ||
| ^^^^ | ||
| | ||
help: if there were a trait named `Example` with associated type `P` implemented for `S`, you could use the fully-qualified path | ||
| | ||
LL | struct S(<S as Example>::P); | ||
| ~~~~~~~~~~~~~~~~~ | ||
|
||
error[E0658]: inherent associated types are unstable | ||
--> $DIR/dont-select-if-disabled.rs:15:10 | ||
| | ||
LL | impl S { type P = (); } | ||
| ^^^^^^^^^^^^ | ||
| | ||
= note: see issue #8995 <https://github.com/rust-lang/rust/issues/8995> for more information | ||
= help: add `#![feature(inherent_associated_types)]` to the crate attributes to enable | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0223, E0658. | ||
For more information about an error, try `rustc --explain E0223`. |
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
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
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.
For some reason my change leads to a reordering of diagnostics. Shouldn't matter too much.