-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Improve SubSupConflict with a named and an anonymous lifetime parameter #42701 #44167
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
r? @pnkfelix (rust_highfive has picked a reviewer for you, use r? to override) |
@@ -0,0 +1,41 @@ | |||
error[E0495]: cannot infer an appropriate lifetime for borrow expression due to conflicting requirements |
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.
#42700
The first snippet of code, that's how the ui test must output
@@ -0,0 +1,24 @@ | |||
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT |
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 is of type ConcreteFailure, not SubSupConflict
pub fn try_report_named_anon_conflict(&self, error: &RegionResolutionError<'tcx>) -> bool { | ||
let (span, sub, sup) = match *error { | ||
ConcreteFailure(ref origin, sub, sup) => (origin.span(), sub, sup), | ||
SubSupConflict(_, ref origin, sub, _, sup) => (origin.span(), sub, sup), | ||
_ => return false, // inapplicable | ||
}; | ||
|
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.
You will have to remove the is_self_anon
check. Maybe you can try an example without self
, that should work.
I think this is a good test case: struct Foo {
field: i32,
}
fn foo2<'a>(a: &'a Foo, x: &i32) -> &'a i32 {
if true {
let p: &i32 = &a.field;
&*p
} else {
&*x
}
}
fn main() { } |
Hi @cengizio! Nice PR! Can you add @nikomatsakis's test so we can see how the errors look and fix this? |
@nikomatsakis can you suggest a test case for anon_anon conflicts too? |
@gaurikholkar I guess that's a bit harder. If you just remove the named lifetime, then the elision rules will fail. You can use an |
☔ The latest upstream changes (presumably #44079) made this pull request unmergeable. Please resolve the merge conflicts. |
Maybe try this example too? struct Foo {
field: i32,
}
fn foo2<'a, 'b>(a: &'a Foo, x: &'b i32) -> &'a i32 {
if true {
let p: &i32 = &a.field;
&*p
} else {
&*x
}
}
fn main() { } I imagine this will exercise the "different lifetimes" code a bit. |
You have a tidy error:
|
This PR is basically ready to land, you just have to fix the tidy error. Just a ping to make sure this isn't getting lost. |
Hello @arielb1 Thanks for notifying. I'm still trying to resolve this example case #44167 (comment) Whenever that finishes, I'll fix tidy error and push them. |
Just fixed tidy error. Also, while rebasing, it turned out to change 3 ui tests. I'm not sure about this because it was an implicit change. 314bb98 @nikomatsakis maybe can shed some light to this implicit change |
There seems to be some changes which are breaking other tests also. Back to the drawing board... |
@cengizio those 3 ui tests appear to be bug fixes =) that is, thanks to your change, the 'new and improved' errors are triggering more often. seems good! |
@cengizio also those test errors are not unexpected. I think you just have to update the tests to change them to expect the new error message. However, these tests are a bit surprising to me:
I'm not sure what's up with those two cases! |
@nikomatsakis I will also check those two surprising cases and report here. |
@cengizio yes, compile-fail tests have to be edited manually. |
@nikomatsakis @arielb1 @gaurikholkar hello again! I've updated the test cases. NOTE: I decided to make test assertions in |
@cengizio this test fails
I guess you have given the wrong column no for the error |
@gaurikholkar thanks for noticing. The annoying part is, all tests are passing on my local machine. (with latest HEAD). Let's see if this fixes the problem. |
Argh! There seems to be line differences between my git clone and travis' copy. I'll investigate this further tomorrow. |
gaurikholkar-zz@cb0d746 |
Ignore the indentation mess |
☀️ Test successful - status-travis |
@rust-lang/infra Perf check wanted ( |
Looks like try build is ready. cc @rust-lang/infra |
OK so -- the perf results seem fine, but @cengizio and I were discussing that maybe it's still worth replacing the |
📌 Commit dad7d94 has been approved by |
⌛ Testing commit dad7d94 with merge 5b1b7b6c84a3e8e723a0416485a228abf756918c... |
💔 Test failed - status-travis |
@bors r+ |
📌 Commit f53fc57 has been approved by |
Improve SubSupConflict with a named and an anonymous lifetime parameter #42701 Hello! This fixes #42701. ## UPDATE 01 Tests are producing different results between different env builds. This inconsistency might take a long time to investigate and fix. So, be patient ## UPDATE 02 Changed an `FxHashMap` with a `BTreeMap`. Inconsistency seems to be resolved for now.
☀️ Test successful - status-appveyor, status-travis |
Hello!
This fixes #42701.
UPDATE 01
Tests are producing different results between different env builds.
This inconsistency might take a long time to investigate and fix. So, be patient
UPDATE 02
Changed an
FxHashMap
with aBTreeMap
. Inconsistency seems to be resolved for now.