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

Deduplicate :: -> : typo errors #74210

Merged
merged 1 commit into from
Aug 2, 2020
Merged

Conversation

estebank
Copy link
Contributor

@estebank estebank commented Jul 10, 2020

Deduplicate errors caused by the same type ascription typo, including
ones suggested during parsing that would get reported again during
resolve. Fix #70382.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 10, 2020
@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 15, 2020
@estebank
Copy link
Contributor Author

I made some indentation changes in a block, so you might prefer to ignore whitespace in the diff.

@estebank estebank added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 15, 2020
@estebank
Copy link
Contributor Author

(@petrochenkov I can remove the last commit and not handle those cases in this PR)

|
LL | let _ = Foo:A;
| ^ help: write a path separator instead: `::`

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For reference, this is the current output:

error: expected type, found `2`
 --> src/main.rs:6:19
  |
6 |     let _ = Foo:B(2); //~ ERROR expected type
  |                -  ^ expected type
  |                |
  |                help: maybe write a path separator here: `::`
  |
  = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>`

error: expected one of `!`, `(`, `.`, `::`, `;`, `<`, or `?`, found `{`
 --> src/main.rs:9:19
  |
9 |     let _ = Foo:C { x: 1 }; //~ ERROR expected one of
  |                -  ^ expected one of 7 possible tokens
  |                |
  |                help: maybe write a path separator here: `::`
  |
  = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>`

error: expected type, found reserved keyword `box`
 --> src/main.rs:2:25
  |
2 |     let _ = Option:Some(vec![0, 1]); //~ ERROR expected type, found
  |                   -     ^^^^^^^^^^
  |                   |     |
  |                   |     expected type
  |                   |     in this macro invocation
  |                   |     this macro call doesn't expand to a type
  |                   help: maybe write a path separator here: `::`
  |
  = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>`
  = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0423]: expected value, found enum `Option`
 --> src/main.rs:2:13
  |
2 |     let _ = Option:Some(vec![0, 1]); //~ ERROR expected type, found
  |             ^^^^^^
  |
help: try using one of the enum's variants
  |
2 |     let _ = std::option::Option::None:Some(vec![0, 1]); //~ ERROR expected type, found
  |             ^^^^^^^^^^^^^^^^^^^^^^^^^
2 |     let _ = std::option::Option::Some:Some(vec![0, 1]); //~ ERROR expected type, found
  |             ^^^^^^^^^^^^^^^^^^^^^^^^^
help: consider importing one of these items instead
  |
1 | use serde::de::Unexpected::Option;
  |
1 | use serde_value::Unexpected::Option;
  |
1 | use serde_value::Value::Option;
  |

error[E0573]: expected type, found variant `Some`
 --> src/main.rs:2:20
  |
2 |     let _ = Option:Some(vec![0, 1]); //~ ERROR expected type, found
  |                    ^^^^^^^^^^^^^^^^ not a type
  |
help: try using the variant's enum
  |
2 |     let _ = Option:core::option::Option; //~ ERROR expected type, found
  |                    ^^^^^^^^^^^^^^^^^^^^
2 |     let _ = Option:futures_core::core_reexport::option::Option; //~ ERROR expected type, found
  |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 |     let _ = Option:futures_util::core_reexport::option::Option; //~ ERROR expected type, found
  |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 |     let _ = Option:lzw::Bits; //~ ERROR expected type, found
  |                    ^^^^^^^^^
    and 5 other candidates
help: maybe you meant to write a path separator here
  |
2 |     let _ = Option::Some(vec![0, 1]); //~ ERROR expected type, found
  |                   ^^

error[E0423]: expected value, found enum `Foo`
 --> src/main.rs:5:13
  |
5 |     let _ = Foo:A; //~ ERROR expected `::`, found `:`
  |             ^^^
  |
help: try using one of the enum's variants
  |
5 |     let _ = Foo::A:A; //~ ERROR expected `::`, found `:`
  |             ^^^^^^
5 |     let _ = Foo::B:A; //~ ERROR expected `::`, found `:`
  |             ^^^^^^
5 |     let _ = Foo::C:A; //~ ERROR expected `::`, found `:`
  |             ^^^^^^

error[E0412]: cannot find type `A` in this scope
 --> src/main.rs:5:17
  |
5 |     let _ = Foo:A; //~ ERROR expected `::`, found `:`
  |                 ^ not found in this scope
  |
help: there is an enum variant `crate::Foo::A`; try using the variant's enum
  |
5 |     let _ = Foo:crate::Foo; //~ ERROR expected `::`, found `:`
  |                 ^^^^^^^^^^
help: maybe you meant to write a path separator here
  |
5 |     let _ = Foo::A; //~ ERROR expected `::`, found `:`
  |                ^^
help: you might be missing a type parameter
  |
4 | fn qux<A>() {
  |       ^^^

@petrochenkov
Copy link
Contributor

(@petrochenkov I can remove the last commit and not handle those cases in this PR)

Yes, could you split the changes, then I'll get a chance to r+ one of the parts before the return from vacation.

@estebank
Copy link
Contributor Author

I'm offline until Monday, but can do so then. Should I rebase to single commit or into smaller logical changes?

@estebank estebank force-pushed the type-ascriptomatic branch 2 times, most recently from aa8598a to 9958256 Compare July 20, 2020 19:20
@estebank
Copy link
Contributor Author

Rebased onto a single commit.

@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 26, 2020
* Deduplicate type ascription LHS errors
* Remove duplicated `:` -> `::` suggestion from parse error
* Tweak wording to be more accurate
* Modify `current_type_ascription` to reduce span wrangling
* remove now unnecessary match arm
* Add run-rustfix to appropriate tests
@estebank estebank added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 31, 2020
@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Aug 2, 2020

📌 Commit 6ed06b2 has been approved by petrochenkov

@bors bors removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 2, 2020
@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Aug 2, 2020
@bors
Copy link
Contributor

bors commented Aug 2, 2020

⌛ Testing commit 6ed06b2 with merge fd4d151...

@bors
Copy link
Contributor

bors commented Aug 2, 2020

☀️ Test successful - checks-actions, checks-azure
Approved by: petrochenkov
Pushing fd4d151 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Aug 2, 2020
@bors bors merged commit fd4d151 into rust-lang:master Aug 2, 2020
@estebank estebank deleted the type-ascriptomatic branch November 9, 2023 05:16
@cuviper cuviper added this to the 1.47.0 milestone May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: 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.

Incorrect suggestion after #70074
5 participants