Uh oh!
There was an error while loading. Please reload this page.
Tweak self arg not as first argument of a method diagnostic - #61087
Conversation
rust-highfive
commented
May 23, 2019
r? @pnkfelix (rust_highfive has picked a reviewer for you, use r? to override) |
estebank
commented
May 23, 2019
r? @Centril parser code shuffle |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I'll do a more thorough review later. @estebank Can you split the "move stuff" and "change diagnostics output" into separate commits and then a third commit for addressing review comments? |
There was a problem hiding this comment.
Refactor out b.push_str(connective)?
Uh oh!
There was an error while loading. Please reload this page.
@Centril addressed all review comments but one, which I think should be part of a separate PR cleaning up all the times this one-or-more string handling has been done in the parser. |
This comment has been minimized.
This comment has been minimized.
b116e3b to
0230fc3Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Why not set the TyKind to what it would have been had it been in the right position?
There was a problem hiding this comment.
Because we don't know wether this is any of the following:
- a function with an arbitrary argument called
self - a method with
selfnot at the start - a method with
selfat the start and a secondself
I thought it'd be safer to just mark it as TyKind::Err and avoid potential incorrect diagnostics elsewhere. I prefer to be silent on actual problems (given other errors are emitted) over being too verbose with possibly unnecessary errors.
There was a problem hiding this comment.
Good insight; on the other hand, I'd say that self not at the start is probabilistically more correct than the others... but, in any case, let's land this as-is. :)
Mention that `self` is only valid on "associated functions"
```
error: unexpected `self` argument in function
--> $DIR/self-in-function-arg.rs:1:15
|
LL | fn foo(x:i32, self: i32) -> i32 { self }
| ^^^^ not valid as function argument
|
= note: `self` is only valid as the first argument of an associated function
```
When it is a method, mention it must be first
```
error: unexpected `self` argument in function
--> $DIR/trait-fn.rs:4:20
|
LL | fn c(foo: u32, self) {}
| ^^^^ must be the first associated function argument
```Move a bunch of error recovery methods to `diagnostics.rs` away from `parser.rs`.
estebank
commented
May 25, 2019
@bors r=Centril |
bors
commented
May 25, 2019
📌 Commit 4e68ddc has been approved by |
Tweak `self` arg not as first argument of a method diagnostic
Mention that `self` is only valid on "associated functions"
```
error: unexpected `self` argument in function
--> $DIR/self-in-function-arg.rs:1:15
|
LL | fn foo(x:i32, self: i32) -> i32 { self }
| ^^^^ not valid as function argument
|
= note: `self` is only valid as the first argument of an associated function
```
When it is a method, mention it must be first
```
error: unexpected `self` argument in function
--> $DIR/trait-fn.rs:4:20
|
LL | fn c(foo: u32, self) {}
| ^^^^ must be the first associated function argument
```
Move a bunch of error recovery methods to `diagnostics.rs` away from `parser.rs`.
Fixrust-lang#51547. CC rust-lang#60015.Tweak `self` arg not as first argument of a method diagnostic
Mention that `self` is only valid on "associated functions"
```
error: unexpected `self` argument in function
--> $DIR/self-in-function-arg.rs:1:15
|
LL | fn foo(x:i32, self: i32) -> i32 { self }
| ^^^^ not valid as function argument
|
= note: `self` is only valid as the first argument of an associated function
```
When it is a method, mention it must be first
```
error: unexpected `self` argument in function
--> $DIR/trait-fn.rs:4:20
|
LL | fn c(foo: u32, self) {}
| ^^^^ must be the first associated function argument
```
Move a bunch of error recovery methods to `diagnostics.rs` away from `parser.rs`.
Fixrust-lang#51547. CC rust-lang#60015.Rollup of 9 pull requests Successful merges: - #61087 (Tweak `self` arg not as first argument of a method diagnostic) - #61114 (Vec: avoid creating slices to the elements) - #61144 (Suggest borrowing for loop head on move error) - #61149 (Fix spelling in release notes) - #61161 (MaybeUninit doctest: remove unnecessary type ascription) - #61173 (Auto-derive Encode and Decode implementations of DefPathTable) - #61184 (Add additional trace statements to the const propagator) - #61189 (Turn turbo 🐟 🍨 into an error) - #61193 (Add comment to explain why we change the layout for Projection) Failed merges: r? @ghost
Mention that
selfis only valid on "associated functions"When it is a method, mention it must be first
Move a bunch of error recovery methods to
diagnostics.rsaway fromparser.rs.Fix#51547. CC #60015.