aboutsummaryrefslogtreecommitdiff
path: root/src/generics.rs
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@gmail.com>2018-03-09 00:50:45 -0800
committerDavid Tolnay <dtolnay@gmail.com>2018-03-09 00:50:48 -0800
commit2a0b02fed953ff7d46c41ecbd62613de5f1d6ca4 (patch)
tree8835e7f64a5ffc2d54159f9979277b4e0bb315cb /src/generics.rs
parent4755104910a20fe4ce11d3d37fc72f28f5f75133 (diff)
downloadsyn-2a0b02fed953ff7d46c41ecbd62613de5f1d6ca4.tar.gz
Avoid printing 'where' keyword in empty where-clause
A 'where' keyword with an empty where-clause is not supported before Rust 1.16. struct S where {} Do some convenient legalization by omitting the 'where' keyword if there are no predicates in the where-clause. If the user really wants the WhereClause printed faithfully they can print 'where_token' and 'predicates' themselves directly.
Diffstat (limited to 'src/generics.rs')
-rw-r--r--src/generics.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/generics.rs b/src/generics.rs
index b86f77dc..13a850bb 100644
--- a/src/generics.rs
+++ b/src/generics.rs
@@ -950,8 +950,10 @@ mod printing {
impl ToTokens for WhereClause {
fn to_tokens(&self, tokens: &mut Tokens) {
- self.where_token.to_tokens(tokens);
- self.predicates.to_tokens(tokens);
+ if !self.predicates.is_empty() {
+ self.where_token.to_tokens(tokens);
+ self.predicates.to_tokens(tokens);
+ }
}
}