Skip to content

Commit e9897cd

Browse files
committed
auto merge of #7598 : sanxiyn/rust/rollup-1, r=sanxiyn
c9b9462 r=z0w0 2e65782 r=cmr 2045889 r=thestinger 30fca57 r=huonw
2 parents 6595c42 + 376d5d6 commit e9897cd

File tree

13 files changed

+57
-73
lines changed

13 files changed

+57
-73
lines changed

src/etc/vim/syntax/rust.vim

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ syn region rustDeriving start="deriving(" end=")" contains=rustTrait
9595
" Number literals
9696
syn match rustNumber display "\<[0-9][0-9_]*\>"
9797
syn match rustNumber display "\<[0-9][0-9_]*\(u\|u8\|u16\|u32\|u64\)\>"
98-
syn match rustNumber display "\<[0-9][0-9_]*\(i8\|i16\|i32\|i64\)\>"
98+
syn match rustNumber display "\<[0-9][0-9_]*\(i\|i8\|i16\|i32\|i64\)\>"
9999

100100
syn match rustHexNumber display "\<0x[a-fA-F0-9_]\+\>"
101101
syn match rustHexNumber display "\<0x[a-fA-F0-9_]\+\(u\|u8\|u16\|u32\|u64\)\>"

src/librustc/front/test.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use front::config;
1717
use std::vec;
1818
use syntax::ast_util::*;
1919
use syntax::attr;
20-
use syntax::codemap::{dummy_sp, span, ExpandedFrom, CallInfo, NameAndSpan};
20+
use syntax::codemap::{dummy_sp, span, ExpnInfo, NameAndSpan};
2121
use syntax::codemap;
2222
use syntax::ext::base::ExtCtxt;
2323
use syntax::fold;
@@ -72,13 +72,13 @@ fn generate_test_harness(sess: session::Session,
7272
};
7373

7474
let ext_cx = cx.ext_cx;
75-
ext_cx.bt_push(ExpandedFrom(CallInfo {
75+
ext_cx.bt_push(ExpnInfo {
7676
call_site: dummy_sp(),
7777
callee: NameAndSpan {
7878
name: @"test",
7979
span: None
8080
}
81-
}));
81+
});
8282

