-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Closes #52413: Provide structured suggestion instead of label #52450
Conversation
arg.pat.span, | ||
format!("consider changing {} to `{}`", span_label_var, new_ty), | ||
&format!("consider changing {} to `{}`", span_label_var, new_ty), | ||
"".to_string() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When applying the suggestion, the code will be incorrect. The fourth argument should the new_ty
, as that's what the code needs to be after applying the change, and the span needs to be changed to point at the argument type, instead of the argument name so the suggestion gets applied in the right place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@estebank make sense! I will fix this by today or tomorrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Friendly ping :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@estebank I am stuck on this, I am not able to figure out how to find hir_id
or node_id
of arguments type at https://github.com/rust-lang/rust/blob/9f9ac89d11a2afaeaa029738b38142124684c89b/src/librustc/infer/error_reporting/nice_region_error/util.rs#L83
I had planning of introducing arg_ty_span
in AnonymousArgInfo
which later we can use at https://github.com/rust-lang/rust/blob/9f9ac89d11a2afaeaa029738b38142124684c89b/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs#L115
Could you give me pointer or two on how to approach this. I think this is bit tough to find span
on util.rs
because in some cases table
may not be fully populated.
PS: apology for delayed response :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@estebank I think I have found the way to find span of argument type. doing experiements now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@estebank: done :)
efd6373
to
1940108
Compare
| consider changing the type of `y` to `&'a u32` | ||
| ---- ^ lifetime `'a` required | ||
| | | ||
| help: consider changing the type of `y` to : `&'a u32` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@estebank should we change this message? because with :
it looks bit weird. Any suggestion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets reword it slightly, so it reads help: add explicit lifetime
'a to the type of 'y': '&'a u32'
, which is slightly better. The colon is always there for suggestions. If the message is long, or there are multiple possible suggestions, or the suggestion spans multiple lines the emitter will look like this:
error[E0621]: explicit lifetime required in the type of `y`
--> $DIR/mismatched.rs:14:42
|
LL | fn foo(x: &'a u32, y: &u32) -> &'a u32 { y } //~ ERROR explicit lifetime required
| ^ lifetime `'a` required
help: add explicit lifetime `'a` to the type of `y`
|
XX | fn foo(x: &'a u32, y: &'a u32) -> &'a u32 { y }
| ^^^^^^^
Because of this, wording needs to be able to work for both types of presentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
r? @estebank
Love the change! r=me after rewording the suggestion message. |
@bors r+ |
📌 Commit 49b0a1e has been approved by |
⌛ Testing commit 49b0a1e with merge ca33855a0553719b119a883c10d97fc82104e333... |
💔 Test failed - status-travis |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
@bors retry travis-ci/travis-ci#9696
|
☀️ Test successful - status-appveyor, status-travis |
Provide structured suggestion instead of label
r? @estebank