diff options
Diffstat (limited to 'src')
287 files changed, 1611 insertions, 2157 deletions
| diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index d9467e8fd6b..7105a2457e2 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -147,12 +147,6 @@ fn main() { cmd.arg("-Z").arg("force-unstable-if-unmarked"); } - if let Ok(flags) = env::var("MAGIC_EXTRA_RUSTFLAGS") { - for flag in flags.split(' ') { - cmd.arg(flag); - } - } - let is_test = args.iter().any(|a| a == "--test"); if verbose > 2 { let rust_env_vars = diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 521a88f9beb..f54fb4af261 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -297,7 +297,6 @@ impl<'a> Clean<Option<WherePredicate>> for ty::Predicate<'a> { | ty::PredicateKind::ObjectSafe(..) | ty::PredicateKind::ClosureKind(..) | ty::PredicateKind::ConstEquate(..) - | ty::PredicateKind::OpaqueType(..) | ty::PredicateKind::TypeWellFormedFromEnv(..) => panic!("not user writable"), } } diff --git a/src/test/incremental/hashes/function_interfaces.rs b/src/test/incremental/hashes/function_interfaces.rs index 31564a0cbd5..4124eada188 100644 --- a/src/test/incremental/hashes/function_interfaces.rs +++ b/src/test/incremental/hashes/function_interfaces.rs @@ -305,7 +305,7 @@ pub fn return_impl_trait() -> i32 { } #[cfg(not(any(cfail1,cfail4)))] -#[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, typeck, fn_sig, optimized_mir")] +#[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, typeck, fn_sig")] #[rustc_clean(cfg = "cfail3")] #[rustc_clean(cfg = "cfail5", except = "hir_owner, hir_owner_nodes, typeck, fn_sig, optimized_mir")] #[rustc_clean(cfg = "cfail6")] diff --git a/src/test/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.rs b/src/test/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.rs index 67b97c21805..4c36289f47b 100644 --- a/src/test/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.rs +++ b/src/test/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.rs @@ -30,7 +30,7 @@ impl Thing for AssocNoCopy { type Out = Box<dyn Bar<Assoc: Copy>>; fn func() -> Self::Out { - Box::new(AssocNoCopy) //~^ ERROR the trait bound `String: Copy` is not satisfied + Box::new(AssocNoCopy) } } diff --git a/src/test/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.stderr b/src/test/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.stderr index f1dcd34066d..a32ab453152 100644 --- a/src/test/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.stderr +++ b/src/test/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.stderr @@ -1,10 +1,8 @@ error[E0277]: the trait bound `String: Copy` is not satisfied - --> $DIR/assoc-type-eq-with-dyn-atb-fail.rs:33:9 + --> $DIR/assoc-type-eq-with-dyn-atb-fail.rs:32:18 | -LL | Box::new(AssocNoCopy) - | ^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` - | - = note: required for the cast to the object type `dyn Bar<Assoc = <AssocNoCopy as Thing>::Out::{opaque#0}>` +LL | fn func() -> Self::Out { + | ^^^^^^^^^ the trait `Copy` is not implemented for `String` error: aborting due to previous error diff --git a/src/test/ui/associated-types/impl-trait-return-missing-constraint.rs b/src/test/ui/associated-types/impl-trait-return-missing-constraint.rs index 30e4c1a3c53..5f994f26534 100644 --- a/src/test/ui/associated-types/impl-trait-return-missing-constraint.rs +++ b/src/test/ui/associated-types/impl-trait-return-missing-constraint.rs @@ -23,8 +23,8 @@ fn bar() -> impl Bar { } fn baz() -> impl Bar<Item = i32> { +//~^ ERROR type mismatch resolving `<impl Bar as Foo>::Item == i32` bar() - //~^ ERROR type mismatch resolving `<impl Bar as Foo>::Item == i32` } fn main() { diff --git a/src/test/ui/associated-types/impl-trait-return-missing-constraint.stderr b/src/test/ui/associated-types/impl-trait-return-missing-constraint.stderr index 9523a54d954..283ecea735d 100644 --- a/src/test/ui/associated-types/impl-trait-return-missing-constraint.stderr +++ b/src/test/ui/associated-types/impl-trait-return-missing-constraint.stderr @@ -1,16 +1,14 @@ error[E0271]: type mismatch resolving `<impl Bar as Foo>::Item == i32` - --> $DIR/impl-trait-return-missing-constraint.rs:26:5 + --> $DIR/impl-trait-return-missing-constraint.rs:25:13 | LL | fn bar() -> impl Bar { - | -------- the expected opaque type + | -------- the found opaque type ... -LL | bar() - | ^^^^^ expected associated type, found `i32` +LL | fn baz() -> impl Bar<Item = i32> { + | ^^^^^^^^^^^^^^^^^^^^ expected `i32`, found associated type | - = note: expected associated type `<impl Bar as Foo>::Item` - found type `i32` - = help: consider constraining the associated type `<impl Bar as Foo>::Item` to `i32` or calling a method that returns `<impl Bar as Foo>::Item` - = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html + = note: expected type `i32` + found associated type `<impl Bar as Foo>::Item` help: consider constraining the associated type `<impl Bar as Foo>::Item` to `i32` | LL | fn bar() -> impl Bar<Item = i32> { diff --git a/src/test/ui/async-await/async-borrowck-escaping-block-error.stderr b/src/test/ui/async-await/async-borrowck-escaping-block-error.stderr index f21c8115124..44d60c1d80d 100644 --- a/src/test/ui/async-await/async-borrowck-escaping-block-error.stderr +++ b/src/test/ui/async-await/async-borrowck-escaping-block-error.stderr @@ -8,10 +8,10 @@ LL | Box::new(async { x } ) | may outlive borrowed value `x` | note: async block is returned here - --> $DIR/async-borrowck-escaping-block-error.rs:6:5 + --> $DIR/async-borrowck-escaping-block-error.rs:4:20 | -LL | Box::new(async { x } ) - | ^^^^^^^^^^^^^^^^^^^^^^ +LL | fn test_boxed() -> Box<impl std::future::Future<Output = u32>> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: to force the async block to take ownership of `x` (and any other referenced variables), use the `move` keyword | LL | Box::new(async move { x } ) diff --git a/src/test/ui/async-await/issue-64130-4-async-move.rs b/src/test/ui/async-await/issue-64130-4-async-move.rs index 7cb02e5cf38..2538f34351e 100644 --- a/src/test/ui/async-await/issue-64130-4-async-move.rs +++ b/src/test/ui/async-await/issue-64130-4-async-move.rs @@ -13,9 +13,9 @@ impl Client { async fn get() { } pub fn foo() -> impl Future + Send { + //~^ ERROR future cannot be sent between threads safely let client = Client(Box::new(true)); async move { - //~^ ERROR future cannot be sent between threads safely match client.status() { 200 => { let _x = get().await; diff --git a/src/test/ui/async-await/issue-64130-4-async-move.stderr b/src/test/ui/async-await/issue-64130-4-async-move.stderr index 3a84907e0c0..d631e6dc7f7 100644 --- a/src/test/ui/async-await/issue-64130-4-async-move.stderr +++ b/src/test/ui/async-await/issue-64130-4-async-move.stderr @@ -1,8 +1,8 @@ error: future cannot be sent between threads safely - --> $DIR/issue-64130-4-async-move.rs:17:5 + --> $DIR/issue-64130-4-async-move.rs:15:17 | -LL | async move { - | ^^^^^^^^^^ future created by async block is not `Send` +LL | pub fn foo() -> impl Future + Send { + | ^^^^^^^^^^^^^^^^^^ future created by async block is not `Send` | = help: the trait `Sync` is not implemented for `(dyn Any + Send + 'static)` note: future is not `Send` as this value is used across an await diff --git a/src/test/ui/async-await/issue-70818.rs b/src/test/ui/async-await/issue-70818.rs index 631389e10f3..0609e4fc081 100644 --- a/src/test/ui/async-await/issue-70818.rs +++ b/src/test/ui/async-await/issue-70818.rs @@ -2,8 +2,8 @@ use std::future::Future; fn foo<T: Send, U>(ty: T, ty1: U) -> impl Future<Output = (T, U)> + Send { +//~^ Error future cannot be sent between threads safely async { (ty, ty1) } - //~^ Error future cannot be sent between threads safely } fn main() {} diff --git a/src/test/ui/async-await/issue-70818.stderr b/src/test/ui/async-await/issue-70818.stderr index cb50c70f998..20109d4d116 100644 --- a/src/test/ui/async-await/issue-70818.stderr +++ b/src/test/ui/async-await/issue-70818.stderr @@ -1,11 +1,11 @@ error: future cannot be sent between threads safely - --> $DIR/issue-70818.rs:5:5 + --> $DIR/issue-70818.rs:4:38 | -LL | async { (ty, ty1) } - | ^^^^^ future created by async block is not `Send` +LL | fn foo<T: Send, U>(ty: T, ty1: U) -> impl Future<Output = (T, U)> + Send { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future created by async block is not `Send` | note: captured value is not `Send` - --> $DIR/issue-70818.rs:5:18 + --> $DIR/issue-70818.rs:6:18 | LL | async { (ty, ty1) } | ^^^ has type `U` which is not `Send` diff --git a/src/test/ui/async-await/issue-70935-complex-spans.rs b/src/test/ui/async-await/issue-70935-complex-spans.rs index 49456122951..2965a7e0654 100644 --- a/src/test/ui/async-await/issue-70935-complex-spans.rs +++ b/src/test/ui/async-await/issue-70935-complex-spans.rs @@ -8,8 +8,8 @@ async fn baz<T>(_c: impl FnMut() -> T) where T: Future<Output=()> { } fn foo(tx: std::sync::mpsc::Sender<i32>) -> impl Future + Send { + //~^ ERROR: future cannot be sent between threads safely async move { - //~^ ERROR: future cannot be sent between threads safely baz(|| async{ foo(tx.clone()); }).await; diff --git a/src/test/ui/async-await/issue-70935-complex-spans.stderr b/src/test/ui/async-await/issue-70935-complex-spans.stderr index ad61f21741b..db309938119 100644 --- a/src/test/ui/async-await/issue-70935-complex-spans.stderr +++ b/src/test/ui/async-await/issue-70935-complex-spans.stderr @@ -1,8 +1,8 @@ error: future cannot be sent between threads safely - --> $DIR/issue-70935-complex-spans.rs:11:5 + --> $DIR/issue-70935-complex-spans.rs:10:45 | -LL | async move { - | ^^^^^^^^^^ future created by async block is not `Send` +LL | fn foo(tx: std::sync::mpsc::Sender<i32>) -> impl Future + Send { + | ^^^^^^^^^^^^^^^^^^ future created by async block is not `Send` | = help: the trait `Sync` is not implemented for `Sender<i32>` note: future is not `Send` as this value is used across an await diff --git a/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.nll.stderr b/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.nll.stderr index cdb141c0e3e..2722c72c20a 100644 --- a/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.nll.stderr +++ b/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.nll.stderr @@ -14,16 +14,12 @@ LL | | } = help: consider adding the following bound: `'a: 'b` error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/ret-impl-trait-one.rs:16:80 + --> $DIR/ret-impl-trait-one.rs:16:65 | -LL | async fn async_ret_impl_trait1<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> { - | ____________________________________--__________________________________________^ - | | | - | | hidden type `(&'a u8, &'b u8)` captures the lifetime `'b` as defined here -LL | | -LL | | (a, b) -LL | | } - | |_^ +LL | async fn async_ret_impl_trait1<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> { + | -- ^^^^^^^^^^^^^^ + | | + | hidden type `(&'a u8, &'b u8)` captures the lifetime `'b` as defined here | help: to declare that the `impl Trait` captures `'b`, you can add an explicit `'b` lifetime bound | diff --git a/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.stderr b/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.stderr index 2eb3a07059f..149692a2c69 100644 --- a/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.stderr +++ b/src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.stderr @@ -1,26 +1,19 @@ error[E0623]: lifetime mismatch - --> $DIR/ret-impl-trait-one.rs:10:85 + --> $DIR/ret-impl-trait-one.rs:10:65 | -LL | async fn async_ret_impl_trait3<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> + 'b { - | ______________________________________________________------_____-------------------_^ - | | | - | | this parameter and the return type are declared with different lifetimes... -LL | | -LL | | (a, b) -LL | | } - | |_^ ...but data from `a` is returned here +LL | async fn async_ret_impl_trait3<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> + 'b { + | ------ ^^^^^^^^^^^^^^^^^^^ + | | | + | | ...but data from `a` is returned here + | this parameter and the return type are declared with different lifetimes... error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/ret-impl-trait-one.rs:16:80 + --> $DIR/ret-impl-trait-one.rs:16:65 | -LL | async fn async_ret_impl_trait1<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> { - | ____________________________________--__________________________________________^ - | | | - | | hidden type `(&'a u8, &'b u8)` captures the lifetime `'b` as defined here -LL | | -LL | | (a, b) -LL | | } - | |_^ +LL | async fn async_ret_impl_trait1<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> { + | -- ^^^^^^^^^^^^^^ + | | + | hidden type `(&'a u8, &'b u8)` captures the lifetime `'b` as defined here | help: to declare that the `impl Trait` captures `'b`, you can add an explicit `'b` lifetime bound | diff --git a/src/test/ui/async-await/no-const-async.rs b/src/test/ui/async-await/no-const-async.rs index cfb0ef1b33a..b3c59734e03 100644 --- a/src/test/ui/async-await/no-const-async.rs +++ b/src/test/ui/async-await/no-const-async.rs @@ -3,4 +3,3 @@ pub const async fn x() {} //~^ ERROR functions cannot be both `const` and `async` -//~| ERROR cycle detected diff --git a/src/test/ui/async-await/no-const-async.stderr b/src/test/ui/async-await/no-const-async.stderr index fd76c282f96..90ec646c8c0 100644 --- a/src/test/ui/async-await/no-const-async.stderr +++ b/src/test/ui/async-await/no-const-async.stderr @@ -7,36 +7,5 @@ LL | pub const async fn x() {} | | `async` because of this | `const` because of this -error[E0391]: cycle detected when computing type of `x::{opaque#0}` - --> $DIR/no-const-async.rs:4:24 - | -LL | pub const async fn x() {} - | ^ - | -note: ...which requires borrow-checking `x`... - --> $DIR/no-const-async.rs:4:1 - | -LL | pub const async fn x() {} - | ^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires processing `x`... - --> $DIR/no-const-async.rs:4:1 - | -LL | pub const async fn x() {} - | ^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires const checking `x`... - --> $DIR/no-const-async.rs:4:1 - | -LL | pub const async fn x() {} - | ^^^^^^^^^^^^^^^^^^^^^^ - = note: ...which requires computing whether `impl core::future::future::Future<Output = ()>` is freeze... - = note: ...which requires evaluating trait selection obligation `impl core::future::future::Future<Output = ()>: core::marker::Freeze`... - = note: ...which again requires computing type of `x::{opaque#0}`, completing the cycle -note: cycle used when checking item types in top-level module - --> $DIR/no-const-async.rs:4:1 - | -LL | pub const async fn x() {} - | ^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors +error: aborting due to previous error -For more information about this error, try `rustc --explain E0391`. diff --git a/src/test/ui/async-await/recursive-async-impl-trait-type.rs b/src/test/ui/async-await/recursive-async-impl-trait-type.rs index edc4cb8ac5d..aa773319458 100644 --- a/src/test/ui/async-await/recursive-async-impl-trait-type.rs +++ b/src/test/ui/async-await/recursive-async-impl-trait-type.rs @@ -2,8 +2,7 @@ // Test that impl trait does not allow creating recursive types that are // otherwise forbidden when using `async` and `await`. -async fn recursive_async_function() -> () { - //~^ ERROR recursion in an `async fn` requires boxing +async fn recursive_async_function() -> () { //~ ERROR recursive_async_function().await; } diff --git a/src/test/ui/async-await/suggest-missing-await.rs b/src/test/ui/async-await/suggest-missing-await.rs index 046f1dfea32..c7c5b51e733 100644 --- a/src/test/ui/async-await/suggest-missing-await.rs +++ b/src/test/ui/async-await/suggest-missing-await.rs @@ -21,6 +21,7 @@ async fn dummy() {} async fn suggest_await_in_async_fn_return() { dummy() //~^ ERROR mismatched types [E0308] + //~| HELP consider using a semicolon here //~| HELP consider `await`ing on the `Future` //~| SUGGESTION .await } diff --git a/src/test/ui/async-await/suggest-missing-await.stderr b/src/test/ui/async-await/suggest-missing-await.stderr index a60571dc11d..3cca9616a35 100644 --- a/src/test/ui/async-await/suggest-missing-await.stderr +++ b/src/test/ui/async-await/suggest-missing-await.stderr @@ -33,9 +33,13 @@ help: consider `await`ing on the `Future` | LL | dummy().await | ++++++ +help: consider using a semicolon here + | +LL | dummy(); + | + error[E0308]: `if` and `else` have incompatible types - --> $DIR/suggest-missing-await.rs:34:9 + --> $DIR/suggest-missing-await.rs:35:9 | LL | let _x = if true { | ______________- @@ -49,20 +53,15 @@ LL | | LL | | }; | |_____- `if` and `else` have incompatible types | -note: while checking the return type of the `async fn` - --> $DIR/suggest-missing-await.rs:18:18 - | -LL | async fn dummy() {} - | ^ checked the `Output` of this `async fn`, expected opaque type - = note: expected opaque type `impl Future<Output = ()>` - found unit type `()` + = note: expected type `impl Future<Output = ()>` + found unit type `()` help: consider `await`ing on the `Future` | LL | dummy().await | ++++++ error[E0308]: `match` arms have incompatible types - --> $DIR/suggest-missing-await.rs:44:14 + --> $DIR/suggest-missing-await.rs:45:14 | LL | let _x = match 0usize { | ______________- @@ -90,7 +89,7 @@ LL ~ 1 => dummy().await, | error[E0308]: mismatched types - --> $DIR/suggest-missing-await.rs:52:9 + --> $DIR/suggest-missing-await.rs:53:9 | LL | () => {} | ^^ expected opaque type, found `()` @@ -108,13 +107,13 @@ LL | let _x = match dummy().await { | ++++++ error[E0308]: mismatched types - --> $DIR/suggest-missing-await.rs:66:9 + --> $DIR/suggest-missing-await.rs:67:9 | LL | Ok(_) => {} | ^^^^^ expected opaque type, found enum `Result` | note: while checking the return type of the `async fn` - --> $DIR/suggest-missing-await.rs:56:28 + --> $DIR/suggest-missing-await.rs:57:28 | LL | async fn dummy_result() -> Result<(), ()> { | ^^^^^^^^^^^^^^ checked the `Output` of this `async fn`, expected opaque type @@ -126,13 +125,13 @@ LL | match dummy_result().await { | ++++++ error[E0308]: mismatched types - --> $DIR/suggest-missing-await.rs:68:9 + --> $DIR/suggest-missing-await.rs:69:9 | LL | Err(_) => {} | ^^^^^^ expected opaque type, found enum `Result` | note: while checking the return type of the `async fn` - --> $DIR/suggest-missing-await.rs:56:28 + --> $DIR/suggest-missing-await.rs:57:28 | LL | async fn dummy_result() -> Result<(), ()> { | ^^^^^^^^^^^^^^ checked the `Output` of this `async fn`, expected opaque type diff --git a/src/test/ui/cast/casts-differing-anon.rs b/src/test/ui/cast/casts-differing-anon.rs index ccf41adce6b..d4a0f961305 100644 --- a/src/test/ui/cast/casts-differing-anon.rs +++ b/src/test/ui/cast/casts-differing-anon.rs @@ -18,5 +18,5 @@ fn main() { // this is an `*mut fmt::Debug` in practice let mut b_raw = Box::into_raw(b); // ... and they should not be mixable - b_raw = f_raw as *mut _; //~ ERROR mismatched types + b_raw = f_raw as *mut _; //~ ERROR is invalid } diff --git a/src/test/ui/cast/casts-differing-anon.stderr b/src/test/ui/cast/casts-differing-anon.stderr index 2d08903c5ef..f9abfb5225f 100644 --- a/src/test/ui/cast/casts-differing-anon.stderr +++ b/src/test/ui/cast/casts-differing-anon.stderr @@ -1,19 +1,11 @@ -error[E0308]: mismatched types +error[E0606]: casting `*mut impl Debug + ?Sized` as `*mut impl Debug + ?Sized` is invalid --> $DIR/casts-differing-anon.rs:21:13 | -LL | fn foo() -> Box<impl fmt::Debug+?Sized> { - | ---------------------- the found opaque type -... -LL | fn bar() -> Box<impl fmt::Debug+?Sized> { - | ---------------------- the expected opaque type -... LL | b_raw = f_raw as *mut _; - | ^^^^^ expected opaque type, found a different opaque type + | ^^^^^^^^^^^^^^^ | - = note: expected opaque type `impl Debug + ?Sized` (opaque type at <$DIR/casts-differing-anon.rs:7:17>) - found opaque type `impl Debug + ?Sized` (opaque type at <$DIR/casts-differing-anon.rs:3:17>) - = note: distinct uses of `impl Trait` result in different opaque types + = note: vtable kinds may not match error: aborting due to previous error -For more information about this error, try `rustc --explain E0308`. +For more information about this error, try `rustc --explain E0606`. diff --git a/src/test/ui/closures/2229_closure_analysis/diagnostics/borrowck/borrowck-4.stderr b/src/test/ui/closures/2229_closure_analysis/diagnostics/borrowck/borrowck-4.stderr index 46379a3815a..bb00465758a 100644 --- a/src/test/ui/closures/2229_closure_analysis/diagnostics/borrowck/borrowck-4.stderr +++ b/src/test/ui/closures/2229_closure_analysis/diagnostics/borrowck/borrowck-4.stderr @@ -8,10 +8,10 @@ LL | println!("{:?}", p); | - `p` is borrowed here | note: closure is returned here - --> $DIR/borrowck-4.rs:15:5 + --> $DIR/borrowck-4.rs:8:14 | -LL | c - | ^ +LL | fn foo () -> impl FnMut()->() { + | ^^^^^^^^^^^^^^^^ help: to force the closure to take ownership of `p` (and any other referenced variables), use the `move` keyword | LL | let mut c = move || { diff --git a/src/test/ui/conservative_impl_trait.stderr b/src/test/ui/conservative_impl_trait.stderr index 9dc486980aa..63a4df242f8 100644 --- a/src/test/ui/conservative_impl_trait.stderr +++ b/src/test/ui/conservative_impl_trait.stderr @@ -1,11 +1,8 @@ error[E0277]: `()` is not an iterator - --> $DIR/conservative_impl_trait.rs:3:60 + --> $DIR/conservative_impl_trait.rs:3:33 | -LL | fn will_ice(something: &u32) -> impl Iterator<Item = &u32> { - | ____________________________________________________________^ -LL | | -LL | | } - | |_^ `()` is not an iterator +LL | fn will_ice(something: &u32) -> impl Iterator<Item = &u32> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not an iterator | = help: the trait `Iterator` is not implemented for `()` diff --git a/src/test/ui/const-generics/defaults/rp_impl_trait_fail.rs b/src/test/ui/const-generics/defaults/rp_impl_trait_fail.rs index b3bd88ad7d5..308c121a941 100644 --- a/src/test/ui/const-generics/defaults/rp_impl_trait_fail.rs +++ b/src/test/ui/const-generics/defaults/rp_impl_trait_fail.rs @@ -4,8 +4,8 @@ trait Trait {} impl<const N: u32> Trait for Uwu<N> {} fn rawr() -> impl Trait { - Uwu::<10, 12> //~^ error: the trait bound `Uwu<10_u32, 12_u32>: Trait` is not satisfied + Uwu::<10, 12> } trait Traitor<const N: u8 = 1, const M: u8 = N> { } @@ -15,13 +15,13 @@ impl Traitor<1, 2> for u64 {} fn uwu<const N: u8>() -> impl Traitor<N> { - 1_u32 //~^ error: the trait bound `u32: Traitor<N, N>` is not satisfied + 1_u32 } fn owo() -> impl Traitor { - 1_u64 //~^ error: the trait bound `u64: Traitor<1_u8, 1_u8>` is not satisfied + 1_u64 } fn main() { diff --git a/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr b/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr index ec23952114c..8c8bfdc0e48 100644 --- a/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr +++ b/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr @@ -1,26 +1,26 @@ error[E0277]: the trait bound `Uwu<10_u32, 12_u32>: Trait` is not satisfied - --> $DIR/rp_impl_trait_fail.rs:7:5 + --> $DIR/rp_impl_trait_fail.rs:6:14 | -LL | Uwu::<10, 12> - | ^^^^^^^^^^^^^ the trait `Trait` is not implemented for `Uwu<10_u32, 12_u32>` +LL | fn rawr() -> impl Trait { + | ^^^^^^^^^^ the trait `Trait` is not implemented for `Uwu<10_u32, 12_u32>` | = help: the following implementations were found: <Uwu<N> as Trait> error[E0277]: the trait bound `u32: Traitor<N, N>` is not satisfied - --> $DIR/rp_impl_trait_fail.rs:18:5 + --> $DIR/rp_impl_trait_fail.rs:17:26 | -LL | 1_u32 - | ^^^^^ the trait `Traitor<N, N>` is not implemented for `u32` +LL | fn uwu<const N: u8>() -> impl Traitor<N> { + | ^^^^^^^^^^^^^^^ the trait `Traitor<N, N>` is not implemented for `u32` | = help: the following implementations were found: <u32 as Traitor<N, 2_u8>> error[E0277]: the trait bound `u64: Traitor<1_u8, 1_u8>` is not satisfied - --> $DIR/rp_impl_trait_fail.rs:23:5 + --> $DIR/rp_impl_trait_fail.rs:22:13 | -LL | 1_u64 - | ^^^^^ the trait `Traitor<1_u8, 1_u8>` is not implemented for `u64` +LL | fn owo() -> impl Traitor { + | ^^^^^^^^^^^^ the trait `Traitor<1_u8, 1_u8>` is not implemented for `u64` | = help: the following implementations were found: <u64 as Traitor<1_u8, 2_u8>> diff --git a/src/test/ui/entry-point/imported_main_const_fn_item_type_forbidden.rs b/src/test/ui/entry-point/imported_main_const_fn_item_type_forbidden.rs index eab5a6190ef..e0bb7dbfae9 100644 --- a/src/test/ui/entry-point/imported_main_const_fn_item_type_forbidden.rs +++ b/src/test/ui/entry-point/imported_main_const_fn_item_type_forbidden.rs @@ -4,9 +4,11 @@ //~^^^ ERROR `main` function not found in crate pub mod foo { type MainFn = impl Fn(); + //~^ ERROR could not find defining uses fn bar() {} pub const BAR: MainFn = bar; + //~^ ERROR mismatched types [E0308] } use foo::BAR as main; diff --git a/src/test/ui/entry-point/imported_main_const_fn_item_type_forbidden.stderr b/src/test/ui/entry-point/imported_main_const_fn_item_type_forbidden.stderr index 83a189e01e0..c731c328322 100644 --- a/src/test/ui/entry-point/imported_main_const_fn_item_type_forbidden.stderr +++ b/src/test/ui/entry-point/imported_main_const_fn_item_type_forbidden.stderr @@ -12,6 +12,25 @@ LL | | use foo::BAR as main; | | | non-function item at `crate::main` is found -error: aborting due to previous error +error[E0308]: mismatched types + --> $DIR/imported_main_const_fn_item_type_forbidden.rs:10:29 + | +LL | type MainFn = impl Fn(); + | --------- the expected opaque type +... +LL | pub const BAR: MainFn = bar; + | ^^^ expected opaque type, found fn item + | + = note: expected opaque type `impl Fn()` + found fn item `fn() {bar}` + +error: could not find defining uses + --> $DIR/imported_main_const_fn_item_type_forbidden.rs:6:19 + | +LL | type MainFn = impl Fn(); + | ^^^^^^^^^ + +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0601`. +Some errors have detailed explanations: E0308, E0601. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.rs b/src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.rs index 6dfd7f6840f..ea82837d4bf 100644 --- a/src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.rs +++ b/src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.rs @@ -1,13 +1,13 @@ // ignore-compare-mode-chalk -// check-pass #![feature(type_alias_impl_trait)] use std::fmt::Debug; type Foo = impl Debug; +//~^ ERROR could not find defining uses struct Bar(Foo); fn define() -> Bar { - Bar(42) + Bar(42) //~ ERROR mismatched types } type Foo2 = impl Debug; @@ -17,18 +17,21 @@ fn define2() { } type Foo3 = impl Debug; +//~^ ERROR could not find defining uses fn define3(x: Foo3) { - let y: i32 = x; + let y: i32 = x; //~ ERROR mismatched types } fn define3_1() { - define3(42) + define3(42) //~ ERROR mismatched types } type Foo4 = impl Debug; +//~^ ERROR could not find defining uses fn define4() { let y: Foo4 = 42; + //~^ ERROR mismatched types [E0308] } fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.stderr b/src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.stderr new file mode 100644 index 00000000000..da3ddb1c509 --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.stderr @@ -0,0 +1,73 @@ +error[E0308]: mismatched types + --> $DIR/feature-gate-type_alias_impl_trait.rs:10:9 + | +LL | type Foo = impl Debug; + | ---------- the expected opaque type +... +LL | Bar(42) + | ^^ expected opaque type, found integer + | + = note: expected opaque type `impl Debug` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/feature-gate-type_alias_impl_trait.rs:23:18 + | +LL | type Foo3 = impl Debug; + | ---------- the found opaque type +... +LL | let y: i32 = x; + | --- ^ expected `i32`, found opaque type + | | + | expected due to this + | + = note: expected type `i32` + found opaque type `impl Debug` + +error[E0308]: mismatched types + --> $DIR/feature-gate-type_alias_impl_trait.rs:26:13 + | +LL | type Foo3 = impl Debug; + | ---------- the expected opaque type +... +LL | define3(42) + | ^^ expected opaque type, found integer + | + = note: expected opaque type `impl Debug` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/feature-gate-type_alias_impl_trait.rs:33:19 + | +LL | type Foo4 = impl Debug; + | ---------- the expected opaque type +... +LL | let y: Foo4 = 42; + | ---- ^^ expected opaque type, found integer + | | + | expected due to this + | + = note: expected opaque type `impl Debug` + found type `{integer}` + +error: could not find defining uses + --> $DIR/feature-gate-type_alias_impl_trait.rs:5:12 + | +LL | type Foo = impl Debug; + | ^^^^^^^^^^ + +error: could not find defining uses + --> $DIR/feature-gate-type_alias_impl_trait.rs:19:13 + | +LL | type Foo3 = impl Debug; + | ^^^^^^^^^^ + +error: could not find defining uses + --> $DIR/feature-gate-type_alias_impl_trait.rs:29:13 + | +LL | type Foo4 = impl Debug; + | ^^^^^^^^^^ + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/generator/issue-88653.rs b/src/test/ui/generator/issue-88653.rs index c4905995a86..ce9159b53e0 100644 --- a/src/test/ui/generator/issue-88653.rs +++ b/src/test/ui/generator/issue-88653.rs @@ -6,10 +6,10 @@ use std::ops::Generator; fn foo(bar: bool) -> impl Generator<(bool,)> { +//~^ ERROR: type mismatch in generator arguments [E0631] +//~| NOTE: expected signature of `fn((bool,)) -> _` |bar| { //~^ NOTE: found signature of `fn(bool) -> _` - //~| ERROR: type mismatch in generator arguments [E0631] - //~| NOTE: expected signature of `fn((bool,)) -> _` if bar { yield bar; } diff --git a/src/test/ui/generator/issue-88653.stderr b/src/test/ui/generator/issue-88653.stderr index eaa90a8e60a..5bd8ad129fe 100644 --- a/src/test/ui/generator/issue-88653.stderr +++ b/src/test/ui/generator/issue-88653.stderr @@ -1,11 +1,11 @@ error[E0631]: type mismatch in generator arguments - --> $DIR/issue-88653.rs:9:5 + --> $DIR/issue-88653.rs:8:22 | +LL | fn foo(bar: bool) -> impl Generator<(bool,)> { + | ^^^^^^^^^^^^^^^^^^^^^^^ expected signature of `fn((bool,)) -> _` +... LL | |bar| { - | ^^^^^ - | | - | expected signature of `fn((bool,)) -> _` - | found signature of `fn(bool) -> _` + | ----- found signature of `fn(bool) -> _` error: aborting due to previous error diff --git a/src/test/ui/generator/type-mismatch-signature-deduction.rs b/src/test/ui/generator/type-mismatch-signature-deduction.rs index d1b16b6e10d..7774ff48f56 100644 --- a/src/test/ui/generator/type-mismatch-signature-deduction.rs +++ b/src/test/ui/generator/type-mismatch-signature-deduction.rs @@ -2,8 +2,8 @@ use std::ops::Generator; -fn foo() -> impl Generator<Return = i32> { - || { //~ ERROR type mismatch +fn foo() -> impl Generator<Return = i32> { //~ ERROR type mismatch + || { if false { return Ok(6); } diff --git a/src/test/ui/generator/type-mismatch-signature-deduction.stderr b/src/test/ui/generator/type-mismatch-signature-deduction.stderr index 3e78e5b53ba..3f1f33a3b12 100644 --- a/src/test/ui/generator/type-mismatch-signature-deduction.stderr +++ b/src/test/ui/generator/type-mismatch-signature-deduction.stderr @@ -13,19 +13,13 @@ LL | return Ok(6); | ^^^^^ error[E0271]: type mismatch resolving `<[generator@$DIR/type-mismatch-signature-deduction.rs:6:5: 14:6] as Generator>::Return == i32` - --> $DIR/type-mismatch-signature-deduction.rs:6:5 + --> $DIR/type-mismatch-signature-deduction.rs:5:13 | -LL | / || { -LL | | if false { -LL | | return Ok(6); -LL | | } -... | -LL | | 5 -LL | | } - | |_____^ expected enum `Result`, found `i32` +LL | fn foo() -> impl Generator<Return = i32> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found enum `Result` | - = note: expected enum `Result<{integer}, _>` - found type `i32` + = note: expected type `i32` + found enum `Result<{integer}, _>` error: aborting due to 2 previous errors diff --git a/src/test/ui/generic-associated-types/issue-87258_a.rs b/src/test/ui/generic-associated-types/issue-87258_a.rs index c65f3fb2aa0..d9d17751fa6 100644 --- a/src/test/ui/generic-associated-types/issue-87258_a.rs +++ b/src/test/ui/generic-associated-types/issue-87258_a.rs @@ -16,8 +16,7 @@ pub trait Trait2 { impl<'c, S: Trait2> Trait2 for &'c mut S { type FooFuture<'a> = impl Trait1; - //~^ ERROR unconstrained opaque type - fn foo<'a>() -> Self::FooFuture<'a> { + fn foo<'a>() -> Self::FooFuture<'a> { //~ ERROR Struct(unimplemented!()) } } diff --git a/src/test/ui/generic-associated-types/issue-87258_a.stderr b/src/test/ui/generic-associated-types/issue-87258_a.stderr index db3a5c819cb..93513a4563f 100644 --- a/src/test/ui/generic-associated-types/issue-87258_a.stderr +++ b/src/test/ui/generic-associated-types/issue-87258_a.stderr @@ -1,10 +1,11 @@ -error: unconstrained opaque type - --> $DIR/issue-87258_a.rs:18:26 +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/issue-87258_a.rs:19:21 | -LL | type FooFuture<'a> = impl Trait1; - | ^^^^^^^^^^^ +LL | fn foo<'a>() -> Self::FooFuture<'a> { + | ^^^^^^^^^^^^^^^^^^^ | - = note: `FooFuture` must be used in combination with a concrete type within the same module + = note: hidden type `Struct<'_>` captures lifetime '_#7r error: aborting due to previous error +For more information about this error, try `rustc --explain E0700`. diff --git a/src/test/ui/generic-associated-types/issue-87258_b.rs b/src/test/ui/generic-associated-types/issue-87258_b.rs index f59e0d76659..b29a978f517 100644 --- a/src/test/ui/generic-associated-types/issue-87258_b.rs +++ b/src/test/ui/generic-associated-types/issue-87258_b.rs @@ -15,11 +15,10 @@ pub trait Trait2 { } type Helper<'xenon, 'yttrium, KABOOM: Trait2> = impl Trait1; -//~^ ERROR unconstrained opaque type impl<'c, S: Trait2> Trait2 for &'c mut S { type FooFuture<'a> = Helper<'c, 'a, S>; - fn foo<'a>() -> Self::FooFuture<'a> { + fn foo<'a>() -> Self::FooFuture<'a> { //~ ERROR Struct(unimplemented!()) } } diff --git a/src/test/ui/generic-associated-types/issue-87258_b.stderr b/src/test/ui/generic-associated-types/issue-87258_b.stderr index 9faccc96124..e077a423400 100644 --- a/src/test/ui/generic-associated-types/issue-87258_b.stderr +++ b/src/test/ui/generic-associated-types/issue-87258_b.stderr @@ -1,10 +1,11 @@ -error: unconstrained opaque type - --> $DIR/issue-87258_b.rs:17:49 +error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds + --> $DIR/issue-87258_b.rs:21:21 | -LL | type Helper<'xenon, 'yttrium, KABOOM: Trait2> = impl Trait1; - | ^^^^^^^^^^^ +LL | fn foo<'a>() -> Self::FooFuture<'a> { + | ^^^^^^^^^^^^^^^^^^^ | - = note: `Helper` must be used in combination with a concrete type within the same module + = note: hidden type `Struct<'_>` captures lifetime '_#7r error: aborting due to previous error +For more information about this error, try `rustc --explain E0700`. diff --git a/src/test/ui/generic-associated-types/issue-88595.rs b/src/test/ui/generic-associated-types/issue-88595.rs index ea1bd2be452..e397390783f 100644 --- a/src/test/ui/generic-associated-types/issue-88595.rs +++ b/src/test/ui/generic-associated-types/issue-88595.rs @@ -18,6 +18,7 @@ struct C; impl<'a> A<'a> for C { type B<'b> = impl Clone; //~^ ERROR: lifetime bound not satisfied + //~| ERROR: could not find defining uses fn a(&'a self) -> Self::B<'a> {} //~ ERROR: non-defining opaque type use in defining scope } diff --git a/src/test/ui/generic-associated-types/issue-88595.stderr b/src/test/ui/generic-associated-types/issue-88595.stderr index e1d55fa228c..cb462871ccd 100644 --- a/src/test/ui/generic-associated-types/issue-88595.stderr +++ b/src/test/ui/generic-associated-types/issue-88595.stderr @@ -16,10 +16,10 @@ LL | type B<'b> = impl Clone; | ^^ error: non-defining opaque type use in defining scope - --> $DIR/issue-88595.rs:22:35 + --> $DIR/issue-88595.rs:23:23 | LL | fn a(&'a self) -> Self::B<'a> {} - | ^^ + | ^^^^^^^^^^^ | note: lifetime used multiple times --> $DIR/issue-88595.rs:18:6 @@ -29,6 +29,12 @@ LL | impl<'a> A<'a> for C { LL | type B<'b> = impl Clone; | ^^ -error: aborting due to 2 previous errors +error: could not find defining uses + --> $DIR/issue-88595.rs:19:18 + | +LL | type B<'b> = impl Clone; + | ^^^^^^^^^^ + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0478`. diff --git a/src/test/ui/generic-associated-types/issue-92096.migrate.stderr b/src/test/ui/generic-associated-types/issue-92096.migrate.stderr index f8c89829e16..72ade5774d7 100644 --- a/src/test/ui/generic-associated-types/issue-92096.migrate.stderr +++ b/src/test/ui/generic-associated-types/issue-92096.migrate.stderr @@ -1,20 +1,18 @@ error[E0311]: the parameter type `C` may not live long enough - --> $DIR/issue-92096.rs:24:5 + --> $DIR/issue-92096.rs:20:33 | LL | fn call_connect<C>(c: &'_ C) -> impl '_ + Future + Send - | - help: consider adding an explicit lifetime bound...: `C: 'a` -... -LL | async move { c.connect().await } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `C` will meet its required lifetime bounds + | - ^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `C` will meet its required lifetime bounds + | | + | help: consider adding an explicit lifetime bound...: `C: 'a` error[E0311]: the parameter type `C` may not live long enough - --> $DIR/issue-92096.rs:24:5 + --> $DIR/issue-92096.rs:20:33 | LL | fn call_connect<C>(c: &'_ C) -> impl '_ + Future + Send - | - help: consider adding an explicit lifetime bound...: `C: 'a` -... -LL | async move { c.connect().await } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `C` will meet its required lifetime bounds + | - ^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `C` will meet its required lifetime bounds + | | + | help: consider adding an explicit lifetime bound...: `C: 'a` error: aborting due to 2 previous errors diff --git a/src/test/ui/generic-associated-types/issue-92096.rs b/src/test/ui/generic-associated-types/issue-92096.rs index 2bc1af5506f..066132a5d98 100644 --- a/src/test/ui/generic-associated-types/issue-92096.rs +++ b/src/test/ui/generic-associated-types/issue-92096.rs @@ -18,12 +18,12 @@ trait Client { } fn call_connect<C>(c: &'_ C) -> impl '_ + Future + Send +//[migrate]~^ ERROR the parameter +//[migrate]~| ERROR the parameter where C: Client + Send + Sync, { async move { c.connect().await } - //[migrate]~^ ERROR the parameter - //[migrate]~| ERROR the parameter } fn main() {} diff --git a/src/test/ui/impl-trait/auto-trait-leak.rs b/src/test/ui/impl-trait/auto-trait-leak.rs index d2452abab02..c2fbbf94fd6 100644 --- a/src/test/ui/impl-trait/auto-trait-leak.rs +++ b/src/test/ui/impl-trait/auto-trait-leak.rs @@ -11,7 +11,6 @@ fn main() { // return type, which can't depend on the obligation. fn cycle1() -> impl Clone { //~^ ERROR cycle detected - //~| ERROR cycle detected send(cycle2().clone()); Rc::new(Cell::new(5)) diff --git a/src/test/ui/impl-trait/auto-trait-leak.stderr b/src/test/ui/impl-trait/auto-trait-leak.stderr index 14db864f1c2..634ff14869e 100644 --- a/src/test/ui/impl-trait/auto-trait-leak.stderr +++ b/src/test/ui/impl-trait/auto-trait-leak.stderr @@ -30,129 +30,47 @@ note: ...which requires building MIR for `cycle1`... LL | fn cycle1() -> impl Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^ note: ...which requires type-checking `cycle1`... - --> $DIR/auto-trait-leak.rs:12:1 - | -LL | fn cycle1() -> impl Clone { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires computing type of `cycle2::{opaque#0}`... - --> $DIR/auto-trait-leak.rs:20:16 - | -LL | fn cycle2() -> impl Clone { - | ^^^^^^^^^^ -note: ...which requires borrow-checking `cycle2`... - --> $DIR/auto-trait-leak.rs:20:1 - | -LL | fn cycle2() -> impl Clone { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires processing `cycle2`... - --> $DIR/auto-trait-leak.rs:20:1 - | -LL | fn cycle2() -> impl Clone { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires processing MIR for `cycle2`... - --> $DIR/auto-trait-leak.rs:20:1 - | -LL | fn cycle2() -> impl Clone { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires unsafety-checking `cycle2`... - --> $DIR/auto-trait-leak.rs:20:1 - | -LL | fn cycle2() -> impl Clone { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires building MIR for `cycle2`... - --> $DIR/auto-trait-leak.rs:20:1 - | -LL | fn cycle2() -> impl Clone { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires type-checking `cycle2`... - --> $DIR/auto-trait-leak.rs:20:1 - | -LL | fn cycle2() -> impl Clone { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: ...which again requires computing type of `cycle1::{opaque#0}`, completing the cycle -note: cycle used when checking item types in top-level module - --> $DIR/auto-trait-leak.rs:1:1 - | -LL | / use std::cell::Cell; -LL | | use std::rc::Rc; -LL | | -LL | | fn send<T: Send>(_: T) {} -... | -LL | | Rc::new(String::from("foo")) -LL | | } - | |_^ - -error[E0391]: cycle detected when computing type of `cycle1::{opaque#0}` - --> $DIR/auto-trait-leak.rs:12:16 + --> $DIR/auto-trait-leak.rs:14:5 | -LL | fn cycle1() -> impl Clone { - | ^^^^^^^^^^ - | -note: ...which requires borrow-checking `cycle1`... - --> $DIR/auto-trait-leak.rs:12:1 - | -LL | fn cycle1() -> impl Clone { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires processing `cycle1`... - --> $DIR/auto-trait-leak.rs:12:1 - | -LL | fn cycle1() -> impl Clone { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires processing MIR for `cycle1`... - --> $DIR/auto-trait-leak.rs:12:1 - | -LL | fn cycle1() -> impl Clone { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires unsafety-checking `cycle1`... - --> $DIR/auto-trait-leak.rs:12:1 - | -LL | fn cycle1() -> impl Clone { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires building MIR for `cycle1`... - --> $DIR/auto-trait-leak.rs:12:1 - | -LL | fn cycle1() -> impl Clone { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires type-checking `cycle1`... - --> $DIR/auto-trait-leak.rs:12:1 - | -LL | fn cycle1() -> impl Clone { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | send(cycle2().clone()); + | ^^^^ + = note: ...which requires evaluating trait selection obligation `impl core::clone::Clone: core::marker::Send`... note: ...which requires computing type of `cycle2::{opaque#0}`... - --> $DIR/auto-trait-leak.rs:20:16 + --> $DIR/auto-trait-leak.rs:19:16 | LL | fn cycle2() -> impl Clone { | ^^^^^^^^^^ note: ...which requires borrow-checking `cycle2`... - --> $DIR/auto-trait-leak.rs:20:1 + --> $DIR/auto-trait-leak.rs:19:1 | LL | fn cycle2() -> impl Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^ note: ...which requires processing `cycle2`... - --> $DIR/auto-trait-leak.rs:20:1 + --> $DIR/auto-trait-leak.rs:19:1 | LL | fn cycle2() -> impl Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^ note: ...which requires processing MIR for `cycle2`... - --> $DIR/auto-trait-leak.rs:20:1 + --> $DIR/auto-trait-leak.rs:19:1 | LL | fn cycle2() -> impl Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^ note: ...which requires unsafety-checking `cycle2`... - --> $DIR/auto-trait-leak.rs:20:1 + --> $DIR/auto-trait-leak.rs:19:1 | LL | fn cycle2() -> impl Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^ note: ...which requires building MIR for `cycle2`... - --> $DIR/auto-trait-leak.rs:20:1 + --> $DIR/auto-trait-leak.rs:19:1 | LL | fn cycle2() -> impl Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^ note: ...which requires type-checking `cycle2`... - --> $DIR/auto-trait-leak.rs:20:1 + --> $DIR/auto-trait-leak.rs:20:5 | -LL | fn cycle2() -> impl Clone { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | send(cycle1().clone()); + | ^^^^ + = note: ...which requires evaluating trait selection obligation `impl core::clone::Clone: core::marker::Send`... = note: ...which again requires computing type of `cycle1::{opaque#0}`, completing the cycle note: cycle used when checking item types in top-level module --> $DIR/auto-trait-leak.rs:1:1 @@ -166,6 +84,6 @@ LL | | Rc::new(String::from("foo")) LL | | } | |_^ -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0391`. diff --git a/src/test/ui/impl-trait/auto-trait.rs b/src/test/ui/impl-trait/auto-trait.rs index 35994e4a5ba..cf2773f4ef5 100644 --- a/src/test/ui/impl-trait/auto-trait.rs +++ b/src/test/ui/impl-trait/auto-trait.rs @@ -19,7 +19,7 @@ impl<T: Send> AnotherTrait for T {} // (We treat opaque types as "foreign types" that could grow more impls // in the future.) impl AnotherTrait for D<OpaqueType> { - //~^ ERROR conflicting implementations of trait `AnotherTrait` for type `D<OpaqueType>` + //~^ ERROR conflicting implementations of trait `AnotherTrait` for type `D<impl OpaqueTrait>` } fn main() {} diff --git a/src/test/ui/impl-trait/auto-trait.stderr b/src/test/ui/impl-trait/auto-trait.stderr index 81009413c9a..26cd8fb6a9b 100644 --- a/src/test/ui/impl-trait/auto-trait.stderr +++ b/src/test/ui/impl-trait/auto-trait.stderr @@ -1,11 +1,11 @@ -error[E0119]: conflicting implementations of trait `AnotherTrait` for type `D<OpaqueType>` +error[E0119]: conflicting implementations of trait `AnotherTrait` for type `D<impl OpaqueTrait>` --> $DIR/auto-trait.rs:21:1 | LL | impl<T: Send> AnotherTrait for T {} | -------------------------------- first implementation here ... LL | impl AnotherTrait for D<OpaqueType> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D<OpaqueType>` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D<impl OpaqueTrait>` error: aborting due to previous error diff --git a/src/test/ui/impl-trait/bound-normalization-fail.rs b/src/test/ui/impl-trait/bound-normalization-fail.rs index 20ddad0547e..8ec06e534d1 100644 --- a/src/test/ui/impl-trait/bound-normalization-fail.rs +++ b/src/test/ui/impl-trait/bound-normalization-fail.rs @@ -23,8 +23,8 @@ mod impl_trait { /// `T::Assoc` can't be normalized any further here. fn foo_fail<T: Trait>() -> impl FooLike<Output = T::Assoc> { - Foo(()) //~^ ERROR: type mismatch + Foo(()) } } @@ -39,9 +39,9 @@ mod lifetimes { /// Missing bound constraining `Assoc`, `T::Assoc` can't be normalized further. fn foo2_fail<'a, T: Trait<'a>>() -> impl FooLike<Output = T::Assoc> { - //~^ ERROR `impl Trait` return type cannot contain a projection or `Self` that references lifetimes from a parent scope - Foo(()) //~^ ERROR: type mismatch + //~^^ ERROR `impl Trait` return type cannot contain a projection or `Self` that references lifetimes from a parent scope + Foo(()) } } diff --git a/src/test/ui/impl-trait/bound-normalization-fail.stderr b/src/test/ui/impl-trait/bound-normalization-fail.stderr index 01fb853e1d1..afa21c1a858 100644 --- a/src/test/ui/impl-trait/bound-normalization-fail.stderr +++ b/src/test/ui/impl-trait/bound-normalization-fail.stderr @@ -1,16 +1,16 @@ error[E0271]: type mismatch resolving `<Foo<()> as FooLike>::Output == <T as impl_trait::Trait>::Assoc` - --> $DIR/bound-normalization-fail.rs:26:9 + --> $DIR/bound-normalization-fail.rs:25:32 | -LL | Foo(()) - | ^^^^^^^ type mismatch resolving `<Foo<()> as FooLike>::Output == <T as impl_trait::Trait>::Assoc` +LL | fn foo_fail<T: Trait>() -> impl FooLike<Output = T::Assoc> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<Foo<()> as FooLike>::Output == <T as impl_trait::Trait>::Assoc` | -note: expected this to be `()` +note: expected this to be `<T as impl_trait::Trait>::Assoc` --> $DIR/bound-normalization-fail.rs:14:19 | LL | type Output = T; | ^ - = note: expected unit type `()` - found associated type `<T as impl_trait::Trait>::Assoc` + = note: expected associated type `<T as impl_trait::Trait>::Assoc` + found unit type `()` help: consider constraining the associated type `<T as impl_trait::Trait>::Assoc` to `()` | LL | fn foo_fail<T: Trait<Assoc = ()>>() -> impl FooLike<Output = T::Assoc> { @@ -23,18 +23,18 @@ LL | fn foo2_fail<'a, T: Trait<'a>>() -> impl FooLike<Output = T::Assoc> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0271]: type mismatch resolving `<Foo<()> as FooLike>::Output == <T as lifetimes::Trait<'static>>::Assoc` - --> $DIR/bound-normalization-fail.rs:43:9 + --> $DIR/bound-normalization-fail.rs:41:41 | -LL | Foo(()) - | ^^^^^^^ type mismatch resolving `<Foo<()> as FooLike>::Output == <T as lifetimes::Trait<'static>>::Assoc` +LL | fn foo2_fail<'a, T: Trait<'a>>() -> impl FooLike<Output = T::Assoc> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<Foo<()> as FooLike>::Output == <T as lifetimes::Trait<'static>>::Assoc` | -note: expected this to be `()` +note: expected this to be `<T as lifetimes::Trait<'static>>::Assoc` --> $DIR/bound-normalization-fail.rs:14:19 | LL | type Output = T; | ^ - = note: expected unit type `()` - found associated type `<T as lifetimes::Trait<'static>>::Assoc` + = note: expected associated type `<T as lifetimes::Trait<'static>>::Assoc` + found unit type `()` help: consider constraining the associated type `<T as lifetimes::Trait<'static>>::Assoc` to `()` | LL | fn foo2_fail<'a, T: Trait<'a, Assoc = ()>>() -> impl FooLike<Output = T::Assoc> { diff --git a/src/test/ui/impl-trait/does-not-live-long-enough.stderr b/src/test/ui/impl-trait/does-not-live-long-enough.stderr index 750687e2322..f4bd0fde3b6 100644 --- a/src/test/ui/impl-trait/does-not-live-long-enough.stderr +++ b/src/test/ui/impl-trait/does-not-live-long-enough.stderr @@ -7,10 +7,10 @@ LL | self.data.iter().filter(|s| s.starts_with(prefix)).map(|s| s.as_ref | may outlive borrowed value `prefix` | note: closure is returned here - --> $DIR/does-not-live-long-enough.rs:6:9 + --> $DIR/does-not-live-long-enough.rs:5:55 | -LL | self.data.iter().filter(|s| s.starts_with(prefix)).map(|s| s.as_ref()) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn started_with<'a>(&'a self, prefix: &'a str) -> impl Iterator<Item=&'a str> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: to force the closure to take ownership of `prefix` (and any other referenced variables), use the `move` keyword | LL | self.data.iter().filter(move |s| s.starts_with(prefix)).map(|s| s.as_ref()) diff --git a/src/test/ui/impl-trait/equality.rs b/src/test/ui/impl-trait/equality.rs index 59770c10da2..9610618ca11 100644 --- a/src/test/ui/impl-trait/equality.rs +++ b/src/test/ui/impl-trait/equality.rs @@ -17,8 +17,8 @@ fn two(x: bool) -> impl Foo { //~| expected `i32`, found `u32` } -fn sum_to(n: u32) -> impl Foo { - if n == 0 { //~ ERROR type annotations needed +fn sum_to(n: u32) -> impl Foo { //~ ERROR type annotations needed + if n == 0 { 0 } else { n + sum_to(n - 1) diff --git a/src/test/ui/impl-trait/equality.stderr b/src/test/ui/impl-trait/equality.stderr index 4032fbbceba..d9819484a96 100644 --- a/src/test/ui/impl-trait/equality.stderr +++ b/src/test/ui/impl-trait/equality.stderr @@ -12,13 +12,19 @@ error[E0308]: mismatched types --> $DIR/equality.rs:15:5 | LL | fn two(x: bool) -> impl Foo { - | -------- the expected opaque type -... + | -------- expected because this return type... +LL | if x { +LL | return 1_i32; + | ----- ...is found to be `i32` here +LL | } LL | 0_u32 | ^^^^^ expected `i32`, found `u32` | - = note: expected opaque type `impl Foo` - found type `u32` + = note: to return `impl Trait`, all returned values must be of the same type + = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits> + = help: if the trait `Foo` were object safe, you could return a boxed trait object + = note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types> + = help: you could instead create a new `enum` with a variant for each returned type error[E0277]: cannot add `impl Foo` to `u32` --> $DIR/equality.rs:24:11 @@ -29,15 +35,10 @@ LL | n + sum_to(n - 1) = help: the trait `Add<impl Foo>` is not implemented for `u32` error[E0283]: type annotations needed - --> $DIR/equality.rs:21:5 - | -LL | / if n == 0 { -LL | | 0 -LL | | } else { -LL | | n + sum_to(n - 1) -LL | | -LL | | } - | |_____^ cannot infer type for type `{integer}` + --> $DIR/equality.rs:20:22 + | +LL | fn sum_to(n: u32) -> impl Foo { + | ^^^^^^^^ cannot infer type for type `{integer}` | = note: multiple `impl`s satisfying `{integer}: ToString` found in the `alloc` crate: - impl ToString for i8; diff --git a/src/test/ui/impl-trait/equality2.stderr b/src/test/ui/impl-trait/equality2.stderr index fd33fa7c674..46053c6e7c1 100644 --- a/src/test/ui/impl-trait/equality2.stderr +++ b/src/test/ui/impl-trait/equality2.stderr @@ -15,7 +15,9 @@ LL | fn hide<T: Foo>(x: T) -> impl Foo { | -------- the found opaque type ... LL | let _: u32 = hide(0_u32); - | ^^^^^^^^^^^ expected `u32`, found opaque type + | --- ^^^^^^^^^^^ expected `u32`, found opaque type + | | + | expected due to this | = note: expected type `u32` found opaque type `impl Foo` diff --git a/src/test/ui/impl-trait/fallback.rs b/src/test/ui/impl-trait/fallback.rs deleted file mode 100644 index 1e6eb5bb355..00000000000 --- a/src/test/ui/impl-trait/fallback.rs +++ /dev/null @@ -1,9 +0,0 @@ -// check-pass - -fn take_edge_counters( - x: &mut Option<Vec<i32>>, -) -> Option<impl Iterator<Item = i32>> { - x.take().map_or(None, |m| Some(m.into_iter())) -} - -fn main() {} diff --git a/src/test/ui/impl-trait/hidden-lifetimes.rs b/src/test/ui/impl-trait/hidden-lifetimes.rs index ae07c892768..2ee004a37a6 100644 --- a/src/test/ui/impl-trait/hidden-lifetimes.rs +++ b/src/test/ui/impl-trait/hidden-lifetimes.rs @@ -26,8 +26,8 @@ impl<T> Swap for Rc<RefCell<T>> { // Here we are hiding `'b` making the caller believe that `&'a mut &'s T` and // `&'a mut &'l T` are the same type. fn hide_ref<'a, 'b, T: 'static>(x: &'a mut &'b T) -> impl Swap + 'a { - x //~^ ERROR hidden type + x } fn dangle_ref() -> &'static [i32; 3] { @@ -43,8 +43,8 @@ fn dangle_ref() -> &'static [i32; 3] { // This is different to the previous example because the concrete return type // only has a single lifetime. fn hide_rc_refcell<'a, 'b: 'a, T: 'static>(x: Rc<RefCell<&'b T>>) -> impl Swap + 'a { - x //~^ ERROR hidden type + x } fn dangle_rc_refcell() -> &'static [i32; 3] { diff --git a/src/test/ui/impl-trait/hidden-lifetimes.stderr b/src/test/ui/impl-trait/hidden-lifetimes.stderr index 97652f5462e..c6d11293eec 100644 --- a/src/test/ui/impl-trait/hidden-lifetimes.stderr +++ b/src/test/ui/impl-trait/hidden-lifetimes.stderr @@ -1,10 +1,10 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/hidden-lifetimes.rs:29:5 + --> $DIR/hidden-lifetimes.rs:28:54 | LL | fn hide_ref<'a, 'b, T: 'static>(x: &'a mut &'b T) -> impl Swap + 'a { - | -- hidden type `&'a mut &'b T` captures the lifetime `'b` as defined here -LL | x - | ^ + | -- ^^^^^^^^^^^^^^ + | | + | hidden type `&'a mut &'b T` captures the lifetime `'b` as defined here | help: to declare that the `impl Trait` captures `'b`, you can add an explicit `'b` lifetime bound | @@ -12,12 +12,12 @@ LL | fn hide_ref<'a, 'b, T: 'static>(x: &'a mut &'b T) -> impl Swap + 'a + 'b { | ++++ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/hidden-lifetimes.rs:46:5 + --> $DIR/hidden-lifetimes.rs:45:70 | LL | fn hide_rc_refcell<'a, 'b: 'a, T: 'static>(x: Rc<RefCell<&'b T>>) -> impl Swap + 'a { - | -- hidden type `Rc<RefCell<&'b T>>` captures the lifetime `'b` as defined here -LL | x - | ^ + | -- ^^^^^^^^^^^^^^ + | | + | hidden type `Rc<RefCell<&'b T>>` captures the lifetime `'b` as defined here | help: to declare that the `impl Trait` captures `'b`, you can add an explicit `'b` lifetime bound | diff --git a/src/test/ui/impl-trait/issue-55872-1.rs b/src/test/ui/impl-trait/issue-55872-1.rs index a75b9b43b3e..46188636475 100644 --- a/src/test/ui/impl-trait/issue-55872-1.rs +++ b/src/test/ui/impl-trait/issue-55872-1.rs @@ -10,10 +10,11 @@ impl<S: Default> Bar for S { type E = impl Copy; fn foo<T: Default>() -> Self::E { - //~^ ERROR impl has stricter requirements than trait - (S::default(), T::default()) - //~^ ERROR the trait bound `S: Copy` is not satisfied in `(S, T)` [E0277] + //~^ ERROR type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias + //~| ERROR impl has stricter requirements than trait + //~| ERROR the trait bound `S: Copy` is not satisfied in `(S, T)` [E0277] //~| ERROR the trait bound `T: Copy` is not satisfied in `(S, T)` [E0277] + (S::default(), T::default()) } } diff --git a/src/test/ui/impl-trait/issue-55872-1.stderr b/src/test/ui/impl-trait/issue-55872-1.stderr index efc57da7461..2d1142fd0c5 100644 --- a/src/test/ui/impl-trait/issue-55872-1.stderr +++ b/src/test/ui/impl-trait/issue-55872-1.stderr @@ -8,10 +8,10 @@ LL | fn foo<T: Default>() -> Self::E { | ^^^^^^^ impl has extra requirement `T: Default` error[E0277]: the trait bound `S: Copy` is not satisfied in `(S, T)` - --> $DIR/issue-55872-1.rs:14:9 + --> $DIR/issue-55872-1.rs:12:29 | -LL | (S::default(), T::default()) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `(S, T)`, the trait `Copy` is not implemented for `S` +LL | fn foo<T: Default>() -> Self::E { + | ^^^^^^^ within `(S, T)`, the trait `Copy` is not implemented for `S` | = note: required because it appears within the type `(S, T)` help: consider further restricting this bound @@ -20,10 +20,10 @@ LL | impl<S: Default + std::marker::Copy> Bar for S { | +++++++++++++++++++ error[E0277]: the trait bound `T: Copy` is not satisfied in `(S, T)` - --> $DIR/issue-55872-1.rs:14:9 + --> $DIR/issue-55872-1.rs:12:29 | -LL | (S::default(), T::default()) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `(S, T)`, the trait `Copy` is not implemented for `T` +LL | fn foo<T: Default>() -> Self::E { + | ^^^^^^^ within `(S, T)`, the trait `Copy` is not implemented for `T` | = note: required because it appears within the type `(S, T)` help: consider further restricting this bound @@ -31,7 +31,20 @@ help: consider further restricting this bound LL | fn foo<T: Default + std::marker::Copy>() -> Self::E { | +++++++++++++++++++ -error: aborting due to 3 previous errors +error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias + --> $DIR/issue-55872-1.rs:12:37 + | +LL | fn foo<T: Default>() -> Self::E { + | _____________________________________^ +LL | | +LL | | +LL | | +LL | | +LL | | (S::default(), T::default()) +LL | | } + | |_____^ + +error: aborting due to 4 previous errors Some errors have detailed explanations: E0276, E0277. For more information about an error, try `rustc --explain E0276`. diff --git a/src/test/ui/impl-trait/issue-55872-2.rs b/src/test/ui/impl-trait/issue-55872-2.rs index f0bc0b52727..a519397806e 100644 --- a/src/test/ui/impl-trait/issue-55872-2.rs +++ b/src/test/ui/impl-trait/issue-55872-2.rs @@ -4,16 +4,17 @@ #![feature(type_alias_impl_trait)] pub trait Bar { - type E: Send; + type E: Copy; fn foo<T>() -> Self::E; } impl<S> Bar for S { - type E = impl std::marker::Send; + type E = impl std::marker::Copy; fn foo<T>() -> Self::E { - async {} //~^ ERROR type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias + //~| ERROR the trait bound `impl Future<Output = [async output]>: Copy` is not satisfied + async {} } } diff --git a/src/test/ui/impl-trait/issue-55872-2.stderr b/src/test/ui/impl-trait/issue-55872-2.stderr index 71090bdbf80..97545ba3d11 100644 --- a/src/test/ui/impl-trait/issue-55872-2.stderr +++ b/src/test/ui/impl-trait/issue-55872-2.stderr @@ -1,8 +1,20 @@ +error[E0277]: the trait bound `impl Future<Output = [async output]>: Copy` is not satisfied + --> $DIR/issue-55872-2.rs:14:20 + | +LL | fn foo<T>() -> Self::E { + | ^^^^^^^ the trait `Copy` is not implemented for `impl Future<Output = [async output]>` + error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias - --> $DIR/issue-55872-2.rs:15:9 + --> $DIR/issue-55872-2.rs:14:28 | -LL | async {} - | ^^^^^^^^ +LL | fn foo<T>() -> Self::E { + | ____________________________^ +LL | | +LL | | +LL | | async {} +LL | | } + | |_____^ -error: aborting due to previous error +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/impl-trait/issue-55872-3.rs b/src/test/ui/impl-trait/issue-55872-3.rs deleted file mode 100644 index f50b31ff496..00000000000 --- a/src/test/ui/impl-trait/issue-55872-3.rs +++ /dev/null @@ -1,20 +0,0 @@ -// edition:2018 -// ignore-compare-mode-chalk - -#![feature(type_alias_impl_trait)] - -pub trait Bar { - type E: Copy; - - fn foo<T>() -> Self::E; -} - -impl<S> Bar for S { - type E = impl std::marker::Copy; - fn foo<T>() -> Self::E { - async {} - //~^ ERROR the trait bound `impl Future<Output = [async output]>: Copy` is not satisfied [E0277] - } -} - -fn main() {} diff --git a/src/test/ui/impl-trait/issue-55872-3.stderr b/src/test/ui/impl-trait/issue-55872-3.stderr deleted file mode 100644 index bafd31f0083..00000000000 --- a/src/test/ui/impl-trait/issue-55872-3.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0277]: the trait bound `impl Future<Output = [async output]>: Copy` is not satisfied - --> $DIR/issue-55872-3.rs:15:9 - | -LL | async {} - | ^^^^^^^^ the trait `Copy` is not implemented for `impl Future<Output = [async output]>` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/impl-trait/issue-55872.rs b/src/test/ui/impl-trait/issue-55872.rs index 65874d22ac6..bbd94025417 100644 --- a/src/test/ui/impl-trait/issue-55872.rs +++ b/src/test/ui/impl-trait/issue-55872.rs @@ -11,8 +11,8 @@ impl<S> Bar for S { type E = impl Copy; fn foo<T>() -> Self::E { - || () //~^ ERROR type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias + || () } } diff --git a/src/test/ui/impl-trait/issue-55872.stderr b/src/test/ui/impl-trait/issue-55872.stderr index 7abcf6a0594..60654ec3461 100644 --- a/src/test/ui/impl-trait/issue-55872.stderr +++ b/src/test/ui/impl-trait/issue-55872.stderr @@ -1,8 +1,12 @@ error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias - --> $DIR/issue-55872.rs:14:9 + --> $DIR/issue-55872.rs:13:28 | -LL | || () - | ^^^^^ +LL | fn foo<T>() -> Self::E { + | ____________________________^ +LL | | +LL | | || () +LL | | } + | |_____^ error: aborting due to previous error diff --git a/src/test/ui/impl-trait/issue-72911.rs b/src/test/ui/impl-trait/issue-72911.rs index cf2c8b7e415..dee5a41f6de 100644 --- a/src/test/ui/impl-trait/issue-72911.rs +++ b/src/test/ui/impl-trait/issue-72911.rs @@ -5,7 +5,7 @@ pub struct Lint {} impl Lint {} pub fn gather_all() -> impl Iterator<Item = Lint> { - //~^ ERROR `()` is not an iterator + //~^ ERROR: cannot resolve opaque type lint_files().flat_map(|f| gather_from_file(&f)) } diff --git a/src/test/ui/impl-trait/issue-72911.stderr b/src/test/ui/impl-trait/issue-72911.stderr index 4a990286d96..e57fbf104dc 100644 --- a/src/test/ui/impl-trait/issue-72911.stderr +++ b/src/test/ui/impl-trait/issue-72911.stderr @@ -10,15 +10,25 @@ error[E0433]: failed to resolve: use of undeclared crate or module `foo` LL | fn lint_files() -> impl Iterator<Item = foo::MissingItem> { | ^^^ use of undeclared crate or module `foo` -error[E0277]: `()` is not an iterator +error[E0720]: cannot resolve opaque type --> $DIR/issue-72911.rs:7:24 | LL | pub fn gather_all() -> impl Iterator<Item = Lint> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not an iterator - | - = help: the trait `Iterator` is not implemented for `()` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ recursive opaque type +LL | +LL | lint_files().flat_map(|f| gather_from_file(&f)) + | ----------------------------------------------- + | | + | returning here with type `FlatMap<impl Iterator<Item = [type error]>, [type error], [closure@$DIR/issue-72911.rs:9:27: 9:51]>` + | returning here with type `FlatMap<impl Iterator<Item = [type error]>, [type error], [closure@$DIR/issue-72911.rs:9:27: 9:51]>` +... +LL | fn gather_from_file(dir_entry: &foo::MissingItem) -> impl Iterator<Item = Lint> { + | -------------------------- returning this opaque type `FlatMap<impl Iterator<Item = [type error]>, [type error], [closure@$DIR/issue-72911.rs:9:27: 9:51]>` +... +LL | fn lint_files() -> impl Iterator<Item = foo::MissingItem> { + | -------------------------------------- returning this opaque type `FlatMap<impl Iterator<Item = [type error]>, [type error], [closure@$DIR/issue-72911.rs:9:27: 9:51]>` error: aborting due to 3 previous errors -Some errors have detailed explanations: E0277, E0433. -For more information about an error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0433, E0720. +For more information about an error, try `rustc --explain E0433`. diff --git a/src/test/ui/impl-trait/issues/issue-70877.rs b/src/test/ui/impl-trait/issues/issue-70877.rs index 8169cfafac7..853c2a82bed 100644 --- a/src/test/ui/impl-trait/issues/issue-70877.rs +++ b/src/test/ui/impl-trait/issues/issue-70877.rs @@ -4,7 +4,7 @@ type FooArg<'a> = &'a dyn ToString; type FooRet = impl std::fmt::Debug; type FooItem = Box<dyn Fn(FooArg) -> FooRet>; -type Foo = impl Iterator<Item = FooItem>; +type Foo = impl Iterator<Item = FooItem>; //~ ERROR: type mismatch #[repr(C)] struct Bar(u8); @@ -28,7 +28,7 @@ fn ham() -> Foo { fn oof() -> impl std::fmt::Debug { let mut bar = ham(); let func = bar.next().unwrap(); - return func(&"oof"); //~ ERROR opaque type's hidden type cannot be another opaque type + return func(&"oof"); } fn main() { diff --git a/src/test/ui/impl-trait/issues/issue-70877.stderr b/src/test/ui/impl-trait/issues/issue-70877.stderr index 8813bff3c35..fe48e92da5e 100644 --- a/src/test/ui/impl-trait/issues/issue-70877.stderr +++ b/src/test/ui/impl-trait/issues/issue-70877.stderr @@ -1,19 +1,20 @@ -error: opaque type's hidden type cannot be another opaque type from the same scope - --> $DIR/issue-70877.rs:31:12 +error[E0271]: type mismatch resolving `<Bar as Iterator>::Item == Box<(dyn for<'r> Fn(&'r (dyn ToString + 'r)) -> Option<String> + 'static)>` + --> $DIR/issue-70877.rs:7:12 | -LL | return func(&"oof"); - | ^^^^^^^^^^^^ one of the two opaque types used here has to be outside its defining scope - | -note: opaque type whose hidden type is being assigned - --> $DIR/issue-70877.rs:28:13 +LL | type FooRet = impl std::fmt::Debug; + | -------------------- the found opaque type +... +LL | type Foo = impl Iterator<Item = FooItem>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<Bar as Iterator>::Item == Box<(dyn for<'r> Fn(&'r (dyn ToString + 'r)) -> Option<String> + 'static)>` | -LL | fn oof() -> impl std::fmt::Debug { - | ^^^^^^^^^^^^^^^^^^^^ -note: opaque type being used as hidden type - --> $DIR/issue-70877.rs:4:15 +note: expected this to be `Box<(dyn for<'r> Fn(&'r (dyn ToString + 'r)) -> Option<String> + 'static)>` + --> $DIR/issue-70877.rs:13:17 | -LL | type FooRet = impl std::fmt::Debug; - | ^^^^^^^^^^^^^^^^^^^^ +LL | type Item = FooItem; + | ^^^^^^^ + = note: expected struct `Box<(dyn for<'r> Fn(&'r (dyn ToString + 'r)) -> Option<String> + 'static)>` + found struct `Box<(dyn for<'r> Fn(&'r (dyn ToString + 'r)) -> impl Debug + 'static)>` error: aborting due to previous error +For more information about this error, try `rustc --explain E0271`. diff --git a/src/test/ui/impl-trait/issues/issue-78722.rs b/src/test/ui/impl-trait/issues/issue-78722.rs index b13ab6bad7f..bdbd20f9d2b 100644 --- a/src/test/ui/impl-trait/issues/issue-78722.rs +++ b/src/test/ui/impl-trait/issues/issue-78722.rs @@ -10,8 +10,7 @@ struct Bug { async {} } let f: F = async { 1 }; - //~^ ERROR `async` blocks are not allowed in constants - //~| ERROR destructors cannot be evaluated at compile-time + //~^ ERROR mismatched types [E0308] 1 }], } diff --git a/src/test/ui/impl-trait/issues/issue-78722.stderr b/src/test/ui/impl-trait/issues/issue-78722.stderr index 975c771759f..130678de237 100644 --- a/src/test/ui/impl-trait/issues/issue-78722.stderr +++ b/src/test/ui/impl-trait/issues/issue-78722.stderr @@ -1,22 +1,23 @@ -error[E0658]: `async` blocks are not allowed in constants +error[E0308]: mismatched types --> $DIR/issue-78722.rs:12:20 | +LL | type F = impl core::future::Future<Output = u8>; + | -------------------------------------- the expected opaque type +... LL | let f: F = async { 1 }; - | ^^^^^^^^^^^ + | - ^^^^^^^^^^^ expected opaque type, found a different opaque type + | | + | expected due to this | - = note: see issue #85368 <https://github.com/rust-lang/rust/issues/85368> for more information - = help: add `#![feature(const_async_blocks)]` to the crate attributes to enable - -error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/issue-78722.rs:12:13 + ::: $SRC_DIR/core/src/future/mod.rs:LL:COL | -LL | let f: F = async { 1 }; - | ^ constants cannot evaluate destructors -... -LL | }], - | - value is dropped here +LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return> + | ------------------------------- the found opaque type + | + = note: expected opaque type `impl Future<Output = u8>` + found opaque type `impl Future<Output = [async output]>` + = note: distinct uses of `impl Trait` result in different opaque types -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0493, E0658. -For more information about an error, try `rustc --explain E0493`. +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/impl-trait/issues/issue-86201.rs b/src/test/ui/impl-trait/issues/issue-86201.rs index 0786e66ca8b..e3386d29def 100644 --- a/src/test/ui/impl-trait/issues/issue-86201.rs +++ b/src/test/ui/impl-trait/issues/issue-86201.rs @@ -1,10 +1,10 @@ #![feature(unboxed_closures)] #![feature(type_alias_impl_trait)] -// check-pass - type FunType = impl Fn<()>; +//~^ ERROR could not find defining uses static STATIC_FN: FunType = some_fn; +//~^ ERROR mismatched types fn some_fn() {} diff --git a/src/test/ui/impl-trait/issues/issue-86201.stderr b/src/test/ui/impl-trait/issues/issue-86201.stderr new file mode 100644 index 00000000000..b1460096ded --- /dev/null +++ b/src/test/ui/impl-trait/issues/issue-86201.stderr @@ -0,0 +1,21 @@ +error[E0308]: mismatched types + --> $DIR/issue-86201.rs:6:29 + | +LL | type FunType = impl Fn<()>; + | ----------- the expected opaque type +LL | +LL | static STATIC_FN: FunType = some_fn; + | ^^^^^^^ expected opaque type, found fn item + | + = note: expected opaque type `impl Fn<()>` + found fn item `fn() {some_fn}` + +error: could not find defining uses + --> $DIR/issue-86201.rs:4:16 + | +LL | type FunType = impl Fn<()>; + | ^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/impl-trait/issues/issue-88236-2.nll.stderr b/src/test/ui/impl-trait/issues/issue-88236-2.nll.stderr deleted file mode 100644 index 86323add779..00000000000 --- a/src/test/ui/impl-trait/issues/issue-88236-2.nll.stderr +++ /dev/null @@ -1,39 +0,0 @@ -error: higher-ranked subtype error - --> $DIR/issue-88236-2.rs:17:5 - | -LL | &() - | ^^^ - -error: higher-ranked subtype error - --> $DIR/issue-88236-2.rs:17:5 - | -LL | &() - | ^^^ - -error: lifetime may not live long enough - --> $DIR/issue-88236-2.rs:20:5 - | -LL | fn make_bad_impl<'b>(x: &'b ()) -> impl for<'a> Hrtb<'a, Assoc = impl Send + 'a> { - | -- lifetime `'b` defined here -LL | x - | ^ returning this value requires that `'b` must outlive `'static` - | -help: to allow this `impl Trait` to capture borrowed data with lifetime `'b`, add `'b` as a bound - | -LL | fn make_bad_impl<'b>(x: &'b ()) -> impl for<'a> Hrtb<'a, Assoc = impl Send + 'a> + 'b { - | ++++ - -error: higher-ranked subtype error - --> $DIR/issue-88236-2.rs:20:5 - | -LL | x - | ^ - -error: higher-ranked subtype error - --> $DIR/issue-88236-2.rs:20:5 - | -LL | x - | ^ - -error: aborting due to 5 previous errors - diff --git a/src/test/ui/impl-trait/issues/issue-88236-2.rs b/src/test/ui/impl-trait/issues/issue-88236-2.rs deleted file mode 100644 index f89ab7fbd36..00000000000 --- a/src/test/ui/impl-trait/issues/issue-88236-2.rs +++ /dev/null @@ -1,23 +0,0 @@ -// this used to cause stack overflows - -trait Hrtb<'a> { - type Assoc; -} - -impl<'a> Hrtb<'a> for () { - type Assoc = (); -} - -impl<'a> Hrtb<'a> for &'a () { - type Assoc = (); -} - -fn make_impl() -> impl for<'a> Hrtb<'a, Assoc = impl Send + 'a> {} -fn make_weird_impl<'b>(x: &'b ()) -> impl for<'a> Hrtb<'a, Assoc = impl Send + 'a> { - &() //~ ERROR implementation of `Hrtb` is not general enough -} -fn make_bad_impl<'b>(x: &'b ()) -> impl for<'a> Hrtb<'a, Assoc = impl Send + 'a> { - x //~ ERROR implementation of `Hrtb` is not general enough -} - -fn main() {} diff --git a/src/test/ui/impl-trait/issues/issue-88236-2.stderr b/src/test/ui/impl-trait/issues/issue-88236-2.stderr deleted file mode 100644 index 95c4a528036..00000000000 --- a/src/test/ui/impl-trait/issues/issue-88236-2.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: implementation of `Hrtb` is not general enough - --> $DIR/issue-88236-2.rs:17:5 - | -LL | &() - | ^^^ implementation of `Hrtb` is not general enough - | - = note: `Hrtb<'0>` would have to be implemented for the type `&()`, for any lifetime `'0`... - = note: ...but `Hrtb<'1>` is actually implemented for the type `&'1 ()`, for some specific lifetime `'1` - -error: implementation of `Hrtb` is not general enough - --> $DIR/issue-88236-2.rs:20:5 - | -LL | x - | ^ implementation of `Hrtb` is not general enough - | - = note: `&()` must implement `Hrtb<'0>`, for any lifetime `'0`... - = note: ...but `Hrtb<'_>` is actually implemented for the type `&()` - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/impl-trait/issues/issue-88236.rs b/src/test/ui/impl-trait/issues/issue-88236.rs deleted file mode 100644 index 2ea35270a7e..00000000000 --- a/src/test/ui/impl-trait/issues/issue-88236.rs +++ /dev/null @@ -1,19 +0,0 @@ -// check-pass - -// this used to cause stack overflows - -trait Hrtb<'a> { - type Assoc; -} - -impl<'a> Hrtb<'a> for () { - type Assoc = (); -} - -impl<'a> Hrtb<'a> for &'a () { - type Assoc = (); -} - -fn make_impl() -> impl for<'a> Hrtb<'a, Assoc = impl Send + 'a> {} - -fn main() {} diff --git a/src/test/ui/impl-trait/lifetimes2.rs b/src/test/ui/impl-trait/lifetimes2.rs deleted file mode 100644 index 834f2dc6cb5..00000000000 --- a/src/test/ui/impl-trait/lifetimes2.rs +++ /dev/null @@ -1,10 +0,0 @@ -// check-pass - -pub fn keys<'a>(x: &'a Result<u32, u32>) -> impl std::fmt::Debug + 'a { - match x { - Ok(map) => Ok(map), - Err(map) => Err(map), - } -} - -fn main() {} diff --git a/src/test/ui/impl-trait/multiple-lifetimes/error-handling-2.rs b/src/test/ui/impl-trait/multiple-lifetimes/error-handling-2.rs index f5aaf118521..72e9d96da36 100644 --- a/src/test/ui/impl-trait/multiple-lifetimes/error-handling-2.rs +++ b/src/test/ui/impl-trait/multiple-lifetimes/error-handling-2.rs @@ -8,6 +8,7 @@ impl<T: Copy> Copy for CopyIfEq<T, T> {} type E<'a, 'b> = impl Sized; fn foo<'a: 'b, 'b, 'c>(x: &'static i32, mut y: &'a i32) -> E<'b, 'c> { + //~^ ERROR hidden type for `impl Trait` captures lifetime that does not appear in bounds let v = CopyIfEq::<*mut _, *mut _>(&mut { x }, &mut y); // This assignment requires that `x` and `y` have the same type due to the @@ -20,7 +21,6 @@ fn foo<'a: 'b, 'b, 'c>(x: &'static i32, mut y: &'a i32) -> E<'b, 'c> { let _: &'b i32 = *u.0; } u.0 - //~^ ERROR hidden type for `impl Trait` captures lifetime that does not appear in bounds } fn main() {} diff --git a/src/test/ui/impl-trait/multiple-lifetimes/error-handling-2.stderr b/src/test/ui/impl-trait/multiple-lifetimes/error-handling-2.stderr index b837b641103..40bec0da270 100644 --- a/src/test/ui/impl-trait/multiple-lifetimes/error-handling-2.stderr +++ b/src/test/ui/impl-trait/multiple-lifetimes/error-handling-2.stderr @@ -1,11 +1,10 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/error-handling-2.rs:22:5 + --> $DIR/error-handling-2.rs:10:60 | LL | fn foo<'a: 'b, 'b, 'c>(x: &'static i32, mut y: &'a i32) -> E<'b, 'c> { - | -- hidden type `*mut &'a i32` captures the lifetime `'a` as defined here -... -LL | u.0 - | ^^^ + | -- ^^^^^^^^^ + | | + | hidden type `*mut &'a i32` captures the lifetime `'a` as defined here error: aborting due to previous error diff --git a/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unrelated.rs b/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unrelated.rs index 47e05bce0f8..3a97624647e 100644 --- a/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unrelated.rs +++ b/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unrelated.rs @@ -14,6 +14,7 @@ struct Ordinary<'a>(&'a u8); // by both `'a` and `'b`. fn upper_bounds<'a, 'b, 'c, 'd, 'e>(a: Ordinary<'a>, b: Ordinary<'b>) -> impl Trait<'d, 'e> +//~^ ERROR hidden type for `impl Trait` captures lifetime that does not appear in bounds where 'a: 'e, 'b: 'd, @@ -26,7 +27,6 @@ where // 'a in ['d, 'e] // ``` if condition() { a } else { b } - //~^ ERROR hidden type for `impl Trait` captures lifetime that does not appear in bounds } fn condition() -> bool { diff --git a/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unrelated.stderr b/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unrelated.stderr index 15476c706a7..32829a0a1b2 100644 --- a/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unrelated.stderr +++ b/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unrelated.stderr @@ -1,11 +1,10 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/ordinary-bounds-unrelated.rs:28:33 + --> $DIR/ordinary-bounds-unrelated.rs:16:74 | LL | fn upper_bounds<'a, 'b, 'c, 'd, 'e>(a: Ordinary<'a>, b: Ordinary<'b>) -> impl Trait<'d, 'e> - | -- hidden type `Ordinary<'b>` captures the lifetime `'b` as defined here -... -LL | if condition() { a } else { b } - | ^ + | -- ^^^^^^^^^^^^^^^^^^ + | | + | hidden type `Ordinary<'b>` captures the lifetime `'b` as defined here | help: to declare that the `impl Trait` captures `'b`, you can add an explicit `'b` lifetime bound | diff --git a/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unsuited.rs b/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unsuited.rs index 321cb8c92a1..d4c60a4e892 100644 --- a/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unsuited.rs +++ b/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unsuited.rs @@ -16,6 +16,7 @@ struct Ordinary<'a>(&'a u8); // consider the loans for both `'a` and `'b` alive. fn upper_bounds<'a, 'b>(a: Ordinary<'a>, b: Ordinary<'b>) -> impl Trait<'a, 'b> +//~^ ERROR hidden type for `impl Trait` captures lifetime that does not appear in bounds { // We return a value: // @@ -29,7 +30,6 @@ fn upper_bounds<'a, 'b>(a: Ordinary<'a>, b: Ordinary<'b>) -> impl Trait<'a, 'b> // // We are forced to pick that '0 = 'e, because only 'e is outlived by *both* 'a and 'b. if condition() { a } else { b } - //~^ ERROR hidden type for `impl Trait` captures lifetime that does not appear in bounds } fn condition() -> bool { diff --git a/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unsuited.stderr b/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unsuited.stderr index 7315aa8e9d4..83ad23b253b 100644 --- a/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unsuited.stderr +++ b/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-unsuited.stderr @@ -1,11 +1,10 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/ordinary-bounds-unsuited.rs:31:33 + --> $DIR/ordinary-bounds-unsuited.rs:18:62 | LL | fn upper_bounds<'a, 'b>(a: Ordinary<'a>, b: Ordinary<'b>) -> impl Trait<'a, 'b> - | -- hidden type `Ordinary<'b>` captures the lifetime `'b` as defined here -... -LL | if condition() { a } else { b } - | ^ + | -- ^^^^^^^^^^^^^^^^^^ + | | + | hidden type `Ordinary<'b>` captures the lifetime `'b` as defined here | help: to declare that the `impl Trait` captures `'b`, you can add an explicit `'b` lifetime bound | diff --git a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.nll.stderr b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.nll.stderr index eb38f84d4af..2f6bd8ff377 100644 --- a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.nll.stderr +++ b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.nll.stderr @@ -1,8 +1,8 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/must_outlive_least_region_or_bound.rs:3:35 + --> $DIR/must_outlive_least_region_or_bound.rs:3:23 | LL | fn elided(x: &i32) -> impl Copy { x } - | ---- ^ + | ---- ^^^^^^^^^ | | | hidden type `&i32` captures the anonymous lifetime defined here | @@ -12,10 +12,10 @@ LL | fn elided(x: &i32) -> impl Copy + '_ { x } | ++++ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/must_outlive_least_region_or_bound.rs:6:44 + --> $DIR/must_outlive_least_region_or_bound.rs:6:32 | LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x } - | -- ^ + | -- ^^^^^^^^^ | | | hidden type `&'a i32` captures the lifetime `'a` as defined here | @@ -67,12 +67,12 @@ LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x } = help: consider replacing `'a` with `'static` error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/must_outlive_least_region_or_bound.rs:34:5 + --> $DIR/must_outlive_least_region_or_bound.rs:33:61 | LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) { - | -- hidden type `[closure@$DIR/must_outlive_least_region_or_bound.rs:34:5: 34:31]` captures the lifetime `'b` as defined here -LL | move |_| println!("{}", y) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | -- ^^^^^^^^^^^^^^^^ + | | + | hidden type `[closure@$DIR/must_outlive_least_region_or_bound.rs:35:5: 35:31]` captures the lifetime `'b` as defined here | help: to declare that the `impl Trait` captures `'b`, you can add an explicit `'b` lifetime bound | @@ -80,10 +80,10 @@ LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32 | ++++ error[E0310]: the parameter type `T` may not live long enough - --> $DIR/must_outlive_least_region_or_bound.rs:39:5 + --> $DIR/must_outlive_least_region_or_bound.rs:38:51 | -LL | x - | ^ +LL | fn ty_param_wont_outlive_static<T:Debug>(x: T) -> impl Debug + 'static { + | ^^^^^^^^^^^^^^^^^^^^ | = help: consider adding an explicit lifetime bound `T: 'static`... diff --git a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.rs b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.rs index 02ea0255912..69d2843ff3f 100644 --- a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.rs +++ b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.rs @@ -31,13 +31,13 @@ fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x } //~ ERRO // Tests that a closure type containing 'b cannot be returned from a type where // only 'a was expected. fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) { - move |_| println!("{}", y) //~^ ERROR: captures lifetime that does not appear in bounds + move |_| println!("{}", y) } fn ty_param_wont_outlive_static<T:Debug>(x: T) -> impl Debug + 'static { - x //~^ ERROR the parameter type `T` may not live long enough + x } fn main() {} diff --git a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr index 77ba0bf9087..07ac0a8db35 100644 --- a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr +++ b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr @@ -1,8 +1,8 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/must_outlive_least_region_or_bound.rs:3:35 + --> $DIR/must_outlive_least_region_or_bound.rs:3:23 | LL | fn elided(x: &i32) -> impl Copy { x } - | ---- ^ + | ---- ^^^^^^^^^ | | | hidden type `&i32` captures the anonymous lifetime defined here | @@ -12,10 +12,10 @@ LL | fn elided(x: &i32) -> impl Copy + '_ { x } | ++++ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/must_outlive_least_region_or_bound.rs:6:44 + --> $DIR/must_outlive_least_region_or_bound.rs:6:32 | LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x } - | -- ^ + | -- ^^^^^^^^^ | | | hidden type `&'a i32` captures the lifetime `'a` as defined here | @@ -28,10 +28,15 @@ error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'sta --> $DIR/must_outlive_least_region_or_bound.rs:9:46 | LL | fn elided2(x: &i32) -> impl Copy + 'static { x } - | ---- ^ ...is used and required to live as long as `'static` here + | ---- ^ ...is used here... | | | this data with an anonymous lifetime `'_`... | +note: ...and is required to live as long as `'static` here + --> $DIR/must_outlive_least_region_or_bound.rs:9:24 + | +LL | fn elided2(x: &i32) -> impl Copy + 'static { x } + | ^^^^^^^^^^^^^^^^^^^ help: consider changing the `impl Trait`'s explicit `'static` bound to the lifetime of argument `x` | LL | fn elided2(x: &i32) -> impl Copy + '_ { x } @@ -45,10 +50,15 @@ error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime --> $DIR/must_outlive_least_region_or_bound.rs:11:55 | LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x } - | ------- ^ ...is used and required to live as long as `'static` here + | ------- ^ ...is used here... | | | this data with lifetime `'a`... | +note: ...and is required to live as long as `'static` here + --> $DIR/must_outlive_least_region_or_bound.rs:11:33 + | +LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x } + | ^^^^^^^^^^^^^^^^^^^ help: consider changing the `impl Trait`'s explicit `'static` bound to the lifetime of argument `x` | LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'a { x } @@ -59,10 +69,10 @@ LL | fn explicit2<'a>(x: &'static i32) -> impl Copy + 'static { x } | ~~~~~~~~~~~~ error[E0621]: explicit lifetime required in the type of `x` - --> $DIR/must_outlive_least_region_or_bound.rs:13:41 + --> $DIR/must_outlive_least_region_or_bound.rs:13:24 | LL | fn foo<'a>(x: &i32) -> impl Copy + 'a { x } - | ---- ^ lifetime `'a` required + | ---- ^^^^^^^^^^^^^^ lifetime `'a` required | | | help: add explicit lifetime `'a` to the type of `x`: `&'a i32` @@ -85,8 +95,13 @@ error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime --> $DIR/must_outlive_least_region_or_bound.rs:29:69 | LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x } - | ------- this data with lifetime `'a`... ^ ...is used and required to live as long as `'static` here + | ------- this data with lifetime `'a`... ^ ...is used here... + | +note: ...and is required to live as long as `'static` here + --> $DIR/must_outlive_least_region_or_bound.rs:29:34 | +LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the `impl Trait`'s explicit `'static` bound to the lifetime of argument `x` | LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'a { x } @@ -97,12 +112,12 @@ LL | fn with_bound<'a>(x: &'static i32) -> impl LifetimeTrait<'a> + 'static { x | ~~~~~~~~~~~~ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/must_outlive_least_region_or_bound.rs:34:5 + --> $DIR/must_outlive_least_region_or_bound.rs:33:61 | LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) { - | -- hidden type `[closure@$DIR/must_outlive_least_region_or_bound.rs:34:5: 34:31]` captures the lifetime `'b` as defined here -LL | move |_| println!("{}", y) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | -- ^^^^^^^^^^^^^^^^ + | | + | hidden type `[closure@$DIR/must_outlive_least_region_or_bound.rs:35:5: 35:31]` captures the lifetime `'b` as defined here | help: to declare that the `impl Trait` captures `'b`, you can add an explicit `'b` lifetime bound | @@ -110,12 +125,12 @@ LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32 | ++++ error[E0310]: the parameter type `T` may not live long enough - --> $DIR/must_outlive_least_region_or_bound.rs:39:5 + --> $DIR/must_outlive_least_region_or_bound.rs:38:51 | LL | fn ty_param_wont_outlive_static<T:Debug>(x: T) -> impl Debug + 'static { - | -- help: consider adding an explicit lifetime bound...: `T: 'static +` -LL | x - | ^ ...so that the type `T` will meet its required lifetime bounds + | -- ^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | | + | help: consider adding an explicit lifetime bound...: `T: 'static +` error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement --> $DIR/must_outlive_least_region_or_bound.rs:16:50 diff --git a/src/test/ui/impl-trait/negative-reasoning.rs b/src/test/ui/impl-trait/negative-reasoning.rs index 70e24a3a9d0..d173fe83fb7 100644 --- a/src/test/ui/impl-trait/negative-reasoning.rs +++ b/src/test/ui/impl-trait/negative-reasoning.rs @@ -17,7 +17,7 @@ impl<T: std::fmt::Debug> AnotherTrait for T {} // This is in error, because we cannot assume that `OpaqueType: !Debug` impl AnotherTrait for D<OpaqueType> { - //~^ ERROR conflicting implementations of trait `AnotherTrait` for type `D<OpaqueType>` + //~^ ERROR conflicting implementations of trait `AnotherTrait` for type `D<impl OpaqueTrait>` } fn main() {} diff --git a/src/test/ui/impl-trait/negative-reasoning.stderr b/src/test/ui/impl-trait/negative-reasoning.stderr index 6b8cc9e7374..e39a8e53f79 100644 --- a/src/test/ui/impl-trait/negative-reasoning.stderr +++ b/src/test/ui/impl-trait/negative-reasoning.stderr @@ -1,13 +1,13 @@ -error[E0119]: conflicting implementations of trait `AnotherTrait` for type `D<OpaqueType>` +error[E0119]: conflicting implementations of trait `AnotherTrait` for type `D<impl OpaqueTrait>` --> $DIR/negative-reasoning.rs:19:1 | LL | impl<T: std::fmt::Debug> AnotherTrait for T {} | ------------------------------------------- first implementation here ... LL | impl AnotherTrait for D<OpaqueType> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D<OpaqueType>` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D<impl OpaqueTrait>` | - = note: upstream crates may add a new impl of trait `std::fmt::Debug` for type `OpaqueType` in future versions + = note: upstream crates may add a new impl of trait `std::fmt::Debug` for type `impl OpaqueTrait` in future versions error: aborting due to previous error diff --git a/src/test/ui/impl-trait/nested_impl_trait.rs b/src/test/ui/impl-trait/nested_impl_trait.rs index 6eac2dece1f..be2c21a7743 100644 --- a/src/test/ui/impl-trait/nested_impl_trait.rs +++ b/src/test/ui/impl-trait/nested_impl_trait.rs @@ -4,7 +4,6 @@ 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 @@ -17,7 +16,6 @@ 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 87ff4ffc4fb..59c7e4d5f4e 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:9:42 + --> $DIR/nested_impl_trait.rs:8: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:13:37 + --> $DIR/nested_impl_trait.rs:12: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:18:44 + --> $DIR/nested_impl_trait.rs:17:44 | LL | fn bad(x: impl Into<u32>) -> impl Into<impl Debug> { x } | ----------^^^^^^^^^^- @@ -35,40 +35,18 @@ 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:9:32 + --> $DIR/nested_impl_trait.rs:8: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:27:42 + --> $DIR/nested_impl_trait.rs:25:42 | LL | fn allowed_in_ret_type() -> impl Fn() -> impl Into<u32> { | ^^^^^^^^^^^^^^ -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 +error: aborting due to 6 previous errors -Some errors have detailed explanations: E0277, E0562, E0666. -For more information about an error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0562, E0666. +For more information about an error, try `rustc --explain E0562`. diff --git a/src/test/ui/impl-trait/object-unsafe-trait-in-return-position-impl-trait.stderr b/src/test/ui/impl-trait/object-unsafe-trait-in-return-position-impl-trait.stderr index b2f7166f0ae..357166d1123 100644 --- a/src/test/ui/impl-trait/object-unsafe-trait-in-return-position-impl-trait.stderr +++ b/src/test/ui/impl-trait/object-unsafe-trait-in-return-position-impl-trait.stderr @@ -2,25 +2,46 @@ error[E0308]: mismatched types --> $DIR/object-unsafe-trait-in-return-position-impl-trait.rs:36:5 | LL | fn can() -> impl NotObjectSafe { - | ------------------ the expected opaque type -... + | ------------------ expected because this return type... +LL | if true { +LL | return A; + | - ...is found to be `A` here +LL | } LL | B | ^ expected struct `A`, found struct `B` | - = note: expected opaque type `impl NotObjectSafe` - found struct `B` + = note: to return `impl Trait`, all returned values must be of the same type + = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits> + = help: if the trait `NotObjectSafe` were object safe, you could return a boxed trait object + = note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types> + = help: you could instead create a new `enum` with a variant for each returned type error[E0308]: mismatched types --> $DIR/object-unsafe-trait-in-return-position-impl-trait.rs:43:5 | LL | fn cat() -> impl ObjectSafe { - | --------------- the expected opaque type -... + | --------------- expected because this return type... +LL | if true { +LL | return A; + | - ...is found to be `A` here +LL | } LL | B | ^ expected struct `A`, found struct `B` | - = note: expected opaque type `impl ObjectSafe` - found struct `B` + = note: to return `impl Trait`, all returned values must be of the same type + = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits> + = note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types> + = help: you could instead create a new `enum` with a variant for each returned type +help: you could change the return type to be a boxed trait object + | +LL | fn cat() -> Box<dyn ObjectSafe> { + | ~~~~~~~ + +help: if you change the return type to expect trait objects, box the returned expressions + | +LL ~ return Box::new(A); +LL | } +LL ~ Box::new(B) + | error: aborting due to 2 previous errors diff --git a/src/test/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs b/src/test/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs index 9f9a6c784e6..fa7664a83ee 100644 --- a/src/test/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs +++ b/src/test/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs @@ -14,10 +14,10 @@ fn bar() -> impl std::fmt::Display { } fn baz() -> impl std::fmt::Display { - if false { //~ ERROR mismatched types + if false { return 0i32; } else { - 1u32 + 1u32 //~ ERROR mismatched types } } @@ -30,9 +30,9 @@ fn qux() -> impl std::fmt::Display { } fn bat() -> impl std::fmt::Display { - match 13 { //~ ERROR mismatched types + match 13 { 0 => return 0i32, - _ => 1u32, + _ => 1u32, //~ ERROR mismatched types } } @@ -45,12 +45,12 @@ fn can() -> impl std::fmt::Display { } fn cat() -> impl std::fmt::Display { - match 13 { //~ ERROR mismatched types + match 13 { 0 => { return 0i32; } _ => { - 1u32 + 1u32 //~ ERROR mismatched types } } } diff --git a/src/test/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.stderr b/src/test/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.stderr index db0d446e559..970abad5c72 100644 --- a/src/test/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.stderr +++ b/src/test/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.stderr @@ -2,40 +2,82 @@ error[E0308]: mismatched types --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:5:5 | LL | fn foo() -> impl std::fmt::Display { - | ---------------------- the expected opaque type -... + | ---------------------- expected because this return type... +LL | if false { +LL | return 0i32; + | ---- ...is found to be `i32` here +LL | } LL | 1u32 | ^^^^ expected `i32`, found `u32` | - = note: expected opaque type `impl std::fmt::Display` - found type `u32` + = note: to return `impl Trait`, all returned values must be of the same type + = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits> + = note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types> + = help: you could instead create a new `enum` with a variant for each returned type +help: you could change the return type to be a boxed trait object + | +LL | fn foo() -> Box<dyn std::fmt::Display> { + | ~~~~~~~ + +help: if you change the return type to expect trait objects, box the returned expressions + | +LL ~ return Box::new(0i32); +LL | } +LL ~ Box::new(1u32) + | error[E0308]: mismatched types --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:12:16 | LL | fn bar() -> impl std::fmt::Display { - | ---------------------- the expected opaque type -... + | ---------------------- expected because this return type... +LL | if false { +LL | return 0i32; + | ---- ...is found to be `i32` here +LL | } else { LL | return 1u32; | ^^^^ expected `i32`, found `u32` | - = note: expected opaque type `impl std::fmt::Display` - found type `u32` + = note: to return `impl Trait`, all returned values must be of the same type + = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits> + = note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types> + = help: you could instead create a new `enum` with a variant for each returned type +help: you could change the return type to be a boxed trait object + | +LL | fn bar() -> Box<dyn std::fmt::Display> { + | ~~~~~~~ + +help: if you change the return type to expect trait objects, box the returned expressions + | +LL ~ return Box::new(0i32); +LL | } else { +LL ~ return Box::new(1u32); + | error[E0308]: mismatched types - --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:17:5 + --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:20:9 | -LL | fn baz() -> impl std::fmt::Display { - | ---------------------- the expected opaque type -LL | / if false { -LL | | return 0i32; -LL | | } else { -LL | | 1u32 -LL | | } - | |_____^ expected `i32`, found `u32` +LL | fn baz() -> impl std::fmt::Display { + | ---------------------- expected because this return type... +LL | if false { +LL | return 0i32; + | ---- ...is found to be `i32` here +LL | } else { +LL | 1u32 + | ^^^^ expected `i32`, found `u32` + | + = note: to return `impl Trait`, all returned values must be of the same type + = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits> + = note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types> + = help: you could instead create a new `enum` with a variant for each returned type +help: you could change the return type to be a boxed trait object + | +LL | fn baz() -> Box<dyn std::fmt::Display> { + | ~~~~~~~ + +help: if you change the return type to expect trait objects, box the returned expressions + | +LL ~ return Box::new(0i32); +LL | } else { +LL ~ Box::new(1u32) | - = note: expected opaque type `impl std::fmt::Display` - found type `u32` error[E0308]: `if` and `else` have incompatible types --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:28:9 @@ -61,50 +103,87 @@ LL ~ Box::new(1u32) | error[E0308]: mismatched types - --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:33:5 + --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:35:14 | -LL | fn bat() -> impl std::fmt::Display { - | ---------------------- the expected opaque type -LL | / match 13 { -LL | | 0 => return 0i32, -LL | | _ => 1u32, -LL | | } - | |_____^ expected `i32`, found `u32` +LL | fn bat() -> impl std::fmt::Display { + | ---------------------- expected because this return type... +LL | match 13 { +LL | 0 => return 0i32, + | ---- ...is found to be `i32` here +LL | _ => 1u32, + | ^^^^ expected `i32`, found `u32` + | + = note: to return `impl Trait`, all returned values must be of the same type + = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits> + = note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types> + = help: you could instead create a new `enum` with a variant for each returned type +help: you could change the return type to be a boxed trait object + | +LL | fn bat() -> Box<dyn std::fmt::Display> { + | ~~~~~~~ + +help: if you change the return type to expect trait objects, box the returned expressions + | +LL ~ 0 => return Box::new(0i32), +LL ~ _ => Box::new(1u32), | - = note: expected opaque type `impl std::fmt::Display` - found type `u32` error[E0308]: mismatched types --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:40:5 | LL | fn can() -> impl std::fmt::Display { - | ---------------------- the expected opaque type + | ---------------------- expected because this return type... LL | / match 13 { LL | | 0 => return 0i32, + | | ---- ...is found to be `i32` here LL | | 1 => 1u32, LL | | _ => 2u32, LL | | } | |_____^ expected `i32`, found `u32` | - = note: expected opaque type `impl std::fmt::Display` - found type `u32` + = note: to return `impl Trait`, all returned values must be of the same type + = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits> + = note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types> + = help: you could instead create a new `enum` with a variant for each returned type +help: you could change the return type to be a boxed trait object + | +LL | fn can() -> Box<dyn std::fmt::Display> { + | ~~~~~~~ + +help: if you change the return type to expect trait objects, box the returned expressions + | +LL ~ Box::new(match 13 { +LL ~ 0 => return Box::new(0i32), +LL | 1 => 1u32, +LL | _ => 2u32, +LL ~ }) + | error[E0308]: mismatched types - --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:48:5 + --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:53:13 | -LL | fn cat() -> impl std::fmt::Display { - | ---------------------- the expected opaque type -LL | / match 13 { -LL | | 0 => { -LL | | return 0i32; -LL | | } -... | -LL | | } -LL | | } - | |_____^ expected `i32`, found `u32` +LL | fn cat() -> impl std::fmt::Display { + | ---------------------- expected because this return type... +... +LL | return 0i32; + | ---- ...is found to be `i32` here +... +LL | 1u32 + | ^^^^ expected `i32`, found `u32` + | + = note: to return `impl Trait`, all returned values must be of the same type + = note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits> + = note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types> + = help: you could instead create a new `enum` with a variant for each returned type +help: you could change the return type to be a boxed trait object + | +LL | fn cat() -> Box<dyn std::fmt::Display> { + | ~~~~~~~ + +help: if you change the return type to expect trait objects, box the returned expressions + | +LL ~ return Box::new(0i32); +LL | } +LL | _ => { +LL ~ Box::new(1u32) | - = note: expected opaque type `impl std::fmt::Display` - found type `u32` error[E0308]: `match` arms have incompatible types --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:61:14 @@ -117,6 +196,16 @@ LL | | 1 => 1u32, LL | | _ => 2u32, LL | | } | |_____- `match` arms have incompatible types + | +help: you could change the return type to be a boxed trait object + | +LL | fn dog() -> Box<dyn std::fmt::Display> { + | ~~~~~~~ + +help: if you change the return type to expect trait objects, box the returned expressions + | +LL ~ 0 => Box::new(0i32), +LL ~ 1 => Box::new(1u32), + | error[E0308]: `if` and `else` have incompatible types --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:97:9 @@ -129,6 +218,17 @@ LL | | 1u32 | | ^^^^ expected `i32`, found `u32` LL | | } | |_____- `if` and `else` have incompatible types + | +help: you could change the return type to be a boxed trait object + | +LL | fn apt() -> Box<dyn std::fmt::Display> { + | ~~~~~~~ + +help: if you change the return type to expect trait objects, box the returned expressions + | +LL ~ Box::new(0i32) +LL | } else { +LL ~ Box::new(1u32) + | error[E0746]: return type cannot have an unboxed trait object --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:66:13 diff --git a/src/test/ui/impl-trait/projection-mismatch-in-impl-where-clause.rs b/src/test/ui/impl-trait/projection-mismatch-in-impl-where-clause.rs index 2e7cb21592c..b4fd6b3e743 100644 --- a/src/test/ui/impl-trait/projection-mismatch-in-impl-where-clause.rs +++ b/src/test/ui/impl-trait/projection-mismatch-in-impl-where-clause.rs @@ -11,8 +11,8 @@ pub trait Test {} impl<T> Test for T where T: Super<Assoc = ()> {} fn test() -> impl Test { - () //~^ERROR type mismatch resolving `<() as Super>::Assoc == ()` + () } fn main() { diff --git a/src/test/ui/impl-trait/projection-mismatch-in-impl-where-clause.stderr b/src/test/ui/impl-trait/projection-mismatch-in-impl-where-clause.stderr index 5ef1e9abef6..65daabe419d 100644 --- a/src/test/ui/impl-trait/projection-mismatch-in-impl-where-clause.stderr +++ b/src/test/ui/impl-trait/projection-mismatch-in-impl-where-clause.stderr @@ -1,10 +1,10 @@ error[E0271]: type mismatch resolving `<() as Super>::Assoc == ()` - --> $DIR/projection-mismatch-in-impl-where-clause.rs:14:5 + --> $DIR/projection-mismatch-in-impl-where-clause.rs:13:14 | -LL | () - | ^^ type mismatch resolving `<() as Super>::Assoc == ()` +LL | fn test() -> impl Test { + | ^^^^^^^^^ type mismatch resolving `<() as Super>::Assoc == ()` | -note: expected this to be `u8` +note: expected this to be `()` --> $DIR/projection-mismatch-in-impl-where-clause.rs:6:18 | LL | type Assoc = u8; diff --git a/src/test/ui/impl-trait/question_mark.rs b/src/test/ui/impl-trait/question_mark.rs deleted file mode 100644 index 211f7972dbc..00000000000 --- a/src/test/ui/impl-trait/question_mark.rs +++ /dev/null @@ -1,13 +0,0 @@ -// check-pass - -fn foo() -> impl MyTrait { - panic!(); - MyStruct -} - -struct MyStruct; -trait MyTrait {} - -impl MyTrait for MyStruct {} - -fn main() {} diff --git a/src/test/ui/impl-trait/recursive-impl-trait-type-direct.rs b/src/test/ui/impl-trait/recursive-impl-trait-type-direct.rs index 540a280f0a3..3cc53744097 100644 --- a/src/test/ui/impl-trait/recursive-impl-trait-type-direct.rs +++ b/src/test/ui/impl-trait/recursive-impl-trait-type-direct.rs @@ -1,8 +1,9 @@ -// check-pass +// Test that an `impl Trait` type that expands to itself is an error. #![allow(unconditional_recursion)] fn test() -> impl Sized { + //~^ ERROR E0720 test() } diff --git a/src/test/ui/impl-trait/recursive-impl-trait-type-direct.stderr b/src/test/ui/impl-trait/recursive-impl-trait-type-direct.stderr new file mode 100644 index 00000000000..5a3027ec751 --- /dev/null +++ b/src/test/ui/impl-trait/recursive-impl-trait-type-direct.stderr @@ -0,0 +1,12 @@ +error[E0720]: cannot resolve opaque type + --> $DIR/recursive-impl-trait-type-direct.rs:5:14 + | +LL | fn test() -> impl Sized { + | ^^^^^^^^^^ recursive opaque type +LL | +LL | test() + | ------ returning here with type `impl Sized` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0720`. diff --git a/src/test/ui/impl-trait/recursive-impl-trait-type-indirect.rs b/src/test/ui/impl-trait/recursive-impl-trait-type-indirect.rs index ffc0cd9d10c..e3c621f0c57 100644 --- a/src/test/ui/impl-trait/recursive-impl-trait-type-indirect.rs +++ b/src/test/ui/impl-trait/recursive-impl-trait-type-indirect.rs @@ -5,7 +5,7 @@ #![allow(unconditional_recursion)] fn option(i: i32) -> impl Sized { - //~^ ERROR cannot resolve opaque type + //~^ ERROR if i < 0 { None } else { Some((option(i - 1), i)) } } diff --git a/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.rs b/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.rs deleted file mode 100644 index a60e34c17b6..00000000000 --- a/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.rs +++ /dev/null @@ -1,29 +0,0 @@ -#![feature(type_alias_impl_trait)] - -mod a { - type Foo = impl PartialEq<(Foo, i32)>; - //~^ ERROR unconstrained opaque type - - struct Bar; - - impl PartialEq<(Bar, i32)> for Bar { - fn eq(&self, _other: &(Foo, i32)) -> bool { - true - } - } -} - -mod b { - type Foo = impl PartialEq<(Foo, i32)>; - //~^ ERROR unconstrained opaque type - - struct Bar; - - impl PartialEq<(Foo, i32)> for Bar { - fn eq(&self, _other: &(Bar, i32)) -> bool { - true - } - } -} - -fn main() {} diff --git a/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr b/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr deleted file mode 100644 index eae7d38d116..00000000000 --- a/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error: unconstrained opaque type - --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:4:16 - | -LL | type Foo = impl PartialEq<(Foo, i32)>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `Foo` must be used in combination with a concrete type within the same module - -error: unconstrained opaque type - --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:17:16 - | -LL | type Foo = impl PartialEq<(Foo, i32)>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `Foo` must be used in combination with a concrete type within the same module - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration.rs b/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration.rs deleted file mode 100644 index bdabc13c36a..00000000000 --- a/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration.rs +++ /dev/null @@ -1,37 +0,0 @@ -// check-pass - -#![feature(type_alias_impl_trait)] - -mod direct { - type Foo = impl PartialEq<(Foo, i32)>; - - struct Bar; - - impl PartialEq<(Foo, i32)> for Bar { - fn eq(&self, _other: &(Foo, i32)) -> bool { - true - } - } - - fn foo() -> Foo { - Bar - } -} - -mod indirect { - type Foo = impl PartialEq<(Foo, i32)>; - - struct Bar; - - impl PartialEq<(Bar, i32)> for Bar { - fn eq(&self, _other: &(Bar, i32)) -> bool { - true - } - } - - fn foo() -> Foo { - Bar - } -} - -fn main() {} diff --git a/src/test/ui/impl-trait/region-escape-via-bound.rs b/src/test/ui/impl-trait/region-escape-via-bound.rs index 18e3a5bcaa4..29243699e44 100644 --- a/src/test/ui/impl-trait/region-escape-via-bound.rs +++ b/src/test/ui/impl-trait/region-escape-via-bound.rs @@ -13,10 +13,10 @@ trait Trait<'a> { } impl Trait<'b> for Cell<&'a u32> { } fn foo(x: Cell<&'x u32>) -> impl Trait<'y> + //~^ ERROR hidden type for `impl Trait` captures lifetime that does not appear in bounds [E0700] where 'x: 'y { x - //~^ ERROR hidden type for `impl Trait` captures lifetime that does not appear in bounds [E0700] } fn main() { } diff --git a/src/test/ui/impl-trait/region-escape-via-bound.stderr b/src/test/ui/impl-trait/region-escape-via-bound.stderr index 690d049ec8f..cf854f67d04 100644 --- a/src/test/ui/impl-trait/region-escape-via-bound.stderr +++ b/src/test/ui/impl-trait/region-escape-via-bound.stderr @@ -1,11 +1,11 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/region-escape-via-bound.rs:18:5 + --> $DIR/region-escape-via-bound.rs:15:29 | +LL | fn foo(x: Cell<&'x u32>) -> impl Trait<'y> + | ^^^^^^^^^^^^^^ +LL | LL | where 'x: 'y | -- hidden type `Cell<&'x u32>` captures the lifetime `'x` as defined here -LL | { -LL | x - | ^ | help: to declare that the `impl Trait` captures `'x`, you can add an explicit `'x` lifetime bound | diff --git a/src/test/ui/impl-trait/static-return-lifetime-infered.rs b/src/test/ui/impl-trait/static-return-lifetime-infered.rs index f940c1949d0..d792c6eafb3 100644 --- a/src/test/ui/impl-trait/static-return-lifetime-infered.rs +++ b/src/test/ui/impl-trait/static-return-lifetime-infered.rs @@ -4,14 +4,14 @@ struct A { impl A { fn iter_values_anon(&self) -> impl Iterator<Item=u32> { - self.x.iter().map(|a| a.0) //~^ ERROR: captures lifetime that does not appear in bounds //~| ERROR: captures lifetime that does not appear in bounds + self.x.iter().map(|a| a.0) } fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> { - self.x.iter().map(|a| a.0) //~^ ERROR: captures lifetime that does not appear in bounds //~| ERROR: captures lifetime that does not appear in bounds + self.x.iter().map(|a| a.0) } } diff --git a/src/test/ui/impl-trait/static-return-lifetime-infered.stderr b/src/test/ui/impl-trait/static-return-lifetime-infered.stderr index bc8e39f9c50..7424da76182 100644 --- a/src/test/ui/impl-trait/static-return-lifetime-infered.stderr +++ b/src/test/ui/impl-trait/static-return-lifetime-infered.stderr @@ -1,10 +1,10 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/static-return-lifetime-infered.rs:7:9 + --> $DIR/static-return-lifetime-infered.rs:6:35 | LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> { - | ----- hidden type `Map<std::slice::Iter<'_, (u32, u32)>, [closure@$DIR/static-return-lifetime-infered.rs:7:27: 7:34]>` captures the anonymous lifetime defined here -LL | self.x.iter().map(|a| a.0) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ----- ^^^^^^^^^^^^^^^^^^^^^^^ + | | + | hidden type `Map<std::slice::Iter<'_, (u32, u32)>, [closure@$DIR/static-return-lifetime-infered.rs:9:27: 9:34]>` captures the anonymous lifetime defined here | help: to declare that the `impl Trait` captures `'_`, you can add an explicit `'_` lifetime bound | @@ -12,12 +12,12 @@ LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> + '_ { | ++++ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/static-return-lifetime-infered.rs:7:9 + --> $DIR/static-return-lifetime-infered.rs:6:35 | LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> { - | ----- hidden type `Map<std::slice::Iter<'_, (u32, u32)>, [closure@$DIR/static-return-lifetime-infered.rs:7:27: 7:34]>` captures the anonymous lifetime defined here -LL | self.x.iter().map(|a| a.0) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ----- ^^^^^^^^^^^^^^^^^^^^^^^ + | | + | hidden type `Map<std::slice::Iter<'_, (u32, u32)>, [closure@$DIR/static-return-lifetime-infered.rs:9:27: 9:34]>` captures the anonymous lifetime defined here | help: to declare that the `impl Trait` captures `'_`, you can add an explicit `'_` lifetime bound | @@ -25,12 +25,12 @@ LL | fn iter_values_anon(&self) -> impl Iterator<Item=u32> + '_ { | ++++ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/static-return-lifetime-infered.rs:12:9 + --> $DIR/static-return-lifetime-infered.rs:11:37 | LL | fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> { - | -- hidden type `Map<std::slice::Iter<'a, (u32, u32)>, [closure@$DIR/static-return-lifetime-infered.rs:12:27: 12:34]>` captures the lifetime `'a` as defined here -LL | self.x.iter().map(|a| a.0) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | -- ^^^^^^^^^^^^^^^^^^^^^^^ + | | + | hidden type `Map<std::slice::Iter<'a, (u32, u32)>, [closure@$DIR/static-return-lifetime-infered.rs:14:27: 14:34]>` captures the lifetime `'a` as defined here | help: to declare that the `impl Trait` captures `'a`, you can add an explicit `'a` lifetime bound | @@ -38,12 +38,12 @@ LL | fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> + 'a { | ++++ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/static-return-lifetime-infered.rs:12:9 + --> $DIR/static-return-lifetime-infered.rs:11:37 | LL | fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> { - | -- hidden type `Map<std::slice::Iter<'a, (u32, u32)>, [closure@$DIR/static-return-lifetime-infered.rs:12:27: 12:34]>` captures the lifetime `'a` as defined here -LL | self.x.iter().map(|a| a.0) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | -- ^^^^^^^^^^^^^^^^^^^^^^^ + | | + | hidden type `Map<std::slice::Iter<'a, (u32, u32)>, [closure@$DIR/static-return-lifetime-infered.rs:14:27: 14:34]>` captures the lifetime `'a` as defined here | help: to declare that the `impl Trait` captures `'a`, you can add an explicit `'a` lifetime bound | diff --git a/src/test/ui/impl-trait/two_tait_defining_each_other.rs b/src/test/ui/impl-trait/two_tait_defining_each_other.rs deleted file mode 100644 index 6eb2a11b22c..00000000000 --- a/src/test/ui/impl-trait/two_tait_defining_each_other.rs +++ /dev/null @@ -1,19 +0,0 @@ -#![feature(type_alias_impl_trait)] - -type A = impl Foo; -type B = impl Foo; - -trait Foo {} - -fn muh(x: A) -> B { - if false { - return Bar; // B's hidden type is Bar - } - x // A's hidden type is `Bar`, because all the hidden types of `B` are compared with each other - //~^ ERROR opaque type's hidden type cannot be another opaque type -} - -struct Bar; -impl Foo for Bar {} - -fn main() {} diff --git a/src/test/ui/impl-trait/two_tait_defining_each_other.stderr b/src/test/ui/impl-trait/two_tait_defining_each_other.stderr deleted file mode 100644 index 1a42ac525a6..00000000000 --- a/src/test/ui/impl-trait/two_tait_defining_each_other.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error: opaque type's hidden type cannot be another opaque type from the same scope - --> $DIR/two_tait_defining_each_other.rs:12:5 - | -LL | x // A's hidden type is `Bar`, because all the hidden types of `B` are compared with each other - | ^ one of the two opaque types used here has to be outside its defining scope - | -note: opaque type whose hidden type is being assigned - --> $DIR/two_tait_defining_each_other.rs:4:10 - | -LL | type B = impl Foo; - | ^^^^^^^^ -note: opaque type being used as hidden type - --> $DIR/two_tait_defining_each_other.rs:3:10 - | -LL | type A = impl Foo; - | ^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/impl-trait/two_tait_defining_each_other2.rs b/src/test/ui/impl-trait/two_tait_defining_each_other2.rs deleted file mode 100644 index 3b16d0f5e04..00000000000 --- a/src/test/ui/impl-trait/two_tait_defining_each_other2.rs +++ /dev/null @@ -1,16 +0,0 @@ -#![feature(type_alias_impl_trait)] - -type A = impl Foo; -type B = impl Foo; - -trait Foo {} - -fn muh(x: A) -> B { - x // B's hidden type is A (opaquely) - //~^ ERROR opaque type's hidden type cannot be another opaque type -} - -struct Bar; -impl Foo for Bar {} - -fn main() {} diff --git a/src/test/ui/impl-trait/two_tait_defining_each_other2.stderr b/src/test/ui/impl-trait/two_tait_defining_each_other2.stderr deleted file mode 100644 index ef2089a6c5b..00000000000 --- a/src/test/ui/impl-trait/two_tait_defining_each_other2.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error: opaque type's hidden type cannot be another opaque type from the same scope - --> $DIR/two_tait_defining_each_other2.rs:9:5 - | -LL | x // B's hidden type is A (opaquely) - | ^ one of the two opaque types used here has to be outside its defining scope - | -note: opaque type whose hidden type is being assigned - --> $DIR/two_tait_defining_each_other2.rs:4:10 - | -LL | type B = impl Foo; - | ^^^^^^^^ -note: opaque type being used as hidden type - --> $DIR/two_tait_defining_each_other2.rs:3:10 - | -LL | type A = impl Foo; - | ^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/impl-trait/two_tait_defining_each_other3.rs b/src/test/ui/impl-trait/two_tait_defining_each_other3.rs deleted file mode 100644 index 37f8ae1b84b..00000000000 --- a/src/test/ui/impl-trait/two_tait_defining_each_other3.rs +++ /dev/null @@ -1,19 +0,0 @@ -#![feature(type_alias_impl_trait)] - -type A = impl Foo; -type B = impl Foo; - -trait Foo {} - -fn muh(x: A) -> B { - if false { - return x; // B's hidden type is A (opaquely) - //~^ ERROR opaque type's hidden type cannot be another opaque type - } - Bar // A's hidden type is `Bar`, because all the return types are compared with each other -} - -struct Bar; -impl Foo for Bar {} - -fn main() {} diff --git a/src/test/ui/impl-trait/two_tait_defining_each_other3.stderr b/src/test/ui/impl-trait/two_tait_defining_each_other3.stderr deleted file mode 100644 index b06dc16d5e7..00000000000 --- a/src/test/ui/impl-trait/two_tait_defining_each_other3.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error: opaque type's hidden type cannot be another opaque type from the same scope - --> $DIR/two_tait_defining_each_other3.rs:10:16 - | -LL | return x; // B's hidden type is A (opaquely) - | ^ one of the two opaque types used here has to be outside its defining scope - | -note: opaque type whose hidden type is being assigned - --> $DIR/two_tait_defining_each_other3.rs:4:10 - | -LL | type B = impl Foo; - | ^^^^^^^^ -note: opaque type being used as hidden type - --> $DIR/two_tait_defining_each_other3.rs:3:10 - | -LL | type A = impl Foo; - | ^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/impl-trait/type_parameters_captured.nll.stderr b/src/test/ui/impl-trait/type_parameters_captured.nll.stderr index e0b77544d43..039cb62f866 100644 --- a/src/test/ui/impl-trait/type_parameters_captured.nll.stderr +++ b/src/test/ui/impl-trait/type_parameters_captured.nll.stderr @@ -1,8 +1,8 @@ error[E0310]: the parameter type `T` may not live long enough - --> $DIR/type_parameters_captured.rs:8:5 + --> $DIR/type_parameters_captured.rs:7:20 | -LL | x - | ^ +LL | fn foo<T>(x: T) -> impl Any + 'static { + | ^^^^^^^^^^^^^^^^^^ | = help: consider adding an explicit lifetime bound `T: 'static`... diff --git a/src/test/ui/impl-trait/type_parameters_captured.rs b/src/test/ui/impl-trait/type_parameters_captured.rs index 81ee7d3f8a5..6c9c9d4a42a 100644 --- a/src/test/ui/impl-trait/type_parameters_captured.rs +++ b/src/test/ui/impl-trait/type_parameters_captured.rs @@ -5,8 +5,8 @@ impl<T> Any for T {} // Check that type parameters are captured and not considered 'static fn foo<T>(x: T) -> impl Any + 'static { - x //~^ ERROR the parameter type `T` may not live long enough + x } fn main() {} diff --git a/src/test/ui/impl-trait/type_parameters_captured.stderr b/src/test/ui/impl-trait/type_parameters_captured.stderr index c0de4f4b4a0..40e50b9922f 100644 --- a/src/test/ui/impl-trait/type_parameters_captured.stderr +++ b/src/test/ui/impl-trait/type_parameters_captured.stderr @@ -1,10 +1,10 @@ error[E0310]: the parameter type `T` may not live long enough - --> $DIR/type_parameters_captured.rs:8:5 + --> $DIR/type_parameters_captured.rs:7:20 | LL | fn foo<T>(x: T) -> impl Any + 'static { - | - help: consider adding an explicit lifetime bound...: `T: 'static` -LL | x - | ^ ...so that the type `T` will meet its required lifetime bounds + | - ^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | | + | help: consider adding an explicit lifetime bound...: `T: 'static` error: aborting due to previous error diff --git a/src/test/ui/impl-trait/where-allowed-2.rs b/src/test/ui/impl-trait/where-allowed-2.rs index d5a87b5d468..462508f306e 100644 --- a/src/test/ui/impl-trait/where-allowed-2.rs +++ b/src/test/ui/impl-trait/where-allowed-2.rs @@ -1,7 +1,8 @@ +//! Ideally, these tests would go in `where-allowed.rs`, but we bail out +//! too early to display them. use std::fmt::Debug; -// check-pass - -fn in_adt_in_return() -> Vec<impl Debug> { panic!() } +// Disallowed +fn in_adt_in_return() -> Vec<impl Debug> { panic!() } //~ ERROR cannot resolve opaque type fn main() {} diff --git a/src/test/ui/impl-trait/where-allowed-2.stderr b/src/test/ui/impl-trait/where-allowed-2.stderr new file mode 100644 index 00000000000..b8e06725cbc --- /dev/null +++ b/src/test/ui/impl-trait/where-allowed-2.stderr @@ -0,0 +1,13 @@ +error[E0720]: cannot resolve opaque type + --> $DIR/where-allowed-2.rs:6:30 + | +LL | fn in_adt_in_return() -> Vec<impl Debug> { panic!() } + | ^^^^^^^^^^ -------- this returned value is of `!` type + | | + | cannot resolve opaque type + | + = help: this error will resolve once the item's body returns a concrete type + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0720`. diff --git a/src/test/ui/issues-71798.rs b/src/test/ui/issues-71798.rs index 89e07037afd..fecba721ac9 100644 --- a/src/test/ui/issues-71798.rs +++ b/src/test/ui/issues-71798.rs @@ -1,6 +1,5 @@ fn test_ref(x: &u32) -> impl std::future::Future<Output = u32> + '_ { - *x - //~^ ERROR `u32` is not a future + *x //~^ ERROR `u32` is not a future } fn main() { diff --git a/src/test/ui/issues-71798.stderr b/src/test/ui/issues-71798.stderr index 1efa886436e..bc4dc9ebf9e 100644 --- a/src/test/ui/issues-71798.stderr +++ b/src/test/ui/issues-71798.stderr @@ -1,14 +1,14 @@ error[E0425]: cannot find value `u` in this scope - --> $DIR/issues-71798.rs:7:24 + --> $DIR/issues-71798.rs:6:24 | LL | let _ = test_ref & u; | ^ not found in this scope error[E0277]: `u32` is not a future - --> $DIR/issues-71798.rs:2:5 + --> $DIR/issues-71798.rs:1:25 | -LL | *x - | ^^ `u32` is not a future +LL | fn test_ref(x: &u32) -> impl std::future::Future<Output = u32> + '_ { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `u32` is not a future | = help: the trait `Future` is not implemented for `u32` = note: u32 must be a future or must implement `IntoFuture` to be awaited diff --git a/src/test/ui/lang-items/lang-item-missing-generator.stderr b/src/test/ui/lang-items/lang-item-missing-generator.stderr index e5f26822f26..fa13bf0b127 100644 --- a/src/test/ui/lang-items/lang-item-missing-generator.stderr +++ b/src/test/ui/lang-items/lang-item-missing-generator.stderr @@ -1,8 +1,8 @@ error: requires `generator` lang_item - --> $DIR/lang-item-missing-generator.rs:15:22 + --> $DIR/lang-item-missing-generator.rs:15:17 | LL | pub fn abc() -> impl FnOnce(f32) { - | ^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/lazy-type-alias-impl-trait/freeze_cycle.rs b/src/test/ui/lazy-type-alias-impl-trait/freeze_cycle.rs deleted file mode 100644 index 84bfa2d8487..00000000000 --- a/src/test/ui/lazy-type-alias-impl-trait/freeze_cycle.rs +++ /dev/null @@ -1,46 +0,0 @@ -// check-pass - -#![feature(gen_future, generator_trait, negative_impls, const_fn_trait_bound, const_impl_trait)] - -use std::ops::{Generator, GeneratorState}; -use std::task::{Poll, Context}; -use std::future::{Future}; -use std::ptr::NonNull; -use std::pin::Pin; - -fn main() {} - -#[derive(Debug, Copy, Clone)] -pub struct ResumeTy(NonNull<Context<'static>>); - -unsafe impl Send for ResumeTy {} - -unsafe impl Sync for ResumeTy {} - -pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return> -where - T: Generator<ResumeTy, Yield = ()>, -{ - struct GenFuture<T: Generator<ResumeTy, Yield = ()>>(T); - - // We rely on the fact that async/await futures are immovable in order to create - // self-referential borrows in the underlying generator. - impl<T: Generator<ResumeTy, Yield = ()>> !Unpin for GenFuture<T> {} - - impl<T: Generator<ResumeTy, Yield = ()>> Future for GenFuture<T> { - type Output = T::Return; - fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { - // SAFETY: Safe because we're !Unpin + !Drop, and this is just a field projection. - let gen = unsafe { Pin::map_unchecked_mut(self, |s| &mut s.0) }; - - // Resume the generator, turning the `&mut Context` into a `NonNull` raw pointer. The - // `.await` lowering will safely cast that back to a `&mut Context`. - match gen.resume(ResumeTy(NonNull::from(cx).cast::<Context<'static>>())) { - GeneratorState::Yielded(()) => Poll::Pending, - GeneratorState::Complete(x) => Poll::Ready(x), - } - } - } - - GenFuture(gen) -} diff --git a/src/test/ui/lazy-type-alias-impl-trait/infer_cross_function.rs b/src/test/ui/lazy-type-alias-impl-trait/infer_cross_function.rs deleted file mode 100644 index d07d732c785..00000000000 --- a/src/test/ui/lazy-type-alias-impl-trait/infer_cross_function.rs +++ /dev/null @@ -1,27 +0,0 @@ -// check-pass - -fn main() {} - -trait Reader {} - -struct Unit<R>(R); -struct ResDwarf<R>(R); - -struct Context<R: Reader> { - dwarf: ResDwarf<R>, -} - -struct Range; - -struct ResUnit<R>(R); - -impl<R: Reader + 'static> Context<R> { - fn find_dwarf_unit(&self, probe: u64) -> Option<&Unit<R>> { - let x = self.find_units(probe); - None - } - - fn find_units(&self, probe: u64) -> impl Iterator<Item = &ResUnit<R>> { - std::iter::empty() - } -} diff --git a/src/test/ui/lazy-type-alias-impl-trait/lifetime_inference.rs b/src/test/ui/lazy-type-alias-impl-trait/lifetime_inference.rs deleted file mode 100644 index f75a88aa8f0..00000000000 --- a/src/test/ui/lazy-type-alias-impl-trait/lifetime_inference.rs +++ /dev/null @@ -1,7 +0,0 @@ -// check-pass - -fn main() {} - -fn nth<I: Iterator>(iter: &mut I, step: usize) -> impl FnMut() -> Option<I::Item> + '_ { - move || iter.nth(step) -} diff --git a/src/test/ui/lazy-type-alias-impl-trait/nested.rs b/src/test/ui/lazy-type-alias-impl-trait/nested.rs deleted file mode 100644 index f8291112739..00000000000 --- a/src/test/ui/lazy-type-alias-impl-trait/nested.rs +++ /dev/null @@ -1,23 +0,0 @@ -// check-pass - -fn main() {} - -struct RawTableInner<A> { - alloc: A, -} - -impl<A> RawTableInner<A> { - fn prepare_resize( - self, - ) -> ScopeGuard<Self, impl FnMut(&mut Self)> { - ScopeGuard { dropfn: move |self_| {}, value: self, } - } -} - -pub struct ScopeGuard<T, F> -where - F: FnMut(&mut T), -{ - dropfn: F, - value: T, -} diff --git a/src/test/ui/lazy-type-alias-impl-trait/opaque_vs_opaque.rs b/src/test/ui/lazy-type-alias-impl-trait/opaque_vs_opaque.rs deleted file mode 100644 index 8d03b5158d6..00000000000 --- a/src/test/ui/lazy-type-alias-impl-trait/opaque_vs_opaque.rs +++ /dev/null @@ -1,10 +0,0 @@ -// check-pass - -fn main() {} - -fn filter_fold<T, Acc, PRED: FnMut(&T) -> bool, FOLD: FnMut(Acc, T) -> Acc>( - mut predicate: PRED, - mut fold: FOLD, -) -> impl FnMut(Acc, T) -> Acc { - move |acc, item| if predicate(&item) { fold(acc, item) } else { acc } -} diff --git a/src/test/ui/lazy-type-alias-impl-trait/unsized_sized_opaque.rs b/src/test/ui/lazy-type-alias-impl-trait/unsized_sized_opaque.rs deleted file mode 100644 index 00710149823..00000000000 --- a/src/test/ui/lazy-type-alias-impl-trait/unsized_sized_opaque.rs +++ /dev/null @@ -1,16 +0,0 @@ -// check-pass - -fn main() {} - -pub struct PairSlices<'a, 'b, T> { - pub(crate) a0: &'a mut [T], - pub(crate) a1: &'a mut [T], - pub(crate) b0: &'b [T], - pub(crate) b1: &'b [T], -} - -impl<'a, 'b, T> PairSlices<'a, 'b, T> { - pub fn remainder(self) -> impl Iterator<Item = &'b [T]> { - IntoIterator::into_iter([self.b0, self.b1]) - } -} diff --git a/src/test/ui/lifetimes/lifetime-elision-return-type-trait.rs b/src/test/ui/lifetimes/lifetime-elision-return-type-trait.rs index fd49b4842a7..ea0d0ccbc55 100644 --- a/src/test/ui/lifetimes/lifetime-elision-return-type-trait.rs +++ b/src/test/ui/lifetimes/lifetime-elision-return-type-trait.rs @@ -6,8 +6,8 @@ trait Future { use std::error::Error; fn foo() -> impl Future<Item=(), Error=Box<dyn Error>> { +//~^ ERROR not satisfied Ok(()) - //~^ ERROR not satisfied } fn main() {} diff --git a/src/test/ui/lifetimes/lifetime-elision-return-type-trait.stderr b/src/test/ui/lifetimes/lifetime-elision-return-type-trait.stderr index 7f8384d7eca..ef1127c59ac 100644 --- a/src/test/ui/lifetimes/lifetime-elision-return-type-trait.stderr +++ b/src/test/ui/lifetimes/lifetime-elision-return-type-trait.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `Result<(), _>: Future` is not satisfied - --> $DIR/lifetime-elision-return-type-trait.rs:9:5 + --> $DIR/lifetime-elision-return-type-trait.rs:8:13 | -LL | Ok(()) - | ^^^^^^ the trait `Future` is not implemented for `Result<(), _>` +LL | fn foo() -> impl Future<Item=(), Error=Box<dyn Error>> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Future` is not implemented for `Result<(), _>` error: aborting due to previous error diff --git a/src/test/ui/lint/inline-trait-and-foreign-items.rs b/src/test/ui/lint/inline-trait-and-foreign-items.rs index 13dab7ed954..6321b3c76e4 100644 --- a/src/test/ui/lint/inline-trait-and-foreign-items.rs +++ b/src/test/ui/lint/inline-trait-and-foreign-items.rs @@ -23,7 +23,7 @@ impl Trait for () { type T = Self; #[inline] //~ ERROR attribute should be applied to function or closure - type U = impl Trait; //~ ERROR unconstrained opaque type + type U = impl Trait; //~ ERROR could not find defining uses } extern "C" { diff --git a/src/test/ui/lint/inline-trait-and-foreign-items.stderr b/src/test/ui/lint/inline-trait-and-foreign-items.stderr index fc7e89e4f4c..6ac884c12ce 100644 --- a/src/test/ui/lint/inline-trait-and-foreign-items.stderr +++ b/src/test/ui/lint/inline-trait-and-foreign-items.stderr @@ -61,13 +61,11 @@ LL | #[inline] LL | type T; | ------- not a function or closure -error: unconstrained opaque type +error: could not find defining uses --> $DIR/inline-trait-and-foreign-items.rs:26:14 | LL | type U = impl Trait; | ^^^^^^^^^^ - | - = note: `U` must be used in combination with a concrete type within the same module error: aborting due to 6 previous errors; 2 warnings emitted diff --git a/src/test/ui/lint/lint-ctypes-73249-2.rs b/src/test/ui/lint/lint-ctypes-73249-2.rs index 691047c8a40..fe578f51b63 100644 --- a/src/test/ui/lint/lint-ctypes-73249-2.rs +++ b/src/test/ui/lint/lint-ctypes-73249-2.rs @@ -23,7 +23,7 @@ pub struct A<T: Foo> { } extern "C" { - pub fn lint_me() -> A<()>; //~ ERROR: uses type `Qux` + pub fn lint_me() -> A<()>; //~ ERROR: uses type `impl Baz` } fn main() {} diff --git a/src/test/ui/lint/lint-ctypes-73249-2.stderr b/src/test/ui/lint/lint-ctypes-73249-2.stderr index 7c85e9fa85c..36dbe3217d7 100644 --- a/src/test/ui/lint/lint-ctypes-73249-2.stderr +++ b/src/test/ui/lint/lint-ctypes-73249-2.stderr @@ -1,4 +1,4 @@ -error: `extern` block uses type `Qux`, which is not FFI-safe +error: `extern` block uses type `impl Baz`, which is not FFI-safe --> $DIR/lint-ctypes-73249-2.rs:26:25 | LL | pub fn lint_me() -> A<()>; diff --git a/src/test/ui/lint/lint-ctypes-73249-3.rs b/src/test/ui/lint/lint-ctypes-73249-3.rs index ef8ab7e03d2..ec12de00739 100644 --- a/src/test/ui/lint/lint-ctypes-73249-3.rs +++ b/src/test/ui/lint/lint-ctypes-73249-3.rs @@ -17,7 +17,7 @@ pub struct A { } extern "C" { - pub fn lint_me() -> A; //~ ERROR: uses type `Qux` + pub fn lint_me() -> A; //~ ERROR: uses type `impl Baz` } fn main() {} diff --git a/src/test/ui/lint/lint-ctypes-73249-3.stderr b/src/test/ui/lint/lint-ctypes-73249-3.stderr index 83e2a233c43..e987ec90228 100644 --- a/src/test/ui/lint/lint-ctypes-73249-3.stderr +++ b/src/test/ui/lint/lint-ctypes-73249-3.stderr @@ -1,4 +1,4 @@ -error: `extern` block uses type `Qux`, which is not FFI-safe +error: `extern` block uses type `impl Baz`, which is not FFI-safe --> $DIR/lint-ctypes-73249-3.rs:20:25 | LL | pub fn lint_me() -> A; diff --git a/src/test/ui/lint/lint-ctypes-73249-5.rs b/src/test/ui/lint/lint-ctypes-73249-5.rs index 083fb6c5fb1..58c2d7a501a 100644 --- a/src/test/ui/lint/lint-ctypes-73249-5.rs +++ b/src/test/ui/lint/lint-ctypes-73249-5.rs @@ -17,7 +17,7 @@ pub struct A { } extern "C" { - pub fn lint_me() -> A; //~ ERROR: uses type `Qux` + pub fn lint_me() -> A; //~ ERROR: uses type `impl Baz` } fn main() {} diff --git a/src/test/ui/lint/lint-ctypes-73249-5.stderr b/src/test/ui/lint/lint-ctypes-73249-5.stderr index 37781d78cf2..749714c7df8 100644 --- a/src/test/ui/lint/lint-ctypes-73249-5.stderr +++ b/src/test/ui/lint/lint-ctypes-73249-5.stderr @@ -1,4 +1,4 @@ -error: `extern` block uses type `Qux`, which is not FFI-safe +error: `extern` block uses type `impl Baz`, which is not FFI-safe --> $DIR/lint-ctypes-73249-5.rs:20:25 | LL | pub fn lint_me() -> A; diff --git a/src/test/ui/lint/lint-ctypes-73251-1.rs b/src/test/ui/lint/lint-ctypes-73251-1.rs index 145ba784f7c..dc4c7efd7ef 100644 --- a/src/test/ui/lint/lint-ctypes-73251-1.rs +++ b/src/test/ui/lint/lint-ctypes-73251-1.rs @@ -20,7 +20,7 @@ fn assign() -> Qux { } extern "C" { - pub fn lint_me() -> <u32 as Foo>::Assoc; //~ ERROR: uses type `Qux` + pub fn lint_me() -> <u32 as Foo>::Assoc; //~ ERROR: uses type `impl Baz` } fn main() {} diff --git a/src/test/ui/lint/lint-ctypes-73251-1.stderr b/src/test/ui/lint/lint-ctypes-73251-1.stderr index 76b19d37e21..505ccd5a930 100644 --- a/src/test/ui/lint/lint-ctypes-73251-1.stderr +++ b/src/test/ui/lint/lint-ctypes-73251-1.stderr @@ -1,4 +1,4 @@ -error: `extern` block uses type `Qux`, which is not FFI-safe +error: `extern` block uses type `impl Baz`, which is not FFI-safe --> $DIR/lint-ctypes-73251-1.rs:23:25 | LL | pub fn lint_me() -> <u32 as Foo>::Assoc; diff --git a/src/test/ui/lint/lint-ctypes-73251-2.rs b/src/test/ui/lint/lint-ctypes-73251-2.rs index df71a945796..717ca4986f7 100644 --- a/src/test/ui/lint/lint-ctypes-73251-2.rs +++ b/src/test/ui/lint/lint-ctypes-73251-2.rs @@ -33,7 +33,7 @@ fn use_of_b() -> AliasB { } extern "C" { - pub fn lint_me() -> <AliasB as TraitB>::Assoc; //~ ERROR: uses type `AliasA` + pub fn lint_me() -> <AliasB as TraitB>::Assoc; //~ ERROR: uses type `impl TraitA<Assoc = u32>` } fn main() {} diff --git a/src/test/ui/lint/lint-ctypes-73251-2.stderr b/src/test/ui/lint/lint-ctypes-73251-2.stderr index 64f0fb2d892..d7e10db441e 100644 --- a/src/test/ui/lint/lint-ctypes-73251-2.stderr +++ b/src/test/ui/lint/lint-ctypes-73251-2.stderr @@ -1,4 +1,4 @@ -error: `extern` block uses type `AliasA`, which is not FFI-safe +error: `extern` block uses type `impl TraitA<Assoc = u32>`, which is not FFI-safe --> $DIR/lint-ctypes-73251-2.rs:36:25 | LL | pub fn lint_me() -> <AliasB as TraitB>::Assoc; diff --git a/src/test/ui/lint/opaque-ty-ffi-unsafe.rs b/src/test/ui/lint/opaque-ty-ffi-unsafe.rs index b7cc38e99fc..3a62b6a21a5 100644 --- a/src/test/ui/lint/opaque-ty-ffi-unsafe.rs +++ b/src/test/ui/lint/opaque-ty-ffi-unsafe.rs @@ -9,7 +9,7 @@ pub fn ret_closure() -> A { extern "C" { pub fn a(_: A); - //~^ ERROR `extern` block uses type `A`, which is not FFI-safe [improper_ctypes] + //~^ ERROR `extern` block uses type `impl Fn()`, which is not FFI-safe [improper_ctypes] } fn main() {} diff --git a/src/test/ui/lint/opaque-ty-ffi-unsafe.stderr b/src/test/ui/lint/opaque-ty-ffi-unsafe.stderr index 62d00fd6835..5afbef778b3 100644 --- a/src/test/ui/lint/opaque-ty-ffi-unsafe.stderr +++ b/src/test/ui/lint/opaque-ty-ffi-unsafe.stderr @@ -1,4 +1,4 @@ -error: `extern` block uses type `A`, which is not FFI-safe +error: `extern` block uses type `impl Fn()`, which is not FFI-safe --> $DIR/opaque-ty-ffi-unsafe.rs:11:17 | LL | pub fn a(_: A); diff --git a/src/test/ui/never_type/feature-gate-never_type_fallback.rs b/src/test/ui/never_type/feature-gate-never_type_fallback.rs index 7d020841180..3b896ec9d70 100644 --- a/src/test/ui/never_type/feature-gate-never_type_fallback.rs +++ b/src/test/ui/never_type/feature-gate-never_type_fallback.rs @@ -6,8 +6,7 @@ fn main() {} trait T {} -fn should_ret_unit() { - foo(panic!()) //~ ERROR +fn should_ret_unit() -> impl T { + //~^ ERROR the trait bound `(): T` is not satisfied + panic!() } - -fn foo(_: impl T) {} diff --git a/src/test/ui/never_type/feature-gate-never_type_fallback.stderr b/src/test/ui/never_type/feature-gate-never_type_fallback.stderr index 54abed38300..670f76867ce 100644 --- a/src/test/ui/never_type/feature-gate-never_type_fallback.stderr +++ b/src/test/ui/never_type/feature-gate-never_type_fallback.stderr @@ -1,14 +1,8 @@ error[E0277]: the trait bound `(): T` is not satisfied - --> $DIR/feature-gate-never_type_fallback.rs:10:5 + --> $DIR/feature-gate-never_type_fallback.rs:9:25 | -LL | foo(panic!()) - | ^^^ the trait `T` is not implemented for `()` - | -note: required by a bound in `foo` - --> $DIR/feature-gate-never_type_fallback.rs:13:16 - | -LL | fn foo(_: impl T) {} - | ^ required by this bound in `foo` +LL | fn should_ret_unit() -> impl T { + | ^^^^^^ the trait `T` is not implemented for `()` error: aborting due to previous error diff --git a/src/test/ui/never_type/impl_trait_fallback.rs b/src/test/ui/never_type/impl_trait_fallback.rs deleted file mode 100644 index cc9520c1b24..00000000000 --- a/src/test/ui/never_type/impl_trait_fallback.rs +++ /dev/null @@ -1,10 +0,0 @@ -// check-pass - -fn main() {} - -trait T {} -impl T for () {} - -fn should_ret_unit() -> impl T { - panic!() -} diff --git a/src/test/ui/never_type/impl_trait_fallback2.rs b/src/test/ui/never_type/impl_trait_fallback2.rs deleted file mode 100644 index f73d953bdbd..00000000000 --- a/src/test/ui/never_type/impl_trait_fallback2.rs +++ /dev/null @@ -1,21 +0,0 @@ -#![feature(type_alias_impl_trait)] - -fn main() {} - -trait T {} -impl T for i32 {} - -fn should_ret_unit() -> impl T { - //~^ ERROR `(): T` is not satisfied - panic!() -} - -type Foo = impl T; - -fn a() -> Foo { - panic!() -} - -fn b() -> Foo { - 42 -} diff --git a/src/test/ui/never_type/impl_trait_fallback2.stderr b/src/test/ui/never_type/impl_trait_fallback2.stderr deleted file mode 100644 index 2f50b9d2459..00000000000 --- a/src/test/ui/never_type/impl_trait_fallback2.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0277]: the trait bound `(): T` is not satisfied - --> $DIR/impl_trait_fallback2.rs:8:25 - | -LL | fn should_ret_unit() -> impl T { - | ^^^^^^ the trait `T` is not implemented for `()` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/never_type/impl_trait_fallback3.rs b/src/test/ui/never_type/impl_trait_fallback3.rs deleted file mode 100644 index 26ce9b93105..00000000000 --- a/src/test/ui/never_type/impl_trait_fallback3.rs +++ /dev/null @@ -1,15 +0,0 @@ -#![feature(type_alias_impl_trait)] - -fn main() {} - -trait T { - type Assoc; -} - -type Foo = impl T; -//~^ ERROR unconstrained opaque type - -fn a() -> Foo { - // This is not a defining use, it doesn't actually constrain the opaque type. - panic!() -} diff --git a/src/test/ui/never_type/impl_trait_fallback3.stderr b/src/test/ui/never_type/impl_trait_fallback3.stderr deleted file mode 100644 index 121019d5f69..00000000000 --- a/src/test/ui/never_type/impl_trait_fallback3.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: unconstrained opaque type - --> $DIR/impl_trait_fallback3.rs:9:12 - | -LL | type Foo = impl T; - | ^^^^^^ - | - = note: `Foo` must be used in combination with a concrete type within the same module - -error: aborting due to previous error - diff --git a/src/test/ui/never_type/impl_trait_fallback4.rs b/src/test/ui/never_type/impl_trait_fallback4.rs deleted file mode 100644 index fe62773fa02..00000000000 --- a/src/test/ui/never_type/impl_trait_fallback4.rs +++ /dev/null @@ -1,24 +0,0 @@ -#![feature(type_alias_impl_trait)] - -trait T { - type Assoc: Cake; -} - -trait Cake: std::fmt::Display { - fn cake() -> Self; -} - -type Foo = impl T; - -fn foo() -> impl T { - //~^ ERROR `(): T` is not satisfied - panic!() -} - -fn a() -> Foo { - foo() -} - -fn main() { - println!("{}", <Foo as T>::Assoc::cake()); -} diff --git a/src/test/ui/never_type/impl_trait_fallback4.stderr b/src/test/ui/never_type/impl_trait_fallback4.stderr deleted file mode 100644 index f2e216e9044..00000000000 --- a/src/test/ui/never_type/impl_trait_fallback4.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0277]: the trait bound `(): T` is not satisfied - --> $DIR/impl_trait_fallback4.rs:13:13 - | -LL | fn foo() -> impl T { - | ^^^^^^ the trait `T` is not implemented for `()` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/nll/issue-52113.rs b/src/test/ui/nll/issue-52113.rs index 2f4cbf8322b..0d7ee037692 100644 --- a/src/test/ui/nll/issue-52113.rs +++ b/src/test/ui/nll/issue-52113.rs @@ -29,9 +29,9 @@ fn produce3<'a, 'b: 'a>(data: &'a mut Vec<&'a u32>, value: &'b u32) -> impl Bazi fn produce_err<'a, 'b: 'a>(data: &'b mut Vec<&'b u32>, value: &'a u32) -> impl Bazinga + 'b { let x = move || { let value: &'a u32 = value; - data.push(value); //~ ERROR lifetime may not live long enough + data.push(value); }; - x + x //~ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/nll/issue-52113.stderr b/src/test/ui/nll/issue-52113.stderr index 42ff1866893..f70ae2edd7f 100644 --- a/src/test/ui/nll/issue-52113.stderr +++ b/src/test/ui/nll/issue-52113.stderr @@ -1,13 +1,13 @@ error: lifetime may not live long enough - --> $DIR/issue-52113.rs:32:9 + --> $DIR/issue-52113.rs:34:5 | LL | fn produce_err<'a, 'b: 'a>(data: &'b mut Vec<&'b u32>, value: &'a u32) -> impl Bazinga + 'b { | -- -- lifetime `'b` defined here | | | lifetime `'a` defined here ... -LL | data.push(value); - | ^^^^^^^^^^^^^^^^ argument requires that `'a` must outlive `'b` +LL | x + | ^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` | = help: consider adding the following bound: `'a: 'b` diff --git a/src/test/ui/nll/issue-73159-rpit-static.rs b/src/test/ui/nll/issue-73159-rpit-static.rs index 97dc016068b..e29ba09b369 100644 --- a/src/test/ui/nll/issue-73159-rpit-static.rs +++ b/src/test/ui/nll/issue-73159-rpit-static.rs @@ -7,8 +7,8 @@ struct Foo<'a>(&'a [u8]); impl<'a> Foo<'a> { fn make_it(&self) -> impl Iterator<Item = u8> { - self.0.iter().copied() //~^ ERROR: captures lifetime that does not appear in bounds + self.0.iter().copied() } } diff --git a/src/test/ui/nll/issue-73159-rpit-static.stderr b/src/test/ui/nll/issue-73159-rpit-static.stderr index a3e9c0b44c2..6c7cd0c8254 100644 --- a/src/test/ui/nll/issue-73159-rpit-static.stderr +++ b/src/test/ui/nll/issue-73159-rpit-static.stderr @@ -1,11 +1,10 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/issue-73159-rpit-static.rs:10:9 + --> $DIR/issue-73159-rpit-static.rs:9:26 | LL | impl<'a> Foo<'a> { | -- hidden type `Copied<std::slice::Iter<'a, u8>>` captures the lifetime `'a` as defined here LL | fn make_it(&self) -> impl Iterator<Item = u8> { -LL | self.0.iter().copied() - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/nll/ty-outlives/impl-trait-captures.rs b/src/test/ui/nll/ty-outlives/impl-trait-captures.rs index c04185d0814..8af23aad726 100644 --- a/src/test/ui/nll/ty-outlives/impl-trait-captures.rs +++ b/src/test/ui/nll/ty-outlives/impl-trait-captures.rs @@ -8,8 +8,8 @@ trait Foo<'a> { impl<'a, T> Foo<'a> for T { } fn foo<'a, T>(x: &T) -> impl Foo<'a> { +//~^ ERROR captures lifetime that does not appear in bounds x - //~^ ERROR captures lifetime that does not appear in bounds } fn main() {} diff --git a/src/test/ui/nll/ty-outlives/impl-trait-captures.stderr b/src/test/ui/nll/ty-outlives/impl-trait-captures.stderr index 42d9f057aaa..3e6fe789a8b 100644 --- a/src/test/ui/nll/ty-outlives/impl-trait-captures.stderr +++ b/src/test/ui/nll/ty-outlives/impl-trait-captures.stderr @@ -1,10 +1,10 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/impl-trait-captures.rs:11:5 + --> $DIR/impl-trait-captures.rs:10:25 | LL | fn foo<'a, T>(x: &T) -> impl Foo<'a> { - | -- hidden type `&ReFree(DefId(0:8 ~ impl_trait_captures[1afc]::foo), BrAnon(0)) T` captures the anonymous lifetime defined here -LL | x - | ^ + | -- ^^^^^^^^^^^^ + | | + | hidden type `&ReFree(DefId(0:8 ~ impl_trait_captures[1afc]::foo), BrAnon(0)) T` captures the anonymous lifetime defined here | help: to declare that the `impl Trait` captures `ReFree(DefId(0:8 ~ impl_trait_captures[1afc]::foo), BrAnon(0))`, you can add an explicit `ReFree(DefId(0:8 ~ impl_trait_captures[1afc]::foo), BrAnon(0))` lifetime bound | diff --git a/src/test/ui/nll/ty-outlives/impl-trait-outlives.rs b/src/test/ui/nll/ty-outlives/impl-trait-outlives.rs index 3548ad03a7d..0c7d8acb052 100644 --- a/src/test/ui/nll/ty-outlives/impl-trait-outlives.rs +++ b/src/test/ui/nll/ty-outlives/impl-trait-outlives.rs @@ -5,11 +5,11 @@ use std::fmt::Debug; fn no_region<'a, T>(x: Box<T>) -> impl Debug + 'a + //~^ ERROR the parameter type `T` may not live long enough [E0309] where T: Debug, { x - //~^ ERROR the parameter type `T` may not live long enough [E0309] } fn correct_region<'a, T>(x: Box<T>) -> impl Debug + 'a @@ -20,11 +20,11 @@ where } fn wrong_region<'a, 'b, T>(x: Box<T>) -> impl Debug + 'a + //~^ ERROR the parameter type `T` may not live long enough [E0309] where T: 'b + Debug, { x - //~^ ERROR the parameter type `T` may not live long enough [E0309] } fn outlives_region<'a, 'b, T>(x: Box<T>) -> impl Debug + 'a diff --git a/src/test/ui/nll/ty-outlives/impl-trait-outlives.stderr b/src/test/ui/nll/ty-outlives/impl-trait-outlives.stderr index 31ee540cce9..053aef951f2 100644 --- a/src/test/ui/nll/ty-outlives/impl-trait-outlives.stderr +++ b/src/test/ui/nll/ty-outlives/impl-trait-outlives.stderr @@ -1,16 +1,16 @@ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/impl-trait-outlives.rs:11:5 + --> $DIR/impl-trait-outlives.rs:7:35 | -LL | x - | ^ +LL | fn no_region<'a, T>(x: Box<T>) -> impl Debug + 'a + | ^^^^^^^^^^^^^^^ | = help: consider adding an explicit lifetime bound `T: 'a`... error[E0309]: the parameter type `T` may not live long enough - --> $DIR/impl-trait-outlives.rs:26:5 + --> $DIR/impl-trait-outlives.rs:22:42 | -LL | x - | ^ +LL | fn wrong_region<'a, 'b, T>(x: Box<T>) -> impl Debug + 'a + | ^^^^^^^^^^^^^^^ | = help: consider adding an explicit lifetime bound `T: 'a`... diff --git a/src/test/ui/parser/fn-header-semantic-fail.rs b/src/test/ui/parser/fn-header-semantic-fail.rs index cf5d3dab4aa..91a63bafd99 100644 --- a/src/test/ui/parser/fn-header-semantic-fail.rs +++ b/src/test/ui/parser/fn-header-semantic-fail.rs @@ -9,9 +9,8 @@ fn main() { unsafe fn ff2() {} // OK. const fn ff3() {} // OK. extern "C" fn ff4() {} // OK. - const async unsafe extern "C" fn ff5() {} + const async unsafe extern "C" fn ff5() {} // OK. //~^ ERROR functions cannot be both `const` and `async` - //~| ERROR cycle detected trait X { async fn ft1(); //~ ERROR functions in traits cannot be declared `async` @@ -27,14 +26,15 @@ fn main() { struct Y; impl X for Y { async fn ft1() {} //~ ERROR functions in traits cannot be declared `async` + //~^ ERROR method `ft1` has an incompatible type for trait unsafe fn ft2() {} // OK. const fn ft3() {} //~ ERROR functions in traits cannot be declared const extern "C" fn ft4() {} const async unsafe extern "C" fn ft5() {} //~^ ERROR functions in traits cannot be declared `async` //~| ERROR functions in traits cannot be declared const + //~| ERROR method `ft5` has an incompatible type for trait //~| ERROR functions cannot be both `const` and `async` - //~| ERROR cycle detected } impl Y { @@ -44,7 +44,6 @@ fn main() { extern "C" fn fi4() {} // OK. const async unsafe extern "C" fn fi5() {} //~^ ERROR functions cannot be both `const` and `async` - //~| ERROR cycle detected } extern "C" { diff --git a/src/test/ui/parser/fn-header-semantic-fail.stderr b/src/test/ui/parser/fn-header-semantic-fail.stderr index 1d7460b8d36..8eaba559a62 100644 --- a/src/test/ui/parser/fn-header-semantic-fail.stderr +++ b/src/test/ui/parser/fn-header-semantic-fail.stderr @@ -1,14 +1,14 @@ error: functions cannot be both `const` and `async` --> $DIR/fn-header-semantic-fail.rs:12:5 | -LL | const async unsafe extern "C" fn ff5() {} +LL | const async unsafe extern "C" fn ff5() {} // OK. | ^^^^^-^^^^^------------------------------ | | | | | `async` because of this | `const` because of this error[E0706]: functions in traits cannot be declared `async` - --> $DIR/fn-header-semantic-fail.rs:17:9 + --> $DIR/fn-header-semantic-fail.rs:16:9 | LL | async fn ft1(); | -----^^^^^^^^^^ @@ -19,19 +19,19 @@ LL | async fn ft1(); = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait error[E0379]: functions in traits cannot be declared const - --> $DIR/fn-header-semantic-fail.rs:19:9 + --> $DIR/fn-header-semantic-fail.rs:18:9 | LL | const fn ft3(); | ^^^^^ functions in traits cannot be const error[E0379]: functions in traits cannot be declared const - --> $DIR/fn-header-semantic-fail.rs:21:9 + --> $DIR/fn-header-semantic-fail.rs:20:9 | LL | const async unsafe extern "C" fn ft5(); | ^^^^^ functions in traits cannot be const error[E0706]: functions in traits cannot be declared `async` - --> $DIR/fn-header-semantic-fail.rs:21:9 + --> $DIR/fn-header-semantic-fail.rs:20:9 | LL | const async unsafe extern "C" fn ft5(); | ^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -42,7 +42,7 @@ LL | const async unsafe extern "C" fn ft5(); = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait error: functions cannot be both `const` and `async` - --> $DIR/fn-header-semantic-fail.rs:21:9 + --> $DIR/fn-header-semantic-fail.rs:20:9 | LL | const async unsafe extern "C" fn ft5(); | ^^^^^-^^^^^---------------------------- @@ -51,7 +51,7 @@ LL | const async unsafe extern "C" fn ft5(); | `const` because of this error[E0706]: functions in traits cannot be declared `async` - --> $DIR/fn-header-semantic-fail.rs:29:9 + --> $DIR/fn-header-semantic-fail.rs:28:9 | LL | async fn ft1() {} | -----^^^^^^^^^^^^ @@ -103,7 +103,7 @@ LL | const async unsafe extern "C" fn fi5() {} | `const` because of this error: functions in `extern` blocks cannot have qualifiers - --> $DIR/fn-header-semantic-fail.rs:51:18 + --> $DIR/fn-header-semantic-fail.rs:50:18 | LL | extern "C" { | ---------- in this `extern` block @@ -116,7 +116,7 @@ LL | fn fe1(); | ~~ error: functions in `extern` blocks cannot have qualifiers - --> $DIR/fn-header-semantic-fail.rs:52:19 + --> $DIR/fn-header-semantic-fail.rs:51:19 | LL | extern "C" { | ---------- in this `extern` block @@ -130,7 +130,7 @@ LL | fn fe2(); | ~~ error: functions in `extern` blocks cannot have qualifiers - --> $DIR/fn-header-semantic-fail.rs:53:18 + --> $DIR/fn-header-semantic-fail.rs:52:18 | LL | extern "C" { | ---------- in this `extern` block @@ -144,7 +144,7 @@ LL | fn fe3(); | ~~ error: functions in `extern` blocks cannot have qualifiers - --> $DIR/fn-header-semantic-fail.rs:54:23 + --> $DIR/fn-header-semantic-fail.rs:53:23 | LL | extern "C" { | ---------- in this `extern` block @@ -158,7 +158,7 @@ LL | fn fe4(); | ~~ error: functions in `extern` blocks cannot have qualifiers - --> $DIR/fn-header-semantic-fail.rs:55:42 + --> $DIR/fn-header-semantic-fail.rs:54:42 | LL | extern "C" { | ---------- in this `extern` block @@ -172,7 +172,7 @@ LL | fn fe5(); | ~~ error: functions cannot be both `const` and `async` - --> $DIR/fn-header-semantic-fail.rs:55:9 + --> $DIR/fn-header-semantic-fail.rs:54:9 | LL | const async unsafe extern "C" fn fe5(); | ^^^^^-^^^^^---------------------------- @@ -180,115 +180,43 @@ LL | const async unsafe extern "C" fn fe5(); | | `async` because of this | `const` because of this -error[E0391]: cycle detected when computing type of `main::ff5::{opaque#0}` - --> $DIR/fn-header-semantic-fail.rs:12:44 +error[E0053]: method `ft1` has an incompatible type for trait + --> $DIR/fn-header-semantic-fail.rs:28:24 | -LL | const async unsafe extern "C" fn ff5() {} - | ^ - | -note: ...which requires borrow-checking `main::ff5`... - --> $DIR/fn-header-semantic-fail.rs:12:5 - | -LL | const async unsafe extern "C" fn ff5() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires processing `main::ff5`... - --> $DIR/fn-header-semantic-fail.rs:12:5 +LL | async fn ft1() {} + | ^ + | | + | checked the `Output` of this `async fn`, found opaque type + | expected `()`, found opaque type | -LL | const async unsafe extern "C" fn ff5() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires const checking `main::ff5`... - --> $DIR/fn-header-semantic-fail.rs:12:5 + = note: while checking the return type of the `async fn` +note: type in trait + --> $DIR/fn-header-semantic-fail.rs:16:23 | -LL | const async unsafe extern "C" fn ff5() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: ...which requires computing whether `impl core::future::future::Future<Output = ()>` is freeze... - = note: ...which requires evaluating trait selection obligation `impl core::future::future::Future<Output = ()>: core::marker::Freeze`... - = note: ...which again requires computing type of `main::ff5::{opaque#0}`, completing the cycle -note: cycle used when checking item types in top-level module - --> $DIR/fn-header-semantic-fail.rs:5:1 - | -LL | / #![feature(const_extern_fn)] -LL | | -LL | | fn main() { -LL | | async fn ff1() {} // OK. -... | -LL | | } -LL | | } - | |_^ +LL | async fn ft1(); + | ^ + = note: expected fn pointer `fn()` + found fn pointer `fn() -> impl Future<Output = ()>` -error[E0391]: cycle detected when computing type of `main::<impl at $DIR/fn-header-semantic-fail.rs:28:5: 38:6>::ft5::{opaque#0}` +error[E0053]: method `ft5` has an incompatible type for trait --> $DIR/fn-header-semantic-fail.rs:33:48 | LL | const async unsafe extern "C" fn ft5() {} | ^ + | | + | checked the `Output` of this `async fn`, found opaque type + | expected `()`, found opaque type | -note: ...which requires borrow-checking `main::<impl at $DIR/fn-header-semantic-fail.rs:28:5: 38:6>::ft5`... - --> $DIR/fn-header-semantic-fail.rs:33:9 - | -LL | const async unsafe extern "C" fn ft5() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires processing `main::<impl at $DIR/fn-header-semantic-fail.rs:28:5: 38:6>::ft5`... - --> $DIR/fn-header-semantic-fail.rs:33:9 - | -LL | const async unsafe extern "C" fn ft5() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires const checking `main::<impl at $DIR/fn-header-semantic-fail.rs:28:5: 38:6>::ft5`... - --> $DIR/fn-header-semantic-fail.rs:33:9 - | -LL | const async unsafe extern "C" fn ft5() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: ...which requires computing whether `impl core::future::future::Future<Output = ()>` is freeze... - = note: ...which requires evaluating trait selection obligation `impl core::future::future::Future<Output = ()>: core::marker::Freeze`... - = note: ...which again requires computing type of `main::<impl at $DIR/fn-header-semantic-fail.rs:28:5: 38:6>::ft5::{opaque#0}`, completing the cycle -note: cycle used when checking item types in top-level module - --> $DIR/fn-header-semantic-fail.rs:5:1 - | -LL | / #![feature(const_extern_fn)] -LL | | -LL | | fn main() { -LL | | async fn ff1() {} // OK. -... | -LL | | } -LL | | } - | |_^ - -error[E0391]: cycle detected when computing type of `main::<impl at $DIR/fn-header-semantic-fail.rs:40:5: 48:6>::fi5::{opaque#0}` - --> $DIR/fn-header-semantic-fail.rs:45:48 - | -LL | const async unsafe extern "C" fn fi5() {} - | ^ - | -note: ...which requires borrow-checking `main::<impl at $DIR/fn-header-semantic-fail.rs:40:5: 48:6>::fi5`... - --> $DIR/fn-header-semantic-fail.rs:45:9 + = note: while checking the return type of the `async fn` +note: type in trait + --> $DIR/fn-header-semantic-fail.rs:20:47 | -LL | const async unsafe extern "C" fn fi5() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires processing `main::<impl at $DIR/fn-header-semantic-fail.rs:40:5: 48:6>::fi5`... - --> $DIR/fn-header-semantic-fail.rs:45:9 - | -LL | const async unsafe extern "C" fn fi5() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires const checking `main::<impl at $DIR/fn-header-semantic-fail.rs:40:5: 48:6>::fi5`... - --> $DIR/fn-header-semantic-fail.rs:45:9 - | -LL | const async unsafe extern "C" fn fi5() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: ...which requires computing whether `impl core::future::future::Future<Output = ()>` is freeze... - = note: ...which requires evaluating trait selection obligation `impl core::future::future::Future<Output = ()>: core::marker::Freeze`... - = note: ...which again requires computing type of `main::<impl at $DIR/fn-header-semantic-fail.rs:40:5: 48:6>::fi5::{opaque#0}`, completing the cycle -note: cycle used when checking item types in top-level module - --> $DIR/fn-header-semantic-fail.rs:5:1 - | -LL | / #![feature(const_extern_fn)] -LL | | -LL | | fn main() { -LL | | async fn ff1() {} // OK. -... | -LL | | } -LL | | } - | |_^ +LL | const async unsafe extern "C" fn ft5(); + | ^ + = note: expected fn pointer `unsafe extern "C" fn()` + found fn pointer `unsafe extern "C" fn() -> impl Future<Output = ()>` -error: aborting due to 21 previous errors +error: aborting due to 20 previous errors -Some errors have detailed explanations: E0379, E0391, E0706. -For more information about an error, try `rustc --explain E0379`. +Some errors have detailed explanations: E0053, E0379, E0706. +For more information about an error, try `rustc --explain E0053`. diff --git a/src/test/ui/polymorphization/generators.rs b/src/test/ui/polymorphization/generators.rs index 68ea4a026d7..f295cf15d08 100644 --- a/src/test/ui/polymorphization/generators.rs +++ b/src/test/ui/polymorphization/generators.rs @@ -32,6 +32,7 @@ where #[rustc_polymorphize_error] pub fn unused_type<T>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin { + //~^ ERROR item has unused generic parameters || { //~^ ERROR item has unused generic parameters yield 1; @@ -57,6 +58,7 @@ pub fn used_type_in_return<R: Default>() -> impl Generator<(), Yield = u32, Retu #[rustc_polymorphize_error] pub fn unused_const<const T: u32>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin { + //~^ ERROR item has unused generic parameters || { //~^ ERROR item has unused generic parameters yield 1; diff --git a/src/test/ui/polymorphization/generators.stderr b/src/test/ui/polymorphization/generators.stderr index 1152bcb0734..c4e566a42d0 100644 --- a/src/test/ui/polymorphization/generators.stderr +++ b/src/test/ui/polymorphization/generators.stderr @@ -8,10 +8,11 @@ LL | #![feature(generic_const_exprs, generators, generator_trait, rustc_attrs)] = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information error: item has unused generic parameters - --> $DIR/generators.rs:35:5 + --> $DIR/generators.rs:36:5 | LL | pub fn unused_type<T>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin { | - generic parameter `T` is unused +LL | LL | / || { LL | | LL | | yield 1; @@ -20,10 +21,17 @@ LL | | } | |_____^ error: item has unused generic parameters - --> $DIR/generators.rs:60:5 + --> $DIR/generators.rs:34:8 + | +LL | pub fn unused_type<T>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin { + | ^^^^^^^^^^^ - generic parameter `T` is unused + +error: item has unused generic parameters + --> $DIR/generators.rs:62:5 | LL | pub fn unused_const<const T: u32>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin { | - generic parameter `T` is unused +LL | LL | / || { LL | | LL | | yield 1; @@ -31,5 +39,11 @@ LL | | 2 LL | | } | |_____^ -error: aborting due to 2 previous errors; 1 warning emitted +error: item has unused generic parameters + --> $DIR/generators.rs:60:8 + | +LL | pub fn unused_const<const T: u32>() -> impl Generator<(), Yield = u32, Return = u32> + Unpin { + | ^^^^^^^^^^^^ - generic parameter `T` is unused + +error: aborting due to 4 previous errors; 1 warning emitted diff --git a/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.rs b/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.rs index 49462f52fb4..cc36f054bc3 100644 --- a/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.rs +++ b/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.rs @@ -14,6 +14,7 @@ trait B { impl B for A { async fn associated(); //~ ERROR without body //~^ ERROR cannot be declared `async` + //~| ERROR incompatible type for trait } fn main() {} diff --git a/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.stderr b/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.stderr index a473f42fc2c..d3214458eac 100644 --- a/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.stderr +++ b/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.stderr @@ -44,6 +44,25 @@ LL | async fn associated(); = note: `async` trait functions are not currently supported = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait -error: aborting due to 5 previous errors +error[E0053]: method `associated` has an incompatible type for trait + --> $DIR/issue-70736-async-fn-no-body-def-collector.rs:15:26 + | +LL | async fn associated(); + | ^ + | | + | checked the `Output` of this `async fn`, found opaque type + | expected `()`, found opaque type + | + = note: while checking the return type of the `async fn` +note: type in trait + --> $DIR/issue-70736-async-fn-no-body-def-collector.rs:11:26 + | +LL | async fn associated(); + | ^ + = note: expected fn pointer `fn()` + found fn pointer `fn() -> impl Future<Output = ()>` + +error: aborting due to 6 previous errors -For more information about this error, try `rustc --explain E0706`. +Some errors have detailed explanations: E0053, E0706. +For more information about an error, try `rustc --explain E0053`. diff --git a/src/test/ui/save-analysis/issue-68621.rs b/src/test/ui/save-analysis/issue-68621.rs index 30479580f11..96af085c5b6 100644 --- a/src/test/ui/save-analysis/issue-68621.rs +++ b/src/test/ui/save-analysis/issue-68621.rs @@ -11,7 +11,7 @@ trait Service { struct Struct; impl Service for Struct { - type Future = impl Trait; //~ ERROR: unconstrained opaque type + type Future = impl Trait; //~ ERROR: could not find defining uses } fn main() {} diff --git a/src/test/ui/save-analysis/issue-68621.stderr b/src/test/ui/save-analysis/issue-68621.stderr index 4a4bf9a6996..3af6d0a3e07 100644 --- a/src/test/ui/save-analysis/issue-68621.stderr +++ b/src/test/ui/save-analysis/issue-68621.stderr @@ -1,10 +1,8 @@ -error: unconstrained opaque type +error: could not find defining uses --> $DIR/issue-68621.rs:14:19 | LL | type Future = impl Trait; | ^^^^^^^^^^ - | - = note: `Future` must be used in combination with a concrete type within the same module error: aborting due to previous error diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr b/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr index 570a08cb587..61ac7731777 100644 --- a/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr +++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait-async.stderr @@ -1,8 +1,8 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/arbitrary_self_types_pin_lifetime_impl_trait-async.rs:8:48 + --> $DIR/arbitrary_self_types_pin_lifetime_impl_trait-async.rs:8:37 | LL | async fn f(self: Pin<&Self>) -> impl Clone { self } - | - ^^^^^^^^ + | - ^^^^^^^^^^ | | | hidden type `Pin<&Foo>` captures the lifetime `'_` as defined here | diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait.stderr b/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait.stderr index abdc650c68e..6f8200739b9 100644 --- a/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait.stderr +++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime_impl_trait.stderr @@ -1,8 +1,8 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds - --> $DIR/arbitrary_self_types_pin_lifetime_impl_trait.rs:6:44 + --> $DIR/arbitrary_self_types_pin_lifetime_impl_trait.rs:6:31 | LL | fn f(self: Pin<&Self>) -> impl Clone { self } - | ----- ^^^^ + | ----- ^^^^^^^^^^ | | | hidden type `Pin<&Foo>` captures the anonymous lifetime defined here | diff --git a/src/test/ui/suggestions/impl-trait-return-trailing-semicolon.stderr b/src/test/ui/suggestions/impl-trait-return-trailing-semicolon.stderr index 07c1d8bccba..d826222a06a 100644 --- a/src/test/ui/suggestions/impl-trait-return-trailing-semicolon.stderr +++ b/src/test/ui/suggestions/impl-trait-return-trailing-semicolon.stderr @@ -1,11 +1,10 @@ error[E0277]: the trait bound `(): Bar` is not satisfied - --> $DIR/impl-trait-return-trailing-semicolon.rs:3:22 + --> $DIR/impl-trait-return-trailing-semicolon.rs:3:13 | -LL | fn foo() -> impl Bar { - | ______________________^ -LL | | 5; -LL | | } - | |_^ the trait `Bar` is not implemented for `()` +LL | fn foo() -> impl Bar { + | ^^^^^^^^ the trait `Bar` is not implemented for `()` +LL | 5; + | - consider removing this semicolon error: aborting due to previous error diff --git a/src/test/ui/suggestions/issue-81098.stderr b/src/test/ui/suggestions/issue-81098.stderr index f13e653cb06..2a72159e577 100644 --- a/src/test/ui/suggestions/issue-81098.stderr +++ b/src/test/ui/suggestions/issue-81098.stderr @@ -1,23 +1,19 @@ error[E0277]: `()` doesn't implement `std::fmt::Display` - --> $DIR/issue-81098.rs:3:37 + --> $DIR/issue-81098.rs:3:13 | -LL | fn wat() -> impl core::fmt::Display { - | _____________________________________^ -LL | | fn why() {} -LL | | } - | |_^ `()` cannot be formatted with the default formatter +LL | fn wat() -> impl core::fmt::Display { + | ^^^^^^^^^^^^^^^^^^^^^^^ `()` cannot be formatted with the default formatter | = help: the trait `std::fmt::Display` is not implemented for `()` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead error[E0277]: `()` doesn't implement `std::fmt::Display` - --> $DIR/issue-81098.rs:9:36 + --> $DIR/issue-81098.rs:9:12 | -LL | fn ok() -> impl core::fmt::Display { - | ____________________________________^ -LL | | 1; -LL | | } - | |_^ `()` cannot be formatted with the default formatter +LL | fn ok() -> impl core::fmt::Display { + | ^^^^^^^^^^^^^^^^^^^^^^^ `()` cannot be formatted with the default formatter +LL | 1; + | - consider removing this semicolon | = help: the trait `std::fmt::Display` is not implemented for `()` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead diff --git a/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.stderr b/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.stderr index c7f1215c8cc..a5b50634c71 100644 --- a/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.stderr +++ b/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.stderr @@ -7,18 +7,13 @@ LL | fn iter(&self) -> impl Iterator<Item = Box<dyn Foo>> { LL | remaining: self.0.iter(), | ------ ^^^^ | | - | ...is used and required to live as long as `'static` here + | ...is used here... | -note: `'static` lifetime requirement introduced by the return type +note: ...and is required to live as long as `'static` here --> $DIR/trait-object-nested-in-impl-trait.rs:27:23 | -LL | fn iter(&self) -> impl Iterator<Item = Box<dyn Foo>> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requirement introduced by this return type -LL | / Iter { -LL | | current: None, -LL | | remaining: self.0.iter(), -LL | | } - | |_________- because of this returned expression +LL | fn iter(&self) -> impl Iterator<Item = Box<dyn Foo>> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: to declare that the `impl Trait` captures data from argument `self`, you can add an explicit `'_` lifetime bound | LL | fn iter(&self) -> impl Iterator<Item = Box<dyn Foo>> + '_ { @@ -37,18 +32,13 @@ LL | fn iter(&self) -> impl Iterator<Item = Box<dyn Foo>> + '_ { LL | remaining: self.0.iter(), | ------ ^^^^ | | - | ...is used and required to live as long as `'static` here + | ...is used here... | -note: `'static` lifetime requirement introduced by the return type +note: ...and is required to live as long as `'static` here --> $DIR/trait-object-nested-in-impl-trait.rs:38:23 | -LL | fn iter(&self) -> impl Iterator<Item = Box<dyn Foo>> + '_ { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requirement introduced by this return type -LL | / Iter { -LL | | current: None, -LL | | remaining: self.0.iter(), -LL | | } - | |_________- because of this returned expression +LL | fn iter(&self) -> impl Iterator<Item = Box<dyn Foo>> + '_ { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: to declare that the trait object captures data from argument `self`, you can add an explicit `'_` lifetime bound | LL | fn iter(&self) -> impl Iterator<Item = Box<dyn Foo + '_>> + '_ { @@ -63,18 +53,13 @@ LL | fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo>> + 'a { LL | remaining: self.0.iter(), | ------ ^^^^ | | - | ...is used and required to live as long as `'static` here + | ...is used here... | -note: `'static` lifetime requirement introduced by the return type +note: ...and is required to live as long as `'static` here --> $DIR/trait-object-nested-in-impl-trait.rs:49:30 | -LL | fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo>> + 'a { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requirement introduced by this return type -LL | / Iter { -LL | | current: None, -LL | | remaining: self.0.iter(), -LL | | } - | |_________- because of this returned expression +LL | fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo>> + 'a { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: to declare that the trait object captures data from argument `self`, you can add an explicit `'a` lifetime bound | LL | fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo + 'a>> + 'a { @@ -89,18 +74,13 @@ LL | fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo>> { LL | remaining: self.0.iter(), | ------ ^^^^ | | - | ...is used and required to live as long as `'static` here + | ...is used here... | -note: `'static` lifetime requirement introduced by the return type +note: ...and is required to live as long as `'static` here --> $DIR/trait-object-nested-in-impl-trait.rs:60:30 | -LL | fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo>> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requirement introduced by this return type -LL | / Iter { -LL | | current: None, -LL | | remaining: self.0.iter(), -LL | | } - | |_________- because of this returned expression +LL | fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo>> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: to declare that the `impl Trait` captures data from argument `self`, you can add an explicit `'a` lifetime bound | LL | fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo>> + 'a { diff --git a/src/test/ui/suggestions/match-prev-arm-needing-semi.rs b/src/test/ui/suggestions/match-prev-arm-needing-semi.rs index a02664ad7ca..6aa93a24d2f 100644 --- a/src/test/ui/suggestions/match-prev-arm-needing-semi.rs +++ b/src/test/ui/suggestions/match-prev-arm-needing-semi.rs @@ -16,9 +16,6 @@ fn extra_semicolon() { async fn async_dummy() {} //~ NOTE checked the `Output` of this `async fn`, found opaque type //~| NOTE while checking the return type of the `async fn` //~| NOTE in this expansion of desugaring of `async` block or function -//~| NOTE while checking the return type of the `async fn` -//~| NOTE in this expansion of desugaring of `async` block or function -//~| NOTE checked the `Output` of this `async fn`, expected opaque type async fn async_dummy2() {} //~ NOTE checked the `Output` of this `async fn`, found opaque type //~| NOTE checked the `Output` of this `async fn`, found opaque type //~| NOTE while checking the return type of the `async fn` @@ -34,7 +31,7 @@ async fn async_extra_semicolon_same() { } false => async_dummy(), //~ ERROR `match` arms have incompatible types //~^ NOTE expected `()`, found opaque type - //~| NOTE expected unit type `()` + //~| NOTE expected type `()` //~| HELP consider `await`ing on the `Future` }; } @@ -47,7 +44,7 @@ async fn async_extra_semicolon_different() { } false => async_dummy2(), //~ ERROR `match` arms have incompatible types //~^ NOTE expected `()`, found opaque type - //~| NOTE expected unit type `()` + //~| NOTE expected type `()` //~| HELP consider `await`ing on the `Future` }; } @@ -58,7 +55,7 @@ async fn async_different_futures() { //~| HELP consider `await`ing on both `Future`s false => async_dummy2(), //~ ERROR `match` arms have incompatible types //~^ NOTE expected opaque type, found a different opaque type - //~| NOTE expected opaque type `impl Future<Output = ()>` + //~| NOTE expected type `impl Future<Output = ()>` //~| NOTE distinct uses of `impl Trait` result in different opaque types }; } diff --git a/src/test/ui/suggestions/match-prev-arm-needing-semi.stderr b/src/test/ui/suggestions/match-prev-arm-needing-semi.stderr index 4c4b782bd6f..b55c51b9280 100644 --- a/src/test/ui/suggestions/match-prev-arm-needing-semi.stderr +++ b/src/test/ui/suggestions/match-prev-arm-needing-semi.stderr @@ -1,5 +1,5 @@ error[E0308]: `match` arms have incompatible types - --> $DIR/match-prev-arm-needing-semi.rs:35:18 + --> $DIR/match-prev-arm-needing-semi.rs:32:18 | LL | let _ = match true { | _____________- @@ -20,8 +20,8 @@ note: while checking the return type of the `async fn` | LL | async fn async_dummy() {} | ^ checked the `Output` of this `async fn`, found opaque type - = note: expected unit type `()` - found opaque type `impl Future<Output = ()>` + = note: expected type `()` + found opaque type `impl Future<Output = ()>` help: consider `await`ing on the `Future` | LL | false => async_dummy().await, @@ -33,7 +33,7 @@ LL + async_dummy() | error[E0308]: `match` arms have incompatible types - --> $DIR/match-prev-arm-needing-semi.rs:48:18 + --> $DIR/match-prev-arm-needing-semi.rs:45:18 | LL | let _ = match true { | _____________- @@ -50,12 +50,12 @@ LL | | }; | |_____- `match` arms have incompatible types | note: while checking the return type of the `async fn` - --> $DIR/match-prev-arm-needing-semi.rs:22:25 + --> $DIR/match-prev-arm-needing-semi.rs:19:25 | LL | async fn async_dummy2() {} | ^ checked the `Output` of this `async fn`, found opaque type - = note: expected unit type `()` - found opaque type `impl Future<Output = ()>` + = note: expected type `()` + found opaque type `impl Future<Output = ()>` help: consider `await`ing on the `Future` | LL | false => async_dummy2().await, @@ -69,7 +69,7 @@ LL ~ false => Box::new(async_dummy2()), | error[E0308]: `match` arms have incompatible types - --> $DIR/match-prev-arm-needing-semi.rs:59:18 + --> $DIR/match-prev-arm-needing-semi.rs:56:18 | LL | let _ = match true { | _____________- @@ -84,17 +84,12 @@ LL | | }; | |_____- `match` arms have incompatible types | note: while checking the return type of the `async fn` - --> $DIR/match-prev-arm-needing-semi.rs:16:24 - | -LL | async fn async_dummy() {} - | ^ checked the `Output` of this `async fn`, expected opaque type -note: while checking the return type of the `async fn` - --> $DIR/match-prev-arm-needing-semi.rs:22:25 + --> $DIR/match-prev-arm-needing-semi.rs:19:25 | LL | async fn async_dummy2() {} | ^ checked the `Output` of this `async fn`, found opaque type - = note: expected opaque type `impl Future<Output = ()>` (opaque type at <$DIR/match-prev-arm-needing-semi.rs:16:24>) - found opaque type `impl Future<Output = ()>` (opaque type at <$DIR/match-prev-arm-needing-semi.rs:22:25>) + = note: expected type `impl Future<Output = ()>` (opaque type at <$DIR/match-prev-arm-needing-semi.rs:16:24>) + found opaque type `impl Future<Output = ()>` (opaque type at <$DIR/match-prev-arm-needing-semi.rs:19:25>) = note: distinct uses of `impl Trait` result in different opaque types help: consider `await`ing on both `Future`s | diff --git a/src/test/ui/suggestions/opaque-type-error.stderr b/src/test/ui/suggestions/opaque-type-error.stderr index 133ffb05873..e065e0aaa8e 100644 --- a/src/test/ui/suggestions/opaque-type-error.stderr +++ b/src/test/ui/suggestions/opaque-type-error.stderr @@ -1,9 +1,6 @@ error[E0308]: `if` and `else` have incompatible types --> $DIR/opaque-type-error.rs:20:9 | -LL | fn thing_one() -> impl Future<Output = Result<(), ()>> { - | ------------------------------------ the expected opaque type -... LL | fn thing_two() -> impl Future<Output = Result<(), ()>> { | ------------------------------------ the found opaque type ... @@ -16,8 +13,8 @@ LL | | thing_two() LL | | }.await | |_____- `if` and `else` have incompatible types | - = note: expected opaque type `impl Future<Output = Result<(), ()>>` (opaque type at <$DIR/opaque-type-error.rs:8:19>) - found opaque type `impl Future<Output = Result<(), ()>>` (opaque type at <$DIR/opaque-type-error.rs:12:19>) + = note: expected type `impl Future<Output = Result<(), ()>>` (opaque type at <$DIR/opaque-type-error.rs:8:19>) + found opaque type `impl Future<Output = Result<(), ()>>` (opaque type at <$DIR/opaque-type-error.rs:12:19>) = note: distinct uses of `impl Trait` result in different opaque types help: consider `await`ing on both `Future`s | diff --git a/src/test/ui/traits/alias/issue-83613.rs b/src/test/ui/traits/alias/issue-83613.rs index 04320e72076..0013d5d66f1 100644 --- a/src/test/ui/traits/alias/issue-83613.rs +++ b/src/test/ui/traits/alias/issue-83613.rs @@ -8,6 +8,6 @@ fn mk_opaque() -> OpaqueType { trait AnotherTrait {} impl<T: Send> AnotherTrait for T {} impl AnotherTrait for OpaqueType {} -//~^ ERROR conflicting implementations of trait `AnotherTrait` for type `OpaqueType` +//~^ ERROR conflicting implementations of trait `AnotherTrait` for type `impl OpaqueTrait` //~| ERROR cannot implement trait on type alias impl trait fn main() {} diff --git a/src/test/ui/traits/alias/issue-83613.stderr b/src/test/ui/traits/alias/issue-83613.stderr index 4f19e6607c8..6a3498a3893 100644 --- a/src/test/ui/traits/alias/issue-83613.stderr +++ b/src/test/ui/traits/alias/issue-83613.stderr @@ -10,13 +10,13 @@ note: type alias impl trait defined here LL | type OpaqueType = impl OpaqueTrait; | ^^^^^^^^^^^^^^^^ -error[E0119]: conflicting implementations of trait `AnotherTrait` for type `OpaqueType` +error[E0119]: conflicting implementations of trait `AnotherTrait` for type `impl OpaqueTrait` --> $DIR/issue-83613.rs:10:1 | LL | impl<T: Send> AnotherTrait for T {} | -------------------------------- first implementation here LL | impl AnotherTrait for OpaqueType {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `OpaqueType` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `impl OpaqueTrait` error: aborting due to 2 previous errors diff --git a/src/test/ui/type-alias-impl-trait/argument-types.rs b/src/test/ui/type-alias-impl-trait/argument-types.rs index 185207b9800..8427b5b1fe8 100644 --- a/src/test/ui/type-alias-impl-trait/argument-types.rs +++ b/src/test/ui/type-alias-impl-trait/argument-types.rs @@ -1,12 +1,14 @@ #![feature(type_alias_impl_trait)] #![allow(dead_code)] -// check-pass + use std::fmt::Debug; type Foo = impl Debug; +// FIXME: This should compile, but it currently doesn't fn foo1(mut x: Foo) { x = 22_u32; + //~^ ERROR: mismatched types [E0308] } fn foo2(mut x: Foo) { diff --git a/src/test/ui/type-alias-impl-trait/argument-types.stderr b/src/test/ui/type-alias-impl-trait/argument-types.stderr new file mode 100644 index 00000000000..a87e44a048b --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/argument-types.stderr @@ -0,0 +1,17 @@ +error[E0308]: mismatched types + --> $DIR/argument-types.rs:10:9 + | +LL | type Foo = impl Debug; + | ---------- the expected opaque type +... +LL | fn foo1(mut x: Foo) { + | --- expected due to this parameter type +LL | x = 22_u32; + | ^^^^^^ expected opaque type, found `u32` + | + = note: expected opaque type `impl Debug` + found type `u32` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/type-alias-impl-trait/auto-trait-leakage2.stderr b/src/test/ui/type-alias-impl-trait/auto-trait-leakage2.stderr index 0664275b2ad..4a49d6e4ab8 100644 --- a/src/test/ui/type-alias-impl-trait/auto-trait-leakage2.stderr +++ b/src/test/ui/type-alias-impl-trait/auto-trait-leakage2.stderr @@ -2,15 +2,15 @@ error[E0277]: `Rc<u32>` cannot be sent between threads safely --> $DIR/auto-trait-leakage2.rs:17:13 | LL | type Foo = impl std::fmt::Debug; - | -------------------- within this `Foo` + | -------------------- within this `impl Debug` ... LL | is_send(m::foo()); | ------- ^^^^^^^^ `Rc<u32>` cannot be sent between threads safely | | | required by a bound introduced by this call | - = help: within `Foo`, the trait `Send` is not implemented for `Rc<u32>` - = note: required because it appears within the type `Foo` + = help: within `impl Debug`, the trait `Send` is not implemented for `Rc<u32>` + = note: required because it appears within the type `impl Debug` note: required by a bound in `is_send` --> $DIR/auto-trait-leakage2.rs:14:15 | diff --git a/src/test/ui/type-alias-impl-trait/auto-trait-leakage3.rs b/src/test/ui/type-alias-impl-trait/auto-trait-leakage3.rs index b456b1445e7..5fb7a9473d3 100644 --- a/src/test/ui/type-alias-impl-trait/auto-trait-leakage3.rs +++ b/src/test/ui/type-alias-impl-trait/auto-trait-leakage3.rs @@ -6,7 +6,6 @@ mod m { type Foo = impl std::fmt::Debug; //~^ ERROR: cycle detected when computing type of `m::Foo::{opaque#0}` [E0391] - //~| ERROR: cycle detected when computing type of `m::Foo::{opaque#0}` [E0391] pub fn foo() -> Foo { 22_u32 diff --git a/src/test/ui/type-alias-impl-trait/auto-trait-leakage3.stderr b/src/test/ui/type-alias-impl-trait/auto-trait-leakage3.stderr index 4c44875b4a5..c0147e56c93 100644 --- a/src/test/ui/type-alias-impl-trait/auto-trait-leakage3.stderr +++ b/src/test/ui/type-alias-impl-trait/auto-trait-leakage3.stderr @@ -5,10 +5,11 @@ LL | type Foo = impl std::fmt::Debug; | ^^^^^^^^^^^^^^^^^^^^ | note: ...which requires type-checking `m::bar`... - --> $DIR/auto-trait-leakage3.rs:15:5 + --> $DIR/auto-trait-leakage3.rs:15:9 | -LL | pub fn bar() { - | ^^^^^^^^^^^^ +LL | is_send(foo()); + | ^^^^^^^ + = note: ...which requires evaluating trait selection obligation `impl core::fmt::Debug: core::marker::Send`... = note: ...which again requires computing type of `m::Foo::{opaque#0}`, completing the cycle note: cycle used when checking item types in module `m` --> $DIR/auto-trait-leakage3.rs:6:1 @@ -16,24 +17,6 @@ note: cycle used when checking item types in module `m` LL | mod m { | ^^^^^ -error[E0391]: cycle detected when computing type of `m::Foo::{opaque#0}` - --> $DIR/auto-trait-leakage3.rs:7:16 - | -LL | type Foo = impl std::fmt::Debug; - | ^^^^^^^^^^^^^^^^^^^^ - | -note: ...which requires type-checking `m::bar`... - --> $DIR/auto-trait-leakage3.rs:15:5 - | -LL | pub fn bar() { - | ^^^^^^^^^^^^ - = note: ...which again requires computing type of `m::Foo::{opaque#0}`, completing the cycle -note: cycle used when checking item types in module `m` - --> $DIR/auto-trait-leakage3.rs:6:1 - | -LL | mod m { - | ^^^^^ - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0391`. diff --git a/src/test/ui/type-alias-impl-trait/bound_reduction2.rs b/src/test/ui/type-alias-impl-trait/bound_reduction2.rs index 4d2890b5de5..cee8186dd8f 100644 --- a/src/test/ui/type-alias-impl-trait/bound_reduction2.rs +++ b/src/test/ui/type-alias-impl-trait/bound_reduction2.rs @@ -7,12 +7,13 @@ trait TraitWithAssoc { } type Foo<V> = impl Trait<V>; +//~^ ERROR could not find defining uses trait Trait<U> {} impl<W> Trait<W> for () {} fn foo_desugared<T: TraitWithAssoc>(_: T) -> Foo<T::Assoc> { + //~^ ERROR non-defining opaque type use in defining scope () - //~^ ERROR non-defining opaque type use } diff --git a/src/test/ui/type-alias-impl-trait/bound_reduction2.stderr b/src/test/ui/type-alias-impl-trait/bound_reduction2.stderr index c405b1f6af2..03e696fe898 100644 --- a/src/test/ui/type-alias-impl-trait/bound_reduction2.stderr +++ b/src/test/ui/type-alias-impl-trait/bound_reduction2.stderr @@ -1,8 +1,8 @@ error: non-defining opaque type use in defining scope - --> $DIR/bound_reduction2.rs:16:5 + --> $DIR/bound_reduction2.rs:16:46 | -LL | () - | ^^ +LL | fn foo_desugared<T: TraitWithAssoc>(_: T) -> Foo<T::Assoc> { + | ^^^^^^^^^^^^^ | note: used non-generic type `<T as TraitWithAssoc>::Assoc` for generic parameter --> $DIR/bound_reduction2.rs:9:10 @@ -10,5 +10,11 @@ note: used non-generic type `<T as TraitWithAssoc>::Assoc` for generic parameter LL | type Foo<V> = impl Trait<V>; | ^ -error: aborting due to previous error +error: could not find defining uses + --> $DIR/bound_reduction2.rs:9:15 + | +LL | type Foo<V> = impl Trait<V>; + | ^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors diff --git a/src/test/ui/type-alias-impl-trait/bounds-are-checked.rs b/src/test/ui/type-alias-impl-trait/bounds-are-checked.rs index 83d22161e4e..eecef2338c1 100644 --- a/src/test/ui/type-alias-impl-trait/bounds-are-checked.rs +++ b/src/test/ui/type-alias-impl-trait/bounds-are-checked.rs @@ -4,11 +4,11 @@ #![feature(type_alias_impl_trait)] type X<'a> = impl Into<&'static str> + From<&'a str>; +//~^ ERROR mismatched types fn f<'a: 'static>(t: &'a str) -> X<'a> { //~^ WARNING unnecessary lifetime parameter t - //~^ ERROR non-defining opaque type use } fn extend_lt<'a>(o: &'a str) -> &'static str { diff --git a/src/test/ui/type-alias-impl-trait/bounds-are-checked.stderr b/src/test/ui/type-alias-impl-trait/bounds-are-checked.stderr index d87ef2ec79c..da9f81d6bd3 100644 --- a/src/test/ui/type-alias-impl-trait/bounds-are-checked.stderr +++ b/src/test/ui/type-alias-impl-trait/bounds-are-checked.stderr @@ -1,19 +1,26 @@ warning: unnecessary lifetime parameter `'a` - --> $DIR/bounds-are-checked.rs:8:6 + --> $DIR/bounds-are-checked.rs:9:6 | LL | fn f<'a: 'static>(t: &'a str) -> X<'a> { | ^^^^^^^^^^^ | = help: you can use the `'static` lifetime directly, in place of `'a` -error: non-defining opaque type use in defining scope - --> $DIR/bounds-are-checked.rs:10:5 +error[E0308]: mismatched types + --> $DIR/bounds-are-checked.rs:6:14 | LL | type X<'a> = impl Into<&'static str> + From<&'a str>; - | -- cannot use static lifetime; use a bound lifetime instead or remove the lifetime parameter from the opaque type -... -LL | t - | ^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch + | + = note: expected trait `From<&'a str>` + found trait `From<&'static str>` +note: the lifetime `'a` as defined here... + --> $DIR/bounds-are-checked.rs:6:8 + | +LL | type X<'a> = impl Into<&'static str> + From<&'a str>; + | ^^ + = note: ...does not necessarily outlive the static lifetime error: aborting due to previous error; 1 warning emitted +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/type-alias-impl-trait/declared_but_never_defined.rs b/src/test/ui/type-alias-impl-trait/declared_but_never_defined.rs index 6febd07157a..c4bf56a9197 100644 --- a/src/test/ui/type-alias-impl-trait/declared_but_never_defined.rs +++ b/src/test/ui/type-alias-impl-trait/declared_but_never_defined.rs @@ -3,4 +3,4 @@ fn main() {} // declared but never defined -type Bar = impl std::fmt::Debug; //~ ERROR unconstrained opaque type +type Bar = impl std::fmt::Debug; //~ ERROR could not find defining uses diff --git a/src/test/ui/type-alias-impl-trait/declared_but_never_defined.stderr b/src/test/ui/type-alias-impl-trait/declared_but_never_defined.stderr index 60bc24320a3..21c2e8a9db6 100644 --- a/src/test/ui/type-alias-impl-trait/declared_but_never_defined.stderr +++ b/src/test/ui/type-alias-impl-trait/declared_but_never_defined.stderr @@ -1,10 +1,8 @@ -error: unconstrained opaque type +error: could not find defining uses --> $DIR/declared_but_never_defined.rs:6:12 | LL | type Bar = impl std::fmt::Debug; | ^^^^^^^^^^^^^^^^^^^^ - | - = note: `Bar` must be used in combination with a concrete type within the same module error: aborting due to previous error diff --git a/src/test/ui/type-alias-impl-trait/declared_but_not_defined_in_scope.rs b/src/test/ui/type-alias-impl-trait/declared_but_not_defined_in_scope.rs index 5bda5f0fcea..7ea517eb734 100644 --- a/src/test/ui/type-alias-impl-trait/declared_but_not_defined_in_scope.rs +++ b/src/test/ui/type-alias-impl-trait/declared_but_not_defined_in_scope.rs @@ -4,7 +4,7 @@ fn main() {} mod boo { // declared in module but not defined inside of it - pub type Boo = impl ::std::fmt::Debug; //~ ERROR unconstrained opaque type + pub type Boo = impl ::std::fmt::Debug; //~ ERROR could not find defining uses } fn bomp() -> boo::Boo { diff --git a/src/test/ui/type-alias-impl-trait/declared_but_not_defined_in_scope.stderr b/src/test/ui/type-alias-impl-trait/declared_but_not_defined_in_scope.stderr index 26308c6ff6b..0b4c262bbb4 100644 --- a/src/test/ui/type-alias-impl-trait/declared_but_not_defined_in_scope.stderr +++ b/src/test/ui/type-alias-impl-trait/declared_but_not_defined_in_scope.stderr @@ -1,10 +1,8 @@ -error: unconstrained opaque type +error: could not find defining uses --> $DIR/declared_but_not_defined_in_scope.rs:7:20 | LL | pub type Boo = impl ::std::fmt::Debug; | ^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `Boo` must be used in combination with a concrete type within the same module error[E0308]: mismatched types --> $DIR/declared_but_not_defined_in_scope.rs:11:5 @@ -12,11 +10,13 @@ error[E0308]: mismatched types LL | pub type Boo = impl ::std::fmt::Debug; | ---------------------- the expected opaque type ... +LL | fn bomp() -> boo::Boo { + | -------- expected `impl Debug` because of return type LL | "" | ^^ expected opaque type, found `&str` | - = note: expected opaque type `Boo` - found reference `&str` + = note: expected opaque type `impl Debug` + found reference `&'static str` error: aborting due to 2 previous errors diff --git a/src/test/ui/type-alias-impl-trait/different_defining_uses_never_type.rs b/src/test/ui/type-alias-impl-trait/different_defining_uses_never_type.rs index 7740f774ebc..95cbcfec2dc 100644 --- a/src/test/ui/type-alias-impl-trait/different_defining_uses_never_type.rs +++ b/src/test/ui/type-alias-impl-trait/different_defining_uses_never_type.rs @@ -1,5 +1,5 @@ #![feature(type_alias_impl_trait)] -// check-pass + fn main() {} // two definitions with different types @@ -10,9 +10,11 @@ fn foo() -> Foo { } fn bar() -> Foo { + //~^ ERROR concrete type differs from previous panic!() } fn boo() -> Foo { + //~^ ERROR concrete type differs from previous loop {} } diff --git a/src/test/ui/type-alias-impl-trait/different_defining_uses_never_type.stderr b/src/test/ui/type-alias-impl-trait/different_defining_uses_never_type.stderr new file mode 100644 index 00000000000..6274029e4f5 --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/different_defining_uses_never_type.stderr @@ -0,0 +1,26 @@ +error: concrete type differs from previous defining opaque type use + --> $DIR/different_defining_uses_never_type.rs:12:1 + | +LL | fn bar() -> Foo { + | ^^^^^^^^^^^^^^^ expected `&'static str`, got `()` + | +note: previous use here + --> $DIR/different_defining_uses_never_type.rs:8:1 + | +LL | fn foo() -> Foo { + | ^^^^^^^^^^^^^^^ + +error: concrete type differs from previous defining opaque type use + --> $DIR/different_defining_uses_never_type.rs:17:1 + | +LL | fn boo() -> Foo { + | ^^^^^^^^^^^^^^^ expected `&'static str`, got `()` + | +note: previous use here + --> $DIR/different_defining_uses_never_type.rs:8:1 + | +LL | fn foo() -> Foo { + | ^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/type-alias-impl-trait/fallback.rs b/src/test/ui/type-alias-impl-trait/fallback.rs index d7e93335f47..fe1ca2230da 100644 --- a/src/test/ui/type-alias-impl-trait/fallback.rs +++ b/src/test/ui/type-alias-impl-trait/fallback.rs @@ -1,5 +1,5 @@ -// Tests that we correctly handle opaque types being used opaquely, -// even within their defining scope. +// Tests that we correctly handle the instantiated +// inference variable being completely unconstrained. // // check-pass #![feature(type_alias_impl_trait)] diff --git a/src/test/ui/type-alias-impl-trait/field-types.rs b/src/test/ui/type-alias-impl-trait/field-types.rs index d99ed58127b..91494a82d0f 100644 --- a/src/test/ui/type-alias-impl-trait/field-types.rs +++ b/src/test/ui/type-alias-impl-trait/field-types.rs @@ -1,11 +1,12 @@ #![feature(type_alias_impl_trait)] #![allow(dead_code)] -// check-pass +// FIXME This should compile, but it currently doesn't use std::fmt::Debug; type Foo = impl Debug; +//~^ ERROR: could not find defining uses struct Bar { foo: Foo, @@ -13,6 +14,7 @@ struct Bar { fn bar() -> Bar { Bar { foo: "foo" } + //~^ ERROR: mismatched types [E0308] } fn main() {} diff --git a/src/test/ui/type-alias-impl-trait/field-types.stderr b/src/test/ui/type-alias-impl-trait/field-types.stderr new file mode 100644 index 00000000000..18c2abbdf37 --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/field-types.stderr @@ -0,0 +1,21 @@ +error[E0308]: mismatched types + --> $DIR/field-types.rs:16:16 + | +LL | type Foo = impl Debug; + | ---------- the expected opaque type +... +LL | Bar { foo: "foo" } + | ^^^^^ expected opaque type, found `&str` + | + = note: expected opaque type `impl Debug` + found reference `&'static str` + +error: could not find defining uses + --> $DIR/field-types.rs:8:12 + | +LL | type Foo = impl Debug; + | ^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.rs b/src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.rs index c9b9e128f88..885aae619d6 100644 --- a/src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.rs +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.rs @@ -3,9 +3,9 @@ fn main() {} type Two<'a, 'b> = impl std::fmt::Debug; - +//~^ ERROR could not find defining uses fn one<'a>(t: &'a ()) -> Two<'a, 'a> { - t //~^ ERROR non-defining opaque type use + t } diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.stderr index 222aaea78d9..b99c6a51f4b 100644 --- a/src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.stderr @@ -1,8 +1,8 @@ error: non-defining opaque type use in defining scope - --> $DIR/generic_duplicate_lifetime_param.rs:9:5 + --> $DIR/generic_duplicate_lifetime_param.rs:8:26 | -LL | t - | ^ +LL | fn one<'a>(t: &'a ()) -> Two<'a, 'a> { + | ^^^^^^^^^^^ | note: lifetime used multiple times --> $DIR/generic_duplicate_lifetime_param.rs:5:10 @@ -10,5 +10,11 @@ note: lifetime used multiple times LL | type Two<'a, 'b> = impl std::fmt::Debug; | ^^ ^^ -error: aborting due to previous error +error: could not find defining uses + --> $DIR/generic_duplicate_lifetime_param.rs:5:20 + | +LL | type Two<'a, 'b> = impl std::fmt::Debug; + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.rs b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.rs index 093c1c23186..33cd2f6ba07 100644 --- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.rs +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.rs @@ -6,23 +6,23 @@ fn main() {} // test that unused generic parameters are ok type TwoTys<T, U> = impl Debug; - +//~^ ERROR could not find defining uses type TwoLifetimes<'a, 'b> = impl Debug; - +//~^ ERROR could not find defining uses type TwoConsts<const X: usize, const Y: usize> = impl Debug; - +//~^ ERROR could not find defining uses fn one_ty<T: Debug>(t: T) -> TwoTys<T, T> { - t //~^ ERROR non-defining opaque type use in defining scope + t } fn one_lifetime<'a>(t: &'a u32) -> TwoLifetimes<'a, 'a> { - t //~^ ERROR non-defining opaque type use in defining scope + t } fn one_const<const N: usize>(t: *mut [u8; N]) -> TwoConsts<N, N> { - t //~^ ERROR non-defining opaque type use in defining scope + t } diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr index 922e41e0f68..52c60d1777e 100644 --- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr @@ -1,8 +1,8 @@ error: non-defining opaque type use in defining scope - --> $DIR/generic_duplicate_param_use.rs:16:5 + --> $DIR/generic_duplicate_param_use.rs:15:30 | -LL | t - | ^ +LL | fn one_ty<T: Debug>(t: T) -> TwoTys<T, T> { + | ^^^^^^^^^^^^ | note: type used multiple times --> $DIR/generic_duplicate_param_use.rs:8:13 @@ -10,11 +10,17 @@ note: type used multiple times LL | type TwoTys<T, U> = impl Debug; | ^ ^ +error: could not find defining uses + --> $DIR/generic_duplicate_param_use.rs:8:21 + | +LL | type TwoTys<T, U> = impl Debug; + | ^^^^^^^^^^ + error: non-defining opaque type use in defining scope - --> $DIR/generic_duplicate_param_use.rs:21:5 + --> $DIR/generic_duplicate_param_use.rs:20:36 | -LL | t - | ^ +LL | fn one_lifetime<'a>(t: &'a u32) -> TwoLifetimes<'a, 'a> { + | ^^^^^^^^^^^^^^^^^^^^ | note: lifetime used multiple times --> $DIR/generic_duplicate_param_use.rs:10:19 @@ -22,11 +28,17 @@ note: lifetime used multiple times LL | type TwoLifetimes<'a, 'b> = impl Debug; | ^^ ^^ +error: could not find defining uses + --> $DIR/generic_duplicate_param_use.rs:10:29 + | +LL | type TwoLifetimes<'a, 'b> = impl Debug; + | ^^^^^^^^^^ + error: non-defining opaque type use in defining scope - --> $DIR/generic_duplicate_param_use.rs:26:5 + --> $DIR/generic_duplicate_param_use.rs:25:50 | -LL | t - | ^ +LL | fn one_const<const N: usize>(t: *mut [u8; N]) -> TwoConsts<N, N> { + | ^^^^^^^^^^^^^^^ | note: constant used multiple times --> $DIR/generic_duplicate_param_use.rs:12:22 @@ -34,5 +46,11 @@ note: constant used multiple times LL | type TwoConsts<const X: usize, const Y: usize> = impl Debug; | ^ ^ -error: aborting due to 3 previous errors +error: could not find defining uses + --> $DIR/generic_duplicate_param_use.rs:12:50 + | +LL | type TwoConsts<const X: usize, const Y: usize> = impl Debug; + | ^^^^^^^^^^ + +error: aborting due to 6 previous errors diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use2.rs b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use2.rs index 81bf9770d02..04fb57b39c0 100644 --- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use2.rs +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use2.rs @@ -8,6 +8,11 @@ fn main() {} type Two<T, U> = impl Debug; //~^ ERROR `T` doesn't implement `Debug` +fn one<T: Debug>(t: T) -> Two<T, T> { + //~^ ERROR non-defining opaque type use in defining scope + t +} + fn two<T: Debug, U>(t: T, _: U) -> Two<T, U> { t } diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use2.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use2.stderr index 84aa260b099..fca9b70d184 100644 --- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use2.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use2.stderr @@ -1,3 +1,15 @@ +error: non-defining opaque type use in defining scope + --> $DIR/generic_duplicate_param_use2.rs:11:27 + | +LL | fn one<T: Debug>(t: T) -> Two<T, T> { + | ^^^^^^^^^ + | +note: type used multiple times + --> $DIR/generic_duplicate_param_use2.rs:8:10 + | +LL | type Two<T, U> = impl Debug; + | ^ ^ + error[E0277]: `T` doesn't implement `Debug` --> $DIR/generic_duplicate_param_use2.rs:8:18 | @@ -9,6 +21,6 @@ help: consider restricting type parameter `T` LL | type Two<T: std::fmt::Debug, U> = impl Debug; | +++++++++++++++++ -error: aborting due to previous error +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use3.rs b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use3.rs index c95692182c2..1a755d39026 100644 --- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use3.rs +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use3.rs @@ -8,6 +8,11 @@ fn main() {} type Two<T, U> = impl Debug; //~^ ERROR `T` doesn't implement `Debug` +fn one<T: Debug>(t: T) -> Two<T, T> { + //~^ ERROR non-defining opaque type use in defining scope + t +} + fn two<T: Debug, U>(t: T, _: U) -> Two<T, U> { t } diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use3.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use3.stderr index e5a70fa8ce5..90b04c043a0 100644 --- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use3.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use3.stderr @@ -1,11 +1,23 @@ +error: non-defining opaque type use in defining scope + --> $DIR/generic_duplicate_param_use3.rs:11:27 + | +LL | fn one<T: Debug>(t: T) -> Two<T, T> { + | ^^^^^^^^^ + | +note: type used multiple times + --> $DIR/generic_duplicate_param_use3.rs:8:10 + | +LL | type Two<T, U> = impl Debug; + | ^ ^ + error: concrete type differs from previous defining opaque type use - --> $DIR/generic_duplicate_param_use3.rs:15:1 + --> $DIR/generic_duplicate_param_use3.rs:20:1 | LL | fn three<T, U: Debug>(_: T, u: U) -> Two<T, U> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `T`, got `U` | note: previous use here - --> $DIR/generic_duplicate_param_use3.rs:11:1 + --> $DIR/generic_duplicate_param_use3.rs:16:1 | LL | fn two<T: Debug, U>(t: T, _: U) -> Two<T, U> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -21,6 +33,6 @@ help: consider restricting type parameter `T` LL | type Two<T: std::fmt::Debug, U> = impl Debug; | +++++++++++++++++ -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use4.rs b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use4.rs index aee2550e907..50d95c83d58 100644 --- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use4.rs +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use4.rs @@ -8,6 +8,11 @@ fn main() {} type Two<T, U> = impl Debug; //~^ ERROR `U` doesn't implement `Debug` +fn one<T: Debug>(t: T) -> Two<T, T> { + //~^ ERROR non-defining opaque type use in defining scope + t +} + fn three<T, U: Debug>(_: T, u: U) -> Two<T, U> { u } diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use4.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use4.stderr index 0491d61030e..c4be2fa83f1 100644 --- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use4.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use4.stderr @@ -1,3 +1,15 @@ +error: non-defining opaque type use in defining scope + --> $DIR/generic_duplicate_param_use4.rs:11:27 + | +LL | fn one<T: Debug>(t: T) -> Two<T, T> { + | ^^^^^^^^^ + | +note: type used multiple times + --> $DIR/generic_duplicate_param_use4.rs:8:10 + | +LL | type Two<T, U> = impl Debug; + | ^ ^ + error[E0277]: `U` doesn't implement `Debug` --> $DIR/generic_duplicate_param_use4.rs:8:18 | @@ -9,6 +21,6 @@ help: consider restricting type parameter `U` LL | type Two<T, U: std::fmt::Debug> = impl Debug; | +++++++++++++++++ -error: aborting due to previous error +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/type-alias-impl-trait/generic_nondefining_use.rs b/src/test/ui/type-alias-impl-trait/generic_nondefining_use.rs index f39741a6a62..cf43085877f 100644 --- a/src/test/ui/type-alias-impl-trait/generic_nondefining_use.rs +++ b/src/test/ui/type-alias-impl-trait/generic_nondefining_use.rs @@ -5,25 +5,25 @@ use std::fmt::Debug; fn main() {} type OneTy<T> = impl Debug; - +//~^ ERROR could not find defining uses type OneLifetime<'a> = impl Debug; - +//~^ ERROR could not find defining uses type OneConst<const X: usize> = impl Debug; - +//~^ ERROR could not find defining uses // Not defining uses, because they doesn't define *all* possible generics. fn concrete_ty() -> OneTy<u32> { - 5u32 //~^ ERROR non-defining opaque type use in defining scope + 5u32 } fn concrete_lifetime() -> OneLifetime<'static> { - 6u32 //~^ ERROR non-defining opaque type use in defining scope + 6u32 } fn concrete_const() -> OneConst<{ 123 }> { - 7u32 //~^ ERROR non-defining opaque type use in defining scope + 7u32 } diff --git a/src/test/ui/type-alias-impl-trait/generic_nondefining_use.stderr b/src/test/ui/type-alias-impl-trait/generic_nondefining_use.stderr index 36694900c17..3aa42a25484 100644 --- a/src/test/ui/type-alias-impl-trait/generic_nondefining_use.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_nondefining_use.stderr @@ -1,8 +1,8 @@ error: non-defining opaque type use in defining scope - --> $DIR/generic_nondefining_use.rs:17:5 + --> $DIR/generic_nondefining_use.rs:16:21 | -LL | 5u32 - | ^^^^ +LL | fn concrete_ty() -> OneTy<u32> { + | ^^^^^^^^^^ | note: used non-generic type `u32` for generic parameter --> $DIR/generic_nondefining_use.rs:7:12 @@ -10,20 +10,32 @@ note: used non-generic type `u32` for generic parameter LL | type OneTy<T> = impl Debug; | ^ +error: could not find defining uses + --> $DIR/generic_nondefining_use.rs:7:17 + | +LL | type OneTy<T> = impl Debug; + | ^^^^^^^^^^ + error: non-defining opaque type use in defining scope - --> $DIR/generic_nondefining_use.rs:22:5 + --> $DIR/generic_nondefining_use.rs:21:27 | LL | type OneLifetime<'a> = impl Debug; | -- cannot use static lifetime; use a bound lifetime instead or remove the lifetime parameter from the opaque type ... -LL | 6u32 - | ^^^^ +LL | fn concrete_lifetime() -> OneLifetime<'static> { + | ^^^^^^^^^^^^^^^^^^^^ + +error: could not find defining uses + --> $DIR/generic_nondefining_use.rs:9:24 + | +LL | type OneLifetime<'a> = impl Debug; + | ^^^^^^^^^^ error: non-defining opaque type use in defining scope - --> $DIR/generic_nondefining_use.rs:27:5 + --> $DIR/generic_nondefining_use.rs:26:24 | -LL | 7u32 - | ^^^^ +LL | fn concrete_const() -> OneConst<{ 123 }> { + | ^^^^^^^^^^^^^^^^^ | note: used non-generic constant `123_usize` for generic parameter --> $DIR/generic_nondefining_use.rs:11:21 @@ -31,5 +43,11 @@ note: used non-generic constant `123_usize` for generic parameter LL | type OneConst<const X: usize> = impl Debug; | ^ -error: aborting due to 3 previous errors +error: could not find defining uses + --> $DIR/generic_nondefining_use.rs:11:33 + | +LL | type OneConst<const X: usize> = impl Debug; + | ^^^^^^^^^^ + +error: aborting due to 6 previous errors diff --git a/src/test/ui/type-alias-impl-trait/generic_not_used.rs b/src/test/ui/type-alias-impl-trait/generic_not_used.rs index c70f473cff5..dd6300a64f4 100644 --- a/src/test/ui/type-alias-impl-trait/generic_not_used.rs +++ b/src/test/ui/type-alias-impl-trait/generic_not_used.rs @@ -6,6 +6,6 @@ type WrongGeneric<T: 'static> = impl 'static; //~^ ERROR: at least one trait must be specified fn wrong_generic<U: 'static, V: 'static>(_: U, v: V) -> WrongGeneric<U> { - v //~^ ERROR type parameter `V` is part of concrete type but not used in parameter list + v } diff --git a/src/test/ui/type-alias-impl-trait/generic_not_used.stderr b/src/test/ui/type-alias-impl-trait/generic_not_used.stderr index fd720239a52..8015ff7eded 100644 --- a/src/test/ui/type-alias-impl-trait/generic_not_used.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_not_used.stderr @@ -5,10 +5,14 @@ LL | type WrongGeneric<T: 'static> = impl 'static; | ^^^^^^^^^^^^ error: type parameter `V` is part of concrete type but not used in parameter list for the `impl Trait` type alias - --> $DIR/generic_not_used.rs:9:5 + --> $DIR/generic_not_used.rs:8:73 | -LL | v - | ^ +LL | fn wrong_generic<U: 'static, V: 'static>(_: U, v: V) -> WrongGeneric<U> { + | _________________________________________________________________________^ +LL | | +LL | | v +LL | | } + | |_^ error: aborting due to 2 previous errors diff --git a/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.nll.stderr b/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.nll.stderr index dc85db66d32..f4e1de8e50f 100644 --- a/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.nll.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.nll.stderr @@ -1,29 +1,41 @@ error: at least one trait must be specified - --> $DIR/generic_type_does_not_live_long_enough.rs:10:24 + --> $DIR/generic_type_does_not_live_long_enough.rs:9:24 | LL | type WrongGeneric<T> = impl 'static; | ^^^^^^^^^^^^ -error: non-defining opaque type use in defining scope +error[E0308]: mismatched types --> $DIR/generic_type_does_not_live_long_enough.rs:6:18 | LL | let z: i32 = x; - | ^ + | --- ^ expected `i32`, found opaque type + | | + | expected due to this +... +LL | type WrongGeneric<T> = impl 'static; + | ------------ the found opaque type | -note: used non-generic type `&'static i32` for generic parameter - --> $DIR/generic_type_does_not_live_long_enough.rs:10:19 + = note: expected type `i32` + found opaque type `impl Sized` + +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/generic_type_does_not_live_long_enough.rs:12:30 | -LL | type WrongGeneric<T> = impl 'static; - | ^ +LL | fn wrong_generic<T>(t: T) -> WrongGeneric<T> { + | ^^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `T: 'static`... error[E0310]: the parameter type `T` may not live long enough - --> $DIR/generic_type_does_not_live_long_enough.rs:14:5 + --> $DIR/generic_type_does_not_live_long_enough.rs:9:24 | -LL | t - | ^ +LL | type WrongGeneric<T> = impl 'static; + | ^^^^^^^^^^^^ | = help: consider adding an explicit lifetime bound `T: 'static`... + = note: ...so that the type `T` will meet its required lifetime bounds -error: aborting due to 3 previous errors +error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0310`. +Some errors have detailed explanations: E0308, E0310. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.rs b/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.rs index cb90776472b..78d25e30e03 100644 --- a/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.rs +++ b/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.rs @@ -3,14 +3,13 @@ fn main() { let y = 42; let x = wrong_generic(&y); - let z: i32 = x; - //~^ ERROR non-defining opaque type use + let z: i32 = x; //~ ERROR mismatched types } type WrongGeneric<T> = impl 'static; //~^ ERROR: at least one trait must be specified fn wrong_generic<T>(t: T) -> WrongGeneric<T> { - t //~^ ERROR the parameter type `T` may not live long enough + t } diff --git a/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.stderr b/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.stderr index 15ec2eed3da..568784372e5 100644 --- a/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.stderr +++ b/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.stderr @@ -1,29 +1,32 @@ error: at least one trait must be specified - --> $DIR/generic_type_does_not_live_long_enough.rs:10:24 + --> $DIR/generic_type_does_not_live_long_enough.rs:9:24 | LL | type WrongGeneric<T> = impl 'static; | ^^^^^^^^^^^^ -error: non-defining opaque type use in defining scope +error[E0308]: mismatched types --> $DIR/generic_type_does_not_live_long_enough.rs:6:18 | LL | let z: i32 = x; - | ^ - | -note: used non-generic type `&'static i32` for generic parameter - --> $DIR/generic_type_does_not_live_long_enough.rs:10:19 - | + | --- ^ expected `i32`, found opaque type + | | + | expected due to this +... LL | type WrongGeneric<T> = impl 'static; - | ^ + | ------------ the found opaque type + | + = note: expected type `i32` + found opaque type `impl Sized` error[E0310]: the parameter type `T` may not live long enough - --> $DIR/generic_type_does_not_live_long_enough.rs:14:5 + --> $DIR/generic_type_does_not_live_long_enough.rs:12:30 | LL | fn wrong_generic<T>(t: T) -> WrongGeneric<T> { - | - help: consider adding an explicit lifetime bound...: `T: 'static` -LL | t - | ^ ...so that the type `T` will meet its required lifetime bounds + | - ^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + | | + | help: consider adding an explicit lifetime bound...: `T: 'static` error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0310`. +Some errors have detailed explanations: E0308, E0310. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/type-alias-impl-trait/inference-cycle.rs b/src/test/ui/type-alias-impl-trait/inference-cycle.rs index 608572978a3..c781e200bf8 100644 --- a/src/test/ui/type-alias-impl-trait/inference-cycle.rs +++ b/src/test/ui/type-alias-impl-trait/inference-cycle.rs @@ -3,8 +3,7 @@ mod m { type Foo = impl std::fmt::Debug; - //~^ ERROR cycle detected - //~| ERROR cycle detected + //~^ ERROR: cycle detected when computing type of `m::Foo::{opaque#0}` [E0391] // Cycle: error today, but it'd be nice if it eventually worked @@ -18,6 +17,7 @@ mod m { fn baz() { let f: Foo = 22_u32; + //~^ ERROR: mismatched types [E0308] } fn is_send<T: Send>(_: T) {} diff --git a/src/test/ui/type-alias-impl-trait/inference-cycle.stderr b/src/test/ui/type-alias-impl-trait/inference-cycle.stderr index 3ed86fae8a1..e1212466477 100644 --- a/src/test/ui/type-alias-impl-trait/inference-cycle.stderr +++ b/src/test/ui/type-alias-impl-trait/inference-cycle.stderr @@ -5,10 +5,11 @@ LL | type Foo = impl std::fmt::Debug; | ^^^^^^^^^^^^^^^^^^^^ | note: ...which requires type-checking `m::bar`... - --> $DIR/inference-cycle.rs:15:5 + --> $DIR/inference-cycle.rs:15:9 | -LL | pub fn bar() { - | ^^^^^^^^^^^^ +LL | is_send(foo()); // Today: error + | ^^^^^^^ + = note: ...which requires evaluating trait selection obligation `impl core::fmt::Debug: core::marker::Send`... = note: ...which again requires computing type of `m::Foo::{opaque#0}`, completing the cycle note: cycle used when checking item types in module `m` --> $DIR/inference-cycle.rs:4:1 @@ -16,24 +17,21 @@ note: cycle used when checking item types in module `m` LL | mod m { | ^^^^^ -error[E0391]: cycle detected when computing type of `m::Foo::{opaque#0}` - --> $DIR/inference-cycle.rs:5:16 +error[E0308]: mismatched types + --> $DIR/inference-cycle.rs:19:22 | LL | type Foo = impl std::fmt::Debug; - | ^^^^^^^^^^^^^^^^^^^^ - | -note: ...which requires type-checking `m::bar`... - --> $DIR/inference-cycle.rs:15:5 - | -LL | pub fn bar() { - | ^^^^^^^^^^^^ - = note: ...which again requires computing type of `m::Foo::{opaque#0}`, completing the cycle -note: cycle used when checking item types in module `m` - --> $DIR/inference-cycle.rs:4:1 - | -LL | mod m { - | ^^^^^ + | -------------------- the expected opaque type +... +LL | let f: Foo = 22_u32; + | --- ^^^^^^ expected opaque type, found `u32` + | | + | expected due to this + | + = note: expected opaque type `impl Debug` + found type `u32` error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0391`. +Some errors have detailed explanations: E0308, E0391. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/type-alias-impl-trait/issue-53598.rs b/src/test/ui/type-alias-impl-trait/issue-53598.rs index 34be4202744..37b330ba4b8 100644 --- a/src/test/ui/type-alias-impl-trait/issue-53598.rs +++ b/src/test/ui/type-alias-impl-trait/issue-53598.rs @@ -18,8 +18,8 @@ impl Foo for S2 { type Item = impl Debug; fn foo<T: Debug>(_: T) -> Self::Item { - S::<T>(Default::default()) //~^ Error type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias + S::<T>(Default::default()) } } diff --git a/src/test/ui/type-alias-impl-trait/issue-53598.stderr b/src/test/ui/type-alias-impl-trait/issue-53598.stderr index 34f0aa0d98d..4c8144a2359 100644 --- a/src/test/ui/type-alias-impl-trait/issue-53598.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-53598.stderr @@ -1,8 +1,12 @@ error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias - --> $DIR/issue-53598.rs:21:9 + --> $DIR/issue-53598.rs:20:42 | -LL | S::<T>(Default::default()) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo<T: Debug>(_: T) -> Self::Item { + | __________________________________________^ +LL | | +LL | | S::<T>(Default::default()) +LL | | } + | |_____^ error: aborting due to previous error diff --git a/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.nll.stderr b/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.nll.stderr index 1538274d45c..a4ccae4eb7e 100644 --- a/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.nll.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.nll.stderr @@ -1,14 +1,38 @@ error: higher-ranked subtype error - --> $DIR/issue-57611-trait-alias.rs:20:9 + --> $DIR/issue-57611-trait-alias.rs:21:9 | LL | |x| x | ^^^^^ error: higher-ranked subtype error - --> $DIR/issue-57611-trait-alias.rs:20:9 + --> $DIR/issue-57611-trait-alias.rs:21:9 | LL | |x| x | ^^^^^ -error: aborting due to 2 previous errors +error[E0308]: mismatched types + --> $DIR/issue-57611-trait-alias.rs:17:16 + | +LL | type Bar = impl Baz<Self, Self>; + | ^^^^^^^^^^^^^^^^^^^^ one type is more general than the other + | + = note: expected type `for<'r> Fn<(&'r X,)>` + found type `Fn<(&'static X,)>` +note: this closure does not fulfill the lifetime requirements + --> $DIR/issue-57611-trait-alias.rs:21:9 + | +LL | |x| x + | ^^^^^ + +error: implementation of `FnOnce` is not general enough + --> $DIR/issue-57611-trait-alias.rs:17:16 + | +LL | type Bar = impl Baz<Self, Self>; + | ^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough + | + = note: closure with signature `fn(&'static X) -> &'static X` must implement `FnOnce<(&'0 X,)>`, for any lifetime `'0`... + = note: ...but it actually implements `FnOnce<(&'static X,)>` + +error: aborting due to 4 previous errors +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.rs b/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.rs index 7c6e7642484..625e46b6bc0 100644 --- a/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.rs +++ b/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.rs @@ -17,8 +17,8 @@ impl Foo for X { type Bar = impl Baz<Self, Self>; fn bar(&self) -> Self::Bar { - |x| x //~^ ERROR implementation of `FnOnce` is not general enough + |x| x } } diff --git a/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.stderr b/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.stderr index 45329ea292d..54d237159d8 100644 --- a/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.stderr @@ -1,8 +1,8 @@ error: implementation of `FnOnce` is not general enough - --> $DIR/issue-57611-trait-alias.rs:20:9 + --> $DIR/issue-57611-trait-alias.rs:19:22 | -LL | |x| x - | ^^^^^ implementation of `FnOnce` is not general enough +LL | fn bar(&self) -> Self::Bar { + | ^^^^^^^^^ implementation of `FnOnce` is not general enough | = note: closure with signature `fn(&'2 X) -> &X` must implement `FnOnce<(&'1 X,)>`, for any lifetime `'1`... = note: ...but it actually implements `FnOnce<(&'2 X,)>`, for some specific lifetime `'2` diff --git a/src/test/ui/type-alias-impl-trait/issue-57700.rs b/src/test/ui/type-alias-impl-trait/issue-57700.rs index ba8bda76cec..f1db4d3291b 100644 --- a/src/test/ui/type-alias-impl-trait/issue-57700.rs +++ b/src/test/ui/type-alias-impl-trait/issue-57700.rs @@ -14,8 +14,8 @@ impl<C> Foo for C { type Bar = impl Foo; fn foo(self: impl Deref<Target = Self>) -> Self::Bar { - self //~^ Error type parameter `impl Deref<Target = Self>` is part of concrete type but not used in parameter list for the `impl Trait` type alias + self } } diff --git a/src/test/ui/type-alias-impl-trait/issue-57700.stderr b/src/test/ui/type-alias-impl-trait/issue-57700.stderr index 56ad997f843..c701e3e74ef 100644 --- a/src/test/ui/type-alias-impl-trait/issue-57700.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-57700.stderr @@ -1,8 +1,12 @@ error: type parameter `impl Deref<Target = Self>` is part of concrete type but not used in parameter list for the `impl Trait` type alias - --> $DIR/issue-57700.rs:17:9 + --> $DIR/issue-57700.rs:16:58 | -LL | self - | ^^^^ +LL | fn foo(self: impl Deref<Target = Self>) -> Self::Bar { + | __________________________________________________________^ +LL | | +LL | | self +LL | | } + | |_____^ error: aborting due to previous error diff --git a/src/test/ui/type-alias-impl-trait/issue-58951-2.rs b/src/test/ui/type-alias-impl-trait/issue-58951-2.rs deleted file mode 100644 index e4ba7f8e2a6..00000000000 --- a/src/test/ui/type-alias-impl-trait/issue-58951-2.rs +++ /dev/null @@ -1,18 +0,0 @@ -// check-pass - -#![feature(type_alias_impl_trait)] - -mod defining_use_scope { - pub type A = impl Iterator; - - pub fn def_a() -> A { - 0..1 - } -} -use defining_use_scope::*; - -pub fn use_a() { - def_a().map(|x| x); -} - -fn main() {} diff --git a/src/test/ui/type-alias-impl-trait/issue-60371.rs b/src/test/ui/type-alias-impl-trait/issue-60371.rs index 37a2f28ce07..9d2ba849c86 100644 --- a/src/test/ui/type-alias-impl-trait/issue-60371.rs +++ b/src/test/ui/type-alias-impl-trait/issue-60371.rs @@ -11,6 +11,7 @@ impl Bug for &() { const FUN: fn() -> Self::Item = || (); //~^ ERROR the trait bound `(): Bug` is not satisfied + //~| ERROR non-defining opaque type use in defining scope } fn main() {} diff --git a/src/test/ui/type-alias-impl-trait/issue-60371.stderr b/src/test/ui/type-alias-impl-trait/issue-60371.stderr index 3666b6e97ec..62ab7eb4560 100644 --- a/src/test/ui/type-alias-impl-trait/issue-60371.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-60371.stderr @@ -11,12 +11,21 @@ error[E0277]: the trait bound `(): Bug` is not satisfied --> $DIR/issue-60371.rs:12:40 | LL | const FUN: fn() -> Self::Item = || (); - | ^^ the trait `Bug` is not implemented for `()` + | ^ the trait `Bug` is not implemented for `()` | = help: the following implementations were found: <&() as Bug> -error: aborting due to 2 previous errors +error: non-defining opaque type use in defining scope + --> $DIR/issue-60371.rs:12:37 + | +LL | impl Bug for &() { + | - cannot use static lifetime; use a bound lifetime instead or remove the lifetime parameter from the opaque type +... +LL | const FUN: fn() -> Self::Item = || (); + | ^^^^^ + +error: aborting due to 3 previous errors Some errors have detailed explanations: E0277, E0658. For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/type-alias-impl-trait/issue-60564.rs b/src/test/ui/type-alias-impl-trait/issue-60564.rs index 4fc7679311a..44dcec2c3da 100644 --- a/src/test/ui/type-alias-impl-trait/issue-60564.rs +++ b/src/test/ui/type-alias-impl-trait/issue-60564.rs @@ -6,6 +6,7 @@ trait IterBits { } type IterBitsIter<T, E, I> = impl std::iter::Iterator<Item = I>; +//~^ ERROR could not find defining uses impl<T: Copy, E> IterBits for T where @@ -17,8 +18,8 @@ where { type BitsIter = IterBitsIter<T, E, u8>; fn iter_bits(self, n: u8) -> Self::BitsIter { - (0u8..n).rev().map(move |shift| ((self >> T::from(shift)) & T::from(1)).try_into().unwrap()) //~^ ERROR non-defining opaque type use in defining scope + (0u8..n).rev().map(move |shift| ((self >> T::from(shift)) & T::from(1)).try_into().unwrap()) } } diff --git a/src/test/ui/type-alias-impl-trait/issue-60564.stderr b/src/test/ui/type-alias-impl-trait/issue-60564.stderr index bbc93657be3..6b73fbef011 100644 --- a/src/test/ui/type-alias-impl-trait/issue-60564.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-60564.stderr @@ -1,8 +1,8 @@ error: non-defining opaque type use in defining scope - --> $DIR/issue-60564.rs:20:9 + --> $DIR/issue-60564.rs:20:34 | -LL | (0u8..n).rev().map(move |shift| ((self >> T::from(shift)) & T::from(1)).try_into().unwrap()) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn iter_bits(self, n: u8) -> Self::BitsIter { + | ^^^^^^^^^^^^^^ | note: used non-generic type `u8` for generic parameter --> $DIR/issue-60564.rs:8:25 @@ -10,5 +10,11 @@ note: used non-generic type `u8` for generic parameter LL | type IterBitsIter<T, E, I> = impl std::iter::Iterator<Item = I>; | ^ -error: aborting due to previous error +error: could not find defining uses + --> $DIR/issue-60564.rs:8:30 + | +LL | type IterBitsIter<T, E, I> = impl std::iter::Iterator<Item = I>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors diff --git a/src/test/ui/type-alias-impl-trait/issue-63279.rs b/src/test/ui/type-alias-impl-trait/issue-63279.rs index 057a908bbee..875cce4df23 100644 --- a/src/test/ui/type-alias-impl-trait/issue-63279.rs +++ b/src/test/ui/type-alias-impl-trait/issue-63279.rs @@ -5,10 +5,7 @@ type Closure = impl FnOnce(); fn c() -> Closure { - || -> Closure { || () } - //~^ ERROR: mismatched types - //~| ERROR: mismatched types - //~| ERROR: expected a `FnOnce<()>` closure, found `()` + || -> Closure { || () } //~ ERROR: mismatched types } fn main() {} diff --git a/src/test/ui/type-alias-impl-trait/issue-63279.stderr b/src/test/ui/type-alias-impl-trait/issue-63279.stderr index 4b7dbbd6a56..5fde8c2ef1e 100644 --- a/src/test/ui/type-alias-impl-trait/issue-63279.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-63279.stderr @@ -1,34 +1,17 @@ -error[E0277]: expected a `FnOnce<()>` closure, found `()` - --> $DIR/issue-63279.rs:8:11 - | -LL | || -> Closure { || () } - | ^^^^^^^ expected an `FnOnce<()>` closure, found `()` - | - = help: the trait `FnOnce<()>` is not implemented for `()` - = note: wrap the `()` in a closure with no arguments: `|| { /* code */ }` - -error[E0308]: mismatched types - --> $DIR/issue-63279.rs:8:21 - | -LL | || -> Closure { || () } - | ^^^^^ expected `()`, found closure - | - = note: expected unit type `()` - found closure `[closure@$DIR/issue-63279.rs:8:21: 8:26]` - error[E0308]: mismatched types --> $DIR/issue-63279.rs:8:5 | LL | type Closure = impl FnOnce(); - | ------------- the expected opaque type + | ------------- the found opaque type ... LL | || -> Closure { || () } - | ^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found closure + | ^^^^^^^^^^^^^^^^^^^^^^^ expected closure, found a different closure | - = note: expected opaque type `Closure` - found closure `[closure@$DIR/issue-63279.rs:8:5: 8:28]` + = note: expected type `[closure@$DIR/issue-63279.rs:8:21: 8:26]` + found closure `[closure@$DIR/issue-63279.rs:8:5: 8:28]` + = note: no two closures, even if identical, have the same type + = help: consider boxing your closure and/or using it as a trait object -error: aborting due to 3 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0277, E0308. -For more information about an error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/type-alias-impl-trait/issue-63355.rs b/src/test/ui/type-alias-impl-trait/issue-63355.rs index 7066a0535e1..ff4fd5dcec7 100644 --- a/src/test/ui/type-alias-impl-trait/issue-63355.rs +++ b/src/test/ui/type-alias-impl-trait/issue-63355.rs @@ -1,5 +1,6 @@ #![feature(type_alias_impl_trait)] -// check-pass +#![feature(type_alias_impl_trait)] +#![allow(incomplete_features)] pub trait Foo {} @@ -27,8 +28,11 @@ impl Bar for () { } } +// FIXME(#86731): The below is illegal use of `type_alias_impl_trait` +// but the compiler doesn't report it, we should fix it. pub type FooImpl = impl Foo; pub type BarImpl = impl Bar<Foo = FooImpl>; +//~^ ERROR: type mismatch resolving `<() as Bar>::Foo == ()` impl Baz for () { type Foo = FooImpl; diff --git a/src/test/ui/type-alias-impl-trait/issue-63355.stderr b/src/test/ui/type-alias-impl-trait/issue-63355.stderr new file mode 100644 index 00000000000..6fc6b4bfe1f --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/issue-63355.stderr @@ -0,0 +1,19 @@ +error[E0271]: type mismatch resolving `<() as Bar>::Foo == ()` + --> $DIR/issue-63355.rs:34:20 + | +LL | pub type FooImpl = impl Foo; + | -------- the found opaque type +LL | pub type BarImpl = impl Bar<Foo = FooImpl>; + | ^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<() as Bar>::Foo == ()` + | +note: expected this to be `()` + --> $DIR/issue-63355.rs:24:16 + | +LL | type Foo = FooImpl; + | ^^^^^^^ + = note: expected unit type `()` + found opaque type `impl Foo` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0271`. diff --git a/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use-2.rs b/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use-2.rs index 5223fb1c702..2e6354088ac 100644 --- a/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use-2.rs +++ b/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use-2.rs @@ -5,7 +5,7 @@ #![feature(type_alias_impl_trait)] trait Trait<T> {} type Alias<'a, U> = impl Trait<U>; - +//~^ ERROR could not find defining uses fn f<'a>() -> Alias<'a, ()> {} //~^ ERROR non-defining opaque type use in defining scope diff --git a/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use-2.stderr b/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use-2.stderr index 7fb9a0c410e..721f99a3f0d 100644 --- a/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use-2.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use-2.stderr @@ -1,8 +1,8 @@ error: non-defining opaque type use in defining scope - --> $DIR/issue-68368-non-defining-use-2.rs:9:29 + --> $DIR/issue-68368-non-defining-use-2.rs:9:15 | LL | fn f<'a>() -> Alias<'a, ()> {} - | ^^ + | ^^^^^^^^^^^^^ | note: used non-generic type `()` for generic parameter --> $DIR/issue-68368-non-defining-use-2.rs:7:16 @@ -10,5 +10,11 @@ note: used non-generic type `()` for generic parameter LL | type Alias<'a, U> = impl Trait<U>; | ^ -error: aborting due to previous error +error: could not find defining uses + --> $DIR/issue-68368-non-defining-use-2.rs:7:21 + | +LL | type Alias<'a, U> = impl Trait<U>; + | ^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors diff --git a/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use.rs b/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use.rs index b50462bf237..3addd8dcc4f 100644 --- a/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use.rs +++ b/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use.rs @@ -5,7 +5,7 @@ #![feature(type_alias_impl_trait)] trait Trait<T> {} type Alias<'a, U> = impl Trait<U>; - +//~^ ERROR could not find defining uses fn f<'a>() -> Alias<'a, ()> {} //~^ ERROR non-defining opaque type use in defining scope diff --git a/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use.stderr b/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use.stderr index 8059621b61a..f5b8fccf65d 100644 --- a/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-68368-non-defining-use.stderr @@ -1,8 +1,8 @@ error: non-defining opaque type use in defining scope - --> $DIR/issue-68368-non-defining-use.rs:9:29 + --> $DIR/issue-68368-non-defining-use.rs:9:15 | LL | fn f<'a>() -> Alias<'a, ()> {} - | ^^ + | ^^^^^^^^^^^^^ | note: used non-generic type `()` for generic parameter --> $DIR/issue-68368-non-defining-use.rs:7:16 @@ -10,5 +10,11 @@ note: used non-generic type `()` for generic parameter LL | type Alias<'a, U> = impl Trait<U>; | ^ -error: aborting due to previous error +error: could not find defining uses + --> $DIR/issue-68368-non-defining-use.rs:7:21 + | +LL | type Alias<'a, U> = impl Trait<U>; + | ^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors diff --git a/src/test/ui/type-alias-impl-trait/issue-74280.stderr b/src/test/ui/type-alias-impl-trait/issue-74280.stderr index 38591e37f53..f6b369dd8d5 100644 --- a/src/test/ui/type-alias-impl-trait/issue-74280.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-74280.stderr @@ -1,14 +1,8 @@ error[E0308]: mismatched types --> $DIR/issue-74280.rs:9:5 | -LL | type Test = impl Copy; - | --------- the expected opaque type -... LL | 7 | ^ expected `()`, found integer - | - = note: expected opaque type `Test` - found type `{integer}` error: aborting due to previous error diff --git a/src/test/ui/type-alias-impl-trait/issue-77179.stderr b/src/test/ui/type-alias-impl-trait/issue-77179.stderr index 053546e4b92..15205ba9b41 100644 --- a/src/test/ui/type-alias-impl-trait/issue-77179.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-77179.stderr @@ -5,7 +5,7 @@ LL | fn test() -> Pointer<_> { | --------^- | | | | | not allowed in type signatures - | help: replace with the correct return type: `Pointer<i32>` + | help: replace with the correct return type: `Box<i32>` error: aborting due to previous error diff --git a/src/test/ui/type-alias-impl-trait/issue-89686.stderr b/src/test/ui/type-alias-impl-trait/issue-89686.stderr index 3a75dc6fe7b..19ed9a7476c 100644 --- a/src/test/ui/type-alias-impl-trait/issue-89686.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-89686.stderr @@ -2,18 +2,18 @@ error[E0271]: type mismatch resolving `<impl Future<Output = [async output]> as --> $DIR/issue-89686.rs:7:17 | LL | type G<'a, T> = impl Future<Output = ()>; - | ^^^^^^^^^^^^^^^^^^^^^^^^ expected associated type, found `()` + | ^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found associated type ... LL | async move { self.f().await } - | ------------------ the expected `async` block + | ------------------ the found `async` block | ::: $SRC_DIR/core/src/future/mod.rs:LL:COL | LL | pub const fn from_generator<T>(gen: T) -> impl Future<Output = T::Return> - | ------------------------------- the expected opaque type + | ------------------------------- the found opaque type | - = note: expected associated type `<impl Future<Output = [async output]> as Future>::Output` - found unit type `()` + = note: expected unit type `()` + found associated type `<impl Future<Output = [async output]> as Future>::Output` = help: consider constraining the associated type `<impl Future<Output = [async output]> as Future>::Output` to `()` = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html diff --git a/src/test/ui/type-alias-impl-trait/issue-93411.rs b/src/test/ui/type-alias-impl-trait/issue-93411.rs deleted file mode 100644 index 1f8c789267d..00000000000 --- a/src/test/ui/type-alias-impl-trait/issue-93411.rs +++ /dev/null @@ -1,19 +0,0 @@ -#![feature(type_alias_impl_trait)] - -// this test used to stack overflow due to infinite recursion. -// check-pass -// compile-flags: --edition=2018 - -use std::future::Future; - -fn main() { - let _ = move || async move { - let value = 0u8; - blah(&value).await; - }; -} - -type BlahFut<'a> = impl Future<Output = ()> + Send + 'a; -fn blah<'a>(_value: &'a u8) -> BlahFut<'a> { - async {} -} diff --git a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-infer.rs b/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-infer.rs deleted file mode 100644 index 08cb48ccf30..00000000000 --- a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-infer.rs +++ /dev/null @@ -1,13 +0,0 @@ -// https://github.com/rust-lang/rust/issues/73481 -// This test used to cause unsoundness, since one of the two possible -// resolutions was chosen at random instead of erroring due to conflicts. - -#![feature(type_alias_impl_trait)] - -type Y<A, B> = impl std::fmt::Debug; - -fn g<A, B>() -> (Y<A, B>, Y<B, A>) { - (42_i64, 60) //~^ ERROR concrete type differs from previous defining opaque type use -} - -fn main() {} diff --git a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-infer.stderr b/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-infer.stderr deleted file mode 100644 index 3f57612684e..00000000000 --- a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-infer.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: concrete type differs from previous defining opaque type use - --> $DIR/multiple-def-uses-in-one-fn-infer.rs:9:1 - | -LL | fn g<A, B>() -> (Y<A, B>, Y<B, A>) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i64`, got `i32` - | -note: previous use here - --> $DIR/multiple-def-uses-in-one-fn-infer.rs:9:1 - | -LL | fn g<A, B>() -> (Y<A, B>, Y<B, A>) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.rs b/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.rs deleted file mode 100644 index f39bf4aeb29..00000000000 --- a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.rs +++ /dev/null @@ -1,9 +0,0 @@ -#![feature(type_alias_impl_trait)] - -type Foo<'a, 'b> = impl std::fmt::Debug; - -fn foo<'x, 'y>(i: &'x i32, j: &'y i32) -> (Foo<'x, 'y>, Foo<'y, 'x>) { - (i, i) //~^ ERROR concrete type differs from previous -} - -fn main() {} diff --git a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.stderr b/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.stderr deleted file mode 100644 index 49d08dda9f9..00000000000 --- a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: concrete type differs from previous defining opaque type use - --> $DIR/multiple-def-uses-in-one-fn-lifetimes.rs:5:1 - | -LL | fn foo<'x, 'y>(i: &'x i32, j: &'y i32) -> (Foo<'x, 'y>, Foo<'y, 'x>) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&'a i32`, got `&'b i32` - | -note: previous use here - --> $DIR/multiple-def-uses-in-one-fn-lifetimes.rs:5:1 - | -LL | fn foo<'x, 'y>(i: &'x i32, j: &'y i32) -> (Foo<'x, 'y>, Foo<'y, 'x>) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-pass.rs b/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-pass.rs index 83fd9a1da45..f412b2d0e7d 100644 --- a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-pass.rs +++ b/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-pass.rs @@ -7,15 +7,6 @@ fn f<A: ToString + Clone, B: ToString + Clone>(a: A, b: B) -> (X<A, B>, X<A, B>) (a.clone(), a) } -type Foo<'a, 'b> = impl std::fmt::Debug; - -fn foo<'x, 'y>(i: &'x i32, j: &'y i32) -> (Foo<'x, 'y>, Foo<'y, 'x>) { - (i, j) -} - fn main() { println!("{}", <X<_, _> as ToString>::to_string(&f(42_i32, String::new()).1)); - let meh = 42; - let muh = 69; - println!("{:?}", foo(&meh, &muh)); } diff --git a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.rs b/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.rs index 46bac5a34f5..da845e86147 100644 --- a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.rs +++ b/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.rs @@ -7,8 +7,8 @@ type X<A, B> = impl Into<&'static A>; fn f<A, B: 'static>(a: &'static A, b: B) -> (X<A, B>, X<B, A>) { - (a, a) //~^ ERROR the trait bound `&'static B: From<&A>` is not satisfied + (a, a) } fn main() { diff --git a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.stderr b/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.stderr index f4d8b4509d4..4df2f52a9e4 100644 --- a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.stderr +++ b/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `&'static B: From<&A>` is not satisfied - --> $DIR/multiple-def-uses-in-one-fn.rs:10:9 + --> $DIR/multiple-def-uses-in-one-fn.rs:9:45 | -LL | (a, a) - | ^ the trait `From<&A>` is not implemented for `&'static B` +LL | fn f<A, B: 'static>(a: &'static A, b: B) -> (X<A, B>, X<B, A>) { + | ^^^^^^^^^^^^^^^^^^ the trait `From<&A>` is not implemented for `&'static B` | = note: required because of the requirements on the impl of `Into<&'static B>` for `&A` help: consider introducing a `where` bound, but there might be an alternative better way to express this requirement diff --git a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn3.stderr b/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn3.stderr index db4b60461ef..bbe709dccab 100644 --- a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn3.stderr +++ b/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn3.stderr @@ -1,9 +1,6 @@ error[E0308]: mismatched types --> $DIR/multiple-def-uses-in-one-fn3.rs:14:9 | -LL | type X<A: ToString + Clone, B: ToString + Clone> = impl ToString; - | ------------- the expected opaque type -... LL | fn g<A: ToString + Clone, B: ToString + Clone>(a: A, b: B) -> (X<A, B>, X<A, B>) { | - - found type parameter | | @@ -11,8 +8,8 @@ LL | fn g<A: ToString + Clone, B: ToString + Clone>(a: A, b: B) -> (X<A, B>, X<A LL | (a, b) | ^ expected type parameter `A`, found type parameter `B` | - = note: expected opaque type `X<A, B>` - found type parameter `B` + = note: expected type parameter `A` + found type parameter `B` = note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters diff --git a/src/test/ui/type-alias-impl-trait/nested-tait-inference.rs b/src/test/ui/type-alias-impl-trait/nested-tait-inference.rs index 784a6c75886..efb88dabf34 100644 --- a/src/test/ui/type-alias-impl-trait/nested-tait-inference.rs +++ b/src/test/ui/type-alias-impl-trait/nested-tait-inference.rs @@ -1,3 +1,5 @@ +// check-pass + #![feature(type_alias_impl_trait)] #![allow(dead_code)] @@ -10,9 +12,7 @@ trait Foo<A> { } impl Foo<()> for () { } fn foo() -> impl Foo<FooX> { - // FIXME(type-alias-impl-trait): We could probably make this work. () - //~^ ERROR: the trait bound `(): Foo<FooX>` is not satisfied } fn main() { } diff --git a/src/test/ui/type-alias-impl-trait/nested-tait-inference.stderr b/src/test/ui/type-alias-impl-trait/nested-tait-inference.stderr deleted file mode 100644 index 9472cac6355..00000000000 --- a/src/test/ui/type-alias-impl-trait/nested-tait-inference.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0277]: the trait bound `(): Foo<FooX>` is not satisfied - --> $DIR/nested-tait-inference.rs:14:5 - | -LL | () - | ^^ the trait `Foo<FooX>` is not implemented for `()` - | - = help: the following implementations were found: - <() as Foo<()>> - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/type-alias-impl-trait/nested-tait-inference2.rs b/src/test/ui/type-alias-impl-trait/nested-tait-inference2.rs index 00bd44c493c..9b26a652978 100644 --- a/src/test/ui/type-alias-impl-trait/nested-tait-inference2.rs +++ b/src/test/ui/type-alias-impl-trait/nested-tait-inference2.rs @@ -4,6 +4,7 @@ use std::fmt::Debug; type FooX = impl Debug; +//~^ ERROR: could not find defining uses trait Foo<A> {} @@ -11,8 +12,8 @@ impl Foo<()> for () {} impl Foo<u32> for () {} fn foo() -> impl Foo<FooX> { + //~^ ERROR: the trait bound `(): Foo<impl Debug>` is not satisfied [E0277] () - //~^ ERROR: the trait bound `(): Foo<FooX>` is not satisfied } fn main() {} diff --git a/src/test/ui/type-alias-impl-trait/nested-tait-inference2.stderr b/src/test/ui/type-alias-impl-trait/nested-tait-inference2.stderr index ec1b4642d08..7e24ee644b1 100644 --- a/src/test/ui/type-alias-impl-trait/nested-tait-inference2.stderr +++ b/src/test/ui/type-alias-impl-trait/nested-tait-inference2.stderr @@ -1,13 +1,19 @@ -error[E0277]: the trait bound `(): Foo<FooX>` is not satisfied - --> $DIR/nested-tait-inference2.rs:14:5 +error[E0277]: the trait bound `(): Foo<impl Debug>` is not satisfied + --> $DIR/nested-tait-inference2.rs:14:13 | -LL | () - | ^^ the trait `Foo<FooX>` is not implemented for `()` +LL | fn foo() -> impl Foo<FooX> { + | ^^^^^^^^^^^^^^ the trait `Foo<impl Debug>` is not implemented for `()` | = help: the following implementations were found: <() as Foo<()>> <() as Foo<u32>> -error: aborting due to previous error +error: could not find defining uses + --> $DIR/nested-tait-inference2.rs:6:13 + | +LL | type FooX = impl Debug; + | ^^^^^^^^^^ + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/type-alias-impl-trait/nested-tait-inference3.rs b/src/test/ui/type-alias-impl-trait/nested-tait-inference3.rs deleted file mode 100644 index fbab5470b4f..00000000000 --- a/src/test/ui/type-alias-impl-trait/nested-tait-inference3.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![feature(type_alias_impl_trait)] -#![allow(dead_code)] - -use std::fmt::Debug; - -type FooX = impl Debug; -//~^ unconstrained opaque type - -trait Foo<A> { } - -impl Foo<FooX> for () { } - -fn foo() -> impl Foo<FooX> { - () -} - -fn main() { } diff --git a/src/test/ui/type-alias-impl-trait/nested-tait-inference3.stderr b/src/test/ui/type-alias-impl-trait/nested-tait-inference3.stderr deleted file mode 100644 index b1d947a9ccf..00000000000 --- a/src/test/ui/type-alias-impl-trait/nested-tait-inference3.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: unconstrained opaque type - --> $DIR/nested-tait-inference3.rs:6:13 - | -LL | type FooX = impl Debug; - | ^^^^^^^^^^ - | - = note: `FooX` must be used in combination with a concrete type within the same module - -error: aborting due to previous error - diff --git a/src/test/ui/type-alias-impl-trait/nested.rs b/src/test/ui/type-alias-impl-trait/nested.rs deleted file mode 100644 index 6b866be7d17..00000000000 --- a/src/test/ui/type-alias-impl-trait/nested.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![feature(type_alias_impl_trait)] - -type Foo = impl std::fmt::Debug; -type Bar = impl Trait<Foo>; - -trait Trait<T> {} - -impl<T, U> Trait<T> for U {} - -fn bar() -> Bar { - 42 -} - -fn main() { - println!("{:?}", bar()); - //~^ ERROR `Bar` doesn't implement `Debug` -} diff --git a/src/test/ui/type-alias-impl-trait/nested.stderr b/src/test/ui/type-alias-impl-trait/nested.stderr deleted file mode 100644 index cf4d23656e0..00000000000 --- a/src/test/ui/type-alias-impl-trait/nested.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0277]: `Bar` doesn't implement `Debug` - --> $DIR/nested.rs:15:22 - | -LL | println!("{:?}", bar()); - | ^^^^^ `Bar` cannot be formatted using `{:?}` because it doesn't implement `Debug` - | - = help: the trait `Debug` is not implemented for `Bar` - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/type-alias-impl-trait/nested_type_alias_impl_trait.rs b/src/test/ui/type-alias-impl-trait/nested_type_alias_impl_trait.rs index 60b6e1aac62..6282264d8fe 100644 --- a/src/test/ui/type-alias-impl-trait/nested_type_alias_impl_trait.rs +++ b/src/test/ui/type-alias-impl-trait/nested_type_alias_impl_trait.rs @@ -1,5 +1,5 @@ #![feature(type_alias_impl_trait)] - +// build-pass (FIXME(62277): could be check-pass?) mod my_mod { use std::fmt::Debug; @@ -11,7 +11,7 @@ mod my_mod { } pub fn get_foot() -> Foot { - get_foo() //~ ERROR opaque type's hidden type cannot be another opaque type + get_foo() } } diff --git a/src/test/ui/type-alias-impl-trait/nested_type_alias_impl_trait.stderr b/src/test/ui/type-alias-impl-trait/nested_type_alias_impl_trait.stderr deleted file mode 100644 index fa6ecf68d28..00000000000 --- a/src/test/ui/type-alias-impl-trait/nested_type_alias_impl_trait.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error: opaque type's hidden type cannot be another opaque type from the same scope - --> $DIR/nested_type_alias_impl_trait.rs:14:9 - | -LL | get_foo() - | ^^^^^^^^^ one of the two opaque types used here has to be outside its defining scope - | -note: opaque type whose hidden type is being assigned - --> $DIR/nested_type_alias_impl_trait.rs:7:21 - | -LL | pub type Foot = impl Debug; - | ^^^^^^^^^^ -note: opaque type being used as hidden type - --> $DIR/nested_type_alias_impl_trait.rs:6:20 - | -LL | pub type Foo = impl Debug; - | ^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/type-alias-impl-trait/never_reveal_concrete_type.rs b/src/test/ui/type-alias-impl-trait/never_reveal_concrete_type.rs index fed5ac07c90..8787c023eb0 100644 --- a/src/test/ui/type-alias-impl-trait/never_reveal_concrete_type.rs +++ b/src/test/ui/type-alias-impl-trait/never_reveal_concrete_type.rs @@ -1,7 +1,8 @@ #![feature(type_alias_impl_trait)] -// check-pass + fn main() {} +// don't reveal the concrete type type NoReveal = impl std::fmt::Debug; fn define_no_reveal() -> NoReveal { @@ -9,6 +10,6 @@ fn define_no_reveal() -> NoReveal { } fn no_reveal(x: NoReveal) { - let _: &'static str = x; - let _ = x as &'static str; + let _: &'static str = x; //~ mismatched types + let _ = x as &'static str; //~ non-primitive cast } diff --git a/src/test/ui/type-alias-impl-trait/never_reveal_concrete_type.stderr b/src/test/ui/type-alias-impl-trait/never_reveal_concrete_type.stderr new file mode 100644 index 00000000000..b438f844516 --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/never_reveal_concrete_type.stderr @@ -0,0 +1,24 @@ +error[E0308]: mismatched types + --> $DIR/never_reveal_concrete_type.rs:13:27 + | +LL | type NoReveal = impl std::fmt::Debug; + | -------------------- the found opaque type +... +LL | let _: &'static str = x; + | ------------ ^ expected `&str`, found opaque type + | | + | expected due to this + | + = note: expected reference `&'static str` + found opaque type `impl Debug` + +error[E0605]: non-primitive cast: `impl Debug` as `&'static str` + --> $DIR/never_reveal_concrete_type.rs:14:13 + | +LL | let _ = x as &'static str; + | ^^^^^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0308, E0605. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/type-alias-impl-trait/no_inferrable_concrete_type.rs b/src/test/ui/type-alias-impl-trait/no_inferrable_concrete_type.rs index fa578eced5f..1197c7bc58e 100644 --- a/src/test/ui/type-alias-impl-trait/no_inferrable_concrete_type.rs +++ b/src/test/ui/type-alias-impl-trait/no_inferrable_concrete_type.rs @@ -1,9 +1,9 @@ // Issue 52985: user code provides no use case that allows a type alias `impl Trait` -// We now emit a 'unconstrained opaque type' error +// We now emit a 'could not find defining uses' error #![feature(type_alias_impl_trait)] -type Foo = impl Copy; //~ unconstrained opaque type +type Foo = impl Copy; //~ could not find defining uses // make compiler happy about using 'Foo' fn bar(x: Foo) -> Foo { diff --git a/src/test/ui/type-alias-impl-trait/no_inferrable_concrete_type.stderr b/src/test/ui/type-alias-impl-trait/no_inferrable_concrete_type.stderr index 009935347e6..61025e84692 100644 --- a/src/test/ui/type-alias-impl-trait/no_inferrable_concrete_type.stderr +++ b/src/test/ui/type-alias-impl-trait/no_inferrable_concrete_type.stderr @@ -1,10 +1,8 @@ -error: unconstrained opaque type +error: could not find defining uses --> $DIR/no_inferrable_concrete_type.rs:6:12 | LL | type Foo = impl Copy; | ^^^^^^^^^ - | - = note: `Foo` must be used in combination with a concrete type within the same module error: aborting due to previous error diff --git a/src/test/ui/type-alias-impl-trait/no_revealing_outside_defining_module.stderr b/src/test/ui/type-alias-impl-trait/no_revealing_outside_defining_module.stderr index e691d8781c0..67752acb8c9 100644 --- a/src/test/ui/type-alias-impl-trait/no_revealing_outside_defining_module.stderr +++ b/src/test/ui/type-alias-impl-trait/no_revealing_outside_defining_module.stderr @@ -5,10 +5,12 @@ LL | pub type Boo = impl ::std::fmt::Debug; | ---------------------- the found opaque type ... LL | let _: &str = bomp(); - | ^^^^^^ expected `&str`, found opaque type + | ---- ^^^^^^ expected `&str`, found opaque type + | | + | expected due to this | = note: expected reference `&str` - found opaque type `Boo` + found opaque type `impl Debug` error[E0308]: mismatched types --> $DIR/no_revealing_outside_defining_module.rs:19:5 @@ -16,11 +18,13 @@ error[E0308]: mismatched types LL | pub type Boo = impl ::std::fmt::Debug; | ---------------------- the expected opaque type ... +LL | fn bomp() -> boo::Boo { + | -------- expected `impl Debug` because of return type LL | "" | ^^ expected opaque type, found `&str` | - = note: expected opaque type `Boo` - found reference `&str` + = note: expected opaque type `impl Debug` + found reference `&'static str` error: aborting due to 2 previous errors diff --git a/src/test/ui/type-alias-impl-trait/not_a_defining_use.rs b/src/test/ui/type-alias-impl-trait/not_a_defining_use.rs index 5b332b8cb6b..107cd394579 100644 --- a/src/test/ui/type-alias-impl-trait/not_a_defining_use.rs +++ b/src/test/ui/type-alias-impl-trait/not_a_defining_use.rs @@ -7,6 +7,11 @@ fn main() {} type Two<T, U> = impl Debug; //~^ ERROR `T` doesn't implement `Debug` +fn two<T: Debug>(t: T) -> Two<T, u32> { + //~^ ERROR non-defining opaque type use in defining scope + (t, 4i8) +} + fn three<T: Debug, U>(t: T) -> Two<T, U> { (t, 5i8) } diff --git a/src/test/ui/type-alias-impl-trait/not_a_defining_use.stderr b/src/test/ui/type-alias-impl-trait/not_a_defining_use.stderr index f946dc48a4b..08e49845521 100644 --- a/src/test/ui/type-alias-impl-trait/not_a_defining_use.stderr +++ b/src/test/ui/type-alias-impl-trait/not_a_defining_use.stderr @@ -1,11 +1,23 @@ +error: non-defining opaque type use in defining scope + --> $DIR/not_a_defining_use.rs:10:27 + | +LL | fn two<T: Debug>(t: T) -> Two<T, u32> { + | ^^^^^^^^^^^ + | +note: used non-generic type `u32` for generic parameter + --> $DIR/not_a_defining_use.rs:7:13 + | +LL | type Two<T, U> = impl Debug; + | ^ + error: concrete type differs from previous defining opaque type use - --> $DIR/not_a_defining_use.rs:24:1 + --> $DIR/not_a_defining_use.rs:29:1 | LL | fn four<T: Debug, U: Bar>(t: T) -> Two<T, U> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `(T, i8)`, got `(T, <U as Bar>::Blub)` | note: previous use here - --> $DIR/not_a_defining_use.rs:10:1 + --> $DIR/not_a_defining_use.rs:15:1 | LL | fn three<T: Debug, U>(t: T) -> Two<T, U> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -22,6 +34,6 @@ help: consider restricting type parameter `T` LL | type Two<T: std::fmt::Debug, U> = impl Debug; | +++++++++++++++++ -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/type-alias-impl-trait/self-referential-2.rs b/src/test/ui/type-alias-impl-trait/self-referential-2.rs deleted file mode 100644 index dc7054da5ec..00000000000 --- a/src/test/ui/type-alias-impl-trait/self-referential-2.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![feature(type_alias_impl_trait)] - -type Foo = impl std::fmt::Debug; -type Bar = impl PartialEq<Foo>; - -fn bar() -> Bar { - 42_i32 //~ ERROR can't compare `i32` with `Foo` -} - -fn main() {} diff --git a/src/test/ui/type-alias-impl-trait/self-referential-2.stderr b/src/test/ui/type-alias-impl-trait/self-referential-2.stderr deleted file mode 100644 index 6997676260d..00000000000 --- a/src/test/ui/type-alias-impl-trait/self-referential-2.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0277]: can't compare `i32` with `Foo` - --> $DIR/self-referential-2.rs:7:5 - | -LL | 42_i32 - | ^^^^^^ no implementation for `i32 == Foo` - | - = help: the trait `PartialEq<Foo>` is not implemented for `i32` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/type-alias-impl-trait/self-referential-3.rs b/src/test/ui/type-alias-impl-trait/self-referential-3.rs deleted file mode 100644 index d40715717d4..00000000000 --- a/src/test/ui/type-alias-impl-trait/self-referential-3.rs +++ /dev/null @@ -1,14 +0,0 @@ -// run-pass -#![feature(type_alias_impl_trait)] - -type Bar<'a, 'b> = impl PartialEq<Bar<'a, 'b>> + std::fmt::Debug; - -fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> { - i -} - -fn main() { - let meh = 42; - let muh = 42; - assert_eq!(bar(&meh), bar(&muh)); -} diff --git a/src/test/ui/type-alias-impl-trait/self-referential-4.rs b/src/test/ui/type-alias-impl-trait/self-referential-4.rs deleted file mode 100644 index 697ec56825a..00000000000 --- a/src/test/ui/type-alias-impl-trait/self-referential-4.rs +++ /dev/null @@ -1,25 +0,0 @@ -#![feature(type_alias_impl_trait)] - -type Bar<'a, 'b> = impl PartialEq<Bar<'b, 'static>> + std::fmt::Debug; - -fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> { - i //~ ERROR can't compare `&i32` with `Bar<'b, 'static>` -} - -type Foo<'a, 'b> = impl PartialEq<Foo<'static, 'b>> + std::fmt::Debug; - -fn foo<'a, 'b>(i: &'a i32) -> Foo<'a, 'b> { - i //~ ERROR can't compare `&i32` with `Foo<'static, 'b>` -} - -type Moo<'a, 'b> = impl PartialEq<Moo<'static, 'a>> + std::fmt::Debug; - -fn moo<'a, 'b>(i: &'a i32) -> Moo<'a, 'b> { - i //~ ERROR can't compare `&i32` with `Moo<'static, 'a>` -} - -fn main() { - let meh = 42; - let muh = 69; - assert_eq!(bar(&meh), bar(&meh)); -} diff --git a/src/test/ui/type-alias-impl-trait/self-referential-4.stderr b/src/test/ui/type-alias-impl-trait/self-referential-4.stderr deleted file mode 100644 index 4a6ee2f9279..00000000000 --- a/src/test/ui/type-alias-impl-trait/self-referential-4.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error[E0277]: can't compare `&i32` with `Bar<'b, 'static>` - --> $DIR/self-referential-4.rs:6:5 - | -LL | i - | ^ no implementation for `&i32 == Bar<'b, 'static>` - | - = help: the trait `PartialEq<Bar<'b, 'static>>` is not implemented for `&i32` - -error[E0277]: can't compare `&i32` with `Foo<'static, 'b>` - --> $DIR/self-referential-4.rs:12:5 - | -LL | i - | ^ no implementation for `&i32 == Foo<'static, 'b>` - | - = help: the trait `PartialEq<Foo<'static, 'b>>` is not implemented for `&i32` - -error[E0277]: can't compare `&i32` with `Moo<'static, 'a>` - --> $DIR/self-referential-4.rs:18:5 - | -LL | i - | ^ no implementation for `&i32 == Moo<'static, 'a>` - | - = help: the trait `PartialEq<Moo<'static, 'a>>` is not implemented for `&i32` - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/type-alias-impl-trait/self-referential.rs b/src/test/ui/type-alias-impl-trait/self-referential.rs deleted file mode 100644 index 4974ac72dad..00000000000 --- a/src/test/ui/type-alias-impl-trait/self-referential.rs +++ /dev/null @@ -1,25 +0,0 @@ -#![feature(type_alias_impl_trait)] - -type Bar<'a, 'b> = impl PartialEq<Bar<'b, 'a>> + std::fmt::Debug; - -fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> { - i //~ ERROR can't compare `&i32` with `Bar<'b, 'a>` -} - -type Foo<'a, 'b> = (i32, impl PartialEq<Foo<'a, 'b>> + std::fmt::Debug); - -fn foo<'a, 'b>(i: &'a i32) -> Foo<'a, 'b> { - (42, i) //~ ERROR can't compare `&i32` with `(i32, &i32)` -} - -type Moo<'a, 'b> = (i32, impl PartialEq<Moo<'b, 'a>> + std::fmt::Debug); - -fn moo<'a, 'b>(i: &'a i32) -> Moo<'a, 'b> { - (42, i) //~ ERROR can't compare `&i32` with `(i32, Moo<'b, 'a>::{opaque#0})` -} - -fn main() { - let meh = 42; - let muh = 69; - assert_eq!(bar(&meh), bar(&meh)); -} diff --git a/src/test/ui/type-alias-impl-trait/self-referential.stderr b/src/test/ui/type-alias-impl-trait/self-referential.stderr deleted file mode 100644 index 0626e6be0d5..00000000000 --- a/src/test/ui/type-alias-impl-trait/self-referential.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error[E0277]: can't compare `&i32` with `Bar<'b, 'a>` - --> $DIR/self-referential.rs:6:5 - | -LL | i - | ^ no implementation for `&i32 == Bar<'b, 'a>` - | - = help: the trait `PartialEq<Bar<'b, 'a>>` is not implemented for `&i32` - -error[E0277]: can't compare `&i32` with `(i32, &i32)` - --> $DIR/self-referential.rs:12:10 - | -LL | (42, i) - | ^ no implementation for `&i32 == (i32, &i32)` - | - = help: the trait `PartialEq<(i32, &i32)>` is not implemented for `&i32` - -error[E0277]: can't compare `&i32` with `(i32, Moo<'b, 'a>::{opaque#0})` - --> $DIR/self-referential.rs:18:10 - | -LL | (42, i) - | ^ no implementation for `&i32 == (i32, Moo<'b, 'a>::{opaque#0})` - | - = help: the trait `PartialEq<(i32, Moo<'b, 'a>::{opaque#0})>` is not implemented for `&i32` - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/type-alias-impl-trait/static-const-types.rs b/src/test/ui/type-alias-impl-trait/static-const-types.rs index 748a279e439..86b685022b2 100644 --- a/src/test/ui/type-alias-impl-trait/static-const-types.rs +++ b/src/test/ui/type-alias-impl-trait/static-const-types.rs @@ -1,13 +1,13 @@ #![feature(type_alias_impl_trait)] #![allow(dead_code)] -// check-pass +// FIXME: This should compile, but it currently doesn't use std::fmt::Debug; -type Foo = impl Debug; +type Foo = impl Debug; //~ ERROR could not find defining uses -static FOO1: Foo = 22_u32; -const FOO2: Foo = 22_u32; +static FOO1: Foo = 22_u32; //~ ERROR mismatched types +const FOO2: Foo = 22_u32; //~ ERROR mismatched types fn main() {} diff --git a/src/test/ui/type-alias-impl-trait/static-const-types.stderr b/src/test/ui/type-alias-impl-trait/static-const-types.stderr new file mode 100644 index 00000000000..6f4c2944f72 --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/static-const-types.stderr @@ -0,0 +1,33 @@ +error[E0308]: mismatched types + --> $DIR/static-const-types.rs:10:20 + | +LL | type Foo = impl Debug; + | ---------- the expected opaque type +LL | +LL | static FOO1: Foo = 22_u32; + | ^^^^^^ expected opaque type, found `u32` + | + = note: expected opaque type `impl Debug` + found type `u32` + +error[E0308]: mismatched types + --> $DIR/static-const-types.rs:11:19 + | +LL | type Foo = impl Debug; + | ---------- the expected opaque type +... +LL | const FOO2: Foo = 22_u32; + | ^^^^^^ expected opaque type, found `u32` + | + = note: expected opaque type `impl Debug` + found type `u32` + +error: could not find defining uses + --> $DIR/static-const-types.rs:8:12 + | +LL | type Foo = impl Debug; + | ^^^^^^^^^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/type-alias-impl-trait/structural-match-no-leak.rs b/src/test/ui/type-alias-impl-trait/structural-match-no-leak.rs index cab742d23f5..51a7b6454c3 100644 --- a/src/test/ui/type-alias-impl-trait/structural-match-no-leak.rs +++ b/src/test/ui/type-alias-impl-trait/structural-match-no-leak.rs @@ -11,9 +11,9 @@ const fn leak_free() -> Bar { const LEAK_FREE: Bar = leak_free(); fn leak_free_test() { - match LEAK_FREE { + match todo!() { LEAK_FREE => (), - //~^ `Bar` cannot be used in patterns + //~^ `impl Send` cannot be used in patterns _ => (), } } diff --git a/src/test/ui/type-alias-impl-trait/structural-match-no-leak.stderr b/src/test/ui/type-alias-impl-trait/structural-match-no-leak.stderr index aacc0cc7aa6..7e41b374452 100644 --- a/src/test/ui/type-alias-impl-trait/structural-match-no-leak.stderr +++ b/src/test/ui/type-alias-impl-trait/structural-match-no-leak.stderr @@ -1,4 +1,4 @@ -error: `Bar` cannot be used in patterns +error: `impl Send` cannot be used in patterns --> $DIR/structural-match-no-leak.rs:15:9 | LL | LEAK_FREE => (), diff --git a/src/test/ui/type-alias-impl-trait/structural-match.rs b/src/test/ui/type-alias-impl-trait/structural-match.rs index c8825c68e33..73558d39ad5 100644 --- a/src/test/ui/type-alias-impl-trait/structural-match.rs +++ b/src/test/ui/type-alias-impl-trait/structural-match.rs @@ -12,9 +12,9 @@ const fn value() -> Foo { const VALUE: Foo = value(); fn test() { - match VALUE { + match todo!() { VALUE => (), - //~^ `Foo` cannot be used in patterns + //~^ `impl Send` cannot be used in patterns _ => (), } } diff --git a/src/test/ui/type-alias-impl-trait/structural-match.stderr b/src/test/ui/type-alias-impl-trait/structural-match.stderr index 28ae9c212d9..b43f2148dea 100644 --- a/src/test/ui/type-alias-impl-trait/structural-match.stderr +++ b/src/test/ui/type-alias-impl-trait/structural-match.stderr @@ -1,4 +1,4 @@ -error: `Foo` cannot be used in patterns +error: `impl Send` cannot be used in patterns --> $DIR/structural-match.rs:16:9 | LL | VALUE => (), diff --git a/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-const.rs b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-const.rs index 5630e036be3..1a8113848f9 100644 --- a/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-const.rs +++ b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-const.rs @@ -1,11 +1,13 @@ #![feature(type_alias_impl_trait)] -// check-pass + // Ensures that `const` items can constrain an opaque `impl Trait`. use std::fmt::Debug; pub type Foo = impl Debug; +//~^ ERROR could not find defining uses const _FOO: Foo = 5; +//~^ ERROR mismatched types [E0308] fn main() {} diff --git a/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-const.stderr b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-const.stderr new file mode 100644 index 00000000000..e2567e87ac6 --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-const.stderr @@ -0,0 +1,21 @@ +error[E0308]: mismatched types + --> $DIR/type-alias-impl-trait-const.rs:10:19 + | +LL | pub type Foo = impl Debug; + | ---------- the expected opaque type +... +LL | const _FOO: Foo = 5; + | ^ expected opaque type, found integer + | + = note: expected opaque type `impl Debug` + found type `{integer}` + +error: could not find defining uses + --> $DIR/type-alias-impl-trait-const.rs:7:16 + | +LL | pub type Foo = impl Debug; + | ^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error.rs b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error.rs index e5e7fb677ed..c009952eab7 100644 --- a/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error.rs +++ b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error.rs @@ -1,7 +1,7 @@ #![feature(type_alias_impl_trait)] type Foo = impl Fn() -> Foo; -//~^ ERROR: unconstrained opaque type +//~^ ERROR: could not find defining uses fn crash(x: Foo) -> Foo { x diff --git a/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error.stderr b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error.stderr index a770eeac39b..726f4ea6e00 100644 --- a/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error.stderr +++ b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error.stderr @@ -1,10 +1,8 @@ -error: unconstrained opaque type +error: could not find defining uses --> $DIR/type-alias-impl-trait-with-cycle-error.rs:3:12 | LL | type Foo = impl Fn() -> Foo; | ^^^^^^^^^^^^^^^^ - | - = note: `Foo` must be used in combination with a concrete type within the same module error: aborting due to previous error diff --git a/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error2.rs b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error2.rs index 7c7a1b405bc..f3898bca64b 100644 --- a/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error2.rs +++ b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error2.rs @@ -5,7 +5,7 @@ pub trait Bar<T> { } type Foo = impl Bar<Foo, Item = Foo>; -//~^ ERROR: unconstrained opaque type +//~^ ERROR: could not find defining uses fn crash(x: Foo) -> Foo { x diff --git a/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error2.stderr b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error2.stderr index 3f3699ce532..3947cc4d270 100644 --- a/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error2.stderr +++ b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait-with-cycle-error2.stderr @@ -1,10 +1,8 @@ -error: unconstrained opaque type +error: could not find defining uses --> $DIR/type-alias-impl-trait-with-cycle-error2.rs:7:12 | LL | type Foo = impl Bar<Foo, Item = Foo>; | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `Foo` must be used in combination with a concrete type within the same module error: aborting due to previous error diff --git a/src/test/ui/type-alias-impl-trait/type-alias-impl-trait.rs b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait.rs index 70c2ee4278c..d2c8c1f63df 100644 --- a/src/test/ui/type-alias-impl-trait/type-alias-impl-trait.rs +++ b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait.rs @@ -1,4 +1,4 @@ -// check-pass +// run-pass #![allow(dead_code)] #![allow(unused_assignments)] diff --git a/src/test/ui/type-alias-impl-trait/type-alias-impl-trait2.rs b/src/test/ui/type-alias-impl-trait/type-alias-impl-trait2.rs deleted file mode 100644 index 67f56bcde93..00000000000 --- a/src/test/ui/type-alias-impl-trait/type-alias-impl-trait2.rs +++ /dev/null @@ -1,84 +0,0 @@ -// check-pass - -#![allow(dead_code)] -#![allow(unused_assignments)] -#![allow(unused_variables)] -#![feature(type_alias_impl_trait)] - -fn main() { - assert_eq!(foo().to_string(), "foo"); - assert_eq!(bar1().to_string(), "bar1"); - assert_eq!(bar2().to_string(), "bar2"); - let mut x = bar1(); - x = bar2(); - assert_eq!(my_iter(42u8).collect::<Vec<u8>>(), vec![42u8]); -} - -use defining_use_scope::*; - -mod defining_use_scope { - // single definition - pub type Foo = impl std::fmt::Display; - - pub fn foo() -> Foo { - "foo" - } - - // two definitions - pub type Bar = impl std::fmt::Display; - - pub fn bar1() -> Bar { - "bar1" - } - - pub fn bar2() -> Bar { - "bar2" - } - - pub type MyIter<T> = impl Iterator<Item = T>; - - pub fn my_iter<T>(t: T) -> MyIter<T> { - std::iter::once(t) - } - - fn my_iter2<T>(t: T) -> MyIter<T> { - std::iter::once(t) - } - - // param names should not have an effect! - fn my_iter3<U>(u: U) -> MyIter<U> { - std::iter::once(u) - } - - // param position should not have an effect! - fn my_iter4<U, V>(_: U, v: V) -> MyIter<V> { - std::iter::once(v) - } - - // param names should not have an effect! - type MyOtherIter<T> = impl Iterator<Item = T>; - - fn my_other_iter<U>(u: U) -> MyOtherIter<U> { - std::iter::once(u) - } - - trait Trait {} - type GenericBound<'a, T: Trait + 'a> = impl Sized + 'a; - - fn generic_bound<'a, T: Trait + 'a>(t: T) -> GenericBound<'a, T> { - t - } - - mod pass_through { - pub type Passthrough<T: 'static> = impl Sized + 'static; - - fn define_passthrough<T: 'static>(t: T) -> Passthrough<T> { - t - } - } - - fn use_passthrough(x: pass_through::Passthrough<u32>) -> pass_through::Passthrough<u32> { - x - } - -} diff --git a/src/test/ui/type-alias-impl-trait/type_of_a_let.rs b/src/test/ui/type-alias-impl-trait/type_of_a_let.rs index 4e9d1788b94..7f8e6127cca 100644 --- a/src/test/ui/type-alias-impl-trait/type_of_a_let.rs +++ b/src/test/ui/type-alias-impl-trait/type_of_a_let.rs @@ -1,20 +1,27 @@ #![feature(type_alias_impl_trait)] #![allow(dead_code)] +// FIXME This should compile, but it currently doesn't + use std::fmt::Debug; type Foo = impl Debug; +//~^ ERROR: could not find defining uses fn foo1() -> u32 { let x: Foo = 22_u32; + //~^ ERROR: mismatched types [E0308] x + //~^ ERROR: mismatched types [E0308] } fn foo2() -> u32 { let x: Foo = 22_u32; + //~^ ERROR: mismatched types [E0308] let y: Foo = x; - same_type((x, y)); //~ ERROR use of moved value - y //~ ERROR use of moved value + same_type((x, y)); + y + //~^ ERROR: mismatched types [E0308] } fn same_type<T>(x: (T, T)) {} diff --git a/src/test/ui/type-alias-impl-trait/type_of_a_let.stderr b/src/test/ui/type-alias-impl-trait/type_of_a_let.stderr index 1dabe4586c5..cac8d6841af 100644 --- a/src/test/ui/type-alias-impl-trait/type_of_a_let.stderr +++ b/src/test/ui/type-alias-impl-trait/type_of_a_let.stderr @@ -1,23 +1,67 @@ -error[E0382]: use of moved value: `x` - --> $DIR/type_of_a_let.rs:16:16 +error[E0308]: mismatched types + --> $DIR/type_of_a_let.rs:12:18 | +LL | type Foo = impl Debug; + | ---------- the expected opaque type +... LL | let x: Foo = 22_u32; - | - move occurs because `x` has type `Foo`, which does not implement the `Copy` trait -LL | let y: Foo = x; - | - value moved here -LL | same_type((x, y)); - | ^ value used here after move + | --- ^^^^^^ expected opaque type, found `u32` + | | + | expected due to this + | + = note: expected opaque type `impl Debug` + found type `u32` + +error[E0308]: mismatched types + --> $DIR/type_of_a_let.rs:14:5 + | +LL | type Foo = impl Debug; + | ---------- the found opaque type +... +LL | fn foo1() -> u32 { + | --- expected `u32` because of return type +... +LL | x + | ^ expected `u32`, found opaque type + | + = note: expected type `u32` + found opaque type `impl Debug` -error[E0382]: use of moved value: `y` - --> $DIR/type_of_a_let.rs:17:5 +error[E0308]: mismatched types + --> $DIR/type_of_a_let.rs:19:18 + | +LL | type Foo = impl Debug; + | ---------- the expected opaque type +... +LL | let x: Foo = 22_u32; + | --- ^^^^^^ expected opaque type, found `u32` + | | + | expected due to this | -LL | let y: Foo = x; - | - move occurs because `y` has type `Foo`, which does not implement the `Copy` trait -LL | same_type((x, y)); - | - value moved here + = note: expected opaque type `impl Debug` + found type `u32` + +error[E0308]: mismatched types + --> $DIR/type_of_a_let.rs:23:5 + | +LL | type Foo = impl Debug; + | ---------- the found opaque type +... +LL | fn foo2() -> u32 { + | --- expected `u32` because of return type +... LL | y - | ^ value used here after move + | ^ expected `u32`, found opaque type + | + = note: expected type `u32` + found opaque type `impl Debug` + +error: could not find defining uses + --> $DIR/type_of_a_let.rs:8:12 + | +LL | type Foo = impl Debug; + | ^^^^^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to 5 previous errors -For more information about this error, try `rustc --explain E0382`. +For more information about this error, try `rustc --explain E0308`. diff --git a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs index 5407b5e8ed9..7512039a480 100644 --- a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs +++ b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs @@ -32,7 +32,6 @@ pub fn is_min_const_fn<'a, 'tcx>(tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, msrv: | ty::PredicateKind::Projection(_) | ty::PredicateKind::ConstEvaluatable(..) | ty::PredicateKind::ConstEquate(..) - | ty::PredicateKind::OpaqueType(..) | ty::PredicateKind::TypeWellFormedFromEnv(..) => continue, ty::PredicateKind::ObjectSafe(_) => panic!("object safe predicate on function: {:#?}", predicate), ty::PredicateKind::ClosureKind(..) => panic!("closure kind predicate on function: {:#?}", predicate), | 