8383
let precursor = @fold::AstFoldFns {
8484
fold_crate: fold::wrap(|a,b| fold_crate(cx, a, b) ),

src/librustc/middle/lint.rs

-12
Original file line numberDiff line numberDiff line change
@@ -966,10 +966,6 @@ fn lint_unused_mut() -> visit::vt<@mut Context> {
966966
visit_fn_decl(cx, &tm.decl);
967967
visit::visit_ty_method(tm, (cx, vt));
968968
},
969-
visit_struct_method: |sm, (cx, vt)| {
970-
visit_fn_decl(cx, &sm.decl);
971-
visit::visit_struct_method(sm, (cx, vt));
972-
},
973969
visit_trait_method: |tm, (cx, vt)| {
974970
match *tm {
975971
ast::required(ref tm) => visit_fn_decl(cx, &tm.decl),
@@ -1049,14 +1045,6 @@ fn lint_missing_doc() -> visit::vt<@mut Context> {
10491045
}
10501046

10511047
visit::mk_vt(@visit::Visitor {
1052-
visit_struct_method: |m, (cx, vt)| {
1053-
if m.vis == ast::public {
1054-
check_attrs(cx, m.attrs, m.span,
1055-
"missing documentation for a method");
1056-
}
1057-
visit::visit_struct_method(m, (cx, vt));
1058-
},
1059-
10601048
visit_ty_method: |m, (cx, vt)| {
10611049
// All ty_method objects are linted about because they're part of a
10621050
// trait (no visibility)

src/libsyntax/codemap.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -174,18 +174,13 @@ pub struct FileMapAndBytePos {fm: @FileMap, pos: BytePos}
174174
#[deriving(IterBytes)]
175175
pub struct NameAndSpan {name: @str, span: Option<span>}
176176

177+
/// Extra information for tracking macro expansion of spans
177178
#[deriving(IterBytes)]
178-
pub struct CallInfo {
179+
pub struct ExpnInfo {
179180
call_site: span,
180181
callee: NameAndSpan
181182
}
182183

183-
/// Extra information for tracking macro expansion of spans
184-
#[deriving(IterBytes)]
185-
pub enum ExpnInfo {
186-
ExpandedFrom(CallInfo)
187-
}
188-
189184
pub type FileName = @str;
190185

191186
pub struct FileLines

src/libsyntax/ext/base.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
use ast;
1212
use ast::Name;
1313
use codemap;
14-
use codemap::{CodeMap, span, ExpnInfo, ExpandedFrom};
15-
use codemap::CallInfo;
14+
use codemap::{CodeMap, span, ExpnInfo};
1615
use diagnostic::span_handler;
1716
use ext;
1817
use parse;
@@ -243,7 +242,7 @@ impl ExtCtxt {
243242
pub fn cfg(&self) -> ast::crate_cfg { copy self.cfg }
244243
pub fn call_site(&self) -> span {
245244
match *self.backtrace {
246-
Some(@ExpandedFrom(CallInfo {call_site: cs, _})) => cs,
245+
Some(@ExpnInfo {call_site: cs, _}) => cs,
247246
None => self.bug("missing top span")
248247
}
249248
}
@@ -254,21 +253,19 @@ impl ExtCtxt {
254253
pub fn mod_path(&self) -> ~[ast::ident] { copy *self.mod_path }
255254
pub fn bt_push(&self, ei: codemap::ExpnInfo) {
256255
match ei {
257-
ExpandedFrom(CallInfo {call_site: cs, callee: ref callee}) => {
256+
ExpnInfo {call_site: cs, callee: ref callee} => {
258257
*self.backtrace =
259-
Some(@ExpandedFrom(CallInfo {
258+
Some(@ExpnInfo {
260259
call_site: span {lo: cs.lo, hi: cs.hi,
261260
expn_info: *self.backtrace},
262-
callee: copy *callee}));
261+
callee: copy *callee});
263262
}
264263
}
265264
}
266265
pub fn bt_pop(&self) {
267266
match *self.backtrace {
268-
Some(@ExpandedFrom(
269-
CallInfo {
270-
call_site: span {expn_info: prev, _}, _
271-
})) => {
267+
Some(@ExpnInfo {
268+
call_site: span {expn_info: prev, _}, _}) => {
272269
*self.backtrace = prev
273270
}
274271
_ => self.bug("tried to pop without a push")

src/libsyntax/ext/expand.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use ast;
1616
use ast_util::{new_rename, new_mark, resolve};
1717
use attr;
1818
use codemap;
19-
use codemap::{span, CallInfo, ExpandedFrom, NameAndSpan, spanned};
19+
use codemap::{span, ExpnInfo, NameAndSpan, spanned};
2020
use ext::base::*;
2121
use fold::*;
2222
use parse;
@@ -60,13 +60,13 @@ pub fn expand_expr(extsbox: @mut SyntaxEnv,
6060
expander: exp,
6161
span: exp_sp
6262
}))) => {
63-
cx.bt_push(ExpandedFrom(CallInfo {
63+
cx.bt_push(ExpnInfo {
6464
call_site: s,
6565
callee: NameAndSpan {
6666
name: extnamestr,
6767
span: exp_sp,
6868
},
69-
}));
69+
});
7070

7171
let expanded = match exp(cx, mac.span, *tts) {
7272
MRExpr(e) => e,
@@ -131,13 +131,13 @@ pub fn expand_mod_items(extsbox: @mut SyntaxEnv,
131131

132132
match (*extsbox).find(&intern(mname)) {
133133
Some(@SE(ItemDecorator(dec_fn))) => {
134-
cx.bt_push(ExpandedFrom(CallInfo {
134+
cx.bt_push(ExpnInfo {
135135
call_site: attr.span,
136136
callee: NameAndSpan {
137137
name: mname,
138138
span: None
139139
}
140-
}));
140+
});
141141
let r = dec_fn(cx, attr.span, attr.node.value, items);
142142
cx.bt_pop();
143143
r
@@ -227,13 +227,13 @@ pub fn expand_item_mac(extsbox: @mut SyntaxEnv,
227227
given '%s'", extnamestr,
228228
ident_to_str(&it.ident)));
229229
}
230-
cx.bt_push(ExpandedFrom(CallInfo {
230+
cx.bt_push(ExpnInfo {
231231
call_site: it.span,
232232
callee: NameAndSpan {
233233
name: extnamestr,
234234
span: expand.span
235235
}
236-
}));
236+
});
237237
((*expand).expander)(cx, it.span, tts)
238238
}
239239
Some(@SE(IdentTT(ref expand))) => {
@@ -242,13 +242,13 @@ pub fn expand_item_mac(extsbox: @mut SyntaxEnv,
242242
fmt!("macro %s! expects an ident argument",
243243
extnamestr));
244244
}
245-
cx.bt_push(ExpandedFrom(CallInfo {
245+
cx.bt_push(ExpnInfo {
246246
call_site: it.span,
247247
callee: NameAndSpan {
248248
name: extnamestr,
249249
span: expand.span
250250
}
251-
}));
251+
});
252252
((*expand).expander)(cx, it.span, it.ident, tts)
253253
}
254254
_ => cx.span_fatal(
@@ -319,10 +319,10 @@ pub fn expand_stmt(extsbox: @mut SyntaxEnv,
319319

320320
Some(@SE(NormalTT(
321321
SyntaxExpanderTT{expander: exp, span: exp_sp}))) => {
322-
cx.bt_push(ExpandedFrom(CallInfo {
322+
cx.bt_push(ExpnInfo {
323323
call_site: sp,
324324
callee: NameAndSpan { name: extnamestr, span: exp_sp }
325-
}));
325+
});
326326
let expanded = match exp(cx, mac.span, tts) {
327327
MRExpr(e) =>
328328
@codemap::spanned { node: stmt_expr(e, cx.next_id()),

src/libsyntax/ext/source_util.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
use ast;
1212
use codemap;
13-
use codemap::{Pos, ExpandedFrom, span};
14-
use codemap::{CallInfo, NameAndSpan};
13+
use codemap::{Pos, span};
14+
use codemap::{ExpnInfo, NameAndSpan};
1515
use ext::base::*;
1616
use ext::base;
1717
use ext::build::AstBuilder;
@@ -117,14 +117,14 @@ pub fn expand_include_bin(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
117117
// recur along an ExpnInfo chain to find the original expression
118118
fn topmost_expn_info(expn_info: @codemap::ExpnInfo) -> @codemap::ExpnInfo {
119119
match *expn_info {
120-
ExpandedFrom(CallInfo { call_site: ref call_site, _ }) => {
120+
ExpnInfo { call_site: ref call_site, _ } => {
121121
match call_site.expn_info {
122122
Some(next_expn_info) => {
123123
match *next_expn_info {
124-
ExpandedFrom(CallInfo {
124+
ExpnInfo {
125125
callee: NameAndSpan { name: ref name, _ },
126126
_
127-
}) => {
127+
} => {
128128
// Don't recurse into file using "include!"
129129
if "include" == *name {
130130
expn_info

src/libsyntax/parse/parser.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -1549,10 +1549,10 @@ impl Parser {
15491549
} else if self.eat_keyword(keywords::If) {
15501550
return self.parse_if_expr();
15511551
} else if self.eat_keyword(keywords::For) {
1552-
return self.parse_sugary_call_expr(~"for", ForSugar,
1552+
return self.parse_sugary_call_expr(lo, ~"for", ForSugar,
15531553
expr_loop_body);
15541554
} else if self.eat_keyword(keywords::Do) {
1555-
return self.parse_sugary_call_expr(~"do", DoSugar,
1555+
return self.parse_sugary_call_expr(lo, ~"do", DoSugar,
15561556
expr_do_body);
15571557
} else if self.eat_keyword(keywords::While) {
15581558
return self.parse_while_expr();
@@ -2264,12 +2264,11 @@ impl Parser {
22642264
// parse a 'for' or 'do'.
22652265
// the 'for' and 'do' expressions parse as calls, but look like
22662266
// function calls followed by a closure expression.
2267-
pub fn parse_sugary_call_expr(&self,
2267+
pub fn parse_sugary_call_expr(&self, lo: BytePos,
22682268
keyword: ~str,
22692269
sugar: CallSugar,
22702270
ctor: &fn(v: @expr) -> expr_)
22712271
-> @expr {
2272-
let lo = self.last_span;
22732272
// Parse the callee `foo` in
22742273
// for foo || {
22752274
// for foo.bar || {
@@ -2286,21 +2285,21 @@ impl Parser {
22862285
let last_arg = self.mk_expr(block.span.lo, block.span.hi,
22872286
ctor(block));
22882287
let args = vec::append(copy *args, [last_arg]);
2289-
self.mk_expr(lo.lo, block.span.hi, expr_call(f, args, sugar))
2288+
self.mk_expr(lo, block.span.hi, expr_call(f, args, sugar))
22902289
}
22912290
expr_method_call(_, f, i, ref tps, ref args, NoSugar) => {
22922291
let block = self.parse_lambda_block_expr();
22932292
let last_arg = self.mk_expr(block.span.lo, block.span.hi,
22942293
ctor(block));
22952294
let args = vec::append(copy *args, [last_arg]);
2296-
self.mk_expr(lo.lo, block.span.hi,
2295+
self.mk_expr(lo, block.span.hi,
22972296
self.mk_method_call(f, i, copy *tps, args, sugar))
22982297
}
22992298
expr_field(f, i, ref tps) => {
23002299
let block = self.parse_lambda_block_expr();
23012300
let last_arg = self.mk_expr(block.span.lo, block.span.hi,
23022301
ctor(block));
2303-
self.mk_expr(lo.lo, block.span.hi,
2302+
self.mk_expr(lo, block.span.hi,
23042303
self.mk_method_call(f, i, copy *tps, ~[last_arg], sugar))
23052304
}
23062305
expr_path(*) | expr_call(*) | expr_method_call(*) |
@@ -2309,7 +2308,7 @@ impl Parser {
23092308
let last_arg = self.mk_expr(block.span.lo, block.span.hi,
23102309
ctor(block));
23112310
self.mk_expr(
2312-
lo.lo,
2311+
lo,
23132312
last_arg.span.hi,
23142313
self.mk_call(e, ~[last_arg], sugar))
23152314
}
@@ -2319,7 +2318,7 @@ impl Parser {
23192318
// but they aren't represented by tests
23202319
debug!("sugary call on %?", e.node);
23212320
self.span_fatal(
2322-
*lo,
2321+
e.span,
23232322
fmt!("`%s` must be followed by a block call", keyword));
23242323
}
23252324
}

src/libsyntax/visit.rs

-12
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ pub struct Visitor<E> {
9090
visit_trait_method: @fn(&trait_method, (E, vt<E>)),
9191
visit_struct_def: @fn(@struct_def, ident, &Generics, node_id, (E, vt<E>)),
9292
visit_struct_field: @fn(@struct_field, (E, vt<E>)),
93-
visit_struct_method: @fn(@method, (E, vt<E>))
9493
}
9594

9695
pub type visitor<E> = @Visitor<E>;
@@ -116,7 +115,6 @@ pub fn default_visitor<E: Copy>() -> visitor<E> {
116115
visit_trait_method: |a,b|visit_trait_method::<E>(a, b),
117116
visit_struct_def: |a,b,c,d,e|visit_struct_def::<E>(a, b, c, d, e),
118117
visit_struct_field: |a,b|visit_struct_field::<E>(a, b),
119-
visit_struct_method: |a,b|visit_struct_method::<E>(a, b)
120118
};
121119
}
122120

@@ -414,10 +412,6 @@ pub fn visit_struct_field<E: Copy>(sf: &struct_field, (e, v): (E, vt<E>)) {
414412
(v.visit_ty)(sf.node.ty, (e, v));
415413
}
416414

417-
pub fn visit_struct_method<E: Copy>(m: &method, (e, v): (E, vt<E>)) {
418-
visit_method_helper(m, (e, v));
419-
}
420-
421415
pub fn visit_block<E: Copy>(b: &blk, (e, v): (E, vt<E>)) {
422416
for b.node.view_items.iter().advance |vi| {
423417
(v.visit_view_item)(*vi, (copy e, v));
@@ -729,10 +723,6 @@ pub fn mk_simple_visitor(v: simple_visitor) -> vt<()> {
729723
f(sf);
730724
visit_struct_field(sf, (e, v));
731725
}
732-
fn v_struct_method(f: @fn(@method), m: @method, (e, v): ((), vt<()>)) {
733-
f(m);
734-
visit_struct_method(m, (e, v));
735-
}
736726
return mk_vt(@Visitor {
737727
visit_mod: |a,b,c,d|v_mod(v.visit_mod, a, b, c, d),
738728
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<()> {
760750
v_struct_def(v.visit_struct_def, a, b, c, d, e),
761751
visit_struct_field: |a,b|
762752
v_struct_field(v.visit_struct_field, a, b),
763-
visit_struct_method: |a,b|
764-
v_struct_method(v.visit_struct_method, a, b)
765753
});
766754
}

src/test/compile-fail/issue-3044.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fn main() {
1212
let needlesArr: ~[char] = ~['a', 'f'];
1313
do needlesArr.iter().fold() |x, y| {
1414
}
15-
//~^ ERROR 1 parameter was supplied (including the closure passed by the `do` keyword)
15+
//~^^ ERROR 1 parameter was supplied (including the closure passed by the `do` keyword)
1616
//
1717
// the first error is, um, non-ideal.
1818
}

src/test/pretty/block-comment-wchar.pp

-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@
108108
'\xA0', '\u1680', '\u180E', '\u2000', '\u2001', '\u2002', '\u2003',
109109
'\u2004', '\u2005', '\u2006', '\u2007', '\u2008', '\u2009', '\u200A',
110110
'\u2028', '\u2029', '\u202F', '\u205F', '\u3000'];
111-
// <= bugs in pretty-printer?
112111
for chars.iter().advance |c| {
113112
let ws = c.is_whitespace();
114113
println(fmt!("%? %?" , c , ws));

src/test/pretty/block-comment-wchar.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,6 @@ fn main() {
104104
'\u2028', '\u2029', '\u202F', '\u205F', '\u3000'];
105105
for chars.iter().advance |c| {
106106
let ws = c.is_whitespace();
107-
println(fmt!("%? %?", c , ws)); // <= bugs in pretty-printer?
107+
println(fmt!("%? %?", c , ws));
108108
}
109109
}

0 commit comments

Comments
 (0)