1
Fork 0

Rollup merge of #81655 - matsujika:suggest-accessing-field-rewording, r=estebank

Improve wording of suggestion about accessing field

Follow-up to #81504

The compiler at this moment suggests "you might have meant to use field `b` of type `B`", sounding like it's type `B` which has the field `b`.
r? ```@estebank```
This commit is contained in:
Jack Huey 2021-02-02 16:01:48 -05:00 committed by GitHub
commit 7edb3ad39b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 13 deletions

View file

@ -1855,7 +1855,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
diag.span_suggestion( diag.span_suggestion(
span, span,
&format!( &format!(
"you might have meant to use field `{}` of type `{}`", "you might have meant to use field `{}` whose type is `{}`",
name, ty name, ty
), ),
suggestion, suggestion,

View file

@ -18,17 +18,17 @@ union Foo {
fn main() { fn main() {
let a = A { b: B::Fst }; let a = A { b: B::Fst };
if let B::Fst = a.b {}; //~ ERROR mismatched types [E0308] 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 { match a.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` of type `B` //~| HELP you might have meant to use field `b` whose type is `B`
B::Fst => (), //~ ERROR mismatched types [E0308] B::Fst => (), //~ ERROR mismatched types [E0308]
B::Snd => (), //~ ERROR mismatched types [E0308] B::Snd => (), //~ ERROR mismatched types [E0308]
} }
let foo = Foo { bar: 42 }; let foo = Foo { bar: 42 };
match unsafe { foo.bar } { 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] 1u32 => (), //~ ERROR mismatched types [E0308]
_ => (), _ => (),
} }

View file

@ -18,17 +18,17 @@ union Foo {
fn main() { fn main() {
let a = A { b: B::Fst }; let a = A { b: B::Fst };
if let B::Fst = a {}; //~ ERROR mismatched types [E0308] 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 { match a {
//~^ 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` of type `B` //~| HELP you might have meant to use field `b` whose type is `B`
B::Fst => (), //~ ERROR mismatched types [E0308] B::Fst => (), //~ ERROR mismatched types [E0308]
B::Snd => (), //~ ERROR mismatched types [E0308] B::Snd => (), //~ ERROR mismatched types [E0308]
} }
let foo = Foo { bar: 42 }; let foo = Foo { bar: 42 };
match foo { 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] 1u32 => (), //~ ERROR mismatched types [E0308]
_ => (), _ => (),
} }

View file

@ -9,7 +9,7 @@ LL | if let B::Fst = a {};
| | | |
| expected struct `A`, found enum `B` | 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 {}; LL | if let B::Fst = a.b {};
| ^^^ | ^^^
@ -26,7 +26,7 @@ LL | match a {
LL | B::Fst => (), LL | B::Fst => (),
| ^^^^^^ expected struct `A`, found enum `B` | ^^^^^^ 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 { LL | match a.b {
| ^^^ | ^^^
@ -43,7 +43,7 @@ LL | match a {
LL | B::Snd => (), LL | B::Snd => (),
| ^^^^^^ expected struct `A`, found enum `B` | ^^^^^^ 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 { LL | match a.b {
| ^^^ | ^^^
@ -57,7 +57,7 @@ LL |
LL | 1u32 => (), LL | 1u32 => (),
| ^^^^ expected union `Foo`, found `u32` | ^^^^ 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 } { LL | match unsafe { foo.bar } {
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^