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

Correctly format typed self in function arguments #159

Merged
merged 1 commit into from
Aug 14, 2015
Merged

Correctly format typed self in function arguments #159

merged 1 commit into from
Aug 14, 2015

Conversation

marcusklaas
Copy link
Contributor

@@ -790,6 +759,37 @@ impl<'a> FmtVisitor<'a> {
}
}

fn rewrite_explicit_self(explicit_self: &ast::ExplicitSelf, args: &[ast::Arg]) -> String {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to return Option<String> than giving a special meaning to the empty string (also saves an allocation).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered this, but reserved the None case for if we want to implement Rewrite for it later. I don't think String::new allocates, by the way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess maybe return a custom enum then? Alternatively we could always return Option<Option> if we implement Rewrite (which would require making Rewrite more generic I guess). If we have to treat the result specially if its an empty string, then it really ought to be explicit by using an enum of some kind.

@nrc
Copy link
Member

nrc commented Jul 24, 2015

@marcusklaas thanks for all the patches! You've done a tonne of good work recently :-) Heads up that I'll be travelling next week, so might be a bit slower with reviews and merging.

@marcusklaas
Copy link
Contributor Author

Updated!

@marcusklaas
Copy link
Contributor Author

Wait, maybe there is no need to skip it once we fix the span... Why do we need min_args = 2 for the other cases?

@marcusklaas
Copy link
Contributor Author

Should we consider merging this? It's not ideal, but at least fixes the underlying bug. To do it the proper way would be to address rust-lang/rust#27522, which isn't trivial.

Until that happens, the comment for the self type is dropped. We could open a separate issue for that.

@nrc
Copy link
Member

nrc commented Aug 14, 2015

Yes, we should! (Sorry it took a while to get to).

@marcusklaas could you add a fixme comment referencing #27522 please? Then you can push this.

marcusklaas added a commit that referenced this pull request Aug 14, 2015
Correctly format typed self in function arguments
@marcusklaas marcusklaas merged commit 78b38c8 into rust-lang:master Aug 14, 2015
@marcusklaas marcusklaas deleted the explicit-self branch August 14, 2015 09:58
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.

2 participants