-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Tweak suggestions when using incorrect type of enum literal #127891
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,8 @@ LL | let _x = (S { x: 1.0, y: 2.0 }, S { x: 3.0, y: 4.0 }); | |
| | ||
help: `S` is a tuple struct, use the appropriate syntax | ||
| | ||
LL | let _x = (S(/* fields */), S { x: 3.0, y: 4.0 }); | ||
| ~~~~~~~~~~~~~~~ | ||
LL | let _x = (S(/* f32 */, /* f32 */), S { x: 3.0, y: 4.0 }); | ||
| ~~~~~~~~~~~~~~~~~~~~~~~ | ||
Comment on lines
10
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @nnethercote this is a case where the "reuse the literal values that were already there" gets harder: should it have been There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm guessing these help suggestions aren't required to be 100% correct, right? Though of course we want them to be as close to 100% as reasonable. So I would answer There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think if we ever handle this case, I'd only hazard a guess on moving existing code when there is no ambiguity, and leave the comment placeholder for cases like this one so that the user has to make a determination manually (with IDEs a user could accidentally accept a suggestion without noticing the subtlety of what happened). |
||
|
||
error[E0560]: struct `S` has no field named `y` | ||
--> $DIR/nested-non-tuple-tuple-struct.rs:8:27 | ||
|
@@ -23,8 +23,8 @@ LL | let _x = (S { x: 1.0, y: 2.0 }, S { x: 3.0, y: 4.0 }); | |
| | ||
help: `S` is a tuple struct, use the appropriate syntax | ||
| | ||
LL | let _x = (S(/* fields */), S { x: 3.0, y: 4.0 }); | ||
| ~~~~~~~~~~~~~~~ | ||
LL | let _x = (S(/* f32 */, /* f32 */), S { x: 3.0, y: 4.0 }); | ||
| ~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
error[E0560]: struct `S` has no field named `x` | ||
--> $DIR/nested-non-tuple-tuple-struct.rs:8:41 | ||
|
@@ -37,8 +37,8 @@ LL | let _x = (S { x: 1.0, y: 2.0 }, S { x: 3.0, y: 4.0 }); | |
| | ||
help: `S` is a tuple struct, use the appropriate syntax | ||
| | ||
LL | let _x = (S { x: 1.0, y: 2.0 }, S(/* fields */)); | ||
| ~~~~~~~~~~~~~~~ | ||
LL | let _x = (S { x: 1.0, y: 2.0 }, S(/* f32 */, /* f32 */)); | ||
| ~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
error[E0560]: struct `S` has no field named `y` | ||
--> $DIR/nested-non-tuple-tuple-struct.rs:8:49 | ||
|
@@ -51,8 +51,8 @@ LL | let _x = (S { x: 1.0, y: 2.0 }, S { x: 3.0, y: 4.0 }); | |
| | ||
help: `S` is a tuple struct, use the appropriate syntax | ||
| | ||
LL | let _x = (S { x: 1.0, y: 2.0 }, S(/* fields */)); | ||
| ~~~~~~~~~~~~~~~ | ||
LL | let _x = (S { x: 1.0, y: 2.0 }, S(/* f32 */, /* f32 */)); | ||
| ~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
error[E0559]: variant `E::V` has no field named `x` | ||
--> $DIR/nested-non-tuple-tuple-struct.rs:13:22 | ||
|
@@ -65,8 +65,8 @@ LL | let _y = (E::V { x: 1.0, y: 2.0 }, E::V { x: 3.0, y: 4.0 }); | |
| | ||
help: `E::V` is a tuple variant, use the appropriate syntax | ||
| | ||
LL | let _y = (E::V(/* fields */), E::V { x: 3.0, y: 4.0 }); | ||
| ~~~~~~~~~~~~~~~~~~ | ||
LL | let _y = (E::V(/* f32 */, /* f32 */), E::V { x: 3.0, y: 4.0 }); | ||
| ~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
error[E0559]: variant `E::V` has no field named `y` | ||
--> $DIR/nested-non-tuple-tuple-struct.rs:13:30 | ||
|
@@ -79,8 +79,8 @@ LL | let _y = (E::V { x: 1.0, y: 2.0 }, E::V { x: 3.0, y: 4.0 }); | |
| | ||
help: `E::V` is a tuple variant, use the appropriate syntax | ||
| | ||
LL | let _y = (E::V(/* fields */), E::V { x: 3.0, y: 4.0 }); | ||
| ~~~~~~~~~~~~~~~~~~ | ||
LL | let _y = (E::V(/* f32 */, /* f32 */), E::V { x: 3.0, y: 4.0 }); | ||
| ~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
error[E0559]: variant `E::V` has no field named `x` | ||
--> $DIR/nested-non-tuple-tuple-struct.rs:13:47 | ||
|
@@ -93,8 +93,8 @@ LL | let _y = (E::V { x: 1.0, y: 2.0 }, E::V { x: 3.0, y: 4.0 }); | |
| | ||
help: `E::V` is a tuple variant, use the appropriate syntax | ||
| | ||
LL | let _y = (E::V { x: 1.0, y: 2.0 }, E::V(/* fields */)); | ||
| ~~~~~~~~~~~~~~~~~~ | ||
LL | let _y = (E::V { x: 1.0, y: 2.0 }, E::V(/* f32 */, /* f32 */)); | ||
| ~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
error[E0559]: variant `E::V` has no field named `y` | ||
--> $DIR/nested-non-tuple-tuple-struct.rs:13:55 | ||
|
@@ -107,8 +107,8 @@ LL | let _y = (E::V { x: 1.0, y: 2.0 }, E::V { x: 3.0, y: 4.0 }); | |
| | ||
help: `E::V` is a tuple variant, use the appropriate syntax | ||
| | ||
LL | let _y = (E::V { x: 1.0, y: 2.0 }, E::V(/* fields */)); | ||
| ~~~~~~~~~~~~~~~~~~ | ||
LL | let _y = (E::V { x: 1.0, y: 2.0 }, E::V(/* f32 */, /* f32 */)); | ||
| ~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
error: aborting due to 8 previous errors | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one's a little confusing because
()
is the name of the type and its one value. But it's probably not worth specializing it to removes the comment markers.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have a "Give us a default value for this type" logic. I do think that this and others are edge cases that we can ignore for now.