Skip to content

Inherent associated type projections are not normalized after substitution #105314

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
fmease opened this issue Dec 5, 2022 · 0 comments · Fixed by #105315
Closed

Inherent associated type projections are not normalized after substitution #105314

fmease opened this issue Dec 5, 2022 · 0 comments · Fixed by #105315
Assignees
Labels
C-bug Category: This is a bug. F-inherent_associated_types `#![feature(inherent_associated_types)]`

Comments

@fmease
Copy link
Member

fmease commented Dec 5, 2022

I tried this code:

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

struct S<T>(T);
impl<T: O> S<T> {
    type P = <T as O>::P;
}
trait O {
    type P;
}
impl O for i32 {
    type P = String;
}
fn main() {
    let _: S<i32>::P = String::new();
}

I expected to see it compile successfully.
Instead, it was rejected with the following error message:

error[E0308]: mismatched types
  --> p0.rs:15:24
   |
15 |     let _: S<i32>::P = String::new();
   |            ---------   ^^^^^^^^^^^^^ expected associated type, found struct `String`
   |            |
   |            expected due to this
   |
   = note: expected associated type `<i32 as O>::P`
                       found struct `String`
   = help: consider constraining the associated type `<i32 as O>::P` to `String` or calling a method that returns `<i32 as O>::P`
   = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
help: call `Into::into` on this expression to convert `String` into `<i32 as O>::P`
   |
15 |     let _: S<i32>::P = String::new().into();
   |                                     +++++++

Meta

rustc -Vv:

rustc 1.67.0-nightly (53e4b9dd7 2022-12-04)
binary: rustc
commit-hash: 53e4b9dd74c29cc9308b8d0f10facac70bb101a7
commit-date: 2022-12-04
host: x86_64-unknown-linux-gnu
release: 1.67.0-nightly
LLVM version: 15.0.4

@rustbot label F-inherent_associated_types
@rustbot claim

@fmease fmease added the C-bug Category: This is a bug. label Dec 5, 2022
@rustbot rustbot added the F-inherent_associated_types `#![feature(inherent_associated_types)]` label Dec 5, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Dec 5, 2022
…errors

Normalize inherent associated types after substitution

Fixes rust-lang#105314.

r? `@cjgillot` (rust-lang#105224)
`@rustbot` label F-inherent_associated_types
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Dec 5, 2022
…errors

Normalize inherent associated types after substitution

Fixes rust-lang#105314.

r? ``@cjgillot`` (rust-lang#105224)
``@rustbot`` label F-inherent_associated_types
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Dec 5, 2022
…errors

Normalize inherent associated types after substitution

Fixes rust-lang#105314.

r? ```@cjgillot``` (rust-lang#105224)
```@rustbot``` label F-inherent_associated_types
@bors bors closed this as completed in 7ba37ad Dec 6, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-bug Category: This is a bug. F-inherent_associated_types `#![feature(inherent_associated_types)]`
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants