forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Predicate ConstraintCategory when normalizing
- Loading branch information
Showing
14 changed files
with
172 additions
and
15 deletions.
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
40 changes: 40 additions & 0 deletions
40
src/test/ui/generic-associated-types/bugs/hrtb-implied-2.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,40 @@ | ||
// check-fail | ||
// known-bug | ||
|
||
// This gives us problems because `for<'a> I::Item<'a>: Debug` should mean "for | ||
// all 'a where I::Item<'a> is WF", but really means "for all 'a possible" | ||
|
||
trait LendingIterator: Sized { | ||
type Item<'a> | ||
where | ||
Self: 'a; | ||
fn next(&mut self) -> Self::Item<'_>; | ||
} | ||
fn fails<I: LendingIterator, F>(iter: &mut I, f: F) -> bool | ||
where | ||
F: FnMut(I::Item<'_>), | ||
{ | ||
let mut iter2 = Eat(iter, f); | ||
let _next = iter2.next(); | ||
//~^ borrowed data escapes | ||
true | ||
} | ||
impl<I: LendingIterator> LendingIterator for &mut I { | ||
type Item<'a> = I::Item<'a> where Self:'a; | ||
fn next(&mut self) -> Self::Item<'_> { | ||
(**self).next() | ||
} | ||
} | ||
|
||
struct Eat<I, F>(I, F); | ||
impl<I: LendingIterator, F> Iterator for Eat<I, F> | ||
where | ||
F: FnMut(I::Item<'_>), | ||
{ | ||
type Item = (); | ||
fn next(&mut self) -> Option<Self::Item> { | ||
None | ||
} | ||
} | ||
|
||
fn main() {} |
22 changes: 22 additions & 0 deletions
22
src/test/ui/generic-associated-types/bugs/hrtb-implied-2.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,22 @@ | ||
error[E0521]: borrowed data escapes outside of function | ||
--> $DIR/hrtb-implied-2.rs:18:17 | ||
| | ||
LL | fn fails<I: LendingIterator, F>(iter: &mut I, f: F) -> bool | ||
| ---- - let's call the lifetime of this reference `'1` | ||
| | | ||
| `iter` is a reference that is only valid in the function body | ||
... | ||
LL | let _next = iter2.next(); | ||
| ^^^^^^^^^^^^ | ||
| | | ||
| `iter` escapes the function body here | ||
| argument requires that `'1` must outlive `'static` | ||
| | ||
= note: requirement occurs because of a mutable reference to `Eat<&mut I, F>` | ||
= note: mutable references are invariant over their type parameter | ||
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance | ||
= note: due to current limitations in the borrow checker, this implies a `'static` lifetime | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0521`. |
23 changes: 23 additions & 0 deletions
23
src/test/ui/generic-associated-types/bugs/hrtb-implied-3.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,23 @@ | ||
trait LendingIterator { | ||
type Item<'a> | ||
where | ||
Self: 'a; | ||
} | ||
|
||
impl LendingIterator for &str { | ||
type Item<'a> = () where Self:'a; | ||
} | ||
|
||
fn trivial_bound<I>(_: I) | ||
where | ||
I: LendingIterator, | ||
for<'a> I::Item<'a>: Sized, | ||
{ | ||
} | ||
|
||
fn fails(iter: &str) { | ||
trivial_bound(iter); | ||
//~^ borrowed data escapes | ||
} | ||
|
||
fn main() {} |
22 changes: 22 additions & 0 deletions
22
src/test/ui/generic-associated-types/bugs/hrtb-implied-3.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,22 @@ | ||
error[E0521]: borrowed data escapes outside of function | ||
--> $DIR/hrtb-implied-3.rs:19:5 | ||
| | ||
LL | fn fails(iter: &str) { | ||
| ---- - let's call the lifetime of this reference `'1` | ||
| | | ||
| `iter` is a reference that is only valid in the function body | ||
LL | trivial_bound(iter); | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| `iter` escapes the function body here | ||
| argument requires that `'1` must outlive `'static` | ||
| | ||
note: due to current limitations in the borrow checker, this implies a `'static` lifetime | ||
--> $DIR/hrtb-implied-3.rs:14:26 | ||
| | ||
LL | for<'a> I::Item<'a>: Sized, | ||
| ^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0521`. |
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