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 removes GATs from associated type #87829

Closed
louaykamel opened this issue Aug 6, 2021 · 1 comment
Closed

rustfmt removes GATs from associated type #87829

louaykamel opened this issue Aug 6, 2021 · 1 comment
Labels
C-bug Category: This is a bug.

Comments

@louaykamel
Copy link

I tried this code:

#![feature(generic_associated_types)]

trait GAT {
    type R<T>;
    fn do_something<T>(r: Self::R<T>) -> Self::R<T> {
        r
    }
    
}
struct SomeStruct;

impl GAT for SomeStruct {
    type R<T> = T;
}

impl SomeStruct {
    fn process<T>(v: T) -> <Self as GAT>::R<T>
    // Issue: rustfmt removes the GAT from the associated R  
    where Self: GAT<R<T> = T>
    {
        SomeStruct::do_something(v)
    }
}


fn main() {
  let one: u8 = SomeStruct::process(1);
  assert!(one == 1)
}

I expected rustfmt to: keep <T>

where Self: GAT<R<T> = T>

Instead, this happened: removed <T>

where Self: GAT<R = T>

Meta

rustc --version --verbose:

rustc 1.56.0-nightly (2f07ae408 2021-08-05)
binary: rustc
commit-hash: 2f07ae408fce782bf1058e3de808f1b6f9ab60a4
commit-date: 2021-08-05
host: x86_64-unknown-linux-gnu
release: 1.56.0-nightly
LLVM version: 12.0.1
@louaykamel louaykamel added the C-bug Category: This is a bug. label Aug 6, 2021
@louaykamel
Copy link
Author

Moved to rustfmt repo:
rust-lang/rustfmt#4943

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

1 participant