Skip to content
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

removing eager infer var replacement improves type inference #81

Open
lcnr opened this issue Dec 21, 2023 · 0 comments
Open

removing eager infer var replacement improves type inference #81

lcnr opened this issue Dec 21, 2023 · 0 comments

Comments

@lcnr
Copy link
Contributor

lcnr commented Dec 21, 2023

the following test compiles with the new solver, but not with the old one. This now works because we don't do eager infer var replacement and use deferred projection equality.

trait Id {
    type Assoc;
}

impl<T> Id for T {
    type Assoc = T;
}

trait Trait<T> {}
impl Trait<u32> for Vec<u32> {}
impl Trait<i32> for Vec<u32> {}

fn assoc_pair<T: Id>() -> Option<*mut (Vec<T>, T::Assoc)> {
    None
}

fn impls_trait<T: Trait<U>, U>(_: Option<*mut (T, U)>) {}

fn main() {
    impls_trait(assoc_pair());
}
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 26, 2024
always normalize `LoweredTy` in the new solver

I currently expect us to stop using alias bound candidates of normalizable aliases due to rust-lang/trait-system-refactor-initiative#77 by landing rust-lang#119744. At this point it mostly doesn't matter whether we eagerly normalize (and replace with infer vars in case of ambiguity). cc rust-lang#113473 previous attempt

The infer var replacement for ambiguous projections can in very rare cases:
- weaken inference rust-lang/trait-system-refactor-initiative#81
- strengthen inference rust-lang/trait-system-refactor-initiative#7

I do not expect this impact on inference to significantly affect real crates.

r? `@compiler-errors`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 26, 2024
always normalize `LoweredTy` in the new solver

I currently expect us to stop using alias bound candidates of normalizable aliases due to rust-lang/trait-system-refactor-initiative#77 by landing rust-lang#119744. At this point it mostly doesn't matter whether we eagerly normalize (and replace with infer vars in case of ambiguity). cc rust-lang#113473 previous attempt

The infer var replacement for ambiguous projections can in very rare cases:
- weaken inference rust-lang/trait-system-refactor-initiative#81
- strengthen inference rust-lang/trait-system-refactor-initiative#7

I do not expect this impact on inference to significantly affect real crates.

r? ``@compiler-errors``
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jan 27, 2024
Rollup merge of rust-lang#120378 - lcnr:normalize-ast, r=compiler-errors

always normalize `LoweredTy` in the new solver

I currently expect us to stop using alias bound candidates of normalizable aliases due to rust-lang/trait-system-refactor-initiative#77 by landing rust-lang#119744. At this point it mostly doesn't matter whether we eagerly normalize (and replace with infer vars in case of ambiguity). cc rust-lang#113473 previous attempt

The infer var replacement for ambiguous projections can in very rare cases:
- weaken inference rust-lang/trait-system-refactor-initiative#81
- strengthen inference rust-lang/trait-system-refactor-initiative#7

I do not expect this impact on inference to significantly affect real crates.

r? ``@compiler-errors``
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant