Skip to content

Commit

Permalink
Merge #1877
Browse files Browse the repository at this point in the history
1877: Replace usages of bump_any with bump r=matklad a=kjeremy

Fixes #1854 

Co-authored-by: kjeremy <kjeremy@gmail.com>
  • Loading branch information
bors[bot] and kjeremy authored Sep 19, 2019
2 parents cd9b222 + 883edd0 commit 58dc3b1
Show file tree
Hide file tree
Showing 14 changed files with 87 additions and 87 deletions.
14 changes: 7 additions & 7 deletions crates/ra_parser/src/grammar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ fn opt_visibility(p: &mut Parser) -> bool {
// fn foo() { crate::foo(); }
T![crate] if !p.nth_at(1, T![::]) => {
let m = p.start();
p.bump_any();
p.bump(T![crate]);
m.complete(p, VISIBILITY);
}
_ => return false,
Expand All @@ -223,7 +223,7 @@ fn opt_visibility(p: &mut Parser) -> bool {
fn opt_alias(p: &mut Parser) {
if p.at(T![as]) {
let m = p.start();
p.bump_any();
p.bump(T![as]);
if !p.eat(T![_]) {
name(p);
}
Expand All @@ -234,7 +234,7 @@ fn opt_alias(p: &mut Parser) {
fn abi(p: &mut Parser) {
assert!(p.at(T![extern]));
let abi = p.start();
p.bump_any();
p.bump(T![extern]);
match p.current() {
STRING | RAW_STRING => p.bump_any(),
_ => (),
Expand All @@ -257,7 +257,7 @@ fn opt_fn_ret_type(p: &mut Parser) -> bool {
fn name_r(p: &mut Parser, recovery: TokenSet) {
if p.at(IDENT) {
let m = p.start();
p.bump_any();
p.bump(IDENT);
m.complete(p, NAME);
} else {
p.err_recover("expected a name", recovery);
Expand All @@ -271,11 +271,11 @@ fn name(p: &mut Parser) {
fn name_ref(p: &mut Parser) {
if p.at(IDENT) {
let m = p.start();
p.bump_any();
p.bump(IDENT);
m.complete(p, NAME_REF);
} else if p.at(T![self]) {
let m = p.start();
p.bump_any();
p.bump(T![self]);
m.complete(p, T![self]);
} else {
p.err_and_bump("expected identifier");
Expand All @@ -296,7 +296,7 @@ fn error_block(p: &mut Parser, message: &str) {
assert!(p.at(T!['{']));
let m = p.start();
p.error(message);
p.bump_any();
p.bump(T!['{']);
expressions::expr_block_contents(p);
p.eat(T!['}']);
m.complete(p, ERROR);
Expand Down
4 changes: 2 additions & 2 deletions crates/ra_parser/src/grammar/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ pub(super) fn outer_attributes(p: &mut Parser) {
fn attribute(p: &mut Parser, inner: bool) {
let attr = p.start();
assert!(p.at(T![#]));
p.bump_any();
p.bump(T![#]);

if inner {
assert!(p.at(T![!]));
p.bump_any();
p.bump(T![!]);
}

if p.at(T!['[']) {
Expand Down
20 changes: 10 additions & 10 deletions crates/ra_parser/src/grammar/expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub(crate) fn block(p: &mut Parser) {
pub(crate) fn naked_block(p: &mut Parser) {
assert!(p.at(T!['{']));
let m = p.start();
p.bump_any();
p.bump(T!['{']);
expr_block_contents(p);
p.expect(T!['}']);
m.complete(p, BLOCK);
Expand Down Expand Up @@ -150,7 +150,7 @@ pub(super) fn stmt(p: &mut Parser, with_semi: StmtWithSemi) {
// }
fn let_stmt(p: &mut Parser, m: Marker, with_semi: StmtWithSemi) {
assert!(p.at(T![let]));
p.bump_any();
p.bump(T![let]);
patterns::pattern(p);
if p.at(T![:]) {
types::ascription(p);
Expand Down Expand Up @@ -195,7 +195,7 @@ pub(crate) fn expr_block_contents(p: &mut Parser) {
// }

if p.at(T![;]) {
p.bump_any();
p.bump(T![;]);
continue;
}

Expand Down Expand Up @@ -297,7 +297,7 @@ fn lhs(p: &mut Parser, r: Restrictions) -> Option<(CompletedMarker, BlockLike)>
// }
T![&] => {
m = p.start();
p.bump_any();
p.bump(T![&]);
p.eat(T![mut]);
REF_EXPR
}
Expand Down Expand Up @@ -438,7 +438,7 @@ fn call_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
fn index_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
assert!(p.at(T!['[']));
let m = lhs.precede(p);
p.bump_any();
p.bump(T!['[']);
expr(p);
p.expect(T![']']);
m.complete(p, INDEX_EXPR)
Expand Down Expand Up @@ -478,7 +478,7 @@ fn method_call_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
fn field_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
assert!(p.at(T![.]));
let m = lhs.precede(p);
p.bump_any();
p.bump(T![.]);
if p.at(IDENT) || p.at(INT_NUMBER) {
name_ref_or_index(p)
} else if p.at(FLOAT_NUMBER) {
Expand All @@ -497,7 +497,7 @@ fn field_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
fn try_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
assert!(p.at(T![?]));
let m = lhs.precede(p);
p.bump_any();
p.bump(T![?]);
m.complete(p, TRY_EXPR)
}

Expand All @@ -511,7 +511,7 @@ fn try_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
fn cast_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
assert!(p.at(T![as]));
let m = lhs.precede(p);
p.bump_any();
p.bump(T![as]);
// Use type_no_bounds(), because cast expressions are not
// allowed to have bounds.
types::type_no_bounds(p);
Expand All @@ -521,7 +521,7 @@ fn cast_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
fn arg_list(p: &mut Parser) {
assert!(p.at(T!['(']));
let m = p.start();
p.bump_any();
p.bump(T!['(']);
while !p.at(T![')']) && !p.at(EOF) {
if !p.at_ts(EXPR_FIRST) {
p.error("expected expression");
Expand Down Expand Up @@ -570,7 +570,7 @@ fn path_expr(p: &mut Parser, r: Restrictions) -> (CompletedMarker, BlockLike) {
pub(crate) fn record_field_list(p: &mut Parser) {
assert!(p.at(T!['{']));
let m = p.start();
p.bump_any();
p.bump(T!['{']);
while !p.at(EOF) && !p.at(T!['}']) {
match p.current() {
// test record_literal_field_with_attr
Expand Down
32 changes: 16 additions & 16 deletions crates/ra_parser/src/grammar/expressions/atom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar
}
T![async] if la == T!['{'] || (la == T![move] && p.nth(2) == T!['{']) => {
let m = p.start();
p.bump_any();
p.bump(T![async]);
p.eat(T![move]);
block_expr(p, Some(m))
}
T![match] => match_expr(p),
T![unsafe] if la == T!['{'] => {
let m = p.start();
p.bump_any();
p.bump(T![unsafe]);
block_expr(p, Some(m))
}
T!['{'] => {
Expand Down Expand Up @@ -180,7 +180,7 @@ fn tuple_expr(p: &mut Parser) -> CompletedMarker {
fn array_expr(p: &mut Parser) -> CompletedMarker {
assert!(p.at(T!['[']));
let m = p.start();
p.bump_any();
p.bump(T!['[']);
if p.eat(T![']']) {
return m.complete(p, ARRAY_EXPR);
}
Expand Down Expand Up @@ -262,11 +262,11 @@ fn lambda_expr(p: &mut Parser) -> CompletedMarker {
fn if_expr(p: &mut Parser) -> CompletedMarker {
assert!(p.at(T![if]));
let m = p.start();
p.bump_any();
p.bump(T![if]);
cond(p);
block(p);
if p.at(T![else]) {
p.bump_any();
p.bump(T![else]);
if p.at(T![if]) {
if_expr(p);
} else {
Expand All @@ -285,7 +285,7 @@ fn if_expr(p: &mut Parser) -> CompletedMarker {
fn label(p: &mut Parser) {
assert!(p.at(LIFETIME) && p.nth(1) == T![:]);
let m = p.start();
p.bump_any();
p.bump(LIFETIME);
p.bump_any();
m.complete(p, LABEL);
}
Expand All @@ -297,7 +297,7 @@ fn label(p: &mut Parser) {
fn loop_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker {
assert!(p.at(T![loop]));
let m = m.unwrap_or_else(|| p.start());
p.bump_any();
p.bump(T![loop]);
block(p);
m.complete(p, LOOP_EXPR)
}
Expand All @@ -310,7 +310,7 @@ fn loop_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker {
fn while_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker {
assert!(p.at(T![while]));
let m = m.unwrap_or_else(|| p.start());
p.bump_any();
p.bump(T![while]);
cond(p);
block(p);
m.complete(p, WHILE_EXPR)
Expand All @@ -323,7 +323,7 @@ fn while_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker {
fn for_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker {
assert!(p.at(T![for]));
let m = m.unwrap_or_else(|| p.start());
p.bump_any();
p.bump(T![for]);
patterns::pattern(p);
p.expect(T![in]);
expr_no_struct(p);
Expand Down Expand Up @@ -357,7 +357,7 @@ fn cond(p: &mut Parser) {
fn match_expr(p: &mut Parser) -> CompletedMarker {
assert!(p.at(T![match]));
let m = p.start();
p.bump_any();
p.bump(T![match]);
expr_no_struct(p);
if p.at(T!['{']) {
match_arm_list(p);
Expand Down Expand Up @@ -453,7 +453,7 @@ fn match_arm(p: &mut Parser) -> BlockLike {
fn match_guard(p: &mut Parser) -> CompletedMarker {
assert!(p.at(T![if]));
let m = p.start();
p.bump_any();
p.bump(T![if]);
expr(p);
m.complete(p, MATCH_GUARD)
}
Expand All @@ -479,7 +479,7 @@ pub(super) fn block_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker {
fn return_expr(p: &mut Parser) -> CompletedMarker {
assert!(p.at(T![return]));
let m = p.start();
p.bump_any();
p.bump(T![return]);
if p.at_ts(EXPR_FIRST) {
expr(p);
}
Expand All @@ -496,7 +496,7 @@ fn return_expr(p: &mut Parser) -> CompletedMarker {
fn continue_expr(p: &mut Parser) -> CompletedMarker {
assert!(p.at(T![continue]));
let m = p.start();
p.bump_any();
p.bump(T![continue]);
p.eat(LIFETIME);
m.complete(p, CONTINUE_EXPR)
}
Expand All @@ -513,7 +513,7 @@ fn continue_expr(p: &mut Parser) -> CompletedMarker {
fn break_expr(p: &mut Parser, r: Restrictions) -> CompletedMarker {
assert!(p.at(T![break]));
let m = p.start();
p.bump_any();
p.bump(T![break]);
p.eat(LIFETIME);
// test break_ambiguity
// fn foo(){
Expand All @@ -535,7 +535,7 @@ fn break_expr(p: &mut Parser, r: Restrictions) -> CompletedMarker {
fn try_block_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker {
assert!(p.at(T![try]));
let m = m.unwrap_or_else(|| p.start());
p.bump_any();
p.bump(T![try]);
block(p);
m.complete(p, TRY_EXPR)
}
Expand All @@ -549,7 +549,7 @@ fn try_block_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker {
fn box_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker {
assert!(p.at(T![box]));
let m = m.unwrap_or_else(|| p.start());
p.bump_any();
p.bump(T![box]);
if p.at_ts(EXPR_FIRST) {
expr(p);
}
Expand Down
18 changes: 9 additions & 9 deletions crates/ra_parser/src/grammar/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool, flavor: ItemF
} else if p.at(T!['}']) && !stop_on_r_curly {
let e = p.start();
p.error("unmatched `}`");
p.bump_any();
p.bump(T!['}']);
e.complete(p, ERROR);
} else if !p.at(EOF) && !p.at(T!['}']) {
p.err_and_bump("expected an item");
Expand Down Expand Up @@ -276,9 +276,9 @@ fn items_without_modifiers(p: &mut Parser, m: Marker) -> Result<(), Marker> {

fn extern_crate_item(p: &mut Parser, m: Marker) {
assert!(p.at(T![extern]));
p.bump_any();
p.bump(T![extern]);
assert!(p.at(T![crate]));
p.bump_any();
p.bump(T![crate]);
name_ref(p);
opt_alias(p);
p.expect(T![;]);
Expand All @@ -288,15 +288,15 @@ fn extern_crate_item(p: &mut Parser, m: Marker) {
pub(crate) fn extern_item_list(p: &mut Parser) {
assert!(p.at(T!['{']));
let m = p.start();
p.bump_any();
p.bump(T!['{']);
mod_contents(p, true);
p.expect(T!['}']);
m.complete(p, EXTERN_ITEM_LIST);
}

fn fn_def(p: &mut Parser, flavor: ItemFlavor) {
assert!(p.at(T![fn]));
p.bump_any();
p.bump(T![fn]);

name_r(p, ITEM_RECOVERY_SET);
// test function_type_params
Expand All @@ -323,7 +323,7 @@ fn fn_def(p: &mut Parser, flavor: ItemFlavor) {
// test fn_decl
// trait T { fn foo(); }
if p.at(T![;]) {
p.bump_any();
p.bump(T![;]);
} else {
expressions::block(p)
}
Expand All @@ -333,7 +333,7 @@ fn fn_def(p: &mut Parser, flavor: ItemFlavor) {
// type Foo = Bar;
fn type_def(p: &mut Parser, m: Marker) {
assert!(p.at(T![type]));
p.bump_any();
p.bump(T![type]);

name(p);

Expand All @@ -357,7 +357,7 @@ fn type_def(p: &mut Parser, m: Marker) {

pub(crate) fn mod_item(p: &mut Parser, m: Marker) {
assert!(p.at(T![mod]));
p.bump_any();
p.bump(T![mod]);

name(p);
if p.at(T!['{']) {
Expand All @@ -371,7 +371,7 @@ pub(crate) fn mod_item(p: &mut Parser, m: Marker) {
pub(crate) fn mod_item_list(p: &mut Parser) {
assert!(p.at(T!['{']));
let m = p.start();
p.bump_any();
p.bump(T!['{']);
mod_contents(p, true);
p.expect(T!['}']);
m.complete(p, ITEM_LIST);
Expand Down
2 changes: 1 addition & 1 deletion crates/ra_parser/src/grammar/items/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub(super) fn const_def(p: &mut Parser, m: Marker) {

fn const_or_static(p: &mut Parser, m: Marker, kw: SyntaxKind, def: SyntaxKind) {
assert!(p.at(kw));
p.bump_any();
p.bump(kw);
p.eat(T![mut]); // FIXME: validator to forbid const mut

// Allow `_` in place of an identifier in a `const`.
Expand Down
Loading

0 comments on commit 58dc3b1

Please sign in to comment.