aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r--crates/ra_syntax/src/ast.rs2
-rw-r--r--crates/ra_syntax/src/grammar/type_params.rs7
-rw-r--r--crates/ra_syntax/src/lexer.rs2
-rw-r--r--crates/ra_syntax/src/string_lexing/byte.rs2
-rw-r--r--crates/ra_syntax/src/string_lexing/byte_string.rs2
-rw-r--r--crates/ra_syntax/src/string_lexing/char.rs2
-rw-r--r--crates/ra_syntax/src/string_lexing/string.rs2
-rw-r--r--crates/ra_syntax/tests/data/parser/inline/ok/0056_where_clause.rs1
-rw-r--r--crates/ra_syntax/tests/data/parser/inline/ok/0056_where_clause.txt44
-rw-r--r--crates/ra_syntax/tests/data/parser/ok/0036_fully_qualified.rs8
-rw-r--r--crates/ra_syntax/tests/data/parser/ok/0036_fully_qualified.txt88
-rw-r--r--crates/ra_syntax/tests/test.rs12
12 files changed, 149 insertions, 23 deletions
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs
index 91c67119f..f12479fb4 100644
--- a/crates/ra_syntax/src/ast.rs
+++ b/crates/ra_syntax/src/ast.rs
@@ -284,7 +284,7 @@ impl<'a> IfExpr<'a> {
284 } 284 }
285} 285}
286 286
287#[derive(Debug, Clone, Copy)] 287#[derive(Debug, Clone, Copy, PartialEq, Eq)]
288pub enum PathSegmentKind<'a> { 288pub enum PathSegmentKind<'a> {
289 Name(NameRef<'a>), 289 Name(NameRef<'a>),
290 SelfKw, 290 SelfKw,
diff --git a/crates/ra_syntax/src/grammar/type_params.rs b/crates/ra_syntax/src/grammar/type_params.rs
index 863f8e00c..7db25beba 100644
--- a/crates/ra_syntax/src/grammar/type_params.rs
+++ b/crates/ra_syntax/src/grammar/type_params.rs
@@ -96,6 +96,7 @@ pub(super) fn bounds_without_colon(p: &mut Parser) {
96// 'a: 'b + 'c, 96// 'a: 'b + 'c,
97// T: Clone + Copy + 'static, 97// T: Clone + Copy + 'static,
98// Iterator::Item: 'a, 98// Iterator::Item: 'a,
99// <T as Iterator>::Item: 'a
99// {} 100// {}
100pub(super) fn opt_where_clause(p: &mut Parser) { 101pub(super) fn opt_where_clause(p: &mut Parser) {
101 if !p.at(WHERE_KW) { 102 if !p.at(WHERE_KW) {
@@ -104,7 +105,11 @@ pub(super) fn opt_where_clause(p: &mut Parser) {
104 let m = p.start(); 105 let m = p.start();
105 p.bump(); 106 p.bump();
106 loop { 107 loop {
107 if !(paths::is_path_start(p) || p.current() == LIFETIME || p.current() == FOR_KW) { 108 if !(paths::is_path_start(p)
109 || p.current() == LIFETIME
110 || p.current() == FOR_KW
111 || p.current() == L_ANGLE)
112 {
108 break; 113 break;
109 } 114 }
110 where_predicate(p); 115 where_predicate(p);
diff --git a/crates/ra_syntax/src/lexer.rs b/crates/ra_syntax/src/lexer.rs
index f388da273..c6acd095e 100644
--- a/crates/ra_syntax/src/lexer.rs
+++ b/crates/ra_syntax/src/lexer.rs
@@ -160,7 +160,7 @@ fn next_token_inner(c: char, ptr: &mut Ptr) -> SyntaxKind {
160 // if we find one, then this is an invalid character literal 160 // if we find one, then this is an invalid character literal
161 if ptr.at('\'') { 161 if ptr.at('\'') {
162 ptr.bump(); 162 ptr.bump();
163 return CHAR; // TODO: error reporting 163 return CHAR;
164 } 164 }
165 LIFETIME 165 LIFETIME
166 } else { 166 } else {
diff --git a/crates/ra_syntax/src/string_lexing/byte.rs b/crates/ra_syntax/src/string_lexing/byte.rs
index 24424349c..b3228d6ca 100644
--- a/crates/ra_syntax/src/string_lexing/byte.rs
+++ b/crates/ra_syntax/src/string_lexing/byte.rs
@@ -40,7 +40,7 @@ impl<'a> Iterator for ByteComponentIterator<'a> {
40 40
41 assert!( 41 assert!(
42 self.parser.peek() == None, 42 self.parser.peek() == None,
43 "byte literal should leave no unparsed input: src = {}, pos = {}, length = {}", 43 "byte literal should leave no unparsed input: src = {:?}, pos = {}, length = {}",
44 self.parser.src, 44 self.parser.src,
45 self.parser.pos, 45 self.parser.pos,
46 self.parser.src.len() 46 self.parser.src.len()
diff --git a/crates/ra_syntax/src/string_lexing/byte_string.rs b/crates/ra_syntax/src/string_lexing/byte_string.rs
index 5b6dda760..a6056159b 100644
--- a/crates/ra_syntax/src/string_lexing/byte_string.rs
+++ b/crates/ra_syntax/src/string_lexing/byte_string.rs
@@ -40,7 +40,7 @@ impl<'a> Iterator for ByteStringComponentIterator<'a> {
40 40
41 assert!( 41 assert!(
42 self.parser.peek() == None, 42 self.parser.peek() == None,
43 "byte string literal should leave no unparsed input: src = {}, pos = {}, length = {}", 43 "byte string literal should leave no unparsed input: src = {:?}, pos = {}, length = {}",
44 self.parser.src, 44 self.parser.src,
45 self.parser.pos, 45 self.parser.pos,
46 self.parser.src.len() 46 self.parser.src.len()
diff --git a/crates/ra_syntax/src/string_lexing/char.rs b/crates/ra_syntax/src/string_lexing/char.rs
index 885c03b14..e01813176 100644
--- a/crates/ra_syntax/src/string_lexing/char.rs
+++ b/crates/ra_syntax/src/string_lexing/char.rs
@@ -35,7 +35,7 @@ impl<'a> Iterator for CharComponentIterator<'a> {
35 35
36 assert!( 36 assert!(
37 self.parser.peek() == None, 37 self.parser.peek() == None,
38 "char literal should leave no unparsed input: src = {}, pos = {}, length = {}", 38 "char literal should leave no unparsed input: src = {:?}, pos = {}, length = {}",
39 self.parser.src, 39 self.parser.src,
40 self.parser.pos, 40 self.parser.pos,
41 self.parser.src.len() 41 self.parser.src.len()
diff --git a/crates/ra_syntax/src/string_lexing/string.rs b/crates/ra_syntax/src/string_lexing/string.rs
index 1b23029c6..d8351e9af 100644
--- a/crates/ra_syntax/src/string_lexing/string.rs
+++ b/crates/ra_syntax/src/string_lexing/string.rs
@@ -35,7 +35,7 @@ impl<'a> Iterator for StringComponentIterator<'a> {
35 35
36 assert!( 36 assert!(
37 self.parser.peek() == None, 37 self.parser.peek() == None,
38 "string literal should leave no unparsed input: src = {}, pos = {}, length = {}", 38 "string literal should leave no unparsed input: src = {:?}, pos = {}, length = {}",
39 self.parser.src, 39 self.parser.src,
40 self.parser.pos, 40 self.parser.pos,
41 self.parser.src.len() 41 self.parser.src.len()
diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0056_where_clause.rs b/crates/ra_syntax/tests/data/parser/inline/ok/0056_where_clause.rs
index 592a005f9..19d7e571b 100644
--- a/crates/ra_syntax/tests/data/parser/inline/ok/0056_where_clause.rs
+++ b/crates/ra_syntax/tests/data/parser/inline/ok/0056_where_clause.rs
@@ -3,4 +3,5 @@ where
3 'a: 'b + 'c, 3 'a: 'b + 'c,
4 T: Clone + Copy + 'static, 4 T: Clone + Copy + 'static,
5 Iterator::Item: 'a, 5 Iterator::Item: 'a,
6 <T as Iterator>::Item: 'a
6{} 7{}
diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0056_where_clause.txt b/crates/ra_syntax/tests/data/parser/inline/ok/0056_where_clause.txt
index 54c3d64f1..68485dc0b 100644
--- a/crates/ra_syntax/tests/data/parser/inline/ok/0056_where_clause.txt
+++ b/crates/ra_syntax/tests/data/parser/inline/ok/0056_where_clause.txt
@@ -1,5 +1,5 @@
1SOURCE_FILE@[0; 87) 1SOURCE_FILE@[0; 116)
2 FN_DEF@[0; 86) 2 FN_DEF@[0; 115)
3 FN_KW@[0; 2) 3 FN_KW@[0; 2)
4 WHITESPACE@[2; 3) 4 WHITESPACE@[2; 3)
5 NAME@[3; 6) 5 NAME@[3; 6)
@@ -8,7 +8,7 @@ SOURCE_FILE@[0; 87)
8 L_PAREN@[6; 7) 8 L_PAREN@[6; 7)
9 R_PAREN@[7; 8) 9 R_PAREN@[7; 8)
10 WHITESPACE@[8; 9) 10 WHITESPACE@[8; 9)
11 WHERE_CLAUSE@[9; 83) 11 WHERE_CLAUSE@[9; 112)
12 WHERE_KW@[9; 14) 12 WHERE_KW@[9; 14)
13 WHITESPACE@[14; 18) 13 WHITESPACE@[14; 18)
14 WHERE_PRED@[18; 29) 14 WHERE_PRED@[18; 29)
@@ -64,8 +64,36 @@ SOURCE_FILE@[0; 87)
64 WHITESPACE@[79; 80) 64 WHITESPACE@[79; 80)
65 LIFETIME@[80; 82) "'a" 65 LIFETIME@[80; 82) "'a"
66 COMMA@[82; 83) 66 COMMA@[82; 83)
67 WHITESPACE@[83; 84) 67 WHITESPACE@[83; 87)
68 BLOCK@[84; 86) 68 WHERE_PRED@[87; 112)
69 L_CURLY@[84; 85) 69 PATH_TYPE@[87; 108)
70 R_CURLY@[85; 86) 70 PATH@[87; 108)
71 WHITESPACE@[86; 87) 71 PATH@[87; 102)
72 PATH_SEGMENT@[87; 102)
73 L_ANGLE@[87; 88)
74 PATH_TYPE@[88; 89)
75 PATH@[88; 89)
76 PATH_SEGMENT@[88; 89)
77 NAME_REF@[88; 89)
78 IDENT@[88; 89) "T"
79 WHITESPACE@[89; 90)
80 AS_KW@[90; 92)
81 WHITESPACE@[92; 93)
82 PATH_TYPE@[93; 101)
83 PATH@[93; 101)
84 PATH_SEGMENT@[93; 101)
85 NAME_REF@[93; 101)
86 IDENT@[93; 101) "Iterator"
87 R_ANGLE@[101; 102)
88 COLONCOLON@[102; 104)
89 PATH_SEGMENT@[104; 108)
90 NAME_REF@[104; 108)
91 IDENT@[104; 108) "Item"
92 COLON@[108; 109)
93 WHITESPACE@[109; 110)
94 LIFETIME@[110; 112) "'a"
95 WHITESPACE@[112; 113)
96 BLOCK@[113; 115)
97 L_CURLY@[113; 114)
98 R_CURLY@[114; 115)
99 WHITESPACE@[115; 116)
diff --git a/crates/ra_syntax/tests/data/parser/ok/0036_fully_qualified.rs b/crates/ra_syntax/tests/data/parser/ok/0036_fully_qualified.rs
new file mode 100644
index 000000000..6da27933e
--- /dev/null
+++ b/crates/ra_syntax/tests/data/parser/ok/0036_fully_qualified.rs
@@ -0,0 +1,8 @@
1// https://github.com/rust-analyzer/rust-analyzer/issues/311
2
3pub fn foo<S: Iterator>() -> String
4where
5 <S as Iterator>::Item: Eq,
6{
7 "".to_owned()
8}
diff --git a/crates/ra_syntax/tests/data/parser/ok/0036_fully_qualified.txt b/crates/ra_syntax/tests/data/parser/ok/0036_fully_qualified.txt
new file mode 100644
index 000000000..208e5e51c
--- /dev/null
+++ b/crates/ra_syntax/tests/data/parser/ok/0036_fully_qualified.txt
@@ -0,0 +1,88 @@
1SOURCE_FILE@[0; 157)
2 COMMENT@[0; 60)
3 WHITESPACE@[60; 62)
4 FN_DEF@[62; 156)
5 VISIBILITY@[62; 65)
6 PUB_KW@[62; 65)
7 WHITESPACE@[65; 66)
8 FN_KW@[66; 68)
9 WHITESPACE@[68; 69)
10 NAME@[69; 72)
11 IDENT@[69; 72) "foo"
12 TYPE_PARAM_LIST@[72; 85)
13 L_ANGLE@[72; 73)
14 TYPE_PARAM@[73; 84)
15 NAME@[73; 74)
16 IDENT@[73; 74) "S"
17 COLON@[74; 75)
18 WHITESPACE@[75; 76)
19 PATH_TYPE@[76; 84)
20 PATH@[76; 84)
21 PATH_SEGMENT@[76; 84)
22 NAME_REF@[76; 84)
23 IDENT@[76; 84) "Iterator"
24 R_ANGLE@[84; 85)
25 PARAM_LIST@[85; 87)
26 L_PAREN@[85; 86)
27 R_PAREN@[86; 87)
28 WHITESPACE@[87; 88)
29 RET_TYPE@[88; 97)
30 THIN_ARROW@[88; 90)
31 WHITESPACE@[90; 91)
32 PATH_TYPE@[91; 97)
33 PATH@[91; 97)
34 PATH_SEGMENT@[91; 97)
35 NAME_REF@[91; 97)
36 IDENT@[91; 97) "String"
37 WHITESPACE@[97; 98)
38 WHERE_CLAUSE@[98; 134)
39 WHERE_KW@[98; 103)
40 WHITESPACE@[103; 108)
41 WHERE_PRED@[108; 133)
42 PATH_TYPE@[108; 129)
43 PATH@[108; 129)
44 PATH@[108; 123)
45 PATH_SEGMENT@[108; 123)
46 L_ANGLE@[108; 109)
47 PATH_TYPE@[109; 110)
48 PATH@[109; 110)
49 PATH_SEGMENT@[109; 110)
50 NAME_REF@[109; 110)
51 IDENT@[109; 110) "S"
52 WHITESPACE@[110; 111)
53 AS_KW@[111; 113)
54 WHITESPACE@[113; 114)
55 PATH_TYPE@[114; 122)
56 PATH@[114; 122)
57 PATH_SEGMENT@[114; 122)
58 NAME_REF@[114; 122)
59 IDENT@[114; 122) "Iterator"
60 R_ANGLE@[122; 123)
61 COLONCOLON@[123; 125)
62 PATH_SEGMENT@[125; 129)
63 NAME_REF@[125; 129)
64 IDENT@[125; 129) "Item"
65 COLON@[129; 130)
66 WHITESPACE@[130; 131)
67 PATH_TYPE@[131; 133)
68 PATH@[131; 133)
69 PATH_SEGMENT@[131; 133)
70 NAME_REF@[131; 133)
71 IDENT@[131; 133) "Eq"
72 COMMA@[133; 134)
73 WHITESPACE@[134; 135)
74 BLOCK@[135; 156)
75 L_CURLY@[135; 136)
76 WHITESPACE@[136; 141)
77 METHOD_CALL_EXPR@[141; 154)
78 LITERAL@[141; 143)
79 STRING@[141; 143)
80 DOT@[143; 144)
81 NAME_REF@[144; 152)
82 IDENT@[144; 152) "to_owned"
83 ARG_LIST@[152; 154)
84 L_PAREN@[152; 153)
85 R_PAREN@[153; 154)
86 WHITESPACE@[154; 155)
87 R_CURLY@[155; 156)
88 WHITESPACE@[156; 157)
diff --git a/crates/ra_syntax/tests/test.rs b/crates/ra_syntax/tests/test.rs
index 14ad836b5..4266864bd 100644
--- a/crates/ra_syntax/tests/test.rs
+++ b/crates/ra_syntax/tests/test.rs
@@ -65,14 +65,10 @@ fn self_hosting_parsing() {
65 for entry in walkdir::WalkDir::new(dir) 65 for entry in walkdir::WalkDir::new(dir)
66 .into_iter() 66 .into_iter()
67 .filter_entry(|entry| { 67 .filter_entry(|entry| {
68 !entry 68 !entry.path().components().any(|component| {
69 .path() 69 // Get all files which are not in the crates/ra_syntax/tests/data folder
70 .components() 70 component == Component::Normal(OsStr::new("data"))
71 // TODO: this more neatly 71 })
72 .any(|component| {
73 // Get all files which are not in the crates/ra_syntax/tests/data folder
74 component == Component::Normal(OsStr::new("data"))
75 })
76 }) 72 })
77 .map(|e| e.unwrap()) 73 .map(|e| e.unwrap())
78 .filter(|entry| { 74 .filter(|entry| {