-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Make lifetime elision help more useful on type signatures. #20263
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nick29581 (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see CONTRIBUTING.md for more information. |
Looks good! For the output I think there should only be backticks around the name of the argument if it is the actual name. If it is "argument #1" or whatever, then there shouldn't be backticks. Also, I would just use "argument 1" instead of "argument #1" because the user might wonder if the # has any special meaning (and indeed in future Rust it might have some special meaning), otherwise it is a good choice of output. |
type foo = fn(&u8, &u8) -> &u8; //~ ERROR missing lifetime specifier | ||
//~^ HELP the signature does not say whether it is borrowed from `argument #1` or `argument #2` | ||
|
||
fn bar<F:Fn(&u8, &u8)->&u8>(f: &F) {} //~ ERROR missing lifetime specifier |
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.
nit: please add spaces around the ->
and after the first :
That all makes sense to me, addressed in the commit above. |
for (i, (name, n)) in v.into_iter().enumerate() { | ||
m.push_str(if n == 1 { | ||
for (i, (mut name, n)) in v.into_iter().enumerate() { | ||
name = if name.is_empty() { |
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.
It would be more idiomatic Rust to re-assign to name and make it immutable (i.e., remove mut
and add let name = ...
Done. Should I rebase and squash? |
@@ -164,10 +164,16 @@ pub fn opt_ast_region_to_region<'tcx, AC: AstConv<'tcx>, RS: RegionScope>( | |||
let mut m = String::new(); | |||
let len = v.len(); | |||
for (i, (name, n)) in v.into_iter().enumerate() { | |||
m.push_str(if n == 1 { | |||
let help_name = if name.is_empty() { |
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.
You don't actually need to change the name to help_name
, just keeping name
is fine, but either way works for me
@crhino yes please, r=me when you do |
0eb6f50
to
ba17759
Compare
It felt a little weird to keep the name as r=nick29581 |
Fixes rust-lang#19707. In terms of output, it currently uses the form `argument #1`, `argument #2`, etc. If anyone has any better suggestions I would be glad to consider them.
Fixes #19707.
In terms of output, it currently uses the form
argument #1
,argument #2
, etc. If anyone has any better suggestions I would be glad to consider them.