-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Normalize obligations for closure confirmation
- Loading branch information
Showing
18 changed files
with
349 additions
and
79 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
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
20 changes: 0 additions & 20 deletions
20
src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-70120.stderr
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
src/test/ui/higher-rank-trait-bounds/normalize-under-binder/normalization-under-binders-1.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,30 @@ | ||
// check-pass | ||
|
||
use std::marker::PhantomData; | ||
|
||
trait A<'a> { | ||
type B; | ||
fn b(self) -> Self::B; | ||
} | ||
|
||
struct T; | ||
struct S<'a>(PhantomData<&'a ()>); | ||
|
||
impl<'a> A<'a> for T { | ||
type B = S<'a>; | ||
fn b(self) -> Self::B { | ||
S(PhantomData) | ||
} | ||
} | ||
|
||
fn s<TT, F>(t: TT, f: F) | ||
where | ||
TT: for<'a> A<'a>, | ||
F: for<'a> FnOnce(<TT as A<'a>>::B) | ||
{ | ||
f(t.b()); | ||
} | ||
|
||
fn main() { | ||
s(T, |_| {}); | ||
} |
92 changes: 92 additions & 0 deletions
92
...her-rank-trait-bounds/normalize-under-binder/normalization-under-binders-2.migrate.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,92 @@ | ||
error: implementation of `Parser` is not general enough | ||
--> $DIR/normalization-under-binders-2.rs:53:5 | ||
| | ||
LL | foo(bar, "string", |s| s.len() == 5); | ||
| ^^^ implementation of `Parser` is not general enough | ||
| | ||
= note: `for<'a> fn(&'a str) -> (&'a str, &'a str) {bar}` must implement `Parser<'0>`, for any lifetime `'0`... | ||
= note: ...but it actually implements `Parser<'1>`, for some specific lifetime `'1` | ||
|
||
error: implementation of `Parser` is not general enough | ||
--> $DIR/normalization-under-binders-2.rs:53:5 | ||
| | ||
LL | foo(bar, "string", |s| s.len() == 5); | ||
| ^^^ implementation of `Parser` is not general enough | ||
| | ||
= note: `for<'a> fn(&'a str) -> (&'a str, &'a str) {bar}` must implement `Parser<'0>`, for any lifetime `'0`... | ||
= note: ...but it actually implements `Parser<'1>`, for some specific lifetime `'1` | ||
|
||
error: implementation of `Parser` is not general enough | ||
--> $DIR/normalization-under-binders-2.rs:53:5 | ||
| | ||
LL | foo(bar, "string", |s| s.len() == 5); | ||
| ^^^ implementation of `Parser` is not general enough | ||
| | ||
= note: `for<'a> fn(&'a str) -> (&'a str, &'a str) {bar}` must implement `Parser<'0>`, for any lifetime `'0`... | ||
= note: ...but it actually implements `Parser<'1>`, for some specific lifetime `'1` | ||
|
||
error: implementation of `Parser` is not general enough | ||
--> $DIR/normalization-under-binders-2.rs:53:5 | ||
| | ||
LL | foo(bar, "string", |s| s.len() == 5); | ||
| ^^^ implementation of `Parser` is not general enough | ||
| | ||
= note: `for<'a> fn(&'a str) -> (&'a str, &'a str) {bar}` must implement `Parser<'0>`, for any lifetime `'0`... | ||
= note: ...but it actually implements `Parser<'1>`, for some specific lifetime `'1` | ||
|
||
error: implementation of `Parser` is not general enough | ||
--> $DIR/normalization-under-binders-2.rs:53:5 | ||
| | ||
LL | foo(bar, "string", |s| s.len() == 5); | ||
| ^^^ implementation of `Parser` is not general enough | ||
| | ||
= note: `for<'a> fn(&'a str) -> (&'a str, &'a str) {bar}` must implement `Parser<'0>`, for any lifetime `'0`... | ||
= note: ...but it actually implements `Parser<'1>`, for some specific lifetime `'1` | ||
|
||
error: implementation of `Parser` is not general enough | ||
--> $DIR/normalization-under-binders-2.rs:59:5 | ||
| | ||
LL | foo(baz, "string", |s| s.0.len() == 5); | ||
| ^^^ implementation of `Parser` is not general enough | ||
| | ||
= note: `for<'a> fn(&'a str) -> (&'a str, Wrapper<'a>) {baz}` must implement `Parser<'0>`, for any lifetime `'0`... | ||
= note: ...but it actually implements `Parser<'1>`, for some specific lifetime `'1` | ||
|
||
error: implementation of `Parser` is not general enough | ||
--> $DIR/normalization-under-binders-2.rs:59:5 | ||
| | ||
LL | foo(baz, "string", |s| s.0.len() == 5); | ||
| ^^^ implementation of `Parser` is not general enough | ||
| | ||
= note: `for<'a> fn(&'a str) -> (&'a str, Wrapper<'a>) {baz}` must implement `Parser<'0>`, for any lifetime `'0`... | ||
= note: ...but it actually implements `Parser<'1>`, for some specific lifetime `'1` | ||
|
||
error: implementation of `Parser` is not general enough | ||
--> $DIR/normalization-under-binders-2.rs:59:5 | ||
| | ||
LL | foo(baz, "string", |s| s.0.len() == 5); | ||
| ^^^ implementation of `Parser` is not general enough | ||
| | ||
= note: `for<'a> fn(&'a str) -> (&'a str, Wrapper<'a>) {baz}` must implement `Parser<'0>`, for any lifetime `'0`... | ||
= note: ...but it actually implements `Parser<'1>`, for some specific lifetime `'1` | ||
|
||
error: implementation of `Parser` is not general enough | ||
--> $DIR/normalization-under-binders-2.rs:59:5 | ||
| | ||
LL | foo(baz, "string", |s| s.0.len() == 5); | ||
| ^^^ implementation of `Parser` is not general enough | ||
| | ||
= note: `for<'a> fn(&'a str) -> (&'a str, Wrapper<'a>) {baz}` must implement `Parser<'0>`, for any lifetime `'0`... | ||
= note: ...but it actually implements `Parser<'1>`, for some specific lifetime `'1` | ||
|
||
error: implementation of `Parser` is not general enough | ||
--> $DIR/normalization-under-binders-2.rs:59:5 | ||
| | ||
LL | foo(baz, "string", |s| s.0.len() == 5); | ||
| ^^^ implementation of `Parser` is not general enough | ||
| | ||
= note: `for<'a> fn(&'a str) -> (&'a str, Wrapper<'a>) {baz}` must implement `Parser<'0>`, for any lifetime `'0`... | ||
= note: ...but it actually implements `Parser<'1>`, for some specific lifetime `'1` | ||
|
||
error: aborting due to 10 previous errors | ||
|
57 changes: 57 additions & 0 deletions
57
src/test/ui/higher-rank-trait-bounds/normalize-under-binder/normalization-under-binders-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,57 @@ | ||
// ignore-compare-mode-nll | ||
// fails in migrate, passes in nll | ||
|
||
trait Parser<'s> { | ||
type Output; | ||
|
||
fn call(&self, input: &'s str) -> (&'s str, Self::Output); | ||
} | ||
|
||
impl<'s, F, T> Parser<'s> for F | ||
where F: Fn(&'s str) -> (&'s str, T) { | ||
type Output = T; | ||
fn call(&self, input: &'s str) -> (&'s str, T) { | ||
self(input) | ||
} | ||
} | ||
|
||
fn foo<F1, F2>( | ||
f1: F1, | ||
base: &'static str, | ||
f2: F2 | ||
) | ||
where | ||
F1: for<'a> Parser<'a>, | ||
F2: FnOnce(&<F1 as Parser>::Output) -> bool | ||
{ | ||
let s: String = base.to_owned(); | ||
let str_ref = s.as_ref(); | ||
let (remaining, produced) = f1.call(str_ref); | ||
assert!(f2(&produced)); | ||
assert_eq!(remaining.len(), 0); | ||
} | ||
|
||
struct Wrapper<'a>(&'a str); | ||
|
||
fn main() { | ||
fn bar<'a>(s: &'a str) -> (&'a str, &'a str) { | ||
(&s[..1], &s[..]) | ||
} | ||
|
||
fn baz<'a>(s: &'a str) -> (&'a str, Wrapper<'a>) { | ||
(&s[..1], Wrapper(&s[..])) | ||
} | ||
|
||
foo(bar, "string", |s| s.len() == 5); | ||
//~^ ERROR implementation of `Parser` is not general enough | ||
//~| ERROR implementation of `Parser` is not general enough | ||
//~| ERROR implementation of `Parser` is not general enough | ||
//~| ERROR implementation of `Parser` is not general enough | ||
//~| ERROR implementation of `Parser` is not general enough | ||
foo(baz, "string", |s| s.0.len() == 5); | ||
//~^ ERROR implementation of `Parser` is not general enough | ||
//~| ERROR implementation of `Parser` is not general enough | ||
//~| ERROR implementation of `Parser` is not general enough | ||
//~| ERROR implementation of `Parser` is not general enough | ||
//~| ERROR implementation of `Parser` is not general enough | ||
} |
Oops, something went wrong.