diff options
| author | bors <bors@rust-lang.org> | 2019-12-03 13:21:03 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-12-03 13:21:03 +0000 |
| commit | f577b0ef6e637ab7a6095cdfe0b51fa3faf97050 (patch) | |
| tree | 3acfc5e36ad8991bf613d5b85e3274c816a8b970 /src/libsyntax_ext/assert.rs | |
| parent | 7d808659cdc6c979a992fe3db345c0cfb53d973e (diff) | |
| parent | bce77980a2611da10b42dbd8a672c8cd17f79a94 (diff) | |
| download | rust-f577b0ef6e637ab7a6095cdfe0b51fa3faf97050.tar.gz rust-f577b0ef6e637ab7a6095cdfe0b51fa3faf97050.zip | |
Auto merge of #66982 - Centril:rollup-yq2281i, r=Centril
Rollup of 6 pull requests Successful merges: - #66148 (Show the sign for signed ops on `exact_div`) - #66651 (Add `enclosing scope` parameter to `rustc_on_unimplemented`) - #66904 (Adding docs for keyword match, move) - #66935 (syntax: Unify macro and attribute arguments in AST) - #66941 (Remove `ord` lang item) - #66967 (Remove hack for top-level or-patterns in match checking) Failed merges: r? @ghost
Diffstat (limited to 'src/libsyntax_ext/assert.rs')
| -rw-r--r-- | src/libsyntax_ext/assert.rs | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/libsyntax_ext/assert.rs b/src/libsyntax_ext/assert.rs index c4f3c03813f..c788d062994 100644 --- a/src/libsyntax_ext/assert.rs +++ b/src/libsyntax_ext/assert.rs @@ -6,7 +6,7 @@ use syntax::token::{self, TokenKind}; use syntax::print::pprust; use syntax::ptr::P; use syntax::symbol::{sym, Symbol}; -use syntax::tokenstream::{TokenStream, TokenTree}; +use syntax::tokenstream::{DelimSpan, TokenStream, TokenTree}; use syntax_expand::base::*; use syntax_pos::{Span, DUMMY_SP}; @@ -26,19 +26,19 @@ pub fn expand_assert<'cx>( // `core::panic` and `std::panic` are different macros, so we use call-site // context to pick up whichever is currently in scope. 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), + DUMMY_SP, + )) + }); + let args = P(MacArgs::Delimited(DelimSpan::from_single(sp), MacDelimiter::Parenthesis, tokens)); let panic_call = Mac { path: Path::from_ident(Ident::new(sym::panic, sp)), - tts: 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), - DUMMY_SP, - )) - }).into(), - delim: MacDelimiter::Parenthesis, - span: sp, + args, prior_type_ascription: None, }; let if_expr = cx.expr_if( |
