Skip to content

Commit cc3e6ec

Browse files
committed
libsyntax: De-@mut Parser::last_span
1 parent 0c6cee5 commit cc3e6ec

File tree

2 files changed

+32
-34
lines changed

2 files changed

+32
-34
lines changed

src/libsyntax/ext/asm.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ pub fn expand_asm(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree])
7777
let (constraint, _str_style) = p.parse_str();
7878

7979
if constraint.starts_with("+") {
80-
cx.span_unimpl(*p.last_span,
80+
cx.span_unimpl(p.last_span,
8181
"'+' (read+write) output operand constraint modifier");
8282
} else if !constraint.starts_with("=") {
83-
cx.span_err(*p.last_span, "output operand constraint lacks '='");
83+
cx.span_err(p.last_span, "output operand constraint lacks '='");
8484
}
8585

8686
p.expect(&token::LPAREN);
@@ -102,9 +102,9 @@ pub fn expand_asm(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree])
102102
let (constraint, _str_style) = p.parse_str();
103103

104104
if constraint.starts_with("=") {
105-
cx.span_err(*p.last_span, "input operand constraint contains '='");
105+
cx.span_err(p.last_span, "input operand constraint contains '='");
106106
} else if constraint.starts_with("+") {
107-
cx.span_err(*p.last_span, "input operand constraint contains '+'");
107+
cx.span_err(p.last_span, "input operand constraint contains '+'");
108108
}
109109

110110
p.expect(&token::LPAREN);

