Skip to content

Rustfmt loses qself type inside struct expr #5151

@dtolnay

Description

@dtolnay
#![feature(more_qualified_paths)]

struct Struct {}

trait Trait {
    type Type;
}

impl Trait for Struct {
    type Type = Self;
}

fn main() {
    let _ = <Struct as Trait>::Type {};
}

As of current master (7b8303d), cargo run --bin rustfmt -- repro.rs --emit=stdout creates the following diff:

-     let _ = <Struct as Trait>::Type {};
+     let _ = Trait::Type {};

which fails to compile:

error[E0223]: ambiguous associated type
  --> repro.rs:14:13
   |
14 |     let _ = Trait::Type {};
   |             ^^^^^^^^^^^ help: use fully-qualified syntax: `<Type as Trait>::Type`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions