Skip to content

Alias-eq weakens inference in HIR typeck #7

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

Closed
compiler-errors opened this issue Mar 28, 2023 · 1 comment
Closed

Alias-eq weakens inference in HIR typeck #7

compiler-errors opened this issue Mar 28, 2023 · 1 comment
Labels
fundamental-issue Something that'll need fundamental restructuring or a hack existing at the solver level hacked-around A hack exists to work around this, but it may not be the optimal solution needs-design A clear root cause exists, but needs medium/hard re-architecture work towards a solution

Comments

@compiler-errors
Copy link
Owner

compiler-errors commented Mar 28, 2023

originally reported this in lcnr/solver-woes#13 --

trait Mk {
    type Assoc;
}

fn mk<T: Mk>(t: T) -> T::Assoc {
    todo!()
}

fn foo<S: Mk + Default>() {
    let x = Default::default();
    let y = mk::<_ /* ?z */>(x);
    let x: S = x;
}
error[E0282]: type annotations needed for `<_ as Mk>::Assoc`
  --> <source>:11:9
   |
11 |     let y = mk::<_ /* ?z */>(x);
   |         ^
   |
help: consider giving `y` an explicit type, where the type for associated type `<_ as Mk>::Assoc` is specified
   |
11 |     let y: <_ as Mk>::Assoc = mk::<_ /* ?z */>(x);
   |          ++++++++++++++++++

Related, heavily reduced from an example in syn:

fn main() {
    let mut x: Vec<_> = vec![];
    x.extend(Some(1i32).into_iter().map(|x| x));
}

General direction of the fix would be to not prefer the subst-relate branch of alias-relate...

Something like compiler-errors/rust@d7001d2 + compiler-errors/rust@10064381389 (so we don't prefer alias-eq results that do no inference) will probably be needed ultimately, though fixed so it doesn't do this behavior during coherence, etc., maybe some other tweaking idk.

@compiler-errors compiler-errors added hacked-around A hack exists to work around this, but it may not be the optimal solution needs-design A clear root cause exists, but needs medium/hard re-architecture work towards a solution fundamental-issue Something that'll need fundamental restructuring or a hack existing at the solver level labels Mar 29, 2023
@compiler-errors
Copy link
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fundamental-issue Something that'll need fundamental restructuring or a hack existing at the solver level hacked-around A hack exists to work around this, but it may not be the optimal solution needs-design A clear root cause exists, but needs medium/hard re-architecture work towards a solution
Projects
None yet
Development

No branches or pull requests

1 participant