src/libsyntax/parse/parser.rs

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,7 @@ struct ParsedItemsAndViewItems {
286286

287287
/* ident is handled by common.rs */
288288

289-
pub fn Parser(sess: @mut ParseSess,
290-
cfg: ast::CrateConfig,
291-
rdr: @mut reader)
289+
pub fn Parser(sess: @mut ParseSess, cfg: ast::CrateConfig, rdr: @mut reader)
292290
-> Parser {
293291
let tok0 = rdr.next_token();
294292
let interner = get_ident_interner();
@@ -305,7 +303,7 @@ pub fn Parser(sess: @mut ParseSess,
305303
cfg: cfg,
306304
token: tok0.tok,
307305
span: span,
308-
last_span: @mut span,
306+
last_span: span,
309307
last_token: @mut None,
310308
buffer: @mut ([
311309
placeholder.clone(),
@@ -334,7 +332,7 @@ pub struct Parser {
334332
// the span of the current token:
335333
span: Span,
336334
// the span of the prior token:
337-
last_span: @mut Span,
335+
last_span: Span,
338336
// the previous token or None (only stashed sometimes).
339337
last_token: @mut Option<~token::Token>,
340338
buffer: @mut [TokenAndSpan, ..4],
@@ -373,8 +371,8 @@ impl Parser {
373371

374372
pub fn unexpected_last(&mut self, t: &token::Token) -> ! {
375373
let token_str = Parser::token_to_str(t);
376-
self.span_fatal(*self.last_span, format!("unexpected token: `{}`",
377-
token_str));
374+
self.span_fatal(self.last_span, format!("unexpected token: `{}`",
375+
token_str));
378376
}
379377

380378
pub fn unexpected(&mut self) -> ! {
@@ -728,7 +726,7 @@ impl Parser {
728726

729727
// advance the parser by one token
730728
pub fn bump(&mut self) {
731-
*self.last_span = self.span;
729+
self.last_span = self.span;
732730
// Stash token for error recovery (sometimes; clone is not necessarily cheap).
733731
*self.last_token = if is_ident_or_path(&self.token) {
734732
Some(~self.token.clone())
@@ -940,7 +938,7 @@ impl Parser {
940938

941939
// Re-parse the region here. What a hack.
942940
if region.is_some() {
943-
self.span_err(*self.last_span,
941+
self.span_err(self.last_span,
944942
"lifetime declarations must precede \
945943
the lifetime associated with a \
946944
closure");
@@ -1281,13 +1279,13 @@ impl Parser {
12811279
match self.token {
12821280
token::LIFETIME(..) => {
12831281
let lifetime = self.parse_lifetime();
1284-
self.obsolete(*self.last_span, ObsoleteBoxedClosure);
1282+
self.obsolete(self.last_span, ObsoleteBoxedClosure);
12851283
return self.parse_ty_closure(Some(sigil), Some(lifetime));
12861284
}
12871285

12881286
token::IDENT(..) => {
12891287
if self.token_is_old_style_closure_keyword() {
1290-
self.obsolete(*self.last_span, ObsoleteBoxedClosure);
1288+
self.obsolete(self.last_span, ObsoleteBoxedClosure);
12911289
return self.parse_ty_closure(Some(sigil), None);
12921290
}
12931291
}
@@ -1310,7 +1308,7 @@ impl Parser {
13101308
let opt_lifetime = self.parse_opt_lifetime();
13111309

13121310
if self.token_is_old_style_closure_keyword() {
1313-
self.obsolete(*self.last_span, ObsoleteClosureType);
1311+
self.obsolete(self.last_span, ObsoleteClosureType);
13141312
return self.parse_ty_closure(Some(BorrowedSigil), opt_lifetime);
13151313
}
13161314

@@ -1350,7 +1348,7 @@ impl Parser {
13501348
} else {
13511349
debug!("parse_arg_general ident_to_pat");
13521350
ast_util::ident_to_pat(ast::DUMMY_NODE_ID,
1353-
*self.last_span,
1351+
self.last_span,
13541352
special_idents::invalid)
13551353
};
13561354

@@ -1649,7 +1647,7 @@ impl Parser {
16491647
if self.eat_keyword(keywords::Mut) {
16501648
MutMutable
16511649
} else if self.eat_keyword(keywords::Const) {
1652-
self.obsolete(*self.last_span, ObsoleteConstPointer);
1650+
self.obsolete(self.last_span, ObsoleteConstPointer);
16531651
MutImmutable
16541652
} else {
16551653
MutImmutable
@@ -2630,11 +2628,11 @@ impl Parser {
26302628
} else {
26312629
// This is an obsolete 'continue' expression
26322630
if opt_ident.is_some() {
2633-
self.span_err(*self.last_span,
2631+
self.span_err(self.last_span,
26342632
"a label may not be used with a `loop` expression");
26352633
}
26362634

2637-
self.obsolete(*self.last_span, ObsoleteLoopAsContinue);
2635+
self.obsolete(self.last_span, ObsoleteLoopAsContinue);
26382636
let lo = self.span.lo;
26392637
let ex = if Parser::token_is_lifetime(&self.token) {
26402638
let lifetime = self.get_lifetime();
@@ -2848,7 +2846,7 @@ impl Parser {
28482846
subpat = @ast::Pat {
28492847
id: ast::DUMMY_NODE_ID,
28502848
node: PatIdent(bind_type, fieldpath, None),
2851-
span: *self.last_span
2849+
span: self.last_span
28522850
};
28532851
}
28542852
fields.push(ast::FieldPat { ident: fieldname, pat: subpat });
@@ -3138,7 +3136,7 @@ impl Parser {
31383136
binding_mode: ast::BindingMode)
31393137
-> ast::Pat_ {
31403138
if !is_plain_ident(&self.token) {
3141-
self.span_fatal(*self.last_span,
3139+
self.span_fatal(self.last_span,
31423140
"expected identifier, found path");
31433141
}
31443142
// why a path here, and not just an identifier?
@@ -3157,7 +3155,7 @@ impl Parser {
31573155
// will direct us over to parse_enum_variant()
31583156
if self.token == token::LPAREN {
31593157
self.span_fatal(
3160-
*self.last_span,
3158+
self.last_span,
31613159
"expected identifier, found enum pattern");
31623160
}
31633161

@@ -3223,7 +3221,7 @@ impl Parser {
32233221
fn check_expected_item(p: &mut Parser, found_attrs: bool) {
32243222
// If we have attributes then we should have an item
32253223
if found_attrs {
3226-
p.span_err(*p.last_span, "expected item after attributes");
3224+
p.span_err(p.last_span, "expected item after attributes");
32273225
}
32283226
}
32293227

@@ -3383,7 +3381,7 @@ impl Parser {
33833381
match self.token {
33843382
token::SEMI => {
33853383
if !attributes_box.is_empty() {
3386-
self.span_err(*self.last_span, "expected item after attributes");
3384+
self.span_err(self.last_span, "expected item after attributes");
33873385
attributes_box = ~[];
33883386
}
33893387
self.bump(); // empty
@@ -3461,7 +3459,7 @@ impl Parser {
34613459
}
34623460

34633461
if !attributes_box.is_empty() {
3464-
self.span_err(*self.last_span, "expected item after attributes");
3462+
self.span_err(self.last_span, "expected item after attributes");
34653463
}
34663464

34673465
let hi = self.span.hi;
@@ -3709,7 +3707,7 @@ impl Parser {
37093707
token::TILDE => {
37103708
maybe_parse_explicit_self(|mutability| {
37113709
if mutability != MutImmutable {
3712-
self.span_err(*self.last_span,
3710+
self.span_err(self.last_span,
37133711
"mutability declaration not allowed here");
37143712
}
37153713
sty_uniq(MutImmutable)
@@ -3983,7 +3981,7 @@ impl Parser {
39833981

39843982
let mut meths = ~[];
39853983
let inner_attrs = if self.eat(&token::SEMI) {
3986-
self.obsolete(*self.last_span, ObsoleteEmptyImpl);
3984+
self.obsolete(self.last_span, ObsoleteEmptyImpl);
39873985
None
39883986
} else {
39893987
self.expect(&token::LBRACE);
@@ -4166,7 +4164,7 @@ impl Parser {
41664164

41674165
if first && attrs_remaining_len > 0u {
41684166
// We parsed attributes for the first item but didn't find it
4169-
self.span_err(*self.last_span, "expected item after attributes");
4167+
self.span_err(self.last_span, "expected item after attributes");
41704168
}
41714169

41724170
ast::_mod { view_items: view_items, items: items }
@@ -4300,7 +4298,7 @@ impl Parser {
43004298
// Parse obsolete purity.
43014299
let purity = self.parse_fn_purity();
43024300
if purity != impure_fn {
4303-
self.obsolete(*self.last_span, ObsoleteUnsafeExternFn);
4301+
self.obsolete(self.last_span, ObsoleteUnsafeExternFn);
43044302
}
43054303
43064304
let (ident, generics) = self.parse_fn_header();
@@ -4360,7 +4358,7 @@ impl Parser {
43604358
foreign_items: foreign_items
43614359
} = self.parse_foreign_items(first_item_attrs, true);
43624360
if (! attrs_remaining.is_empty()) {
4363-
self.span_err(*self.last_span,
4361+
self.span_err(self.last_span,
43644362
"expected item after attributes");
43654363
}
43664364
assert!(self.token == token::RBRACE);
@@ -4418,7 +4416,7 @@ impl Parser {
44184416
if items_allowed && self.eat(&token::LBRACE) {
44194417
// `extern mod foo { ... }` is obsolete.
44204418
if named {
4421-
self.obsolete(*self.last_span, ObsoleteNamedExternModule);
4419+
self.obsolete(self.last_span, ObsoleteNamedExternModule);
44224420
}
44234421

44244422
let abis = opt_abis.unwrap_or(AbiSet::C());
@@ -4863,7 +4861,7 @@ impl Parser {
48634861
s.push_str("priv")
48644862
}
48654863
s.push_char('`');
4866-
self.span_fatal(*self.last_span, s);
4864+
self.span_fatal(self.last_span, s);
48674865
}
48684866
return iovi_none(attrs);
48694867
}
@@ -5018,7 +5016,7 @@ impl Parser {
50185016
let mut vp = ~[self.parse_view_path()];
50195017
while self.token == token::COMMA {
50205018
self.bump();
5021-
self.obsolete(*self.last_span, ObsoleteMultipleImport);
5019+
self.obsolete(self.last_span, ObsoleteMultipleImport);
50225020
vp.push(self.parse_view_path());
50235021
}
50245022
return vp;

0 commit comments

Comments
 (0)