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

Closed
lcnr opened this issue Dec 21, 2023 · 1 comment
Closed

removing eager infer var replacement improves type inference #81

lcnr opened this issue Dec 21, 2023 · 1 comment
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

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``
@lcnr lcnr added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Jan 29, 2025
@lcnr
Copy link
Contributor Author

lcnr commented Jan 29, 2025

This is no longer the case as we replace aliases with infer vars when adding goals rust-lang/rust#125343

@lcnr lcnr closed this as completed Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

No branches or pull requests

1 participant