diff options
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/Cargo.toml | 2 | ||||
| -rw-r--r-- | src/libsyntax/attr.rs | 3 | ||||
| -rw-r--r-- | src/libsyntax/codemap.rs | 43 | ||||
| -rw-r--r-- | src/libsyntax/ext/base.rs | 12 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/macro_rules.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/lib.rs | 7 | ||||
| -rw-r--r-- | src/libsyntax/parse/lexer/mod.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/parse/mod.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 67 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/test.rs | 4 |
12 files changed, 113 insertions, 53 deletions
diff --git a/src/libsyntax/Cargo.toml b/src/libsyntax/Cargo.toml index 97d37266130..82e7cfa0032 100644 --- a/src/libsyntax/Cargo.toml +++ b/src/libsyntax/Cargo.toml @@ -11,7 +11,7 @@ crate-type = ["dylib"] [dependencies] serialize = { path = "../libserialize" } log = "0.3" -rustc_bitflags = { path = "../librustc_bitflags" } +bitflags = "0.8" syntax_pos = { path = "../libsyntax_pos" } rustc_errors = { path = "../librustc_errors" } rustc_data_structures = { path = "../librustc_data_structures" } diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 82492d97627..0980b73e80c 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -511,8 +511,7 @@ pub fn find_export_name_attr(diag: &Handler, attrs: &[Attribute]) -> Option<Symb } else { struct_span_err!(diag, attr.span, E0558, "export_name attribute has invalid format") - .span_label(attr.span, - &format!("did you mean #[export_name=\"*\"]?")) + .span_label(attr.span, "did you mean #[export_name=\"*\"]?") .emit(); None } diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 8a88ec3a672..0c8be1d4f24 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -21,8 +21,8 @@ pub use syntax_pos::*; pub use syntax_pos::hygiene::{ExpnFormat, ExpnInfo, NameAndSpan}; pub use self::ExpnFormat::*; -use std::cell::RefCell; -use std::path::{Path,PathBuf}; +use std::cell::{RefCell, Ref}; +use std::path::{Path, PathBuf}; use std::rc::Rc; use std::env; @@ -103,11 +103,18 @@ impl FileLoader for RealFileLoader { // pub struct CodeMap { - pub files: RefCell<Vec<Rc<FileMap>>>, + // The `files` field should not be visible outside of libsyntax so that we + // can do proper dependency tracking. + pub(super) files: RefCell<Vec<Rc<FileMap>>>, file_loader: Box<FileLoader>, // This is used to apply the file path remapping as specified via // -Zremap-path-prefix to all FileMaps allocated within this CodeMap. path_mapping: FilePathMapping, + // The CodeMap will invoke this callback whenever a specific FileMap is + // accessed. The callback starts out as a no-op but when the dependency + // graph becomes available later during the compilation process, it is + // be replaced with something that notifies the dep-tracking system. + dep_tracking_callback: RefCell<Box<Fn(&FileMap)>>, } impl CodeMap { @@ -116,6 +123,7 @@ impl CodeMap { files: RefCell::new(Vec::new()), file_loader: Box::new(RealFileLoader), path_mapping: path_mapping, + dep_tracking_callback: RefCell::new(Box::new(|_| {})), } } @@ -126,6 +134,7 @@ impl CodeMap { files: RefCell::new(Vec::new()), file_loader: file_loader, path_mapping: path_mapping, + dep_tracking_callback: RefCell::new(Box::new(|_| {})), } } @@ -133,6 +142,10 @@ impl CodeMap { &self.path_mapping } + pub fn set_dep_tracking_callback(&self, cb: Box<Fn(&FileMap)>) { + *self.dep_tracking_callback.borrow_mut() = cb; + } + pub fn file_exists(&self, path: &Path) -> bool { self.file_loader.file_exists(path) } @@ -142,6 +155,19 @@ impl CodeMap { Ok(self.new_filemap(path.to_str().unwrap().to_string(), src)) } + pub fn files(&self) -> Ref<Vec<Rc<FileMap>>> { + let files = self.files.borrow(); + for file in files.iter() { + (self.dep_tracking_callback.borrow())(file); + } + files + } + + /// Only use this if you do your own dependency tracking! + pub fn files_untracked(&self) -> Ref<Vec<Rc<FileMap>>> { + self.files.borrow() + } + fn next_start_pos(&self) -> usize { let files = self.files.borrow(); match files.last() { @@ -170,6 +196,7 @@ impl CodeMap { let filemap = Rc::new(FileMap { name: filename, name_was_remapped: was_remapped, + crate_of_origin: 0, src: Some(Rc::new(src)), start_pos: Pos::from_usize(start_pos), end_pos: Pos::from_usize(end_pos), @@ -204,6 +231,7 @@ impl CodeMap { pub fn new_imported_filemap(&self, filename: FileName, name_was_remapped: bool, + crate_of_origin: u32, source_len: usize, mut file_local_lines: Vec<BytePos>, mut file_local_multibyte_chars: Vec<MultiByteChar>) @@ -225,6 +253,7 @@ impl CodeMap { let filemap = Rc::new(FileMap { name: filename, name_was_remapped: name_was_remapped, + crate_of_origin: crate_of_origin, src: None, start_pos: start_pos, end_pos: end_pos, @@ -282,6 +311,8 @@ impl CodeMap { let files = self.files.borrow(); let f = (*files)[idx].clone(); + (self.dep_tracking_callback.borrow())(&f); + match f.lookup_line(pos) { Some(line) => Ok(FileMapAndLine { fm: f, line: line }), None => Err(f) @@ -471,6 +502,7 @@ impl CodeMap { pub fn get_filemap(&self, filename: &str) -> Option<Rc<FileMap>> { for fm in self.files.borrow().iter() { if filename == fm.name { + (self.dep_tracking_callback.borrow())(&fm); return Some(fm.clone()); } } @@ -481,6 +513,7 @@ impl CodeMap { pub fn lookup_byte_offset(&self, bpos: BytePos) -> FileMapAndBytePos { let idx = self.lookup_filemap_idx(bpos); let fm = (*self.files.borrow())[idx].clone(); + (self.dep_tracking_callback.borrow())(&fm); let offset = bpos - fm.start_pos; FileMapAndBytePos {fm: fm, pos: offset} } @@ -491,6 +524,8 @@ impl CodeMap { let files = self.files.borrow(); let map = &(*files)[idx]; + (self.dep_tracking_callback.borrow())(map); + // The number of extra bytes due to multibyte chars in the FileMap let mut total_extra_bytes = 0; @@ -536,7 +571,7 @@ impl CodeMap { } pub fn count_lines(&self) -> usize { - self.files.borrow().iter().fold(0, |a, f| a + f.count_lines()) + self.files().iter().fold(0, |a, f| a + f.count_lines()) } } diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index fda026fec64..f731c5abdd6 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -24,6 +24,7 @@ use ptr::P; use symbol::Symbol; use util::small_vector::SmallVector; +use std::collections::HashMap; use std::path::PathBuf; use std::rc::Rc; use std::default::Default; @@ -643,6 +644,7 @@ pub struct ExtCtxt<'a> { pub resolver: &'a mut Resolver, pub resolve_err_count: usize, pub current_expansion: ExpansionData, + pub expansions: HashMap<Span, Vec<String>>, } impl<'a> ExtCtxt<'a> { @@ -662,6 +664,7 @@ impl<'a> ExtCtxt<'a> { module: Rc::new(ModuleData { mod_path: Vec::new(), directory: PathBuf::new() }), directory_ownership: DirectoryOwnership::Owned, }, + expansions: HashMap::new(), } } @@ -765,6 +768,15 @@ impl<'a> ExtCtxt<'a> { pub fn span_bug(&self, sp: Span, msg: &str) -> ! { self.parse_sess.span_diagnostic.span_bug(sp, msg); } + pub fn trace_macros_diag(&self) { + for (sp, notes) in self.expansions.iter() { + let mut db = self.parse_sess.span_diagnostic.span_note_diag(*sp, &"trace_macro"); + for note in notes { + db.note(¬e); + } + db.emit(); + } + } pub fn bug(&self, msg: &str) -> ! { self.parse_sess.span_diagnostic.bug(msg); } diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 2db295d0136..a8aa103f80a 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -231,7 +231,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { }, _ => unreachable!(), }; - + self.cx.trace_macros_diag(); krate } @@ -1038,7 +1038,7 @@ impl<'feat> ExpansionConfig<'feat> { ExpansionConfig { crate_name: crate_name, features: None, - recursion_limit: 64, + recursion_limit: 1024, trace_mac: false, should_test: false, single_step: false, diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index be979960725..f959ccc989e 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -27,8 +27,8 @@ use symbol::Symbol; use tokenstream::{TokenStream, TokenTree}; use std::cell::RefCell; -use std::collections::{HashMap}; -use std::collections::hash_map::{Entry}; +use std::collections::HashMap; +use std::collections::hash_map::Entry; use std::rc::Rc; pub struct ParserAnyMacro<'a> { @@ -85,7 +85,7 @@ impl TTMacroExpander for MacroRulesMacroExpander { } /// Given `lhses` and `rhses`, this is the new macro we create -fn generic_extension<'cx>(cx: &'cx ExtCtxt, +fn generic_extension<'cx>(cx: &'cx mut ExtCtxt, sp: Span, name: ast::Ident, arg: TokenStream, @@ -93,7 +93,9 @@ fn generic_extension<'cx>(cx: &'cx ExtCtxt, rhses: &[quoted::TokenTree]) -> Box<MacResult+'cx> { if cx.trace_macros() { - println!("{}! {{ {} }}", name, arg); + let sp = sp.macro_backtrace().last().map(|trace| trace.call_site).unwrap_or(sp); + let mut values: &mut Vec<String> = cx.expansions.entry(sp).or_insert(vec![]); + values.push(format!("expands to `{}! {{ {} }}`", name, arg)); } // Which arm's failure should we report? (the one furthest along) diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 86ee1c5336d..89c67b88cbd 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -24,20 +24,15 @@ test(attr(deny(warnings))))] #![deny(warnings)] -#![feature(associated_consts)] -#![feature(const_fn)] -#![feature(optin_builtin_traits)] #![feature(rustc_private)] #![feature(staged_api)] -#![feature(str_escape)] #![feature(unicode)] #![feature(rustc_diagnostic_macros)] -#![feature(specialization)] #![feature(i128_type)] extern crate serialize; #[macro_use] extern crate log; -#[macro_use] #[no_link] extern crate rustc_bitflags; +#[macro_use] extern crate bitflags; extern crate std_unicode; pub extern crate rustc_errors as errors; extern crate syntax_pos; diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index c2e5763237d..ded1f0b599a 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -73,7 +73,7 @@ fn mk_sp(lo: BytePos, hi: BytePos) -> Span { } impl<'a> StringReader<'a> { - fn next_token(&mut self) -> TokenAndSpan where Self: Sized { + fn next_token(&mut self) -> TokenAndSpan { let res = self.try_next_token(); self.unwrap_or_abort(res) } @@ -504,7 +504,7 @@ impl<'a> StringReader<'a> { self.bump(); // line comments starting with "///" or "//!" are doc-comments - let doc_comment = self.ch_is('/') || self.ch_is('!'); + let doc_comment = (self.ch_is('/') && !self.nextch_is('/')) || self.ch_is('!'); let start_bpos = self.pos - BytePos(2); while !self.is_eof() { diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 9d8f3b3d039..fe3ca1cf230 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -261,10 +261,14 @@ pub fn char_lit(lit: &str) -> (char, isize) { } } +pub fn escape_default(s: &str) -> String { + s.chars().map(char::escape_default).flat_map(|x| x).collect() +} + /// Parse a string representing a string literal into its final form. Does /// unescaping. pub fn str_lit(lit: &str) -> String { - debug!("parse_str_lit: given {}", lit.escape_default()); + debug!("parse_str_lit: given {}", escape_default(lit)); let mut res = String::with_capacity(lit.len()); // FIXME #8372: This could be a for-loop if it didn't borrow the iterator @@ -339,7 +343,7 @@ pub fn str_lit(lit: &str) -> String { /// Parse a string representing a raw string literal into its final form. The /// only operation this does is convert embedded CRLF into a single LF. pub fn raw_str_lit(lit: &str) -> String { - debug!("raw_str_lit: given {}", lit.escape_default()); + debug!("raw_str_lit: given {}", escape_default(lit)); let mut res = String::with_capacity(lit.len()); // FIXME #8372: This could be a for-loop if it didn't borrow the iterator diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index d252963274e..ca1351e3b41 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -64,7 +64,7 @@ use std::path::{self, Path, PathBuf}; use std::slice; bitflags! { - flags Restrictions: u8 { + pub flags Restrictions: u8 { const RESTRICTION_STMT_EXPR = 1 << 0, const RESTRICTION_NO_STRUCT_LITERAL = 1 << 1, } @@ -602,10 +602,10 @@ impl<'a> Parser<'a> { label_sp }; if self.span.contains(sp) { - err.span_label(self.span, &label_exp); + err.span_label(self.span, label_exp); } else { - err.span_label(sp, &label_exp); - err.span_label(self.span, &"unexpected token"); + err.span_label(sp, label_exp); + err.span_label(self.span, "unexpected token"); } Err(err) } @@ -1512,10 +1512,10 @@ impl<'a> Parser<'a> { err.span_suggestion(sum_span, "try adding parentheses:", sum_with_parens); } TyKind::Ptr(..) | TyKind::BareFn(..) => { - err.span_label(sum_span, &"perhaps you forgot parentheses?"); + err.span_label(sum_span, "perhaps you forgot parentheses?"); } _ => { - err.span_label(sum_span, &"expected a path"); + err.span_label(sum_span, "expected a path"); }, } err.emit(); @@ -2291,7 +2291,7 @@ impl<'a> Parser<'a> { let e = if self.token.can_begin_expr() && !(self.token == token::OpenDelim(token::Brace) && self.restrictions.contains( - Restrictions::RESTRICTION_NO_STRUCT_LITERAL)) { + RESTRICTION_NO_STRUCT_LITERAL)) { Some(self.parse_expr()?) } else { None @@ -2318,7 +2318,7 @@ impl<'a> Parser<'a> { // This is a struct literal, unless we're prohibited // from parsing struct literals here. let prohibited = self.restrictions.contains( - Restrictions::RESTRICTION_NO_STRUCT_LITERAL + RESTRICTION_NO_STRUCT_LITERAL ); if !prohibited { return self.parse_struct_expr(lo, pth, attrs); @@ -2556,7 +2556,7 @@ impl<'a> Parser<'a> { let fstr = n.as_str(); let mut err = self.diagnostic().struct_span_err(self.prev_span, &format!("unexpected token: `{}`", n)); - err.span_label(self.prev_span, &"unexpected token"); + err.span_label(self.prev_span, "unexpected token"); if fstr.chars().all(|x| "0123456789.".contains(x)) { let float = match fstr.parse::<f64>().ok() { Some(f) => f, @@ -2700,6 +2700,19 @@ impl<'a> Parser<'a> { let (span, e) = self.interpolated_or_expr_span(e)?; (span, self.mk_unary(UnOp::Not, e)) } + // Suggest `!` for bitwise negation when encountering a `~` + token::Tilde => { + self.bump(); + let e = self.parse_prefix_expr(None); + let (span, e) = self.interpolated_or_expr_span(e)?; + let span_of_tilde = lo; + let mut err = self.diagnostic().struct_span_err(span_of_tilde, + "`~` can not be used as a unary operator"); + err.span_label(span_of_tilde, "did you mean `!`?"); + err.help("use `!` instead of `~` if you meant to perform bitwise negation"); + err.emit(); + (span, self.mk_unary(UnOp::Not, e)) + } token::BinOp(token::Minus) => { self.bump(); let e = self.parse_prefix_expr(None); @@ -2722,7 +2735,7 @@ impl<'a> Parser<'a> { token::Ident(..) if self.token.is_keyword(keywords::In) => { self.bump(); let place = self.parse_expr_res( - Restrictions::RESTRICTION_NO_STRUCT_LITERAL, + RESTRICTION_NO_STRUCT_LITERAL, None, )?; let blk = self.parse_block()?; @@ -2785,7 +2798,7 @@ impl<'a> Parser<'a> { let cur_op_span = self.span; let restrictions = if op.is_assign_like() { - self.restrictions & Restrictions::RESTRICTION_NO_STRUCT_LITERAL + self.restrictions & RESTRICTION_NO_STRUCT_LITERAL } else { self.restrictions }; @@ -2835,13 +2848,13 @@ impl<'a> Parser<'a> { let rhs = match op.fixity() { Fixity::Right => self.with_res( - restrictions - Restrictions::RESTRICTION_STMT_EXPR, + restrictions - RESTRICTION_STMT_EXPR, |this| { this.parse_assoc_expr_with(op.precedence(), LhsExpr::NotYetParsed) }), Fixity::Left => self.with_res( - restrictions - Restrictions::RESTRICTION_STMT_EXPR, + restrictions - RESTRICTION_STMT_EXPR, |this| { this.parse_assoc_expr_with(op.precedence() + 1, LhsExpr::NotYetParsed) @@ -2849,7 +2862,7 @@ impl<'a> Parser<'a> { // We currently have no non-associative operators that are not handled above by // the special cases. The code is here only for future convenience. Fixity::None => self.with_res( - restrictions - Restrictions::RESTRICTION_STMT_EXPR, + restrictions - RESTRICTION_STMT_EXPR, |this| { this.parse_assoc_expr_with(op.precedence() + 1, LhsExpr::NotYetParsed) @@ -2959,7 +2972,7 @@ impl<'a> Parser<'a> { if self.token.can_begin_expr() { // parse `for i in 1.. { }` as infinite loop, not as `for i in (1..{})`. if self.token == token::OpenDelim(token::Brace) { - return !self.restrictions.contains(Restrictions::RESTRICTION_NO_STRUCT_LITERAL); + return !self.restrictions.contains(RESTRICTION_NO_STRUCT_LITERAL); } true } else { @@ -2973,7 +2986,7 @@ impl<'a> Parser<'a> { return self.parse_if_let_expr(attrs); } let lo = self.prev_span; - let cond = self.parse_expr_res(Restrictions::RESTRICTION_NO_STRUCT_LITERAL, None)?; + let cond = self.parse_expr_res(RESTRICTION_NO_STRUCT_LITERAL, None)?; let thn = self.parse_block()?; let mut els: Option<P<Expr>> = None; let mut hi = thn.span; @@ -2992,7 +3005,7 @@ impl<'a> Parser<'a> { self.expect_keyword(keywords::Let)?; let pat = self.parse_pat()?; self.expect(&token::Eq)?; - let expr = self.parse_expr_res(Restrictions::RESTRICTION_NO_STRUCT_LITERAL, None)?; + let expr = self.parse_expr_res(RESTRICTION_NO_STRUCT_LITERAL, None)?; let thn = self.parse_block()?; let (hi, els) = if self.eat_keyword(keywords::Else) { let expr = self.parse_else_expr()?; @@ -3046,7 +3059,7 @@ impl<'a> Parser<'a> { let pat = self.parse_pat()?; self.expect_keyword(keywords::In)?; - let expr = self.parse_expr_res(Restrictions::RESTRICTION_NO_STRUCT_LITERAL, None)?; + let expr = self.parse_expr_res(RESTRICTION_NO_STRUCT_LITERAL, None)?; let (iattrs, loop_block) = self.parse_inner_attrs_and_block()?; attrs.extend(iattrs); @@ -3061,7 +3074,7 @@ impl<'a> Parser<'a> { if self.token.is_keyword(keywords::Let) { return self.parse_while_let_expr(opt_ident, span_lo, attrs); } - let cond = self.parse_expr_res(Restrictions::RESTRICTION_NO_STRUCT_LITERAL, None)?; + let cond = self.parse_expr_res(RESTRICTION_NO_STRUCT_LITERAL, None)?; let (iattrs, body) = self.parse_inner_attrs_and_block()?; attrs.extend(iattrs); let span = span_lo.to(body.span); @@ -3075,7 +3088,7 @@ impl<'a> Parser<'a> { self.expect_keyword(keywords::Let)?; let pat = self.parse_pat()?; self.expect(&token::Eq)?; - let expr = self.parse_expr_res(Restrictions::RESTRICTION_NO_STRUCT_LITERAL, None)?; + let expr = self.parse_expr_res(RESTRICTION_NO_STRUCT_LITERAL, None)?; let (iattrs, body) = self.parse_inner_attrs_and_block()?; attrs.extend(iattrs); let span = span_lo.to(body.span); @@ -3105,7 +3118,7 @@ impl<'a> Parser<'a> { fn parse_match_expr(&mut self, mut attrs: ThinVec<Attribute>) -> PResult<'a, P<Expr>> { let match_span = self.prev_span; let lo = self.prev_span; - let discriminant = self.parse_expr_res(Restrictions::RESTRICTION_NO_STRUCT_LITERAL, + let discriminant = self.parse_expr_res(RESTRICTION_NO_STRUCT_LITERAL, None)?; if let Err(mut e) = self.expect(&token::OpenDelim(token::Brace)) { if self.token == token::Token::Semi { @@ -3146,7 +3159,7 @@ impl<'a> Parser<'a> { guard = Some(self.parse_expr()?); } self.expect(&token::FatArrow)?; - let expr = self.parse_expr_res(Restrictions::RESTRICTION_STMT_EXPR, None)?; + let expr = self.parse_expr_res(RESTRICTION_STMT_EXPR, None)?; let require_comma = !classify::expr_is_simple_block(&expr) @@ -3727,7 +3740,7 @@ impl<'a> Parser<'a> { self.look_ahead(2, |t| *t == token::OpenDelim(token::Brace)) && // prevent `while catch {} {}`, `if catch {} {} else {}`, etc. - !self.restrictions.contains(Restrictions::RESTRICTION_NO_STRUCT_LITERAL) + !self.restrictions.contains(RESTRICTION_NO_STRUCT_LITERAL) } fn is_union_item(&self) -> bool { @@ -3799,7 +3812,7 @@ impl<'a> Parser<'a> { self.mk_expr(lo.to(hi), ExprKind::Path(None, pth), ThinVec::new()) }; - let expr = self.with_res(Restrictions::RESTRICTION_STMT_EXPR, |this| { + let expr = self.with_res(RESTRICTION_STMT_EXPR, |this| { let expr = this.parse_dot_or_call_expr_with(expr, lo, attrs.into())?; this.parse_assoc_expr_with(0, LhsExpr::AlreadyParsed(expr)) })?; @@ -3939,7 +3952,7 @@ impl<'a> Parser<'a> { // Remainder are line-expr stmts. let e = self.parse_expr_res( - Restrictions::RESTRICTION_STMT_EXPR, Some(attrs.into()))?; + RESTRICTION_STMT_EXPR, Some(attrs.into()))?; Stmt { id: ast::DUMMY_NODE_ID, span: lo.to(e.span), @@ -3952,7 +3965,7 @@ impl<'a> Parser<'a> { /// Is this expression a successfully-parsed statement? fn expr_is_complete(&mut self, e: &Expr) -> bool { - self.restrictions.contains(Restrictions::RESTRICTION_STMT_EXPR) && + self.restrictions.contains(RESTRICTION_STMT_EXPR) && !classify::expr_requires_semi_to_be_stmt(e) } @@ -4779,7 +4792,7 @@ impl<'a> Parser<'a> { sp, &format!("missing `fn`, `type`, or `const` for {}-item declaration", item_type)); - err.span_label(sp, &"missing `fn`, `type`, or `const`"); + err.span_label(sp, "missing `fn`, `type`, or `const`"); err } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index a911c21ed98..0c7e8fda837 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -677,7 +677,7 @@ pub trait PrintState<'a> { style: ast::StrStyle) -> io::Result<()> { let st = match style { ast::StrStyle::Cooked => { - (format!("\"{}\"", st.escape_default())) + (format!("\"{}\"", parse::escape_default(st))) } ast::StrStyle::Raw(n) => { (format!("r{delim}\"{string}\"{delim}", diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index 50380626d7f..91746a2edd9 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -442,7 +442,7 @@ We're going to be building a module that looks more or less like: mod __test { extern crate test (name = "test", vers = "..."); fn main() { - test::test_main_static(&::os::args()[], tests) + test::test_main_static(&::os::args()[], tests, test::Options::new()) } static tests : &'static [test::TestDescAndFn] = &[ @@ -478,7 +478,7 @@ fn mk_main(cx: &mut TestCtxt) -> P<ast::Item> { // pub fn main() { // #![main] // use std::slice::AsSlice; - // test::test_main_static(::std::os::args().as_slice(), TESTS); + // test::test_main_static(::std::os::args().as_slice(), TESTS, test::Options::new()); // } let sp = ignored_span(cx, DUMMY_SP); |
