aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock4
-rw-r--r--crates/assists/src/handlers/introduce_named_lifetime.rs2
-rw-r--r--crates/hir_ty/src/tests.rs4
-rw-r--r--crates/ide/src/display/navigation_target.rs14
-rw-r--r--crates/ide/src/goto_definition.rs5
-rw-r--r--crates/ide/src/hover.rs5
-rw-r--r--crates/ide/src/references/rename.rs76
-rw-r--r--crates/ide/src/syntax_highlighting/highlight.rs22
-rw-r--r--crates/ide_db/src/defs.rs11
-rw-r--r--crates/parser/src/grammar.rs12
-rw-r--r--crates/parser/src/grammar/items.rs2
-rw-r--r--crates/parser/src/grammar/params.rs31
-rw-r--r--crates/syntax/src/ast/generated/nodes.rs7
-rw-r--r--crates/syntax/src/ast/node_ext.rs33
-rw-r--r--crates/syntax/test_data/parser/err/0037_visibility_in_traits.rast10
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0006_self_param.rast15
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0018_arb_self_types.rast6
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0021_impl_item_list.rast3
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0022_crate_visibility.rast50
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0022_crate_visibility.rs3
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0138_self_param_outer_attr.rast3
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0160_crate_visibility_in.rast42
-rw-r--r--crates/syntax/test_data/parser/inline/ok/0160_crate_visibility_in.rs2
-rw-r--r--crates/syntax/test_data/parser/ok/0007_extern_crate.rast3
-rw-r--r--crates/syntax/test_data/parser/ok/0012_visibility.rast10
-rw-r--r--crates/syntax/test_data/parser/ok/0045_block_inner_attrs.rast3
-rw-r--r--crates/syntax/test_data/parser/ok/0051_parameter_attrs.rast24
-rw-r--r--xtask/Cargo.toml2
28 files changed, 236 insertions, 168 deletions
diff --git a/Cargo.lock b/Cargo.lock
index db8b49122..89d52a290 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1837,9 +1837,9 @@ checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c"
1837 1837
1838[[package]] 1838[[package]]
1839name = "ungrammar" 1839name = "ungrammar"
1840version = "1.8.0" 1840version = "1.9.0"
1841source = "registry+https://github.com/rust-lang/crates.io-index" 1841source = "registry+https://github.com/rust-lang/crates.io-index"
1842checksum = "e33a2183403af89252547c4219a06a6cc8aef6302fee67e10e8431866af3ee72" 1842checksum = "b137a875a3b942539dd04bd37d193649f5d67e11407186f5b9d63ae0332b1a93"
1843 1843
1844[[package]] 1844[[package]]
1845name = "unicase" 1845name = "unicase"
diff --git a/crates/assists/src/handlers/introduce_named_lifetime.rs b/crates/assists/src/handlers/introduce_named_lifetime.rs
index 3f5f44d69..02782eb6d 100644
--- a/crates/assists/src/handlers/introduce_named_lifetime.rs
+++ b/crates/assists/src/handlers/introduce_named_lifetime.rs
@@ -61,7 +61,7 @@ fn generate_fn_def_assist(
61 // compute the location which implicitly has the same lifetime as the anonymous lifetime 61 // compute the location which implicitly has the same lifetime as the anonymous lifetime
62 let loc_needing_lifetime = if let Some(self_param) = self_param { 62 let loc_needing_lifetime = if let Some(self_param) = self_param {
63 // if we have a self reference, use that 63 // if we have a self reference, use that
64 Some(self_param.self_token()?.text_range().start()) 64 Some(self_param.name()?.syntax().text_range().start())
65 } else { 65 } else {
66 // otherwise, if there's a single reference parameter without a named liftime, use that 66 // otherwise, if there's a single reference parameter without a named liftime, use that
67 let fn_params_without_lifetime: Vec<_> = param_list 67 let fn_params_without_lifetime: Vec<_> = param_list
diff --git a/crates/hir_ty/src/tests.rs b/crates/hir_ty/src/tests.rs
index 3b1675f0b..5ff755321 100644
--- a/crates/hir_ty/src/tests.rs
+++ b/crates/hir_ty/src/tests.rs
@@ -26,7 +26,7 @@ use once_cell::race::OnceBool;
26use stdx::format_to; 26use stdx::format_to;
27use syntax::{ 27use syntax::{
28 algo, 28 algo,
29 ast::{self, AstNode}, 29 ast::{self, AstNode, NameOwner},
30 SyntaxNode, 30 SyntaxNode,
31}; 31};
32use tracing_subscriber::{layer::SubscriberExt, EnvFilter, Registry}; 32use tracing_subscriber::{layer::SubscriberExt, EnvFilter, Registry};
@@ -153,7 +153,7 @@ fn infer_with_mismatches(content: &str, include_mismatches: bool) -> String {
153 }); 153 });
154 for (node, ty) in &types { 154 for (node, ty) in &types {
155 let (range, text) = if let Some(self_param) = ast::SelfParam::cast(node.value.clone()) { 155 let (range, text) = if let Some(self_param) = ast::SelfParam::cast(node.value.clone()) {
156 (self_param.self_token().unwrap().text_range(), "self".to_string()) 156 (self_param.name().unwrap().syntax().text_range(), "self".to_string())
157 } else { 157 } else {
158 (node.value.text_range(), node.value.text().to_string().replace("\n", " ")) 158 (node.value.text_range(), node.value.text().to_string().replace("\n", " "))
159 }; 159 };
diff --git a/crates/ide/src/display/navigation_target.rs b/crates/ide/src/display/navigation_target.rs
index 685052e7f..00e601244 100644
--- a/crates/ide/src/display/navigation_target.rs
+++ b/crates/ide/src/display/navigation_target.rs
@@ -400,15 +400,13 @@ impl TryToNav for hir::GenericParam {
400impl ToNav for hir::Local { 400impl ToNav for hir::Local {
401 fn to_nav(&self, db: &RootDatabase) -> NavigationTarget { 401 fn to_nav(&self, db: &RootDatabase) -> NavigationTarget {
402 let src = self.source(db); 402 let src = self.source(db);
403 let (node, focus_range) = match &src.value { 403 let (node, name) = match &src.value {
404 Either::Left(bind_pat) => ( 404 Either::Left(bind_pat) => (bind_pat.syntax().clone(), bind_pat.name()),
405 bind_pat.syntax().clone(), 405 Either::Right(it) => (it.syntax().clone(), it.name()),
406 bind_pat
407 .name()
408 .map(|it| src.with_value(&it.syntax().clone()).original_file_range(db).range),
409 ),
410 Either::Right(it) => (it.syntax().clone(), it.self_token().map(|it| it.text_range())),
411 }; 406 };
407 let focus_range =
408 name.map(|it| src.with_value(&it.syntax().clone()).original_file_range(db).range);
409
412 let full_range = src.with_value(&node).original_file_range(db); 410 let full_range = src.with_value(&node).original_file_range(db);
413 let name = match self.name(db) { 411 let name = match self.name(db) {
414 Some(it) => it.to_string().into(), 412 Some(it) => it.to_string().into(),
diff --git a/crates/ide/src/goto_definition.rs b/crates/ide/src/goto_definition.rs
index 988a5668f..a1d2bce1d 100644
--- a/crates/ide/src/goto_definition.rs
+++ b/crates/ide/src/goto_definition.rs
@@ -55,11 +55,6 @@ pub(crate) fn goto_definition(
55 } else { 55 } else {
56 reference_definition(&sema, Either::Left(&lt)).to_vec() 56 reference_definition(&sema, Either::Left(&lt)).to_vec()
57 }, 57 },
58 ast::SelfParam(self_param) => {
59 let def = NameClass::classify_self_param(&sema, &self_param)?.referenced_or_defined(sema.db);
60 let nav = def.try_to_nav(sema.db)?;
61 vec![nav]
62 },
63 _ => return None, 58 _ => return None,
64 } 59 }
65 }; 60 };
diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs
index 6022bd275..2024acd94 100644
--- a/crates/ide/src/hover.rs
+++ b/crates/ide/src/hover.rs
@@ -98,7 +98,6 @@ pub(crate) fn hover(
98 ast::NameRef(name_ref) => NameRefClass::classify(&sema, &name_ref).map(|d| d.referenced(sema.db)), 98 ast::NameRef(name_ref) => NameRefClass::classify(&sema, &name_ref).map(|d| d.referenced(sema.db)),
99 ast::Lifetime(lifetime) => NameClass::classify_lifetime(&sema, &lifetime) 99 ast::Lifetime(lifetime) => NameClass::classify_lifetime(&sema, &lifetime)
100 .map_or_else(|| NameRefClass::classify_lifetime(&sema, &lifetime).map(|d| d.referenced(sema.db)), |d| d.defined(sema.db)), 100 .map_or_else(|| NameRefClass::classify_lifetime(&sema, &lifetime).map(|d| d.referenced(sema.db)), |d| d.defined(sema.db)),
101 ast::SelfParam(self_param) => NameClass::classify_self_param(&sema, &self_param).and_then(|d| d.defined(sema.db)),
102 _ => None, 101 _ => None,
103 } 102 }
104 }; 103 };
@@ -3223,7 +3222,7 @@ impl Foo {
3223} 3222}
3224"#, 3223"#,
3225 expect![[r#" 3224 expect![[r#"
3226 *&self* 3225 *self*
3227 3226
3228 ```rust 3227 ```rust
3229 &Foo 3228 &Foo
@@ -3243,7 +3242,7 @@ impl Foo {
3243} 3242}
3244"#, 3243"#,
3245 expect![[r#" 3244 expect![[r#"
3246 *self: Arc<Foo>* 3245 *self*
3247 3246
3248 ```rust 3247 ```rust
3249 Arc<Foo> 3248 Arc<Foo>
diff --git a/crates/ide/src/references/rename.rs b/crates/ide/src/references/rename.rs
index 9ac4af026..4df189c98 100644
--- a/crates/ide/src/references/rename.rs
+++ b/crates/ide/src/references/rename.rs
@@ -1,12 +1,9 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2use std::{ 2use std::fmt::{self, Display};
3 convert::TryInto,
4 fmt::{self, Display},
5};
6 3
7use hir::{Module, ModuleDef, ModuleSource, Semantics}; 4use hir::{Module, ModuleDef, ModuleSource, Semantics};
8use ide_db::{ 5use ide_db::{
9 base_db::{AnchoredPathBuf, FileId, FileRange, SourceDatabaseExt}, 6 base_db::{AnchoredPathBuf, FileId, FileRange},
10 defs::{Definition, NameClass, NameRefClass}, 7 defs::{Definition, NameClass, NameRefClass},
11 search::FileReference, 8 search::FileReference,
12 RootDatabase, 9 RootDatabase,
@@ -14,14 +11,14 @@ use ide_db::{
14use syntax::{ 11use syntax::{
15 algo::find_node_at_offset, 12 algo::find_node_at_offset,
16 ast::{self, NameOwner}, 13 ast::{self, NameOwner},
17 lex_single_syntax_kind, match_ast, AstNode, SyntaxKind, SyntaxNode, SyntaxToken, T, 14 lex_single_syntax_kind, match_ast, AstNode, SyntaxKind, SyntaxNode, T,
18}; 15};
19use test_utils::mark; 16use test_utils::mark;
20use text_edit::TextEdit; 17use text_edit::TextEdit;
21 18
22use crate::{ 19use crate::{
23 FilePosition, FileSystemEdit, RangeInfo, ReferenceKind, ReferenceSearchResult, SourceChange, 20 FilePosition, FileSystemEdit, RangeInfo, ReferenceKind, ReferenceSearchResult, SourceChange,
24 TextRange, TextSize, 21 TextRange,
25}; 22};
26 23
27type RenameResult<T> = Result<T, RenameError>; 24type RenameResult<T> = Result<T, RenameError>;
@@ -52,10 +49,6 @@ pub(crate) fn prepare_rename(
52 let syntax = source_file.syntax(); 49 let syntax = source_file.syntax();
53 if let Some(module) = find_module_at_offset(&sema, position, syntax) { 50 if let Some(module) = find_module_at_offset(&sema, position, syntax) {
54 rename_mod(&sema, position, module, "dummy") 51 rename_mod(&sema, position, module, "dummy")
55 } else if let Some(self_token) =
56 syntax.token_at_offset(position.offset).find(|t| t.kind() == T![self])
57 {
58 rename_self_to_param(&sema, position, self_token, "dummy")
59 } else { 52 } else {
60 let RangeInfo { range, .. } = find_all_refs(&sema, position)?; 53 let RangeInfo { range, .. } = find_all_refs(&sema, position)?;
61 Ok(RangeInfo::new(range, SourceChange::default())) 54 Ok(RangeInfo::new(range, SourceChange::default()))
@@ -82,10 +75,6 @@ pub(crate) fn rename_with_semantics(
82 75
83 if let Some(module) = find_module_at_offset(&sema, position, syntax) { 76 if let Some(module) = find_module_at_offset(&sema, position, syntax) {
84 rename_mod(&sema, position, module, new_name) 77 rename_mod(&sema, position, module, new_name)
85 } else if let Some(self_token) =
86 syntax.token_at_offset(position.offset).find(|t| t.kind() == T![self])
87 {
88 rename_self_to_param(&sema, position, self_token, new_name)
89 } else { 78 } else {
90 rename_reference(&sema, position, new_name) 79 rename_reference(&sema, position, new_name)
91 } 80 }
@@ -108,7 +97,7 @@ pub(crate) fn will_rename_file(
108 Some(change) 97 Some(change)
109} 98}
110 99
111#[derive(Debug, PartialEq)] 100#[derive(Copy, Clone, Debug, PartialEq)]
112enum IdentifierKind { 101enum IdentifierKind {
113 Ident, 102 Ident,
114 Lifetime, 103 Lifetime,
@@ -375,53 +364,50 @@ fn text_edit_from_self_param(
375fn rename_self_to_param( 364fn rename_self_to_param(
376 sema: &Semantics<RootDatabase>, 365 sema: &Semantics<RootDatabase>,
377 position: FilePosition, 366 position: FilePosition,
378 self_token: SyntaxToken,
379 new_name: &str, 367 new_name: &str,
368 ident_kind: IdentifierKind,
369 range: TextRange,
370 refs: ReferenceSearchResult,
380) -> Result<RangeInfo<SourceChange>, RenameError> { 371) -> Result<RangeInfo<SourceChange>, RenameError> {
381 let ident_kind = check_identifier(new_name)?;
382 match ident_kind { 372 match ident_kind {
383 IdentifierKind::Lifetime => bail!("Invalid name `{}`: not an identifier", new_name), 373 IdentifierKind::Lifetime => bail!("Invalid name `{}`: not an identifier", new_name),
384 IdentifierKind::ToSelf => { 374 IdentifierKind::ToSelf => {
385 // no-op 375 // no-op
386 mark::hit!(rename_self_to_self); 376 mark::hit!(rename_self_to_self);
387 return Ok(RangeInfo::new(self_token.text_range(), SourceChange::default())); 377 return Ok(RangeInfo::new(range, SourceChange::default()));
388 } 378 }
389 _ => (), 379 _ => (),
390 } 380 }
391 let source_file = sema.parse(position.file_id); 381 let source_file = sema.parse(position.file_id);
392 let syn = source_file.syntax(); 382 let syn = source_file.syntax();
393 383
394 let text = sema.db.file_text(position.file_id);
395 let fn_def = find_node_at_offset::<ast::Fn>(syn, position.offset) 384 let fn_def = find_node_at_offset::<ast::Fn>(syn, position.offset)
396 .ok_or_else(|| format_err!("No surrounding method declaration found"))?; 385 .ok_or_else(|| format_err!("No surrounding method declaration found"))?;
397 let search_range = fn_def.syntax().text_range();
398 386
399 let mut source_change = SourceChange::default(); 387 let mut source_change = SourceChange::default();
400 388 if let Some(self_param) = fn_def.param_list().and_then(|it| it.self_param()) {
401 for (idx, _) in text.match_indices("self") { 389 if self_param
402 let offset: TextSize = idx.try_into().unwrap(); 390 .syntax()
403 if !search_range.contains_inclusive(offset) { 391 .text_range()
404 continue; 392 .contains_range(refs.declaration().nav.focus_or_full_range())
405 } 393 {
406 if let Some(ref usage) = syn.token_at_offset(offset).find(|t| t.kind() == T![self]) { 394 let edit = text_edit_from_self_param(syn, &self_param, new_name)
407 let edit = if let Some(ref self_param) = ast::SelfParam::cast(usage.parent()) { 395 .ok_or_else(|| format_err!("No target type found"))?;
408 text_edit_from_self_param(syn, self_param, new_name)
409 .ok_or_else(|| format_err!("No target type found"))?
410 } else {
411 TextEdit::replace(usage.text_range(), String::from(new_name))
412 };
413 source_change.insert_source_edit(position.file_id, edit); 396 source_change.insert_source_edit(position.file_id, edit);
414 }
415 }
416 397
417 if source_change.source_file_edits.len() > 1 && ident_kind == IdentifierKind::Underscore { 398 source_change.extend(refs.references().iter().map(|(&file_id, references)| {
418 bail!("Cannot rename reference to `_` as it is being referenced multiple times"); 399 source_edit_from_references(sema, file_id, &references, new_name)
419 } 400 }));
420 401
421 let range = ast::SelfParam::cast(self_token.parent()) 402 if source_change.source_file_edits.len() > 1 && ident_kind == IdentifierKind::Underscore
422 .map_or(self_token.text_range(), |p| p.syntax().text_range()); 403 {
404 bail!("Cannot rename reference to `_` as it is being referenced multiple times");
405 }
423 406
424 Ok(RangeInfo::new(range, source_change)) 407 return Ok(RangeInfo::new(range, source_change));
408 }
409 }
410 Err(format_err!("Method has no self param"))
425} 411}
426 412
427fn rename_reference( 413fn rename_reference(
@@ -444,8 +430,9 @@ fn rename_reference(
444 mark::hit!(rename_not_an_ident_ref); 430 mark::hit!(rename_not_an_ident_ref);
445 bail!("Invalid name `{}`: not an identifier", new_name) 431 bail!("Invalid name `{}`: not an identifier", new_name)
446 } 432 }
447 (IdentifierKind::ToSelf, ReferenceKind::SelfParam) => { 433 (_, ReferenceKind::SelfParam) => {
448 unreachable!("rename_self_to_param should've been called instead") 434 mark::hit!(rename_self_to_param);
435 return rename_self_to_param(sema, position, new_name, ident_kind, range, refs);
449 } 436 }
450 (IdentifierKind::ToSelf, _) => { 437 (IdentifierKind::ToSelf, _) => {
451 mark::hit!(rename_to_self); 438 mark::hit!(rename_to_self);
@@ -1350,6 +1337,7 @@ impl Foo {
1350 1337
1351 #[test] 1338 #[test]
1352 fn test_owned_self_to_parameter() { 1339 fn test_owned_self_to_parameter() {
1340 mark::check!(rename_self_to_param);
1353 check( 1341 check(
1354 "foo", 1342 "foo",
1355 r#" 1343 r#"
diff --git a/crates/ide/src/syntax_highlighting/highlight.rs b/crates/ide/src/syntax_highlighting/highlight.rs
index 87578e70a..8625ef5df 100644
--- a/crates/ide/src/syntax_highlighting/highlight.rs
+++ b/crates/ide/src/syntax_highlighting/highlight.rs
@@ -68,7 +68,8 @@ pub(super) fn element(
68 NAME_REF => { 68 NAME_REF => {
69 let name_ref = element.into_node().and_then(ast::NameRef::cast).unwrap(); 69 let name_ref = element.into_node().and_then(ast::NameRef::cast).unwrap();
70 highlight_func_by_name_ref(sema, &name_ref).unwrap_or_else(|| { 70 highlight_func_by_name_ref(sema, &name_ref).unwrap_or_else(|| {
71 match NameRefClass::classify(sema, &name_ref) { 71 let is_self = name_ref.self_token().is_some();
72 let h = match NameRefClass::classify(sema, &name_ref) {
72 Some(name_kind) => match name_kind { 73 Some(name_kind) => match name_kind {
73 NameRefClass::ExternCrate(_) => HlTag::Symbol(SymbolKind::Module).into(), 74 NameRefClass::ExternCrate(_) => HlTag::Symbol(SymbolKind::Module).into(),
74 NameRefClass::Definition(def) => { 75 NameRefClass::Definition(def) => {
@@ -108,6 +109,11 @@ pub(super) fn element(
108 highlight_name_ref_by_syntax(name_ref, sema) 109 highlight_name_ref_by_syntax(name_ref, sema)
109 } 110 }
110 None => HlTag::UnresolvedReference.into(), 111 None => HlTag::UnresolvedReference.into(),
112 };
113 if h.tag == HlTag::Symbol(SymbolKind::Module) && is_self {
114 HlTag::Symbol(SymbolKind::SelfParam).into()
115 } else {
116 h
111 } 117 }
112 }) 118 })
113 } 119 }
@@ -225,18 +231,8 @@ pub(super) fn element(
225 T![for] if !is_child_of_impl(&element) => h | HlMod::ControlFlow, 231 T![for] if !is_child_of_impl(&element) => h | HlMod::ControlFlow,
226 T![unsafe] => h | HlMod::Unsafe, 232 T![unsafe] => h | HlMod::Unsafe,
227 T![true] | T![false] => HlTag::BoolLiteral.into(), 233 T![true] | T![false] => HlTag::BoolLiteral.into(),
228 T![self] => { 234 // self is handled as either a Name or NameRef already
229 let self_param = element.parent().and_then(ast::SelfParam::cast); 235 T![self] => return None,
230 if let Some(NameClass::Definition(def)) = self_param
231 .and_then(|self_param| NameClass::classify_self_param(sema, &self_param))
232 {
233 highlight_def(db, def) | HlMod::Definition
234 } else if element.ancestors().any(|it| it.kind() == USE_TREE) {
235 HlTag::Symbol(SymbolKind::SelfParam).into()
236 } else {
237 return None;
238 }
239 }
240 T![ref] => element 236 T![ref] => element
241 .parent() 237 .parent()
242 .and_then(ast::IdentPat::cast) 238 .and_then(ast::IdentPat::cast)
diff --git a/crates/ide_db/src/defs.rs b/crates/ide_db/src/defs.rs
index 231e886a9..d9875ffef 100644
--- a/crates/ide_db/src/defs.rs
+++ b/crates/ide_db/src/defs.rs
@@ -117,13 +117,6 @@ impl NameClass {
117 } 117 }
118 } 118 }
119 119
120 pub fn classify_self_param(
121 sema: &Semantics<RootDatabase>,
122 self_param: &ast::SelfParam,
123 ) -> Option<NameClass> {
124 sema.to_def(self_param).map(Definition::Local).map(NameClass::Definition)
125 }
126
127 pub fn classify(sema: &Semantics<RootDatabase>, name: &ast::Name) -> Option<NameClass> { 120 pub fn classify(sema: &Semantics<RootDatabase>, name: &ast::Name) -> Option<NameClass> {
128 let _p = profile::span("classify_name"); 121 let _p = profile::span("classify_name");
129 122
@@ -186,6 +179,10 @@ impl NameClass {
186 179
187 Some(NameClass::Definition(Definition::Local(local))) 180 Some(NameClass::Definition(Definition::Local(local)))
188 }, 181 },
182 ast::SelfParam(it) => {
183 let def = sema.to_def(&it)?;
184 Some(NameClass::Definition(Definition::Local(def.into())))
185 },
189 ast::RecordField(it) => { 186 ast::RecordField(it) => {
190 let field: hir::Field = sema.to_def(&it)?; 187 let field: hir::Field = sema.to_def(&it)?;
191 Some(NameClass::Definition(Definition::Field(field))) 188 Some(NameClass::Definition(Definition::Field(field)))
diff --git a/crates/parser/src/grammar.rs b/crates/parser/src/grammar.rs
index bb9ffea8b..6913e9ec2 100644
--- a/crates/parser/src/grammar.rs
+++ b/crates/parser/src/grammar.rs
@@ -190,17 +190,25 @@ fn opt_visibility(p: &mut Parser) -> bool {
190 // test crate_visibility 190 // test crate_visibility
191 // pub(crate) struct S; 191 // pub(crate) struct S;
192 // pub(self) struct S; 192 // pub(self) struct S;
193 // pub(self) struct S; 193 // pub(super) struct S;
194 // pub(self) struct S;
195 194
196 // test pub_parens_typepath 195 // test pub_parens_typepath
197 // struct B(pub (super::A)); 196 // struct B(pub (super::A));
198 // struct B(pub (crate::A,)); 197 // struct B(pub (crate::A,));
199 T![crate] | T![self] | T![super] if p.nth(2) != T![:] => { 198 T![crate] | T![self] | T![super] if p.nth(2) != T![:] => {
200 p.bump_any(); 199 p.bump_any();
200 let path_m = p.start();
201 let path_segment_m = p.start();
202 let name_ref_m = p.start();
201 p.bump_any(); 203 p.bump_any();
204 name_ref_m.complete(p, NAME_REF);
205 path_segment_m.complete(p, PATH_SEGMENT);
206 path_m.complete(p, PATH);
202 p.expect(T![')']); 207 p.expect(T![')']);
203 } 208 }
209 // test crate_visibility_in
210 // pub(in super::A) struct S;
211 // pub(in crate) struct S;
204 T![in] => { 212 T![in] => {
205 p.bump_any(); 213 p.bump_any();
206 p.bump_any(); 214 p.bump_any();
diff --git a/crates/parser/src/grammar/items.rs b/crates/parser/src/grammar/items.rs
index 2070ce163..1d894e907 100644
--- a/crates/parser/src/grammar/items.rs
+++ b/crates/parser/src/grammar/items.rs
@@ -270,7 +270,9 @@ fn extern_crate(p: &mut Parser, m: Marker) {
270 p.bump(T![crate]); 270 p.bump(T![crate]);
271 271
272 if p.at(T![self]) { 272 if p.at(T![self]) {
273 let m = p.start();
273 p.bump(T![self]); 274 p.bump(T![self]);
275 m.complete(p, NAME_REF);
274 } else { 276 } else {
275 name_ref(p); 277 name_ref(p);
276 } 278 }
diff --git a/crates/parser/src/grammar/params.rs b/crates/parser/src/grammar/params.rs
index 2d006a1d5..6a98d7368 100644
--- a/crates/parser/src/grammar/params.rs
+++ b/crates/parser/src/grammar/params.rs
@@ -156,7 +156,7 @@ fn variadic_param(p: &mut Parser) -> bool {
156fn opt_self_param(p: &mut Parser, m: Marker) { 156fn opt_self_param(p: &mut Parser, m: Marker) {
157 if p.at(T![self]) || p.at(T![mut]) && p.nth(1) == T![self] { 157 if p.at(T![self]) || p.at(T![mut]) && p.nth(1) == T![self] {
158 p.eat(T![mut]); 158 p.eat(T![mut]);
159 p.eat(T![self]); 159 self_as_name(p);
160 // test arb_self_types 160 // test arb_self_types
161 // impl S { 161 // impl S {
162 // fn a(self: &Self) {} 162 // fn a(self: &Self) {}
@@ -169,24 +169,29 @@ fn opt_self_param(p: &mut Parser, m: Marker) {
169 let la1 = p.nth(1); 169 let la1 = p.nth(1);
170 let la2 = p.nth(2); 170 let la2 = p.nth(2);
171 let la3 = p.nth(3); 171 let la3 = p.nth(3);
172 let mut n_toks = match (p.current(), la1, la2, la3) { 172 if !matches!((p.current(), la1, la2, la3),
173 (T![&], T![self], _, _) => 2, 173 (T![&], T![self], _, _)
174 (T![&], T![mut], T![self], _) => 3, 174 | (T![&], T![mut], T![self], _)
175 (T![&], LIFETIME_IDENT, T![self], _) => 3, 175 | (T![&], LIFETIME_IDENT, T![self], _)
176 (T![&], LIFETIME_IDENT, T![mut], T![self]) => 4, 176 | (T![&], LIFETIME_IDENT, T![mut], T![self])
177 _ => return m.abandon(p), 177 ) {
178 }; 178 return m.abandon(p);
179 p.bump_any(); 179 }
180 p.bump(T![&]);
180 if p.at(LIFETIME_IDENT) { 181 if p.at(LIFETIME_IDENT) {
181 lifetime(p); 182 lifetime(p);
182 n_toks -= 1;
183 }
184 for _ in 1..n_toks {
185 p.bump_any();
186 } 183 }
184 p.eat(T![mut]);
185 self_as_name(p);
187 } 186 }
188 m.complete(p, SELF_PARAM); 187 m.complete(p, SELF_PARAM);
189 if !p.at(T![')']) { 188 if !p.at(T![')']) {
190 p.expect(T![,]); 189 p.expect(T![,]);
191 } 190 }
192} 191}
192
193fn self_as_name(p: &mut Parser) {
194 let m = p.start();
195 p.bump(T![self]);
196 m.complete(p, NAME);
197}
diff --git a/crates/syntax/src/ast/generated/nodes.rs b/crates/syntax/src/ast/generated/nodes.rs
index 1d722db3c..6407d7c85 100644
--- a/crates/syntax/src/ast/generated/nodes.rs
+++ b/crates/syntax/src/ast/generated/nodes.rs
@@ -11,6 +11,7 @@ pub struct Name {
11} 11}
12impl Name { 12impl Name {
13 pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) } 13 pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) }
14 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
14} 15}
15#[derive(Debug, Clone, PartialEq, Eq, Hash)] 16#[derive(Debug, Clone, PartialEq, Eq, Hash)]
16pub struct NameRef { 17pub struct NameRef {
@@ -238,7 +239,6 @@ impl ExternCrate {
238 pub fn extern_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![extern]) } 239 pub fn extern_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![extern]) }
239 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) } 240 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
240 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } 241 pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
241 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
242 pub fn rename(&self) -> Option<Rename> { support::child(&self.syntax) } 242 pub fn rename(&self) -> Option<Rename> { support::child(&self.syntax) }
243 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 243 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
244} 244}
@@ -406,9 +406,6 @@ pub struct Visibility {
406impl Visibility { 406impl Visibility {
407 pub fn pub_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![pub]) } 407 pub fn pub_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![pub]) }
408 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) } 408 pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
409 pub fn super_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![super]) }
410 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
411 pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
412 pub fn in_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![in]) } 409 pub fn in_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![in]) }
413 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } 410 pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
414 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) } 411 pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
@@ -492,11 +489,11 @@ pub struct SelfParam {
492 pub(crate) syntax: SyntaxNode, 489 pub(crate) syntax: SyntaxNode,
493} 490}
494impl ast::AttrsOwner for SelfParam {} 491impl ast::AttrsOwner for SelfParam {}
492impl ast::NameOwner for SelfParam {}
495impl SelfParam { 493impl SelfParam {
496 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) } 494 pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
497 pub fn lifetime(&self) -> Option<Lifetime> { support::child(&self.syntax) } 495 pub fn lifetime(&self) -> Option<Lifetime> { support::child(&self.syntax) }
498 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) } 496 pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
499 pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
500 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) } 497 pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
501 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) } 498 pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
502} 499}
diff --git a/crates/syntax/src/ast/node_ext.rs b/crates/syntax/src/ast/node_ext.rs
index b8ce71d27..738c92a5b 100644
--- a/crates/syntax/src/ast/node_ext.rs
+++ b/crates/syntax/src/ast/node_ext.rs
@@ -198,6 +198,13 @@ impl ast::Path {
198 pub fn parent_path(&self) -> Option<ast::Path> { 198 pub fn parent_path(&self) -> Option<ast::Path> {
199 self.syntax().parent().and_then(ast::Path::cast) 199 self.syntax().parent().and_then(ast::Path::cast)
200 } 200 }
201
202 pub fn as_single_segment(&self) -> Option<ast::PathSegment> {
203 match self.qualifier() {
204 Some(_) => None,
205 None => self.segment(),
206 }
207 }
201} 208}
202 209
203impl ast::UseTreeList { 210impl ast::UseTreeList {
@@ -448,16 +455,22 @@ pub enum VisibilityKind {
448 455
449impl ast::Visibility { 456impl ast::Visibility {
450 pub fn kind(&self) -> VisibilityKind { 457 pub fn kind(&self) -> VisibilityKind {
451 if let Some(path) = support::children(self.syntax()).next() { 458 match self.path() {
452 VisibilityKind::In(path) 459 Some(path) => {
453 } else if self.crate_token().is_some() { 460 if let Some(segment) =
454 VisibilityKind::PubCrate 461 path.as_single_segment().filter(|it| it.coloncolon_token().is_none())
455 } else if self.super_token().is_some() { 462 {
456 VisibilityKind::PubSuper 463 if segment.crate_token().is_some() {
457 } else if self.self_token().is_some() { 464 return VisibilityKind::PubCrate;
458 VisibilityKind::PubSelf 465 } else if segment.super_token().is_some() {
459 } else { 466 return VisibilityKind::PubSuper;
460 VisibilityKind::Pub 467 } else if segment.self_token().is_some() {
468 return VisibilityKind::PubSelf;
469 }
470 }
471 VisibilityKind::In(path)
472 }
473 None => VisibilityKind::Pub,
461 } 474 }
462 } 475 }
463} 476}
diff --git a/crates/syntax/test_data/parser/err/0037_visibility_in_traits.rast b/crates/syntax/test_data/parser/err/0037_visibility_in_traits.rast
index faf87d6e5..ae4dd2f3b 100644
--- a/crates/syntax/test_data/parser/err/0037_visibility_in_traits.rast
+++ b/crates/syntax/test_data/parser/err/0037_visibility_in_traits.rast
@@ -50,7 +50,10 @@ [email protected]
50 [email protected] 50 [email protected]
51 [email protected] "pub" 51 [email protected] "pub"
52 [email protected] "(" 52 [email protected] "("
53 [email protected] "crate" 53 [email protected]
54 [email protected]
55 [email protected]
56 [email protected] "crate"
54 [email protected] ")" 57 [email protected] ")"
55 [email protected] " " 58 [email protected] " "
56 [email protected] "type" 59 [email protected] "type"
@@ -69,7 +72,10 @@ [email protected]
69 [email protected] 72 [email protected]
70 [email protected] "pub" 73 [email protected] "pub"
71 [email protected] "(" 74 [email protected] "("
72 [email protected] "crate" 75 [email protected]
76 [email protected]
77 [email protected]
78 [email protected] "crate"
73 [email protected] ")" 79 [email protected] ")"
74 [email protected] " " 80 [email protected] " "
75 [email protected] "const" 81 [email protected] "const"
diff --git a/crates/syntax/test_data/parser/inline/ok/0006_self_param.rast b/crates/syntax/test_data/parser/inline/ok/0006_self_param.rast
index 8048f5fad..f0d152d33 100644
--- a/crates/syntax/test_data/parser/inline/ok/0006_self_param.rast
+++ b/crates/syntax/test_data/parser/inline/ok/0006_self_param.rast
@@ -19,7 +19,8 @@ [email protected]
19 [email protected] 19 [email protected]
20 [email protected] "(" 20 [email protected] "("
21 [email protected] 21 [email protected]
22 [email protected] "self" 22 [email protected]
23 [email protected] "self"
23 [email protected] ")" 24 [email protected] ")"
24 [email protected] " " 25 [email protected] " "
25 [email protected] 26 [email protected]
@@ -35,7 +36,8 @@ [email protected]
35 [email protected] "(" 36 [email protected] "("
36 [email protected] 37 [email protected]
37 [email protected] "&" 38 [email protected] "&"
38 [email protected] "self" 39 [email protected]
40 [email protected] "self"
39 [email protected] "," 41 [email protected] ","
40 [email protected] ")" 42 [email protected] ")"
41 [email protected] " " 43 [email protected] " "
@@ -55,7 +57,8 @@ [email protected]
55 [email protected] 57 [email protected]
56 [email protected] "\'a" 58 [email protected] "\'a"
57 [email protected] " " 59 [email protected] " "
58 [email protected] "self" 60 [email protected]
61 [email protected] "self"
59 [email protected] "," 62 [email protected] ","
60 [email protected] ")" 63 [email protected] ")"
61 [email protected] " " 64 [email protected] " "
@@ -77,7 +80,8 @@ [email protected]
77 [email protected] " " 80 [email protected] " "
78 [email protected] "mut" 81 [email protected] "mut"
79 [email protected] " " 82 [email protected] " "
80 [email protected] "self" 83 [email protected]
84 [email protected] "self"
81 [email protected] "," 85 [email protected] ","
82 [email protected] " " 86 [email protected] " "
83 [email protected] 87 [email protected]
@@ -107,7 +111,8 @@ [email protected]
107 [email protected] 111 [email protected]
108 [email protected] "mut" 112 [email protected] "mut"
109 [email protected] " " 113 [email protected] " "
110 [email protected] "self" 114 [email protected]
115 [email protected] "self"
111 [email protected] ")" 116 [email protected] ")"
112 [email protected] " " 117 [email protected] " "
113 [email protected] 118 [email protected]
diff --git a/crates/syntax/test_data/parser/inline/ok/0018_arb_self_types.rast b/crates/syntax/test_data/parser/inline/ok/0018_arb_self_types.rast
index ddbd66588..df59f37a2 100644
--- a/crates/syntax/test_data/parser/inline/ok/0018_arb_self_types.rast
+++ b/crates/syntax/test_data/parser/inline/ok/0018_arb_self_types.rast
@@ -19,7 +19,8 @@ [email protected]
19 [email protected] 19 [email protected]
20 [email protected] "(" 20 [email protected] "("
21 [email protected] 21 [email protected]
22 [email protected] "self" 22 [email protected]
23 [email protected] "self"
23 [email protected] ":" 24 [email protected] ":"
24 [email protected] " " 25 [email protected] " "
25 [email protected] 26 [email protected]
@@ -45,7 +46,8 @@ [email protected]
45 [email protected] 46 [email protected]
46 [email protected] "mut" 47 [email protected] "mut"
47 [email protected] " " 48 [email protected] " "
48 [email protected] "self" 49 [email protected]
50 [email protected] "self"
49 [email protected] ":" 51 [email protected] ":"
50 [email protected] " " 52 [email protected] " "
51 [email protected] 53 [email protected]
diff --git a/crates/syntax/test_data/parser/inline/ok/0021_impl_item_list.rast b/crates/syntax/test_data/parser/inline/ok/0021_impl_item_list.rast
index ca0702aba..dc7f6295b 100644
--- a/crates/syntax/test_data/parser/inline/ok/0021_impl_item_list.rast
+++ b/crates/syntax/test_data/parser/inline/ok/0021_impl_item_list.rast
@@ -67,7 +67,8 @@ [email protected]
67 [email protected] "(" 67 [email protected] "("
68 [email protected] 68 [email protected]
69 [email protected] "&" 69 [email protected] "&"
70 [email protected] "self" 70 [email protected]
71 [email protected] "self"
71 [email protected] ")" 72 [email protected] ")"
72 [email protected] " " 73 [email protected] " "
73 [email protected] 74 [email protected]
diff --git a/crates/syntax/test_data/parser/inline/ok/0022_crate_visibility.rast b/crates/syntax/test_data/parser/inline/ok/0022_crate_visibility.rast
index 50742cbcf..f2ead8a62 100644
--- a/crates/syntax/test_data/parser/inline/ok/0022_crate_visibility.rast
+++ b/crates/syntax/test_data/parser/inline/ok/0022_crate_visibility.rast
@@ -1,9 +1,12 @@
1SOURCE_FILE@0..81 1SOURCE_FILE@0..62
2 [email protected] 2 [email protected]
3 [email protected] 3 [email protected]
4 [email protected] "pub" 4 [email protected] "pub"
5 [email protected] "(" 5 [email protected] "("
6 [email protected] "crate" 6 [email protected]
7 [email protected]
8 [email protected]
9 [email protected] "crate"
7 [email protected] ")" 10 [email protected] ")"
8 [email protected] " " 11 [email protected] " "
9 [email protected] "struct" 12 [email protected] "struct"
@@ -16,7 +19,10 @@ [email protected]
16 [email protected] 19 [email protected]
17 [email protected] "pub" 20 [email protected] "pub"
18 [email protected] "(" 21 [email protected] "("
19 [email protected] "self" 22 [email protected]
23 [email protected]
24 [email protected]
25 [email protected] "self"
20 [email protected] ")" 26 [email protected] ")"
21 [email protected] " " 27 [email protected] " "
22 [email protected] "struct" 28 [email protected] "struct"
@@ -25,29 +31,19 @@ [email protected]
25 [email protected] "S" 31 [email protected] "S"
26 [email protected] ";" 32 [email protected] ";"
27 [email protected] "\n" 33 [email protected] "\n"
28 [email protected]0 34 [email protected]1
29 [email protected]0 35 [email protected]1
30 [email protected] "pub" 36 [email protected] "pub"
31 [email protected] "(" 37 [email protected] "("
32 [email protected] "self" 38 [email protected]
33 [email protected] ")" 39 [email protected]
34 [email protected] " " 40 [email protected]
35 [email protected] "struct" 41 [email protected] "super"
36 [email protected] " " 42 [email protected] ")"
37 [email protected] 43 [email protected] " "
38 [email protected] "S" 44 [email protected] "struct"
39 [email protected] ";" 45 [email protected] " "
40 [email protected] "\n" 46 [email protected]
41 [email protected] 47 [email protected] "S"
42 [email protected] 48 [email protected] ";"
43 [email protected] "pub" 49 [email protected] "\n"
44 [email protected] "("
45 [email protected] "self"
46 [email protected] ")"
47 [email protected] " "
48 [email protected] "struct"
49 [email protected] " "
50 [email protected]
51 [email protected] "S"
52 [email protected] ";"
53 [email protected] "\n"
diff --git a/crates/syntax/test_data/parser/inline/ok/0022_crate_visibility.rs b/crates/syntax/test_data/parser/inline/ok/0022_crate_visibility.rs
index faeefde94..a790a485f 100644
--- a/crates/syntax/test_data/parser/inline/ok/0022_crate_visibility.rs
+++ b/crates/syntax/test_data/parser/inline/ok/0022_crate_visibility.rs
@@ -1,4 +1,3 @@
1pub(crate) struct S; 1pub(crate) struct S;
2pub(self) struct S; 2pub(self) struct S;
3pub(self) struct S; 3pub(super) struct S;
4pub(self) struct S;
diff --git a/crates/syntax/test_data/parser/inline/ok/0138_self_param_outer_attr.rast b/crates/syntax/test_data/parser/inline/ok/0138_self_param_outer_attr.rast
index d3219f0b2..c54e64e3f 100644
--- a/crates/syntax/test_data/parser/inline/ok/0138_self_param_outer_attr.rast
+++ b/crates/syntax/test_data/parser/inline/ok/0138_self_param_outer_attr.rast
@@ -16,7 +16,8 @@ [email protected]
16 [email protected] "must_use" 16 [email protected] "must_use"
17 [email protected] "]" 17 [email protected] "]"
18 [email protected] " " 18 [email protected] " "
19 [email protected] "self" 19 [email protected]
20 [email protected] "self"
20 [email protected] ")" 21 [email protected] ")"
21 [email protected] " " 22 [email protected] " "
22 [email protected] 23 [email protected]
diff --git a/crates/syntax/test_data/parser/inline/ok/0160_crate_visibility_in.rast b/crates/syntax/test_data/parser/inline/ok/0160_crate_visibility_in.rast
new file mode 100644
index 000000000..3d855fc6b
--- /dev/null
+++ b/crates/syntax/test_data/parser/inline/ok/0160_crate_visibility_in.rast
@@ -0,0 +1,42 @@
1[email protected]
2 [email protected]
3 [email protected]
4 [email protected] "pub"
5 [email protected] "("
6 [email protected] "in"
7 [email protected] " "
8 [email protected]
9 [email protected]
10 [email protected]
11 [email protected]
12 [email protected] "super"
13 [email protected] "::"
14 [email protected]
15 [email protected]
16 [email protected] "A"
17 [email protected] ")"
18 [email protected] " "
19 [email protected] "struct"
20 [email protected] " "
21 [email protected]
22 [email protected] "S"
23 [email protected] ";"
24 [email protected] "\n"
25 [email protected]
26 [email protected]
27 [email protected] "pub"
28 [email protected] "("
29 [email protected] "in"
30 [email protected] " "
31 [email protected]
32 [email protected]
33 [email protected]
34 [email protected] "crate"
35 [email protected] ")"
36 [email protected] " "
37 [email protected] "struct"
38 [email protected] " "
39 [email protected]
40 [email protected] "S"
41 [email protected] ";"
42 [email protected] "\n"
diff --git a/crates/syntax/test_data/parser/inline/ok/0160_crate_visibility_in.rs b/crates/syntax/test_data/parser/inline/ok/0160_crate_visibility_in.rs
new file mode 100644
index 000000000..2856dbd84
--- /dev/null
+++ b/crates/syntax/test_data/parser/inline/ok/0160_crate_visibility_in.rs
@@ -0,0 +1,2 @@
1pub(in super::A) struct S;
2pub(in crate) struct S;
diff --git a/crates/syntax/test_data/parser/ok/0007_extern_crate.rast b/crates/syntax/test_data/parser/ok/0007_extern_crate.rast
index 594c2f8f2..4babdba92 100644
--- a/crates/syntax/test_data/parser/ok/0007_extern_crate.rast
+++ b/crates/syntax/test_data/parser/ok/0007_extern_crate.rast
@@ -28,7 +28,8 @@ [email protected]
28 [email protected] " " 28 [email protected] " "
29 [email protected] "crate" 29 [email protected] "crate"
30 [email protected] " " 30 [email protected] " "
31 [email protected] "self" 31 [email protected]
32 [email protected] "self"
32 [email protected] " " 33 [email protected] " "
33 [email protected] 34 [email protected]
34 [email protected] "as" 35 [email protected] "as"
diff --git a/crates/syntax/test_data/parser/ok/0012_visibility.rast b/crates/syntax/test_data/parser/ok/0012_visibility.rast
index 83a93b5a9..c5dbfb702 100644
--- a/crates/syntax/test_data/parser/ok/0012_visibility.rast
+++ b/crates/syntax/test_data/parser/ok/0012_visibility.rast
@@ -32,7 +32,10 @@ [email protected]
32 [email protected] 32 [email protected]
33 [email protected] "pub" 33 [email protected] "pub"
34 [email protected] "(" 34 [email protected] "("
35 [email protected] "crate" 35 [email protected]
36 [email protected]
37 [email protected]
38 [email protected] "crate"
36 [email protected] ")" 39 [email protected] ")"
37 [email protected] " " 40 [email protected] " "
38 [email protected] "fn" 41 [email protected] "fn"
@@ -51,7 +54,10 @@ [email protected]
51 [email protected] 54 [email protected]
52 [email protected] "pub" 55 [email protected] "pub"
53 [email protected] "(" 56 [email protected] "("
54 [email protected] "super" 57 [email protected]
58 [email protected]
59 [email protected]
60 [email protected] "super"
55 [email protected] ")" 61 [email protected] ")"
56 [email protected] " " 62 [email protected] " "
57 [email protected] "fn" 63 [email protected] "fn"
diff --git a/crates/syntax/test_data/parser/ok/0045_block_inner_attrs.rast b/crates/syntax/test_data/parser/ok/0045_block_inner_attrs.rast
index 0ac56df6d..6afed5f05 100644
--- a/crates/syntax/test_data/parser/ok/0045_block_inner_attrs.rast
+++ b/crates/syntax/test_data/parser/ok/0045_block_inner_attrs.rast
@@ -110,7 +110,8 @@ [email protected]
110 [email protected] "(" 110 [email protected] "("
111 [email protected] 111 [email protected]
112 [email protected] "&" 112 [email protected] "&"
113 [email protected] "self" 113 [email protected]
114 [email protected] "self"
114 [email protected] "," 115 [email protected] ","
115 [email protected] " " 116 [email protected] " "
116 [email protected] 117 [email protected]
diff --git a/crates/syntax/test_data/parser/ok/0051_parameter_attrs.rast b/crates/syntax/test_data/parser/ok/0051_parameter_attrs.rast
index 3fed11838..e10521d85 100644
--- a/crates/syntax/test_data/parser/ok/0051_parameter_attrs.rast
+++ b/crates/syntax/test_data/parser/ok/0051_parameter_attrs.rast
@@ -281,7 +281,8 @@ [email protected]
281 [email protected] "must_use" 281 [email protected] "must_use"
282 [email protected] "]" 282 [email protected] "]"
283 [email protected] " " 283 [email protected] " "
284 [email protected] "self" 284 [email protected]
285 [email protected] "self"
285 [email protected] ")" 286 [email protected] ")"
286 [email protected] " " 287 [email protected] " "
287 [email protected] 288 [email protected]
@@ -305,7 +306,8 @@ [email protected]
305 [email protected] "attr" 306 [email protected] "attr"
306 [email protected] "]" 307 [email protected] "]"
307 [email protected] " " 308 [email protected] " "
308 [email protected] "self" 309 [email protected]
310 [email protected] "self"
309 [email protected] ")" 311 [email protected] ")"
310 [email protected] " " 312 [email protected] " "
311 [email protected] 313 [email protected]
@@ -330,7 +332,8 @@ [email protected]
330 [email protected] "]" 332 [email protected] "]"
331 [email protected] " " 333 [email protected] " "
332 [email protected] "&" 334 [email protected] "&"
333 [email protected] "self" 335 [email protected]
336 [email protected] "self"
334 [email protected] ")" 337 [email protected] ")"
335 [email protected] " " 338 [email protected] " "
336 [email protected] 339 [email protected]
@@ -363,7 +366,8 @@ [email protected]
363 [email protected] "&" 366 [email protected] "&"
364 [email protected] "mut" 367 [email protected] "mut"
365 [email protected] " " 368 [email protected] " "
366 [email protected] "self" 369 [email protected]
370 [email protected] "self"
367 [email protected] ")" 371 [email protected] ")"
368 [email protected] " " 372 [email protected] " "
369 [email protected] 373 [email protected]
@@ -397,7 +401,8 @@ [email protected]
397 [email protected] 401 [email protected]
398 [email protected] "\'a" 402 [email protected] "\'a"
399 [email protected] " " 403 [email protected] " "
400 [email protected] "self" 404 [email protected]
405 [email protected] "self"
401 [email protected] ")" 406 [email protected] ")"
402 [email protected] " " 407 [email protected] " "
403 [email protected] 408 [email protected]
@@ -433,7 +438,8 @@ [email protected]
433 [email protected] " " 438 [email protected] " "
434 [email protected] "mut" 439 [email protected] "mut"
435 [email protected] " " 440 [email protected] " "
436 [email protected] "self" 441 [email protected]
442 [email protected] "self"
437 [email protected] ")" 443 [email protected] ")"
438 [email protected] " " 444 [email protected] " "
439 [email protected] 445 [email protected]
@@ -457,7 +463,8 @@ [email protected]
457 [email protected] "attr" 463 [email protected] "attr"
458 [email protected] "]" 464 [email protected] "]"
459 [email protected] " " 465 [email protected] " "
460 [email protected] "self" 466 [email protected]
467 [email protected] "self"
461 [email protected] ":" 468 [email protected] ":"
462 [email protected] " " 469 [email protected] " "
463 [email protected] 470 [email protected]
@@ -488,7 +495,8 @@ [email protected]
488 [email protected] "attr" 495 [email protected] "attr"
489 [email protected] "]" 496 [email protected] "]"
490 [email protected] " " 497 [email protected] " "
491 [email protected] "self" 498 [email protected]
499 [email protected] "self"
492 [email protected] ":" 500 [email protected] ":"
493 [email protected] " " 501 [email protected] " "
494 [email protected] 502 [email protected]
diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml
index 1bb9222d7..4abc7b053 100644
--- a/xtask/Cargo.toml
+++ b/xtask/Cargo.toml
@@ -15,7 +15,7 @@ flate2 = "1.0"
15pico-args = "0.3.1" 15pico-args = "0.3.1"
16proc-macro2 = "1.0.8" 16proc-macro2 = "1.0.8"
17quote = "1.0.2" 17quote = "1.0.2"
18ungrammar = "1.8" 18ungrammar = "1.9"
19walkdir = "2.3.1" 19walkdir = "2.3.1"
20write-json = "0.1.0" 20write-json = "0.1.0"
21xshell = "0.1" 21xshell = "0.1"