-
Couldn't load subscription status.
- Fork 13.9k
Emit delayed bug during wfck for stranded opaque #148173
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
Open
tiif
wants to merge
2
commits into
rust-lang:master
Choose a base branch
from
tiif:fix-opaque-ice
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+176
−0
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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,50 @@ | ||
| //@ compile-flags: -Znext-solver | ||
| #![feature(type_alias_impl_trait)] | ||
| use std::future::Future; | ||
|
|
||
| // Test for https://github.com/rust-lang/trait-system-refactor-initiative/issues/235 | ||
|
|
||
| // These are cases where an opaque types become "stranded" due to | ||
| // some errors. Make sure we don't ICE in either case. | ||
|
|
||
| // Case 1: `impl Send` is stranded | ||
| fn foo() -> impl ?Future<Output = impl Send> { | ||
| //~^ ERROR bound modifier `?` can only be applied to `Sized` | ||
| //~| ERROR bound modifier `?` can only be applied to `Sized` | ||
| () | ||
| } | ||
|
|
||
| // Case 2: `Assoc = impl Trait` is stranded | ||
| trait Trait {} | ||
| impl Trait for i32 {} | ||
|
|
||
| fn produce() -> impl Trait<Assoc = impl Trait> { | ||
| //~^ ERROR associated type `Assoc` not found for `Trait` | ||
| //~| ERROR associated type `Assoc` not found for `Trait` | ||
| 16 | ||
| } | ||
|
|
||
tiif marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // Case 3: `impl Trait` is stranded | ||
| fn ill_formed_string() -> String<impl Trait> { | ||
| //~^ ERROR struct takes 0 generic arguments but 1 generic argument was supplied | ||
| String::from("a string") | ||
| } | ||
|
|
||
| // Case 4: TAIT variant of Case 1 to 3 | ||
| type Foo = impl ?Future<Output = impl Send>; | ||
| //~^ ERROR unconstrained opaque type | ||
| //~| ERROR unconstrained opaque type | ||
| //~| ERROR bound modifier `?` can only be applied to `Sized` | ||
| //~| ERROR bound modifier `?` can only be applied to `Sized` | ||
|
|
||
| type Produce = impl Trait<Assoc = impl Trait>; | ||
| //~^ ERROR unconstrained opaque type | ||
| //~| ERROR unconstrained opaque type | ||
| //~| ERROR associated type `Assoc` not found for `Trait` | ||
| //~| ERROR associated type `Assoc` not found for `Trait` | ||
|
|
||
| type IllFormedString = String<impl Trait>; | ||
| //~^ ERROR unconstrained opaque type | ||
| //~| ERROR struct takes 0 generic arguments but 1 generic argument was supplied | ||
|
|
||
| fn main() {} | ||
116 changes: 116 additions & 0 deletions
116
tests/ui/traits/next-solver/opaques/stranded_opaque.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,116 @@ | ||
| error: bound modifier `?` can only be applied to `Sized` | ||
| --> $DIR/stranded_opaque.rs:11:18 | ||
| | | ||
| LL | fn foo() -> impl ?Future<Output = impl Send> { | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
|
||
| error[E0220]: associated type `Assoc` not found for `Trait` | ||
| --> $DIR/stranded_opaque.rs:21:28 | ||
| | | ||
| LL | fn produce() -> impl Trait<Assoc = impl Trait> { | ||
| | ^^^^^ associated type `Assoc` not found | ||
|
|
||
| error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied | ||
| --> $DIR/stranded_opaque.rs:28:27 | ||
| | | ||
| LL | fn ill_formed_string() -> String<impl Trait> { | ||
| | ^^^^^^------------ help: remove the unnecessary generics | ||
| | | | ||
| | expected 0 generic arguments | ||
|
|
||
| error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied | ||
| --> $DIR/stranded_opaque.rs:46:25 | ||
| | | ||
| LL | type IllFormedString = String<impl Trait>; | ||
| | ^^^^^^------------ help: remove the unnecessary generics | ||
| | | | ||
| | expected 0 generic arguments | ||
|
|
||
| error: bound modifier `?` can only be applied to `Sized` | ||
| --> $DIR/stranded_opaque.rs:11:18 | ||
| | | ||
| LL | fn foo() -> impl ?Future<Output = impl Send> { | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
|
||
| error[E0220]: associated type `Assoc` not found for `Trait` | ||
| --> $DIR/stranded_opaque.rs:21:28 | ||
| | | ||
| LL | fn produce() -> impl Trait<Assoc = impl Trait> { | ||
| | ^^^^^ associated type `Assoc` not found | ||
| | | ||
| = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
|
||
| error: unconstrained opaque type | ||
| --> $DIR/stranded_opaque.rs:34:12 | ||
| | | ||
| LL | type Foo = impl ?Future<Output = impl Send>; | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| = note: `Foo` must be used in combination with a concrete type within the same crate | ||
|
|
||
| error: bound modifier `?` can only be applied to `Sized` | ||
| --> $DIR/stranded_opaque.rs:34:17 | ||
| | | ||
| LL | type Foo = impl ?Future<Output = impl Send>; | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
|
||
| error: bound modifier `?` can only be applied to `Sized` | ||
| --> $DIR/stranded_opaque.rs:34:17 | ||
| | | ||
| LL | type Foo = impl ?Future<Output = impl Send>; | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
|
||
| error: unconstrained opaque type | ||
| --> $DIR/stranded_opaque.rs:34:34 | ||
| | | ||
| LL | type Foo = impl ?Future<Output = impl Send>; | ||
| | ^^^^^^^^^ | ||
| | | ||
| = note: `Foo` must be used in combination with a concrete type within the same crate | ||
|
|
||
| error: unconstrained opaque type | ||
| --> $DIR/stranded_opaque.rs:40:17 | ||
| | | ||
| LL | type Produce = impl Trait<Assoc = impl Trait>; | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| = note: `Produce` must be used in combination with a concrete type within the same crate | ||
|
|
||
| error[E0220]: associated type `Assoc` not found for `Trait` | ||
| --> $DIR/stranded_opaque.rs:40:28 | ||
| | | ||
| LL | type Produce = impl Trait<Assoc = impl Trait>; | ||
| | ^^^^^ associated type `Assoc` not found | ||
|
|
||
| error[E0220]: associated type `Assoc` not found for `Trait` | ||
| --> $DIR/stranded_opaque.rs:40:28 | ||
| | | ||
| LL | type Produce = impl Trait<Assoc = impl Trait>; | ||
| | ^^^^^ associated type `Assoc` not found | ||
| | | ||
| = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
|
||
| error: unconstrained opaque type | ||
| --> $DIR/stranded_opaque.rs:40:36 | ||
| | | ||
| LL | type Produce = impl Trait<Assoc = impl Trait>; | ||
| | ^^^^^^^^^^ | ||
| | | ||
| = note: `Produce` must be used in combination with a concrete type within the same crate | ||
|
|
||
| error: unconstrained opaque type | ||
| --> $DIR/stranded_opaque.rs:46:32 | ||
| | | ||
| LL | type IllFormedString = String<impl Trait>; | ||
| | ^^^^^^^^^^ | ||
| | | ||
| = note: `IllFormedString` must be used in combination with a concrete type within the same crate | ||
|
|
||
| error: aborting due to 15 previous errors | ||
|
|
||
| Some errors have detailed explanations: E0107, E0220. | ||
| For more information about an error, try `rustc --explain E0107`. |
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.
Uh oh!
There was an error while loading. Please reload this page.