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

Point out correct turbofish usage on Foo<Bar<Baz>> #40500

Merged
merged 1 commit into from
Mar 17, 2017

Conversation

estebank
Copy link
Contributor

Whenever we parse a chain of binary operations, as long as the first
operation is < and the subsequent operations are either > or <,
present the following diagnostic help:

use `::<...>` instead of `<...>` if you meant to specify type arguments

This will lead to spurious recommendations on situations like
2 < 3 < 4 but should be clear from context that the help doesn't apply
in that case.

Fixes #40396.

@rust-highfive
Copy link
Collaborator

r? @pnkfelix

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

@estebank
Copy link
Contributor Author

CC @jonathandturner @GuillaumeGomez @jorendorff thoughts?

@sophiajt
Copy link
Contributor

I'm very 👍 this, so please don't take this as a blocking comment. I was just thinking about how we could make this a little clearer. Would a snippet help?

error: chained comparison operators require parentheses
  --> file.rs:16:25
   |
16 |     println!("{:?}", Vec<i32>::new());
   |                         ^^^^^^^ incorrect type argument syntax
   |
hint: use `::<...>` instead of `<...>` if you meant to specify type arguments
16 |     println!("{:?}", Vec::<i32>::new());
   |                         ^^^^^^^^^ 

Not sure which is better, but figured it was worth a look to see the other approach.

@estebank
Copy link
Contributor Author

@jonathandturner I love the idea, but in order to provide those suggestions reliably we would have to parse the line in a different way to how we're doing it now, make sure we're properly closing all opening brackets (and if the code isn't, do it ourselves) and make sure that whatever results is actually a valid type and valid code in this context. Should we open a ticket for that task? I'd love to do that at one point, but I think merging this gets us 80% there with very little effort.

@sophiajt
Copy link
Contributor

@estebank - absolutely agree. Like I said, don't block on my suggestion. Let's improve things with your design and if we can go a few percent better later on, then we can do that later.

@GuillaumeGomez
Copy link
Member

Awesome! @jonathandturner's suggestion is good. Might be worth opening an issue to implement it as well.

@pnkfelix
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Mar 14, 2017

📌 Commit 699bfa0 has been approved by pnkfelix

@pnkfelix
Copy link
Member

@bors r-

Travis failure looks legit.

Whenever we parse a chain of binary operations, as long as the first
operation is `<` and the subsequent operations are either `>` or `<`,
present the following diagnostic help:

    use `::<...>` instead of `<...>` if you meant to specify type arguments

This will lead to spurious recommendations on situations like
`2 < 3 < 4` but should be clear from context that the help doesn't apply
in that case.
@estebank
Copy link
Contributor Author

@pnkfelix fixed test.

@bors r=pnkfelix

@bors
Copy link
Contributor

bors commented Mar 14, 2017

📌 Commit e3b8550 has been approved by pnkfelix

frewsxcv added a commit to frewsxcv/rust that referenced this pull request Mar 15, 2017
Point out correct turbofish usage on `Foo<Bar<Baz>>`

Whenever we parse a chain of binary operations, as long as the first
operation is `<` and the subsequent operations are either `>` or `<`,
present the following diagnostic help:

    use `::<...>` instead of `<...>` if you meant to specify type arguments

This will lead to spurious recommendations on situations like
`2 < 3 < 4` but should be clear from context that the help doesn't apply
in that case.

Fixes rust-lang#40396.
bors added a commit that referenced this pull request Mar 15, 2017
bors added a commit that referenced this pull request Mar 16, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Mar 17, 2017
Point out correct turbofish usage on `Foo<Bar<Baz>>`

Whenever we parse a chain of binary operations, as long as the first
operation is `<` and the subsequent operations are either `>` or `<`,
present the following diagnostic help:

    use `::<...>` instead of `<...>` if you meant to specify type arguments

This will lead to spurious recommendations on situations like
`2 < 3 < 4` but should be clear from context that the help doesn't apply
in that case.

Fixes rust-lang#40396.
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Mar 17, 2017
Point out correct turbofish usage on `Foo<Bar<Baz>>`

Whenever we parse a chain of binary operations, as long as the first
operation is `<` and the subsequent operations are either `>` or `<`,
present the following diagnostic help:

    use `::<...>` instead of `<...>` if you meant to specify type arguments

This will lead to spurious recommendations on situations like
`2 < 3 < 4` but should be clear from context that the help doesn't apply
in that case.

Fixes rust-lang#40396.
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Mar 17, 2017
Point out correct turbofish usage on `Foo<Bar<Baz>>`

Whenever we parse a chain of binary operations, as long as the first
operation is `<` and the subsequent operations are either `>` or `<`,
present the following diagnostic help:

    use `::<...>` instead of `<...>` if you meant to specify type arguments

This will lead to spurious recommendations on situations like
`2 < 3 < 4` but should be clear from context that the help doesn't apply
in that case.

Fixes rust-lang#40396.
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Mar 17, 2017
Point out correct turbofish usage on `Foo<Bar<Baz>>`

Whenever we parse a chain of binary operations, as long as the first
operation is `<` and the subsequent operations are either `>` or `<`,
present the following diagnostic help:

    use `::<...>` instead of `<...>` if you meant to specify type arguments

This will lead to spurious recommendations on situations like
`2 < 3 < 4` but should be clear from context that the help doesn't apply
in that case.

Fixes rust-lang#40396.
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Mar 17, 2017
Point out correct turbofish usage on `Foo<Bar<Baz>>`

Whenever we parse a chain of binary operations, as long as the first
operation is `<` and the subsequent operations are either `>` or `<`,
present the following diagnostic help:

    use `::<...>` instead of `<...>` if you meant to specify type arguments

This will lead to spurious recommendations on situations like
`2 < 3 < 4` but should be clear from context that the help doesn't apply
in that case.

Fixes rust-lang#40396.
bors added a commit that referenced this pull request Mar 17, 2017
@bors bors merged commit e3b8550 into rust-lang:master Mar 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants