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

Preserve ordering of associated type constraints relative to types #1216

Merged
merged 1 commit into from Sep 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 6 additions & 22 deletions src/path.rs
Expand Up @@ -756,11 +756,8 @@ pub(crate) mod printing {
self.colon2_token.to_tokens(tokens);
self.lt_token.to_tokens(tokens);

// Print lifetimes before types and consts, all before bindings,
// regardless of their order in self.args.
//
// TODO: ordering rules for const arguments vs type arguments have
// not been settled yet. https://github.com/rust-lang/rust/issues/44580
// Print lifetimes before types/consts/bindings, regardless of their
// order in self.args.
let mut trailing_or_empty = true;
for param in self.args.pairs() {
match **param.value() {
Expand All @@ -776,30 +773,17 @@ pub(crate) mod printing {
}
for param in self.args.pairs() {
match **param.value() {
GenericArgument::Type(_) | GenericArgument::Const(_) => {
if !trailing_or_empty {
<Token![,]>::default().to_tokens(tokens);
}
param.to_tokens(tokens);
trailing_or_empty = param.punct().is_some();
}
GenericArgument::Lifetime(_)
GenericArgument::Type(_)
| GenericArgument::Binding(_)
| GenericArgument::Constraint(_) => {}
}
}
for param in self.args.pairs() {
match **param.value() {
GenericArgument::Binding(_) | GenericArgument::Constraint(_) => {
| GenericArgument::Constraint(_)
| GenericArgument::Const(_) => {
if !trailing_or_empty {
<Token![,]>::default().to_tokens(tokens);
}
param.to_tokens(tokens);
trailing_or_empty = param.punct().is_some();
}
GenericArgument::Lifetime(_)
| GenericArgument::Type(_)
| GenericArgument::Const(_) => {}
GenericArgument::Lifetime(_) => {}
}
}

Expand Down
3 changes: 0 additions & 3 deletions tests/repo/mod.rs
Expand Up @@ -14,9 +14,6 @@ const REVISION: &str = "98ad6a5519651af36e246c0335c964dd52c554ba";

#[rustfmt::skip]
static EXCLUDE_FILES: &[&str] = &[
// TODO: generic associated type constraint inside trait bound
"src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/0138_associated_type_bounds.rs",

// TODO: negative literal for const generic parameter default value
"src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/0200_const_param_default_literal.rs",

Expand Down