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 #4943

Closed
louaykamel opened this issue Aug 6, 2021 · 1 comment · Fixed by #4947
Closed

rustfmt removes GATs from associated type #4943

louaykamel opened this issue Aug 6, 2021 · 1 comment · Fixed by #4947
Labels
2x-port:pending bug Panic, non-idempotency, invalid code, etc.

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
Copy link
Author

#4911

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2x-port:pending bug Panic, non-idempotency, invalid code, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants