diff options
| author | Hirochika Matsumoto <matsujika@gmail.com> | 2021-02-02 15:14:24 +0900 |
|---|---|---|
| committer | Hirochika Matsumoto <matsujika@gmail.com> | 2021-02-02 15:16:07 +0900 |
| commit | bad0f288d31749265b912cad00182929be6f5b25 (patch) | |
| tree | 3c123c07941f6f1dc9a61de43af206b89beefa2c | |
| parent | 461cbe42d03f55ac331ce9ce23108681411b04f5 (diff) | |
| download | rust-bad0f288d31749265b912cad00182929be6f5b25.tar.gz rust-bad0f288d31749265b912cad00182929be6f5b25.zip | |
Improve wording of suggestion about accessing field
| -rw-r--r-- | compiler/rustc_infer/src/infer/error_reporting/mod.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/suggestions/field-access.fixed | 8 | ||||
| -rw-r--r-- | src/test/ui/suggestions/field-access.rs | 8 | ||||
| -rw-r--r-- | src/test/ui/suggestions/field-access.stderr | 8 |
4 files changed, 13 insertions, 13 deletions
diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index 2abb1c725b9..84aa19aedeb 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -1855,7 +1855,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { diag.span_suggestion( span, &format!( - "you might have meant to use field `{}` of type `{}`", + "you might have meant to use field `{}` whose type is `{}`", name, ty ), suggestion, diff --git a/src/test/ui/suggestions/field-access.fixed b/src/test/ui/suggestions/field-access.fixed index 05a4a0eb126..ed9aef6e374 100644 --- a/src/test/ui/suggestions/field-access.fixed +++ b/src/test/ui/suggestions/field-access.fixed @@ -18,17 +18,17 @@ union Foo { fn main() { let a = A { b: B::Fst }; if let B::Fst = a.b {}; //~ ERROR mismatched types [E0308] - //~^ HELP you might have meant to use field `b` of type `B` + //~^ HELP you might have meant to use field `b` whose type is `B` match a.b { - //~^ HELP you might have meant to use field `b` of type `B` - //~| HELP you might have meant to use field `b` of type `B` + //~^ HELP you might have meant to use field `b` whose type is `B` + //~| HELP you might have meant to use field `b` whose type is `B` B::Fst => (), //~ ERROR mismatched types [E0308] B::Snd => (), //~ ERROR mismatched types [E0308] } let foo = Foo { bar: 42 }; match unsafe { foo.bar } { - //~^ HELP you might have meant to use field `bar` of type `u32` + //~^ HELP you might have meant to use field `bar` whose type is `u32` 1u32 => (), //~ ERROR mismatched types [E0308] _ => (), } diff --git a/src/test/ui/suggestions/field-access.rs b/src/test/ui/suggestions/field-access.rs index ad23c0ffa2e..d80488e8a45 100644 --- a/src/test/ui/suggestions/field-access.rs +++ b/src/test/ui/suggestions/field-access.rs @@ -18,17 +18,17 @@ union Foo { fn main() { let a = A { b: B::Fst }; if let B::Fst = a {}; //~ ERROR mismatched types [E0308] - //~^ HELP you might have meant to use field `b` of type `B` + //~^ HELP you might have meant to use field `b` whose type is `B` match a { - //~^ HELP you might have meant to use field `b` of type `B` - //~| HELP you might have meant to use field `b` of type `B` + //~^ HELP you might have meant to use field `b` whose type is `B` + //~| HELP you might have meant to use field `b` whose type is `B` B::Fst => (), //~ ERROR mismatched types [E0308] B::Snd => (), //~ ERROR mismatched types [E0308] } let foo = Foo { bar: 42 }; match foo { - //~^ HELP you might have meant to use field `bar` of type `u32` + //~^ HELP you might have meant to use field `bar` whose type is `u32` 1u32 => (), //~ ERROR mismatched types [E0308] _ => (), } diff --git a/src/test/ui/suggestions/field-access.stderr b/src/test/ui/suggestions/field-access.stderr index aad9872032a..b113b3746d8 100644 --- a/src/test/ui/suggestions/field-access.stderr +++ b/src/test/ui/suggestions/field-access.stderr @@ -9,7 +9,7 @@ LL | if let B::Fst = a {}; | | | expected struct `A`, found enum `B` | -help: you might have meant to use field `b` of type `B` +help: you might have meant to use field `b` whose type is `B` | LL | if let B::Fst = a.b {}; | ^^^ @@ -26,7 +26,7 @@ LL | match a { LL | B::Fst => (), | ^^^^^^ expected struct `A`, found enum `B` | -help: you might have meant to use field `b` of type `B` +help: you might have meant to use field `b` whose type is `B` | LL | match a.b { | ^^^ @@ -43,7 +43,7 @@ LL | match a { LL | B::Snd => (), | ^^^^^^ expected struct `A`, found enum `B` | -help: you might have meant to use field `b` of type `B` +help: you might have meant to use field `b` whose type is `B` | LL | match a.b { | ^^^ @@ -57,7 +57,7 @@ LL | LL | 1u32 => (), | ^^^^ expected union `Foo`, found `u32` | -help: you might have meant to use field `bar` of type `u32` +help: you might have meant to use field `bar` whose type is `u32` | LL | match unsafe { foo.bar } { | ^^^^^^^^^^^^^^^^^^ |
