diff --git a/macros/src/lib.rs b/macros/src/lib.rs index f374f28f..29ad1b31 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -18,10 +18,9 @@ extern crate mac; // See https://github.com/rust-lang/rust/pull/23857 macro_rules! panictry { ($e:expr) => ({ - use syntax::diagnostic::FatalError; match $e { Ok(e) => e, - Err(FatalError) => panic!(FatalError) + Err(err) => panic!("{:?}", err), } }) } diff --git a/macros/src/match_token.rs b/macros/src/match_token.rs index 0e9a3237..09b8148f 100644 --- a/macros/src/match_token.rs +++ b/macros/src/match_token.rs @@ -100,12 +100,12 @@ matching, by enforcing the following restrictions on its input: use std::collections::{HashSet, HashMap}; use std::collections::hash_map::Entry::{Occupied, Vacant}; -use syntax::diagnostic::FatalError; +use syntax::errors::FatalError; use syntax::ptr::P; use syntax::codemap::{Span, Spanned, spanned}; use syntax::ast; use syntax::parse::parser::{Parser, Restrictions}; -use syntax::parse::{token, parser, classify}; +use syntax::parse::{token, parser, classify, PResult}; use syntax::parse; use syntax::ext::base::{ExtCtxt, MacResult, MacEager}; @@ -170,22 +170,22 @@ fn push_all(lhs: &mut Vec, rhs: Vec) { lhs.extend(rhs.into_iter()); } -fn parse_spanned_ident(parser: &mut Parser) -> Result { +fn parse_spanned_ident<'a>(parser: &mut Parser<'a>) -> PResult<'a, ast::SpannedIdent> { let lo = parser.span.lo; let ident = try!(parser.parse_ident()); let hi = parser.last_span.hi; Ok(spanned(lo, hi, ident)) } -fn parse_tag(parser: &mut Parser) -> Result, FatalError> { +fn parse_tag<'a>(parser: &mut Parser<'a>) -> PResult<'a, Spanned> { let lo = parser.span.lo; try!(parser.expect(&token::Lt)); - let kind = match try!(parser.eat(&token::BinOp(token::Slash))) { + let kind = match parser.eat(&token::BinOp(token::Slash)) { true => EndTag, false => StartTag, }; - let name = match try!(parser.eat(&token::Underscore)) { + let name = match parser.eat(&token::Underscore) { true => None, false => Some((*try!(parser.parse_ident()).name.as_str()).to_owned()), }; @@ -198,10 +198,10 @@ fn parse_tag(parser: &mut Parser) -> Result, FatalError> { } /// Parse a `match_token!` invocation into the little AST defined above. -fn parse(cx: &mut ExtCtxt, toks: &[ast::TokenTree]) -> Result { +fn parse<'a>(cx: &mut ExtCtxt<'a>, toks: &[ast::TokenTree]) -> PResult<'a, Match> { let mut parser = parse::new_parser_from_tts(cx.parse_sess(), cx.cfg(), toks.to_vec()); - let discriminant = try!(parser.parse_expr_res(Restrictions::RESTRICTION_NO_STRUCT_LITERAL)); + let discriminant = try!(parser.parse_expr_res(Restrictions::RESTRICTION_NO_STRUCT_LITERAL, None)); try!(parser.commit_expr_expecting(&*discriminant, token::OpenDelim(token::Brace))); let mut arms: Vec = Vec::new(); @@ -209,7 +209,7 @@ fn parse(cx: &mut ExtCtxt, toks: &[ast::TokenTree]) -> Result let mut binding = None; if parser.look_ahead(1, |t| *t == token::At) { binding = Some(try!(parse_spanned_ident(&mut parser))); - try!(parser.bump()); // Consume the @ + parser.bump() // Consume the @ } let lhs_lo = parser.span.lo; @@ -230,11 +230,11 @@ fn parse(cx: &mut ExtCtxt, toks: &[ast::TokenTree]) -> Result let rhs_lo = parser.span.lo; let mut rhs_hi = parser.span.hi; - let rhs = if try!(parser.eat_keyword(token::keywords::Else)) { + let rhs = if parser.eat_keyword(token::keywords::Else) { try!(parser.expect(&token::Comma)); Else } else { - let expr = try!(parser.parse_expr_res(Restrictions::RESTRICTION_STMT_EXPR)); + let expr = try!(parser.parse_expr_res(Restrictions::RESTRICTION_STMT_EXPR, None)); rhs_hi = parser.last_span.hi; let require_comma = @@ -245,7 +245,7 @@ fn parse(cx: &mut ExtCtxt, toks: &[ast::TokenTree]) -> Result try!(parser.commit_expr( &*expr, &[token::Comma], &[token::CloseDelim(token::Brace)])); } else { - try!(parser.eat(&token::Comma)); + parser.eat(&token::Comma); } Expr(expr) @@ -259,7 +259,7 @@ fn parse(cx: &mut ExtCtxt, toks: &[ast::TokenTree]) -> Result } // Consume the closing brace - try!(parser.bump()); + parser.bump(); Ok(Match { discriminant: discriminant, @@ -436,7 +436,7 @@ pub fn expand_to_tokens(cx: &mut ExtCtxt, span: Span, toks: &[ast::TokenTree]) (None, Tags(_), _) => ext_err!(lhs.span, "the last arm cannot have tag patterns"), (None, _, Else) => ext_err!(rhs.span, "the last arm cannot use 'else'"), (None, Pat(p), Expr(e)) => match p.node { - ast::PatWild | ast::PatIdent(..) => (p, e), + ast::PatKind::Wild | ast::PatKind::Ident(..) => (p, e), _ => ext_err!(lhs.span, "the last arm must have a wildcard or ident pattern"), }, }; diff --git a/macros/src/pre_expand.rs b/macros/src/pre_expand.rs index a63d881b..ee4423a0 100644 --- a/macros/src/pre_expand.rs +++ b/macros/src/pre_expand.rs @@ -32,7 +32,7 @@ pub fn pre_expand(from: &Path, to: &Path) { let from = from.to_string_lossy().into_owned(); let tts = parse::parse_tts_from_source_str(from, source, vec![], &sess); - let tts = find_and_expand_match_token(&mut cx, tts); + let tts = find_and_expand_match_token(&mut cx, tts.unwrap()); let tts = pretty(&mut cx, tts); let expanded = print::pprust::tts_to_string(&tts); diff --git a/scripts/travis-build.sh b/scripts/travis-build.sh index 960a9f82..c4e6fbb4 100755 --- a/scripts/travis-build.sh +++ b/scripts/travis-build.sh @@ -14,6 +14,7 @@ if [ $TRAVIS_RUST_VERSION = nightly ] then cargo test --features "rustc-test/capture" cargo test --features "rustc-test/capture unstable" + (cd macros && cargo build) else cargo test fi