Skip to content

Commit c5d21c2

Browse files
committed
review comments: do not always point at init expr
1 parent acff39f commit c5d21c2

20 files changed

+14
-98
lines changed

compiler/rustc_hir_typeck/src/demand.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
355355
}
356356
}
357357
}
358+
if span_labels.len() < 2 {
359+
return false;
360+
}
358361
for (sp, label) in span_labels {
359362
err.span_label(sp, &label);
360363
}

src/test/ui/argument-suggestions/two-mismatch-notes.stderr

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
error[E0308]: arguments to this function are incorrect
22
--> $DIR/two-mismatch-notes.rs:10:5
33
|
4-
LL | let w = Wrapper::<isize>(1isize);
5-
| ------------------------ here the type of `w` is inferred to be `Wrapper<isize>`
64
LL | foo(f, w);
75
| ^^^
86
|

src/test/ui/async-await/dont-suggest-missing-await.stderr

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
error[E0308]: mismatched types
22
--> $DIR/dont-suggest-missing-await.rs:14:18
33
|
4-
LL | let x = make_u32();
5-
| ---------- here the type of `x` is inferred to be `impl Future<Output = u32>`
64
LL | take_u32(x)
75
| -------- ^ expected `u32`, found opaque type
86
| |

src/test/ui/async-await/suggest-missing-await-closure.stderr

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
error[E0308]: mismatched types
22
--> $DIR/suggest-missing-await-closure.rs:16:18
33
|
4-
LL | let x = make_u32();
5-
| ---------- here the type of `x` is inferred to be `impl Future<Output = u32>`
64
LL | take_u32(x)
75
| -------- ^ expected `u32`, found opaque type
86
| |

src/test/ui/async-await/suggest-missing-await.stderr

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
error[E0308]: mismatched types
22
--> $DIR/suggest-missing-await.rs:12:14
33
|
4-
LL | let x = make_u32();
5-
| ---------- here the type of `x` is inferred to be `impl Future<Output = u32>`
64
LL | take_u32(x)
75
| -------- ^ expected `u32`, found opaque type
86
| |

src/test/ui/closures/closure-return-type-mismatch.stderr

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
error[E0308]: mismatched types
22
--> $DIR/closure-return-type-mismatch.rs:7:9
33
|
4-
LL | let a = true;
5-
| ---- here the type of `a` is inferred to be `bool`
64
LL | a
75
| ^ expected `&str`, found `bool`
86
|

src/test/ui/coercion/coerce-to-bang.stderr

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ LL | fn foo(x: usize, y: !, z: usize) { }
3333
error[E0308]: mismatched types
3434
--> $DIR/coerce-to-bang.rs:26:12
3535
|
36-
LL | let b = 22;
37-
| -- here the type of `b` is inferred to be `{integer}`
38-
LL | let c = 44;
3936
LL | foo(a, b, c); // ... and hence a reference to `a` is expected to diverge.
4037
| --- ^ expected `!`, found integer
4138
| |
@@ -52,9 +49,6 @@ LL | fn foo(x: usize, y: !, z: usize) { }
5249
error[E0308]: mismatched types
5350
--> $DIR/coerce-to-bang.rs:36:12
5451
|
55-
LL | let b = 22;
56-
| -- here the type of `b` is inferred to be `{integer}`
57-
LL | let c = 44;
5852
LL | foo(a, b, c);
5953
| --- ^ expected `!`, found integer
6054
| |
@@ -71,9 +65,6 @@ LL | fn foo(x: usize, y: !, z: usize) { }
7165
error[E0308]: mismatched types
7266
--> $DIR/coerce-to-bang.rs:45:12
7367
|
74-
LL | let b = 22;
75-
| -- here the type of `b` is inferred to be `{integer}`
76-
LL | let c = 44;
7768
LL | foo(a, b, c);
7869
| --- ^ expected `!`, found integer
7970
| |

src/test/ui/generic-associated-types/collections-project-default.stderr

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ error[E0308]: mismatched types
44
LL | fn floatify_sibling<C>(ints: &C) -> <C as Collection<i32>>::Sibling<f32>
55
| ------------------------------------ expected `<C as Collection<i32>>::Sibling<f32>` because of return type
66
...
7-
LL | let mut res = <C::Family as CollectionFamily>::Member::<f32>::empty();
8-
| ------------------------------------------------------- here the type of `res` is inferred to be `<<C as Collection<i32>>::Family as CollectionFamily>::Member<f32>`
9-
...
107
LL | res
118
| ^^^ expected Collection::Sibling, found CollectionFamily::Member
129
|

src/test/ui/issues/issue-15783.stderr

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
error[E0308]: mismatched types
22
--> $DIR/issue-15783.rs:8:19
33
|
4-
LL | let x = Some(&[name]);
5-
| ------------- here the type of `x` is inferred to be `Option<&[&str; 1]>`
64
LL | let msg = foo(x);
75
| --- ^ expected slice `[&str]`, found array `[&str; 1]`
86
| |

src/test/ui/let-else/let-else-ref-bindings.stderr

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ LL | let Some(ref a): Option<&[u8]> = &some else { return };
1919
error[E0308]: mismatched types
2020
--> $DIR/let-else-ref-bindings.rs:24:34
2121
|
22-
LL | let some = Some(bytes);
23-
| ----------- here the type of `some` is inferred to be `Option<Vec<u8>>`
24-
...
2522
LL | let Some(a): Option<&[u8]> = some else { return };
2623
| ------------- ^^^^ expected `&[u8]`, found struct `Vec`
2724
| |
@@ -62,9 +59,6 @@ LL | let Some(ref mut a): Option<&mut [u8]> = &mut some else { return };
6259
error[E0308]: mismatched types
6360
--> $DIR/let-else-ref-bindings.rs:52:38
6461
|
65-
LL | let mut some = Some(bytes);
66-
| ----------- here the type of `some` is inferred to be `Option<Vec<u8>>`
67-
...
6862
LL | let Some(a): Option<&mut [u8]> = some else { return };
6963
| ----------------- ^^^^ expected `&mut [u8]`, found struct `Vec`
7064
| |

0 commit comments

Comments
 (0)