diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2022-06-26 13:14:56 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-26 13:14:56 +0900 |
| commit | 645e5c475a238581f6aefe53d416ddcc7aff5fb3 (patch) | |
| tree | 6b2e0f2b5ad3ae38d7c623473a63b24c945b64fe /src | |
| parent | 639a655e11306116e8507d401a1262e87e1b23b7 (diff) | |
| parent | e80ccedbaeeb5b97880d83ea95c79fc1d0dcf418 (diff) | |
| download | rust-645e5c475a238581f6aefe53d416ddcc7aff5fb3.tar.gz rust-645e5c475a238581f6aefe53d416ddcc7aff5fb3.zip | |
Rollup merge of #98371 - compiler-errors:better-opaque-printing, r=oli-obk
Fix printing `impl trait` under binders Before, we would render `impl for<'a> Trait<'a>` like `impl Trait<for<'a> 'a>`, lol.
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr | 2 | ||||
| -rw-r--r-- | src/test/ui/impl-trait/printing-binder.rs | 14 | ||||
| -rw-r--r-- | src/test/ui/impl-trait/printing-binder.stderr | 31 |
3 files changed, 46 insertions, 1 deletions
diff --git a/src/test/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr b/src/test/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr index 43b7cb8cece..e9b76b19dc4 100644 --- a/src/test/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr +++ b/src/test/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr @@ -22,7 +22,7 @@ LL | async fn baz<T>(_c: impl FnMut() -> T) where T: Future<Output=()> { LL | | LL | | } | |_^ - = note: required because it captures the following types: `ResumeTy`, `impl Future<Output = ()>`, `()` + = note: required because it captures the following types: `ResumeTy`, `impl for<'r, 's, 't0> Future<Output = ()>`, `()` note: required because it's used within this `async` block --> $DIR/issue-70935-complex-spans.rs:23:16 | diff --git a/src/test/ui/impl-trait/printing-binder.rs b/src/test/ui/impl-trait/printing-binder.rs new file mode 100644 index 00000000000..273b5dcdb09 --- /dev/null +++ b/src/test/ui/impl-trait/printing-binder.rs @@ -0,0 +1,14 @@ +trait Trait<'a> {} +impl<T> Trait<'_> for T {} +fn whatever() -> impl for<'a> Trait<'a> + for<'b> Trait<'b> {} + +fn whatever2() -> impl for<'c> Fn(&'c ()) { + |_: &()| {} +} + +fn main() { + let x: u32 = whatever(); + //~^ ERROR mismatched types + let x2: u32 = whatever2(); + //~^ ERROR mismatched types +} diff --git a/src/test/ui/impl-trait/printing-binder.stderr b/src/test/ui/impl-trait/printing-binder.stderr new file mode 100644 index 00000000000..5ffec8af102 --- /dev/null +++ b/src/test/ui/impl-trait/printing-binder.stderr @@ -0,0 +1,31 @@ +error[E0308]: mismatched types + --> $DIR/printing-binder.rs:10:18 + | +LL | fn whatever() -> impl for<'a> Trait<'a> + for<'b> Trait<'b> {} + | ------------------------------------------ the found opaque type +... +LL | let x: u32 = whatever(); + | --- ^^^^^^^^^^ expected `u32`, found opaque type + | | + | expected due to this + | + = note: expected type `u32` + found opaque type `impl for<'a> Trait<'a> + for<'b> Trait<'b>` + +error[E0308]: mismatched types + --> $DIR/printing-binder.rs:12:19 + | +LL | fn whatever2() -> impl for<'c> Fn(&'c ()) { + | ----------------------- the found opaque type +... +LL | let x2: u32 = whatever2(); + | --- ^^^^^^^^^^^ expected `u32`, found opaque type + | | + | expected due to this + | + = note: expected type `u32` + found opaque type `impl for<'c> Fn(&'c ())` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. |
