mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
Wrap remaining self/super/crate in Name{Ref}
This commit is contained in:
parent
8a869e870a
commit
98718e0544
28 changed files with 237 additions and 169 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -1837,9 +1837,9 @@ checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ungrammar"
|
name = "ungrammar"
|
||||||
version = "1.8.0"
|
version = "1.9.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e33a2183403af89252547c4219a06a6cc8aef6302fee67e10e8431866af3ee72"
|
checksum = "b137a875a3b942539dd04bd37d193649f5d67e11407186f5b9d63ae0332b1a93"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicase"
|
name = "unicase"
|
||||||
|
|
|
@ -61,7 +61,7 @@ fn generate_fn_def_assist(
|
||||||
// compute the location which implicitly has the same lifetime as the anonymous lifetime
|
// compute the location which implicitly has the same lifetime as the anonymous lifetime
|
||||||
let loc_needing_lifetime = if let Some(self_param) = self_param {
|
let loc_needing_lifetime = if let Some(self_param) = self_param {
|
||||||
// if we have a self reference, use that
|
// if we have a self reference, use that
|
||||||
Some(self_param.self_token()?.text_range().start())
|
Some(self_param.name()?.syntax().text_range().start())
|
||||||
} else {
|
} else {
|
||||||
// otherwise, if there's a single reference parameter without a named liftime, use that
|
// otherwise, if there's a single reference parameter without a named liftime, use that
|
||||||
let fn_params_without_lifetime: Vec<_> = param_list
|
let fn_params_without_lifetime: Vec<_> = param_list
|
||||||
|
|
|
@ -26,7 +26,7 @@ use once_cell::race::OnceBool;
|
||||||
use stdx::format_to;
|
use stdx::format_to;
|
||||||
use syntax::{
|
use syntax::{
|
||||||
algo,
|
algo,
|
||||||
ast::{self, AstNode},
|
ast::{self, AstNode, NameOwner},
|
||||||
SyntaxNode,
|
SyntaxNode,
|
||||||
};
|
};
|
||||||
use tracing_subscriber::{layer::SubscriberExt, EnvFilter, Registry};
|
use tracing_subscriber::{layer::SubscriberExt, EnvFilter, Registry};
|
||||||
|
@ -153,7 +153,7 @@ fn infer_with_mismatches(content: &str, include_mismatches: bool) -> String {
|
||||||
});
|
});
|
||||||
for (node, ty) in &types {
|
for (node, ty) in &types {
|
||||||
let (range, text) = if let Some(self_param) = ast::SelfParam::cast(node.value.clone()) {
|
let (range, text) = if let Some(self_param) = ast::SelfParam::cast(node.value.clone()) {
|
||||||
(self_param.self_token().unwrap().text_range(), "self".to_string())
|
(self_param.name().unwrap().syntax().text_range(), "self".to_string())
|
||||||
} else {
|
} else {
|
||||||
(node.value.text_range(), node.value.text().to_string().replace("\n", " "))
|
(node.value.text_range(), node.value.text().to_string().replace("\n", " "))
|
||||||
};
|
};
|
||||||
|
|
|
@ -400,15 +400,13 @@ impl TryToNav for hir::GenericParam {
|
||||||
impl ToNav for hir::Local {
|
impl ToNav for hir::Local {
|
||||||
fn to_nav(&self, db: &RootDatabase) -> NavigationTarget {
|
fn to_nav(&self, db: &RootDatabase) -> NavigationTarget {
|
||||||
let src = self.source(db);
|
let src = self.source(db);
|
||||||
let (node, focus_range) = match &src.value {
|
let (node, name) = match &src.value {
|
||||||
Either::Left(bind_pat) => (
|
Either::Left(bind_pat) => (bind_pat.syntax().clone(), bind_pat.name()),
|
||||||
bind_pat.syntax().clone(),
|
Either::Right(it) => (it.syntax().clone(), it.name()),
|
||||||
bind_pat
|
|
||||||
.name()
|
|
||||||
.map(|it| src.with_value(&it.syntax().clone()).original_file_range(db).range),
|
|
||||||
),
|
|
||||||
Either::Right(it) => (it.syntax().clone(), it.self_token().map(|it| it.text_range())),
|
|
||||||
};
|
};
|
||||||
|
let focus_range =
|
||||||
|
name.map(|it| src.with_value(&it.syntax().clone()).original_file_range(db).range);
|
||||||
|
|
||||||
let full_range = src.with_value(&node).original_file_range(db);
|
let full_range = src.with_value(&node).original_file_range(db);
|
||||||
let name = match self.name(db) {
|
let name = match self.name(db) {
|
||||||
Some(it) => it.to_string().into(),
|
Some(it) => it.to_string().into(),
|
||||||
|
|
|
@ -55,11 +55,6 @@ pub(crate) fn goto_definition(
|
||||||
} else {
|
} else {
|
||||||
reference_definition(&sema, Either::Left(<)).to_vec()
|
reference_definition(&sema, Either::Left(<)).to_vec()
|
||||||
},
|
},
|
||||||
ast::SelfParam(self_param) => {
|
|
||||||
let def = NameClass::classify_self_param(&sema, &self_param)?.referenced_or_defined(sema.db);
|
|
||||||
let nav = def.try_to_nav(sema.db)?;
|
|
||||||
vec![nav]
|
|
||||||
},
|
|
||||||
_ => return None,
|
_ => return None,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -98,7 +98,6 @@ pub(crate) fn hover(
|
||||||
ast::NameRef(name_ref) => NameRefClass::classify(&sema, &name_ref).map(|d| d.referenced(sema.db)),
|
ast::NameRef(name_ref) => NameRefClass::classify(&sema, &name_ref).map(|d| d.referenced(sema.db)),
|
||||||
ast::Lifetime(lifetime) => NameClass::classify_lifetime(&sema, &lifetime)
|
ast::Lifetime(lifetime) => NameClass::classify_lifetime(&sema, &lifetime)
|
||||||
.map_or_else(|| NameRefClass::classify_lifetime(&sema, &lifetime).map(|d| d.referenced(sema.db)), |d| d.defined(sema.db)),
|
.map_or_else(|| NameRefClass::classify_lifetime(&sema, &lifetime).map(|d| d.referenced(sema.db)), |d| d.defined(sema.db)),
|
||||||
ast::SelfParam(self_param) => NameClass::classify_self_param(&sema, &self_param).and_then(|d| d.defined(sema.db)),
|
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -3223,7 +3222,7 @@ impl Foo {
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
*&self*
|
*self*
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
&Foo
|
&Foo
|
||||||
|
@ -3243,7 +3242,7 @@ impl Foo {
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
*self: Arc<Foo>*
|
*self*
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
Arc<Foo>
|
Arc<Foo>
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
//! FIXME: write short doc here
|
//! FIXME: write short doc here
|
||||||
use std::{
|
use std::fmt::{self, Display};
|
||||||
convert::TryInto,
|
|
||||||
fmt::{self, Display},
|
|
||||||
};
|
|
||||||
|
|
||||||
use hir::{Module, ModuleDef, ModuleSource, Semantics};
|
use hir::{Module, ModuleDef, ModuleSource, Semantics};
|
||||||
use ide_db::{
|
use ide_db::{
|
||||||
base_db::{AnchoredPathBuf, FileId, FileRange, SourceDatabaseExt},
|
base_db::{AnchoredPathBuf, FileId, FileRange},
|
||||||
defs::{Definition, NameClass, NameRefClass},
|
defs::{Definition, NameClass, NameRefClass},
|
||||||
search::FileReference,
|
search::FileReference,
|
||||||
RootDatabase,
|
RootDatabase,
|
||||||
|
@ -14,14 +11,14 @@ use ide_db::{
|
||||||
use syntax::{
|
use syntax::{
|
||||||
algo::find_node_at_offset,
|
algo::find_node_at_offset,
|
||||||
ast::{self, NameOwner},
|
ast::{self, NameOwner},
|
||||||
lex_single_syntax_kind, match_ast, AstNode, SyntaxKind, SyntaxNode, SyntaxToken, T,
|
lex_single_syntax_kind, match_ast, AstNode, SyntaxKind, SyntaxNode, T,
|
||||||
};
|
};
|
||||||
use test_utils::mark;
|
use test_utils::mark;
|
||||||
use text_edit::TextEdit;
|
use text_edit::TextEdit;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
FilePosition, FileSystemEdit, RangeInfo, ReferenceKind, ReferenceSearchResult, SourceChange,
|
FilePosition, FileSystemEdit, RangeInfo, ReferenceKind, ReferenceSearchResult, SourceChange,
|
||||||
TextRange, TextSize,
|
TextRange,
|
||||||
};
|
};
|
||||||
|
|
||||||
type RenameResult<T> = Result<T, RenameError>;
|
type RenameResult<T> = Result<T, RenameError>;
|
||||||
|
@ -52,10 +49,6 @@ pub(crate) fn prepare_rename(
|
||||||
let syntax = source_file.syntax();
|
let syntax = source_file.syntax();
|
||||||
if let Some(module) = find_module_at_offset(&sema, position, syntax) {
|
if let Some(module) = find_module_at_offset(&sema, position, syntax) {
|
||||||
rename_mod(&sema, position, module, "dummy")
|
rename_mod(&sema, position, module, "dummy")
|
||||||
} else if let Some(self_token) =
|
|
||||||
syntax.token_at_offset(position.offset).find(|t| t.kind() == T![self])
|
|
||||||
{
|
|
||||||
rename_self_to_param(&sema, position, self_token, "dummy")
|
|
||||||
} else {
|
} else {
|
||||||
let RangeInfo { range, .. } = find_all_refs(&sema, position)?;
|
let RangeInfo { range, .. } = find_all_refs(&sema, position)?;
|
||||||
Ok(RangeInfo::new(range, SourceChange::default()))
|
Ok(RangeInfo::new(range, SourceChange::default()))
|
||||||
|
@ -82,10 +75,6 @@ pub(crate) fn rename_with_semantics(
|
||||||
|
|
||||||
if let Some(module) = find_module_at_offset(&sema, position, syntax) {
|
if let Some(module) = find_module_at_offset(&sema, position, syntax) {
|
||||||
rename_mod(&sema, position, module, new_name)
|
rename_mod(&sema, position, module, new_name)
|
||||||
} else if let Some(self_token) =
|
|
||||||
syntax.token_at_offset(position.offset).find(|t| t.kind() == T![self])
|
|
||||||
{
|
|
||||||
rename_self_to_param(&sema, position, self_token, new_name)
|
|
||||||
} else {
|
} else {
|
||||||
rename_reference(&sema, position, new_name)
|
rename_reference(&sema, position, new_name)
|
||||||
}
|
}
|
||||||
|
@ -108,7 +97,7 @@ pub(crate) fn will_rename_file(
|
||||||
Some(change)
|
Some(change)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||||
enum IdentifierKind {
|
enum IdentifierKind {
|
||||||
Ident,
|
Ident,
|
||||||
Lifetime,
|
Lifetime,
|
||||||
|
@ -375,53 +364,50 @@ fn text_edit_from_self_param(
|
||||||
fn rename_self_to_param(
|
fn rename_self_to_param(
|
||||||
sema: &Semantics<RootDatabase>,
|
sema: &Semantics<RootDatabase>,
|
||||||
position: FilePosition,
|
position: FilePosition,
|
||||||
self_token: SyntaxToken,
|
|
||||||
new_name: &str,
|
new_name: &str,
|
||||||
|
ident_kind: IdentifierKind,
|
||||||
|
range: TextRange,
|
||||||
|
refs: ReferenceSearchResult,
|
||||||
) -> Result<RangeInfo<SourceChange>, RenameError> {
|
) -> Result<RangeInfo<SourceChange>, RenameError> {
|
||||||
let ident_kind = check_identifier(new_name)?;
|
|
||||||
match ident_kind {
|
match ident_kind {
|
||||||
IdentifierKind::Lifetime => bail!("Invalid name `{}`: not an identifier", new_name),
|
IdentifierKind::Lifetime => bail!("Invalid name `{}`: not an identifier", new_name),
|
||||||
IdentifierKind::ToSelf => {
|
IdentifierKind::ToSelf => {
|
||||||
// no-op
|
// no-op
|
||||||
mark::hit!(rename_self_to_self);
|
mark::hit!(rename_self_to_self);
|
||||||
return Ok(RangeInfo::new(self_token.text_range(), SourceChange::default()));
|
return Ok(RangeInfo::new(range, SourceChange::default()));
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
let source_file = sema.parse(position.file_id);
|
let source_file = sema.parse(position.file_id);
|
||||||
let syn = source_file.syntax();
|
let syn = source_file.syntax();
|
||||||
|
|
||||||
let text = sema.db.file_text(position.file_id);
|
|
||||||
let fn_def = find_node_at_offset::<ast::Fn>(syn, position.offset)
|
let fn_def = find_node_at_offset::<ast::Fn>(syn, position.offset)
|
||||||
.ok_or_else(|| format_err!("No surrounding method declaration found"))?;
|
.ok_or_else(|| format_err!("No surrounding method declaration found"))?;
|
||||||
let search_range = fn_def.syntax().text_range();
|
|
||||||
|
|
||||||
let mut source_change = SourceChange::default();
|
let mut source_change = SourceChange::default();
|
||||||
|
if let Some(self_param) = fn_def.param_list().and_then(|it| it.self_param()) {
|
||||||
for (idx, _) in text.match_indices("self") {
|
if self_param
|
||||||
let offset: TextSize = idx.try_into().unwrap();
|
.syntax()
|
||||||
if !search_range.contains_inclusive(offset) {
|
.text_range()
|
||||||
continue;
|
.contains_range(refs.declaration().nav.focus_or_full_range())
|
||||||
}
|
{
|
||||||
if let Some(ref usage) = syn.token_at_offset(offset).find(|t| t.kind() == T![self]) {
|
let edit = text_edit_from_self_param(syn, &self_param, new_name)
|
||||||
let edit = if let Some(ref self_param) = ast::SelfParam::cast(usage.parent()) {
|
.ok_or_else(|| format_err!("No target type found"))?;
|
||||||
text_edit_from_self_param(syn, self_param, new_name)
|
|
||||||
.ok_or_else(|| format_err!("No target type found"))?
|
|
||||||
} else {
|
|
||||||
TextEdit::replace(usage.text_range(), String::from(new_name))
|
|
||||||
};
|
|
||||||
source_change.insert_source_edit(position.file_id, edit);
|
source_change.insert_source_edit(position.file_id, edit);
|
||||||
|
|
||||||
|
source_change.extend(refs.references().iter().map(|(&file_id, references)| {
|
||||||
|
source_edit_from_references(sema, file_id, &references, new_name)
|
||||||
|
}));
|
||||||
|
|
||||||
|
if source_change.source_file_edits.len() > 1 && ident_kind == IdentifierKind::Underscore
|
||||||
|
{
|
||||||
|
bail!("Cannot rename reference to `_` as it is being referenced multiple times");
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(RangeInfo::new(range, source_change));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Err(format_err!("Method has no self param"))
|
||||||
if source_change.source_file_edits.len() > 1 && ident_kind == IdentifierKind::Underscore {
|
|
||||||
bail!("Cannot rename reference to `_` as it is being referenced multiple times");
|
|
||||||
}
|
|
||||||
|
|
||||||
let range = ast::SelfParam::cast(self_token.parent())
|
|
||||||
.map_or(self_token.text_range(), |p| p.syntax().text_range());
|
|
||||||
|
|
||||||
Ok(RangeInfo::new(range, source_change))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rename_reference(
|
fn rename_reference(
|
||||||
|
@ -444,8 +430,9 @@ fn rename_reference(
|
||||||
mark::hit!(rename_not_an_ident_ref);
|
mark::hit!(rename_not_an_ident_ref);
|
||||||
bail!("Invalid name `{}`: not an identifier", new_name)
|
bail!("Invalid name `{}`: not an identifier", new_name)
|
||||||
}
|
}
|
||||||
(IdentifierKind::ToSelf, ReferenceKind::SelfParam) => {
|
(_, ReferenceKind::SelfParam) => {
|
||||||
unreachable!("rename_self_to_param should've been called instead")
|
mark::hit!(rename_self_to_param);
|
||||||
|
return rename_self_to_param(sema, position, new_name, ident_kind, range, refs);
|
||||||
}
|
}
|
||||||
(IdentifierKind::ToSelf, _) => {
|
(IdentifierKind::ToSelf, _) => {
|
||||||
mark::hit!(rename_to_self);
|
mark::hit!(rename_to_self);
|
||||||
|
@ -1350,6 +1337,7 @@ impl Foo {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_owned_self_to_parameter() {
|
fn test_owned_self_to_parameter() {
|
||||||
|
mark::check!(rename_self_to_param);
|
||||||
check(
|
check(
|
||||||
"foo",
|
"foo",
|
||||||
r#"
|
r#"
|
||||||
|
|
|
@ -68,7 +68,8 @@ pub(super) fn element(
|
||||||
NAME_REF => {
|
NAME_REF => {
|
||||||
let name_ref = element.into_node().and_then(ast::NameRef::cast).unwrap();
|
let name_ref = element.into_node().and_then(ast::NameRef::cast).unwrap();
|
||||||
highlight_func_by_name_ref(sema, &name_ref).unwrap_or_else(|| {
|
highlight_func_by_name_ref(sema, &name_ref).unwrap_or_else(|| {
|
||||||
match NameRefClass::classify(sema, &name_ref) {
|
let is_self = name_ref.self_token().is_some();
|
||||||
|
let h = match NameRefClass::classify(sema, &name_ref) {
|
||||||
Some(name_kind) => match name_kind {
|
Some(name_kind) => match name_kind {
|
||||||
NameRefClass::ExternCrate(_) => HlTag::Symbol(SymbolKind::Module).into(),
|
NameRefClass::ExternCrate(_) => HlTag::Symbol(SymbolKind::Module).into(),
|
||||||
NameRefClass::Definition(def) => {
|
NameRefClass::Definition(def) => {
|
||||||
|
@ -108,6 +109,11 @@ pub(super) fn element(
|
||||||
highlight_name_ref_by_syntax(name_ref, sema)
|
highlight_name_ref_by_syntax(name_ref, sema)
|
||||||
}
|
}
|
||||||
None => HlTag::UnresolvedReference.into(),
|
None => HlTag::UnresolvedReference.into(),
|
||||||
|
};
|
||||||
|
if h.tag == HlTag::Symbol(SymbolKind::Module) && is_self {
|
||||||
|
HlTag::Symbol(SymbolKind::SelfParam).into()
|
||||||
|
} else {
|
||||||
|
h
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -225,18 +231,8 @@ pub(super) fn element(
|
||||||
T![for] if !is_child_of_impl(&element) => h | HlMod::ControlFlow,
|
T![for] if !is_child_of_impl(&element) => h | HlMod::ControlFlow,
|
||||||
T![unsafe] => h | HlMod::Unsafe,
|
T![unsafe] => h | HlMod::Unsafe,
|
||||||
T![true] | T![false] => HlTag::BoolLiteral.into(),
|
T![true] | T![false] => HlTag::BoolLiteral.into(),
|
||||||
T![self] => {
|
// self is handled as either a Name or NameRef already
|
||||||
let self_param = element.parent().and_then(ast::SelfParam::cast);
|
T![self] => return None,
|
||||||
if let Some(NameClass::Definition(def)) = self_param
|
|
||||||
.and_then(|self_param| NameClass::classify_self_param(sema, &self_param))
|
|
||||||
{
|
|
||||||
highlight_def(db, def) | HlMod::Definition
|
|
||||||
} else if element.ancestors().any(|it| it.kind() == USE_TREE) {
|
|
||||||
HlTag::Symbol(SymbolKind::SelfParam).into()
|
|
||||||
} else {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
T![ref] => element
|
T![ref] => element
|
||||||
.parent()
|
.parent()
|
||||||
.and_then(ast::IdentPat::cast)
|
.and_then(ast::IdentPat::cast)
|
||||||
|
|
|
@ -117,13 +117,6 @@ impl NameClass {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn classify_self_param(
|
|
||||||
sema: &Semantics<RootDatabase>,
|
|
||||||
self_param: &ast::SelfParam,
|
|
||||||
) -> Option<NameClass> {
|
|
||||||
sema.to_def(self_param).map(Definition::Local).map(NameClass::Definition)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn classify(sema: &Semantics<RootDatabase>, name: &ast::Name) -> Option<NameClass> {
|
pub fn classify(sema: &Semantics<RootDatabase>, name: &ast::Name) -> Option<NameClass> {
|
||||||
let _p = profile::span("classify_name");
|
let _p = profile::span("classify_name");
|
||||||
|
|
||||||
|
@ -186,6 +179,10 @@ impl NameClass {
|
||||||
|
|
||||||
Some(NameClass::Definition(Definition::Local(local)))
|
Some(NameClass::Definition(Definition::Local(local)))
|
||||||
},
|
},
|
||||||
|
ast::SelfParam(it) => {
|
||||||
|
let def = sema.to_def(&it)?;
|
||||||
|
Some(NameClass::Definition(Definition::Local(def.into())))
|
||||||
|
},
|
||||||
ast::RecordField(it) => {
|
ast::RecordField(it) => {
|
||||||
let field: hir::Field = sema.to_def(&it)?;
|
let field: hir::Field = sema.to_def(&it)?;
|
||||||
Some(NameClass::Definition(Definition::Field(field)))
|
Some(NameClass::Definition(Definition::Field(field)))
|
||||||
|
|
|
@ -190,17 +190,25 @@ fn opt_visibility(p: &mut Parser) -> bool {
|
||||||
// test crate_visibility
|
// test crate_visibility
|
||||||
// pub(crate) struct S;
|
// pub(crate) struct S;
|
||||||
// pub(self) struct S;
|
// pub(self) struct S;
|
||||||
// pub(self) struct S;
|
// pub(super) struct S;
|
||||||
// pub(self) struct S;
|
|
||||||
|
|
||||||
// test pub_parens_typepath
|
// test pub_parens_typepath
|
||||||
// struct B(pub (super::A));
|
// struct B(pub (super::A));
|
||||||
// struct B(pub (crate::A,));
|
// struct B(pub (crate::A,));
|
||||||
T![crate] | T![self] | T![super] if p.nth(2) != T![:] => {
|
T![crate] | T![self] | T![super] if p.nth(2) != T![:] => {
|
||||||
p.bump_any();
|
p.bump_any();
|
||||||
|
let path_m = p.start();
|
||||||
|
let path_segment_m = p.start();
|
||||||
|
let name_ref_m = p.start();
|
||||||
p.bump_any();
|
p.bump_any();
|
||||||
|
name_ref_m.complete(p, NAME_REF);
|
||||||
|
path_segment_m.complete(p, PATH_SEGMENT);
|
||||||
|
path_m.complete(p, PATH);
|
||||||
p.expect(T![')']);
|
p.expect(T![')']);
|
||||||
}
|
}
|
||||||
|
// test crate_visibility_in
|
||||||
|
// pub(in super::A) struct S;
|
||||||
|
// pub(in crate) struct S;
|
||||||
T![in] => {
|
T![in] => {
|
||||||
p.bump_any();
|
p.bump_any();
|
||||||
p.bump_any();
|
p.bump_any();
|
||||||
|
|
|
@ -270,7 +270,9 @@ fn extern_crate(p: &mut Parser, m: Marker) {
|
||||||
p.bump(T![crate]);
|
p.bump(T![crate]);
|
||||||
|
|
||||||
if p.at(T![self]) {
|
if p.at(T![self]) {
|
||||||
|
let m = p.start();
|
||||||
p.bump(T![self]);
|
p.bump(T![self]);
|
||||||
|
m.complete(p, NAME_REF);
|
||||||
} else {
|
} else {
|
||||||
name_ref(p);
|
name_ref(p);
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,7 +156,7 @@ fn variadic_param(p: &mut Parser) -> bool {
|
||||||
fn opt_self_param(p: &mut Parser, m: Marker) {
|
fn opt_self_param(p: &mut Parser, m: Marker) {
|
||||||
if p.at(T![self]) || p.at(T![mut]) && p.nth(1) == T![self] {
|
if p.at(T![self]) || p.at(T![mut]) && p.nth(1) == T![self] {
|
||||||
p.eat(T![mut]);
|
p.eat(T![mut]);
|
||||||
p.eat(T![self]);
|
self_as_name(p);
|
||||||
// test arb_self_types
|
// test arb_self_types
|
||||||
// impl S {
|
// impl S {
|
||||||
// fn a(self: &Self) {}
|
// fn a(self: &Self) {}
|
||||||
|
@ -169,24 +169,29 @@ fn opt_self_param(p: &mut Parser, m: Marker) {
|
||||||
let la1 = p.nth(1);
|
let la1 = p.nth(1);
|
||||||
let la2 = p.nth(2);
|
let la2 = p.nth(2);
|
||||||
let la3 = p.nth(3);
|
let la3 = p.nth(3);
|
||||||
let mut n_toks = match (p.current(), la1, la2, la3) {
|
if !matches!((p.current(), la1, la2, la3),
|
||||||
(T![&], T![self], _, _) => 2,
|
(T![&], T![self], _, _)
|
||||||
(T![&], T![mut], T![self], _) => 3,
|
| (T![&], T![mut], T![self], _)
|
||||||
(T![&], LIFETIME_IDENT, T![self], _) => 3,
|
| (T![&], LIFETIME_IDENT, T![self], _)
|
||||||
(T![&], LIFETIME_IDENT, T![mut], T![self]) => 4,
|
| (T![&], LIFETIME_IDENT, T![mut], T![self])
|
||||||
_ => return m.abandon(p),
|
) {
|
||||||
};
|
return m.abandon(p);
|
||||||
p.bump_any();
|
}
|
||||||
|
p.bump(T![&]);
|
||||||
if p.at(LIFETIME_IDENT) {
|
if p.at(LIFETIME_IDENT) {
|
||||||
lifetime(p);
|
lifetime(p);
|
||||||
n_toks -= 1;
|
|
||||||
}
|
|
||||||
for _ in 1..n_toks {
|
|
||||||
p.bump_any();
|
|
||||||
}
|
}
|
||||||
|
p.eat(T![mut]);
|
||||||
|
self_as_name(p);
|
||||||
}
|
}
|
||||||
m.complete(p, SELF_PARAM);
|
m.complete(p, SELF_PARAM);
|
||||||
if !p.at(T![')']) {
|
if !p.at(T![')']) {
|
||||||
p.expect(T![,]);
|
p.expect(T![,]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn self_as_name(p: &mut Parser) {
|
||||||
|
let m = p.start();
|
||||||
|
p.bump(T![self]);
|
||||||
|
m.complete(p, NAME);
|
||||||
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ pub struct Name {
|
||||||
}
|
}
|
||||||
impl Name {
|
impl Name {
|
||||||
pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) }
|
pub fn ident_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![ident]) }
|
||||||
|
pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct NameRef {
|
pub struct NameRef {
|
||||||
|
@ -238,7 +239,6 @@ impl ExternCrate {
|
||||||
pub fn extern_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![extern]) }
|
pub fn extern_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![extern]) }
|
||||||
pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
|
pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
|
||||||
pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
|
pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
|
||||||
pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
|
|
||||||
pub fn rename(&self) -> Option<Rename> { support::child(&self.syntax) }
|
pub fn rename(&self) -> Option<Rename> { support::child(&self.syntax) }
|
||||||
pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
|
pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
|
||||||
}
|
}
|
||||||
|
@ -406,9 +406,6 @@ pub struct Visibility {
|
||||||
impl Visibility {
|
impl Visibility {
|
||||||
pub fn pub_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![pub]) }
|
pub fn pub_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![pub]) }
|
||||||
pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
|
pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
|
||||||
pub fn super_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![super]) }
|
|
||||||
pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
|
|
||||||
pub fn crate_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![crate]) }
|
|
||||||
pub fn in_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![in]) }
|
pub fn in_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![in]) }
|
||||||
pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
|
pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
|
||||||
pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
|
pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
|
||||||
|
@ -492,11 +489,11 @@ pub struct SelfParam {
|
||||||
pub(crate) syntax: SyntaxNode,
|
pub(crate) syntax: SyntaxNode,
|
||||||
}
|
}
|
||||||
impl ast::AttrsOwner for SelfParam {}
|
impl ast::AttrsOwner for SelfParam {}
|
||||||
|
impl ast::NameOwner for SelfParam {}
|
||||||
impl SelfParam {
|
impl SelfParam {
|
||||||
pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
|
pub fn amp_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![&]) }
|
||||||
pub fn lifetime(&self) -> Option<Lifetime> { support::child(&self.syntax) }
|
pub fn lifetime(&self) -> Option<Lifetime> { support::child(&self.syntax) }
|
||||||
pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
|
pub fn mut_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![mut]) }
|
||||||
pub fn self_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![self]) }
|
|
||||||
pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
|
pub fn colon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![:]) }
|
||||||
pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
|
pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,6 +198,13 @@ impl ast::Path {
|
||||||
pub fn parent_path(&self) -> Option<ast::Path> {
|
pub fn parent_path(&self) -> Option<ast::Path> {
|
||||||
self.syntax().parent().and_then(ast::Path::cast)
|
self.syntax().parent().and_then(ast::Path::cast)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn as_single_segment(&self) -> Option<ast::PathSegment> {
|
||||||
|
match self.qualifier() {
|
||||||
|
Some(_) => None,
|
||||||
|
None => self.segment(),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ast::UseTreeList {
|
impl ast::UseTreeList {
|
||||||
|
@ -448,16 +455,22 @@ pub enum VisibilityKind {
|
||||||
|
|
||||||
impl ast::Visibility {
|
impl ast::Visibility {
|
||||||
pub fn kind(&self) -> VisibilityKind {
|
pub fn kind(&self) -> VisibilityKind {
|
||||||
if let Some(path) = support::children(self.syntax()).next() {
|
match self.path() {
|
||||||
VisibilityKind::In(path)
|
Some(path) => {
|
||||||
} else if self.crate_token().is_some() {
|
if let Some(segment) =
|
||||||
VisibilityKind::PubCrate
|
path.as_single_segment().filter(|it| it.coloncolon_token().is_none())
|
||||||
} else if self.super_token().is_some() {
|
{
|
||||||
VisibilityKind::PubSuper
|
if segment.crate_token().is_some() {
|
||||||
} else if self.self_token().is_some() {
|
return VisibilityKind::PubCrate;
|
||||||
VisibilityKind::PubSelf
|
} else if segment.super_token().is_some() {
|
||||||
} else {
|
return VisibilityKind::PubSuper;
|
||||||
VisibilityKind::Pub
|
} else if segment.self_token().is_some() {
|
||||||
|
return VisibilityKind::PubSelf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
VisibilityKind::In(path)
|
||||||
|
}
|
||||||
|
None => VisibilityKind::Pub,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,10 @@ SOURCE_FILE@0..118
|
||||||
VISIBILITY@56..66
|
VISIBILITY@56..66
|
||||||
PUB_KW@56..59 "pub"
|
PUB_KW@56..59 "pub"
|
||||||
L_PAREN@59..60 "("
|
L_PAREN@59..60 "("
|
||||||
CRATE_KW@60..65 "crate"
|
PATH@60..65
|
||||||
|
PATH_SEGMENT@60..65
|
||||||
|
NAME_REF@60..65
|
||||||
|
CRATE_KW@60..65 "crate"
|
||||||
R_PAREN@65..66 ")"
|
R_PAREN@65..66 ")"
|
||||||
WHITESPACE@66..67 " "
|
WHITESPACE@66..67 " "
|
||||||
TYPE_KW@67..71 "type"
|
TYPE_KW@67..71 "type"
|
||||||
|
@ -69,7 +72,10 @@ SOURCE_FILE@0..118
|
||||||
VISIBILITY@86..96
|
VISIBILITY@86..96
|
||||||
PUB_KW@86..89 "pub"
|
PUB_KW@86..89 "pub"
|
||||||
L_PAREN@89..90 "("
|
L_PAREN@89..90 "("
|
||||||
CRATE_KW@90..95 "crate"
|
PATH@90..95
|
||||||
|
PATH_SEGMENT@90..95
|
||||||
|
NAME_REF@90..95
|
||||||
|
CRATE_KW@90..95 "crate"
|
||||||
R_PAREN@95..96 ")"
|
R_PAREN@95..96 ")"
|
||||||
WHITESPACE@96..97 " "
|
WHITESPACE@96..97 " "
|
||||||
CONST_KW@97..102 "const"
|
CONST_KW@97..102 "const"
|
||||||
|
|
|
@ -19,7 +19,8 @@ SOURCE_FILE@0..128
|
||||||
PARAM_LIST@17..23
|
PARAM_LIST@17..23
|
||||||
L_PAREN@17..18 "("
|
L_PAREN@17..18 "("
|
||||||
SELF_PARAM@18..22
|
SELF_PARAM@18..22
|
||||||
SELF_KW@18..22 "self"
|
NAME@18..22
|
||||||
|
SELF_KW@18..22 "self"
|
||||||
R_PAREN@22..23 ")"
|
R_PAREN@22..23 ")"
|
||||||
WHITESPACE@23..24 " "
|
WHITESPACE@23..24 " "
|
||||||
BLOCK_EXPR@24..26
|
BLOCK_EXPR@24..26
|
||||||
|
@ -35,7 +36,8 @@ SOURCE_FILE@0..128
|
||||||
L_PAREN@35..36 "("
|
L_PAREN@35..36 "("
|
||||||
SELF_PARAM@36..41
|
SELF_PARAM@36..41
|
||||||
AMP@36..37 "&"
|
AMP@36..37 "&"
|
||||||
SELF_KW@37..41 "self"
|
NAME@37..41
|
||||||
|
SELF_KW@37..41 "self"
|
||||||
COMMA@41..42 ","
|
COMMA@41..42 ","
|
||||||
R_PAREN@42..43 ")"
|
R_PAREN@42..43 ")"
|
||||||
WHITESPACE@43..44 " "
|
WHITESPACE@43..44 " "
|
||||||
|
@ -55,7 +57,8 @@ SOURCE_FILE@0..128
|
||||||
LIFETIME@57..59
|
LIFETIME@57..59
|
||||||
LIFETIME_IDENT@57..59 "\'a"
|
LIFETIME_IDENT@57..59 "\'a"
|
||||||
WHITESPACE@59..60 " "
|
WHITESPACE@59..60 " "
|
||||||
SELF_KW@60..64 "self"
|
NAME@60..64
|
||||||
|
SELF_KW@60..64 "self"
|
||||||
COMMA@64..65 ","
|
COMMA@64..65 ","
|
||||||
R_PAREN@65..66 ")"
|
R_PAREN@65..66 ")"
|
||||||
WHITESPACE@66..67 " "
|
WHITESPACE@66..67 " "
|
||||||
|
@ -77,7 +80,8 @@ SOURCE_FILE@0..128
|
||||||
WHITESPACE@82..83 " "
|
WHITESPACE@82..83 " "
|
||||||
MUT_KW@83..86 "mut"
|
MUT_KW@83..86 "mut"
|
||||||
WHITESPACE@86..87 " "
|
WHITESPACE@86..87 " "
|
||||||
SELF_KW@87..91 "self"
|
NAME@87..91
|
||||||
|
SELF_KW@87..91 "self"
|
||||||
COMMA@91..92 ","
|
COMMA@91..92 ","
|
||||||
WHITESPACE@92..93 " "
|
WHITESPACE@92..93 " "
|
||||||
PARAM@93..99
|
PARAM@93..99
|
||||||
|
@ -107,7 +111,8 @@ SOURCE_FILE@0..128
|
||||||
SELF_PARAM@113..121
|
SELF_PARAM@113..121
|
||||||
MUT_KW@113..116 "mut"
|
MUT_KW@113..116 "mut"
|
||||||
WHITESPACE@116..117 " "
|
WHITESPACE@116..117 " "
|
||||||
SELF_KW@117..121 "self"
|
NAME@117..121
|
||||||
|
SELF_KW@117..121 "self"
|
||||||
R_PAREN@121..122 ")"
|
R_PAREN@121..122 ")"
|
||||||
WHITESPACE@122..123 " "
|
WHITESPACE@122..123 " "
|
||||||
BLOCK_EXPR@123..125
|
BLOCK_EXPR@123..125
|
||||||
|
|
|
@ -19,7 +19,8 @@ SOURCE_FILE@0..69
|
||||||
PARAM_LIST@17..30
|
PARAM_LIST@17..30
|
||||||
L_PAREN@17..18 "("
|
L_PAREN@17..18 "("
|
||||||
SELF_PARAM@18..29
|
SELF_PARAM@18..29
|
||||||
SELF_KW@18..22 "self"
|
NAME@18..22
|
||||||
|
SELF_KW@18..22 "self"
|
||||||
COLON@22..23 ":"
|
COLON@22..23 ":"
|
||||||
WHITESPACE@23..24 " "
|
WHITESPACE@23..24 " "
|
||||||
REF_TYPE@24..29
|
REF_TYPE@24..29
|
||||||
|
@ -45,7 +46,8 @@ SOURCE_FILE@0..69
|
||||||
SELF_PARAM@43..62
|
SELF_PARAM@43..62
|
||||||
MUT_KW@43..46 "mut"
|
MUT_KW@43..46 "mut"
|
||||||
WHITESPACE@46..47 " "
|
WHITESPACE@46..47 " "
|
||||||
SELF_KW@47..51 "self"
|
NAME@47..51
|
||||||
|
SELF_KW@47..51 "self"
|
||||||
COLON@51..52 ":"
|
COLON@51..52 ":"
|
||||||
WHITESPACE@52..53 " "
|
WHITESPACE@52..53 " "
|
||||||
PATH_TYPE@53..62
|
PATH_TYPE@53..62
|
||||||
|
|
|
@ -67,7 +67,8 @@ SOURCE_FILE@0..89
|
||||||
L_PAREN@76..77 "("
|
L_PAREN@76..77 "("
|
||||||
SELF_PARAM@77..82
|
SELF_PARAM@77..82
|
||||||
AMP@77..78 "&"
|
AMP@77..78 "&"
|
||||||
SELF_KW@78..82 "self"
|
NAME@78..82
|
||||||
|
SELF_KW@78..82 "self"
|
||||||
R_PAREN@82..83 ")"
|
R_PAREN@82..83 ")"
|
||||||
WHITESPACE@83..84 " "
|
WHITESPACE@83..84 " "
|
||||||
BLOCK_EXPR@84..86
|
BLOCK_EXPR@84..86
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
SOURCE_FILE@0..81
|
SOURCE_FILE@0..62
|
||||||
STRUCT@0..20
|
STRUCT@0..20
|
||||||
VISIBILITY@0..10
|
VISIBILITY@0..10
|
||||||
PUB_KW@0..3 "pub"
|
PUB_KW@0..3 "pub"
|
||||||
L_PAREN@3..4 "("
|
L_PAREN@3..4 "("
|
||||||
CRATE_KW@4..9 "crate"
|
PATH@4..9
|
||||||
|
PATH_SEGMENT@4..9
|
||||||
|
NAME_REF@4..9
|
||||||
|
CRATE_KW@4..9 "crate"
|
||||||
R_PAREN@9..10 ")"
|
R_PAREN@9..10 ")"
|
||||||
WHITESPACE@10..11 " "
|
WHITESPACE@10..11 " "
|
||||||
STRUCT_KW@11..17 "struct"
|
STRUCT_KW@11..17 "struct"
|
||||||
|
@ -16,7 +19,10 @@ SOURCE_FILE@0..81
|
||||||
VISIBILITY@21..30
|
VISIBILITY@21..30
|
||||||
PUB_KW@21..24 "pub"
|
PUB_KW@21..24 "pub"
|
||||||
L_PAREN@24..25 "("
|
L_PAREN@24..25 "("
|
||||||
SELF_KW@25..29 "self"
|
PATH@25..29
|
||||||
|
PATH_SEGMENT@25..29
|
||||||
|
NAME_REF@25..29
|
||||||
|
SELF_KW@25..29 "self"
|
||||||
R_PAREN@29..30 ")"
|
R_PAREN@29..30 ")"
|
||||||
WHITESPACE@30..31 " "
|
WHITESPACE@30..31 " "
|
||||||
STRUCT_KW@31..37 "struct"
|
STRUCT_KW@31..37 "struct"
|
||||||
|
@ -25,29 +31,19 @@ SOURCE_FILE@0..81
|
||||||
IDENT@38..39 "S"
|
IDENT@38..39 "S"
|
||||||
SEMICOLON@39..40 ";"
|
SEMICOLON@39..40 ";"
|
||||||
WHITESPACE@40..41 "\n"
|
WHITESPACE@40..41 "\n"
|
||||||
STRUCT@41..60
|
STRUCT@41..61
|
||||||
VISIBILITY@41..50
|
VISIBILITY@41..51
|
||||||
PUB_KW@41..44 "pub"
|
PUB_KW@41..44 "pub"
|
||||||
L_PAREN@44..45 "("
|
L_PAREN@44..45 "("
|
||||||
SELF_KW@45..49 "self"
|
PATH@45..50
|
||||||
R_PAREN@49..50 ")"
|
PATH_SEGMENT@45..50
|
||||||
WHITESPACE@50..51 " "
|
NAME_REF@45..50
|
||||||
STRUCT_KW@51..57 "struct"
|
SUPER_KW@45..50 "super"
|
||||||
WHITESPACE@57..58 " "
|
R_PAREN@50..51 ")"
|
||||||
NAME@58..59
|
WHITESPACE@51..52 " "
|
||||||
IDENT@58..59 "S"
|
STRUCT_KW@52..58 "struct"
|
||||||
SEMICOLON@59..60 ";"
|
WHITESPACE@58..59 " "
|
||||||
WHITESPACE@60..61 "\n"
|
NAME@59..60
|
||||||
STRUCT@61..80
|
IDENT@59..60 "S"
|
||||||
VISIBILITY@61..70
|
SEMICOLON@60..61 ";"
|
||||||
PUB_KW@61..64 "pub"
|
WHITESPACE@61..62 "\n"
|
||||||
L_PAREN@64..65 "("
|
|
||||||
SELF_KW@65..69 "self"
|
|
||||||
R_PAREN@69..70 ")"
|
|
||||||
WHITESPACE@70..71 " "
|
|
||||||
STRUCT_KW@71..77 "struct"
|
|
||||||
WHITESPACE@77..78 " "
|
|
||||||
NAME@78..79
|
|
||||||
IDENT@78..79 "S"
|
|
||||||
SEMICOLON@79..80 ";"
|
|
||||||
WHITESPACE@80..81 "\n"
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
pub(crate) struct S;
|
pub(crate) struct S;
|
||||||
pub(self) struct S;
|
pub(self) struct S;
|
||||||
pub(self) struct S;
|
pub(super) struct S;
|
||||||
pub(self) struct S;
|
|
||||||
|
|
|
@ -16,7 +16,8 @@ SOURCE_FILE@0..26
|
||||||
IDENT@7..15 "must_use"
|
IDENT@7..15 "must_use"
|
||||||
R_BRACK@15..16 "]"
|
R_BRACK@15..16 "]"
|
||||||
WHITESPACE@16..17 " "
|
WHITESPACE@16..17 " "
|
||||||
SELF_KW@17..21 "self"
|
NAME@17..21
|
||||||
|
SELF_KW@17..21 "self"
|
||||||
R_PAREN@21..22 ")"
|
R_PAREN@21..22 ")"
|
||||||
WHITESPACE@22..23 " "
|
WHITESPACE@22..23 " "
|
||||||
BLOCK_EXPR@23..25
|
BLOCK_EXPR@23..25
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
SOURCE_FILE@0..51
|
||||||
|
STRUCT@0..26
|
||||||
|
VISIBILITY@0..16
|
||||||
|
PUB_KW@0..3 "pub"
|
||||||
|
L_PAREN@3..4 "("
|
||||||
|
IN_KW@4..6 "in"
|
||||||
|
WHITESPACE@6..7 " "
|
||||||
|
PATH@7..15
|
||||||
|
PATH@7..12
|
||||||
|
PATH_SEGMENT@7..12
|
||||||
|
NAME_REF@7..12
|
||||||
|
SUPER_KW@7..12 "super"
|
||||||
|
COLON2@12..14 "::"
|
||||||
|
PATH_SEGMENT@14..15
|
||||||
|
NAME_REF@14..15
|
||||||
|
IDENT@14..15 "A"
|
||||||
|
R_PAREN@15..16 ")"
|
||||||
|
WHITESPACE@16..17 " "
|
||||||
|
STRUCT_KW@17..23 "struct"
|
||||||
|
WHITESPACE@23..24 " "
|
||||||
|
NAME@24..25
|
||||||
|
IDENT@24..25 "S"
|
||||||
|
SEMICOLON@25..26 ";"
|
||||||
|
WHITESPACE@26..27 "\n"
|
||||||
|
STRUCT@27..50
|
||||||
|
VISIBILITY@27..40
|
||||||
|
PUB_KW@27..30 "pub"
|
||||||
|
L_PAREN@30..31 "("
|
||||||
|
IN_KW@31..33 "in"
|
||||||
|
WHITESPACE@33..34 " "
|
||||||
|
PATH@34..39
|
||||||
|
PATH_SEGMENT@34..39
|
||||||
|
NAME_REF@34..39
|
||||||
|
CRATE_KW@34..39 "crate"
|
||||||
|
R_PAREN@39..40 ")"
|
||||||
|
WHITESPACE@40..41 " "
|
||||||
|
STRUCT_KW@41..47 "struct"
|
||||||
|
WHITESPACE@47..48 " "
|
||||||
|
NAME@48..49
|
||||||
|
IDENT@48..49 "S"
|
||||||
|
SEMICOLON@49..50 ";"
|
||||||
|
WHITESPACE@50..51 "\n"
|
|
@ -0,0 +1,2 @@
|
||||||
|
pub(in super::A) struct S;
|
||||||
|
pub(in crate) struct S;
|
|
@ -28,7 +28,8 @@ SOURCE_FILE@0..69
|
||||||
WHITESPACE@49..50 " "
|
WHITESPACE@49..50 " "
|
||||||
CRATE_KW@50..55 "crate"
|
CRATE_KW@50..55 "crate"
|
||||||
WHITESPACE@55..56 " "
|
WHITESPACE@55..56 " "
|
||||||
SELF_KW@56..60 "self"
|
NAME_REF@56..60
|
||||||
|
SELF_KW@56..60 "self"
|
||||||
WHITESPACE@60..61 " "
|
WHITESPACE@60..61 " "
|
||||||
RENAME@61..67
|
RENAME@61..67
|
||||||
AS_KW@61..63 "as"
|
AS_KW@61..63 "as"
|
||||||
|
|
|
@ -32,7 +32,10 @@ SOURCE_FILE@0..98
|
||||||
VISIBILITY@24..34
|
VISIBILITY@24..34
|
||||||
PUB_KW@24..27 "pub"
|
PUB_KW@24..27 "pub"
|
||||||
L_PAREN@27..28 "("
|
L_PAREN@27..28 "("
|
||||||
CRATE_KW@28..33 "crate"
|
PATH@28..33
|
||||||
|
PATH_SEGMENT@28..33
|
||||||
|
NAME_REF@28..33
|
||||||
|
CRATE_KW@28..33 "crate"
|
||||||
R_PAREN@33..34 ")"
|
R_PAREN@33..34 ")"
|
||||||
WHITESPACE@34..35 " "
|
WHITESPACE@34..35 " "
|
||||||
FN_KW@35..37 "fn"
|
FN_KW@35..37 "fn"
|
||||||
|
@ -51,7 +54,10 @@ SOURCE_FILE@0..98
|
||||||
VISIBILITY@45..55
|
VISIBILITY@45..55
|
||||||
PUB_KW@45..48 "pub"
|
PUB_KW@45..48 "pub"
|
||||||
L_PAREN@48..49 "("
|
L_PAREN@48..49 "("
|
||||||
SUPER_KW@49..54 "super"
|
PATH@49..54
|
||||||
|
PATH_SEGMENT@49..54
|
||||||
|
NAME_REF@49..54
|
||||||
|
SUPER_KW@49..54 "super"
|
||||||
R_PAREN@54..55 ")"
|
R_PAREN@54..55 ")"
|
||||||
WHITESPACE@55..56 " "
|
WHITESPACE@55..56 " "
|
||||||
FN_KW@56..58 "fn"
|
FN_KW@56..58 "fn"
|
||||||
|
|
|
@ -110,7 +110,8 @@ SOURCE_FILE@0..686
|
||||||
L_PAREN@558..559 "("
|
L_PAREN@558..559 "("
|
||||||
SELF_PARAM@559..564
|
SELF_PARAM@559..564
|
||||||
AMP@559..560 "&"
|
AMP@559..560 "&"
|
||||||
SELF_KW@560..564 "self"
|
NAME@560..564
|
||||||
|
SELF_KW@560..564 "self"
|
||||||
COMMA@564..565 ","
|
COMMA@564..565 ","
|
||||||
WHITESPACE@565..566 " "
|
WHITESPACE@565..566 " "
|
||||||
PARAM@566..600
|
PARAM@566..600
|
||||||
|
|
|
@ -281,7 +281,8 @@ SOURCE_FILE@0..519
|
||||||
IDENT@259..267 "must_use"
|
IDENT@259..267 "must_use"
|
||||||
R_BRACK@267..268 "]"
|
R_BRACK@267..268 "]"
|
||||||
WHITESPACE@268..269 " "
|
WHITESPACE@268..269 " "
|
||||||
SELF_KW@269..273 "self"
|
NAME@269..273
|
||||||
|
SELF_KW@269..273 "self"
|
||||||
R_PAREN@273..274 ")"
|
R_PAREN@273..274 ")"
|
||||||
WHITESPACE@274..275 " "
|
WHITESPACE@274..275 " "
|
||||||
BLOCK_EXPR@275..277
|
BLOCK_EXPR@275..277
|
||||||
|
@ -305,7 +306,8 @@ SOURCE_FILE@0..519
|
||||||
IDENT@291..295 "attr"
|
IDENT@291..295 "attr"
|
||||||
R_BRACK@295..296 "]"
|
R_BRACK@295..296 "]"
|
||||||
WHITESPACE@296..297 " "
|
WHITESPACE@296..297 " "
|
||||||
SELF_KW@297..301 "self"
|
NAME@297..301
|
||||||
|
SELF_KW@297..301 "self"
|
||||||
R_PAREN@301..302 ")"
|
R_PAREN@301..302 ")"
|
||||||
WHITESPACE@302..303 " "
|
WHITESPACE@302..303 " "
|
||||||
BLOCK_EXPR@303..305
|
BLOCK_EXPR@303..305
|
||||||
|
@ -330,7 +332,8 @@ SOURCE_FILE@0..519
|
||||||
R_BRACK@323..324 "]"
|
R_BRACK@323..324 "]"
|
||||||
WHITESPACE@324..325 " "
|
WHITESPACE@324..325 " "
|
||||||
AMP@325..326 "&"
|
AMP@325..326 "&"
|
||||||
SELF_KW@326..330 "self"
|
NAME@326..330
|
||||||
|
SELF_KW@326..330 "self"
|
||||||
R_PAREN@330..331 ")"
|
R_PAREN@330..331 ")"
|
||||||
WHITESPACE@331..332 " "
|
WHITESPACE@331..332 " "
|
||||||
BLOCK_EXPR@332..334
|
BLOCK_EXPR@332..334
|
||||||
|
@ -363,7 +366,8 @@ SOURCE_FILE@0..519
|
||||||
AMP@358..359 "&"
|
AMP@358..359 "&"
|
||||||
MUT_KW@359..362 "mut"
|
MUT_KW@359..362 "mut"
|
||||||
WHITESPACE@362..363 " "
|
WHITESPACE@362..363 " "
|
||||||
SELF_KW@363..367 "self"
|
NAME@363..367
|
||||||
|
SELF_KW@363..367 "self"
|
||||||
R_PAREN@367..368 ")"
|
R_PAREN@367..368 ")"
|
||||||
WHITESPACE@368..369 " "
|
WHITESPACE@368..369 " "
|
||||||
BLOCK_EXPR@369..371
|
BLOCK_EXPR@369..371
|
||||||
|
@ -397,7 +401,8 @@ SOURCE_FILE@0..519
|
||||||
LIFETIME@396..398
|
LIFETIME@396..398
|
||||||
LIFETIME_IDENT@396..398 "\'a"
|
LIFETIME_IDENT@396..398 "\'a"
|
||||||
WHITESPACE@398..399 " "
|
WHITESPACE@398..399 " "
|
||||||
SELF_KW@399..403 "self"
|
NAME@399..403
|
||||||
|
SELF_KW@399..403 "self"
|
||||||
R_PAREN@403..404 ")"
|
R_PAREN@403..404 ")"
|
||||||
WHITESPACE@404..405 " "
|
WHITESPACE@404..405 " "
|
||||||
BLOCK_EXPR@405..407
|
BLOCK_EXPR@405..407
|
||||||
|
@ -433,7 +438,8 @@ SOURCE_FILE@0..519
|
||||||
WHITESPACE@434..435 " "
|
WHITESPACE@434..435 " "
|
||||||
MUT_KW@435..438 "mut"
|
MUT_KW@435..438 "mut"
|
||||||
WHITESPACE@438..439 " "
|
WHITESPACE@438..439 " "
|
||||||
SELF_KW@439..443 "self"
|
NAME@439..443
|
||||||
|
SELF_KW@439..443 "self"
|
||||||
R_PAREN@443..444 ")"
|
R_PAREN@443..444 ")"
|
||||||
WHITESPACE@444..445 " "
|
WHITESPACE@444..445 " "
|
||||||
BLOCK_EXPR@445..447
|
BLOCK_EXPR@445..447
|
||||||
|
@ -457,7 +463,8 @@ SOURCE_FILE@0..519
|
||||||
IDENT@460..464 "attr"
|
IDENT@460..464 "attr"
|
||||||
R_BRACK@464..465 "]"
|
R_BRACK@464..465 "]"
|
||||||
WHITESPACE@465..466 " "
|
WHITESPACE@465..466 " "
|
||||||
SELF_KW@466..470 "self"
|
NAME@466..470
|
||||||
|
SELF_KW@466..470 "self"
|
||||||
COLON@470..471 ":"
|
COLON@470..471 ":"
|
||||||
WHITESPACE@471..472 " "
|
WHITESPACE@471..472 " "
|
||||||
PATH_TYPE@472..476
|
PATH_TYPE@472..476
|
||||||
|
@ -488,7 +495,8 @@ SOURCE_FILE@0..519
|
||||||
IDENT@493..497 "attr"
|
IDENT@493..497 "attr"
|
||||||
R_BRACK@497..498 "]"
|
R_BRACK@497..498 "]"
|
||||||
WHITESPACE@498..499 " "
|
WHITESPACE@498..499 " "
|
||||||
SELF_KW@499..503 "self"
|
NAME@499..503
|
||||||
|
SELF_KW@499..503 "self"
|
||||||
COLON@503..504 ":"
|
COLON@503..504 ":"
|
||||||
WHITESPACE@504..505 " "
|
WHITESPACE@504..505 " "
|
||||||
PATH_TYPE@505..513
|
PATH_TYPE@505..513
|
||||||
|
|
|
@ -15,7 +15,7 @@ flate2 = "1.0"
|
||||||
pico-args = "0.3.1"
|
pico-args = "0.3.1"
|
||||||
proc-macro2 = "1.0.8"
|
proc-macro2 = "1.0.8"
|
||||||
quote = "1.0.2"
|
quote = "1.0.2"
|
||||||
ungrammar = "1.8"
|
ungrammar = "1.9"
|
||||||
walkdir = "2.3.1"
|
walkdir = "2.3.1"
|
||||||
write-json = "0.1.0"
|
write-json = "0.1.0"
|
||||||
xshell = "0.1"
|
xshell = "0.1"
|
||||||
|
|
Loading…
Reference in a new issue