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

Issue warnings for late-bound regions in assoc type bindings and output types #32488

Conversation

nikomatsakis
Copy link
Contributor

This is part 1 of a series of patches to produce "future compatiblity" warnings for #32330. I have the actual fix in a branch, but I am planning to first land some patches so that we issue warnings for all the cases that will break once the fix is in place.

This particular PR issues a warning for fn types where a higher-ranked region appears only in the return type, such as for<'a> fn() -> &'a i32, as well as for where clauses where a HR region appears only in a binding, such as for<'a> Fn() -> &'a i32 or for<'a> Iterator<Item=&'a i32>.

I also included some a general refactoring of projection that makes the "assembling candidate" phase side-effect free, as intended. This is useful for the work that @soltanmm and I have been doing on plumbing obligations around but is otherwise kind of orthogonal.

r? @aturon
cc @arielb1

@nikomatsakis nikomatsakis force-pushed the issue-32330-lbr-in-return-type-warning branch from 69d9954 to 4c4e3fe Compare March 25, 2016 20:29
@bors
Copy link
Contributor

bors commented Mar 26, 2016

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

{
let self_ty = obligation_trait_ref.self_ty();
let object_ty = selcx.infcx().shallow_resolve(self_ty);
debug!("assemble_candidates_from_object_type(object_ty={:?})",
Copy link
Member

Choose a reason for hiding this comment

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

Name needs to be updated here.

@aturon
Copy link
Member

aturon commented Apr 1, 2016

OK, this looks good to me. Tiny nits, r=me after rebase.

This is a step towards fixing rust-lang#32330. The full fix would be a breaking
change, so we begin by issuing warnings for scenarios that will break.
We ought not to be affecting inference state when assembling candidates,
so invoke select inside of a probe.
Before we would ignore a candidate if it happened to be an impl with a
default type. This change makes us never add the impl in the first
place. This seems largely equivalent, though there might be some subtle
difference in that -- before -- we would have failed to normalize if
there was a "trait-def-candidate" contending with an (opaque) impl
candidate. This corresponds I guess to a case like `<<A as Trait>::B as
Trait2>::C`, and the definition of `Trait` contains a clause. Pretty
obscure, but it seems like it's... ok to favor the trait definition in
such a case.
@nikomatsakis nikomatsakis force-pushed the issue-32330-lbr-in-return-type-warning branch from 4c4e3fe to c534a14 Compare April 4, 2016 19:29
@nikomatsakis
Copy link
Contributor Author

@bors r=aturon

@bors
Copy link
Contributor

bors commented Apr 4, 2016

📌 Commit c534a14 has been approved by aturon

bors added a commit that referenced this pull request Apr 5, 2016
Rollup of 11 pull requests

- Successful merges: #32403, #32596, #32675, #32678, #32685, #32686, #32692, #32710, #32712, #32714, #32715
- Failed merges: #32488
@nikomatsakis
Copy link
Contributor Author

Decided to revise this approach. Closing PR for now.

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.

3 participants