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

Rustfmt loses qself type inside struct expr #5151

Closed
dtolnay opened this issue Dec 23, 2021 · 1 comment · Fixed by #5152
Closed

Rustfmt loses qself type inside struct expr #5151

dtolnay opened this issue Dec 23, 2021 · 1 comment · Fixed by #5152

Comments

@dtolnay
Copy link
Member

dtolnay commented Dec 23, 2021

#![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`
@ytmimi
Copy link
Contributor

ytmimi commented Dec 24, 2021

Thanks for submitting this report.

I actually worked on something similar not too long ago so I'll push a PR to fix this soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants