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

lazy type alias: type parameters are not considered constrained in impls #116100

Closed
fmease opened this issue Sep 23, 2023 · 0 comments · Fixed by #120780
Closed

lazy type alias: type parameters are not considered constrained in impls #116100

fmease opened this issue Sep 23, 2023 · 0 comments · Fixed by #120780
Assignees
Labels
C-bug Category: This is a bug. F-lazy_type_alias `#![feature(lazy_type_alias)]` requires-incomplete-features This issue requires the use of incomplete features. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@fmease
Copy link
Member

fmease commented Sep 23, 2023

Uplifted from #112792 (comment).

#![feature(lazy_type_alias)]
#![allow(incomplete_features)]

type Faa<A> = Foo<A>;
struct Foo<A>(A);

impl<A> Faa<A> {}
error[E0207]: the type parameter `A` is not constrained by the impl trait, self type, or predicates
 --> src/lib.rs:11:6
  |
7 | impl<A> Faa<A> {}
  |      ^ unconstrained type parameter
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 23, 2023
@fmease fmease added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. F-lazy_type_alias `#![feature(lazy_type_alias)]` and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Sep 23, 2023
@fmease fmease added the requires-incomplete-features This issue requires the use of incomplete features. label Sep 23, 2023
@fmease fmease self-assigned this Oct 5, 2023
bors added a commit to rust-lang-ci/rust that referenced this issue Feb 17, 2024
Properly deal with weak alias types as self types of impls

Fixes rust-lang#114216.
Fixes rust-lang#116100.

Not super happy about the two ad hoc “normalization” implementations for weak alias types:

1. In `inherent_impls`: The “peeling”, normalization to [“WHNF”][whnf]: Semantically that's exactly what we want (neither proper normalization nor shallow normalization would be correct here). Basically a weak alias type is “nominal” (well...^^) if the WHNF is nominal. [rust-lang#97974](rust-lang#97974) followed the same approach.
2. In `constrained_generic_params`: Generic parameters are constrained by a weak alias type if the corresp. “normalized” type constrains them (where we only normalize *weak* alias types not arbitrary ones). Weak alias types are injective if the corresp. “normalized” type is injective.

Both have ad hoc overflow detection mechanisms.

**Coherence** is handled in rust-lang#117164.

r? `@oli-obk` or types

[whnf]: https://en.wikipedia.org/wiki/Lambda_calculus_definition#Weak_head_normal_form
@bors bors closed this as completed in d3df8ff Feb 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-lazy_type_alias `#![feature(lazy_type_alias)]` requires-incomplete-features This issue requires the use of incomplete features. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants