Skip to content

Suggest correct cast for struct fields with shorthand syntax - #57769

Merged
bors merged 2 commits into
rust-lang:masterfrom
estebank:cast-suggestion-struct-field
Jan 21, 2019
Merged

Suggest correct cast for struct fields with shorthand syntax#57769
bors merged 2 commits into
rust-lang:masterfrom
estebank:cast-suggestion-struct-field

Conversation

@estebank

Copy link
Copy Markdown
Contributor
error[E0308]: mismatched types
--> $DIR/type-mismatch-struct-field-shorthand.rs:8:19
|
LL | let _ = RGB { r, g, b };
| ^ expected f64, found f32
help: you can cast an `f32` to `f64` in a lossless way
|
LL | let _ = RGB { r: r.into(), g, b };
| ^^^^^^^^^^^

Fix#52497.

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @matthewjasper

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 20, 2019
Comment threadsrc/librustc_typeck/check/demand.rs
@matthewjasper

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Jan 20, 2019

Copy link
Copy Markdown
Collaborator

📌 Commit 5b44b3c has been approved by matthewjasper

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 20, 2019
Centril added a commit to Centril/rust that referenced this pull request Jan 21, 2019
…ld, r=matthewjasper
Suggest correct cast for struct fields with shorthand syntax
```
error[E0308]: mismatched types
--> $DIR/type-mismatch-struct-field-shorthand.rs:8:19
|
LL | let _ = RGB { r, g, b };
| ^ expected f64, found f32
help: you can cast an `f32` to `f64` in a lossless way
|
LL | let _ = RGB { r: r.into(), g, b };
| ^^^^^^^^^^^
```
Fixrust-lang#52497.
@CentrilCentril mentioned this pull request Jan 21, 2019
bors added a commit that referenced this pull request Jan 21, 2019
Rollup of 5 pull requests
Successful merges:
- #56796 (Change bounds on `TryFrom` blanket impl to use `Into` instead of `From`)
- #57768 (Continue parsing after parent type args and suggest using angle brackets)
- #57769 (Suggest correct cast for struct fields with shorthand syntax)
- #57783 (Add "dereference boxed value" suggestion.)
- #57784 (Add span for bad doc comment)
Failed merges:
r? @ghost
@bors
bors merged commit 5b44b3c into rust-lang:masterJan 21, 2019
@estebank
estebank deleted the cast-suggestion-struct-field branch November 9, 2023 05:20
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@estebank@rust-highfive@matthewjasper@bors