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

Add suggestion for incorrect field syntax. #57863

Merged
merged 1 commit into from Jan 25, 2019

Conversation

Projects
None yet
6 participants
@davidtwco
Copy link
Member

davidtwco commented Jan 23, 2019

Fixes #57684.

This commit adds a suggestion when a = character is used when
specifying the value of a field in a struct constructor incorrectly
instead of a : character.

r? @estebank

@davidtwco

This comment has been minimized.

Copy link
Member Author

davidtwco commented Jan 23, 2019

Sorry for another addition to your review queue @estebank. Not sure if this is the approach we want to take with this issue or if it is too large a change for the potential gain - if we just want to change to keep the existing error but add : (as below) then I can revisit this and do that:

error: expected one of `:`, `,` or `}`, found `=` 

@davidtwco davidtwco force-pushed the davidtwco:issue-57684 branch from 93b7b25 to ef261e0 Jan 23, 2019

Show resolved Hide resolved src/libsyntax/parse/parser.rs Outdated

@davidtwco davidtwco force-pushed the davidtwco:issue-57684 branch from ef261e0 to 517840b Jan 23, 2019

@estebank

This comment has been minimized.

Copy link
Contributor

estebank commented Jan 23, 2019

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 23, 2019

📌 Commit 517840b has been approved by estebank

@estebank

This comment has been minimized.

Copy link
Contributor

estebank commented Jan 23, 2019

@bors r-

Show resolved Hide resolved src/libsyntax/parse/parser.rs Outdated

@davidtwco davidtwco force-pushed the davidtwco:issue-57684 branch from 517840b to ac0d342 Jan 23, 2019

@davidtwco

This comment has been minimized.

Copy link
Member Author

davidtwco commented Jan 23, 2019

Since only ':' is expected, this should just state "expected :, found =".

I leant toward matching the structure of the existing messages - expected one of X, found Y instead of omitting the "one of". I can change this if we prefer otherwise.

@ljedrz

This comment has been minimized.

Copy link
Contributor

ljedrz commented Jan 23, 2019

I just feel this might sound like a piece of the error is missing, but it's not a big deal, especially if this is an existing convention for singular items (in which case it might be a better idea to potentially adjust the convention).

@estebank

This comment has been minimized.

Copy link
Contributor

estebank commented Jan 23, 2019

Yeah, sorry about that it was my typo, my bad. It should be "expected :, found =", I had originally written "expected one of :, , or }, found =" and chose against that to make it even clearer for this case in particular. Can you change it to that?

Add suggestion for incorrect field syntax.
This commit adds a suggestion when a `=` character is used when
specifying the value of a field in a struct constructor incorrectly
instead of a `:` character.

@davidtwco davidtwco force-pushed the davidtwco:issue-57684 branch from ac0d342 to f14d007 Jan 23, 2019

@davidtwco

This comment has been minimized.

Copy link
Member Author

davidtwco commented Jan 23, 2019

@estebank should be fixed now.

@estebank

This comment has been minimized.

Copy link
Contributor

estebank commented Jan 23, 2019

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 23, 2019

📌 Commit f14d007 has been approved by estebank

Centril added a commit to Centril/rust that referenced this pull request Jan 24, 2019

Rollup merge of rust-lang#57863 - davidtwco:issue-57684, r=estebank
Add suggestion for incorrect field syntax.

Fixes rust-lang#57684.

This commit adds a suggestion when a `=` character is used when
specifying the value of a field in a struct constructor incorrectly
instead of a `:` character.

r? @estebank

bors added a commit that referenced this pull request Jan 24, 2019

Auto merge of #57874 - Centril:rollup, r=Centril
Rollup of 9 pull requests

Successful merges:

 - #57066 (Fix race condition when emitting stored diagnostics)
 - #57606 (Get rid of the fake stack frame for reading from constants)
 - #57734 (Fix evaluating trivial drop glue in constants)
 - #57846 (rustdoc: fix ICE from loading proc-macro stubs)
 - #57860 (Add os::fortanix_sgx::ffi module)
 - #57861 (Don't export table by default in wasm)
 - #57863 (Add suggestion for incorrect field syntax.)
 - #57867 (Fix std::future::from_generator documentation)
 - #57873 (Stabilize no_panic_pow)

Failed merges:

r? @ghost

bors added a commit that referenced this pull request Jan 24, 2019

Auto merge of #57874 - Centril:rollup, r=Centril
Rollup of 9 pull requests

Successful merges:

 - #57066 (Fix race condition when emitting stored diagnostics)
 - #57606 (Get rid of the fake stack frame for reading from constants)
 - #57734 (Fix evaluating trivial drop glue in constants)
 - #57846 (rustdoc: fix ICE from loading proc-macro stubs)
 - #57860 (Add os::fortanix_sgx::ffi module)
 - #57861 (Don't export table by default in wasm)
 - #57863 (Add suggestion for incorrect field syntax.)
 - #57867 (Fix std::future::from_generator documentation)
 - #57873 (Stabilize no_panic_pow)

Failed merges:

r? @ghost

Centril added a commit to Centril/rust that referenced this pull request Jan 24, 2019

Rollup merge of rust-lang#57863 - davidtwco:issue-57684, r=estebank
Add suggestion for incorrect field syntax.

Fixes rust-lang#57684.

This commit adds a suggestion when a `=` character is used when
specifying the value of a field in a struct constructor incorrectly
instead of a `:` character.

r? @estebank

bors added a commit that referenced this pull request Jan 24, 2019

Auto merge of #57879 - Centril:rollup, r=Centril
Rollup of 9 pull requests

Successful merges:

 - #57380 (Fix Instant/Duration math precision & associativity on Windows)
 - #57606 (Get rid of the fake stack frame for reading from constants)
 - #57803 (Several changes to libunwind for SGX target)
 - #57846 (rustdoc: fix ICE from loading proc-macro stubs)
 - #57860 (Add os::fortanix_sgx::ffi module)
 - #57861 (Don't export table by default in wasm)
 - #57863 (Add suggestion for incorrect field syntax.)
 - #57867 (Fix std::future::from_generator documentation)
 - #57873 (Stabilize no_panic_pow)

Failed merges:

r? @ghost

@bors bors merged commit f14d007 into rust-lang:master Jan 25, 2019

@davidtwco davidtwco deleted the davidtwco:issue-57684 branch Jan 25, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment