-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
create fewer region variables in coercions #32306
Conversation
b1df47b
to
f0c7b3c
Compare
I am still running a final make check, but things were passing at one not so long ago point. :) |
Ah, I think I forgot some kind of regression test. |
Regression test: rust-lang-deprecated/rustc-benchmarks#3 Do you think it makes sense to add to run-pass? The full test takes 3 or 4 seconds to compile, and reduced ones don't seem that interesting. |
Gah, fails to build. |
Well, have to stop now, the error feels fixable. Somehow region inference isn't creating the required edges I think. The minimized test case is: use std::rc::Rc;
#[derive(Clone)]
enum CachedMir<'mir> {
Ref(&'mir String),
Owned(Rc<String>),
}
impl<'mir> CachedMir<'mir> {
fn get_ref<'a>(&'a self) -> &'a String {
match *self {
CachedMir::Ref(r) => r,
CachedMir::Owned(ref rc) => &rc,
}
}
}
fn main() { } which fails with an error:
|
(Obviously the |
// want to use that target type region (`'b`) because -- | ||
// for the program to type-check -- it must be the | ||
// smaller of the two. | ||
let r = if self.use_lub {r_a} else {r_b}; // [2] above |
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.
I believe you still have to relate r_a
and r_b
in sub mode, e.g. &'a T
coerced to &'b T
in sub mode would only require that &'b T
is a subtype of &'b T
, but not that 'a
outlives 'b
.
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.
I believe you still have to relate r_a and r_b in sub mode, e.g. &'a T coerced to &'b T in sub mode would only require that &'b T is a subtype of &'b T, but not that 'a outlives 'b.
We discussed on IRC, but this is not the problem. TL;DR regionck adds the edge. I added more text to the comment to address exactly this point in 1f30fe0.
OK, I think the problem is fixed now, and the compilation performance is still good. |
ty, autoderefs, autoref); | ||
Ok((ty, AdjustDerefRef(AutoDerefRef { | ||
autoderefs: autoderefs, | ||
autoref: autoref, |
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.
This isn't trying to avoid noop reborrow coercions? I don't want the array of strings to have any coercions at all.
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.
@eddyb it's not obvious when we can avoid those -- I guess if r_borrow == r_a
and autoderefs == 1
, you mean? I can add a test for that, why not.
d3578ef
to
f7156bf
Compare
instead, extract the target region out of the autoderef loop
the goal here is to minimize creating variables
The older code would sometimes swallow errors or fail to produce a suggestion. The newer code does not. However, just printing everything would produce a bunch of new and kind of annoying errors, so continue to swallow `T: 'a` errors so long as there are other things to show.
f7156bf
to
bca07b5
Compare
@eddyb ok so we now should have the suggestions again and it is eliding no-op coercions. |
@@ -22,7 +22,7 @@ fn bar1<'a>(x: &Bar) -> (&'a i32, &'a i32, &'a i32) { | |||
} | |||
|
|||
fn bar2<'a, 'b, 'c>(x: &Bar<'a, 'b, 'c>) -> (&'a i32, &'a i32, &'a i32) { | |||
//~^ HELP: consider using an explicit lifetime parameter as shown: fn bar2<'a, 'b, 'c>(x: &'a Bar<'a, 'b, 'c>) -> (&'a i32, &'a i32, &'a i32) | |||
//~^ HELP: consider using an explicit lifetime parameter as shown: fn bar2<'a, 'c>(x: &'a Bar<'a, 'a, 'c>) -> (&'a i32, &'a i32, &'a i32) |
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.
Sigh. I have no idea why this suggestion changed.
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.
Oh, I think I get why. It's not wrong in any case.
@bors r+ |
📌 Commit 43aed96 has been approved by |
⌛ Testing commit 43aed96 with merge 76d42f5... |
💔 Test failed - auto-mac-32-opt |
@bors: retry On Sat, Mar 19, 2016 at 9:39 AM, bors [email protected] wrote:
|
@alexcrichton I was just going to ask if these timeouts are a thing...never seen one before? I ... highly doubt this patch made things any slower. |
Yeah lldb timeouts on mac have been happening for quite some time |
Fixes #32278.
r? @eddyb