diff options
| author | bors <bors@rust-lang.org> | 2019-12-23 02:47:52 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-12-23 02:47:52 +0000 |
| commit | a916ac22b9f7f1f0f7aba0a41a789b3ecd765018 (patch) | |
| tree | 139cba4184f0f290fdbdff1aa0aa68352b16ccbb /src/libsyntax_ext/assert.rs | |
| parent | 9b98af84c4aa66392236fff59c86da2130d46d46 (diff) | |
| parent | 0f24ccd21d9f734a21daaf3566900127167556d1 (diff) | |
Auto merge of #67540 - Mark-Simulacrum:fmt-the-world, r=Centril
Format the world This PR modifies the formatting infrastructure a bit in the first commit (to enable the forgotten 2018 edition), as well as removes most directories from the ignore list in rustfmt.toml. It then follows that up with the second commit which runs `x.py fmt` and formats the entire repository. We continue to not format the test directory (`src/test`) because of interactions with pretty printing and, in part, because re-blessing all of those files is somewhat harder to review, so is best suited for a follow up PR in my opinion.
Diffstat (limited to 'src/libsyntax_ext/assert.rs')
| -rw-r--r-- | src/libsyntax_ext/assert.rs | 65 |
1 files changed, 31 insertions, 34 deletions
diff --git a/src/libsyntax_ext/assert.rs b/src/libsyntax_ext/assert.rs index c788d062994..331e9fa61d0 100644 --- a/src/libsyntax_ext/assert.rs +++ b/src/libsyntax_ext/assert.rs @@ -2,10 +2,10 @@ use errors::{Applicability, DiagnosticBuilder}; use rustc_parse::parser::Parser; use syntax::ast::{self, *}; -use syntax::token::{self, TokenKind}; use syntax::print::pprust; use syntax::ptr::P; use syntax::symbol::{sym, Symbol}; +use syntax::token::{self, TokenKind}; use syntax::tokenstream::{DelimSpan, TokenStream, TokenTree}; use syntax_expand::base::*; use syntax_pos::{Span, DUMMY_SP}; @@ -28,10 +28,14 @@ pub fn expand_assert<'cx>( let sp = cx.with_call_site_ctxt(sp); let tokens = custom_message.unwrap_or_else(|| { TokenStream::from(TokenTree::token( - TokenKind::lit(token::Str, Symbol::intern(&format!( - "assertion failed: {}", - pprust::expr_to_string(&cond_expr).escape_debug() - )), None), + TokenKind::lit( + token::Str, + Symbol::intern(&format!( + "assertion failed: {}", + pprust::expr_to_string(&cond_expr).escape_debug() + )), + None, + ), DUMMY_SP, )) }); @@ -44,10 +48,7 @@ pub fn expand_assert<'cx>( let if_expr = cx.expr_if( sp, cx.expr(sp, ExprKind::Unary(UnOp::Not, cond_expr)), - cx.expr( - sp, - ExprKind::Mac(panic_call), - ), + cx.expr(sp, ExprKind::Mac(panic_call)), None, ); MacEager::expr(if_expr) @@ -61,7 +62,7 @@ struct Assert { fn parse_assert<'a>( cx: &mut ExtCtxt<'a>, sp: Span, - stream: TokenStream + stream: TokenStream, ) -> Result<Assert, DiagnosticBuilder<'a>> { let mut parser = cx.new_parser_from_tts(stream); @@ -87,7 +88,7 @@ fn parse_assert<'a>( parser.token.span, "try removing semicolon", String::new(), - Applicability::MaybeIncorrect + Applicability::MaybeIncorrect, ); err.note("this is going to be an error in the future"); err.emit(); @@ -102,25 +103,25 @@ fn parse_assert<'a>( // // Parse this as an actual message, and suggest inserting a comma. Eventually, this should be // turned into an error. - let custom_message = if let token::Literal(token::Lit { kind: token::Str, .. }) - = parser.token.kind { - let mut err = cx.struct_span_warn(parser.token.span, "unexpected string literal"); - let comma_span = cx.source_map().next_point(parser.prev_span); - err.span_suggestion_short( - comma_span, - "try adding a comma", - ", ".to_string(), - Applicability::MaybeIncorrect - ); - err.note("this is going to be an error in the future"); - err.emit(); + let custom_message = + if let token::Literal(token::Lit { kind: token::Str, .. }) = parser.token.kind { + let mut err = cx.struct_span_warn(parser.token.span, "unexpected string literal"); + let comma_span = cx.source_map().next_point(parser.prev_span); + err.span_suggestion_short( + comma_span, + "try adding a comma", + ", ".to_string(), + Applicability::MaybeIncorrect, + ); + err.note("this is going to be an error in the future"); + err.emit(); - parse_custom_message(&mut parser) - } else if parser.eat(&token::Comma) { - parse_custom_message(&mut parser) - } else { - None - }; + parse_custom_message(&mut parser) + } else if parser.eat(&token::Comma) { + parse_custom_message(&mut parser) + } else { + None + }; if parser.token != token::Eof { parser.expect_one_of(&[], &[])?; @@ -132,9 +133,5 @@ fn parse_assert<'a>( fn parse_custom_message(parser: &mut Parser<'_>) -> Option<TokenStream> { let ts = parser.parse_tokens(); - if !ts.is_empty() { - Some(ts) - } else { - None - } + if !ts.is_empty() { Some(ts) } else { None } } |
