-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Suggests turbofish in patterns #114300
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
Suggests turbofish in patterns #114300
Changes from 1 commit
049c728
89b2fe7
f5243d2
41e85c3
8c8af6c
dce7e87
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
enum E<T> { | ||
A(T) | ||
} | ||
|
||
fn main() { | ||
match E::<i32>::A(1) { | ||
E<i32>::A(v) => { //~ ERROR generic args in patterns require the turbofish syntax | ||
println!("{v:?}"); | ||
}, | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
error: generic args in patterns require the turbofish syntax | ||
--> $DIR/issue-114112.rs:7:10 | ||
| | ||
LL | E<i32>::A(v) => { | ||
| ^ | ||
| | ||
help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments | ||
| | ||
LL | E::<i32>::A(v) => { | ||
| ++ | ||
|
||
error: aborting due to previous error | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
fn main() { | ||
let caller<F> = |f: F| //~ ERROR expected one of `:`, `;`, `=`, `@`, or `|`, found `<` | ||
let caller<F> = |f: F| //~ ERROR generic args in patterns require the turbofish syntax | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at this error, the suggestion we should be giving is to add a type, but don't know how hard it would be to change. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Like function parameters, maybe we can also suggest There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I think the later is the better suggestion (particularly if the rest can be parsed as a type until |
||
where F: Fn() -> i32 | ||
{ | ||
let x = f(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
error: expected one of `:`, `;`, `=`, `@`, or `|`, found `<` | ||
error: generic args in patterns require the turbofish syntax | ||
--> $DIR/issue-22647.rs:2:15 | ||
| | ||
LL | let caller<F> = |f: F| | ||
| ^ expected one of `:`, `;`, `=`, `@`, or `|` | ||
| ^ | ||
| | ||
help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments | ||
| | ||
LL | let caller::<F> = |f: F| | ||
| ++ | ||
|
||
error: aborting due to previous error | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
error: expected one of `:`, `;`, `=`, `@`, or `|`, found `<` | ||
error: generic args in patterns require the turbofish syntax | ||
--> $DIR/issue-22712.rs:6:12 | ||
| | ||
LL | let Foo<Vec<u8>> | ||
| ^ expected one of `:`, `;`, `=`, `@`, or `|` | ||
| ^ | ||
| | ||
help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments | ||
| | ||
LL | let Foo::<Vec<u8>> | ||
| ++ | ||
|
||
error: aborting due to previous error | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
error: expected one of `=>`, `@`, `if`, or `|`, found `<` | ||
error: generic args in patterns require the turbofish syntax | ||
--> $DIR/pat-lt-bracket-3.rs:6:16 | ||
| | ||
LL | Foo<T>(x, y) => { | ||
| ^ expected one of `=>`, `@`, `if`, or `|` | ||
| ^ | ||
| | ||
help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments | ||
| | ||
LL | Foo::<T>(x, y) => { | ||
| ++ | ||
|
||
error: aborting due to previous error | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
error: expected one of `=>`, `@`, `if`, or `|`, found `<` | ||
error: generic args in patterns require the turbofish syntax | ||
--> $DIR/pat-lt-bracket-4.rs:8:12 | ||
| | ||
LL | Foo<T>::A(value) => value, | ||
| ^ expected one of `=>`, `@`, `if`, or `|` | ||
| ^ | ||
| | ||
help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments | ||
| | ||
LL | Foo::<T>::A(value) => value, | ||
| ++ | ||
|
||
error: aborting due to previous error | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
// This test checks that a suggestion to add a `self: ` parameter name is provided | ||
// to functions where this is applicable. | ||
|
||
pub fn foo(Box<Self>) { } | ||
//~^ ERROR expected one of `:`, `@`, or `|`, found `<` | ||
pub fn foo(Box<Self>) { } //~ ERROR generic args in patterns require the turbofish syntax | ||
|
||
struct Bar; | ||
|
||
impl Bar { | ||
fn bar(Box<Self>) { } | ||
//~^ ERROR expected one of `:`, `@`, or `|`, found `<` | ||
fn bar(Box<Self>) { } //~ ERROR generic args in patterns require the turbofish syntax | ||
} | ||
|
||
fn main() { } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,24 @@ | ||
error: expected one of `:`, `@`, or `|`, found `<` | ||
error: generic args in patterns require the turbofish syntax | ||
--> $DIR/issue-64252-self-type.rs:4:15 | ||
| | ||
LL | pub fn foo(Box<Self>) { } | ||
| ^ expected one of `:`, `@`, or `|` | ||
| ^ | ||
| | ||
= note: anonymous parameters are removed in the 2018 edition (see RFC 1685) | ||
help: if this is a `self` type, give it a parameter name | ||
help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments | ||
| | ||
LL | pub fn foo(self: Box<Self>) { } | ||
| +++++ | ||
help: if this is a type, explicitly ignore the parameter name | ||
| | ||
LL | pub fn foo(_: Box<Self>) { } | ||
| ++ | ||
mu001999 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
LL | pub fn foo(Box::<Self>) { } | ||
| ++ | ||
|
||
error: expected one of `:`, `@`, or `|`, found `<` | ||
--> $DIR/issue-64252-self-type.rs:10:15 | ||
error: generic args in patterns require the turbofish syntax | ||
--> $DIR/issue-64252-self-type.rs:9:15 | ||
| | ||
LL | fn bar(Box<Self>) { } | ||
| ^ expected one of `:`, `@`, or `|` | ||
| | ||
= note: anonymous parameters are removed in the 2018 edition (see RFC 1685) | ||
help: if this is a `self` type, give it a parameter name | ||
| ^ | ||
| | ||
LL | fn bar(self: Box<Self>) { } | ||
| +++++ | ||
help: if this is a type, explicitly ignore the parameter name | ||
help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments | ||
| | ||
LL | fn bar(_: Box<Self>) { } | ||
| ++ | ||
LL | fn bar(Box::<Self>) { } | ||
| ++ | ||
|
||
error: aborting due to 2 previous errors | ||
|
Uh oh!
There was an error while loading. Please reload this page.