From 30ed152330637774354f6450d49bd193a1b59dcf Mon Sep 17 00:00:00 2001 From: lcnr Date: Tue, 27 Jun 2023 23:13:50 +0200 Subject: [PATCH] update tests --- .../issue-109789.stderr | 4 +- .../dyn-star/param-env-infer.current.stderr | 18 ---- tests/ui/dyn-star/param-env-infer.next.stderr | 38 ------- .../param-env-region-infer.current.stderr | 9 ++ ...env-infer.rs => param-env-region-infer.rs} | 7 +- tests/ui/for/issue-20605.next.stderr | 51 +++++++++- tests/ui/for/issue-20605.rs | 15 ++- tests/ui/issues/issue-35570.rs | 1 - tests/ui/issues/issue-35570.stderr | 12 +-- ...ions-implied-bounds-projection-gap-hr-1.rs | 1 - ...-implied-bounds-projection-gap-hr-1.stderr | 17 +--- .../traits/new-solver/alias-bound-unsound.rs | 4 +- .../new-solver/alias-bound-unsound.stderr | 30 +----- .../alias_eq_substs_eq_not_intercrate.rs | 19 ++-- .../alias_eq_substs_eq_not_intercrate.stderr | 11 +++ tests/ui/traits/new-solver/async.fail.stderr | 4 +- tests/ui/traits/new-solver/async.rs | 2 +- .../new-solver/dont-remap-tait-substs.rs | 2 +- .../new-solver/dont-remap-tait-substs.stderr | 99 +++++++++++++++++++ .../equating-projection-cyclically.rs | 12 ++- .../equating-projection-cyclically.stderr | 9 +- .../new-solver/lazy-nested-obligations-2.rs | 3 +- .../lazy-nested-obligations-2.stderr | 39 ++++++++ tests/ui/traits/new-solver/object-unsafety.rs | 10 +- .../traits/new-solver/object-unsafety.stderr | 63 +++++++++++- .../recursive-self-normalization-2.rs | 1 + .../recursive-self-normalization-2.stderr | 10 +- .../recursive-self-normalization.rs | 1 + .../recursive-self-normalization.stderr | 10 +- .../new-solver/slice-match-byte-lit.stderr | 4 +- .../new-solver/specialization-transmute.rs | 12 +-- .../specialization-transmute.stderr | 24 ++--- .../specialization-unconstrained.rs | 2 +- .../specialization-unconstrained.stderr | 11 ++- .../type-alias-impl-trait/cross_inference.rs | 4 +- 35 files changed, 367 insertions(+), 192 deletions(-) delete mode 100644 tests/ui/dyn-star/param-env-infer.current.stderr delete mode 100644 tests/ui/dyn-star/param-env-infer.next.stderr create mode 100644 tests/ui/dyn-star/param-env-region-infer.current.stderr rename tests/ui/dyn-star/{param-env-infer.rs => param-env-region-infer.rs} (64%) create mode 100644 tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.stderr create mode 100644 tests/ui/traits/new-solver/dont-remap-tait-substs.stderr create mode 100644 tests/ui/traits/new-solver/lazy-nested-obligations-2.stderr diff --git a/tests/ui/associated-inherent-types/issue-109789.stderr b/tests/ui/associated-inherent-types/issue-109789.stderr index 7af338274a1..84fc85cd09e 100644 --- a/tests/ui/associated-inherent-types/issue-109789.stderr +++ b/tests/ui/associated-inherent-types/issue-109789.stderr @@ -1,8 +1,8 @@ error[E0308]: mismatched types - --> $DIR/issue-109789.rs:18:1 + --> $DIR/issue-109789.rs:18:11 | LL | fn bar(_: Foo fn(&'a ())>::Assoc) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other | = note: expected struct `Foo` found struct `Foo fn(&'a ())>` diff --git a/tests/ui/dyn-star/param-env-infer.current.stderr b/tests/ui/dyn-star/param-env-infer.current.stderr deleted file mode 100644 index b3af7be7950..00000000000 --- a/tests/ui/dyn-star/param-env-infer.current.stderr +++ /dev/null @@ -1,18 +0,0 @@ -warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/param-env-infer.rs:5:12 - | -LL | #![feature(dyn_star, pointer_like_trait)] - | ^^^^^^^^ - | - = note: see issue #102425 for more information - = note: `#[warn(incomplete_features)]` on by default - -error[E0282]: type annotations needed - --> $DIR/param-env-infer.rs:13:10 - | -LL | t as _ - | ^ cannot infer type - -error: aborting due to previous error; 1 warning emitted - -For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/dyn-star/param-env-infer.next.stderr b/tests/ui/dyn-star/param-env-infer.next.stderr deleted file mode 100644 index 408abecc30d..00000000000 --- a/tests/ui/dyn-star/param-env-infer.next.stderr +++ /dev/null @@ -1,38 +0,0 @@ -warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/param-env-infer.rs:5:12 - | -LL | #![feature(dyn_star, pointer_like_trait)] - | ^^^^^^^^ - | - = note: see issue #102425 for more information - = note: `#[warn(incomplete_features)]` on by default - -error[E0391]: cycle detected when computing type of `make_dyn_star::{opaque#0}` - --> $DIR/param-env-infer.rs:11:60 - | -LL | fn make_dyn_star<'a, T: PointerLike + Debug + 'a>(t: T) -> impl PointerLike + Debug + 'a { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: ...which requires type-checking `make_dyn_star`... - --> $DIR/param-env-infer.rs:11:1 - | -LL | fn make_dyn_star<'a, T: PointerLike + Debug + 'a>(t: T) -> impl PointerLike + Debug + 'a { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: ...which requires computing layout of `make_dyn_star::{opaque#0}`... - = note: ...which requires normalizing `make_dyn_star::{opaque#0}`... - = note: ...which again requires computing type of `make_dyn_star::{opaque#0}`, completing the cycle -note: cycle used when checking item types in top-level module - --> $DIR/param-env-infer.rs:5:1 - | -LL | / #![feature(dyn_star, pointer_like_trait)] -LL | | -LL | | -LL | | use std::fmt::Debug; -... | -LL | | -LL | | fn main() {} - | |____________^ - -error: aborting due to previous error; 1 warning emitted - -For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/dyn-star/param-env-region-infer.current.stderr b/tests/ui/dyn-star/param-env-region-infer.current.stderr new file mode 100644 index 00000000000..c606a50c8a9 --- /dev/null +++ b/tests/ui/dyn-star/param-env-region-infer.current.stderr @@ -0,0 +1,9 @@ +error[E0282]: type annotations needed + --> $DIR/param-env-region-infer.rs:16:10 + | +LL | t as _ + | ^ cannot infer type + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/dyn-star/param-env-infer.rs b/tests/ui/dyn-star/param-env-region-infer.rs similarity index 64% rename from tests/ui/dyn-star/param-env-infer.rs rename to tests/ui/dyn-star/param-env-region-infer.rs index 1fb16d76853..9c337e4a89b 100644 --- a/tests/ui/dyn-star/param-env-infer.rs +++ b/tests/ui/dyn-star/param-env-region-infer.rs @@ -1,15 +1,18 @@ // revisions: current next //[next] compile-flags: -Ztrait-solver=next +//[next] check-pass // incremental +// checks that we don't ICE if there are region inference variables in the environment +// when computing `PointerLike` builtin candidates. + #![feature(dyn_star, pointer_like_trait)] -//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes +#![allow(incomplete_features)] use std::fmt::Debug; use std::marker::PointerLike; fn make_dyn_star<'a, T: PointerLike + Debug + 'a>(t: T) -> impl PointerLike + Debug + 'a { - //[next]~^ ERROR cycle detected when computing type of `make_dyn_star::{opaque#0}` t as _ //[current]~^ ERROR type annotations needed } diff --git a/tests/ui/for/issue-20605.next.stderr b/tests/ui/for/issue-20605.next.stderr index a96a53ca93e..d55efedfcbe 100644 --- a/tests/ui/for/issue-20605.next.stderr +++ b/tests/ui/for/issue-20605.next.stderr @@ -20,6 +20,53 @@ error: the type ` as IntoIterator>::IntoIter` is LL | for item in *things { *item = 0 } | ^^^^^^^ -error: aborting due to 3 previous errors +error[E0277]: ` as IntoIterator>::IntoIter` is not an iterator + --> $DIR/issue-20605.rs:5:17 + | +LL | for item in *things { *item = 0 } + | ^^^^^^^ ` as IntoIterator>::IntoIter` is not an iterator + | + = help: the trait `Iterator` is not implemented for ` as IntoIterator>::IntoIter` -For more information about this error, try `rustc --explain E0277`. +error: the type `&mut as IntoIterator>::IntoIter` is not well-formed + --> $DIR/issue-20605.rs:5:17 + | +LL | for item in *things { *item = 0 } + | ^^^^^^^ + +error[E0614]: type `< as IntoIterator>::IntoIter as Iterator>::Item` cannot be dereferenced + --> $DIR/issue-20605.rs:5:27 + | +LL | for item in *things { *item = 0 } + | ^^^^^ + +error[E0277]: the size for values of type `< as IntoIterator>::IntoIter as Iterator>::Item` cannot be known at compilation time + --> $DIR/issue-20605.rs:5:9 + | +LL | for item in *things { *item = 0 } + | ^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `< as IntoIterator>::IntoIter as Iterator>::Item` + = note: all local variables must have a statically known size + = help: unsized locals are gated as an unstable feature + +error: the type `Option<< as IntoIterator>::IntoIter as Iterator>::Item>` is not well-formed + --> $DIR/issue-20605.rs:5:17 + | +LL | for item in *things { *item = 0 } + | ^^^^^^^ + +error[E0277]: the size for values of type `< as IntoIterator>::IntoIter as Iterator>::Item` cannot be known at compilation time + --> $DIR/issue-20605.rs:5:5 + | +LL | for item in *things { *item = 0 } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `< as IntoIterator>::IntoIter as Iterator>::Item` +note: required by a bound in `None` + --> $SRC_DIR/core/src/option.rs:LL:COL + +error: aborting due to 9 previous errors + +Some errors have detailed explanations: E0277, E0614. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/for/issue-20605.rs b/tests/ui/for/issue-20605.rs index 64156b35705..50d4c3fddb5 100644 --- a/tests/ui/for/issue-20605.rs +++ b/tests/ui/for/issue-20605.rs @@ -3,9 +3,18 @@ fn changer<'a>(mut things: Box>) { for item in *things { *item = 0 } - //~^ ERROR the size for values of type - //[next]~^^ ERROR the type ` as IntoIterator>::IntoIter` is not well-formed - //[next]~| ERROR the trait bound `dyn Iterator: IntoIterator` is not satisfied + //[current]~^ ERROR the size for values of type + //[next]~^^ ERROR the trait bound `dyn Iterator: IntoIterator` is not satisfied + //[next]~| ERROR the size for values of type ` as IntoIterator>::IntoIter` cannot be known at compilation time + //[next]~| ERROR the type ` as IntoIterator>::IntoIter` is not well-formed + //[next]~| ERROR ` as IntoIterator>::IntoIter` is not an iterator + //[next]~| ERROR the type `&mut as IntoIterator>::IntoIter` is not well-formed + //[next]~| ERROR the size for values of type `< as IntoIterator>::IntoIter as Iterator>::Item` cannot be known at compilation time + //[next]~| ERROR the type `Option<< as IntoIterator>::IntoIter as Iterator>::Item>` is not well-formed + //[next]~| ERROR the size for values of type `< as IntoIterator>::IntoIter as Iterator>::Item` cannot be known at compilation time + //[next]~| ERROR type `< as IntoIterator>::IntoIter as Iterator>::Item` cannot be dereferenced + // FIXME(-Ztrait-solver=next): these error messages are horrible and have to be + // improved before we stabilize the new solver. } fn main() {} diff --git a/tests/ui/issues/issue-35570.rs b/tests/ui/issues/issue-35570.rs index a2b0222d4f3..42bdb423f8f 100644 --- a/tests/ui/issues/issue-35570.rs +++ b/tests/ui/issues/issue-35570.rs @@ -7,7 +7,6 @@ trait Trait2<'a> { fn _ice(param: Box Trait1<<() as Trait2<'a>>::Ty>>) { //~^ ERROR the trait bound `for<'a> (): Trait2<'a>` is not satisfied - //~| ERROR the trait bound `for<'a> (): Trait2<'a>` is not satisfied let _e: (usize, usize) = unsafe{mem::transmute(param)}; } diff --git a/tests/ui/issues/issue-35570.stderr b/tests/ui/issues/issue-35570.stderr index 3dc33729d8f..2697d46bdb2 100644 --- a/tests/ui/issues/issue-35570.stderr +++ b/tests/ui/issues/issue-35570.stderr @@ -4,16 +4,6 @@ error[E0277]: the trait bound `for<'a> (): Trait2<'a>` is not satisfied LL | fn _ice(param: Box Trait1<<() as Trait2<'a>>::Ty>>) { | ^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> Trait2<'a>` is not implemented for `()` -error[E0277]: the trait bound `for<'a> (): Trait2<'a>` is not satisfied - --> $DIR/issue-35570.rs:8:1 - | -LL | / fn _ice(param: Box Trait1<<() as Trait2<'a>>::Ty>>) { -LL | | -LL | | -LL | | let _e: (usize, usize) = unsafe{mem::transmute(param)}; -LL | | } - | |_^ the trait `for<'a> Trait2<'a>` is not implemented for `()` - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/regions/regions-implied-bounds-projection-gap-hr-1.rs b/tests/ui/regions/regions-implied-bounds-projection-gap-hr-1.rs index 1106352037a..429548f119b 100644 --- a/tests/ui/regions/regions-implied-bounds-projection-gap-hr-1.rs +++ b/tests/ui/regions/regions-implied-bounds-projection-gap-hr-1.rs @@ -20,7 +20,6 @@ trait Trait2<'a, 'b> { // do not infer that. fn callee<'x, 'y, T>(t: &'x dyn for<'z> Trait1< >::Foo >) //~^ ERROR the trait bound `for<'z> T: Trait2<'y, 'z>` is not satisfied - //~| ERROR the trait bound `for<'z> T: Trait2<'y, 'z>` is not satisfied { } diff --git a/tests/ui/regions/regions-implied-bounds-projection-gap-hr-1.stderr b/tests/ui/regions/regions-implied-bounds-projection-gap-hr-1.stderr index 3fd39810d44..6844e866532 100644 --- a/tests/ui/regions/regions-implied-bounds-projection-gap-hr-1.stderr +++ b/tests/ui/regions/regions-implied-bounds-projection-gap-hr-1.stderr @@ -9,21 +9,6 @@ help: consider restricting type parameter `T` LL | fn callee<'x, 'y, T: for<'z> Trait2<'y, 'z>>(t: &'x dyn for<'z> Trait1< >::Foo >) | ++++++++++++++++++++++++ -error[E0277]: the trait bound `for<'z> T: Trait2<'y, 'z>` is not satisfied - --> $DIR/regions-implied-bounds-projection-gap-hr-1.rs:21:1 - | -LL | / fn callee<'x, 'y, T>(t: &'x dyn for<'z> Trait1< >::Foo >) -LL | | -LL | | -LL | | { -LL | | } - | |_^ the trait `for<'z> Trait2<'y, 'z>` is not implemented for `T` - | -help: consider restricting type parameter `T` - | -LL | fn callee<'x, 'y, T: for<'z> Trait2<'y, 'z>>(t: &'x dyn for<'z> Trait1< >::Foo >) - | ++++++++++++++++++++++++ - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/new-solver/alias-bound-unsound.rs b/tests/ui/traits/new-solver/alias-bound-unsound.rs index 6b6a77e2c7e..959f1afa04e 100644 --- a/tests/ui/traits/new-solver/alias-bound-unsound.rs +++ b/tests/ui/traits/new-solver/alias-bound-unsound.rs @@ -21,9 +21,7 @@ impl Foo for () { fn main() { let x = String::from("hello, world"); drop(<() as Foo>::copy_me(&x)); - //~^ ERROR `<() as Foo>::Item: Copy` is not satisfied - //~| ERROR `<() as Foo>::Item` is not well-formed - //~| ERROR `<() as Foo>::Item` is not well-formed + //~^ ERROR the type `&<() as Foo>::Item` is not well-formed //~| ERROR `<() as Foo>::Item` is not well-formed println!("{x}"); } diff --git a/tests/ui/traits/new-solver/alias-bound-unsound.stderr b/tests/ui/traits/new-solver/alias-bound-unsound.stderr index 89abc608213..5800e2c4340 100644 --- a/tests/ui/traits/new-solver/alias-bound-unsound.stderr +++ b/tests/ui/traits/new-solver/alias-bound-unsound.stderr @@ -1,17 +1,8 @@ -error[E0277]: the trait bound `<() as Foo>::Item: Copy` is not satisfied - --> $DIR/alias-bound-unsound.rs:23:10 +error: the type `&<() as Foo>::Item` is not well-formed + --> $DIR/alias-bound-unsound.rs:23:31 | LL | drop(<() as Foo>::copy_me(&x)); - | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `<() as Foo>::Item` - | -note: required by a bound in `Foo::Item` - --> $DIR/alias-bound-unsound.rs:10:30 - | -LL | type Item: Copy - | ---- required by a bound in this associated type -LL | where -LL | ::Item: Copy; - | ^^^^ required by this bound in `Foo::Item` + | ^^ error: the type `<() as Foo>::Item` is not well-formed --> $DIR/alias-bound-unsound.rs:23:10 @@ -19,18 +10,5 @@ error: the type `<() as Foo>::Item` is not well-formed LL | drop(<() as Foo>::copy_me(&x)); | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: the type `<() as Foo>::Item` is not well-formed - --> $DIR/alias-bound-unsound.rs:23:5 - | -LL | drop(<() as Foo>::copy_me(&x)); - | ^^^^ +error: aborting due to 2 previous errors -error: the type `<() as Foo>::Item` is not well-formed - --> $DIR/alias-bound-unsound.rs:23:10 - | -LL | drop(<() as Foo>::copy_me(&x)); - | ^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.rs b/tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.rs index b036411be83..204f6e8b071 100644 --- a/tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.rs +++ b/tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.rs @@ -1,22 +1,17 @@ // compile-flags: -Ztrait-solver=next -// check-pass -// (should not pass, should be turned into a coherence-only test) - -// check that a `alias-eq(::Assoc, ::Assoc)` goal fails. - -// FIXME(deferred_projection_equality): add a test that this is true during coherence +// check that a `alias-eq(::Assoc, ::Assoc)` goal fails +// during coherence. We must not incorrectly constrain `?a` and `?b` to be +// equal. trait TraitB { type Assoc; } -fn needs_a() -> T::Assoc { - unimplemented!() -} +trait Overlaps {} -fn bar() { - let _: <_ as TraitB>::Assoc = needs_a::(); -} +impl Overlaps> for ::Assoc {} +impl Overlaps for ::Assoc {} +//~^ ERROR conflicting implementations of trait fn main() {} diff --git a/tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.stderr b/tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.stderr new file mode 100644 index 00000000000..8eda64e4490 --- /dev/null +++ b/tests/ui/traits/new-solver/alias_eq_substs_eq_not_intercrate.stderr @@ -0,0 +1,11 @@ +error[E0119]: conflicting implementations of trait `Overlaps>` for type `<_ as TraitB>::Assoc` + --> $DIR/alias_eq_substs_eq_not_intercrate.rs:14:1 + | +LL | impl Overlaps> for ::Assoc {} + | --------------------------------------------------------- first implementation here +LL | impl Overlaps for ::Assoc {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `<_ as TraitB>::Assoc` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/tests/ui/traits/new-solver/async.fail.stderr b/tests/ui/traits/new-solver/async.fail.stderr index b395c23ae00..72fa2eb3161 100644 --- a/tests/ui/traits/new-solver/async.fail.stderr +++ b/tests/ui/traits/new-solver/async.fail.stderr @@ -1,8 +1,8 @@ -error[E0271]: expected `[async block@$DIR/async.rs:12:17: 12:25]` to be a future that resolves to `i32`, but it resolves to `()` +error[E0271]: type mismatch resolving `<[async block@$DIR/async.rs:12:17: 12:25] as Future>::Output == i32` --> $DIR/async.rs:12:17 | LL | needs_async(async {}); - | ----------- ^^^^^^^^ expected `i32`, found `()` + | ----------- ^^^^^^^^ types differ | | | required by a bound introduced by this call | diff --git a/tests/ui/traits/new-solver/async.rs b/tests/ui/traits/new-solver/async.rs index 195cc35cad2..155b71eb749 100644 --- a/tests/ui/traits/new-solver/async.rs +++ b/tests/ui/traits/new-solver/async.rs @@ -10,7 +10,7 @@ fn needs_async(_: impl Future) {} #[cfg(fail)] fn main() { needs_async(async {}); - //[fail]~^ ERROR to be a future that resolves to `i32`, but it resolves to `()` + //[fail]~^ ERROR type mismatch } #[cfg(pass)] diff --git a/tests/ui/traits/new-solver/dont-remap-tait-substs.rs b/tests/ui/traits/new-solver/dont-remap-tait-substs.rs index 028222f4e6d..08c08e83076 100644 --- a/tests/ui/traits/new-solver/dont-remap-tait-substs.rs +++ b/tests/ui/traits/new-solver/dont-remap-tait-substs.rs @@ -1,5 +1,5 @@ // compile-flags: -Ztrait-solver=next -// check-pass +// known-bug: #112825 // Makes sure we don't prepopulate the MIR typeck of `define` // with `Foo = T`, but instead, `Foo = B`, so that diff --git a/tests/ui/traits/new-solver/dont-remap-tait-substs.stderr b/tests/ui/traits/new-solver/dont-remap-tait-substs.stderr new file mode 100644 index 00000000000..769eea7dfd6 --- /dev/null +++ b/tests/ui/traits/new-solver/dont-remap-tait-substs.stderr @@ -0,0 +1,99 @@ +error[E0391]: cycle detected when computing type of `Foo::{opaque#0}` + --> $DIR/dont-remap-tait-substs.rs:10:24 + | +LL | type Foo = impl NeedsSend; + | ^^^^^^^^^^^^^^^^^ + | +note: ...which requires borrow-checking `define`... + --> $DIR/dont-remap-tait-substs.rs:15:1 + | +LL | fn define(a: A, b: B) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: ...which again requires computing type of `Foo::{opaque#0}`, completing the cycle +note: cycle used when checking item types in top-level module + --> $DIR/dont-remap-tait-substs.rs:8:1 + | +LL | / #![feature(type_alias_impl_trait)] +LL | | +LL | | type Foo = impl NeedsSend; +LL | | +... | +LL | | +LL | | fn main() {} + | |____________^ + +error[E0391]: cycle detected when computing type of `Foo::{opaque#0}` + --> $DIR/dont-remap-tait-substs.rs:10:24 + | +LL | type Foo = impl NeedsSend; + | ^^^^^^^^^^^^^^^^^ + | +note: ...which requires borrow-checking `define`... + --> $DIR/dont-remap-tait-substs.rs:15:1 + | +LL | fn define(a: A, b: B) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: ...which again requires computing type of `Foo::{opaque#0}`, completing the cycle +note: cycle used when checking item types in top-level module + --> $DIR/dont-remap-tait-substs.rs:8:1 + | +LL | / #![feature(type_alias_impl_trait)] +LL | | +LL | | type Foo = impl NeedsSend; +LL | | +... | +LL | | +LL | | fn main() {} + | |____________^ + +error[E0391]: cycle detected when computing type of `Foo::{opaque#0}` + --> $DIR/dont-remap-tait-substs.rs:10:24 + | +LL | type Foo = impl NeedsSend; + | ^^^^^^^^^^^^^^^^^ + | +note: ...which requires borrow-checking `define`... + --> $DIR/dont-remap-tait-substs.rs:15:1 + | +LL | fn define(a: A, b: B) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: ...which again requires computing type of `Foo::{opaque#0}`, completing the cycle +note: cycle used when checking item types in top-level module + --> $DIR/dont-remap-tait-substs.rs:8:1 + | +LL | / #![feature(type_alias_impl_trait)] +LL | | +LL | | type Foo = impl NeedsSend; +LL | | +... | +LL | | +LL | | fn main() {} + | |____________^ + +error[E0391]: cycle detected when computing type of `Foo::{opaque#0}` + --> $DIR/dont-remap-tait-substs.rs:10:24 + | +LL | type Foo = impl NeedsSend; + | ^^^^^^^^^^^^^^^^^ + | +note: ...which requires borrow-checking `define`... + --> $DIR/dont-remap-tait-substs.rs:15:1 + | +LL | fn define(a: A, b: B) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: ...which again requires computing type of `Foo::{opaque#0}`, completing the cycle +note: cycle used when checking item types in top-level module + --> $DIR/dont-remap-tait-substs.rs:8:1 + | +LL | / #![feature(type_alias_impl_trait)] +LL | | +LL | | type Foo = impl NeedsSend; +LL | | +... | +LL | | +LL | | fn main() {} + | |____________^ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/traits/new-solver/equating-projection-cyclically.rs b/tests/ui/traits/new-solver/equating-projection-cyclically.rs index 019c6e81c50..2668da1b745 100644 --- a/tests/ui/traits/new-solver/equating-projection-cyclically.rs +++ b/tests/ui/traits/new-solver/equating-projection-cyclically.rs @@ -1,11 +1,10 @@ // compile-flags: -Ztrait-solver=next -// known-bug: unknown trait Test { type Assoc; } -fn transform(x: T) -> T::Assoc { +fn transform(x: Inv) -> Inv { todo!() } @@ -17,8 +16,13 @@ impl Test for String { type Assoc = String; } +struct Inv(Option<*mut T>); + fn main() { - let mut x = Default::default(); + let mut x: Inv<_> = Inv(None); + // This ends up equating `Inv` with `Inv<::Assoc>` + // which fails the occurs check when generalizing `?x`. x = transform(x); - x = 1i32; + //~^ ERROR mismatched types + x = Inv::(None); } diff --git a/tests/ui/traits/new-solver/equating-projection-cyclically.stderr b/tests/ui/traits/new-solver/equating-projection-cyclically.stderr index 57cbc65a17a..6031d4f08ee 100644 --- a/tests/ui/traits/new-solver/equating-projection-cyclically.stderr +++ b/tests/ui/traits/new-solver/equating-projection-cyclically.stderr @@ -1,13 +1,8 @@ error[E0308]: mismatched types - --> $DIR/equating-projection-cyclically.rs:22:19 + --> $DIR/equating-projection-cyclically.rs:25:9 | LL | x = transform(x); - | ^ expected inferred type, found associated type - | - = note: expected type `_` - found associated type `<_ as Test>::Assoc` - = help: consider constraining the associated type `<_ as Test>::Assoc` to `_` - = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html + | ^^^^^^^^^^^^ cyclic type of infinite size error: aborting due to previous error diff --git a/tests/ui/traits/new-solver/lazy-nested-obligations-2.rs b/tests/ui/traits/new-solver/lazy-nested-obligations-2.rs index 32addd829dc..fd91d81cdf0 100644 --- a/tests/ui/traits/new-solver/lazy-nested-obligations-2.rs +++ b/tests/ui/traits/new-solver/lazy-nested-obligations-2.rs @@ -1,6 +1,5 @@ -// check-pass // compile-flags: -Ztrait-solver=next -// Issue 95863 +// known-bug: #95863 pub trait With { type F; diff --git a/tests/ui/traits/new-solver/lazy-nested-obligations-2.stderr b/tests/ui/traits/new-solver/lazy-nested-obligations-2.stderr new file mode 100644 index 00000000000..d0a4cd661b3 --- /dev/null +++ b/tests/ui/traits/new-solver/lazy-nested-obligations-2.stderr @@ -0,0 +1,39 @@ +error[E0308]: mismatched types + --> $DIR/lazy-nested-obligations-2.rs:15:23 + | +LL | let _: V = V(f); + | - ^ types differ + | | + | arguments to this struct are incorrect + | + = note: expected associated type `::F` + found fn item `for<'a> fn(&'a str) {f}` + = help: consider constraining the associated type `::F` to `for<'a> fn(&'a str) {f}` or calling a method that returns `::F` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html +note: tuple struct defined here + --> $DIR/lazy-nested-obligations-2.rs:16:16 + | +LL | pub struct V(::F); + | ^ + +error[E0308]: mismatched types + --> $DIR/lazy-nested-obligations-2.rs:21:30 + | +LL | let _: E3 = E3::Var(f); + | ------- ^ types differ + | | + | arguments to this enum variant are incorrect + | + = note: expected associated type `::F` + found fn item `for<'a> fn(&'a str) {f}` + = help: consider constraining the associated type `::F` to `for<'a> fn(&'a str) {f}` or calling a method that returns `::F` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html +note: tuple variant defined here + --> $DIR/lazy-nested-obligations-2.rs:19:9 + | +LL | Var(::F), + | ^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/traits/new-solver/object-unsafety.rs b/tests/ui/traits/new-solver/object-unsafety.rs index 7bdd863a762..da843c91478 100644 --- a/tests/ui/traits/new-solver/object-unsafety.rs +++ b/tests/ui/traits/new-solver/object-unsafety.rs @@ -10,7 +10,15 @@ fn copy(from: &U::From) -> U::From { pub fn copy_any(t: &T) -> T { copy::>(t) - //~^ ERROR the trait bound `dyn Setup: Setup` is not satisfied + //~^ ERROR the type `& as Setup>::From` is not well-formed + //~| ERROR the trait bound `dyn Setup: Setup` is not satisfied + //~| ERROR mismatched types + //~| ERROR mismatched types + //~| ERROR the type ` as Setup>::From` is not well-formed + //~| ERROR the size for values of type ` as Setup>::From` cannot be known at compilation time + + // FIXME(-Ztrait-solver=next): These error messages are horrible and some of them + // are even simple fallout from previous error. } fn main() { diff --git a/tests/ui/traits/new-solver/object-unsafety.stderr b/tests/ui/traits/new-solver/object-unsafety.stderr index 198ac623df8..bb7c68b8941 100644 --- a/tests/ui/traits/new-solver/object-unsafety.stderr +++ b/tests/ui/traits/new-solver/object-unsafety.stderr @@ -14,6 +14,65 @@ help: consider introducing a `where` clause, but there might be an alternative b LL | pub fn copy_any(t: &T) -> T where dyn Setup: Setup { | ++++++++++++++++++++++++++++++++ -error: aborting due to previous error +error: the type `& as Setup>::From` is not well-formed + --> $DIR/object-unsafety.rs:12:31 + | +LL | copy::>(t) + | ^ -For more information about this error, try `rustc --explain E0277`. +error[E0308]: mismatched types + --> $DIR/object-unsafety.rs:12:31 + | +LL | copy::>(t) + | ------------------------- ^ types differ + | | + | arguments to this function are incorrect + | + = note: expected reference `& as Setup>::From` + found reference `&T` +note: function defined here + --> $DIR/object-unsafety.rs:7:4 + | +LL | fn copy(from: &U::From) -> U::From { + | ^^^^ -------------- + +error[E0308]: mismatched types + --> $DIR/object-unsafety.rs:12:5 + | +LL | pub fn copy_any(t: &T) -> T { + | - - expected `T` because of return type + | | + | this type parameter +LL | copy::>(t) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ + | + = note: expected type parameter `T` + found associated type ` as Setup>::From` + = note: you might be missing a type parameter or trait bound + +error: the type ` as Setup>::From` is not well-formed + --> $DIR/object-unsafety.rs:12:5 + | +LL | copy::>(t) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the size for values of type ` as Setup>::From` cannot be known at compilation time + --> $DIR/object-unsafety.rs:12:5 + | +LL | copy::>(t) + | ^^^^^^^^^^^^^^^^^^^^^^^^^--- + | | + | doesn't have a size known at compile-time + | this returned value is of type ` as Setup>::From` + | + = help: the trait `Sized` is not implemented for ` as Setup>::From` + = note: the return type of a function must have a statically known size +help: consider further restricting the associated type + | +LL | pub fn copy_any(t: &T) -> T where as Setup>::From: Sized { + | +++++++++++++++++++++++++++++++++++++++++++++++++ + +error: aborting due to 6 previous errors + +Some errors have detailed explanations: E0277, E0308. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/new-solver/recursive-self-normalization-2.rs b/tests/ui/traits/new-solver/recursive-self-normalization-2.rs index 8c029f5179d..d086db475ac 100644 --- a/tests/ui/traits/new-solver/recursive-self-normalization-2.rs +++ b/tests/ui/traits/new-solver/recursive-self-normalization-2.rs @@ -1,3 +1,4 @@ +//~ ERROR overflow // compile-flags: -Ztrait-solver=next trait Foo1 { diff --git a/tests/ui/traits/new-solver/recursive-self-normalization-2.stderr b/tests/ui/traits/new-solver/recursive-self-normalization-2.stderr index 139b0a45680..eebaf21d7df 100644 --- a/tests/ui/traits/new-solver/recursive-self-normalization-2.stderr +++ b/tests/ui/traits/new-solver/recursive-self-normalization-2.stderr @@ -1,16 +1,20 @@ error[E0275]: overflow evaluating the requirement `::Assoc1: Bar` - --> $DIR/recursive-self-normalization-2.rs:15:5 + --> $DIR/recursive-self-normalization-2.rs:16:5 | LL | needs_bar::(); | ^^^^^^^^^^^^^^^^^^^^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`recursive_self_normalization_2`) note: required by a bound in `needs_bar` - --> $DIR/recursive-self-normalization-2.rs:12:17 + --> $DIR/recursive-self-normalization-2.rs:13:17 | LL | fn needs_bar() {} | ^^^ required by this bound in `needs_bar` -error: aborting due to previous error +error[E0275]: overflow evaluating the requirement `::Assoc2` + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`recursive_self_normalization_2`) + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/traits/new-solver/recursive-self-normalization.rs b/tests/ui/traits/new-solver/recursive-self-normalization.rs index 06d187b5fdf..d15df7dea73 100644 --- a/tests/ui/traits/new-solver/recursive-self-normalization.rs +++ b/tests/ui/traits/new-solver/recursive-self-normalization.rs @@ -1,3 +1,4 @@ +//~ ERROR overflow evaluating the requirement `::Assoc` [E0275] // compile-flags: -Ztrait-solver=next trait Foo { diff --git a/tests/ui/traits/new-solver/recursive-self-normalization.stderr b/tests/ui/traits/new-solver/recursive-self-normalization.stderr index 8e9b9b4b4ce..6a87fe2f121 100644 --- a/tests/ui/traits/new-solver/recursive-self-normalization.stderr +++ b/tests/ui/traits/new-solver/recursive-self-normalization.stderr @@ -1,16 +1,20 @@ error[E0275]: overflow evaluating the requirement `::Assoc: Bar` - --> $DIR/recursive-self-normalization.rs:11:5 + --> $DIR/recursive-self-normalization.rs:12:5 | LL | needs_bar::(); | ^^^^^^^^^^^^^^^^^^^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`recursive_self_normalization`) note: required by a bound in `needs_bar` - --> $DIR/recursive-self-normalization.rs:8:17 + --> $DIR/recursive-self-normalization.rs:9:17 | LL | fn needs_bar() {} | ^^^ required by this bound in `needs_bar` -error: aborting due to previous error +error[E0275]: overflow evaluating the requirement `::Assoc` + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`recursive_self_normalization`) + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/traits/new-solver/slice-match-byte-lit.stderr b/tests/ui/traits/new-solver/slice-match-byte-lit.stderr index 294e8bc94be..cd48a6d1843 100644 --- a/tests/ui/traits/new-solver/slice-match-byte-lit.stderr +++ b/tests/ui/traits/new-solver/slice-match-byte-lit.stderr @@ -1,8 +1,8 @@ -error[E0271]: type mismatch resolving `[u8; 3] <: as SliceIndex<[u8]>>::Output` +error[E0271]: type mismatch resolving `[u8; 3] <: <[u8] as Index>>::Output` --> $DIR/slice-match-byte-lit.rs:6:9 | LL | match &s[0..3] { - | -------- this expression has type `& as SliceIndex<[u8]>>::Output` + | -------- this expression has type `&<[u8] as Index>>::Output` LL | b"uwu" => {} | ^^^^^^ types differ diff --git a/tests/ui/traits/new-solver/specialization-transmute.rs b/tests/ui/traits/new-solver/specialization-transmute.rs index a54701df4ef..f6b19e7adf5 100644 --- a/tests/ui/traits/new-solver/specialization-transmute.rs +++ b/tests/ui/traits/new-solver/specialization-transmute.rs @@ -10,12 +10,11 @@ trait Default { } impl Default for T { - default type Id = T; - - fn intu(&self) -> &Self::Id { + default type Id = T; + // This will be fixed by #111994 + fn intu(&self) -> &Self::Id { //~ ERROR type annotations needed self - //~^ ERROR cannot satisfy `T <: ::Id` - } + } } fn transmute, U: Copy>(t: T) -> U { @@ -24,7 +23,6 @@ fn transmute, U: Copy>(t: T) -> U { use std::num::NonZeroU8; fn main() { - let s = transmute::>(0); - //~^ ERROR cannot satisfy `::Id == Option + let s = transmute::>(0); // this call should then error assert_eq!(s, None); } diff --git a/tests/ui/traits/new-solver/specialization-transmute.stderr b/tests/ui/traits/new-solver/specialization-transmute.stderr index e67c56afc0d..09b1405fefb 100644 --- a/tests/ui/traits/new-solver/specialization-transmute.stderr +++ b/tests/ui/traits/new-solver/specialization-transmute.stderr @@ -8,24 +8,14 @@ LL | #![feature(specialization)] = help: consider using `min_specialization` instead, which is more stable and complete = note: `#[warn(incomplete_features)]` on by default -error[E0284]: type annotations needed: cannot satisfy `T <: ::Id` - --> $DIR/specialization-transmute.rs:16:9 +error[E0284]: type annotations needed + --> $DIR/specialization-transmute.rs:15:23 | -LL | self - | ^^^^ cannot satisfy `T <: ::Id` +LL | fn intu(&self) -> &Self::Id { + | ^^^^^^^^^ cannot infer type + | + = note: cannot satisfy `::Id == _` -error[E0284]: type annotations needed: cannot satisfy `::Id == Option` - --> $DIR/specialization-transmute.rs:27:13 - | -LL | let s = transmute::>(0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot satisfy `::Id == Option` - | -note: required by a bound in `transmute` - --> $DIR/specialization-transmute.rs:21:25 - | -LL | fn transmute, U: Copy>(t: T) -> U { - | ^^^^^^ required by this bound in `transmute` - -error: aborting due to 2 previous errors; 1 warning emitted +error: aborting due to previous error; 1 warning emitted For more information about this error, try `rustc --explain E0284`. diff --git a/tests/ui/traits/new-solver/specialization-unconstrained.rs b/tests/ui/traits/new-solver/specialization-unconstrained.rs index 02150689ee5..7fd753109be 100644 --- a/tests/ui/traits/new-solver/specialization-unconstrained.rs +++ b/tests/ui/traits/new-solver/specialization-unconstrained.rs @@ -11,7 +11,7 @@ trait Default { } impl Default for T { - default type Id = T; + default type Id = T; //~ ERROR type annotations needed } fn test, U>() {} diff --git a/tests/ui/traits/new-solver/specialization-unconstrained.stderr b/tests/ui/traits/new-solver/specialization-unconstrained.stderr index 910925cbaeb..9915da1a27a 100644 --- a/tests/ui/traits/new-solver/specialization-unconstrained.stderr +++ b/tests/ui/traits/new-solver/specialization-unconstrained.stderr @@ -8,6 +8,12 @@ LL | #![feature(specialization)] = help: consider using `min_specialization` instead, which is more stable and complete = note: `#[warn(incomplete_features)]` on by default +error[E0282]: type annotations needed + --> $DIR/specialization-unconstrained.rs:14:22 + | +LL | default type Id = T; + | ^ cannot infer type for associated type `::Id` + error[E0284]: type annotations needed: cannot satisfy `::Id == ()` --> $DIR/specialization-unconstrained.rs:20:5 | @@ -20,6 +26,7 @@ note: required by a bound in `test` LL | fn test, U>() {} | ^^^^^^ required by this bound in `test` -error: aborting due to previous error; 1 warning emitted +error: aborting due to 2 previous errors; 1 warning emitted -For more information about this error, try `rustc --explain E0284`. +Some errors have detailed explanations: E0282, E0284. +For more information about an error, try `rustc --explain E0282`. diff --git a/tests/ui/type-alias-impl-trait/cross_inference.rs b/tests/ui/type-alias-impl-trait/cross_inference.rs index 07f3dd1997b..5eaf0ddda99 100644 --- a/tests/ui/type-alias-impl-trait/cross_inference.rs +++ b/tests/ui/type-alias-impl-trait/cross_inference.rs @@ -5,8 +5,8 @@ #![feature(type_alias_impl_trait)] fn main() { - type T = impl Copy; - let foo: T = (1u32, 2u32); + type Tait = impl Copy; + let foo: Tait = (1u32, 2u32); let x: (_, _) = foo; println!("{:?}", x); }