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

Support non-lifetime binders #5848

Merged

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Jul 19, 2023

Makes it so we stop yeeting non-lifetime binders into the void. Rustfmt already generally supports formatting ast::GenericParam anyways, so this just is piggybacking on that formatting.

Fixes #5721

context: &RewriteContext<'_>,
shape: Shape,
generic_params: &[ast::GenericParam],
) -> Option<String> {
let result = generic_params
.iter()
.filter(|p| matches!(p.kind, ast::GenericParamKind::Lifetime))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this filter line is the only non-name-tweaking change.

@compiler-errors compiler-errors force-pushed the non-lifetime-binders branch 3 times, most recently from 6614042 to a2622a2 Compare July 19, 2023 21:16
Comment on lines +1 to +8
#![feature(non_lifetime_binders)]
#![allow(incomplete_features)]

trait Other<U: ?Sized> {}

trait Trait<U>
where
for<T> U: Other<T> {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No real issue keeping the source file, but I just want to point out that the target file is enough to show that the input is idempotent, and that rustfmt no longer remove the for<T>.

src/types.rs Outdated Show resolved Hide resolved
@calebcartwright calebcartwright added release-notes Needs an associated changelog entry and removed pr-not-reviewed labels Jul 20, 2023
@calebcartwright
Copy link
Member

Thanks!

@calebcartwright calebcartwright merged commit 2db13f4 into rust-lang:master Jul 20, 2023
27 checks passed
@fmease
Copy link
Member

fmease commented Jul 20, 2023

rustfmt doesn't seem to break lengthy higher-ranked parameter lists (ones that contain long binder names or lots of bounds) into multiple lines yet though at least according to my limited testing.

Slightly unrelated since this seems to concern (the stable) lifetime binders, too. Just something I've noticed. Might require a style edition though. Edit: For verbose lifetime names only I guess, everything else is unstable or semantically not permitted yet in rustc.

@ytmimi
Copy link
Contributor

ytmimi commented Jul 21, 2023

rustfmt doesn't seem to break lengthy higher-ranked parameter lists (ones that contain long binder names or lots of bounds) into multiple lines yet though at least according to my limited testing.

@fmease it would be great if you could open up a new issue and provide some example code snippets that the team can use to investigate.

@ytmimi ytmimi removed the release-notes Needs an associated changelog entry label Oct 23, 2023
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 this pull request may close these issues.

feature(non_lifetime_binder) syntax gets removed
5 participants