Skip to content

Cannot solve S<{B}>, but can solve S<B> in impl item #22644

Description

@A4-Tacks

rust-analyzer version: rust-analyzer 0.4.2930-standalone

rustc version: rustc 1.97.0-nightly (36ba2c771 2026-04-23)

editor or extension: Vim

code snippet to reproduce:

trait ToNum {
    type Num;
}
trait Bar {
    type Ty;
}
struct Gen<const B: bool>;
struct Int<const B: bool>;

impl<const B: bool> ToNum for Gen<{B}> { type Num = Int<B>; }
//impl<const B: bool> ToNum for Gen<B> { type Num = Int<B>; }

impl Bar for Int<true> {
    type Ty = i32;
}
impl Bar for Int<false> {
    type Ty = f32;
}

type A = <<Gen<true> as ToNum>
            ::Num as Bar>
            ::Ty;

fn main() {
    let x = A::default();
    // If use `Gen<B>`, x: i32.
    // but use `Gen<{B}>`, x: {unknown}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-tytype system / type inference / traits / method resolutionC-bugCategory: bug

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions