auto merge of #7598 : sanxiyn/rust/rollup-1, r=sanxiyn
c9b9462
r=z0w02e65782
r=cmr2045889
r=thestinger30fca57
r=huonw
This commit is contained in:
commit
e9897cd08a
@ -95,7 +95,7 @@ syn region rustDeriving start="deriving(" end=")" contains=rustTrait
|
||||
" Number literals
|
||||
syn match rustNumber display "\<[0-9][0-9_]*\>"
|
||||
syn match rustNumber display "\<[0-9][0-9_]*\(u\|u8\|u16\|u32\|u64\)\>"
|
||||
syn match rustNumber display "\<[0-9][0-9_]*\(i8\|i16\|i32\|i64\)\>"
|
||||
syn match rustNumber display "\<[0-9][0-9_]*\(i\|i8\|i16\|i32\|i64\)\>"
|
||||
|
||||
syn match rustHexNumber display "\<0x[a-fA-F0-9_]\+\>"
|
||||
syn match rustHexNumber display "\<0x[a-fA-F0-9_]\+\(u\|u8\|u16\|u32\|u64\)\>"
|
||||
|
@ -17,7 +17,7 @@ use front::config;
|
||||
use std::vec;
|
||||
use syntax::ast_util::*;
|
||||
use syntax::attr;
|
||||
use syntax::codemap::{dummy_sp, span, ExpandedFrom, CallInfo, NameAndSpan};
|
||||
use syntax::codemap::{dummy_sp, span, ExpnInfo, NameAndSpan};
|
||||
use syntax::codemap;
|
||||
use syntax::ext::base::ExtCtxt;
|
||||
use syntax::fold;
|
||||
@ -72,13 +72,13 @@ fn generate_test_harness(sess: session::Session,
|
||||
};
|
||||
|
||||
let ext_cx = cx.ext_cx;
|
||||
ext_cx.bt_push(ExpandedFrom(CallInfo {
|
||||
ext_cx.bt_push(ExpnInfo {
|
||||
call_site: dummy_sp(),
|
||||
callee: NameAndSpan {
|
||||
name: @"test",
|
||||
span: None
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
let precursor = @fold::AstFoldFns {
|
||||
fold_crate: fold::wrap(|a,b| fold_crate(cx, a, b) ),
|
||||
|
@ -966,10 +966,6 @@ fn lint_unused_mut() -> visit::vt<@mut Context> {
|
||||
visit_fn_decl(cx, &tm.decl);
|
||||
visit::visit_ty_method(tm, (cx, vt));
|
||||
},
|
||||
visit_struct_method: |sm, (cx, vt)| {
|
||||
visit_fn_decl(cx, &sm.decl);
|
||||
visit::visit_struct_method(sm, (cx, vt));
|
||||
},
|
||||
visit_trait_method: |tm, (cx, vt)| {
|
||||
match *tm {
|
||||
ast::required(ref tm) => visit_fn_decl(cx, &tm.decl),
|
||||
@ -1049,14 +1045,6 @@ fn lint_missing_doc() -> visit::vt<@mut Context> {
|
||||
}
|
||||
|
||||
visit::mk_vt(@visit::Visitor {
|
||||
visit_struct_method: |m, (cx, vt)| {
|
||||
if m.vis == ast::public {
|
||||
check_attrs(cx, m.attrs, m.span,
|
||||
"missing documentation for a method");
|
||||
}
|
||||
visit::visit_struct_method(m, (cx, vt));
|
||||
},
|
||||
|
||||
visit_ty_method: |m, (cx, vt)| {
|
||||
// All ty_method objects are linted about because they're part of a
|
||||
// trait (no visibility)
|
||||
|
@ -174,16 +174,11 @@ pub struct FileMapAndBytePos {fm: @FileMap, pos: BytePos}
|
||||
#[deriving(IterBytes)]
|
||||
pub struct NameAndSpan {name: @str, span: Option<span>}
|
||||
|
||||
#[deriving(IterBytes)]
|
||||
pub struct CallInfo {
|
||||
call_site: span,
|
||||
callee: NameAndSpan
|
||||
}
|
||||
|
||||
/// Extra information for tracking macro expansion of spans
|
||||
#[deriving(IterBytes)]
|
||||
pub enum ExpnInfo {
|
||||
ExpandedFrom(CallInfo)
|
||||
pub struct ExpnInfo {
|
||||
call_site: span,
|
||||
callee: NameAndSpan
|
||||
}
|
||||
|
||||
pub type FileName = @str;
|
||||
|
@ -11,8 +11,7 @@
|
||||
use ast;
|
||||
use ast::Name;
|
||||
use codemap;
|
||||
use codemap::{CodeMap, span, ExpnInfo, ExpandedFrom};
|
||||
use codemap::CallInfo;
|
||||
use codemap::{CodeMap, span, ExpnInfo};
|
||||
use diagnostic::span_handler;
|
||||
use ext;
|
||||
use parse;
|
||||
@ -243,7 +242,7 @@ impl ExtCtxt {
|
||||
pub fn cfg(&self) -> ast::crate_cfg { copy self.cfg }
|
||||
pub fn call_site(&self) -> span {
|
||||
match *self.backtrace {
|
||||
Some(@ExpandedFrom(CallInfo {call_site: cs, _})) => cs,
|
||||
Some(@ExpnInfo {call_site: cs, _}) => cs,
|
||||
None => self.bug("missing top span")
|
||||
}
|
||||
}
|
||||
@ -254,21 +253,19 @@ impl ExtCtxt {
|
||||
pub fn mod_path(&self) -> ~[ast::ident] { copy *self.mod_path }
|
||||
pub fn bt_push(&self, ei: codemap::ExpnInfo) {
|
||||
match ei {
|
||||
ExpandedFrom(CallInfo {call_site: cs, callee: ref callee}) => {
|
||||
ExpnInfo {call_site: cs, callee: ref callee} => {
|
||||
*self.backtrace =
|
||||
Some(@ExpandedFrom(CallInfo {
|
||||
Some(@ExpnInfo {
|
||||
call_site: span {lo: cs.lo, hi: cs.hi,
|
||||
expn_info: *self.backtrace},
|
||||
callee: copy *callee}));
|
||||
callee: copy *callee});
|
||||
}
|
||||
}
|
||||
}
|
||||
pub fn bt_pop(&self) {
|
||||
match *self.backtrace {
|
||||
Some(@ExpandedFrom(
|
||||
CallInfo {
|
||||
call_site: span {expn_info: prev, _}, _
|
||||
})) => {
|
||||
Some(@ExpnInfo {
|
||||
call_site: span {expn_info: prev, _}, _}) => {
|
||||
*self.backtrace = prev
|
||||
}
|
||||
_ => self.bug("tried to pop without a push")
|
||||
|
@ -16,7 +16,7 @@ use ast;
|
||||
use ast_util::{new_rename, new_mark, resolve};
|
||||
use attr;
|
||||
use codemap;
|
||||
use codemap::{span, CallInfo, ExpandedFrom, NameAndSpan, spanned};
|
||||
use codemap::{span, ExpnInfo, NameAndSpan, spanned};
|
||||
use ext::base::*;
|
||||
use fold::*;
|
||||
use parse;
|
||||
@ -60,13 +60,13 @@ pub fn expand_expr(extsbox: @mut SyntaxEnv,
|
||||
expander: exp,
|
||||
span: exp_sp
|
||||
}))) => {
|
||||
cx.bt_push(ExpandedFrom(CallInfo {
|
||||
cx.bt_push(ExpnInfo {
|
||||
call_site: s,
|
||||
callee: NameAndSpan {
|
||||
name: extnamestr,
|
||||
span: exp_sp,
|
||||
},
|
||||
}));
|
||||
});
|
||||
|
||||
let expanded = match exp(cx, mac.span, *tts) {
|
||||
MRExpr(e) => e,
|
||||
@ -131,13 +131,13 @@ pub fn expand_mod_items(extsbox: @mut SyntaxEnv,
|
||||
|
||||
match (*extsbox).find(&intern(mname)) {
|
||||
Some(@SE(ItemDecorator(dec_fn))) => {
|
||||
cx.bt_push(ExpandedFrom(CallInfo {
|
||||
cx.bt_push(ExpnInfo {
|
||||
call_site: attr.span,
|
||||
callee: NameAndSpan {
|
||||
name: mname,
|
||||
span: None
|
||||
}
|
||||
}));
|
||||
});
|
||||
let r = dec_fn(cx, attr.span, attr.node.value, items);
|
||||
cx.bt_pop();
|
||||
r
|
||||
@ -227,13 +227,13 @@ pub fn expand_item_mac(extsbox: @mut SyntaxEnv,
|
||||
given '%s'", extnamestr,
|
||||
ident_to_str(&it.ident)));
|
||||
}
|
||||
cx.bt_push(ExpandedFrom(CallInfo {
|
||||
cx.bt_push(ExpnInfo {
|
||||
call_site: it.span,
|
||||
callee: NameAndSpan {
|
||||
name: extnamestr,
|
||||
span: expand.span
|
||||
}
|
||||
}));
|
||||
});
|
||||
((*expand).expander)(cx, it.span, tts)
|
||||
}
|
||||
Some(@SE(IdentTT(ref expand))) => {
|
||||
@ -242,13 +242,13 @@ pub fn expand_item_mac(extsbox: @mut SyntaxEnv,
|
||||
fmt!("macro %s! expects an ident argument",
|
||||
extnamestr));
|
||||
}
|
||||
cx.bt_push(ExpandedFrom(CallInfo {
|
||||
cx.bt_push(ExpnInfo {
|
||||
call_site: it.span,
|
||||
callee: NameAndSpan {
|
||||
name: extnamestr,
|
||||
span: expand.span
|
||||
}
|
||||
}));
|
||||
});
|
||||
((*expand).expander)(cx, it.span, it.ident, tts)
|
||||
}
|
||||
_ => cx.span_fatal(
|
||||
@ -319,10 +319,10 @@ pub fn expand_stmt(extsbox: @mut SyntaxEnv,
|
||||
|
||||
Some(@SE(NormalTT(
|
||||
SyntaxExpanderTT{expander: exp, span: exp_sp}))) => {
|
||||
cx.bt_push(ExpandedFrom(CallInfo {
|
||||
cx.bt_push(ExpnInfo {
|
||||
call_site: sp,
|
||||
callee: NameAndSpan { name: extnamestr, span: exp_sp }
|
||||
}));
|
||||
});
|
||||
let expanded = match exp(cx, mac.span, tts) {
|
||||
MRExpr(e) =>
|
||||
@codemap::spanned { node: stmt_expr(e, cx.next_id()),
|
||||
|
@ -10,8 +10,8 @@
|
||||
|
||||
use ast;
|
||||
use codemap;
|
||||
use codemap::{Pos, ExpandedFrom, span};
|
||||
use codemap::{CallInfo, NameAndSpan};
|
||||
use codemap::{Pos, span};
|
||||
use codemap::{ExpnInfo, NameAndSpan};
|
||||
use ext::base::*;
|
||||
use ext::base;
|
||||
use ext::build::AstBuilder;
|
||||
@ -117,14 +117,14 @@ pub fn expand_include_bin(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
|
||||
// recur along an ExpnInfo chain to find the original expression
|
||||
fn topmost_expn_info(expn_info: @codemap::ExpnInfo) -> @codemap::ExpnInfo {
|
||||
match *expn_info {
|
||||
ExpandedFrom(CallInfo { call_site: ref call_site, _ }) => {
|
||||
ExpnInfo { call_site: ref call_site, _ } => {
|
||||
match call_site.expn_info {
|
||||
Some(next_expn_info) => {
|
||||
match *next_expn_info {
|
||||
ExpandedFrom(CallInfo {
|
||||
ExpnInfo {
|
||||
callee: NameAndSpan { name: ref name, _ },
|
||||
_
|
||||
}) => {
|
||||
} => {
|
||||
// Don't recurse into file using "include!"
|
||||
if "include" == *name {
|
||||
expn_info
|
||||
|
@ -1549,10 +1549,10 @@ impl Parser {
|
||||
} else if self.eat_keyword(keywords::If) {
|
||||
return self.parse_if_expr();
|
||||
} else if self.eat_keyword(keywords::For) {
|
||||
return self.parse_sugary_call_expr(~"for", ForSugar,
|
||||
return self.parse_sugary_call_expr(lo, ~"for", ForSugar,
|
||||
expr_loop_body);
|
||||
} else if self.eat_keyword(keywords::Do) {
|
||||
return self.parse_sugary_call_expr(~"do", DoSugar,
|
||||
return self.parse_sugary_call_expr(lo, ~"do", DoSugar,
|
||||
expr_do_body);
|
||||
} else if self.eat_keyword(keywords::While) {
|
||||
return self.parse_while_expr();
|
||||
@ -2264,12 +2264,11 @@ impl Parser {
|
||||
// parse a 'for' or 'do'.
|
||||
// the 'for' and 'do' expressions parse as calls, but look like
|
||||
// function calls followed by a closure expression.
|
||||
pub fn parse_sugary_call_expr(&self,
|
||||
pub fn parse_sugary_call_expr(&self, lo: BytePos,
|
||||
keyword: ~str,
|
||||
sugar: CallSugar,
|
||||
ctor: &fn(v: @expr) -> expr_)
|
||||
-> @expr {
|
||||
let lo = self.last_span;
|
||||
// Parse the callee `foo` in
|
||||
// for foo || {
|
||||
// for foo.bar || {
|
||||
@ -2286,21 +2285,21 @@ impl Parser {
|
||||
let last_arg = self.mk_expr(block.span.lo, block.span.hi,
|
||||
ctor(block));
|
||||
let args = vec::append(copy *args, [last_arg]);
|
||||
self.mk_expr(lo.lo, block.span.hi, expr_call(f, args, sugar))
|
||||
self.mk_expr(lo, block.span.hi, expr_call(f, args, sugar))
|
||||
}
|
||||
expr_method_call(_, f, i, ref tps, ref args, NoSugar) => {
|
||||
let block = self.parse_lambda_block_expr();
|
||||
let last_arg = self.mk_expr(block.span.lo, block.span.hi,
|
||||
ctor(block));
|
||||
let args = vec::append(copy *args, [last_arg]);
|
||||
self.mk_expr(lo.lo, block.span.hi,
|
||||
self.mk_expr(lo, block.span.hi,
|
||||
self.mk_method_call(f, i, copy *tps, args, sugar))
|
||||
}
|
||||
expr_field(f, i, ref tps) => {
|
||||
let block = self.parse_lambda_block_expr();
|
||||
let last_arg = self.mk_expr(block.span.lo, block.span.hi,
|
||||
ctor(block));
|
||||
self.mk_expr(lo.lo, block.span.hi,
|
||||
self.mk_expr(lo, block.span.hi,
|
||||
self.mk_method_call(f, i, copy *tps, ~[last_arg], sugar))
|
||||
}
|
||||
expr_path(*) | expr_call(*) | expr_method_call(*) |
|
||||
@ -2309,7 +2308,7 @@ impl Parser {
|
||||
let last_arg = self.mk_expr(block.span.lo, block.span.hi,
|
||||
ctor(block));
|
||||
self.mk_expr(
|
||||
lo.lo,
|
||||
lo,
|
||||
last_arg.span.hi,
|
||||
self.mk_call(e, ~[last_arg], sugar))
|
||||
}
|
||||
@ -2319,7 +2318,7 @@ impl Parser {
|
||||
// but they aren't represented by tests
|
||||
debug!("sugary call on %?", e.node);
|
||||
self.span_fatal(
|
||||
*lo,
|
||||
e.span,
|
||||
fmt!("`%s` must be followed by a block call", keyword));
|
||||
}
|
||||
}
|
||||
|
@ -90,7 +90,6 @@ pub struct Visitor<E> {
|
||||
visit_trait_method: @fn(&trait_method, (E, vt<E>)),
|
||||
visit_struct_def: @fn(@struct_def, ident, &Generics, node_id, (E, vt<E>)),
|
||||
visit_struct_field: @fn(@struct_field, (E, vt<E>)),
|
||||
visit_struct_method: @fn(@method, (E, vt<E>))
|
||||
}
|
||||
|
||||
pub type visitor<E> = @Visitor<E>;
|
||||
@ -116,7 +115,6 @@ pub fn default_visitor<E: Copy>() -> visitor<E> {
|
||||
visit_trait_method: |a,b|visit_trait_method::<E>(a, b),
|
||||
visit_struct_def: |a,b,c,d,e|visit_struct_def::<E>(a, b, c, d, e),
|
||||
visit_struct_field: |a,b|visit_struct_field::<E>(a, b),
|
||||
visit_struct_method: |a,b|visit_struct_method::<E>(a, b)
|
||||
};
|
||||
}
|
||||
|
||||
@ -414,10 +412,6 @@ pub fn visit_struct_field<E: Copy>(sf: &struct_field, (e, v): (E, vt<E>)) {
|
||||
(v.visit_ty)(sf.node.ty, (e, v));
|
||||
}
|
||||
|
||||
pub fn visit_struct_method<E: Copy>(m: &method, (e, v): (E, vt<E>)) {
|
||||
visit_method_helper(m, (e, v));
|
||||
}
|
||||
|
||||
pub fn visit_block<E: Copy>(b: &blk, (e, v): (E, vt<E>)) {
|
||||
for b.node.view_items.iter().advance |vi| {
|
||||
(v.visit_view_item)(*vi, (copy e, v));
|
||||
@ -729,10 +723,6 @@ pub fn mk_simple_visitor(v: simple_visitor) -> vt<()> {
|
||||
f(sf);
|
||||
visit_struct_field(sf, (e, v));
|
||||
}
|
||||
fn v_struct_method(f: @fn(@method), m: @method, (e, v): ((), vt<()>)) {
|
||||
f(m);
|
||||
visit_struct_method(m, (e, v));
|
||||
}
|
||||
return mk_vt(@Visitor {
|
||||
visit_mod: |a,b,c,d|v_mod(v.visit_mod, a, b, c, d),
|
||||
visit_view_item: |a,b| v_view_item(v.visit_view_item, a, b),
|
||||
@ -760,7 +750,5 @@ pub fn mk_simple_visitor(v: simple_visitor) -> vt<()> {
|
||||
v_struct_def(v.visit_struct_def, a, b, c, d, e),
|
||||
visit_struct_field: |a,b|
|
||||
v_struct_field(v.visit_struct_field, a, b),
|
||||
visit_struct_method: |a,b|
|
||||
v_struct_method(v.visit_struct_method, a, b)
|
||||
});
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ fn main() {
|
||||
let needlesArr: ~[char] = ~['a', 'f'];
|
||||
do needlesArr.iter().fold() |x, y| {
|
||||
}
|
||||
//~^ ERROR 1 parameter was supplied (including the closure passed by the `do` keyword)
|
||||
//~^^ ERROR 1 parameter was supplied (including the closure passed by the `do` keyword)
|
||||
//
|
||||
// the first error is, um, non-ideal.
|
||||
}
|
||||
|
@ -108,7 +108,6 @@ fn main() {
|
||||
'\xA0', '\u1680', '\u180E', '\u2000', '\u2001', '\u2002', '\u2003',
|
||||
'\u2004', '\u2005', '\u2006', '\u2007', '\u2008', '\u2009', '\u200A',
|
||||
'\u2028', '\u2029', '\u202F', '\u205F', '\u3000'];
|
||||
// <= bugs in pretty-printer?
|
||||
for chars.iter().advance |c| {
|
||||
let ws = c.is_whitespace();
|
||||
println(fmt!("%? %?" , c , ws));
|
||||
|
@ -104,6 +104,6 @@ fn main() {
|
||||
'\u2028', '\u2029', '\u202F', '\u205F', '\u3000'];
|
||||
for chars.iter().advance |c| {
|
||||
let ws = c.is_whitespace();
|
||||
println(fmt!("%? %?", c , ws)); // <= bugs in pretty-printer?
|
||||
println(fmt!("%? %?", c , ws));
|
||||
}
|
||||
}
|
||||
|
18
src/test/pretty/for-comment.rs
Normal file
18
src/test/pretty/for-comment.rs
Normal file
@ -0,0 +1,18 @@
|
||||
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// pp-exact
|
||||
|
||||
fn f(v: &[int]) {
|
||||
let mut n = 0;
|
||||
for v.iter().advance |e| {
|
||||
n = *e; // This comment once triggered pretty printer bug
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user