-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Apparent regression in implied bounds #27583
Comments
OK, so, stranger and stranger. Now that we have a new stage0, this where clause that was previously required seems...to lead to an error? If I remove it, though, things work. Bizarre. |
Seems like I should put some effort into trying to narrow down the test case better. |
This test seems to fail. use std::cell::Cell;
use std::marker::PhantomData;
pub trait Delegate<'tcx> { }
pub struct InferCtxt<'a, 'tcx: 'a> {
x: PhantomData<&'a Cell<&'tcx ()>>
}
pub struct MemCategorizationContext<'t, 'a: 't, 'tcx : 'a> {
x: &'t InferCtxt<'a, 'tcx>,
}
pub struct ExprUseVisitor<'d, 't, 'a: 't, 'tcx:'a+'d> {
typer: &'t InferCtxt<'a, 'tcx>,
mc: MemCategorizationContext<'t, 'a, 'tcx>,
delegate: &'d mut (Delegate<'tcx>+'d),
}
impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
pub fn new(delegate: &'d mut Delegate<'tcx>,
typer: &'t InferCtxt<'a, 'tcx>)
-> ExprUseVisitor<'d,'t,'a,'tcx>
{
ExprUseVisitor {
typer: typer,
mc: MemCategorizationContext::new(typer),
delegate: delegate,
}
}
}
impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
pub fn new(typer: &'t InferCtxt<'a, 'tcx>) -> MemCategorizationContext<'t, 'a, 'tcx> {
MemCategorizationContext { x: typer }
}
}
fn main() { } |
This MAY be related to object defaults -- if I change |
OK, this is definitely some kind of wacky node-id confusion. If I change |
OK, I found the problem. The problem is that the |
I believe that adding parens makes things work simply because it permutes the ordering of various operations in region inference, causing slightly different LUB operations to arise in which the right variables are seen at the right time. I haven't fully verified this. |
(And, of course, we are not guaranteed a "best" answer here, so this is another case where region inference is (currently) bound to be somewhat inadequate.) |
Issue #27583 was caused by the fact that `LUB('a,'b)` yielded `'static`, even if there existed a region `'tcx:'a+'b`. This PR replaces the old very hacky code for computing how free regions relate to one another with something rather more robust. This solves the issue for #27583, though I think that similar bizarro bugs can no doubt arise in other ways -- the root of the problem is that the region-inference code was written in an era when a LUB always existed, but that hasn't held for some time. To *truly* solve this problem, it needs to be generalized to cope with that reality. But let's leave that battle for another day. r? @aturon
In the RFC 1214 branch, I found that at some point after a rebase (where a new snapshot was introduced), a new implied bound was needed. I believe this is specific to stage0, but I am not sure. I didn't have time to minimize or dig deeply, so i've marked the offending bound for now with a FIXME.
The text was updated successfully, but these errors were encountered: