Point at : when using it instead of ;#43096
Conversation
|
(rust_highfive has picked a reviewer for you, use r? to override) |
|
☔ The latest upstream changes (presumably #43060) made this pull request unmergeable. Please resolve the merge conflicts. |
There was a problem hiding this comment.
Will it work if a colon was here?
There was a problem hiding this comment.
The output in that case is
error: expected type, found `0`
--> ../../src/test/ui/suggestions/type-ascription-instead-of-statement-end.rs:15:5
|
14 | println!("test"):
| - help: did you mean to use `;` here instead?
15 | 0:
| ^ expecting a type here because of type ascriptionThere was a problem hiding this comment.
this sort of looks funny, perhaps because of the ^ having no label. I think I'd prefer:
error: expected type, found `0`
--> $DIR/type-ascription-instead-of-statement-end.rs:15:5
|
14 | println!("test"):
| - help: did you mean to use a `;` here?
15 | 0;
| ^ expecting a type here because of type ascription
error: aborting due to previous error
ad7c8eb to
a4217cb
Compare
There was a problem hiding this comment.
Huh, this looks strange to me somehow. Why not say "help: did you mean to use ; here?"? I think users might not know that "end the statement" means ; -- but also, I am not sure about this "floating" ; that appears at the end of the sentence.
There was a problem hiding this comment.
The presentation is because it is an inline suggestion. Should I change the code so that we can control wether the code to be replaced should be displayed when inline?
There was a problem hiding this comment.
Hmm; I think either change the code, or change the wording. But yeah probably just having the option to "suppress" the suggestion when displayed inline seems good.
|
This is your polite 7-day ping @estebank — when do you think you'll be able to respond to the comments? |
When triggering type ascription in such a way that we can infer a statement end was intended, add a suggestion for the change. Always point out the reason for the expectation of a type is due to type ascription.
5f2261a to
c55295f
Compare
|
Failure: The new message looks improved, though. =) |
Now there's a way to add suggestions that hide the suggested code when presented inline, to avoid weird wording when short code snippets are added at the end.
c55295f to
faf9035
Compare
|
@nikomatsakis fixed |
ce5da67 to
e39bcec
Compare
|
@nikomatsakis covered another case that fails during fn f() {}
fn main() {
f():
f();
} |
|
@nikomatsakis ping |
|
@bors r+ |
|
📌 Commit e39bcec has been approved by |
|
cc @oli-obk, I don't this suggestion follows the guidelines, but I also think it looks good. Perhaps we need to adjust the guidelines to account for the "suppress example code" option? |
|
I'm assuming you mean that the guildelines aren't followed by the use of "Try using a |
|
☀️ Test successful - status-appveyor, status-travis |
|
@estebank Thanks for making this error message better! |
|
Which error message got finalized? |
|
@Nokel81 sorry, I don't understand the question. Could you rephrase? This PR adds a label stating "help: did you mean to use |
|
I was talking about the guideline of not using |
|
@Nokel81 ah, I see. No, I didn't change the message before it got merged. I can post a PR later today/tomorrow changing the wording, if you want. |
|
No it is fine, I personally feel that there are some cases where |
When triggering type ascription in such a way that we can infer a
statement end was intended, add a suggestion for the change. Always
point out the reason for the expectation of a type is due to type
ascription.
Fix #42057, #41928.