Skip to content

Commit c556151

Browse files
committed
review comments
1 parent 9c0000c commit c556151

14 files changed

+53
-33
lines changed

src/librustc/infer/error_reporting/mod.rs

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,16 +1339,16 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
13391339
err.span_label(
13401340
*sp,
13411341
format!(
1342-
"{}this is {}the {} {}{}",
1342+
"{}the {} {}{}{}",
1343+
if count > 1 { "one of " } else { "" },
1344+
target,
1345+
key,
1346+
pluralize!(count),
13431347
if sp.is_desugaring(DesugaringKind::Async) {
1344-
"in the desugared `async fn`, "
1348+
" in the `Output` of this `async fn`"
13451349
} else {
13461350
""
13471351
},
1348-
if count > 1 { "one of" } else { "" },
1349-
target,
1350-
key,
1351-
pluralize!(count),
13521352
),
13531353
);
13541354
}
@@ -1364,18 +1364,24 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
13641364
ty::Opaque(..) => "opaque type",
13651365
_ => "",
13661366
};
1367-
match t.kind {
1368-
ty::Closure(def_id, _) | ty::Opaque(def_id, _) => {
1369-
let span = self.tcx.def_span(def_id);
1370-
debug!("note_type_err visit_ty {:?}", span.macro_backtrace());
1371-
if !self.ignore_span.overlaps(span)
1372-
&& !self.expected.values().any(|exp| exp.iter().any(|sp| *sp == span))
1373-
{
1374-
let entry = self.types.entry(kind).or_default();
1375-
entry.insert(span);
1376-
}
1367+
if let ty::Closure(def_id, _) | ty::Opaque(def_id, _) = t.kind {
1368+
let span = self.tcx.def_span(def_id);
1369+
// Avoid cluttering the output when the "found" and error span overlap:
1370+
//
1371+
// error[E0308]: mismatched types
1372+
// --> $DIR/issue-20862.rs:2:5
1373+
// |
1374+
// LL | |y| x + y
1375+
// | ^^^^^^^^^
1376+
// | |
1377+
// | the found closure
1378+
// | expected `()`, found closure
1379+
// |
1380+
// = note: expected unit type `()`
1381+
// found closure `[closure@$DIR/issue-20862.rs:2:5: 2:14 x:_]`
1382+
if !self.ignore_span.overlaps(span) {
1383+
self.types.entry(kind).or_default().insert(span);
13771384
}
1378-
_ => {}
13791385
}
13801386
t.super_visit_with(self)
13811387
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
22
--> $DIR/dont-suggest-missing-await.rs:14:18
33
|
44
LL | async fn make_u32() -> u32 {
5-
| --- in the desugared `async fn`, this is the found opaque type
5+
| --- the found opaque type in the `Output` of this `async fn`
66
...
77
LL | take_u32(x)
88
| ^ expected `u32`, found opaque type

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
22
--> $DIR/suggest-missing-await-closure.rs:16:18
33
|
44
LL | async fn make_u32() -> u32 {
5-
| --- in the desugared `async fn`, this is the found opaque type
5+
| --- the found opaque type in the `Output` of this `async fn`
66
...
77
LL | take_u32(x)
88
| ^

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
22
--> $DIR/suggest-missing-await.rs:13:14
33
|
44
LL | async fn make_u32() -> u32 {
5-
| --- in the desugared `async fn`, this is the found opaque type
5+
| --- the found opaque type in the `Output` of this `async fn`
66
...
77
LL | take_u32(x)
88
| ^
@@ -16,6 +16,9 @@ LL | take_u32(x)
1616
error[E0308]: mismatched types
1717
--> $DIR/suggest-missing-await.rs:23:5
1818
|
19+
LL | async fn dummy() {}
20+
| - the found opaque type in the `Output` of this `async fn`
21+
...
1922
LL | dummy()
2023
| ^^^^^^^ expected `()`, found opaque type
2124
|

src/test/ui/closures/closure-reform-bad.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
22
--> $DIR/closure-reform-bad.rs:11:15
33
|
44
LL | let f = |s: &str| println!("{}{}", s, string);
5-
| ------------------------------------- this is the found closure
5+
| ------------------------------------- the found closure
66
LL | call_bare(f)
77
| ^ expected fn pointer, found closure
88
|

src/test/ui/extern/extern-types-distinct-types.stderr

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
error[E0308]: mismatched types
22
--> $DIR/extern-types-distinct-types.rs:9:5
33
|
4+
LL | type A;
5+
| ------- the found foreign type
6+
LL | type B;
7+
| ------- the expected foreign type
8+
...
49
LL | r
510
| ^ expected extern type `B`, found extern type `A`
611
|

src/test/ui/impl-trait/equality2.stderr

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
22
--> $DIR/equality2.rs:25:18
33
|
44
LL | fn hide<T: Foo>(x: T) -> impl Foo {
5-
| -------- this is the found opaque type
5+
| -------- the found opaque type
66
...
77
LL | let _: u32 = hide(0_u32);
88
| --- ^^^^^^^^^^^ expected `u32`, found opaque type
@@ -16,7 +16,7 @@ error[E0308]: mismatched types
1616
--> $DIR/equality2.rs:31:18
1717
|
1818
LL | fn hide<T: Foo>(x: T) -> impl Foo {
19-
| -------- this is the found opaque type
19+
| -------- the found opaque type
2020
...
2121
LL | let _: i32 = Leak::leak(hide(0_i32));
2222
| --- ^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found associated type
@@ -32,7 +32,10 @@ error[E0308]: mismatched types
3232
--> $DIR/equality2.rs:38:10
3333
|
3434
LL | fn hide<T: Foo>(x: T) -> impl Foo {
35-
| -------- this is the expected opaque type
35+
| --------
36+
| |
37+
| the expected opaque type
38+
| the found opaque type
3639
...
3740
LL | x = (x.1,
3841
| ^^^ expected `u32`, found `i32`
@@ -44,7 +47,10 @@ error[E0308]: mismatched types
4447
--> $DIR/equality2.rs:41:10
4548
|
4649
LL | fn hide<T: Foo>(x: T) -> impl Foo {
47-
| -------- this is the expected opaque type
50+
| --------
51+
| |
52+
| the expected opaque type
53+
| the found opaque type
4854
...
4955
LL | x.0);
5056
| ^^^ expected `i32`, found `u32`

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
22
--> $DIR/issue-24036.rs:3:9
33
|
44
LL | let mut x = |c| c + 1;
5-
| --------- this is the expected closure
5+
| --------- the expected closure
66
LL | x = |c| c + 1;
77
| ^^^^^^^^^ expected closure, found a different closure
88
|

src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ error[E0308]: mismatched types
236236
--> $DIR/fn-or-tuple-struct-without-args.rs:46:20
237237
|
238238
LL | let closure = || 42;
239-
| ----- this is the found closure
239+
| ----- the found closure
240240
LL | let _: usize = closure;
241241
| ----- ^^^^^^^
242242
| | |

src/test/ui/suggestions/opaque-type-error.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0308]: `if` and `else` have incompatible types
22
--> $DIR/opaque-type-error.rs:20:9
33
|
44
LL | fn thing_two() -> impl Future<Output = Result<(), ()>> {
5-
| ------------------------------------ this is the found opaque type
5+
| ------------------------------------ the found opaque type
66
...
77
LL | / if true {
88
LL | | thing_one()

src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.nll.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ LL | let z: i32 = x;
1313
| expected due to this
1414
...
1515
LL | type WrongGeneric<T> = impl 'static;
16-
| ------------------------------------ this is the found opaque type
16+
| ------------------------------------ the found opaque type
1717
|
1818
= note: expected type `i32`
1919
found opaque type `WrongGeneric::<&{integer}>`

src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ LL | let z: i32 = x;
1313
| expected due to this
1414
...
1515
LL | type WrongGeneric<T> = impl 'static;
16-
| ------------------------------------ this is the found opaque type
16+
| ------------------------------------ the found opaque type
1717
|
1818
= note: expected type `i32`
1919
found opaque type `WrongGeneric::<&{integer}>`

src/test/ui/type-alias-impl-trait/never_reveal_concrete_type.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
22
--> $DIR/never_reveal_concrete_type.rs:13:27
33
|
44
LL | type NoReveal = impl std::fmt::Debug;
5-
| ------------------------------------- this is the found opaque type
5+
| ------------------------------------- the found opaque type
66
...
77
LL | let _: &'static str = x;
88
| ------------ ^ expected `&str`, found opaque type

src/test/ui/type-alias-impl-trait/no_revealing_outside_defining_module.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
22
--> $DIR/no_revealing_outside_defining_module.rs:15:19
33
|
44
LL | pub type Boo = impl ::std::fmt::Debug;
5-
| -------------------------------------- this is the found opaque type
5+
| -------------------------------------- the found opaque type
66
...
77
LL | let _: &str = bomp();
88
| ---- ^^^^^^ expected `&str`, found opaque type
@@ -16,7 +16,7 @@ error[E0308]: mismatched types
1616
--> $DIR/no_revealing_outside_defining_module.rs:19:5
1717
|
1818
LL | pub type Boo = impl ::std::fmt::Debug;
19-
| -------------------------------------- this is the expected opaque type
19+
| -------------------------------------- the expected opaque type
2020
...
2121
LL | fn bomp() -> boo::Boo {
2222
| -------- expected `Boo` because of return type

0 commit comments

Comments
 (0)