diff options
| author | Christoph Schmidler <c.schmidler@gmail.com> | 2019-12-09 07:46:10 +0100 |
|---|---|---|
| committer | Christoph Schmidler <c.schmidler@gmail.com> | 2019-12-09 07:46:10 +0100 |
| commit | abf053d238e051390d5a1cfb62269a5853e77437 (patch) | |
| tree | d1c98f5b876a0d8f092f7003cab372b5dbe00f16 /src/libsyntax_ext/assert.rs | |
| parent | 969926fcfe68787595d384f53d19cf6b8c9df3e3 (diff) | |
| parent | e862c01aadb2d029864f7bb256cf6c85bbb5d7e4 (diff) | |
| download | rust-abf053d238e051390d5a1cfb62269a5853e77437.tar.gz rust-abf053d238e051390d5a1cfb62269a5853e77437.zip | |
Merge branch 'master' of github.com:TheSamsa/rust
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( |
