Skip to content
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

Fix try wrapping expression in variant suggestion with struct field shorthand #92808

Merged

Conversation

compiler-errors
Copy link
Member

Fixes a broken suggestion: playground

before:

error[E0308]: mismatched types
 --> src/main.rs:7:19
  |
7 |     let x = Foo { bar };
  |                   ^^^ expected enum `Option`, found integer
  |
  = note: expected enum `Option<i32>`
             found type `{integer}`
help: try wrapping the expression in `Some`
  |
7 |     let x = Foo { Some(bar) };
  |                   +++++   +

after:

error[E0308]: mismatched types
 --> src/main.rs:7:19
  |
7 |     let x = Foo { bar };
  |                   ^^^ expected enum `Option`, found integer
  |
  = note: expected enum `Option<i32>`
             found type `{integer}`
help: try wrapping the expression in `Some`
  |
7 |     let x = Foo { bar: Some(bar) };
  |                   ~~~~~~~~~~~~~~

r? @m-ou-se
since you touched the code last in #91080

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jan 12, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 12, 2022
@compiler-errors compiler-errors force-pushed the wrap-struct-shorthand-field-in-variant branch from 469ed0b to 5dfaf5f Compare January 13, 2022 22:04
@compiler-errors
Copy link
Member Author

r? @camelid

I fixed those places you asked for, and did some drive-by fixes as well.

@rust-highfive rust-highfive assigned camelid and unassigned m-ou-se Jan 13, 2022
@camelid
Copy link
Member

camelid commented Jan 13, 2022

The error output looks really nice, but unfortunately I don't think I have time to review the rest of this PR :)

r? @davidtwco

@rust-highfive rust-highfive assigned davidtwco and unassigned camelid Jan 13, 2022
@bors

This comment has been minimized.

@compiler-errors compiler-errors force-pushed the wrap-struct-shorthand-field-in-variant branch from 5dfaf5f to 272fb23 Compare January 15, 2022 04:34
Copy link
Member

@davidtwco davidtwco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay in reviewing, this looks great.

@davidtwco
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jan 16, 2022

📌 Commit 272fb23 has been approved by davidtwco

@bors bors 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 16, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 17, 2022
…askrgr

Rollup of 10 pull requests

Successful merges:

 - rust-lang#92795 (Link sidebar "location" heading to top of page)
 - rust-lang#92799 (Remove some unnecessary uses of `FieldDef::ident`)
 - rust-lang#92808 (Fix `try wrapping expression in variant` suggestion with struct field shorthand)
 - rust-lang#92819 (rustdoc: remove hand-rolled isatty)
 - rust-lang#92876 (Fix suggesting turbofish with lifetime arguments)
 - rust-lang#92921 (Rename Printer constructor from mk_printer() to Printer::new())
 - rust-lang#92937 (rustdoc: Add missing dot separator)
 - rust-lang#92953 (Copy an example to PartialOrd as well)
 - rust-lang#92977 (Docs: recommend VecDeque instead of Vec::remove(0))
 - rust-lang#92981 (fix const_ptr_offset_from tracking issue)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit ff1b653 into rust-lang:master Jan 17, 2022
@rustbot rustbot added this to the 1.60.0 milestone Jan 17, 2022
@compiler-errors compiler-errors deleted the wrap-struct-shorthand-field-in-variant branch April 7, 2022 04:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants