diff options
| author | bors <bors@rust-lang.org> | 2019-06-06 03:56:22 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-06-06 03:56:22 +0000 |
| commit | 740668dbd99dbf1726bbb0cca6cd0943ea2f7e27 (patch) | |
| tree | 7fcf783b5f92803e8ca4985eaa24097e76b6192c /src/libsyntax/print | |
| parent | 1bec46c9a5399d5e95c05e3428c3abd264780705 (diff) | |
| parent | ee890331f6e33afe12ef250eb6388db2aab7cbbf (diff) | |
| download | rust-740668dbd99dbf1726bbb0cca6cd0943ea2f7e27.tar.gz rust-740668dbd99dbf1726bbb0cca6cd0943ea2f7e27.zip | |
Auto merge of #57428 - alexreg:associated_type_bounds, r=nikomatsakis,Centril
Implementation of RFC 2289 (associated_type_bounds) This PR implements the [`asociated_type_bounds` feature](https://github.com/rust-lang/rfcs/blob/master/text/2289-associated-type-bounds.md). Associated type bounds are implemented in: - function/method arguments and return types - structs, enums, unions - associated items in traits - type aliases - type parameter defaults - trait objects - let bindings CC @nikomatsakis @centril
Diffstat (limited to 'src/libsyntax/print')
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index b81dc53ef68..57c01e9e3ef 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1715,7 +1715,7 @@ impl<'a> State<'a> { match els { Some(_else) => { match _else.node { - // "another else-if" + // Another `else if` block. ast::ExprKind::If(ref i, ref then, ref e) => { self.cbox(INDENT_UNIT - 1)?; self.ibox(0)?; @@ -1725,7 +1725,7 @@ impl<'a> State<'a> { self.print_block(then)?; self.print_else(e.as_ref().map(|e| &**e)) } - // "another else-if-let" + // Another `else if let` block. ast::ExprKind::IfLet(ref pats, ref expr, ref then, ref e) => { self.cbox(INDENT_UNIT - 1)?; self.ibox(0)?; @@ -1738,14 +1738,14 @@ impl<'a> State<'a> { self.print_block(then)?; self.print_else(e.as_ref().map(|e| &**e)) } - // "final else" + // Final `else` block. ast::ExprKind::Block(ref b, _) => { self.cbox(INDENT_UNIT - 1)?; self.ibox(0)?; self.s.word(" else ")?; self.print_block(b) } - // BLEAH, constraints would be great here + // Constraints would be great here! _ => { panic!("print_if saw if with weird alternative"); } @@ -2450,14 +2450,21 @@ impl<'a> State<'a> { let mut comma = data.args.len() != 0; - for binding in data.bindings.iter() { + for constraint in data.constraints.iter() { if comma { self.word_space(",")? } - self.print_ident(binding.ident)?; + self.print_ident(constraint.ident)?; self.s.space()?; - self.word_space("=")?; - self.print_type(&binding.ty)?; + match constraint.kind { + ast::AssocTyConstraintKind::Equality { ref ty } => { + self.word_space("=")?; + self.print_type(ty)?; + } + ast::AssocTyConstraintKind::Bound { ref bounds } => { + self.print_type_bounds(":", &*bounds)?; + } + } comma = true; } |
