Skip to content

Backport 3941 #5301

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Backport 3941 #5301

wants to merge 1 commit into from

Conversation

ytmimi
Copy link
Contributor

@ytmimi ytmimi commented Apr 6, 2022

rewrite generic params no matter what kind it may be (#3941)

rewrite generic params no matter what kind it may be
@ytmimi
Copy link
Contributor Author

ytmimi commented Apr 22, 2022

I want to call out that the following compiles and has empty bound_generic_params

fn foo<T>(_: T) where for<> T: std::fmt::Debug {
    println!("hello");
}


#[derive(Debug)]
struct A; 

fn main() {
    foo(A)
}

Related to #5316, and with the backport changes in this PR, the previous snippet is reformatted to:
(note the removal of for<> in the where clause)

fn foo<T>(_: T)
where
    T: std::fmt::Debug,
{
    println!("hello");
}

#[derive(Debug)]
struct A;

fn main() {
    foo(A)
}

#5316 pertains to bound generics in the context of macro calls, however the removal of the for<> in the where context doesn't produce invalid code. I'm wondering if rustfmt should remove the empty for<> in the where clause context, preserve it in the macro context, or preserve it in both?

@ytmimi ytmimi added the p-low label Jul 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants