aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_parser/src/grammar/paths.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-05-15 13:45:58 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-05-15 13:45:58 +0100
commitec7d2f64ade9ffa35a64e82ac53e65ad5cbe9efd (patch)
treeb8693ce808a9ca2e7eaae5013644a1082fc7bb17 /crates/ra_parser/src/grammar/paths.rs
parent64ab5ab10d32e7e8ec085af818d3d94211aea39b (diff)
parent993abedd77cf23ce2281b6c8e60cab49ab4fa97e (diff)
Merge #1278
1278: Apply T! macro where posible r=matklad a=pasa apply T! macro implemented in #1248 Co-authored-by: Sergey Parilin <[email protected]>
Diffstat (limited to 'crates/ra_parser/src/grammar/paths.rs')
-rw-r--r--crates/ra_parser/src/grammar/paths.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/crates/ra_parser/src/grammar/paths.rs b/crates/ra_parser/src/grammar/paths.rs
index 33a11886c..3537b0da1 100644
--- a/crates/ra_parser/src/grammar/paths.rs
+++ b/crates/ra_parser/src/grammar/paths.rs
@@ -5,7 +5,7 @@ pub(super) const PATH_FIRST: TokenSet =
5 5
6pub(super) fn is_path_start(p: &Parser) -> bool { 6pub(super) fn is_path_start(p: &Parser) -> bool {
7 match p.current() { 7 match p.current() {
8 IDENT | SELF_KW | SUPER_KW | CRATE_KW | COLONCOLON => true, 8 IDENT | T![self] | T![super] | T![crate] | T![::] => true,
9 _ => false, 9 _ => false,
10 } 10 }
11} 11}
@@ -35,10 +35,10 @@ fn path(p: &mut Parser, mode: Mode) {
35 let mut qual = path.complete(p, PATH); 35 let mut qual = path.complete(p, PATH);
36 loop { 36 loop {
37 let use_tree = match p.nth(1) { 37 let use_tree = match p.nth(1) {
38 STAR | L_CURLY => true, 38 T![*] | T!['{'] => true,
39 _ => false, 39 _ => false,
40 }; 40 };
41 if p.at(COLONCOLON) && !use_tree { 41 if p.at(T![::]) && !use_tree {
42 let path = qual.precede(p); 42 let path = qual.precede(p);
43 p.bump(); 43 p.bump();
44 path_segment(p, mode, false); 44 path_segment(p, mode, false);
@@ -55,19 +55,19 @@ fn path_segment(p: &mut Parser, mode: Mode, first: bool) {
55 // test qual_paths 55 // test qual_paths
56 // type X = <A as B>::Output; 56 // type X = <A as B>::Output;
57 // fn foo() { <usize as Default>::default(); } 57 // fn foo() { <usize as Default>::default(); }
58 if first && p.eat(L_ANGLE) { 58 if first && p.eat(T![<]) {
59 types::type_(p); 59 types::type_(p);
60 if p.eat(AS_KW) { 60 if p.eat(T![as]) {
61 if is_path_start(p) { 61 if is_path_start(p) {
62 types::path_type(p); 62 types::path_type(p);
63 } else { 63 } else {
64 p.error("expected a trait"); 64 p.error("expected a trait");
65 } 65 }
66 } 66 }
67 p.expect(R_ANGLE); 67 p.expect(T![>]);
68 } else { 68 } else {
69 if first { 69 if first {
70 p.eat(COLONCOLON); 70 p.eat(T![::]);
71 } 71 }
72 match p.current() { 72 match p.current() {
73 IDENT => { 73 IDENT => {
@@ -76,7 +76,7 @@ fn path_segment(p: &mut Parser, mode: Mode, first: bool) {
76 } 76 }
77 // test crate_path 77 // test crate_path
78 // use crate::foo; 78 // use crate::foo;
79 SELF_KW | SUPER_KW | CRATE_KW => p.bump(), 79 T![self] | T![super] | T![crate] => p.bump(),
80 _ => { 80 _ => {
81 p.err_recover("expected identifier", items::ITEM_RECOVERY_SET); 81 p.err_recover("expected identifier", items::ITEM_RECOVERY_SET);
82 } 82 }
@@ -91,7 +91,7 @@ fn opt_path_type_args(p: &mut Parser, mode: Mode) {
91 Mode::Type => { 91 Mode::Type => {
92 // test path_fn_trait_args 92 // test path_fn_trait_args
93 // type F = Box<Fn(x: i32) -> ()>; 93 // type F = Box<Fn(x: i32) -> ()>;
94 if p.at(L_PAREN) { 94 if p.at(T!['(']) {
95 params::param_list_opt_patterns(p); 95 params::param_list_opt_patterns(p);
96 opt_fn_ret_type(p); 96 opt_fn_ret_type(p);
97 } else { 97 } else {