-
Notifications
You must be signed in to change notification settings - Fork 0
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
unnormalized projections in writeback may contain infer vars #12
Comments
This is expected behavior, because we resolve and encode the type of all |
I'm not sure if it's possible to come up with an example that has unconstrained infer vars in a projection in the new solver, without also having some "type annotations needed" error even on stable? |
Actually, nevermind! This happens with closure substs, specifically the tupled upvar subst: fn main() {
let mut x: Vec<_> = vec![];
x.extend(Some(1i32).into_iter().map(|x| x));
} |
Also, pretty easy repro of the problem I guess: trait Mk {
type Assoc;
}
fn mk<T: Mk<Assoc = i32>>(t: T) -> T::Assoc {
0
}
trait Bar {}
impl Bar for () {}
impl<T: Bar> Mk for T {
type Assoc = i32;
}
fn main() {
let mut x = Default::default();
let y = mk(x);
x = ();
} |
how does the second example work? don't we constrain also confused about the first example 🤔 the projection is |
In both examples, we emit alias-relate goals instead of simply equating the projection ty to the infer-var of the let-bindings. this is because we generalize the ty of the projection, since the let binding's infer var cannot name the projection type (it was created when the universe was still 0). these alias-relate goals both hold trivially via the normalizes-to branch of the code, so we never end up relating the projection substs, and the infer var remains unconstrained in both examples. that last part seems like it may be a slightly separate issue about alias-relate causing inference to be weaker... I'll file another issue when I wake up. edit: #13 |
If we have some
<T as Id<?x>>::Assoc
in hir typeck and the current impl normalizes that toT
before writeback but is unable to infer?x
, then lazy norm would result in an inference error.It seems like the following currently errors on stable, figure out why
The text was updated successfully, but these errors were encountered: