Skip to content

Improve wording of suggestion about accessing field #81655

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/suggestions/field-access.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -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]
_ => (),
}
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/suggestions/field-access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
_ => (),
}
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/suggestions/field-access.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};
| ^^^
Expand All @@ -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 {
| ^^^
Expand All @@ -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 {
| ^^^
Expand All @@ -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 } {
| ^^^^^^^^^^^^^^^^^^
Expand Down