Skip to content
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

Merged
merged 1 commit into from
Dec 30, 2014

Conversation

crhino
Copy link
Contributor

@crhino crhino commented Dec 27, 2014

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.

@rust-highfive
Copy link
Collaborator

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.

@nrc
Copy link
Member

nrc commented Dec 27, 2014

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
Copy link
Member

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 :

@crhino
Copy link
Contributor Author

crhino commented Dec 28, 2014

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() {
Copy link
Member

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 = ...

@crhino
Copy link
Contributor Author

crhino commented Dec 28, 2014

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() {
Copy link
Member

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

@nrc
Copy link
Member

nrc commented Dec 29, 2014

@crhino yes please, r=me when you do

@crhino crhino force-pushed the lifetime-elision-help branch from 0eb6f50 to ba17759 Compare December 29, 2014 00:31
@crhino
Copy link
Contributor Author

crhino commented Dec 29, 2014

It felt a little weird to keep the name as name, I wanted something that told me I was making it more user friendly.

r=nick29581

alexcrichton added a commit to alexcrichton/rust that referenced this pull request Dec 30, 2014
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.
@bors bors merged commit ba17759 into rust-lang:master Dec 30, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiple input lifetimes when attempting elision in fn & unboxed closure type signatures gives imprecise help
4 participants