1
Fork 0

Rollup merge of #116908 - estebank:issue-78206, r=compiler-errors

Tweak wording of type errors involving type params

Fix #78206.
This commit is contained in:
León Orell Valerian Liehr 2023-10-19 04:34:47 +02:00 committed by GitHub
commit 64ed233fc1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 72 additions and 55 deletions

View file

@ -85,8 +85,13 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
{ {
let p_def_id = tcx.generics_of(body_owner_def_id).type_param(p, tcx).def_id; let p_def_id = tcx.generics_of(body_owner_def_id).type_param(p, tcx).def_id;
let p_span = tcx.def_span(p_def_id); let p_span = tcx.def_span(p_def_id);
let expected = match (values.expected.kind(), values.found.kind()) {
(ty::Param(_), _) => "expected ",
(_, ty::Param(_)) => "found ",
_ => "",
};
if !sp.contains(p_span) { if !sp.contains(p_span) {
diag.span_label(p_span, "this type parameter"); diag.span_label(p_span, format!("{expected}this type parameter"));
} }
let hir = tcx.hir(); let hir = tcx.hir();
let mut note = true; let mut note = true;
@ -168,8 +173,13 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
| (ty::Dynamic(..) | ty::Alias(ty::Opaque, ..), ty::Param(p)) => { | (ty::Dynamic(..) | ty::Alias(ty::Opaque, ..), ty::Param(p)) => {
let generics = tcx.generics_of(body_owner_def_id); let generics = tcx.generics_of(body_owner_def_id);
let p_span = tcx.def_span(generics.type_param(p, tcx).def_id); let p_span = tcx.def_span(generics.type_param(p, tcx).def_id);
let expected = match (values.expected.kind(), values.found.kind()) {
(ty::Param(_), _) => "expected ",
(_, ty::Param(_)) => "found ",
_ => "",
};
if !sp.contains(p_span) { if !sp.contains(p_span) {
diag.span_label(p_span, "this type parameter"); diag.span_label(p_span, format!("{expected}this type parameter"));
} }
diag.help("type parameters must be constrained to match other types"); diag.help("type parameters must be constrained to match other types");
if tcx.sess.teach(&diag.get_code().unwrap()) { if tcx.sess.teach(&diag.get_code().unwrap()) {
@ -209,7 +219,7 @@ impl<T> Trait<T> for X {
let generics = tcx.generics_of(body_owner_def_id); let generics = tcx.generics_of(body_owner_def_id);
let p_span = tcx.def_span(generics.type_param(p, tcx).def_id); let p_span = tcx.def_span(generics.type_param(p, tcx).def_id);
if !sp.contains(p_span) { if !sp.contains(p_span) {
diag.span_label(p_span, "this type parameter"); diag.span_label(p_span, "expected this type parameter");
} }
diag.help(format!( diag.help(format!(
"every closure has a distinct type and so could not always match the \ "every closure has a distinct type and so could not always match the \
@ -219,8 +229,13 @@ impl<T> Trait<T> for X {
(ty::Param(p), _) | (_, ty::Param(p)) => { (ty::Param(p), _) | (_, ty::Param(p)) => {
let generics = tcx.generics_of(body_owner_def_id); let generics = tcx.generics_of(body_owner_def_id);
let p_span = tcx.def_span(generics.type_param(p, tcx).def_id); let p_span = tcx.def_span(generics.type_param(p, tcx).def_id);
let expected = match (values.expected.kind(), values.found.kind()) {
(ty::Param(_), _) => "expected ",
(_, ty::Param(_)) => "found ",
_ => "",
};
if !sp.contains(p_span) { if !sp.contains(p_span) {
diag.span_label(p_span, "this type parameter"); diag.span_label(p_span, format!("{expected}this type parameter"));
} }
} }
(ty::Alias(ty::Projection | ty::Inherent, proj_ty), _) (ty::Alias(ty::Projection | ty::Inherent, proj_ty), _)

View file

@ -13,7 +13,7 @@ error[E0308]: mismatched types
LL | fn foo<u32>(a: u32) -> u32 { LL | fn foo<u32>(a: u32) -> u32 {
| --- --- expected `u32` because of return type | --- --- expected `u32` because of return type
| | | |
| this type parameter | expected this type parameter
LL | 42 LL | 42
| ^^ expected type parameter `u32`, found integer | ^^ expected type parameter `u32`, found integer
| |

View file

@ -17,7 +17,7 @@ LL | fn f(x: &mut dyn Iterator<Item: Iterator<Item = &'_ ()>>) -> Option<&'_ ()>
| ----------------------------- -------------- ^^^^^^^^ expected `Option<&()>`, found `Option<impl Iterator<Item = &'_ ()>>` | ----------------------------- -------------- ^^^^^^^^ expected `Option<&()>`, found `Option<impl Iterator<Item = &'_ ()>>`
| | | | | |
| | expected `Option<&()>` because of return type | | expected `Option<&()>` because of return type
| this type parameter | found this type parameter
| |
= note: expected enum `Option<&()>` = note: expected enum `Option<&()>`
found enum `Option<impl Iterator<Item = &'_ ()>>` found enum `Option<impl Iterator<Item = &'_ ()>>`

View file

@ -2,7 +2,7 @@ error[E0271]: type mismatch resolving `<Adapter<I> as Iterator>::Item == Option<
--> $DIR/associated-types-issue-20346.rs:34:36 --> $DIR/associated-types-issue-20346.rs:34:36
| |
LL | fn test_adapter<T, I: Iterator<Item=Option<T>>>(it: I) { LL | fn test_adapter<T, I: Iterator<Item=Option<T>>>(it: I) {
| - this type parameter | - found this type parameter
... ...
LL | is_iterator_of::<Option<T>, _>(&adapter); LL | is_iterator_of::<Option<T>, _>(&adapter);
| ------------------------------ ^^^^^^^^ type mismatch resolving `<Adapter<I> as Iterator>::Item == Option<T>` | ------------------------------ ^^^^^^^^ type mismatch resolving `<Adapter<I> as Iterator>::Item == Option<T>`

View file

@ -2,7 +2,9 @@ error[E0271]: type mismatch resolving `<T as Deref>::Target == T`
--> $DIR/hr-associated-type-projection-1.rs:13:33 --> $DIR/hr-associated-type-projection-1.rs:13:33
| |
LL | impl<T: Copy + std::ops::Deref> UnsafeCopy<'_, T> for T { LL | impl<T: Copy + std::ops::Deref> UnsafeCopy<'_, T> for T {
| - this type parameter ^^^^^^^^^^^^^^^^^ expected type parameter `T`, found associated type | - ^^^^^^^^^^^^^^^^^ expected type parameter `T`, found associated type
| |
| expected this type parameter
| |
= note: expected type parameter `T` = note: expected type parameter `T`
found associated type `<T as Deref>::Target` found associated type `<T as Deref>::Target`

View file

@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/issue-67945-1.rs:10:20 --> $DIR/issue-67945-1.rs:10:20
| |
LL | struct Bug<S> { LL | struct Bug<S> {
| - this type parameter | - expected this type parameter
... ...
LL | let x: S = MaybeUninit::uninit(); LL | let x: S = MaybeUninit::uninit();
| - ^^^^^^^^^^^^^^^^^^^^^ expected type parameter `S`, found `MaybeUninit<_>` | - ^^^^^^^^^^^^^^^^^^^^^ expected type parameter `S`, found `MaybeUninit<_>`

View file

@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/issue-68648-2.rs:12:17 --> $DIR/issue-68648-2.rs:12:17
| |
LL | fn bug<'a, T: Fun<F<'a> = T>>(t: T) -> T::F<'a> { LL | fn bug<'a, T: Fun<F<'a> = T>>(t: T) -> T::F<'a> {
| - this type parameter | - expected this type parameter
LL | T::identity(()) LL | T::identity(())
| ----------- ^^ expected type parameter `T`, found `()` | ----------- ^^ expected type parameter `T`, found `()`
| | | |

View file

@ -2,7 +2,7 @@ error[E0271]: type mismatch resolving `<T as Deref>::Target == T`
--> $DIR/issue-68656-unsized-values.rs:13:21 --> $DIR/issue-68656-unsized-values.rs:13:21
| |
LL | impl<T: Copy + std::ops::Deref> UnsafeCopy<T> for T { LL | impl<T: Copy + std::ops::Deref> UnsafeCopy<T> for T {
| - this type parameter | - expected this type parameter
LL | type Item<'a> = T; LL | type Item<'a> = T;
| ^ expected type parameter `T`, found associated type | ^ expected type parameter `T`, found associated type
| |

View file

@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/issue-88360.rs:15:9 --> $DIR/issue-88360.rs:15:9
| |
LL | trait SuperTrait<T> LL | trait SuperTrait<T>
| - this type parameter | - found this type parameter
... ...
LL | fn copy(&self) -> Self::Gat<'_> where T: Copy { LL | fn copy(&self) -> Self::Gat<'_> where T: Copy {
| ------------- expected `&T` because of return type | ------------- expected `&T` because of return type

View file

@ -14,7 +14,7 @@ error[E0308]: mismatched types
--> $DIR/missing-bounds.rs:11:11 --> $DIR/missing-bounds.rs:11:11
| |
LL | impl<B> Add for A<B> where B: Add { LL | impl<B> Add for A<B> where B: Add {
| - this type parameter | - expected this type parameter
... ...
LL | A(self.0 + rhs.0) LL | A(self.0 + rhs.0)
| - ^^^^^^^^^^^^^^ expected type parameter `B`, found associated type | - ^^^^^^^^^^^^^^ expected type parameter `B`, found associated type
@ -44,7 +44,7 @@ error[E0308]: mismatched types
--> $DIR/missing-bounds.rs:21:14 --> $DIR/missing-bounds.rs:21:14
| |
LL | impl<B: Add> Add for C<B> { LL | impl<B: Add> Add for C<B> {
| - this type parameter | - expected this type parameter
... ...
LL | Self(self.0 + rhs.0) LL | Self(self.0 + rhs.0)
| ---- ^^^^^^^^^^^^^^ expected type parameter `B`, found associated type | ---- ^^^^^^^^^^^^^^ expected type parameter `B`, found associated type
@ -80,7 +80,7 @@ error[E0308]: mismatched types
--> $DIR/missing-bounds.rs:42:14 --> $DIR/missing-bounds.rs:42:14
| |
LL | impl<B: Add> Add for E<B> where <B as Add>::Output = B { LL | impl<B: Add> Add for E<B> where <B as Add>::Output = B {
| - this type parameter | - expected this type parameter
... ...
LL | Self(self.0 + rhs.0) LL | Self(self.0 + rhs.0)
| ---- ^^^^^^^^^^^^^^ expected type parameter `B`, found associated type | ---- ^^^^^^^^^^^^^^ expected type parameter `B`, found associated type

View file

@ -7,7 +7,7 @@ LL | | &mut Header,
LL | | &mut [EntryMetadata], LL | | &mut [EntryMetadata],
LL | | &mut [Entry<C::EncodedKey, C::EncodedValue>] LL | | &mut [Entry<C::EncodedKey, C::EncodedValue>]
LL | | ) -> R, LL | | ) -> R,
| |__________- this type parameter | |__________- expected this type parameter
LL | ) { LL | ) {
LL | let () = y; LL | let () = y;
| ^^ - this expression has type `impl FnOnce(&mut Header, &mut [EntryMetadata], &mut [Entry<C::EncodedKey, C::EncodedValue>]) -> R` | ^^ - this expression has type `impl FnOnce(&mut Header, &mut [EntryMetadata], &mut [Entry<C::EncodedKey, C::EncodedValue>]) -> R`

View file

@ -6,7 +6,7 @@ LL | fn early<'late, T>(_: &'late ()) {}
| | | | | |
| | expected type parameter `T`, found `()` | | expected type parameter `T`, found `()`
| | help: change the parameter type to match the trait: `&T` | | help: change the parameter type to match the trait: `&T`
| this type parameter | expected this type parameter
| |
note: type in trait note: type in trait
--> $DIR/method-signature-matches.rs:52:28 --> $DIR/method-signature-matches.rs:52:28

View file

@ -2,7 +2,7 @@ error[E0053]: method `bar` has an incompatible type for trait
--> $DIR/specialization-broken.rs:15:22 --> $DIR/specialization-broken.rs:15:22
| |
LL | default impl<U> Foo for U LL | default impl<U> Foo for U
| - this type parameter | - found this type parameter
... ...
LL | fn bar(&self) -> U { LL | fn bar(&self) -> U {
| ^ | ^

View file

@ -4,7 +4,7 @@ error[E0308]: mismatched types
LL | fn foo(x: impl Debug) -> String { LL | fn foo(x: impl Debug) -> String {
| ---------- ------ expected `String` because of return type | ---------- ------ expected `String` because of return type
| | | |
| this type parameter | found this type parameter
LL | x LL | x
| ^ expected `String`, found type parameter `impl Debug` | ^ expected `String`, found type parameter `impl Debug`
| |

View file

@ -70,7 +70,7 @@ error[E0308]: mismatched types
--> $DIR/issue-107090.rs:22:5 --> $DIR/issue-107090.rs:22:5
| |
LL | fn badboi<'in_, 'out, T>(x: Foo<'in_, 'out, T>, sadness: &'in_ Foo<'short, 'out, T>) -> &'out T { LL | fn badboi<'in_, 'out, T>(x: Foo<'in_, 'out, T>, sadness: &'in_ Foo<'short, 'out, T>) -> &'out T {
| - this type parameter ------- expected `&'out T` because of return type | - expected this type parameter ------- expected `&'out T` because of return type
LL | LL |
LL | sadness.cast() LL | sadness.cast()
| ^^^^^^^^^^^^^^ expected `&T`, found `&Foo<'_, '_, T>` | ^^^^^^^^^^^^^^ expected `&T`, found `&Foo<'_, '_, T>`

View file

@ -2,7 +2,7 @@ error[E0053]: method `call` has an incompatible type for trait
--> $DIR/issue-20225.rs:6:43 --> $DIR/issue-20225.rs:6:43
| |
LL | impl<'a, T> Fn<(&'a T,)> for Foo { LL | impl<'a, T> Fn<(&'a T,)> for Foo {
| - this type parameter | - found this type parameter
LL | extern "rust-call" fn call(&self, (_,): (T,)) {} LL | extern "rust-call" fn call(&self, (_,): (T,)) {}
| ^^^^ | ^^^^
| | | |
@ -16,7 +16,7 @@ error[E0053]: method `call_mut` has an incompatible type for trait
--> $DIR/issue-20225.rs:11:51 --> $DIR/issue-20225.rs:11:51
| |
LL | impl<'a, T> FnMut<(&'a T,)> for Foo { LL | impl<'a, T> FnMut<(&'a T,)> for Foo {
| - this type parameter | - found this type parameter
LL | extern "rust-call" fn call_mut(&mut self, (_,): (T,)) {} LL | extern "rust-call" fn call_mut(&mut self, (_,): (T,)) {}
| ^^^^ | ^^^^
| | | |
@ -30,7 +30,7 @@ error[E0053]: method `call_once` has an incompatible type for trait
--> $DIR/issue-20225.rs:18:47 --> $DIR/issue-20225.rs:18:47
| |
LL | impl<'a, T> FnOnce<(&'a T,)> for Foo { LL | impl<'a, T> FnOnce<(&'a T,)> for Foo {
| - this type parameter | - found this type parameter
... ...
LL | extern "rust-call" fn call_once(self, (_,): (T,)) {} LL | extern "rust-call" fn call_once(self, (_,): (T,)) {}
| ^^^^ | ^^^^

View file

@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/issue-51154.rs:2:30 --> $DIR/issue-51154.rs:2:30
| |
LL | fn foo<F: FnMut()>() { LL | fn foo<F: FnMut()>() {
| - this type parameter | - expected this type parameter
LL | let _: Box<F> = Box::new(|| ()); LL | let _: Box<F> = Box::new(|| ());
| -------- ^^^^^ expected type parameter `F`, found closure | -------- ^^^^^ expected type parameter `F`, found closure
| | | |

View file

@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/issue-69306.rs:5:28 --> $DIR/issue-69306.rs:5:28
| |
LL | impl<T> S0<T> { LL | impl<T> S0<T> {
| - this type parameter | - expected this type parameter
LL | const C: S0<u8> = Self(0); LL | const C: S0<u8> = Self(0);
| ---- ^ expected type parameter `T`, found integer | ---- ^ expected type parameter `T`, found integer
| | | |
@ -20,7 +20,7 @@ error[E0308]: mismatched types
--> $DIR/issue-69306.rs:5:23 --> $DIR/issue-69306.rs:5:23
| |
LL | impl<T> S0<T> { LL | impl<T> S0<T> {
| - this type parameter | - found this type parameter
LL | const C: S0<u8> = Self(0); LL | const C: S0<u8> = Self(0);
| ^^^^^^^ expected `S0<u8>`, found `S0<T>` | ^^^^^^^ expected `S0<u8>`, found `S0<T>`
| |
@ -31,7 +31,7 @@ error[E0308]: mismatched types
--> $DIR/issue-69306.rs:10:14 --> $DIR/issue-69306.rs:10:14
| |
LL | impl<T> S0<T> { LL | impl<T> S0<T> {
| - this type parameter | - expected this type parameter
... ...
LL | Self(0); LL | Self(0);
| ---- ^ expected type parameter `T`, found integer | ---- ^ expected type parameter `T`, found integer
@ -50,7 +50,7 @@ error[E0308]: mismatched types
--> $DIR/issue-69306.rs:27:14 --> $DIR/issue-69306.rs:27:14
| |
LL | impl<T> Foo<T> for <S0<T> as Fun>::Out { LL | impl<T> Foo<T> for <S0<T> as Fun>::Out {
| - this type parameter | - expected this type parameter
LL | fn foo() { LL | fn foo() {
LL | Self(0); LL | Self(0);
| ---- ^ expected type parameter `T`, found integer | ---- ^ expected type parameter `T`, found integer
@ -69,7 +69,7 @@ error[E0308]: mismatched types
--> $DIR/issue-69306.rs:33:32 --> $DIR/issue-69306.rs:33:32
| |
LL | impl<T> S1<T, u8> { LL | impl<T> S1<T, u8> {
| - this type parameter | - expected this type parameter
LL | const C: S1<u8, u8> = Self(0, 1); LL | const C: S1<u8, u8> = Self(0, 1);
| ---- ^ expected type parameter `T`, found integer | ---- ^ expected type parameter `T`, found integer
| | | |
@ -87,7 +87,7 @@ error[E0308]: mismatched types
--> $DIR/issue-69306.rs:33:27 --> $DIR/issue-69306.rs:33:27
| |
LL | impl<T> S1<T, u8> { LL | impl<T> S1<T, u8> {
| - this type parameter | - found this type parameter
LL | const C: S1<u8, u8> = Self(0, 1); LL | const C: S1<u8, u8> = Self(0, 1);
| ^^^^^^^^^^ expected `S1<u8, u8>`, found `S1<T, u8>` | ^^^^^^^^^^ expected `S1<u8, u8>`, found `S1<T, u8>`
| |

View file

@ -4,7 +4,7 @@ error[E0308]: lang item `start` function has wrong type
LL | fn start<T>(_main: fn() -> u16, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> isize { LL | fn start<T>(_main: fn() -> u16, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> isize {
| - ^^^^^^^^^^^ expected type parameter `T`, found `u16` | - ^^^^^^^^^^^ expected type parameter `T`, found `u16`
| | | |
| this type parameter | expected this type parameter
| |
= note: expected signature `fn(fn() -> T, _, _, _) -> _` = note: expected signature `fn(fn() -> T, _, _, _) -> _`
found signature `fn(fn() -> u16, _, _, _) -> _` found signature `fn(fn() -> u16, _, _, _) -> _`

View file

@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/issue-35030.rs:9:14 --> $DIR/issue-35030.rs:9:14
| |
LL | impl<bool> Parser<bool> for bool { LL | impl<bool> Parser<bool> for bool {
| ---- this type parameter | ---- expected this type parameter
LL | fn parse(text: &str) -> Option<bool> { LL | fn parse(text: &str) -> Option<bool> {
LL | Some(true) LL | Some(true)
| ---- ^^^^ expected type parameter `bool`, found `bool` | ---- ^^^^ expected type parameter `bool`, found `bool`

View file

@ -4,7 +4,7 @@ error[E0308]: mismatched types
LL | fn bad_echo<T>(_t: T) -> T { LL | fn bad_echo<T>(_t: T) -> T {
| - - expected `T` because of return type | - - expected `T` because of return type
| | | |
| this type parameter | expected this type parameter
LL | "this should not suggest impl Trait" LL | "this should not suggest impl Trait"
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type parameter `T`, found `&str` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type parameter `T`, found `&str`
| |
@ -17,7 +17,7 @@ error[E0308]: mismatched types
LL | fn bad_echo_2<T: Trait>(_t: T) -> T { LL | fn bad_echo_2<T: Trait>(_t: T) -> T {
| - - expected `T` because of return type | - - expected `T` because of return type
| | | |
| this type parameter | expected this type parameter
LL | "this will not suggest it, because that would probably be wrong" LL | "this will not suggest it, because that would probably be wrong"
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type parameter `T`, found `&str` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type parameter `T`, found `&str`
| |
@ -30,7 +30,7 @@ error[E0308]: mismatched types
LL | fn other_bounds_bad<T>() -> T LL | fn other_bounds_bad<T>() -> T
| - - expected `T` because of return type | - - expected `T` because of return type
| | | |
| this type parameter | expected this type parameter
... ...
LL | "don't suggest this, because Option<T> places additional constraints" LL | "don't suggest this, because Option<T> places additional constraints"
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type parameter `T`, found `&str` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type parameter `T`, found `&str`
@ -46,7 +46,7 @@ LL | fn used_in_trait<T>() -> T
| | | | | |
| | expected `T` because of return type | | expected `T` because of return type
| | help: consider using an impl return type: `impl Send` | | help: consider using an impl return type: `impl Send`
| this type parameter | expected this type parameter
... ...
LL | "don't suggest this, because the generic param is used in the bound." LL | "don't suggest this, because the generic param is used in the bound."
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type parameter `T`, found `&str` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type parameter `T`, found `&str`

View file

@ -5,7 +5,7 @@ LL | fn bar<T: Trait + std::marker::Sync>() -> T
| - - | - -
| | | | | |
| | expected `T` because of return type | | expected `T` because of return type
| this type parameter help: consider using an impl return type: `impl Trait + std::marker::Sync + Send` | expected this type parameter help: consider using an impl return type: `impl Trait + std::marker::Sync + Send`
... ...
LL | () LL | ()
| ^^ expected type parameter `T`, found `()` | ^^ expected type parameter `T`, found `()`
@ -21,7 +21,7 @@ LL | fn other_bounds<T>() -> T
| | | | | |
| | expected `T` because of return type | | expected `T` because of return type
| | help: consider using an impl return type: `impl Trait` | | help: consider using an impl return type: `impl Trait`
| this type parameter | expected this type parameter
... ...
LL | () LL | ()
| ^^ expected type parameter `T`, found `()` | ^^ expected type parameter `T`, found `()`

View file

@ -4,7 +4,7 @@ error[E0308]: mismatched types
LL | fn wat<T>(t: &T) -> T { LL | fn wat<T>(t: &T) -> T {
| - - expected `T` because of return type | - - expected `T` because of return type
| | | |
| this type parameter | expected this type parameter
LL | t.clone() LL | t.clone()
| ^^^^^^^^^ expected type parameter `T`, found `&T` | ^^^^^^^^^ expected type parameter `T`, found `&T`
| |

View file

@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/expected-boxed-future-isnt-pinned.rs:11:5 --> $DIR/expected-boxed-future-isnt-pinned.rs:11:5
| |
LL | fn foo<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> { LL | fn foo<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> {
| - this type parameter ----------------------- expected `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` because of return type | - found this type parameter ----------------------- expected `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` because of return type
LL | // We could instead use an `async` block, but this way we have no std spans. LL | // We could instead use an `async` block, but this way we have no std spans.
LL | x LL | x
| ^ expected `Pin<Box<...>>`, found type parameter `F` | ^ expected `Pin<Box<...>>`, found type parameter `F`
@ -30,7 +30,7 @@ error[E0308]: mismatched types
--> $DIR/expected-boxed-future-isnt-pinned.rs:19:14 --> $DIR/expected-boxed-future-isnt-pinned.rs:19:14
| |
LL | fn baz<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> { LL | fn baz<F: Future<Output=i32> + Send + 'static>(x: F) -> BoxFuture<'static, i32> {
| - this type parameter | - found this type parameter
LL | Pin::new(x) LL | Pin::new(x)
| -------- ^ expected `Box<dyn Future<Output = ...> + Send>`, found type parameter `F` | -------- ^ expected `Box<dyn Future<Output = ...> + Send>`, found type parameter `F`
| | | |

View file

@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/restrict-existing-type-bounds.rs:13:12 --> $DIR/restrict-existing-type-bounds.rs:13:12
| |
LL | impl<T: TryAdd> TryAdd for Option<T> { LL | impl<T: TryAdd> TryAdd for Option<T> {
| - this type parameter | - found this type parameter
... ...
LL | Ok(self) LL | Ok(self)
| -- ^^^^ expected `Option<<T as TryAdd>::Output>`, found `Option<T>` | -- ^^^^ expected `Option<<T as TryAdd>::Output>`, found `Option<T>`
@ -29,7 +29,7 @@ error[E0308]: mismatched types
--> $DIR/restrict-existing-type-bounds.rs:26:12 --> $DIR/restrict-existing-type-bounds.rs:26:12
| |
LL | impl<T: TryAdd<Error = X>> TryAdd for Other<T> { LL | impl<T: TryAdd<Error = X>> TryAdd for Other<T> {
| - this type parameter | - found this type parameter
... ...
LL | Ok(self) LL | Ok(self)
| -- ^^^^ expected `Other<<T as TryAdd>::Output>`, found `Other<T>` | -- ^^^^ expected `Other<<T as TryAdd>::Output>`, found `Other<T>`

View file

@ -124,7 +124,7 @@ error[E0308]: mismatched types
--> $DIR/trait-with-missing-associated-type-restriction.rs:31:9 --> $DIR/trait-with-missing-associated-type-restriction.rs:31:9
| |
LL | fn baz<D: std::fmt::Debug, T: Trait<A = D>>(x: T) { LL | fn baz<D: std::fmt::Debug, T: Trait<A = D>>(x: T) {
| - this type parameter | - found this type parameter
LL | qux(x.func()) LL | qux(x.func())
| --- ^^^^^^^^ expected `usize`, found type parameter `D` | --- ^^^^^^^^ expected `usize`, found type parameter `D`
| | | |

View file

@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/issue-52893.rs:53:22 --> $DIR/issue-52893.rs:53:22
| |
LL | impl<F, Name, P> AddClass<Name, F> for Class<P> LL | impl<F, Name, P> AddClass<Name, F> for Class<P>
| - this type parameter | - expected this type parameter
... ...
LL | builder.push(output); LL | builder.push(output);
| ---- ^^^^^^ expected type parameter `F`, found `Class<P>` | ---- ^^^^^^ expected type parameter `F`, found `Class<P>`

View file

@ -42,7 +42,7 @@ error[E0308]: mismatched types
LL | pub fn copy_any<T>(t: &T) -> T { LL | pub fn copy_any<T>(t: &T) -> T {
| - - expected `T` because of return type | - - expected `T` because of return type
| | | |
| this type parameter | expected this type parameter
LL | copy::<dyn Setup<From=T>>(t) LL | copy::<dyn Setup<From=T>>(t)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ
| |

View file

@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/enum-variant-generic-args.rs:13:25 --> $DIR/enum-variant-generic-args.rs:13:25
| |
LL | impl<T> Enum<T> { LL | impl<T> Enum<T> {
| - this type parameter | - expected this type parameter
LL | fn ts_variant() { LL | fn ts_variant() {
LL | Self::TSVariant(()); LL | Self::TSVariant(());
| --------------- ^^ expected type parameter `T`, found `()` | --------------- ^^ expected type parameter `T`, found `()`
@ -50,7 +50,7 @@ error[E0308]: mismatched types
--> $DIR/enum-variant-generic-args.rs:17:31 --> $DIR/enum-variant-generic-args.rs:17:31
| |
LL | impl<T> Enum<T> { LL | impl<T> Enum<T> {
| - this type parameter | - expected this type parameter
... ...
LL | Self::<()>::TSVariant(()); LL | Self::<()>::TSVariant(());
| --------------------- ^^ expected type parameter `T`, found `()` | --------------------- ^^ expected type parameter `T`, found `()`
@ -98,7 +98,7 @@ error[E0308]: mismatched types
--> $DIR/enum-variant-generic-args.rs:26:29 --> $DIR/enum-variant-generic-args.rs:26:29
| |
LL | impl<T> Enum<T> { LL | impl<T> Enum<T> {
| - this type parameter | - expected this type parameter
... ...
LL | Self::SVariant { v: () }; LL | Self::SVariant { v: () };
| ^^ expected type parameter `T`, found `()` | ^^ expected type parameter `T`, found `()`
@ -125,7 +125,7 @@ error[E0308]: mismatched types
--> $DIR/enum-variant-generic-args.rs:28:35 --> $DIR/enum-variant-generic-args.rs:28:35
| |
LL | impl<T> Enum<T> { LL | impl<T> Enum<T> {
| - this type parameter | - expected this type parameter
... ...
LL | Self::SVariant::<()> { v: () }; LL | Self::SVariant::<()> { v: () };
| ^^ expected type parameter `T`, found `()` | ^^ expected type parameter `T`, found `()`
@ -158,7 +158,7 @@ error[E0308]: mismatched types
--> $DIR/enum-variant-generic-args.rs:31:35 --> $DIR/enum-variant-generic-args.rs:31:35
| |
LL | impl<T> Enum<T> { LL | impl<T> Enum<T> {
| - this type parameter | - expected this type parameter
... ...
LL | Self::<()>::SVariant { v: () }; LL | Self::<()>::SVariant { v: () };
| ^^ expected type parameter `T`, found `()` | ^^ expected type parameter `T`, found `()`
@ -206,7 +206,7 @@ error[E0308]: mismatched types
--> $DIR/enum-variant-generic-args.rs:34:41 --> $DIR/enum-variant-generic-args.rs:34:41
| |
LL | impl<T> Enum<T> { LL | impl<T> Enum<T> {
| - this type parameter | - expected this type parameter
... ...
LL | Self::<()>::SVariant::<()> { v: () }; LL | Self::<()>::SVariant::<()> { v: () };
| ^^ expected type parameter `T`, found `()` | ^^ expected type parameter `T`, found `()`

View file

@ -40,7 +40,7 @@ error[E0308]: mismatched types
--> $DIR/bad-index-due-to-nested.rs:20:9 --> $DIR/bad-index-due-to-nested.rs:20:9
| |
LL | fn index<'a, K, V>(map: &'a HashMap<K, V>, k: K) -> &'a V { LL | fn index<'a, K, V>(map: &'a HashMap<K, V>, k: K) -> &'a V {
| - this type parameter | - found this type parameter
LL | map[k] LL | map[k]
| ^ expected `&K`, found type parameter `K` | ^ expected `&K`, found type parameter `K`
| |
@ -55,7 +55,7 @@ error[E0308]: mismatched types
--> $DIR/bad-index-due-to-nested.rs:20:5 --> $DIR/bad-index-due-to-nested.rs:20:5
| |
LL | fn index<'a, K, V>(map: &'a HashMap<K, V>, k: K) -> &'a V { LL | fn index<'a, K, V>(map: &'a HashMap<K, V>, k: K) -> &'a V {
| - this type parameter ----- expected `&'a V` because of return type | - found this type parameter ----- expected `&'a V` because of return type
LL | map[k] LL | map[k]
| ^^^^^^ expected `&V`, found type parameter `V` | ^^^^^^ expected `&V`, found type parameter `V`
| |

View file

@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/issue-13853.rs:14:9 --> $DIR/issue-13853.rs:14:9
| |
LL | fn nodes<'a, I: Iterator<Item=&'a N>>(&self) -> I LL | fn nodes<'a, I: Iterator<Item=&'a N>>(&self) -> I
| - this type parameter - expected `I` because of return type | - expected this type parameter - expected `I` because of return type
... ...
LL | self.iter() LL | self.iter()
| ^^^^^^^^^^^ expected type parameter `I`, found `Iter<'_, N>` | ^^^^^^^^^^^ expected type parameter `I`, found `Iter<'_, N>`