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

Unexpected E0271 while using Pointee trait #91446

Closed
CraftSpider opened this issue Dec 2, 2021 · 1 comment · Fixed by #92248
Closed

Unexpected E0271 while using Pointee trait #91446

CraftSpider opened this issue Dec 2, 2021 · 1 comment · Fixed by #92248
Assignees
Labels
A-inference Area: Type inference A-traits Area: Trait system C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@CraftSpider
Copy link
Contributor

CraftSpider commented Dec 2, 2021

I tried this code:

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=53652794c179fb2128d73e2f11888a8a

I expected to see this happen:

The code compiles successfully

Instead, this happened:

There are two errors, despite the error sites apparently being no different from the successfully compiled ones, aside from the presence of generic type inference.

I couldn't get this to happen with a user-defined trait, so it may be related to Pointee's magic implementations. On the other hand, it may be possible to trigger via user code and I just couldn't find an example.

Meta

Playground Nightly Version Used:

2021-12-01 48a5999fceeea84a8971
@CraftSpider CraftSpider added A-traits Area: Trait system C-bug Category: This is a bug. labels Dec 2, 2021
@inquisitivecrystal inquisitivecrystal added A-inference Area: Type inference T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 2, 2021
@compiler-errors
Copy link
Member

I've confirmed this is fixed by the same fix I'll be putting up for #92128.

@rustbot claim

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 6, 2022
…pointee, r=jackh726

Normalize struct tail type when checking Pointee trait

Let's go ahead and implement the FIXMEs by properly normalizing the struct-tail type when satisfying a Pointee obligation. This should fix the ICE when we try to calculate a layout depending on `<Ty as Pointee>::Metadata` later.
Fixes rust-lang#92128

Additionally, mark the obligation as ambiguous if there are any infer types in that struct-tail type. This has the effect of causing `<_ as Pointee>::Metadata` to be properly replaced with an infer variable ([here](https://github.com/rust-lang/rust/blob/master/compiler/rustc_trait_selection/src/traits/project.rs#L813)) and registered as an obligation... this turns out to be very important in unifying function parameters with formals that are assoc types.

Fixes rust-lang#91446
Fixes rust-lang#92248
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 9, 2022
…pointee, r=jackh726

Normalize struct tail type when checking Pointee trait

Let's go ahead and implement the FIXMEs by properly normalizing the struct-tail type when satisfying a Pointee obligation. This should fix the ICE when we try to calculate a layout depending on `<Ty as Pointee>::Metadata` later.
Fixes rust-lang#92128
Fixes rust-lang#92577

Additionally, mark the obligation as ambiguous if there are any infer types in that struct-tail type. This has the effect of causing `<_ as Pointee>::Metadata` to be properly replaced with an infer variable ([here](https://github.com/rust-lang/rust/blob/master/compiler/rustc_trait_selection/src/traits/project.rs#L813)) and registered as an obligation... this turns out to be very important in unifying function parameters with formals that are assoc types.

Fixes rust-lang#91446
@bors bors closed this as completed in 6466f89 Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-inference Area: Type inference A-traits Area: Trait system C-bug Category: This is a bug. 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.

3 participants