-
Notifications
You must be signed in to change notification settings - Fork 13k
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
test that we do not support higher-ranked regions in opaque type inference #121386
Merged
+451
−34
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
31478cd
Add more tests
oli-obk 66bd645
test that we do not support higher-ranked regions in opaque type infe…
aliemjay 9e016a8
Avoid emitting type mismatches against `{type error}`
oli-obk e3021eb
Preserve the `Span` from `prove_predicate` all the way to registering…
oli-obk e4622e0
`report_mismatch` did not actually report anymore
oli-obk 1efb747
Remove some annotations that just specify the default
oli-obk 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 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 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 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 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 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 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 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 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,23 @@ | ||
// Regression test for #97099. | ||
// This was an ICE because `impl Sized` captures the lifetime 'a. | ||
|
||
trait Trait<E> { | ||
type Assoc; | ||
} | ||
|
||
struct Foo; | ||
|
||
impl<'a> Trait<&'a ()> for Foo { | ||
type Assoc = (); | ||
} | ||
|
||
fn foo() -> impl for<'a> Trait<&'a ()> { | ||
Foo | ||
} | ||
|
||
fn bar() -> impl for<'a> Trait<&'a (), Assoc = impl Sized> { | ||
foo() | ||
//~^ ERROR hidden type for `impl Sized` captures lifetime that does not appear in bounds | ||
} | ||
|
||
fn main() {} |
13 changes: 13 additions & 0 deletions
13
tests/ui/rfcs/impl-trait/higher-ranked-regions-diag.stderr
This file contains 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,13 @@ | ||
error[E0700]: hidden type for `impl Sized` captures lifetime that does not appear in bounds | ||
--> $DIR/higher-ranked-regions-diag.rs:19:5 | ||
| | ||
LL | fn bar() -> impl for<'a> Trait<&'a (), Assoc = impl Sized> { | ||
| -- ---------- opaque type defined here | ||
| | | ||
| hidden type `<impl for<'a> Trait<&'a ()> as Trait<&'a ()>>::Assoc` captures the lifetime `'a` as defined here | ||
LL | foo() | ||
| ^^^^^ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0700`. |
80 changes: 80 additions & 0 deletions
80
tests/ui/rfcs/type-alias-impl-trait/higher-ranked-regions-basic.rs
This file contains 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,80 @@ | ||
// Basic tests for opaque type inference under for<_> binders. | ||
|
||
#![feature(type_alias_impl_trait)] | ||
|
||
trait Trait<'a> { | ||
type Ty; | ||
} | ||
impl<'a, T> Trait<'a> for T { | ||
type Ty = &'a (); | ||
} | ||
|
||
mod basic_pass { | ||
use super::*; | ||
type Opq<'a> = impl Sized + 'a; | ||
fn test() -> impl for<'a> Trait<'a, Ty = Opq<'a>> {} | ||
//~^ ERROR: expected generic lifetime parameter, found `'a` | ||
} | ||
|
||
mod capture_rpit { | ||
use super::*; | ||
fn test() -> impl for<'a> Trait<'a, Ty = impl Sized> {} | ||
//~^ ERROR hidden type for `impl Sized` captures lifetime that does not appear in bounds | ||
} | ||
|
||
mod capture_tait { | ||
use super::*; | ||
type Opq0 = impl Sized; | ||
type Opq1<'a> = impl for<'b> Trait<'b, Ty = Opq0>; | ||
type Opq2 = impl for<'a> Trait<'a, Ty = Opq1<'a>>; | ||
fn test() -> Opq2 {} | ||
//~^ ERROR hidden type for `capture_tait::Opq0` captures lifetime that does not appear in bounds | ||
} | ||
|
||
mod capture_tait_complex_pass { | ||
use super::*; | ||
type Opq0<'a> = impl Sized; | ||
type Opq1<'a> = impl for<'b> Trait<'b, Ty = Opq0<'b>>; // <- Note 'b | ||
type Opq2 = impl for<'a> Trait<'a, Ty = Opq1<'a>>; | ||
fn test() -> Opq2 {} | ||
//~^ ERROR: expected generic lifetime parameter, found `'a` | ||
} | ||
|
||
// Same as the above, but make sure that different placeholder regions are not equal. | ||
mod capture_tait_complex_fail { | ||
use super::*; | ||
type Opq0<'a> = impl Sized; | ||
type Opq1<'a> = impl for<'b> Trait<'b, Ty = Opq0<'a>>; // <- Note 'a | ||
type Opq2 = impl for<'a> Trait<'a, Ty = Opq1<'a>>; | ||
fn test() -> Opq2 {} | ||
//~^ ERROR hidden type for `capture_tait_complex_fail::Opq0<'a>` captures lifetime that does not appear in bounds | ||
} | ||
|
||
// non-defining use because 'static is used. | ||
mod constrain_fail0 { | ||
use super::*; | ||
type Opq0<'a, 'b> = impl Sized; | ||
fn test() -> impl for<'a> Trait<'a, Ty = Opq0<'a, 'static>> {} | ||
//~^ ERROR non-defining opaque type use in defining scope | ||
//~| ERROR: expected generic lifetime parameter, found `'a` | ||
} | ||
|
||
// non-defining use because generic lifetime is used multiple times. | ||
mod constrain_fail { | ||
use super::*; | ||
type Opq0<'a, 'b> = impl Sized; | ||
fn test() -> impl for<'a> Trait<'a, Ty = Opq0<'a, 'a>> {} | ||
//~^ ERROR non-defining opaque type use in defining scope | ||
//~| ERROR: expected generic lifetime parameter, found `'a` | ||
} | ||
|
||
mod constrain_pass { | ||
use super::*; | ||
type Opq0<'a, 'b> = impl Sized; | ||
type Opq1<'a> = impl for<'b> Trait<'b, Ty = Opq0<'a, 'b>>; | ||
type Opq2 = impl for<'a> Trait<'a, Ty = Opq1<'a>>; | ||
fn test() -> Opq2 {} | ||
//~^ ERROR: expected generic lifetime parameter, found `'a` | ||
} | ||
|
||
fn main() {} |
Oops, something went wrong.
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.
vibe: rename this method to
fn build_mismatch_error
or sth? because a method calledreport
returingOk(DiagnosticsBuilder)
feels off to me