diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-01-26 13:02:45 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-02-02 15:40:11 +0000 |
| commit | a745797142f932877695a0a3cd1b452ab67e59df (patch) | |
| tree | b457bf6116f61116d1413de2bcdfba4975fd7e04 /src/test/ui/impl-trait | |
| parent | 7bce50c01af576ca0132d9eddcd0ac85e82c9092 (diff) | |
| download | rust-a745797142f932877695a0a3cd1b452ab67e59df.tar.gz rust-a745797142f932877695a0a3cd1b452ab67e59df.zip | |
Stop generating inference vars for nested impl trait and let type equality handle it.
This means we stop supporting the case where a locally defined trait has only a single impl so we can always use that impl (see nested-tait-inference.rs).
Diffstat (limited to 'src/test/ui/impl-trait')
| -rw-r--r-- | src/test/ui/impl-trait/nested_impl_trait.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/impl-trait/nested_impl_trait.stderr | 38 |
2 files changed, 32 insertions, 8 deletions
diff --git a/src/test/ui/impl-trait/nested_impl_trait.rs b/src/test/ui/impl-trait/nested_impl_trait.rs index be2c21a7743..6eac2dece1f 100644 --- a/src/test/ui/impl-trait/nested_impl_trait.rs +++ b/src/test/ui/impl-trait/nested_impl_trait.rs @@ -4,6 +4,7 @@ fn fine(x: impl Into<u32>) -> impl Into<u32> { x } fn bad_in_ret_position(x: impl Into<u32>) -> impl Into<impl Debug> { x } //~^ ERROR nested `impl Trait` is not allowed +//~| ERROR `impl Into<u32>` doesn't implement `Debug` fn bad_in_fn_syntax(x: fn() -> impl Into<impl Debug>) {} //~^ ERROR nested `impl Trait` is not allowed @@ -16,6 +17,7 @@ struct X; impl X { fn bad(x: impl Into<u32>) -> impl Into<impl Debug> { x } //~^ ERROR nested `impl Trait` is not allowed + //~| ERROR `impl Into<u32>` doesn't implement `Debug` } fn allowed_in_assoc_type() -> impl Iterator<Item=impl Fn()> { diff --git a/src/test/ui/impl-trait/nested_impl_trait.stderr b/src/test/ui/impl-trait/nested_impl_trait.stderr index 59c7e4d5f4e..87ff4ffc4fb 100644 --- a/src/test/ui/impl-trait/nested_impl_trait.stderr +++ b/src/test/ui/impl-trait/nested_impl_trait.stderr @@ -8,7 +8,7 @@ LL | fn bad_in_ret_position(x: impl Into<u32>) -> impl Into<impl Debug> { x } | outer `impl Trait` error[E0666]: nested `impl Trait` is not allowed - --> $DIR/nested_impl_trait.rs:8:42 + --> $DIR/nested_impl_trait.rs:9:42 | LL | fn bad_in_fn_syntax(x: fn() -> impl Into<impl Debug>) {} | ----------^^^^^^^^^^- @@ -17,7 +17,7 @@ LL | fn bad_in_fn_syntax(x: fn() -> impl Into<impl Debug>) {} | outer `impl Trait` error[E0666]: nested `impl Trait` is not allowed - --> $DIR/nested_impl_trait.rs:12:37 + --> $DIR/nested_impl_trait.rs:13:37 | LL | fn bad_in_arg_position(_: impl Into<impl Debug>) { } | ----------^^^^^^^^^^- @@ -26,7 +26,7 @@ LL | fn bad_in_arg_position(_: impl Into<impl Debug>) { } | outer `impl Trait` error[E0666]: nested `impl Trait` is not allowed - --> $DIR/nested_impl_trait.rs:17:44 + --> $DIR/nested_impl_trait.rs:18:44 | LL | fn bad(x: impl Into<u32>) -> impl Into<impl Debug> { x } | ----------^^^^^^^^^^- @@ -35,18 +35,40 @@ LL | fn bad(x: impl Into<u32>) -> impl Into<impl Debug> { x } | outer `impl Trait` error[E0562]: `impl Trait` not allowed outside of function and method return types - --> $DIR/nested_impl_trait.rs:8:32 + --> $DIR/nested_impl_trait.rs:9:32 | LL | fn bad_in_fn_syntax(x: fn() -> impl Into<impl Debug>) {} | ^^^^^^^^^^^^^^^^^^^^^ error[E0562]: `impl Trait` not allowed outside of function and method return types - --> $DIR/nested_impl_trait.rs:25:42 + --> $DIR/nested_impl_trait.rs:27:42 | LL | fn allowed_in_ret_type() -> impl Fn() -> impl Into<u32> { | ^^^^^^^^^^^^^^ -error: aborting due to 6 previous errors +error[E0277]: `impl Into<u32>` doesn't implement `Debug` + --> $DIR/nested_impl_trait.rs:5:70 + | +LL | fn bad_in_ret_position(x: impl Into<u32>) -> impl Into<impl Debug> { x } + | ^ `impl Into<u32>` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | +help: consider further restricting this bound + | +LL | fn bad_in_ret_position(x: impl Into<u32> + std::fmt::Debug) -> impl Into<impl Debug> { x } + | +++++++++++++++++ + +error[E0277]: `impl Into<u32>` doesn't implement `Debug` + --> $DIR/nested_impl_trait.rs:18:58 + | +LL | fn bad(x: impl Into<u32>) -> impl Into<impl Debug> { x } + | ^ `impl Into<u32>` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | +help: consider further restricting this bound + | +LL | fn bad(x: impl Into<u32> + std::fmt::Debug) -> impl Into<impl Debug> { x } + | +++++++++++++++++ + +error: aborting due to 8 previous errors -Some errors have detailed explanations: E0562, E0666. -For more information about an error, try `rustc --explain E0562`. +Some errors have detailed explanations: E0277, E0562, E0666. +For more information about an error, try `rustc --explain E0277`. |
