Skip to content

Associated types aren't normalized with impl cycles #31593

Closed
@strega-nil

Description

@strega-nil
trait Doop {
    type Shaboom;
    fn badoowop(self) -> Self::Shaboom;
}
trait BaDoop: Doop { }

impl<T: BaDoop> Doop for T {
    type Shaboom = T;
    fn badoowop(self) -> Self {
        self
    }
}

fn main() { }

errors with

error: method `badoowop` has an incompatible type for trait: 
 expected associated type,
 found type parameter

playground

A similar issue happens when you now return Self::Shaboom:

error: mismatched types: expected `<T as Doop>::Shaboom`,
    found `T`

playground

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-associated-itemsArea: Associated items (types, constants & functions)C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions