Skip to content

Issue 46976 #47083

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

Merged
merged 2 commits into from
Jan 6, 2018
Merged

Issue 46976 #47083

merged 2 commits into from
Jan 6, 2018

Conversation

CAD97
Copy link
Contributor

@CAD97 CAD97 commented Dec 31, 2017

ICE is due to an empty path segments, so I set the path to be the same as the in band ty params symbol. (I think this is how regular generics end up being handled?)

Pinging @cramertj, this is your code I'm editing here.

@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @steveklabnik (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. Due to 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 the contribution instructions for more information.

@@ -1009,7 +1010,7 @@ impl<'a> LoweringContext<'a> {
hir::TyPath(hir::QPath::Resolved(None, P(hir::Path {
span,
def: Def::TyParam(DefId::local(def_index)),
segments: vec![].into(),
segments: hir_vec![hir::PathSegment::from_name(name)],
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm intrigued about the implications elsewhere in the compiler of having a path with a single path segment of impl Bound1 + Bound2, including that it'd be different from impl Bound2 + Bound1 (but that is already an issue elsewhere, IIRC) and the high likelihood of code not expecting this.

That being said, the code looks otherwise correct. Deferring to @cramertj and @arielb1, @nikomatsakis as they have more context, but it LGTM.

Copy link
Member

Choose a reason for hiding this comment

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

@estebank It's also interesting because there can be multiple different types with the same name (since fn foo(_: impl Into<u8>, _: impl Into<u8>) { ... } desugars to something like fn foo<"impl Into<u8>": Into<u8>, "impl Into<u8>": Into<u8>>(...) { ... }). I think it should be fine, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is a good point as well. If there isn't already, I can add a compile-pass test for the fn f(impl Trait, impl Trait) with two distinct types to the two arguments. That'll make sure it works.

@CAD97
Copy link
Contributor Author

CAD97 commented Jan 2, 2018

This is a bit messy because I did it on my phone

https://play.rust-lang.org/?gist=fa9a03daaccf45929044537529eb2f46&version=nightly

This does work on current nightly rustc, but breaks clippy (Path must have at least one segment).

There is obviously code expecting no empty paths, which argument position impl trait produces without this patch.

I guess the question is whether the synthetic path to the synthetic type name/generic parameter is more or less harmful than the empty path.

I personally have convinced myself that having the path is the correct solution (though to be fully honest I wasn't 100% sure when filling the PR).

@kennytm kennytm added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 3, 2018
@cramertj
Copy link
Member

cramertj commented Jan 5, 2018

cc @nikomatsakis

@nikomatsakis
Copy link
Contributor

@bors r+

This seems fine to me.

@bors
Copy link
Collaborator

bors commented Jan 5, 2018

📌 Commit 077ba8a has been approved by nikomatsakis

@nikomatsakis
Copy link
Contributor

I do sort of want to change the path to some form of enum or something else, but that seems like an orthogonal thing.

@bors
Copy link
Collaborator

bors commented Jan 6, 2018

⌛ Testing commit 077ba8a with merge 90e019b...

bors added a commit that referenced this pull request Jan 6, 2018
Issue 46976

ICE is due to an empty path segments, so I set the path to be the same as the in band ty params symbol. (I think this is how regular generics end up being handled?)

Pinging @cramertj, this is your code I'm editing here.
@bors
Copy link
Collaborator

bors commented Jan 6, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: nikomatsakis
Pushing 90e019b to master...

@bors bors merged commit 077ba8a into rust-lang:master Jan 6, 2018
@CAD97 CAD97 deleted the issue-46976 branch January 13, 2018 02:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants