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

Properly handle collecting default impls of methods with lifetime parameters. #48818

Merged
merged 2 commits into from
Mar 16, 2018

Conversation

michaelwoerister
Copy link
Member

r? @eddyb

Fixes #47309.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 7, 2018
if mono_item.is_instantiable(tcx)
&& should_monomorphize_locally(tcx, &instance) {
output.push(mono_item);
let fn_ty = tcx.erase_regions(&tcx.type_of(method.def_id));
Copy link
Member Author

Choose a reason for hiding this comment

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

Would it be better to erase regions after applying the trait substs?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe if it makes the code simpler.

@pietroalbini
Copy link
Member

Ping from triage @eddyb! This PR needs your review.

@michaelwoerister
Copy link
Member Author

This could also be reviewed by somebody else from @rust-lang/compiler, if @eddyb doesn't have time.

@arielb1
Copy link
Contributor

arielb1 commented Mar 12, 2018

I would prefer to change push_if_root to create a proper substs for the item (with the relevant lifetime parameters substituted with ReErased) instead of adding special casing for exotic substs.

@arielb1
Copy link
Contributor

arielb1 commented Mar 12, 2018

Yes I'm back (somewhat).

@michaelwoerister
Copy link
Member Author

I'll look into it.

@michaelwoerister
Copy link
Member Author

@arielb1, push_if_root() already does that by using Instance::mono(). Default methods are a special case, as they are generic but we happen to know the type arguments. We can't really use push_if_root() here.

@bors
Copy link
Contributor

bors commented Mar 13, 2018

☔ The latest upstream changes (presumably #48411) made this pull request unmergeable. Please resolve the merge conflicts.

@arielb1
Copy link
Contributor

arielb1 commented Mar 14, 2018

@michaelwoerister

I misread that code - you really are not using push_if_root. In any case, the "correct" way of doing things is to create a "correct" method substs with erased regions, as this code does:

// the method may have some early-bound lifetimes, add
// regions for those
let substs = Substs::for_item(tcx, def_id,
|_, _| tcx.types.re_erased,
|def, _| trait_ref.substs().type_for_def(def));

I think Substs::extend_to would also work and it might be a better refactoring to use it instead of Substs::for_item.

@michaelwoerister
Copy link
Member Author

Much nicer now, thanks @arielb1!

@eddyb
Copy link
Member

eddyb commented Mar 15, 2018

@bors r+

@bors
Copy link
Contributor

bors commented Mar 15, 2018

📌 Commit 5218c2d has been approved by eddyb

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 15, 2018
@bors
Copy link
Contributor

bors commented Mar 16, 2018

⌛ Testing commit 5218c2d with merge cc34ca1...

bors added a commit that referenced this pull request Mar 16, 2018
Properly handle collecting default impls of methods with lifetime parameters.

r? @eddyb

Fixes #47309.
@bors
Copy link
Contributor

bors commented Mar 16, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: eddyb
Pushing cc34ca1 to master...

@bors bors merged commit 5218c2d into rust-lang:master Mar 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants