diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2023-01-02 23:34:26 -0800 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2023-01-05 16:51:16 +0000 |
| commit | 6b0cce4b5018bcd1c7aed1f84cb0b86e3cc03f9f (patch) | |
| tree | a8184ac7fad4c0231213f6124d6c555d5940843c | |
| parent | 48094a4a6f53ee3be636b4166a7841505bb7cabc (diff) | |
| download | rust-6b0cce4b5018bcd1c7aed1f84cb0b86e3cc03f9f.tar.gz rust-6b0cce4b5018bcd1c7aed1f84cb0b86e3cc03f9f.zip | |
review comments: do not always point at init expr
20 files changed, 14 insertions, 98 deletions
diff --git a/compiler/rustc_hir_typeck/src/demand.rs b/compiler/rustc_hir_typeck/src/demand.rs index 5ba0d41ab9d..c50d03b944f 100644 --- a/compiler/rustc_hir_typeck/src/demand.rs +++ b/compiler/rustc_hir_typeck/src/demand.rs @@ -355,6 +355,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } } + if span_labels.len() < 2 { + return false; + } for (sp, label) in span_labels { err.span_label(sp, &label); } diff --git a/src/test/ui/argument-suggestions/two-mismatch-notes.stderr b/src/test/ui/argument-suggestions/two-mismatch-notes.stderr index 3ccd399863d..7873cf964cb 100644 --- a/src/test/ui/argument-suggestions/two-mismatch-notes.stderr +++ b/src/test/ui/argument-suggestions/two-mismatch-notes.stderr @@ -1,8 +1,6 @@ error[E0308]: arguments to this function are incorrect --> $DIR/two-mismatch-notes.rs:10:5 | -LL | let w = Wrapper::<isize>(1isize); - | ------------------------ here the type of `w` is inferred to be `Wrapper<isize>` LL | foo(f, w); | ^^^ | diff --git a/src/test/ui/async-await/dont-suggest-missing-await.stderr b/src/test/ui/async-await/dont-suggest-missing-await.stderr index 6e232dd0064..627bf05bba2 100644 --- a/src/test/ui/async-await/dont-suggest-missing-await.stderr +++ b/src/test/ui/async-await/dont-suggest-missing-await.stderr @@ -1,8 +1,6 @@ error[E0308]: mismatched types --> $DIR/dont-suggest-missing-await.rs:14:18 | -LL | let x = make_u32(); - | ---------- here the type of `x` is inferred to be `impl Future<Output = u32>` LL | take_u32(x) | -------- ^ expected `u32`, found opaque type | | diff --git a/src/test/ui/async-await/suggest-missing-await-closure.stderr b/src/test/ui/async-await/suggest-missing-await-closure.stderr index 9f51832365b..a5958baffba 100644 --- a/src/test/ui/async-await/suggest-missing-await-closure.stderr +++ b/src/test/ui/async-await/suggest-missing-await-closure.stderr @@ -1,8 +1,6 @@ error[E0308]: mismatched types --> $DIR/suggest-missing-await-closure.rs:16:18 | -LL | let x = make_u32(); - | ---------- here the type of `x` is inferred to be `impl Future<Output = u32>` LL | take_u32(x) | -------- ^ expected `u32`, found opaque type | | diff --git a/src/test/ui/async-await/suggest-missing-await.stderr b/src/test/ui/async-await/suggest-missing-await.stderr index ce4c8edaf74..1196601ace0 100644 --- a/src/test/ui/async-await/suggest-missing-await.stderr +++ b/src/test/ui/async-await/suggest-missing-await.stderr @@ -1,8 +1,6 @@ error[E0308]: mismatched types --> $DIR/suggest-missing-await.rs:12:14 | -LL | let x = make_u32(); - | ---------- here the type of `x` is inferred to be `impl Future<Output = u32>` LL | take_u32(x) | -------- ^ expected `u32`, found opaque type | | diff --git a/src/test/ui/closures/closure-return-type-mismatch.stderr b/src/test/ui/closures/closure-return-type-mismatch.stderr index d33cf383cbc..3a89d30a05d 100644 --- a/src/test/ui/closures/closure-return-type-mismatch.stderr +++ b/src/test/ui/closures/closure-return-type-mismatch.stderr @@ -1,8 +1,6 @@ error[E0308]: mismatched types --> $DIR/closure-return-type-mismatch.rs:7:9 | -LL | let a = true; - | ---- here the type of `a` is inferred to be `bool` LL | a | ^ expected `&str`, found `bool` | diff --git a/src/test/ui/coercion/coerce-to-bang.stderr b/src/test/ui/coercion/coerce-to-bang.stderr index d2fd0f78838..1207dc7e7a2 100644 --- a/src/test/ui/coercion/coerce-to-bang.stderr +++ b/src/test/ui/coercion/coerce-to-bang.stderr @@ -33,9 +33,6 @@ LL | fn foo(x: usize, y: !, z: usize) { } error[E0308]: mismatched types --> $DIR/coerce-to-bang.rs:26:12 | -LL | let b = 22; - | -- here the type of `b` is inferred to be `{integer}` -LL | let c = 44; LL | foo(a, b, c); // ... and hence a reference to `a` is expected to diverge. | --- ^ expected `!`, found integer | | @@ -52,9 +49,6 @@ LL | fn foo(x: usize, y: !, z: usize) { } error[E0308]: mismatched types --> $DIR/coerce-to-bang.rs:36:12 | -LL | let b = 22; - | -- here the type of `b` is inferred to be `{integer}` -LL | let c = 44; LL | foo(a, b, c); | --- ^ expected `!`, found integer | | @@ -71,9 +65,6 @@ LL | fn foo(x: usize, y: !, z: usize) { } error[E0308]: mismatched types --> $DIR/coerce-to-bang.rs:45:12 | -LL | let b = 22; - | -- here the type of `b` is inferred to be `{integer}` -LL | let c = 44; LL | foo(a, b, c); | --- ^ expected `!`, found integer | | diff --git a/src/test/ui/generic-associated-types/collections-project-default.stderr b/src/test/ui/generic-associated-types/collections-project-default.stderr index c11a5acc352..5701017dc34 100644 --- a/src/test/ui/generic-associated-types/collections-project-default.stderr +++ b/src/test/ui/generic-associated-types/collections-project-default.stderr @@ -4,9 +4,6 @@ error[E0308]: mismatched types LL | fn floatify_sibling<C>(ints: &C) -> <C as Collection<i32>>::Sibling<f32> | ------------------------------------ expected `<C as Collection<i32>>::Sibling<f32>` because of return type ... -LL | let mut res = <C::Family as CollectionFamily>::Member::<f32>::empty(); - | ------------------------------------------------------- here the type of `res` is inferred to be `<<C as Collection<i32>>::Family as CollectionFamily>::Member<f32>` -... LL | res | ^^^ expected Collection::Sibling, found CollectionFamily::Member | diff --git a/src/test/ui/issues/issue-15783.stderr b/src/test/ui/issues/issue-15783.stderr index e7fecfebdc8..660dfe9ed3d 100644 --- a/src/test/ui/issues/issue-15783.stderr +++ b/src/test/ui/issues/issue-15783.stderr @@ -1,8 +1,6 @@ error[E0308]: mismatched types --> $DIR/issue-15783.rs:8:19 | -LL | let x = Some(&[name]); - | ------------- here the type of `x` is inferred to be `Option<&[&str; 1]>` LL | let msg = foo(x); | --- ^ expected slice `[&str]`, found array `[&str; 1]` | | diff --git a/src/test/ui/let-else/let-else-ref-bindings.stderr b/src/test/ui/let-else/let-else-ref-bindings.stderr index 4c58b2db575..56b9e073330 100644 --- a/src/test/ui/let-else/let-else-ref-bindings.stderr +++ b/src/test/ui/let-else/let-else-ref-bindings.stderr @@ -19,9 +19,6 @@ LL | let Some(ref a): Option<&[u8]> = &some else { return }; error[E0308]: mismatched types --> $DIR/let-else-ref-bindings.rs:24:34 | -LL | let some = Some(bytes); - | ----------- here the type of `some` is inferred to be `Option<Vec<u8>>` -... LL | let Some(a): Option<&[u8]> = some else { return }; | ------------- ^^^^ expected `&[u8]`, found struct `Vec` | | @@ -62,9 +59,6 @@ LL | let Some(ref mut a): Option<&mut [u8]> = &mut some else { return }; error[E0308]: mismatched types --> $DIR/let-else-ref-bindings.rs:52:38 | -LL | let mut some = Some(bytes); - | ----------- here the type of `some` is inferred to be `Option<Vec<u8>>` -... LL | let Some(a): Option<&mut [u8]> = some else { return }; | ----------------- ^^^^ expected `&mut [u8]`, found struct `Vec` | | diff --git a/src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr b/src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr index 1d836f20012..82addab9479 100644 --- a/src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr +++ b/src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr @@ -10,9 +10,6 @@ LL | #![feature(unsized_locals, unsized_fn_params)] error[E0308]: mismatched types --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:87:24 | -LL | let z = x.foo(); - | ------- here the type of `z` is inferred to be `u32` -... LL | let _seetype: () = z; | -- ^ expected `()`, found `u32` | | @@ -21,9 +18,6 @@ LL | let _seetype: () = z; error[E0308]: mismatched types --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:104:24 | -LL | let z = x.foo(); - | ------- here the type of `z` is inferred to be `u64` -... LL | let _seetype: () = z; | -- ^ expected `()`, found `u64` | | @@ -66,9 +60,6 @@ LL | let z = FinalFoo::foo(x); error[E0308]: mismatched types --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:139:24 | -LL | let z = x.foo(); - | ------- here the type of `z` is inferred to be `u8` -... LL | let _seetype: () = z; | -- ^ expected `()`, found `u8` | | @@ -77,9 +68,6 @@ LL | let _seetype: () = z; error[E0308]: mismatched types --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:157:24 | -LL | let z = x.foo(); - | ------- here the type of `z` is inferred to be `u32` -... LL | let _seetype: () = z; | -- ^ expected `()`, found `u32` | | @@ -88,9 +76,6 @@ LL | let _seetype: () = z; error[E0308]: mismatched types --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:174:24 | -LL | let z = x.foo(); - | ------- here the type of `z` is inferred to be `u32` -... LL | let _seetype: () = z; | -- ^ expected `()`, found `u32` | | diff --git a/src/test/ui/mismatched_types/abridged.stderr b/src/test/ui/mismatched_types/abridged.stderr index 9b5f0134f12..ff1a836c9ae 100644 --- a/src/test/ui/mismatched_types/abridged.stderr +++ b/src/test/ui/mismatched_types/abridged.stderr @@ -53,19 +53,11 @@ LL | Ok(Foo { bar: 1 }) error[E0308]: mismatched types --> $DIR/abridged.rs:39:5 | -LL | fn d() -> X<X<String, String>, String> { - | ---------------------------- expected `X<X<String, String>, String>` because of return type -LL | let x = X { - | _____________- -LL | | x: X { -LL | | x: "".to_string(), -LL | | y: 2, -LL | | }, -LL | | y: 3, -LL | | }; - | |_____- here the type of `x` is inferred to be `X<X<String, {integer}>, {integer}>` -LL | x - | ^ expected struct `String`, found integer +LL | fn d() -> X<X<String, String>, String> { + | ---------------------------- expected `X<X<String, String>, String>` because of return type +... +LL | x + | ^ expected struct `String`, found integer | = note: expected struct `X<X<_, String>, String>` found struct `X<X<_, {integer}>, {integer}>` @@ -73,19 +65,11 @@ LL | x error[E0308]: mismatched types --> $DIR/abridged.rs:50:5 | -LL | fn e() -> X<X<String, String>, String> { - | ---------------------------- expected `X<X<String, String>, String>` because of return type -LL | let x = X { - | _____________- -LL | | x: X { -LL | | x: "".to_string(), -LL | | y: 2, -LL | | }, -LL | | y: "".to_string(), -LL | | }; - | |_____- here the type of `x` is inferred to be `X<X<String, {integer}>, String>` -LL | x - | ^ expected struct `String`, found integer +LL | fn e() -> X<X<String, String>, String> { + | ---------------------------- expected `X<X<String, String>, String>` because of return type +... +LL | x + | ^ expected struct `String`, found integer | = note: expected struct `X<X<_, String>, _>` found struct `X<X<_, {integer}>, _>` diff --git a/src/test/ui/parser/struct-literal-variant-in-if.stderr b/src/test/ui/parser/struct-literal-variant-in-if.stderr index 97cdd130d0b..9f0c0074d67 100644 --- a/src/test/ui/parser/struct-literal-variant-in-if.stderr +++ b/src/test/ui/parser/struct-literal-variant-in-if.stderr @@ -51,8 +51,6 @@ LL | if x == E::V { field } {} error[E0308]: mismatched types --> $DIR/struct-literal-variant-in-if.rs:10:20 | -LL | let field = true; - | ---- here the type of `field` is inferred to be `bool` LL | if x == E::V { field } {} | ---------------^^^^^-- | | | diff --git a/src/test/ui/rfc-2497-if-let-chains/ensure-that-let-else-does-not-interact-with-let-chains.stderr b/src/test/ui/rfc-2497-if-let-chains/ensure-that-let-else-does-not-interact-with-let-chains.stderr index 8c30f015c5d..498a112fa9b 100644 --- a/src/test/ui/rfc-2497-if-let-chains/ensure-that-let-else-does-not-interact-with-let-chains.stderr +++ b/src/test/ui/rfc-2497-if-let-chains/ensure-that-let-else-does-not-interact-with-let-chains.stderr @@ -100,9 +100,6 @@ LL | let Some(n) = opt && let another = n else { error[E0308]: mismatched types --> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:9:19 | -LL | let opt = Some(1i32); - | ---------- here the type of `opt` is inferred to be `Option<i32>` -... LL | let Some(n) = opt && n == 1 else { | ^^^ expected `bool`, found enum `Option` | @@ -123,9 +120,6 @@ LL | let Some(n) = opt && n == 1 else { error[E0308]: mismatched types --> $DIR/ensure-that-let-else-does-not-interact-with-let-chains.rs:15:19 | -LL | let opt = Some(1i32); - | ---------- here the type of `opt` is inferred to be `Option<i32>` -... LL | let Some(n) = opt && let another = n else { | ^^^ expected `bool`, found enum `Option` | diff --git a/src/test/ui/structs/struct-base-wrong-type.stderr b/src/test/ui/structs/struct-base-wrong-type.stderr index 30feb9cdd70..b039ce2cc92 100644 --- a/src/test/ui/structs/struct-base-wrong-type.stderr +++ b/src/test/ui/structs/struct-base-wrong-type.stderr @@ -13,8 +13,6 @@ LL | static foo_i: Foo = Foo { a: 2, ..4 }; error[E0308]: mismatched types --> $DIR/struct-base-wrong-type.rs:12:27 | -LL | let b = Bar { x: 5 }; - | ------------ here the type of `b` is inferred to be `Bar` LL | let f = Foo { a: 2, ..b }; | ^ expected struct `Foo`, found struct `Bar` diff --git a/src/test/ui/suggestions/call-boxed.stderr b/src/test/ui/suggestions/call-boxed.stderr index 1609c2a3094..9b619ac9a3f 100644 --- a/src/test/ui/suggestions/call-boxed.stderr +++ b/src/test/ui/suggestions/call-boxed.stderr @@ -4,10 +4,7 @@ error[E0308]: mismatched types LL | let mut x = 1i32; | ---- expected due to this value LL | let y = Box::new(|| 1); - | -------------- - | | | - | | the found closure - | here the type of `y` is inferred to be `Box<[closure@call-boxed.rs:3:22]>` + | -- the found closure LL | x = y; | ^ expected `i32`, found struct `Box` | diff --git a/src/test/ui/suggestions/issue-86100-tuple-paren-comma.stderr b/src/test/ui/suggestions/issue-86100-tuple-paren-comma.stderr index 388d8d8d895..8c9a41a2027 100644 --- a/src/test/ui/suggestions/issue-86100-tuple-paren-comma.stderr +++ b/src/test/ui/suggestions/issue-86100-tuple-paren-comma.stderr @@ -49,8 +49,6 @@ LL | let _s = S { _s: ("abc".to_string(),) }; error[E0308]: mismatched types --> $DIR/issue-86100-tuple-paren-comma.rs:23:22 | -LL | let t = (1, 2); - | ------ here the type of `t` is inferred to be `({integer}, {integer})` LL | let _x: (i32,) = (t); | ------ ^^^ expected a tuple with 1 element, found one with 2 elements | | diff --git a/src/test/ui/traits/issue-52893.stderr b/src/test/ui/traits/issue-52893.stderr index f7b5b7fca06..7924d3db06f 100644 --- a/src/test/ui/traits/issue-52893.stderr +++ b/src/test/ui/traits/issue-52893.stderr @@ -4,8 +4,6 @@ error[E0308]: mismatched types LL | impl<F, Name, P> AddClass<Name, F> for Class<P> | - this type parameter ... -LL | let output = builder.to_ref(); - | ---------------- here the type of `output` is inferred to be `Class<P>` LL | builder.push(output); | ---- ^^^^^^ expected type parameter `F`, found struct `Class` | | diff --git a/src/test/ui/tuple/wrong_argument_ice-3.stderr b/src/test/ui/tuple/wrong_argument_ice-3.stderr index 1ad1d692121..0a503e1fe58 100644 --- a/src/test/ui/tuple/wrong_argument_ice-3.stderr +++ b/src/test/ui/tuple/wrong_argument_ice-3.stderr @@ -1,9 +1,6 @@ error[E0061]: this method takes 1 argument but 2 arguments were supplied --> $DIR/wrong_argument_ice-3.rs:9:16 | -LL | let new_group = vec![String::new()]; - | ------------------- here the type of `new_group` is inferred to be `Vec<String>` -... LL | groups.push(new_group, vec![process]); | ^^^^ ------------- argument of type `Vec<&Process>` unexpected | diff --git a/src/test/ui/type/type-mismatch-same-crate-name.stderr b/src/test/ui/type/type-mismatch-same-crate-name.stderr index 0d754459f4a..fcafd315ebf 100644 --- a/src/test/ui/type/type-mismatch-same-crate-name.stderr +++ b/src/test/ui/type/type-mismatch-same-crate-name.stderr @@ -1,9 +1,6 @@ error[E0308]: mismatched types --> $DIR/type-mismatch-same-crate-name.rs:16:20 | -LL | let foo2 = {extern crate crate_a2 as a; a::Foo}; - | ------------------------------------ here the type of `foo2` is inferred to be `Foo` -... LL | a::try_foo(foo2); | ---------- ^^^^ expected struct `main::a::Foo`, found a different struct `main::a::Foo` | | @@ -30,9 +27,6 @@ LL | pub fn try_foo(x: Foo){} error[E0308]: mismatched types --> $DIR/type-mismatch-same-crate-name.rs:20:20 | -LL | let bar2 = {extern crate crate_a2 as a; a::bar()}; - | -------------------------------------- here the type of `bar2` is inferred to be `Box<dyn Bar>` -... LL | a::try_bar(bar2); | ---------- ^^^^ expected trait `main::a::Bar`, found a different trait `main::a::Bar` | | |
