-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Remove contraction from region inference #29188
Conversation
} | ||
Ok(()) | ||
})); | ||
if self.is_local() { // (1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this fix RUST_LOG=rustc::middle::traits
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this fix RUST_LOG=rustc::middle::traits?
Yes, I expect so. I think I was having problems with RUST_LOG=rustc_typeck
, but I suspect it's the same issue. And yes, a fallible version of item_path_str
would be better.
Interestingly, this PR fixes a bug that @dherman was encountered in his nanny project. I need to investigate that a bit more deeply though. |
I looked into @dherman's case. It comes down to a trait method defined like this: fn foo<'root, T:Trait<'root>>(t: T) -> &i32 the point being that |
yes, done. |
I am unable to reproduce @dherman's case, but its not like putting a restriction on |
@arielb1 what do you mean by "lifetime truncation"? |
The fact that you can substitute an fn with some lifetime parameters that don't appear in the signature and then call it after these lifetime parameters are dead. A reasonable argument for the soundness of this is that, because lifetime bounds in Rust are never strict, if you LUB all the lifetimes in a validate predicate with some lifetime you still get something valid - this is basically the reason lifetime erasure works (and therefore I call it "truncation"). For example, in your code: trait Trait<'root> {}
impl<'a,'root> Trait<'root> for &'a i32 where 'a: 'root {}
fn foo<'root, T:Trait<'root>>(t: T) -> i32 {
/* ... - your original signature doesn't specify the return type's lifetime */
}
fn main() {
'v: {
let v = &2;
('t: { foo::<'t, &'v i32> })(&v);
}
}
This, of course, breaks horribly if we have types that can't be bought fresh to some lifetime - e.g. unloadable code, but we already know that. |
OK, yes. This is what I was saying I would potentially like to fix, though On Fri, Oct 23, 2015 at 1:55 PM, arielb1 [email protected] wrote:
|
@pnkfelix would you be able to review this sooner rather than later? It does fix |
okay it took me a little bit longer than I expected to wrap my head around this. You left in the It seems like the code is just calling out for a simplification pass; e.g. the factoring of In addition, it would be nice if the README were updated, removing the discussion of processing the Contracting nodes. But there's no reason to hold up this PR for those kinds of changes. |
@nikomatsakis r=me once you've addressed the travis failure in some reasonable manner. |
Yes, I agree, I was just being hasty. I will try to clean it up a bit.
agreed |
|
empty region, and they complicate region inference to no particular end. They also lead in some cases to spurious errors like rust-lang#29048 (though in some cases these errors are helpful in tracking down missing constraints).
expansion already by growing the RHS to be bigger than LHS (all the way to `'static` if necessary). This is needed because contraction doesn't handle givens. Fixes rust-lang#28934.
1ccd800
to
c2277de
Compare
@bors r=pnkfelix |
📌 Commit c2277de has been approved by |
This fixes #29048 (though I think adding better transactional support would be a better fix for that issue, but that is more difficult). It also simplifies region inference and changes the model to a pure data flow one, as discussed in [this internals thread](https://internals.rust-lang.org/t/rough-thoughts-on-the-impl-of-region-inference-mir-etc/2800). I am not 100% sure though if this PR is the right thing to do -- or at least maybe not at this moment, so thoughts on that would be appreciated. r? @pnkfelix cc @arielb1
Does the beta-nominated tag mean this PR is to be backported to 1.5? I’d appreciate this: at the moment I have code that compiles on stable and nightly, but not 1.5.0-beta.2: https://travis-ci.org/servo/rust-cssparser/builds/88377023 |
@SimonSapin yeah if accepted this'll be backported to 1.5 |
@rust-lang/lang @SimonSapin wants this backported soon. Can you review? |
@brson I think this is really a @rust-lang/compiler issue. But I'm inclined to accept it this for beta backport. |
+1 to backport |
Backport PR is up when you are ready. |
Accepting for beta. |
This fixes #29048 (though I think adding better transactional support would be a better fix for that issue, but that is more difficult). It also simplifies region inference and changes the model to a pure data flow one, as discussed in this internals thread. I am not 100% sure though if this PR is the right thing to do -- or at least maybe not at this moment, so thoughts on that would be appreciated.
r? @pnkfelix
cc @arielb1