X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibsyntax%2Fparse%2Fmod.rs;h=72e4a74bc7355ff682dfcc86ead49191716f208c;hb=7335c7dd63cafe70ffca76677f9e33bc6eccefaa;hp=81803d6bd896f2df2b32e54078c66c0256b869b5;hpb=3484706c38272828efc50b2553578afc62230dbb;p=rust.git diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 81803d6bd89..72e4a74bc73 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -181,7 +181,7 @@ pub fn parse_tts_from_source_str(name: String, name, source ); - p.quote_depth += 1us; + p.quote_depth += 1; // right now this is re-creating the token trees from ... token trees. maybe_aborted(p.parse_all_token_trees(),p) } @@ -324,7 +324,7 @@ pub fn parse_tts_from_source_str(name: String, name, source ); - p.quote_depth += 1us; + p.quote_depth += 1; // right now this is re-creating the token trees from ... token trees. maybe_aborted(p.parse_all_token_trees(),p) } @@ -683,9 +683,9 @@ pub fn integer_lit(s: &str, suffix: Option<&str>, sd: &SpanHandler, sp: Span) -> match suffix { Some(suf) if looks_like_width_suffix(&['f'], suf) => { match base { - 16us => sd.span_err(sp, "hexadecimal float literal is not supported"), - 8us => sd.span_err(sp, "octal float literal is not supported"), - 2us => sd.span_err(sp, "binary float literal is not supported"), + 16 => sd.span_err(sp, "hexadecimal float literal is not supported"), + 8 => sd.span_err(sp, "octal float literal is not supported"), + 2 => sd.span_err(sp, "binary float literal is not supported"), _ => () } let ident = token::intern_and_get_ident(&*s); @@ -755,6 +755,7 @@ mod test { use ast; use abi; use attr::{first_attr_value_str_by_name, AttrMetaMethods}; + use parse; use parse::parser::Parser; use parse::token::{str_to_ident}; use print::pprust::item_to_string; @@ -1214,4 +1215,26 @@ fn wb() -> c_int { O_WRONLY as c_int } let doc = first_attr_value_str_by_name(item.attrs.as_slice(), "doc").unwrap(); assert_eq!(doc.get(), "/** doc comment\n * with CRLF */"); } + + #[test] + fn ttdelim_span() { + let sess = parse::new_parse_sess(); + let expr = parse::parse_expr_from_source_str("foo".to_string(), + "foo!( fn main() { body } )".to_string(), vec![], &sess); + + let tts = match expr.node { + ast::ExprMac(ref mac) => { + let ast::MacInvocTT(_, ref tts, _) = mac.node; + tts.clone() + } + _ => panic!("not a macro"), + }; + + let span = tts.iter().rev().next().unwrap().get_span(); + + match sess.span_diagnostic.cm.span_to_snippet(span) { + Some(s) => assert_eq!(&s[], "{ body }"), + None => panic!("could not get snippet"), + } + } }