diff options
| author | Jakub Bukaj <jakub@jakub.cc> | 2014-11-23 14:11:57 -0500 |
|---|---|---|
| committer | Jakub Bukaj <jakub@jakub.cc> | 2014-11-23 14:11:57 -0500 |
| commit | 4dbd6574b0d4825c7759e2b3755b5e0d6ac09233 (patch) | |
| tree | 5547242f9666aab358c9ce361e4f78f76ada994b /src/libsyntax/print/pprust.rs | |
| parent | 3594c588bb735117621f6a168116d9e1d086654a (diff) | |
| parent | d678684236fece2e8b55515f936c9429036f2d73 (diff) | |
| download | rust-4dbd6574b0d4825c7759e2b3755b5e0d6ac09233.tar.gz rust-4dbd6574b0d4825c7759e2b3755b5e0d6ac09233.zip | |
rollup merge of #19215: aochagavia/pretty
Closes https://github.com/rust-lang/rust/issues/19077 I would appreciate any guidance on how to write a test for this. I saw some examples in `test/pretty`, but there are different ways to test... With or without `.pp` files, with a `pp-exact` comment, etc.
Diffstat (limited to 'src/libsyntax/print/pprust.rs')
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 2b80be0bf2a..6960337c3e2 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -11,31 +11,25 @@ pub use self::AnnNode::*; use abi; -use ast::{FnUnboxedClosureKind, FnMutUnboxedClosureKind}; +use ast::{mod, FnUnboxedClosureKind, FnMutUnboxedClosureKind}; use ast::{FnOnceUnboxedClosureKind}; use ast::{MethodImplItem, RegionTyParamBound, TraitTyParamBound}; use ast::{RequiredMethod, ProvidedMethod, TypeImplItem, TypeTraitItem}; use ast::{UnboxedClosureKind}; -use ast; use ast_util; use owned_slice::OwnedSlice; use attr::{AttrMetaMethods, AttributeMethods}; -use codemap::{CodeMap, BytePos}; -use codemap; +use codemap::{mod, CodeMap, BytePos}; use diagnostic; -use parse::token::{BinOpToken, Token}; -use parse::token; +use parse::token::{mod, BinOpToken, Token}; use parse::lexer::comments; use parse; -use print::pp::{break_offset, word, space, zerobreak, hardbreak}; +use print::pp::{mod, break_offset, word, space, zerobreak, hardbreak}; use print::pp::{Breaks, Consistent, Inconsistent, eof}; -use print::pp; use ptr::P; -use std::ascii; -use std::io::IoResult; -use std::io; -use std::mem; +use std::{ascii, mem}; +use std::io::{mod, IoResult}; pub enum AnnNode<'a> { NodeIdent(&'a ast::Ident), @@ -2150,21 +2144,22 @@ impl<'a> State<'a> { try!(self.print_pat(&**p)); } try!(space(&mut self.s)); - match arm.guard { - Some(ref e) => { - try!(self.word_space("if")); - try!(self.print_expr(&**e)); - try!(space(&mut self.s)); - } - None => () + if let Some(ref e) = arm.guard { + try!(self.word_space("if")); + try!(self.print_expr(&**e)); + try!(space(&mut self.s)); } try!(self.word_space("=>")); match arm.body.node { ast::ExprBlock(ref blk) => { // the block will close the pattern's ibox - try!(self.print_block_unclosed_indent(&**blk, - indent_unit)); + try!(self.print_block_unclosed_indent(&**blk, indent_unit)); + + // If it is a user-provided unsafe block, print a comma after it + if let ast::UnsafeBlock(ast::UserProvided) = blk.rules { + try!(word(&mut self.s, ",")); + } } _ => { try!(self.end()); // close the ibox for the pattern |
