diff --git a/.github/ISSUE_TEMPLATE/tracking_issue_future.md b/.github/ISSUE_TEMPLATE/tracking_issue_future.md index c9da81371e151..62584fa2a9a59 100644 --- a/.github/ISSUE_TEMPLATE/tracking_issue_future.md +++ b/.github/ISSUE_TEMPLATE/tracking_issue_future.md @@ -2,7 +2,7 @@ name: Future Incompatibility Tracking Issue about: A tracking issue for a future-incompatible lint title: Tracking Issue for future-incompatibility lint XXX -labels: C-tracking-issue C-future-incompatibility T-compiler A-lints +labels: C-tracking-issue, C-future-incompatibility, T-compiler, A-lints --- $DIR/associated-const-generic-obligations.rs:14:17 | +LL | impl Bar for T { LL | const FROM: &'static str = "foo"; | ^^^^^^^^^^^^ expected associated type, found `&'static str` | note: type in trait --> $DIR/associated-const-generic-obligations.rs:10:17 | +LL | trait Bar: Foo { LL | const FROM: Self::Out; | ^^^^^^^^^ = note: expected associated type `::Out` diff --git a/tests/ui/associated-consts/associated-const-impl-wrong-type.stderr b/tests/ui/associated-consts/associated-const-impl-wrong-type.stderr index b91b777d5850f..6b517b4a00528 100644 --- a/tests/ui/associated-consts/associated-const-impl-wrong-type.stderr +++ b/tests/ui/associated-consts/associated-const-impl-wrong-type.stderr @@ -1,12 +1,14 @@ error[E0326]: implemented const `BAR` has an incompatible type for trait --> $DIR/associated-const-impl-wrong-type.rs:8:16 | +LL | impl Foo for SignedBar { LL | const BAR: i32 = -1; | ^^^ expected `u32`, found `i32` | note: type in trait --> $DIR/associated-const-impl-wrong-type.rs:2:16 | +LL | trait Foo { LL | const BAR: u32; | ^^^ diff --git a/tests/ui/associated-types/defaults-specialization.stderr b/tests/ui/associated-types/defaults-specialization.stderr index a03296af8a37b..ee0e9878e8e6a 100644 --- a/tests/ui/associated-types/defaults-specialization.stderr +++ b/tests/ui/associated-types/defaults-specialization.stderr @@ -1,12 +1,15 @@ error[E0053]: method `make` has an incompatible type for trait --> $DIR/defaults-specialization.rs:18:18 | +LL | default impl Tr for A { LL | fn make() -> u8 { 0 } | ^^ expected associated type, found `u8` | note: type in trait --> $DIR/defaults-specialization.rs:8:18 | +LL | trait Tr { +... LL | fn make() -> Self::Ty { | ^^^^^^^^ = note: expected signature `fn() -> as Tr>::Ty` @@ -30,6 +33,8 @@ LL | fn make() -> bool { true } note: type in trait --> $DIR/defaults-specialization.rs:8:18 | +LL | trait Tr { +... LL | fn make() -> Self::Ty { | ^^^^^^^^ = note: expected signature `fn() -> as Tr>::Ty` diff --git a/tests/ui/async-await/async-drop/cancelled-future-drops-sync-fields-164901.rs b/tests/ui/async-await/async-drop/cancelled-future-drops-sync-fields-164901.rs deleted file mode 100644 index 280e123eb0b78..0000000000000 --- a/tests/ui/async-await/async-drop/cancelled-future-drops-sync-fields-164901.rs +++ /dev/null @@ -1,56 +0,0 @@ -//@ run-pass -//@ edition: 2024 - -// Regression test for . -// Types with only a sync `Drop` impl nested inside another ADT were treated -// as needing async drop, so a cancelled future leaked them. - -#![feature(async_drop)] -#![allow(incomplete_features)] - -use std::future::Future; -use std::pin::pin; -use std::sync::atomic::{AtomicUsize, Ordering}; -use std::task::{Context, Waker}; - -static DROPS: AtomicUsize = AtomicUsize::new(0); - -struct D; -impl Drop for D { - fn drop(&mut self) { - DROPS.fetch_add(1, Ordering::Relaxed); - } -} - -struct Wrapper(T); - -fn poll_once_then_drop(f: impl Future) { - let mut f = Box::pin(f); - let _ = f.as_mut().poll(&mut Context::from_waker(Waker::noop())); -} - -fn main() { - poll_once_then_drop(async { - let _d = D; - std::future::pending::<()>().await - }); - assert_eq!(DROPS.load(Ordering::Relaxed), 1); - - poll_once_then_drop(async { - let _o = Some(D); - std::future::pending::<()>().await - }); - assert_eq!(DROPS.load(Ordering::Relaxed), 2); - - poll_once_then_drop(async { - let _w = Wrapper(D); - std::future::pending::<()>().await - }); - assert_eq!(DROPS.load(Ordering::Relaxed), 3); - - poll_once_then_drop(async { - let _p = pin!(D); - std::future::pending::<()>().await - }); - assert_eq!(DROPS.load(Ordering::Relaxed), 4); -} diff --git a/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.rs b/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.rs index 8d3dbaf6ca1f1..217eadeb26229 100644 --- a/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.rs +++ b/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.rs @@ -4,7 +4,8 @@ use std::future::Future; use std::pin::Pin; trait MyTrait { - fn foo(&self) -> Pin + '_>>; + fn foo(&self) + -> Pin + '_>>; } impl MyTrait for i32 { diff --git a/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr b/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr index c98df134072eb..387626907f1f5 100644 --- a/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr +++ b/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr @@ -1,14 +1,17 @@ error[E0053]: method `foo` has an incompatible type for trait - --> $DIR/async-example-desugared-boxed-in-trait.rs:11:28 + --> $DIR/async-example-desugared-boxed-in-trait.rs:12:28 | +LL | impl MyTrait for i32 { LL | async fn foo(&self) -> i32 { | ^^^ expected `Pin>>`, found future | note: type in trait - --> $DIR/async-example-desugared-boxed-in-trait.rs:7:22 + --> $DIR/async-example-desugared-boxed-in-trait.rs:8:8 | -LL | fn foo(&self) -> Pin + '_>>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | trait MyTrait { +LL | fn foo(&self) +LL | -> Pin + '_>>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: expected signature `fn(&_) -> Pin>>` found signature `fn(&_) -> impl Future` diff --git a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr index d0c11565f4e90..4feaee82fef79 100644 --- a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr +++ b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr @@ -1,12 +1,14 @@ error[E0053]: method `foo` has an incompatible type for trait --> $DIR/dont-project-to-specializable-projection.rs:14:35 | +LL | impl MyTrait for MyStruct { LL | default async fn foo(_: T) -> &'static str { | ^^^^^^^^^^^^ expected associated type, found future | note: type in trait --> $DIR/dont-project-to-specializable-projection.rs:10:27 | +LL | trait MyTrait { LL | async fn foo(_: T) -> &'static str; | ^^^^^^^^^^^^ = note: expected signature `fn(_) -> impl Future` diff --git a/tests/ui/compare-method/bad-self-type.stderr b/tests/ui/compare-method/bad-self-type.stderr index bc1587883a352..fd5e13e5247ce 100644 --- a/tests/ui/compare-method/bad-self-type.stderr +++ b/tests/ui/compare-method/bad-self-type.stderr @@ -1,6 +1,8 @@ error[E0053]: method `poll` has an incompatible type for trait --> $DIR/bad-self-type.rs:10:13 | +LL | impl Future for MyFuture { +LL | type Output = (); LL | fn poll(self, _: &mut Context<'_>) -> Poll<()> { | ^^^^ expected `Pin<&mut MyFuture>`, found `MyFuture` | @@ -14,12 +16,14 @@ LL | fn poll(self: Pin<&mut MyFuture>, _: &mut Context<'_>) -> Poll<()> { error[E0053]: method `foo` has an incompatible type for trait --> $DIR/bad-self-type.rs:22:18 | +LL | impl T for MyFuture { LL | fn foo(self: Box) {} | ^^^^^^^^^ expected `MyFuture`, found `Box` | note: type in trait --> $DIR/bad-self-type.rs:17:12 | +LL | trait T { LL | fn foo(self); | ^^^^ = note: expected signature `fn(MyFuture)` @@ -33,12 +37,16 @@ LL + fn foo(self) {} error[E0053]: method `bar` has an incompatible type for trait --> $DIR/bad-self-type.rs:24:17 | +LL | impl T for MyFuture { +... LL | fn bar(self) {} | ^ expected `Option<()>`, found `()` | note: type in trait --> $DIR/bad-self-type.rs:18:21 | +LL | trait T { +LL | fn foo(self); LL | fn bar(self) -> Option<()>; | ^^^^^^^^^^ = note: expected signature `fn(MyFuture) -> Option<()>` diff --git a/tests/ui/compare-method/default-type-parameter.rs b/tests/ui/compare-method/default-type-parameter.rs new file mode 100644 index 0000000000000..7b72c4eff03d5 --- /dev/null +++ b/tests/ui/compare-method/default-type-parameter.rs @@ -0,0 +1,25 @@ +// Regression test for https://github.com/rust-lang/rust/issues/67991 +// The weird indentation is to exercise the span context that shows the enclosing items in the +// diagnostics being emitted. +trait Trait< + T = (), + K = Self, +> { + fn foo() + -> T; + fn bar() + -> K; +} + +struct S; + +impl Trait for S { + fn foo() -> u32 { 0 } //~ ERROR + fn bar() -> u32 { 0 } //~ ERROR +} +impl Trait for () { + fn foo() -> u32 { 0 } //~ ERROR + fn bar() -> u32 { 0 } //~ ERROR +} + +fn main() {} diff --git a/tests/ui/compare-method/default-type-parameter.stderr b/tests/ui/compare-method/default-type-parameter.stderr new file mode 100644 index 0000000000000..e3109566d7fac --- /dev/null +++ b/tests/ui/compare-method/default-type-parameter.stderr @@ -0,0 +1,107 @@ +error[E0053]: method `foo` has an incompatible type for trait + --> $DIR/default-type-parameter.rs:17:17 + | +LL | impl Trait for S { +LL | fn foo() -> u32 { 0 } + | ^^^ expected `()`, found `u32` + | +note: type in trait + --> $DIR/default-type-parameter.rs:9:8 + | +LL | trait Trait< +LL | T = (), + | ------ expected to match the default of type parameter `T` +... +LL | fn foo() +LL | -> T; + | ^ + = note: expected signature `fn() -> ()` + found signature `fn() -> u32` +help: change the output type to match the trait + | +LL - fn foo() -> u32 { 0 } +LL + fn foo() -> () { 0 } + | + +error[E0053]: method `bar` has an incompatible type for trait + --> $DIR/default-type-parameter.rs:18:17 + | +LL | impl Trait for S { +LL | fn foo() -> u32 { 0 } +LL | fn bar() -> u32 { 0 } + | ^^^ expected `S`, found `u32` + | +note: type in trait + --> $DIR/default-type-parameter.rs:11:8 + | +LL | trait Trait< +LL | T = (), +LL | K = Self, + | -------- expected to match the `Self` default of type parameter `K` +... +LL | fn bar() +LL | -> K; + | ^ + = note: expected signature `fn() -> S` + found signature `fn() -> u32` +help: change the output type to match the trait + | +LL - fn bar() -> u32 { 0 } +LL + fn bar() -> S { 0 } + | + +error[E0053]: method `foo` has an incompatible type for trait + --> $DIR/default-type-parameter.rs:21:17 + | +LL | impl Trait for () { +LL | fn foo() -> u32 { 0 } + | ^^^ expected `i32`, found `u32` + | +note: type in trait + --> $DIR/default-type-parameter.rs:9:8 + | +LL | trait Trait< +LL | T = (), + | ------ expected to match type parameter `T` +... +LL | fn foo() +LL | -> T; + | ^ + = note: expected signature `fn() -> i32` + found signature `fn() -> u32` +help: change the output type to match the trait + | +LL - fn foo() -> u32 { 0 } +LL + fn foo() -> i32 { 0 } + | + +error[E0053]: method `bar` has an incompatible type for trait + --> $DIR/default-type-parameter.rs:22:17 + | +LL | impl Trait for () { +LL | fn foo() -> u32 { 0 } +LL | fn bar() -> u32 { 0 } + | ^^^ expected `()`, found `u32` + | +note: type in trait + --> $DIR/default-type-parameter.rs:11:8 + | +LL | trait Trait< +LL | T = (), +LL | K = Self, + | -------- expected to match the `Self` default of type parameter `K` +... +LL | fn bar() +LL | -> K; + | ^ + = note: expected signature `fn() -> ()` + found signature `fn() -> u32` +help: change the output type to match the trait + | +LL - fn bar() -> u32 { 0 } +LL + fn bar() -> () { 0 } + | + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0053`. diff --git a/tests/ui/compare-method/issue-90444.stderr b/tests/ui/compare-method/issue-90444.stderr index c69d63b3e30bc..233def019ea42 100644 --- a/tests/ui/compare-method/issue-90444.stderr +++ b/tests/ui/compare-method/issue-90444.stderr @@ -1,6 +1,7 @@ error[E0053]: method `from` has an incompatible type for trait --> $DIR/issue-90444.rs:3:16 | +LL | impl From for A { LL | fn from(_: fn((), (), &mut ())) -> Self { | ^^^^^^^^^^^^^^^^^^^ types differ in mutability | @@ -15,6 +16,7 @@ LL + fn from(_: for<'a> fn((), (), &'a ())) -> Self { error[E0053]: method `from` has an incompatible type for trait --> $DIR/issue-90444.rs:11:16 | +LL | impl From for B { LL | fn from(_: fn((), (), u64)) -> Self { | ^^^^^^^^^^^^^^^ expected `u32`, found `u64` | diff --git a/tests/ui/compare-method/reordered-type-param.stderr b/tests/ui/compare-method/reordered-type-param.stderr index 536364871a368..bea7b43de48d0 100644 --- a/tests/ui/compare-method/reordered-type-param.stderr +++ b/tests/ui/compare-method/reordered-type-param.stderr @@ -1,6 +1,8 @@ error[E0053]: method `b` has an incompatible type for trait --> $DIR/reordered-type-param.rs:16:30 | +LL | impl A for E { +LL | // n.b. The error message is awful -- see #3404 LL | fn b(&self, _x: G) -> G { panic!() } | - - ^ expected type parameter `F`, found type parameter `G` | | | @@ -10,6 +12,7 @@ LL | fn b(&self, _x: G) -> G { panic!() } note: type in trait --> $DIR/reordered-type-param.rs:7:29 | +LL | trait A { LL | fn b(&self, x: C) -> C; | ^ = note: expected signature `fn(&E, F) -> F` diff --git a/tests/ui/const-generics/mgca/type-const-value-type-mismatch.current.stderr b/tests/ui/const-generics/mgca/type-const-value-type-mismatch.current.stderr index dc7f73f2549e8..5d0c6b06dfc8b 100644 --- a/tests/ui/const-generics/mgca/type-const-value-type-mismatch.current.stderr +++ b/tests/ui/const-generics/mgca/type-const-value-type-mismatch.current.stderr @@ -1,12 +1,16 @@ error[E0053]: method `arr` has an incompatible type for trait --> $DIR/type-const-value-type-mismatch.rs:24:5 | +LL | impl Array for A { +... LL | fn arr() -> [u8; const { Self::LEN }] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an array with a size of 0, found one with a size of const { Self::LEN } | note: type in trait --> $DIR/type-const-value-type-mismatch.rs:17:5 | +LL | pub trait Array { +... LL | fn arr() -> [u8; Self::LEN]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: expected signature `fn() -> [u8; 0]` diff --git a/tests/ui/consts/issue-70942-trait-vs-impl-mismatch.stderr b/tests/ui/consts/issue-70942-trait-vs-impl-mismatch.stderr index 0393316f166ba..0e877df4ea553 100644 --- a/tests/ui/consts/issue-70942-trait-vs-impl-mismatch.stderr +++ b/tests/ui/consts/issue-70942-trait-vs-impl-mismatch.stderr @@ -1,12 +1,14 @@ error[E0326]: implemented const `VALUE` has an incompatible type for trait --> $DIR/issue-70942-trait-vs-impl-mismatch.rs:8:18 | +LL | impl Nat for Zero { LL | const VALUE: i32 = 0; | ^^^ expected `usize`, found `i32` | note: type in trait --> $DIR/issue-70942-trait-vs-impl-mismatch.rs:2:18 | +LL | trait Nat { LL | const VALUE: usize; | ^^^^^ diff --git a/tests/ui/cross-crate/graceful-error-for-mistyped-assoc-const.stderr b/tests/ui/cross-crate/graceful-error-for-mistyped-assoc-const.stderr index 18b06462de7b6..67622e28aca7b 100644 --- a/tests/ui/cross-crate/graceful-error-for-mistyped-assoc-const.stderr +++ b/tests/ui/cross-crate/graceful-error-for-mistyped-assoc-const.stderr @@ -1,6 +1,7 @@ error[E0326]: implemented const `CONST` has an incompatible type for trait --> $DIR/graceful-error-for-mistyped-assoc-const.rs:10:18 | +LL | impl issue_41549::Trait for S { LL | const CONST: () = (); | ^^ expected `u32`, found `()` diff --git a/tests/ui/cross-crate/unit-struct.stderr b/tests/ui/cross-crate/unit-struct.stderr index f158602456cea..447b345cafb0b 100644 --- a/tests/ui/cross-crate/unit-struct.stderr +++ b/tests/ui/cross-crate/unit-struct.stderr @@ -2,9 +2,7 @@ error[E0423]: cannot find value `StructWithFields` in crate `xcrate_unit_struct` --> $DIR/unit-struct.rs:9:33 | LL | let _ = xcrate_unit_struct::StructWithFields; - | --------------------^^^^^^^^^^^^^^^^ - | | - | help: use struct literal syntax instead: `xcrate_unit_struct::StructWithFields { foo: val }` + | ^^^^^^^^^^^^^^^^ | ::: $DIR/auxiliary/xcrate_unit_struct.rs:20:1 | @@ -12,6 +10,10 @@ LL | pub struct StructWithFields { | --------------------------- `xcrate_unit_struct::StructWithFields` defined here | = note: a struct named `xcrate_unit_struct::StructWithFields` exists in another namespace +help: use struct literal syntax instead + | +LL | let _ = xcrate_unit_struct::StructWithFields { foo: val }; + | ++++++++++++ error[E0423]: cannot find value `StructWithPrivFields` in crate `xcrate_unit_struct` --> $DIR/unit-struct.rs:11:33 diff --git a/tests/ui/delegation/target-expr-removal-defs-inside.stderr b/tests/ui/delegation/target-expr-removal-defs-inside.stderr index 6fde7fb8a7bdb..9f52c8c137d2a 100644 --- a/tests/ui/delegation/target-expr-removal-defs-inside.stderr +++ b/tests/ui/delegation/target-expr-removal-defs-inside.stderr @@ -183,6 +183,7 @@ LL | | } note: type in trait --> $DIR/target-expr-removal-defs-inside.rs:4:25 | +LL | pub trait Trait: Sized { LL | fn static_self() -> F { F } | ^ = note: expected signature `fn() -> F` @@ -257,6 +258,7 @@ LL | | } note: type in trait --> $DIR/target-expr-removal-defs-inside.rs:4:25 | +LL | pub trait Trait: Sized { LL | fn static_self() -> F { F } | ^ = note: expected signature `fn() -> F` @@ -335,6 +337,7 @@ LL | | } note: type in trait --> $DIR/target-expr-removal-defs-inside.rs:4:25 | +LL | pub trait Trait: Sized { LL | fn static_self() -> F { F } | ^ = note: expected signature `fn() -> F` diff --git a/tests/ui/delegation/unused-target-expr-in-glob-or-list.stderr b/tests/ui/delegation/unused-target-expr-in-glob-or-list.stderr index 21d9586d2f58e..18291e0f8a9a7 100644 --- a/tests/ui/delegation/unused-target-expr-in-glob-or-list.stderr +++ b/tests/ui/delegation/unused-target-expr-in-glob-or-list.stderr @@ -164,7 +164,8 @@ error[E0053]: method `static_self` has an incompatible type for trait --> $DIR/unused-target-expr-in-glob-or-list.rs:107:37 | LL | macro_rules! delegation { -... +LL | () => { +LL | impl Trait for S { LL | reuse ::static_self { self.0 } | ^^^^^^^^^^^ expected `F`, found `()` ... @@ -174,6 +175,7 @@ LL | delegation!(); note: type in trait --> $DIR/unused-target-expr-in-glob-or-list.rs:4:25 | +LL | pub trait Trait: Sized { LL | fn static_self() -> F { F } | ^ = note: expected signature `fn() -> F` @@ -192,12 +194,14 @@ LL | () => { LL | reuse ::static_self { self.0 } | ^^^^^^^^^^^ expected `F`, found `()` ... +LL | impl Trait for S1 { LL | delegation2!(); | -------------- in this macro invocation | note: type in trait --> $DIR/unused-target-expr-in-glob-or-list.rs:4:25 | +LL | pub trait Trait: Sized { LL | fn static_self() -> F { F } | ^ = note: expected signature `fn() -> F` diff --git a/tests/ui/drop/async-drop-cycle-issue-165263.rs b/tests/ui/drop/async-drop-cycle-issue-165263.rs new file mode 100644 index 0000000000000..3add37ecf990a --- /dev/null +++ b/tests/ui/drop/async-drop-cycle-issue-165263.rs @@ -0,0 +1,22 @@ +//@ build-pass +//@ edition: 2024 +// test that a recursive type in an async block does +// not cause a cycle. + +pub struct A(Box); +pub struct B(A); +pub async fn run(_: A) {} + +pub enum A2 { + X(Box), +} + +pub enum B2 { + Y(A2), +} +pub async fn run2(a: Option) { + async {}.await; + drop(a); +} + +fn main() {} diff --git a/tests/ui/drop/tail_expr_drop_order-on-async-block-with-drop-field.rs b/tests/ui/drop/tail_expr_drop_order-on-async-block-with-drop-field.rs deleted file mode 100644 index 69e9a8e06dc86..0000000000000 --- a/tests/ui/drop/tail_expr_drop_order-on-async-block-with-drop-field.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ edition: 2021 -//@ check-pass - -// Regression test for . -// The tail expr drop order lint used to ICE on this async block. It stopped -// once types with only a sync `Drop` were no longer treated as needing async drop. - -#![warn(tail_expr_drop_order)] -use core::future::Future; - -fn f() -> impl Future> { - async { Some("nope".into()) } -} - -fn main() {} diff --git a/tests/ui/errors/remap-path-prefix-reverse.local-self.stderr b/tests/ui/errors/remap-path-prefix-reverse.local-self.stderr index 047916bb7cace..eabf17c25c902 100644 --- a/tests/ui/errors/remap-path-prefix-reverse.local-self.stderr +++ b/tests/ui/errors/remap-path-prefix-reverse.local-self.stderr @@ -2,9 +2,7 @@ error[E0423]: cannot find value `SomeStruct` in crate `remapped_dep` --> $DIR/remap-path-prefix-reverse.rs:15:27 | LL | let _ = remapped_dep::SomeStruct; - | --------------^^^^^^^^^^ - | | - | help: use struct literal syntax instead: `remapped_dep::SomeStruct {}` + | ^^^^^^^^^^ | ::: remapped-aux/remapped_dep.rs:4:1 | @@ -12,6 +10,10 @@ LL | pub struct SomeStruct {} // This line should be show as part of the error. | --------------------- `remapped_dep::SomeStruct` defined here | = note: a struct named `remapped_dep::SomeStruct` exists in another namespace +help: use struct literal syntax instead + | +LL | let _ = remapped_dep::SomeStruct {}; + | ++ error: aborting due to 1 previous error diff --git a/tests/ui/errors/remap-path-prefix-reverse.remapped-self.stderr b/tests/ui/errors/remap-path-prefix-reverse.remapped-self.stderr index 047916bb7cace..eabf17c25c902 100644 --- a/tests/ui/errors/remap-path-prefix-reverse.remapped-self.stderr +++ b/tests/ui/errors/remap-path-prefix-reverse.remapped-self.stderr @@ -2,9 +2,7 @@ error[E0423]: cannot find value `SomeStruct` in crate `remapped_dep` --> $DIR/remap-path-prefix-reverse.rs:15:27 | LL | let _ = remapped_dep::SomeStruct; - | --------------^^^^^^^^^^ - | | - | help: use struct literal syntax instead: `remapped_dep::SomeStruct {}` + | ^^^^^^^^^^ | ::: remapped-aux/remapped_dep.rs:4:1 | @@ -12,6 +10,10 @@ LL | pub struct SomeStruct {} // This line should be show as part of the error. | --------------------- `remapped_dep::SomeStruct` defined here | = note: a struct named `remapped_dep::SomeStruct` exists in another namespace +help: use struct literal syntax instead + | +LL | let _ = remapped_dep::SomeStruct {}; + | ++ error: aborting due to 1 previous error diff --git a/tests/ui/feature-gates/feature-gate-effective-target-features.default.stderr b/tests/ui/feature-gates/feature-gate-effective-target-features.default.stderr index 1bad811ada64a..7b8ba0e660ece 100644 --- a/tests/ui/feature-gates/feature-gate-effective-target-features.default.stderr +++ b/tests/ui/feature-gates/feature-gate-effective-target-features.default.stderr @@ -20,12 +20,15 @@ LL | fn foo(&self) {} error[E0053]: method `foo` has an incompatible type for trait --> $DIR/feature-gate-effective-target-features.rs:24:5 | +LL | impl Foo for Bar2 { +... LL | fn foo(&self) {} | ^^^^^^^^^^^^^ expected safe fn, found unsafe fn | note: type in trait --> $DIR/feature-gate-effective-target-features.rs:8:5 | +LL | trait Foo { LL | fn foo(&self); | ^^^^^^^^^^^^^^ = note: expected signature `fn(&Bar2)` diff --git a/tests/ui/feature-gates/feature-gate-effective-target-features.feature.stderr b/tests/ui/feature-gates/feature-gate-effective-target-features.feature.stderr index 06090cbbef6fe..d1939e35d4aba 100644 --- a/tests/ui/feature-gates/feature-gate-effective-target-features.feature.stderr +++ b/tests/ui/feature-gates/feature-gate-effective-target-features.feature.stderr @@ -23,12 +23,15 @@ LL | fn foo(&self) {} error[E0053]: method `foo` has an incompatible type for trait --> $DIR/feature-gate-effective-target-features.rs:24:5 | +LL | impl Foo for Bar2 { +... LL | fn foo(&self) {} | ^^^^^^^^^^^^^ expected safe fn, found unsafe fn | note: type in trait --> $DIR/feature-gate-effective-target-features.rs:8:5 | +LL | trait Foo { LL | fn foo(&self); | ^^^^^^^^^^^^^^ = note: expected signature `fn(&Bar2)` diff --git a/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr b/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr index f844bdbc2cb21..3a507e5f218b4 100644 --- a/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr +++ b/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr @@ -59,6 +59,8 @@ LL | impl Fn<()> for Foo { error[E0053]: method `call` has an incompatible type for trait --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:13:32 | +LL | impl Fn<()> for Foo { +... LL | extern "rust-call" fn call(self, args: ()) -> () {} | ^^^^ expected `&Foo`, found `Foo` | @@ -151,6 +153,8 @@ LL | impl FnOnce() for Foo1 { error[E0053]: method `call_mut` has an incompatible type for trait --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:30:36 | +LL | impl FnMut<()> for Bar { +... LL | extern "rust-call" fn call_mut(&self, args: ()) -> () {} | ^^^^^ types differ in mutability | diff --git a/tests/ui/fn/fn-traits-call-once-signature-15094.stderr b/tests/ui/fn/fn-traits-call-once-signature-15094.stderr index bb1d336e84842..1a892168c2c16 100644 --- a/tests/ui/fn/fn-traits-call-once-signature-15094.stderr +++ b/tests/ui/fn/fn-traits-call-once-signature-15094.stderr @@ -1,6 +1,8 @@ error[E0053]: method `call_once` has an incompatible type for trait --> $DIR/fn-traits-call-once-signature-15094.rs:13:5 | +LL | impl ops::FnOnce<(),> for Debuger { +LL | type Output = (); LL | fn call_once(self, _args: ()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected "rust-call" fn, found "Rust" fn | diff --git a/tests/ui/impl-trait/apit/impl-generic-mismatch-ab.stderr b/tests/ui/impl-trait/apit/impl-generic-mismatch-ab.stderr index 9db996cf9ce65..a7f67f04c4905 100644 --- a/tests/ui/impl-trait/apit/impl-generic-mismatch-ab.stderr +++ b/tests/ui/impl-trait/apit/impl-generic-mismatch-ab.stderr @@ -1,6 +1,7 @@ error[E0053]: method `foo` has an incompatible type for trait --> $DIR/impl-generic-mismatch-ab.rs:8:32 | +LL | impl Foo for () { LL | fn foo(&self, a: &impl Debug, b: &B) { } | - ^^^^^^^^^^^ expected type parameter `B`, found type parameter `impl Debug` | | @@ -9,6 +10,7 @@ LL | fn foo(&self, a: &impl Debug, b: &B) { } note: type in trait --> $DIR/impl-generic-mismatch-ab.rs:4:32 | +LL | trait Foo { LL | fn foo(&self, a: &A, b: &impl Debug); | ^^ = note: expected signature `fn(&(), &B, &impl Debug)` diff --git a/tests/ui/impl-trait/in-assoc-type-unconstrained.stderr b/tests/ui/impl-trait/in-assoc-type-unconstrained.stderr index 39121c99798bf..5522fea6eb5e2 100644 --- a/tests/ui/impl-trait/in-assoc-type-unconstrained.stderr +++ b/tests/ui/impl-trait/in-assoc-type-unconstrained.stderr @@ -16,6 +16,7 @@ LL | type Ty: IntoIterator; error[E0053]: method `method` has an incompatible type for trait --> $DIR/in-assoc-type-unconstrained.rs:22:24 | +LL | impl Trait for () { LL | type Ty = impl Sized; | ---------- the expected opaque type LL | @@ -25,6 +26,8 @@ LL | fn method() -> () {} note: type in trait --> $DIR/in-assoc-type-unconstrained.rs:17:24 | +LL | trait Trait { +LL | type Ty; LL | fn method() -> Self::Ty; | ^^^^^^^^ = note: expected signature `fn() -> <() as compare_method::Trait>::Ty` diff --git a/tests/ui/impl-trait/in-trait/deep-match.stderr b/tests/ui/impl-trait/in-trait/deep-match.stderr index 8ec30239ea8d7..1433664158b9f 100644 --- a/tests/ui/impl-trait/in-trait/deep-match.stderr +++ b/tests/ui/impl-trait/in-trait/deep-match.stderr @@ -1,12 +1,16 @@ error[E0053]: method `bar` has an incompatible return type for trait --> $DIR/deep-match.rs:8:17 | +LL | impl Foo for () { LL | fn bar() -> i32 { - | ^^^ - | | - | expected `Wrapper<_>`, found `i32` - | return type in trait + | ^^^ expected `Wrapper<_>`, found `i32` | +note: return type in trait + --> $DIR/deep-match.rs:4:17 + | +LL | trait Foo { +LL | fn bar() -> Wrapper; + | ^^^^^^^^^^^^^^^^^^^ = note: expected struct `Wrapper<_>` found type `i32` diff --git a/tests/ui/impl-trait/in-trait/method-signature-matches.lt.stderr b/tests/ui/impl-trait/in-trait/method-signature-matches.lt.stderr index 97f5b2af862e0..8c3f4300532fe 100644 --- a/tests/ui/impl-trait/in-trait/method-signature-matches.lt.stderr +++ b/tests/ui/impl-trait/in-trait/method-signature-matches.lt.stderr @@ -1,6 +1,7 @@ error[E0053]: method `early` has an incompatible type for trait --> $DIR/method-signature-matches.rs:55:27 | +LL | impl Lifetimes for () { LL | fn early<'late, T>(_: &'late ()) {} | - ^^^^^^^^^ expected type parameter `T`, found `()` | | @@ -9,6 +10,7 @@ LL | fn early<'late, T>(_: &'late ()) {} note: type in trait --> $DIR/method-signature-matches.rs:50:28 | +LL | trait Lifetimes { LL | fn early<'early, T>(x: &'early T) -> impl Sized; | ^^^^^^^^^ = note: expected signature `fn(&'early T)` diff --git a/tests/ui/impl-trait/in-trait/method-signature-matches.mismatch.stderr b/tests/ui/impl-trait/in-trait/method-signature-matches.mismatch.stderr index 588b453761003..dd6c906e64255 100644 --- a/tests/ui/impl-trait/in-trait/method-signature-matches.mismatch.stderr +++ b/tests/ui/impl-trait/in-trait/method-signature-matches.mismatch.stderr @@ -1,12 +1,14 @@ error[E0053]: method `owo` has an incompatible type for trait --> $DIR/method-signature-matches.rs:11:15 | +LL | impl Uwu for () { LL | fn owo(_: u8) {} | ^^ expected `()`, found `u8` | note: type in trait --> $DIR/method-signature-matches.rs:6:15 | +LL | trait Uwu { LL | fn owo(x: ()) -> impl Sized; | ^^ = note: expected signature `fn(())` diff --git a/tests/ui/impl-trait/in-trait/method-signature-matches.mismatch_async.stderr b/tests/ui/impl-trait/in-trait/method-signature-matches.mismatch_async.stderr index b0530045bea9a..6a834ceed727e 100644 --- a/tests/ui/impl-trait/in-trait/method-signature-matches.mismatch_async.stderr +++ b/tests/ui/impl-trait/in-trait/method-signature-matches.mismatch_async.stderr @@ -1,12 +1,14 @@ error[E0053]: method `owo` has an incompatible type for trait --> $DIR/method-signature-matches.rs:22:21 | +LL | impl AsyncUwu for () { LL | async fn owo(_: u8) {} | ^^ expected `()`, found `u8` | note: type in trait --> $DIR/method-signature-matches.rs:17:21 | +LL | trait AsyncUwu { LL | async fn owo(x: ()) {} | ^^ = note: expected signature `fn(()) -> _` diff --git a/tests/ui/impl-trait/in-trait/specialization-broken.stderr b/tests/ui/impl-trait/in-trait/specialization-broken.stderr index fbbe1ac40b9ef..ab739dae23d7f 100644 --- a/tests/ui/impl-trait/in-trait/specialization-broken.stderr +++ b/tests/ui/impl-trait/in-trait/specialization-broken.stderr @@ -10,6 +10,7 @@ LL | fn bar(&self) -> U { note: type in trait --> $DIR/specialization-broken.rs:8:22 | +LL | trait Foo { LL | fn bar(&self) -> impl Sized; | ^^^^^^^^^^ = note: expected signature `fn(&_) -> impl Sized` diff --git a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr index f921e5a452244..2c99ae95da74f 100644 --- a/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr +++ b/tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr @@ -4,6 +4,8 @@ error[E0053]: method `eq` has an incompatible type for trait LL | type Foo = impl PartialEq<(Foo, i32)>; | -------------------------- the found opaque type ... +LL | impl PartialEq<(Bar, i32)> for Bar { +LL | #[define_opaque(Foo)] LL | fn eq(&self, _other: &(Foo, i32)) -> bool { | ^^^^^^^^^^^ expected `a::Bar`, found opaque type | @@ -21,6 +23,7 @@ error[E0053]: method `eq` has an incompatible type for trait LL | type Foo = impl PartialEq<(Foo, i32)>; | -------------------------- the expected opaque type ... +LL | impl PartialEq<(Foo, i32)> for Bar { LL | fn eq(&self, _other: &(Bar, i32)) -> bool { | ^^^^^^^^^^^ expected opaque type, found `b::Bar` | diff --git a/tests/ui/impl-trait/trait_type.stderr b/tests/ui/impl-trait/trait_type.stderr index 18d914a96a291..ff07297eacff1 100644 --- a/tests/ui/impl-trait/trait_type.stderr +++ b/tests/ui/impl-trait/trait_type.stderr @@ -1,6 +1,7 @@ error[E0053]: method `fmt` has an incompatible type for trait --> $DIR/trait_type.rs:7:21 | +LL | impl std::fmt::Display for MyType { LL | fn fmt(&self, x: &str) -> () { } | ^^^^ types differ in mutability | diff --git a/tests/ui/impl-trait/where-allowed.stderr b/tests/ui/impl-trait/where-allowed.stderr index a0cdc8ee89382..86573088ed971 100644 --- a/tests/ui/impl-trait/where-allowed.stderr +++ b/tests/ui/impl-trait/where-allowed.stderr @@ -348,6 +348,7 @@ LL | let _in_return_in_local_variable = || -> impl Fn() { || {} }; error[E0053]: method `in_trait_impl_return` has an incompatible type for trait --> $DIR/where-allowed.rs:129:34 | +LL | impl DummyTrait for () { LL | type Out = impl Debug; | ---------- the expected opaque type ... @@ -357,6 +358,8 @@ LL | fn in_trait_impl_return() -> impl Debug { () } note: type in trait --> $DIR/where-allowed.rs:119:34 | +LL | trait DummyTrait { +... LL | fn in_trait_impl_return() -> Self::Out; | ^^^^^^^^^ = note: expected signature `fn() -> <() as DummyTrait>::Out` diff --git a/tests/ui/lint/let_underscore/let_underscore_drop_guard.rs b/tests/ui/lint/let_underscore/let_underscore_drop_guard.rs new file mode 100644 index 0000000000000..b1a82438acdfc --- /dev/null +++ b/tests/ui/lint/let_underscore/let_underscore_drop_guard.rs @@ -0,0 +1,23 @@ +use std::mem::DropGuard; + +struct Struct { + a: T, +} + +fn main() { + let _ = DropGuard::new((), |_| {}); + //~^ERROR non-binding let on a `DropGuard` + _ = DropGuard::new((), |_| {}); + //~^ERROR non-binding let on a `DropGuard` + + let (_, _) = (DropGuard::new((), |_| {}), 1); + //~^ERROR non-binding let on a `DropGuard` + (_, _) = (DropGuard::new((), |_| {}), 1); + //~^ERROR non-binding let on a `DropGuard` + + let (_a, Struct { a: _ }) = (0, Struct { a: DropGuard::new((), |_| {}) }); + //~^ERROR non-binding let on a `DropGuard` + let _b; + (_b, Struct { a: _ }) = (0, Struct { a: DropGuard::new((), |_| {}) }); + //~^ERROR non-binding let on a `DropGuard` +} diff --git a/tests/ui/lint/let_underscore/let_underscore_drop_guard.stderr b/tests/ui/lint/let_underscore/let_underscore_drop_guard.stderr new file mode 100644 index 0000000000000..c4c58fa6b4b95 --- /dev/null +++ b/tests/ui/lint/let_underscore/let_underscore_drop_guard.stderr @@ -0,0 +1,86 @@ +error: non-binding let on a `DropGuard` + --> $DIR/let_underscore_drop_guard.rs:8:9 + | +LL | let _ = DropGuard::new((), |_| {}); + | ^ this `DropGuard` is not assigned to a binding and is immediately dropped + | + = note: `#[deny(let_underscore_drop_guard)]` on by default +help: consider binding to an unused variable to avoid immediately dropping the value + | +LL | let _unused = DropGuard::new((), |_| {}); + | ++++++ +help: consider immediately dropping the value + | +LL - let _ = DropGuard::new((), |_| {}); +LL + drop(DropGuard::new((), |_| {})); + | + +error: non-binding let on a `DropGuard` + --> $DIR/let_underscore_drop_guard.rs:10:5 + | +LL | _ = DropGuard::new((), |_| {}); + | ^ this `DropGuard` is not assigned to a binding and is immediately dropped + | +help: consider binding to an unused variable to avoid immediately dropping the value + | +LL - _ = DropGuard::new((), |_| {}); +LL + let _unused = DropGuard::new((), |_| {}); + | +help: consider immediately dropping the value + | +LL - _ = DropGuard::new((), |_| {}); +LL + drop(DropGuard::new((), |_| {})); + | + +error: non-binding let on a `DropGuard` + --> $DIR/let_underscore_drop_guard.rs:13:10 + | +LL | let (_, _) = (DropGuard::new((), |_| {}), 1); + | ^ this `DropGuard` is not assigned to a binding and is immediately dropped + | + = help: consider immediately dropping the value using `drop(..)` after the `let` statement +help: consider binding to an unused variable to avoid immediately dropping the value + | +LL | let (_unused, _) = (DropGuard::new((), |_| {}), 1); + | ++++++ + +error: non-binding let on a `DropGuard` + --> $DIR/let_underscore_drop_guard.rs:15:6 + | +LL | (_, _) = (DropGuard::new((), |_| {}), 1); + | ^ this `DropGuard` is not assigned to a binding and is immediately dropped + | +help: consider binding to an unused variable to avoid immediately dropping the value + --> $DIR/let_underscore_drop_guard.rs:15:6 + | +LL | (_, _) = (DropGuard::new((), |_| {}), 1); + | ^ + = help: consider immediately dropping the value using `drop(..)` after the `let` statement + +error: non-binding let on a `DropGuard` + --> $DIR/let_underscore_drop_guard.rs:18:26 + | +LL | let (_a, Struct { a: _ }) = (0, Struct { a: DropGuard::new((), |_| {}) }); + | ^ this `DropGuard` is not assigned to a binding and is immediately dropped + | + = help: consider immediately dropping the value using `drop(..)` after the `let` statement +help: consider binding to an unused variable to avoid immediately dropping the value + | +LL | let (_a, Struct { a: _unused }) = (0, Struct { a: DropGuard::new((), |_| {}) }); + | ++++++ + +error: non-binding let on a `DropGuard` + --> $DIR/let_underscore_drop_guard.rs:21:22 + | +LL | (_b, Struct { a: _ }) = (0, Struct { a: DropGuard::new((), |_| {}) }); + | ^ this `DropGuard` is not assigned to a binding and is immediately dropped + | +help: consider binding to an unused variable to avoid immediately dropping the value + --> $DIR/let_underscore_drop_guard.rs:21:22 + | +LL | (_b, Struct { a: _ }) = (0, Struct { a: DropGuard::new((), |_| {}) }); + | ^ + = help: consider immediately dropping the value using `drop(..)` after the `let` statement + +error: aborting due to 6 previous errors + diff --git a/tests/ui/mir/inline-wrong-abi.stderr b/tests/ui/mir/inline-wrong-abi.stderr index e44899eb92a5c..cade8c22165f7 100644 --- a/tests/ui/mir/inline-wrong-abi.stderr +++ b/tests/ui/mir/inline-wrong-abi.stderr @@ -1,6 +1,7 @@ error[E0053]: method `call` has an incompatible type for trait --> $DIR/inline-wrong-abi.rs:7:5 | +LL | impl Fn<()> for Foo { LL | extern "C" fn call(&self, _: ()) -> T { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected "rust-call" fn, found "C" fn | diff --git a/tests/ui/mismatched_types/E0053.stderr b/tests/ui/mismatched_types/E0053.stderr index 32452af5ceda7..6cc5e0b128ee5 100644 --- a/tests/ui/mismatched_types/E0053.stderr +++ b/tests/ui/mismatched_types/E0053.stderr @@ -1,12 +1,14 @@ error[E0053]: method `foo` has an incompatible type for trait --> $DIR/E0053.rs:9:15 | +LL | impl Foo for Bar { LL | fn foo(x: i16) { } | ^^^ expected `u16`, found `i16` | note: type in trait --> $DIR/E0053.rs:2:15 | +LL | trait Foo { LL | fn foo(x: u16); | ^^^ = note: expected signature `fn(u16)` @@ -20,12 +22,16 @@ LL + fn foo(x: u16) { } error[E0053]: method `bar` has an incompatible type for trait --> $DIR/E0053.rs:11:12 | +LL | impl Foo for Bar { +... LL | fn bar(&mut self) { } | ^^^^^^^^^ types differ in mutability | note: type in trait --> $DIR/E0053.rs:3:12 | +LL | trait Foo { +LL | fn foo(x: u16); LL | fn bar(&self); | ^^^^^ = note: expected signature `fn(&Bar)` diff --git a/tests/ui/mismatched_types/issue-112036.stderr b/tests/ui/mismatched_types/issue-112036.stderr index fed6b11a7b292..3a4624d206c48 100644 --- a/tests/ui/mismatched_types/issue-112036.stderr +++ b/tests/ui/mismatched_types/issue-112036.stderr @@ -1,6 +1,7 @@ error[E0053]: method `drop` has an incompatible type for trait --> $DIR/issue-112036.rs:4:13 | +LL | impl Drop for Foo { LL | fn drop(self) {} | ^^^^ expected `&mut Foo`, found `Foo` | diff --git a/tests/ui/mismatched_types/issue-13033.stderr b/tests/ui/mismatched_types/issue-13033.stderr index f21d49eac7284..df83d10e29d9c 100644 --- a/tests/ui/mismatched_types/issue-13033.stderr +++ b/tests/ui/mismatched_types/issue-13033.stderr @@ -1,12 +1,14 @@ error[E0053]: method `bar` has an incompatible type for trait --> $DIR/issue-13033.rs:10:30 | +LL | impl Foo for Baz { LL | fn bar(&mut self, other: &dyn Foo) {} | ^^^^^^^^ types differ in mutability | note: type in trait --> $DIR/issue-13033.rs:4:30 | +LL | trait Foo { LL | fn bar(&mut self, other: &mut dyn Foo); | ^^^^^^^^^^^^ = note: expected signature `fn(&mut Baz, &mut dyn Foo)` diff --git a/tests/ui/mismatched_types/trait-impl-fn-incompatibility.stderr b/tests/ui/mismatched_types/trait-impl-fn-incompatibility.stderr index 4aabf2372e478..02df411583fce 100644 --- a/tests/ui/mismatched_types/trait-impl-fn-incompatibility.stderr +++ b/tests/ui/mismatched_types/trait-impl-fn-incompatibility.stderr @@ -1,12 +1,14 @@ error[E0053]: method `foo` has an incompatible type for trait --> $DIR/trait-impl-fn-incompatibility.rs:9:15 | +LL | impl Foo for Bar { LL | fn foo(x: i16) { } | ^^^ expected `u16`, found `i16` | note: type in trait --> $DIR/trait-impl-fn-incompatibility.rs:2:15 | +LL | trait Foo { LL | fn foo(x: u16); | ^^^ = note: expected signature `fn(u16)` @@ -20,12 +22,16 @@ LL + fn foo(x: u16) { } error[E0053]: method `bar` has an incompatible type for trait --> $DIR/trait-impl-fn-incompatibility.rs:10:28 | +LL | impl Foo for Bar { +LL | fn foo(x: i16) { } LL | fn bar(&mut self, bar: &Bar) { } | ^^^^ types differ in mutability | note: type in trait --> $DIR/trait-impl-fn-incompatibility.rs:3:28 | +LL | trait Foo { +LL | fn foo(x: u16); LL | fn bar(&mut self, bar: &mut Bar); | ^^^^^^^^ = note: expected signature `fn(&mut Bar, &mut Bar)` diff --git a/tests/ui/mut/mismatch-trait-mut.e2015.stderr b/tests/ui/mut/mismatch-trait-mut.e2015.stderr index bc9d60e66bc33..0130f2d9833eb 100644 --- a/tests/ui/mut/mismatch-trait-mut.e2015.stderr +++ b/tests/ui/mut/mismatch-trait-mut.e2015.stderr @@ -1,12 +1,14 @@ error[E0053]: method `f` has an incompatible type for trait --> $DIR/mismatch-trait-mut.rs:30:18 | +LL | impl crate::A for X { LL | fn f(_x: &crate::bar::X) {} | ^^^^^^^^^^^^^^ types differ in mutability | note: type in trait --> $DIR/mismatch-trait-mut.rs:15:14 | +LL | pub trait A { LL | fn f(_x: &mut bar::X) {} | ^^^^^^^^^^^ = note: expected signature `fn(&mut X)` @@ -19,12 +21,16 @@ LL | fn f(_x: &mut crate::bar::X) {} error[E0053]: method `g` has an incompatible type for trait --> $DIR/mismatch-trait-mut.rs:34:22 | +LL | impl crate::A for X { +... LL | fn g<'a>(_x: &'a crate::bar::X) -> &'a () { &() } | ^^^^^^^^^^^^^^^^^ types differ in mutability | note: type in trait --> $DIR/mismatch-trait-mut.rs:17:18 | +LL | pub trait A { +... LL | fn g<'a>(_x: &'a mut bar::X) -> &'a () { &() } | ^^^^^^^^^^^^^^ = note: expected signature `fn(&'a mut X) -> &'a ()` @@ -37,12 +43,16 @@ LL | fn g<'a>(_x: &'a mut crate::bar::X) -> &'a () { &() } error[E0053]: method `f2` has an incompatible type for trait --> $DIR/mismatch-trait-mut.rs:38:19 | +LL | impl crate::A for X { +... LL | fn f2(_x: &mut crate::bar::X) {} | ^^^^^^^^^^^^^^^^^^ types differ in mutability | note: type in trait --> $DIR/mismatch-trait-mut.rs:19:15 | +LL | pub trait A { +... LL | fn f2(_x: &bar::X) {} | ^^^^^^^ = note: expected signature `fn(&X)` @@ -56,12 +66,16 @@ LL + fn f2(_x: &crate::bar::X) {} error[E0053]: method `g2` has an incompatible type for trait --> $DIR/mismatch-trait-mut.rs:42:23 | +LL | impl crate::A for X { +... LL | fn g2<'a>(_x: &'a mut crate::bar::X) -> &'a () { &() } | ^^^^^^^^^^^^^^^^^^^^^ types differ in mutability | note: type in trait --> $DIR/mismatch-trait-mut.rs:21:19 | +LL | pub trait A { +... LL | fn g2<'a>(_x: &'a bar::X) -> &'a () { &() } | ^^^^^^^^^^ = note: expected signature `fn(&'a X) -> &'a ()` diff --git a/tests/ui/mut/mismatch-trait-mut.e2018.stderr b/tests/ui/mut/mismatch-trait-mut.e2018.stderr index bc9d60e66bc33..0130f2d9833eb 100644 --- a/tests/ui/mut/mismatch-trait-mut.e2018.stderr +++ b/tests/ui/mut/mismatch-trait-mut.e2018.stderr @@ -1,12 +1,14 @@ error[E0053]: method `f` has an incompatible type for trait --> $DIR/mismatch-trait-mut.rs:30:18 | +LL | impl crate::A for X { LL | fn f(_x: &crate::bar::X) {} | ^^^^^^^^^^^^^^ types differ in mutability | note: type in trait --> $DIR/mismatch-trait-mut.rs:15:14 | +LL | pub trait A { LL | fn f(_x: &mut bar::X) {} | ^^^^^^^^^^^ = note: expected signature `fn(&mut X)` @@ -19,12 +21,16 @@ LL | fn f(_x: &mut crate::bar::X) {} error[E0053]: method `g` has an incompatible type for trait --> $DIR/mismatch-trait-mut.rs:34:22 | +LL | impl crate::A for X { +... LL | fn g<'a>(_x: &'a crate::bar::X) -> &'a () { &() } | ^^^^^^^^^^^^^^^^^ types differ in mutability | note: type in trait --> $DIR/mismatch-trait-mut.rs:17:18 | +LL | pub trait A { +... LL | fn g<'a>(_x: &'a mut bar::X) -> &'a () { &() } | ^^^^^^^^^^^^^^ = note: expected signature `fn(&'a mut X) -> &'a ()` @@ -37,12 +43,16 @@ LL | fn g<'a>(_x: &'a mut crate::bar::X) -> &'a () { &() } error[E0053]: method `f2` has an incompatible type for trait --> $DIR/mismatch-trait-mut.rs:38:19 | +LL | impl crate::A for X { +... LL | fn f2(_x: &mut crate::bar::X) {} | ^^^^^^^^^^^^^^^^^^ types differ in mutability | note: type in trait --> $DIR/mismatch-trait-mut.rs:19:15 | +LL | pub trait A { +... LL | fn f2(_x: &bar::X) {} | ^^^^^^^ = note: expected signature `fn(&X)` @@ -56,12 +66,16 @@ LL + fn f2(_x: &crate::bar::X) {} error[E0053]: method `g2` has an incompatible type for trait --> $DIR/mismatch-trait-mut.rs:42:23 | +LL | impl crate::A for X { +... LL | fn g2<'a>(_x: &'a mut crate::bar::X) -> &'a () { &() } | ^^^^^^^^^^^^^^^^^^^^^ types differ in mutability | note: type in trait --> $DIR/mismatch-trait-mut.rs:21:19 | +LL | pub trait A { +... LL | fn g2<'a>(_x: &'a bar::X) -> &'a () { &() } | ^^^^^^^^^^ = note: expected signature `fn(&'a X) -> &'a ()` diff --git a/tests/ui/parser/unicode-string-literal-syntax-error-64792.stderr b/tests/ui/parser/unicode-string-literal-syntax-error-64792.stderr index bdb2e412f0211..3ccca2e8a46e1 100644 --- a/tests/ui/parser/unicode-string-literal-syntax-error-64792.stderr +++ b/tests/ui/parser/unicode-string-literal-syntax-error-64792.stderr @@ -5,9 +5,14 @@ LL | struct X {} | ----------- `X` defined here LL | LL | const Y: X = X("ö"); - | ^^^^^^ help: use struct literal syntax instead: `X {}` + | ^^^^^^ | = note: a struct named `X` exists in another namespace +help: use struct literal syntax instead + | +LL - const Y: X = X("ö"); +LL + const Y: X = X {}; + | error: aborting due to 1 previous error diff --git a/tests/ui/pattern/issue-106862.stderr b/tests/ui/pattern/issue-106862.stderr index fc613f3d39156..d075f6252c915 100644 --- a/tests/ui/pattern/issue-106862.stderr +++ b/tests/ui/pattern/issue-106862.stderr @@ -5,9 +5,14 @@ LL | FooB { x: i32, y: i32 } | ----------------------- `FooB` defined here ... LL | FooB(a, b) => println!("{} {}", a, b), - | ^^^^^^^^^^ help: use struct pattern syntax instead: `FooB { x: a, y: b }` + | ^^^^^^^^^^ | = note: a variant named `FooB` exists in another namespace +help: use struct pattern syntax instead + | +LL - FooB(a, b) => println!("{} {}", a, b), +LL + FooB { x: a, y: b } => println!("{} {}", a, b), + | error[E0532]: cannot find tuple struct or tuple variant `FooB` in this scope --> $DIR/issue-106862.rs:22:9 @@ -16,9 +21,14 @@ LL | FooB { x: i32, y: i32 } | ----------------------- `FooB` defined here ... LL | FooB(x, y) => println!("{} {}", x, y), - | ^^^^^^^^^^ help: use struct pattern syntax instead: `FooB { x, y }` + | ^^^^^^^^^^ | = note: a variant named `FooB` exists in another namespace +help: use struct pattern syntax instead + | +LL - FooB(x, y) => println!("{} {}", x, y), +LL + FooB { x, y } => println!("{} {}", x, y), + | error[E0532]: cannot find tuple struct or tuple variant `FooA` in this scope --> $DIR/issue-106862.rs:28:9 @@ -27,9 +37,14 @@ LL | FooA { opt_x: Option, y: i32 }, | ----------------------------------- `FooA` defined here ... LL | FooA(Some(x), y) => println!("{} {}", x, y), - | ^^^^^^^^^^^^^^^^ help: use struct pattern syntax instead: `FooA { opt_x: Some(x), y }` + | ^^^^^^^^^^^^^^^^ | = note: a variant named `FooA` exists in another namespace +help: use struct pattern syntax instead + | +LL - FooA(Some(x), y) => println!("{} {}", x, y), +LL + FooA { opt_x: Some(x), y } => println!("{} {}", x, y), + | error[E0532]: cannot find tuple struct or tuple variant `FooB` in this scope --> $DIR/issue-106862.rs:34:9 @@ -38,9 +53,14 @@ LL | FooB { x: i32, y: i32 } | ----------------------- `FooB` defined here ... LL | FooB(a, _, _) => println!("{}", a), - | ^^^^^^^^^^^^^ help: use struct pattern syntax instead: `FooB { x: a, y: _ }` + | ^^^^^^^^^^^^^ | = note: a variant named `FooB` exists in another namespace +help: use struct pattern syntax instead + | +LL - FooB(a, _, _) => println!("{}", a), +LL + FooB { x: a, y: _ } => println!("{}", a), + | error[E0532]: cannot find tuple struct or tuple variant `FooB` in this scope --> $DIR/issue-106862.rs:40:9 @@ -49,9 +69,14 @@ LL | FooB { x: i32, y: i32 } | ----------------------- `FooB` defined here ... LL | FooB() => (), - | ^^^^^^ help: use struct pattern syntax instead: `FooB { x, y }` + | ^^^^^^ | = note: a variant named `FooB` exists in another namespace +help: use struct pattern syntax instead + | +LL - FooB() => (), +LL + FooB { x, y } => (), + | error: aborting due to 5 previous errors diff --git a/tests/ui/pattern/no-match-tuple-variant-self-ctor.struct_.stderr b/tests/ui/pattern/no-match-tuple-variant-self-ctor.struct_.stderr index 0627e2b202f63..6a7560c3d5a75 100644 --- a/tests/ui/pattern/no-match-tuple-variant-self-ctor.struct_.stderr +++ b/tests/ui/pattern/no-match-tuple-variant-self-ctor.struct_.stderr @@ -5,9 +5,13 @@ LL | struct S {} | ----------- `S` defined here ... LL | let Self = S; - | ^ help: use struct literal syntax instead: `S {}` + | ^ | = note: a struct named `S` exists in another namespace +help: use struct literal syntax instead + | +LL | let Self = S {}; + | ++ error[E0533]: expected unit struct, found self constructor `Self` --> $DIR/no-match-tuple-variant-self-ctor.rs:30:17 diff --git a/tests/ui/pattern/struct-variant-as-tuple-variant.stderr b/tests/ui/pattern/struct-variant-as-tuple-variant.stderr index 821ca297802a3..88d3641d0e81e 100644 --- a/tests/ui/pattern/struct-variant-as-tuple-variant.stderr +++ b/tests/ui/pattern/struct-variant-as-tuple-variant.stderr @@ -5,9 +5,14 @@ LL | FooB { x: i32, y: i32 } | ----------------------- `FooB` defined here ... LL | FooB(a, b) => println!("{} {}", a, b), - | ^^^^^^^^^^ help: use struct pattern syntax instead: `FooB { x: a, y: b }` + | ^^^^^^^^^^ | = note: a variant named `FooB` exists in another namespace +help: use struct pattern syntax instead + | +LL - FooB(a, b) => println!("{} {}", a, b), +LL + FooB { x: a, y: b } => println!("{} {}", a, b), + | error: aborting due to 1 previous error diff --git a/tests/ui/pin-ergonomics/pinned-drop-check.stderr b/tests/ui/pin-ergonomics/pinned-drop-check.stderr index 6087d45dd2900..892413655a229 100644 --- a/tests/ui/pin-ergonomics/pinned-drop-check.stderr +++ b/tests/ui/pin-ergonomics/pinned-drop-check.stderr @@ -113,6 +113,7 @@ LL - #[pin_v2] error[E0053]: method `drop` has an incompatible type for trait --> $DIR/pinned-drop-check.rs:83:17 | +LL | impl Drop for Foo { LL | fn drop(&pin const self) {} | ^^^^^^^^^^^^^^^ expected `&mut drop_pin_const_wrong_type::Foo`, found `Pin<&drop_pin_const_wrong_type::Foo>` | @@ -127,6 +128,7 @@ LL + fn drop(&mut self) {} error[E0053]: method `drop` has an incompatible type for trait --> $DIR/pinned-drop-check.rs:87:17 | +LL | impl Drop for Bar { LL | fn drop(&pin const self) {} | ^^^^^^^^^^^^^^^ expected `&mut drop_pin_const_wrong_type::Bar`, found `Pin<&drop_pin_const_wrong_type::Bar>` | @@ -163,6 +165,7 @@ LL - #[pin_v2] error[E0053]: method `drop` has an incompatible type for trait --> $DIR/pinned-drop-check.rs:99:21 | +LL | impl Drop for Foo { LL | fn drop<'a>(&'a pin mut self) {} | ^^^^^^^^^^^^^^^^ expected `&mut drop_with_lifetime_wrong_type::Foo`, found `Pin<&mut Foo>` | @@ -177,6 +180,7 @@ LL + fn drop<'a>(&mut self) {} error[E0053]: method `drop` has an incompatible type for trait --> $DIR/pinned-drop-check.rs:104:21 | +LL | impl Drop for Bar { LL | fn drop<'a>(&'a pin mut self) {} | ^^^^^^^^^^^^^^^^ expected `&mut drop_with_lifetime_wrong_type::Bar`, found `Pin<&mut Bar>` | @@ -213,6 +217,7 @@ LL - #[pin_v2] error[E0053]: method `drop` has an incompatible type for trait --> $DIR/pinned-drop-check.rs:118:23 | +LL | impl Drop for Foo { LL | fn drop(self: Pin<&mut Self>) {} | ^^^^^^^^^^^^^^ expected `&mut drop_explicit_pin_wrong_type::Foo`, found `Pin<&mut Foo>` | @@ -227,6 +232,7 @@ LL + fn drop(&mut self) {} error[E0053]: method `drop` has an incompatible type for trait --> $DIR/pinned-drop-check.rs:123:23 | +LL | impl Drop for Bar { LL | fn drop(self: Pin<&mut Self>) {} | ^^^^^^^^^^^^^^ expected `&mut drop_explicit_pin_wrong_type::Bar`, found `Pin<&mut Bar>` | @@ -241,6 +247,7 @@ LL + fn drop(&mut self) {} error[E0053]: method `pin_drop` has an incompatible type for trait --> $DIR/pinned-drop-check.rs:135:21 | +LL | impl Drop for Foo { LL | fn pin_drop(&mut self) {} | ^^^^^^^^^ expected `Pin<&mut pin_drop_wrong_type::Foo>`, found `&mut pin_drop_wrong_type::Foo` | @@ -255,6 +262,7 @@ LL + fn pin_drop(self: Pin<&mut pin_drop_wrong_type::Foo>) {} error[E0053]: method `pin_drop` has an incompatible type for trait --> $DIR/pinned-drop-check.rs:139:21 | +LL | impl Drop for Bar { LL | fn pin_drop(&mut self) {} | ^^^^^^^^^ expected `Pin<&mut pin_drop_wrong_type::Bar>`, found `&mut pin_drop_wrong_type::Bar` | diff --git a/tests/ui/privacy/suggest-box-new.stderr b/tests/ui/privacy/suggest-box-new.stderr index 32525a41f946c..53578389db95d 100644 --- a/tests/ui/privacy/suggest-box-new.stderr +++ b/tests/ui/privacy/suggest-box-new.stderr @@ -68,7 +68,7 @@ LL - x: (), LL - })), LL + wtf: Some(Box::new_in(_, _)), | - = and 15 other candidates + = and 16 other candidates help: consider using the `Default` trait | LL - wtf: Some(Box(U { @@ -125,7 +125,7 @@ LL + let _ = Box::new_zeroed(); LL - let _ = Box {}; LL + let _ = Box::new_in(_, _); | - = and 16 other candidates + = and 17 other candidates help: consider using the `Default` trait | LL - let _ = Box {}; @@ -147,12 +147,12 @@ LL - let _ = Box:: {}; LL + let _ = Box::::new_in(_, _); | LL - let _ = Box:: {}; -LL + let _ = Box::::into_inner(_); +LL + let _ = Box::::cast_unchecked(_); | LL - let _ = Box:: {}; -LL + let _ = Box::::map(_, _); +LL + let _ = Box::::into_inner(_); | - = and 7 other candidates + = and 8 other candidates help: consider using the `Default` trait | LL - let _ = Box:: {}; diff --git a/tests/ui/resolve/issue-6702.stderr b/tests/ui/resolve/issue-6702.stderr index dd1f2c5d7f819..865c07812e56c 100644 --- a/tests/ui/resolve/issue-6702.stderr +++ b/tests/ui/resolve/issue-6702.stderr @@ -7,9 +7,14 @@ LL | | } | |_- `Monster` defined here ... LL | let _m = Monster(); - | ^^^^^^^^^ help: use struct literal syntax instead: `Monster { damage: val }` + | ^^^^^^^^^ | = note: a struct named `Monster` exists in another namespace +help: use struct literal syntax instead + | +LL - let _m = Monster(); +LL + let _m = Monster { damage: val }; + | error: aborting due to 1 previous error diff --git a/tests/ui/resolve/privacy-struct-ctor.stderr b/tests/ui/resolve/privacy-struct-ctor.stderr index e948c6fdae9eb..6f8843a24b5de 100644 --- a/tests/ui/resolve/privacy-struct-ctor.stderr +++ b/tests/ui/resolve/privacy-struct-ctor.stderr @@ -33,9 +33,13 @@ LL | | } | |_____- `S2` defined here ... LL | S2; - | ^^ help: use struct literal syntax instead: `S2 { s: val }` + | ^^ | = note: a struct named `S2` exists in another namespace +help: use struct literal syntax instead + | +LL | S2 { s: val }; + | ++++++++++ error[E0423]: cannot find value `S` in crate `xcrate` --> $DIR/privacy-struct-ctor.rs:44:13 diff --git a/tests/ui/resolve/tuple-struct-with-private-fields-doesnt-suggest-local-typo.fixed b/tests/ui/resolve/tuple-struct-with-private-fields-doesnt-suggest-local-typo.fixed new file mode 100644 index 0000000000000..6cbc5833ee2ac --- /dev/null +++ b/tests/ui/resolve/tuple-struct-with-private-fields-doesnt-suggest-local-typo.fixed @@ -0,0 +1,18 @@ +//@ run-rustfix +// Issue #66067. +#![allow(unused)] +mod outer { + mod a { + // This struct can't be constructed from `crate::` because of the private fields. + pub struct Triplet(pub usize, pub usize, pub f64); + } + pub use self::a::Triplet; +} + +use outer::Triplet; + +fn main() { + let mut triplets = Vec::new(); + // Ensure that we do not suggest changing `Triplet` to `triplets`: + triplets.push(Triplet(0, 0, 1.0)); //~ ERROR: E0423 +} diff --git a/tests/ui/resolve/tuple-struct-with-private-fields-doesnt-suggest-local-typo.rs b/tests/ui/resolve/tuple-struct-with-private-fields-doesnt-suggest-local-typo.rs new file mode 100644 index 0000000000000..727220d7ae5b5 --- /dev/null +++ b/tests/ui/resolve/tuple-struct-with-private-fields-doesnt-suggest-local-typo.rs @@ -0,0 +1,18 @@ +//@ run-rustfix +// Issue #66067. +#![allow(unused)] +mod outer { + mod a { + // This struct can't be constructed from `crate::` because of the private fields. + pub struct Triplet(usize, usize, f64); + } + pub use self::a::Triplet; +} + +use outer::Triplet; + +fn main() { + let mut triplets = Vec::new(); + // Ensure that we do not suggest changing `Triplet` to `triplets`: + triplets.push(Triplet(0, 0, 1.0)); //~ ERROR: E0423 +} diff --git a/tests/ui/resolve/tuple-struct-with-private-fields-doesnt-suggest-local-typo.stderr b/tests/ui/resolve/tuple-struct-with-private-fields-doesnt-suggest-local-typo.stderr new file mode 100644 index 0000000000000..ccbad1a2bdf5c --- /dev/null +++ b/tests/ui/resolve/tuple-struct-with-private-fields-doesnt-suggest-local-typo.stderr @@ -0,0 +1,23 @@ +error[E0423]: cannot initialize a tuple struct which contains private fields + --> $DIR/tuple-struct-with-private-fields-doesnt-suggest-local-typo.rs:17:19 + | +LL | triplets.push(Triplet(0, 0, 1.0)); + | ^^^^^^^ + | + = note: a struct named `Triplet` exists in another namespace +note: constructor is not visible here due to private fields + --> $DIR/tuple-struct-with-private-fields-doesnt-suggest-local-typo.rs:7:28 + | +LL | pub struct Triplet(usize, usize, f64); + | ^^^^^ ^^^^^ ^^^ private field + | | | + | | private field + | private field +help: consider making the fields publicly accessible + | +LL | pub struct Triplet(pub usize, pub usize, pub f64); + | +++ +++ +++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0423`. diff --git a/tests/ui/rfcs/rfc-2396-target_feature-11/trait-impl.stderr b/tests/ui/rfcs/rfc-2396-target_feature-11/trait-impl.stderr index 39b0e5ea18f7d..86634e54aa3e1 100644 --- a/tests/ui/rfcs/rfc-2396-target_feature-11/trait-impl.stderr +++ b/tests/ui/rfcs/rfc-2396-target_feature-11/trait-impl.stderr @@ -10,12 +10,15 @@ LL | fn foo(&self) {} error[E0053]: method `foo` has an incompatible type for trait --> $DIR/trait-impl.rs:13:5 | +LL | impl Foo for Bar { +... LL | fn foo(&self) {} | ^^^^^^^^^^^^^ expected safe fn, found unsafe fn | note: type in trait --> $DIR/trait-impl.rs:4:5 | +LL | trait Foo { LL | fn foo(&self); | ^^^^^^^^^^^^^^ = note: expected signature `fn(&Bar)` diff --git a/tests/ui/splat/splat-invalid-trait-impl.stderr b/tests/ui/splat/splat-invalid-trait-impl.stderr index df414a5e63062..3aafd5e0d5575 100644 --- a/tests/ui/splat/splat-invalid-trait-impl.stderr +++ b/tests/ui/splat/splat-invalid-trait-impl.stderr @@ -1,12 +1,14 @@ error[E0053]: method `method` has an incompatible type for trait --> $DIR/splat-invalid-trait-impl.rs:14:33 | +LL | impl FooTrait for Foo { LL | fn method(#[rustc_splat] _: (u32, f32)) {} | ^^^^^^^^^^ expected `i8`, found `f32` | note: type in trait --> $DIR/splat-invalid-trait-impl.rs:6:33 | +LL | trait FooTrait { LL | fn method(#[rustc_splat] _: (u32, i8)); | ^^^^^^^^^ = note: expected signature `fn(#[rustc_splat] (_, i8))` @@ -20,12 +22,14 @@ LL + fn method(#[rustc_splat] _: (u32, i8)) {} error[E0053]: method `method` has an incompatible type for trait --> $DIR/splat-invalid-trait-impl.rs:19:33 | +LL | impl FooTrait for Foo1 { LL | fn method(#[rustc_splat] _: (f32, i8)) {} | ^^^^^^^^^ expected `u32`, found `f32` | note: type in trait --> $DIR/splat-invalid-trait-impl.rs:6:33 | +LL | trait FooTrait { LL | fn method(#[rustc_splat] _: (u32, i8)); | ^^^^^^^^^ = note: expected signature `fn(#[rustc_splat] (u32, _))` @@ -39,12 +43,14 @@ LL + fn method(#[rustc_splat] _: (u32, i8)) {} error[E0053]: method `method` has an incompatible type for trait --> $DIR/splat-invalid-trait-impl.rs:24:33 | +LL | impl FooTrait for Foo2 { LL | fn method(#[rustc_splat] _: (f32, f64)) {} | ^^^^^^^^^^ expected `u32`, found `f32` | note: type in trait --> $DIR/splat-invalid-trait-impl.rs:6:33 | +LL | trait FooTrait { LL | fn method(#[rustc_splat] _: (u32, i8)); | ^^^^^^^^^ = note: expected signature `fn(#[rustc_splat] (u32, i8))` diff --git a/tests/ui/splat/splat-invalid.stderr b/tests/ui/splat/splat-invalid.stderr index 8681084a3c594..5ef430046ab10 100644 --- a/tests/ui/splat/splat-invalid.stderr +++ b/tests/ui/splat/splat-invalid.stderr @@ -182,12 +182,14 @@ LL | #[rustc_splat] error[E0053]: method `has_splat` has an incompatible type for trait --> $DIR/splat-invalid.rs:59:5 | +LL | impl FooTrait for Foo { LL | fn has_splat(_: ()) {} | ^^^^^^^^^^^^^^^^^^^ expected fn with arg 0 splatted, found fn with no splatted arg | note: type in trait --> $DIR/splat-invalid.rs:51:5 | +LL | trait FooTrait { LL | fn has_splat(#[rustc_splat] _: ()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: expected signature `fn(#[rustc_splat] ())` @@ -196,12 +198,16 @@ LL | fn has_splat(#[rustc_splat] _: ()); error[E0053]: method `no_splat` has an incompatible type for trait --> $DIR/splat-invalid.rs:61:5 | +LL | impl FooTrait for Foo { +... LL | fn no_splat(#[rustc_splat] _: (u32, f64)) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected fn with no splatted arg, found fn with arg 0 splatted | note: type in trait --> $DIR/splat-invalid.rs:53:5 | +LL | trait FooTrait { +... LL | fn no_splat(_: (u32, f64)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: expected signature `fn((_, _))` diff --git a/tests/ui/splat/splat-non-tuple.stderr b/tests/ui/splat/splat-non-tuple.stderr index b92c257b9b021..21129c92ce6ee 100644 --- a/tests/ui/splat/splat-non-tuple.stderr +++ b/tests/ui/splat/splat-non-tuple.stderr @@ -1,12 +1,14 @@ error[E0053]: method `tuple_1` has an incompatible type for trait --> $DIR/splat-non-tuple.rs:39:5 | +LL | impl FooTrait for Foo { LL | fn tuple_1(_: (u32,)) {} | ^^^^^^^^^^^^^^^^^^^^^ expected fn with arg 0 splatted, found fn with no splatted arg | note: type in trait --> $DIR/splat-non-tuple.rs:17:5 | +LL | trait FooTrait { LL | fn tuple_1(#[rustc_splat] _: (u32,)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: expected signature `fn(#[rustc_splat] (_,))` diff --git a/tests/ui/structs/struct-construct-with-call-issue-138931.stderr b/tests/ui/structs/struct-construct-with-call-issue-138931.stderr index 9248eebbae3ae..83266161c5206 100644 --- a/tests/ui/structs/struct-construct-with-call-issue-138931.stderr +++ b/tests/ui/structs/struct-construct-with-call-issue-138931.stderr @@ -53,9 +53,14 @@ LL | | } | |_- `PersonWithAge` defined here ... LL | let person = PersonWithAge("Name3".to_owned()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use struct literal syntax instead: `PersonWithAge { name: val, age: val, height: val }` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: a struct named `PersonWithAge` exists in another namespace +help: use struct literal syntax instead + | +LL - let person = PersonWithAge("Name3".to_owned()); +LL + let person = PersonWithAge { name: val, age: val, height: val }; + | error: aborting due to 3 previous errors diff --git a/tests/ui/suggestions/issue-61226.stderr b/tests/ui/suggestions/issue-61226.stderr index cf21435cc3cbc..ba8ca5c315018 100644 --- a/tests/ui/suggestions/issue-61226.stderr +++ b/tests/ui/suggestions/issue-61226.stderr @@ -5,9 +5,13 @@ LL | struct X {} | ----------- `X` defined here LL | fn main() { LL | let _ = vec![X]; //… - | ^ help: use struct literal syntax instead: `X {}` + | ^ | = note: a struct named `X` exists in another namespace +help: use struct literal syntax instead + | +LL | let _ = vec![X {}]; //… + | ++ error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/multi-suggestion.ascii.stderr b/tests/ui/suggestions/multi-suggestion.ascii.stderr index ecc4c5aa7c23b..76fc55177070d 100644 --- a/tests/ui/suggestions/multi-suggestion.ascii.stderr +++ b/tests/ui/suggestions/multi-suggestion.ascii.stderr @@ -68,7 +68,7 @@ LL - x: (), LL - })), LL + wtf: Some(Box::new_in(_, _)), | - = and 15 other candidates + = and 16 other candidates help: consider using the `Default` trait | LL - wtf: Some(Box(U { @@ -125,7 +125,7 @@ LL + let _ = Box::new_zeroed(); LL - let _ = Box {}; LL + let _ = Box::new_in(_, _); | - = and 16 other candidates + = and 17 other candidates help: consider using the `Default` trait | LL - let _ = Box {}; diff --git a/tests/ui/suggestions/multi-suggestion.unicode.stderr b/tests/ui/suggestions/multi-suggestion.unicode.stderr index 1f28a4d8fa289..6bbd95c44a529 100644 --- a/tests/ui/suggestions/multi-suggestion.unicode.stderr +++ b/tests/ui/suggestions/multi-suggestion.unicode.stderr @@ -68,7 +68,7 @@ LL - x: (), LL - })), LL + wtf: Some(Box::new_in(_, _)), │ - ╰ and 15 other candidates + ╰ and 16 other candidates help: consider using the `Default` trait ╭╴ LL - wtf: Some(Box(U { @@ -125,7 +125,7 @@ LL + let _ = Box::new_zeroed(); LL - let _ = Box {}; LL + let _ = Box::new_in(_, _); │ - ╰ and 16 other candidates + ╰ and 17 other candidates help: consider using the `Default` trait ╭╴ LL - let _ = Box {}; diff --git a/tests/ui/target-feature/invalid-attribute.stderr b/tests/ui/target-feature/invalid-attribute.stderr index a5c6e21ee73e0..3feef4b2fa42b 100644 --- a/tests/ui/target-feature/invalid-attribute.stderr +++ b/tests/ui/target-feature/invalid-attribute.stderr @@ -219,12 +219,15 @@ LL | fn foo() {} error[E0053]: method `foo` has an incompatible type for trait --> $DIR/invalid-attribute.rs:92:5 | +LL | impl Quux for Foo { +... LL | fn foo() {} | ^^^^^^^^ expected safe fn, found unsafe fn | note: type in trait --> $DIR/invalid-attribute.rs:84:5 | +LL | trait Quux { LL | fn foo(); | ^^^^^^^^^ = note: expected signature `fn()` diff --git a/tests/ui/traits/const-traits/eval-bad-signature.stderr b/tests/ui/traits/const-traits/eval-bad-signature.stderr index db5f434ee0e98..1230515c79f5c 100644 --- a/tests/ui/traits/const-traits/eval-bad-signature.stderr +++ b/tests/ui/traits/const-traits/eval-bad-signature.stderr @@ -1,12 +1,14 @@ error[E0053]: method `value` has an incompatible type for trait --> $DIR/eval-bad-signature.rs:16:19 | +LL | const impl Value for FortyTwo { LL | fn value() -> i64 { | ^^^ expected `u32`, found `i64` | note: type in trait --> $DIR/eval-bad-signature.rs:6:19 | +LL | const trait Value { LL | fn value() -> u32; | ^^^ = note: expected signature `fn() -> u32` diff --git a/tests/ui/traits/error-reporting/incompatible-method-multiline.stderr b/tests/ui/traits/error-reporting/incompatible-method-multiline.stderr index 4f797dedfa846..ee9a29aa84fd6 100644 --- a/tests/ui/traits/error-reporting/incompatible-method-multiline.stderr +++ b/tests/ui/traits/error-reporting/incompatible-method-multiline.stderr @@ -1,6 +1,8 @@ error[E0053]: method `next` has an incompatible type for trait --> $DIR/incompatible-method-multiline.rs:8:27 | +LL | impl Iterator for S { +LL | type Item = i32; LL | fn next(&mut self) -> Result { Ok(7) } | ^^^^^^^^^^^^^^^^ expected `Option`, found `Result` | diff --git a/tests/ui/traits/impl-method-mismatch.stderr b/tests/ui/traits/impl-method-mismatch.stderr index ca8b35e06c78f..9675edd3d84cb 100644 --- a/tests/ui/traits/impl-method-mismatch.stderr +++ b/tests/ui/traits/impl-method-mismatch.stderr @@ -1,12 +1,15 @@ error[E0053]: method `jumbo` has an incompatible type for trait --> $DIR/impl-method-mismatch.rs:9:5 | +LL | impl Mumbo for usize { +LL | // Cannot have a larger effect than the trait: LL | unsafe fn jumbo(&self, x: &usize) { *self + *x; } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected safe fn, found unsafe fn | note: type in trait --> $DIR/impl-method-mismatch.rs:4:5 | +LL | trait Mumbo { LL | fn jumbo(&self, x: &usize) -> usize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: expected signature `fn(&_, &_) -> usize` diff --git a/tests/ui/traits/issue-35869.stderr b/tests/ui/traits/issue-35869.stderr index 98cbd4650007b..17adad92611cc 100644 --- a/tests/ui/traits/issue-35869.stderr +++ b/tests/ui/traits/issue-35869.stderr @@ -1,12 +1,14 @@ error[E0053]: method `foo` has an incompatible type for trait --> $DIR/issue-35869.rs:11:15 | +LL | impl Foo for Bar { LL | fn foo(_: fn(u16) -> ()) {} | ^^^^^^^^^^^^^ expected `u8`, found `u16` | note: type in trait --> $DIR/issue-35869.rs:2:15 | +LL | trait Foo { LL | fn foo(_: fn(u8) -> ()); | ^^^^^^^^^^^^ = note: expected signature `fn(fn(u8))` @@ -20,12 +22,16 @@ LL + fn foo(_: fn(u8)) {} error[E0053]: method `bar` has an incompatible type for trait --> $DIR/issue-35869.rs:13:15 | +LL | impl Foo for Bar { +... LL | fn bar(_: Option) {} | ^^^^^^^^^^^ expected `u8`, found `u16` | note: type in trait --> $DIR/issue-35869.rs:3:15 | +LL | trait Foo { +LL | fn foo(_: fn(u8) -> ()); LL | fn bar(_: Option); | ^^^^^^^^^^ = note: expected signature `fn(Option)` @@ -39,12 +45,16 @@ LL + fn bar(_: std::option::Option) {} error[E0053]: method `baz` has an incompatible type for trait --> $DIR/issue-35869.rs:15:15 | +LL | impl Foo for Bar { +... LL | fn baz(_: (u16, u16)) {} | ^^^^^^^^^^ expected `u8`, found `u16` | note: type in trait --> $DIR/issue-35869.rs:4:15 | +LL | trait Foo { +... LL | fn baz(_: (u8, u16)); | ^^^^^^^^^ = note: expected signature `fn((u8, _))` @@ -58,12 +68,16 @@ LL + fn baz(_: (u8, u16)) {} error[E0053]: method `qux` has an incompatible type for trait --> $DIR/issue-35869.rs:17:17 | +LL | impl Foo for Bar { +... LL | fn qux() -> u16 { 5u16 } | ^^^ expected `u8`, found `u16` | note: type in trait --> $DIR/issue-35869.rs:5:17 | +LL | trait Foo { +... LL | fn qux() -> u8; | ^^ = note: expected signature `fn() -> u8` diff --git a/tests/ui/traits/wrong-mul-method-signature.stderr b/tests/ui/traits/wrong-mul-method-signature.stderr index bdfc4320631b0..ea07a07e09de9 100644 --- a/tests/ui/traits/wrong-mul-method-signature.stderr +++ b/tests/ui/traits/wrong-mul-method-signature.stderr @@ -1,6 +1,8 @@ error[E0053]: method `mul` has an incompatible type for trait --> $DIR/wrong-mul-method-signature.rs:16:21 | +LL | impl Mul for Vec1 { +... LL | fn mul(self, s: &f64) -> Vec1 { | ^^^^ expected `f64`, found `&f64` | @@ -15,6 +17,8 @@ LL + fn mul(self, s: f64) -> Vec1 { error[E0053]: method `mul` has an incompatible type for trait --> $DIR/wrong-mul-method-signature.rs:33:21 | +LL | impl Mul for Vec2 { +... LL | fn mul(self, s: f64) -> Vec2 { | ^^^ expected `Vec2`, found `f64` | @@ -29,6 +33,8 @@ LL + fn mul(self, s: crate::Vec2) -> Vec2 { error[E0053]: method `mul` has an incompatible type for trait --> $DIR/wrong-mul-method-signature.rs:52:29 | +LL | impl Mul for Vec3 { +... LL | fn mul(self, s: f64) -> f64 { | ^^^ expected `i32`, found `f64` | diff --git a/tests/ui/type-alias-impl-trait/unnameable_type.stderr b/tests/ui/type-alias-impl-trait/unnameable_type.stderr index 48fe7ba275fce..ca55fc350fb3d 100644 --- a/tests/ui/type-alias-impl-trait/unnameable_type.stderr +++ b/tests/ui/type-alias-impl-trait/unnameable_type.stderr @@ -3,13 +3,15 @@ error[E0053]: method `dont_define_this` has an incompatible type for trait | LL | type MyPrivate = impl Sized; | ---------- the found opaque type -... +LL | impl Trait for u32 { +LL | #[define_opaque(MyPrivate)] LL | fn dont_define_this(private: MyPrivate) { | ^^^^^^^^^ expected `Private`, found opaque type | note: type in trait --> $DIR/unnameable_type.rs:10:39 | +LL | pub trait Trait { LL | fn dont_define_this(_private: Private) {} | ^^^^^^^ = note: expected signature `fn(Private)` diff --git a/tests/ui/typeck/mismatched-map-under-self.stderr b/tests/ui/typeck/mismatched-map-under-self.stderr index 541de25749e38..8e5bae258f976 100644 --- a/tests/ui/typeck/mismatched-map-under-self.stderr +++ b/tests/ui/typeck/mismatched-map-under-self.stderr @@ -1,12 +1,16 @@ error[E0053]: method `values` has an incompatible type for trait --> $DIR/mismatched-map-under-self.rs:10:15 | +LL | impl Insertable for Option { +... LL | fn values(self) -> Self::Values { | ^^^^ expected `&Option`, found `Option` | note: type in trait --> $DIR/mismatched-map-under-self.rs:4:15 | +LL | pub trait Insertable { +... LL | fn values(&self) -> Self::Values; | ^^^^^ = note: expected signature `fn(&Option<_>)` diff --git a/tests/ui/ufcs/ufcs-explicit-self-bad.stderr b/tests/ui/ufcs/ufcs-explicit-self-bad.stderr index 7b5f7cd9f7033..e0d6d88fca075 100644 --- a/tests/ui/ufcs/ufcs-explicit-self-bad.stderr +++ b/tests/ui/ufcs/ufcs-explicit-self-bad.stderr @@ -1,12 +1,16 @@ error[E0053]: method `dummy2` has an incompatible type for trait --> $DIR/ufcs-explicit-self-bad.rs:37:21 | +LL | impl<'a, T> SomeTrait for &'a Bar { +LL | fn dummy1(self: &&'a Bar) { } LL | fn dummy2(self: &Bar) {} | ^^^^^^^ expected `&'a Bar`, found `Bar` | note: type in trait --> $DIR/ufcs-explicit-self-bad.rs:31:15 | +LL | trait SomeTrait { +LL | fn dummy1(&self); LL | fn dummy2(&self); | ^^^^^ = note: expected signature `fn(&&'a Bar<_>)` diff --git a/tests/ui/unsafe/unsafe-trait-impl.stderr b/tests/ui/unsafe/unsafe-trait-impl.stderr index 8febbb736634d..250d1f1dcbcf7 100644 --- a/tests/ui/unsafe/unsafe-trait-impl.stderr +++ b/tests/ui/unsafe/unsafe-trait-impl.stderr @@ -1,12 +1,14 @@ error[E0053]: method `len` has an incompatible type for trait --> $DIR/unsafe-trait-impl.rs:10:5 | +LL | impl Foo for u32 { LL | fn len(&self) -> u32 { *self } | ^^^^^^^^^^^^^^^^^^^^ expected unsafe fn, found safe fn | note: type in trait --> $DIR/unsafe-trait-impl.rs:6:5 | +LL | trait Foo { LL | unsafe fn len(&self) -> u32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: expected signature `unsafe fn(&_) -> _`