From 21d2cebcf1a417bce72da98aa638a20235c050db Mon Sep 17 00:00:00 2001 From: David Lattimore Date: Sat, 1 Aug 2020 12:43:10 +1000 Subject: [PATCH 001/119] SSR: Matching trait associated constants, types and functions This fixes matching of things like `HashMap::default()` by resolving `HashMap` instead of `default` (which resolves to `Default::default`). Same for associated constants and types that are part of a trait implementation. However, we still don't support matching calls to trait methods. --- crates/ra_ide/src/ssr.rs | 4 +-- crates/ra_ssr/src/resolving.rs | 31 +++++++++++++--- crates/ra_ssr/src/tests.rs | 64 ++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+), 6 deletions(-) diff --git a/crates/ra_ide/src/ssr.rs b/crates/ra_ide/src/ssr.rs index 4348b43beb..8be862fd6e 100644 --- a/crates/ra_ide/src/ssr.rs +++ b/crates/ra_ide/src/ssr.rs @@ -21,8 +21,8 @@ use ra_ssr::{MatchFinder, SsrError, SsrRule}; // replacement occurs. For example if our replacement template is `foo::Bar` and we match some // code in the `foo` module, we'll insert just `Bar`. // -// Method calls should generally be written in UFCS form. e.g. `foo::Bar::baz($s, $a)` will match -// `$s.baz($a)`, provided the method call `baz` resolves to the method `foo::Bar::baz`. +// Inherent method calls should generally be written in UFCS form. e.g. `foo::Bar::baz($s, $a)` will +// match `$s.baz($a)`, provided the method call `baz` resolves to the method `foo::Bar::baz`. // // The scope of the search / replace will be restricted to the current selection if any, otherwise // it will apply to the whole workspace. diff --git a/crates/ra_ssr/src/resolving.rs b/crates/ra_ssr/src/resolving.rs index 6f62000f4a..d5b65eaacf 100644 --- a/crates/ra_ssr/src/resolving.rs +++ b/crates/ra_ssr/src/resolving.rs @@ -5,7 +5,7 @@ use crate::{parsing, SsrError}; use parsing::Placeholder; use ra_db::FilePosition; use ra_syntax::{ast, SmolStr, SyntaxKind, SyntaxNode, SyntaxToken}; -use rustc_hash::{FxHashMap, FxHashSet}; +use rustc_hash::FxHashMap; use test_utils::mark; pub(crate) struct ResolutionScope<'db> { @@ -111,8 +111,10 @@ impl Resolver<'_, '_> { .resolution_scope .resolve_path(&path) .ok_or_else(|| error!("Failed to resolve path `{}`", node.text()))?; - resolved_paths.insert(node, ResolvedPath { resolution, depth }); - return Ok(()); + if self.ok_to_use_path_resolution(&resolution) { + resolved_paths.insert(node, ResolvedPath { resolution, depth }); + return Ok(()); + } } } for node in node.children() { @@ -136,6 +138,27 @@ impl Resolver<'_, '_> { } false } + + fn ok_to_use_path_resolution(&self, resolution: &hir::PathResolution) -> bool { + match resolution { + hir::PathResolution::AssocItem(hir::AssocItem::Function(function)) => { + if function.has_self_param(self.resolution_scope.scope.db) { + // If we don't use this path resolution, then we won't be able to match method + // calls. e.g. `Foo::bar($s)` should match `x.bar()`. + true + } else { + mark::hit!(replace_associated_trait_default_function_call); + false + } + } + hir::PathResolution::AssocItem(_) => { + // Not a function. Could be a constant or an associated type. + mark::hit!(replace_associated_trait_constant); + false + } + _ => true, + } + } } impl<'db> ResolutionScope<'db> { @@ -176,7 +199,7 @@ impl<'db> ResolutionScope<'db> { adt.ty(self.scope.db).iterate_path_candidates( self.scope.db, self.scope.module()?.krate(), - &FxHashSet::default(), + &self.scope.traits_in_scope(), Some(hir_path.segments().last()?.name), |_ty, assoc_item| Some(hir::PathResolution::AssocItem(assoc_item)), ) diff --git a/crates/ra_ssr/src/tests.rs b/crates/ra_ssr/src/tests.rs index 2ae03c64c4..0a49a46e38 100644 --- a/crates/ra_ssr/src/tests.rs +++ b/crates/ra_ssr/src/tests.rs @@ -549,6 +549,70 @@ fn replace_associated_function_call() { ); } +#[test] +fn replace_associated_trait_default_function_call() { + mark::check!(replace_associated_trait_default_function_call); + assert_ssr_transform( + "Bar2::foo() ==>> Bar2::foo2()", + r#" + trait Foo { fn foo() {} } + pub struct Bar {} + impl Foo for Bar {} + pub struct Bar2 {} + impl Foo for Bar2 {} + impl Bar2 { fn foo2() {} } + fn main() { + Bar::foo(); + Bar2::foo(); + } + "#, + expect![[r#" + trait Foo { fn foo() {} } + pub struct Bar {} + impl Foo for Bar {} + pub struct Bar2 {} + impl Foo for Bar2 {} + impl Bar2 { fn foo2() {} } + fn main() { + Bar::foo(); + Bar2::foo2(); + } + "#]], + ); +} + +#[test] +fn replace_associated_trait_constant() { + mark::check!(replace_associated_trait_constant); + assert_ssr_transform( + "Bar2::VALUE ==>> Bar2::VALUE_2222", + r#" + trait Foo { const VALUE: i32; const VALUE_2222: i32; } + pub struct Bar {} + impl Foo for Bar { const VALUE: i32 = 1; const VALUE_2222: i32 = 2; } + pub struct Bar2 {} + impl Foo for Bar2 { const VALUE: i32 = 1; const VALUE_2222: i32 = 2; } + impl Bar2 { fn foo2() {} } + fn main() { + Bar::VALUE; + Bar2::VALUE; + } + "#, + expect![[r#" + trait Foo { const VALUE: i32; const VALUE_2222: i32; } + pub struct Bar {} + impl Foo for Bar { const VALUE: i32 = 1; const VALUE_2222: i32 = 2; } + pub struct Bar2 {} + impl Foo for Bar2 { const VALUE: i32 = 1; const VALUE_2222: i32 = 2; } + impl Bar2 { fn foo2() {} } + fn main() { + Bar::VALUE; + Bar2::VALUE_2222; + } + "#]], + ); +} + #[test] fn replace_path_in_different_contexts() { // Note the <|> inside module a::b which marks the point where the rule is interpreted. We From 85d5ed367579fb9e868517be0f0df636f6277363 Mon Sep 17 00:00:00 2001 From: Aleksei Trifonov Date: Sun, 2 Aug 2020 13:53:34 +0300 Subject: [PATCH 002/119] Fix test code lens --- crates/rust-analyzer/src/handlers.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index e73b3a2119..6994e611b2 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs @@ -896,7 +896,7 @@ pub(crate) fn handle_code_lens( } let action = runnable.action(); - let range = to_proto::range(&line_index, runnable.nav.focus_or_full_range()); + let range = to_proto::range(&line_index, runnable.nav.full_range); let r = to_proto::runnable(&snap, file_id, runnable)?; if snap.config.lens.run { let lens = CodeLens { From 6cde0b1aa0f6b8623c6b81b2396f4a0345891233 Mon Sep 17 00:00:00 2001 From: Paul Daniel Faria Date: Sat, 8 Aug 2020 14:14:18 -0400 Subject: [PATCH 003/119] Add support for extern crate This adds syntax highlighting, hover and goto def functionality for extern crate --- .../ra_assists/src/handlers/add_turbo_fish.rs | 2 +- crates/ra_hir/src/semantics.rs | 25 ++++- crates/ra_ide/src/display/short_label.rs | 6 ++ crates/ra_ide/src/goto_definition.rs | 37 +++++-- crates/ra_ide/src/hover.rs | 49 ++++++++- crates/ra_ide/src/references.rs | 4 +- crates/ra_ide/src/syntax_highlighting.rs | 2 + .../ra_ide/src/syntax_highlighting/tests.rs | 17 +++ .../test_data/highlight_extern_crate.html | 40 +++++++ crates/ra_ide_db/src/defs.rs | 100 +++++++++++------- crates/ra_ide_db/src/imports_locator.rs | 2 +- 11 files changed, 225 insertions(+), 59 deletions(-) create mode 100644 crates/ra_ide/test_data/highlight_extern_crate.html diff --git a/crates/ra_assists/src/handlers/add_turbo_fish.rs b/crates/ra_assists/src/handlers/add_turbo_fish.rs index 0c565e89af..537322a72c 100644 --- a/crates/ra_assists/src/handlers/add_turbo_fish.rs +++ b/crates/ra_assists/src/handlers/add_turbo_fish.rs @@ -41,7 +41,7 @@ pub(crate) fn add_turbo_fish(acc: &mut Assists, ctx: &AssistContext) -> Option<( let name_ref = ast::NameRef::cast(ident.parent())?; let def = match classify_name_ref(&ctx.sema, &name_ref)? { NameRefClass::Definition(def) => def, - NameRefClass::FieldShorthand { .. } => return None, + NameRefClass::ExternCrate(_) | NameRefClass::FieldShorthand { .. } => return None, }; let fun = match def { Definition::ModuleDef(hir::ModuleDef::Function(it)) => it, diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs index 307b336f20..e392130ab6 100644 --- a/crates/ra_hir/src/semantics.rs +++ b/crates/ra_hir/src/semantics.rs @@ -8,7 +8,7 @@ use hir_def::{ resolver::{self, HasResolver, Resolver}, AsMacroCall, FunctionId, TraitId, VariantId, }; -use hir_expand::{diagnostics::AstDiagnostic, hygiene::Hygiene, ExpansionInfo}; +use hir_expand::{diagnostics::AstDiagnostic, hygiene::Hygiene, name::AsName, ExpansionInfo}; use hir_ty::associated_type_shorthand_candidates; use itertools::Itertools; use ra_db::{FileId, FileRange}; @@ -24,8 +24,8 @@ use crate::{ diagnostics::Diagnostic, semantics::source_to_def::{ChildContainer, SourceToDefCache, SourceToDefCtx}, source_analyzer::{resolve_hir_path, resolve_hir_path_qualifier, SourceAnalyzer}, - AssocItem, Callable, Field, Function, HirFileId, ImplDef, InFile, Local, MacroDef, Module, - ModuleDef, Name, Origin, Path, ScopeDef, Trait, Type, TypeAlias, TypeParam, VariantDef, + AssocItem, Callable, Crate, Field, Function, HirFileId, ImplDef, InFile, Local, MacroDef, + Module, ModuleDef, Name, Origin, Path, ScopeDef, Trait, Type, TypeAlias, TypeParam, VariantDef, }; use resolver::TypeNs; @@ -228,6 +228,10 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { self.imp.resolve_path(path) } + pub fn resolve_extern_crate(&self, extern_crate: &ast::ExternCrate) -> Option { + self.imp.resolve_extern_crate(extern_crate) + } + pub fn resolve_variant(&self, record_lit: ast::RecordExpr) -> Option { self.imp.resolve_variant(record_lit).map(VariantDef::from) } @@ -443,6 +447,17 @@ impl<'db> SemanticsImpl<'db> { self.analyze(path.syntax()).resolve_path(self.db, path) } + fn resolve_extern_crate(&self, extern_crate: &ast::ExternCrate) -> Option { + let krate = self.scope(extern_crate.syntax()).krate()?; + krate.dependencies(self.db).into_iter().find_map(|dep| { + if dep.name == extern_crate.name_ref()?.as_name() { + Some(dep.krate) + } else { + None + } + }) + } + fn resolve_variant(&self, record_lit: ast::RecordExpr) -> Option { self.analyze(record_lit.syntax()).resolve_variant(self.db, record_lit) } @@ -612,6 +627,10 @@ impl<'a> SemanticsScope<'a> { Some(Module { id: self.resolver.module()? }) } + pub fn krate(&self) -> Option { + Some(Crate { id: self.resolver.krate()? }) + } + /// Note: `FxHashSet` should be treated as an opaque type, passed into `Type // FIXME: rename to visible_traits to not repeat scope? pub fn traits_in_scope(&self) -> FxHashSet { diff --git a/crates/ra_ide/src/display/short_label.rs b/crates/ra_ide/src/display/short_label.rs index 0fdf8e9a58..b5ff9fa2de 100644 --- a/crates/ra_ide/src/display/short_label.rs +++ b/crates/ra_ide/src/display/short_label.rs @@ -47,6 +47,12 @@ impl ShortLabel for ast::Module { } } +impl ShortLabel for ast::SourceFile { + fn short_label(&self) -> Option { + None + } +} + impl ShortLabel for ast::TypeAlias { fn short_label(&self) -> Option { short_label_from_node(self, "type ") diff --git a/crates/ra_ide/src/goto_definition.rs b/crates/ra_ide/src/goto_definition.rs index 4e3f428fae..b44b6fe22f 100644 --- a/crates/ra_ide/src/goto_definition.rs +++ b/crates/ra_ide/src/goto_definition.rs @@ -1,6 +1,6 @@ use hir::Semantics; use ra_ide_db::{ - defs::{classify_name, classify_name_ref, NameClass}, + defs::{classify_name, classify_name_ref}, symbol_index, RootDatabase, }; use ra_syntax::{ @@ -40,10 +40,7 @@ pub(crate) fn goto_definition( reference_definition(&sema, &name_ref).to_vec() }, ast::Name(name) => { - let def = match classify_name(&sema, &name)? { - NameClass::Definition(def) | NameClass::ConstReference(def) => def, - NameClass::FieldShorthand { local: _, field } => field, - }; + let def = classify_name(&sema, &name)?.definition(sema.db)?; let nav = def.try_to_nav(sema.db)?; vec![nav] }, @@ -85,9 +82,7 @@ pub(crate) fn reference_definition( name_ref: &ast::NameRef, ) -> ReferenceResult { let name_kind = classify_name_ref(sema, name_ref); - if let Some(def) = name_kind { - let def = def.definition(); - + if let Some(def) = name_kind.and_then(|def| def.definition(sema.db)) { return match def.try_to_nav(sema.db) { Some(nav) => ReferenceResult::Exact(nav), None => ReferenceResult::Approximate(Vec::new()), @@ -133,6 +128,32 @@ mod tests { assert_eq!(expected, FileRange { file_id: nav.file_id, range: nav.focus_or_full_range() }); } + #[test] + fn goto_def_for_extern_crate() { + check( + r#" + //- /main.rs + extern crate std<|>; + //- /std/lib.rs + // empty + //^ file + "#, + ) + } + + #[test] + fn goto_def_for_renamed_extern_crate() { + check( + r#" + //- /main.rs + extern crate std as abc<|>; + //- /std/lib.rs + // empty + //^ file + "#, + ) + } + #[test] fn goto_def_in_items() { check( diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs index aa48cb412f..a632ea6a20 100644 --- a/crates/ra_ide/src/hover.rs +++ b/crates/ra_ide/src/hover.rs @@ -85,8 +85,8 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option classify_name_ref(&sema, &name_ref).map(|d| d.definition()), - ast::Name(name) => classify_name(&sema, &name).map(|d| d.definition()), + ast::NameRef(name_ref) => classify_name_ref(&sema, &name_ref).and_then(|d| d.definition(sema.db)), + ast::Name(name) => classify_name(&sema, &name).and_then(|d| d.definition(sema.db)), _ => None, } }; @@ -304,7 +304,10 @@ fn hover_for_definition(db: &RootDatabase, def: Definition) -> Option { let docs = Documentation::from_ast(&it).map(Into::into); hover_markup(docs, it.short_label(), mod_path) } - _ => None, + ModuleSource::SourceFile(it) => { + let docs = Documentation::from_ast(&it).map(Into::into); + hover_markup(docs, it.short_label(), mod_path) + } }, ModuleDef::Function(it) => from_def_source(db, it, mod_path), ModuleDef::Adt(Adt::Struct(it)) => from_def_source(db, it, mod_path), @@ -1106,6 +1109,46 @@ fn bar() { fo<|>o(); } ); } + #[test] + fn test_hover_extern_crate() { + check( + r#" +//- /main.rs +extern crate st<|>d; +//- /std/lib.rs +//! Standard library for this test +//! +//! Printed? +//! abc123 + "#, + expect![[r#" + *std* + Standard library for this test + + Printed? + abc123 + "#]], + ); + check( + r#" +//- /main.rs +extern crate std as ab<|>c; +//- /std/lib.rs +//! Standard library for this test +//! +//! Printed? +//! abc123 + "#, + expect![[r#" + *abc* + Standard library for this test + + Printed? + abc123 + "#]], + ); + } + #[test] fn test_hover_mod_with_same_name_as_function() { check( diff --git a/crates/ra_ide/src/references.rs b/crates/ra_ide/src/references.rs index cf456630a5..9dd228b9c3 100644 --- a/crates/ra_ide/src/references.rs +++ b/crates/ra_ide/src/references.rs @@ -130,13 +130,13 @@ fn find_name( opt_name: Option, ) -> Option> { if let Some(name) = opt_name { - let def = classify_name(sema, &name)?.definition(); + let def = classify_name(sema, &name)?.definition(sema.db)?; let range = name.syntax().text_range(); return Some(RangeInfo::new(range, def)); } let name_ref = sema.find_node_at_offset_with_descend::(&syntax, position.offset)?; - let def = classify_name_ref(sema, &name_ref)?.definition(); + let def = classify_name_ref(sema, &name_ref)?.definition(sema.db)?; let range = name_ref.syntax().text_range(); Some(RangeInfo::new(range, def)) } diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index 89efe71dab..ec442bcd83 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -483,6 +483,7 @@ fn highlight_element( }; match name_kind { + Some(NameClass::ExternCrate(_)) => HighlightTag::Module.into(), Some(NameClass::Definition(def)) => { highlight_name(db, def) | HighlightModifier::Definition } @@ -500,6 +501,7 @@ fn highlight_element( let name_ref = element.into_node().and_then(ast::NameRef::cast).unwrap(); match classify_name_ref(sema, &name_ref) { Some(name_kind) => match name_kind { + NameRefClass::ExternCrate(_) => HighlightTag::Module.into(), NameRefClass::Definition(def) => { if let Definition::Local(local) = &def { if let Some(name) = local.name(db) { diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ra_ide/src/syntax_highlighting/tests.rs index b9b3580223..b8d60bdc63 100644 --- a/crates/ra_ide/src/syntax_highlighting/tests.rs +++ b/crates/ra_ide/src/syntax_highlighting/tests.rs @@ -380,6 +380,23 @@ macro_rules! noop { ); } +#[test] +fn test_extern_crate() { + check_highlighting( + r#" + //- /main.rs + extern crate std; + extern crate alloc as abc; + //- /std/lib.rs + pub struct S; + //- /alloc/lib.rs + pub struct A + "#, + expect_file!["crates/ra_ide/test_data/highlight_extern_crate.html"], + false, + ); +} + /// Highlights the code given by the `ra_fixture` argument, renders the /// result as HTML, and compares it with the HTML file given as `snapshot`. /// Note that the `snapshot` file is overwritten by the rendered HTML. diff --git a/crates/ra_ide/test_data/highlight_extern_crate.html b/crates/ra_ide/test_data/highlight_extern_crate.html new file mode 100644 index 0000000000..800d894c76 --- /dev/null +++ b/crates/ra_ide/test_data/highlight_extern_crate.html @@ -0,0 +1,40 @@ + + +
extern crate std;
+extern crate alloc as abc;
+
\ No newline at end of file diff --git a/crates/ra_ide_db/src/defs.rs b/crates/ra_ide_db/src/defs.rs index b51000b03f..e2a4f2983c 100644 --- a/crates/ra_ide_db/src/defs.rs +++ b/crates/ra_ide_db/src/defs.rs @@ -6,8 +6,8 @@ // FIXME: this badly needs rename/rewrite (matklad, 2020-02-06). use hir::{ - Field, HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef, Name, PathResolution, - Semantics, TypeParam, Visibility, + db::HirDatabase, Crate, Field, HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef, + Name, PathResolution, Semantics, TypeParam, Visibility, }; use ra_prof::profile; use ra_syntax::{ @@ -80,6 +80,7 @@ impl Definition { #[derive(Debug)] pub enum NameClass { + ExternCrate(Crate), Definition(Definition), /// `None` in `if let None = Some(82) {}` ConstReference(Definition), @@ -90,19 +91,21 @@ pub enum NameClass { } impl NameClass { - pub fn into_definition(self) -> Option { - match self { - NameClass::Definition(it) => Some(it), - NameClass::ConstReference(_) => None, - NameClass::FieldShorthand { local, field: _ } => Some(Definition::Local(local)), - } + pub fn into_definition(self, db: &dyn HirDatabase) -> Option { + Some(match self { + NameClass::ExternCrate(krate) => Definition::ModuleDef(krate.root_module(db)?.into()), + NameClass::Definition(it) => it, + NameClass::ConstReference(_) => return None, + NameClass::FieldShorthand { local, field: _ } => Definition::Local(local), + }) } - pub fn definition(self) -> Definition { - match self { + pub fn definition(self, db: &dyn HirDatabase) -> Option { + Some(match self { + NameClass::ExternCrate(krate) => Definition::ModuleDef(krate.root_module(db)?.into()), NameClass::Definition(it) | NameClass::ConstReference(it) => it, NameClass::FieldShorthand { local: _, field } => field, - } + }) } } @@ -120,32 +123,37 @@ pub fn classify_name(sema: &Semantics, name: &ast::Name) -> Option match_ast! { match parent { ast::Rename(it) => { - let use_tree = it.syntax().parent().and_then(ast::UseTree::cast)?; - let path = use_tree.path()?; - let path_segment = path.segment()?; - let name_ref_class = path_segment - .name_ref() - // The rename might be from a `self` token, so fallback to the name higher - // in the use tree. - .or_else(||{ - if path_segment.self_token().is_none() { - return None; - } + if let Some(use_tree) = it.syntax().parent().and_then(ast::UseTree::cast) { + let path = use_tree.path()?; + let path_segment = path.segment()?; + let name_ref_class = path_segment + .name_ref() + // The rename might be from a `self` token, so fallback to the name higher + // in the use tree. + .or_else(||{ + if path_segment.self_token().is_none() { + return None; + } - let use_tree = use_tree - .syntax() - .parent() - .as_ref() - // Skip over UseTreeList - .and_then(SyntaxNode::parent) - .and_then(ast::UseTree::cast)?; - let path = use_tree.path()?; - let path_segment = path.segment()?; - path_segment.name_ref() - }) - .and_then(|name_ref| classify_name_ref(sema, &name_ref))?; + let use_tree = use_tree + .syntax() + .parent() + .as_ref() + // Skip over UseTreeList + .and_then(SyntaxNode::parent) + .and_then(ast::UseTree::cast)?; + let path = use_tree.path()?; + let path_segment = path.segment()?; + path_segment.name_ref() + }) + .and_then(|name_ref| classify_name_ref(sema, &name_ref))?; - Some(NameClass::Definition(name_ref_class.definition())) + Some(NameClass::Definition(name_ref_class.definition(sema.db)?)) + } else { + let extern_crate = it.syntax().parent().and_then(ast::ExternCrate::cast)?; + let resolved = sema.resolve_extern_crate(&extern_crate)?; + Some(NameClass::ExternCrate(resolved)) + } }, ast::IdentPat(it) => { let local = sema.to_def(&it)?; @@ -220,16 +228,20 @@ pub fn classify_name(sema: &Semantics, name: &ast::Name) -> Option #[derive(Debug)] pub enum NameRefClass { + ExternCrate(Crate), Definition(Definition), FieldShorthand { local: Local, field: Definition }, } impl NameRefClass { - pub fn definition(self) -> Definition { - match self { + pub fn definition(self, db: &dyn HirDatabase) -> Option { + Some(match self { + NameRefClass::ExternCrate(krate) => { + Definition::ModuleDef(krate.root_module(db)?.into()) + } NameRefClass::Definition(def) => def, NameRefClass::FieldShorthand { local, field: _ } => Definition::Local(local), - } + }) } } @@ -307,9 +319,15 @@ pub fn classify_name_ref( } } - let path = name_ref.syntax().ancestors().find_map(ast::Path::cast)?; - let resolved = sema.resolve_path(&path)?; - Some(NameRefClass::Definition(resolved.into())) + if let Some(path) = name_ref.syntax().ancestors().find_map(ast::Path::cast) { + if let Some(resolved) = sema.resolve_path(&path) { + return Some(NameRefClass::Definition(resolved.into())); + } + } + + let extern_crate = ast::ExternCrate::cast(parent)?; + let resolved = sema.resolve_extern_crate(&extern_crate)?; + Some(NameRefClass::ExternCrate(resolved)) } impl From for Definition { diff --git a/crates/ra_ide_db/src/imports_locator.rs b/crates/ra_ide_db/src/imports_locator.rs index 1fba71ff85..9e040973b3 100644 --- a/crates/ra_ide_db/src/imports_locator.rs +++ b/crates/ra_ide_db/src/imports_locator.rs @@ -61,5 +61,5 @@ fn get_name_definition<'a>( candidate_node }; let name = ast::Name::cast(candidate_name_node)?; - classify_name(sema, &name)?.into_definition() + classify_name(sema, &name)?.into_definition(sema.db) } From e43811c1645f78818d5d7fe0054b54a462145847 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sat, 8 Aug 2020 21:53:38 +0300 Subject: [PATCH 004/119] Fix no inlay hints / unresolved tokens until manual edit No we return ContentModified during the workspace loading. This signifies the language client to retry the operation (i.e. the client will continue polling the server while it returns ContentModified). I believe that there might be cases of overly big projects where the backoff logic we have setup in `sendRequestWithRetry` (which we use for inlay hints) might bail too early (currently the largest retry standby time is 10 seconds). However, I've tried on one of my project with 500+ dependencies and it is still enough. --- crates/rust-analyzer/src/main_loop.rs | 10 ++++++++++ editors/code/src/util.ts | 6 +++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index ceddb2b056..d69f7941d8 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs @@ -337,6 +337,16 @@ impl GlobalState { fn on_request(&mut self, request_received: Instant, req: Request) -> Result<()> { self.register_request(&req, request_received); + if self.status == Status::Loading { + self.respond(lsp_server::Response::new_err( + req.id, + // FIXME: i32 should impl From (from() guarantees lossless conversion) + lsp_server::ErrorCode::ContentModified as i32, + "Rust Analyzer is still loading...".to_owned(), + )); + return Ok(()); + } + RequestDispatcher { req: Some(req), global_state: self } .on_sync::(|s, ()| Ok(s.fetch_workspaces()))? .on_sync::(|s, p| handlers::handle_join_lines(s.snapshot(), p))? diff --git a/editors/code/src/util.ts b/editors/code/src/util.ts index 970fedb378..49d2d1c6fb 100644 --- a/editors/code/src/util.ts +++ b/editors/code/src/util.ts @@ -64,7 +64,8 @@ export async function sendRequestWithRetry( param: TParam, token?: vscode.CancellationToken, ): Promise { - for (const delay of [2, 4, 6, 8, 10, null]) { + // The sequence is `10 * (2 ** (2 * n))` where n is 1, 2, 3... + for (const delay of [40, 160, 640, 2560, 10240, null]) { try { return await (token ? client.sendRequest(reqType, param, token) @@ -84,8 +85,7 @@ export async function sendRequestWithRetry( log.warn("LSP request failed", { method: reqType.method, param, error }); throw error; } - - await sleep(10 * (1 << delay)); + await sleep(delay); } } throw 'unreachable'; From 3f2bc813d3b91fbf8a0007eb11c192061571873b Mon Sep 17 00:00:00 2001 From: JmPotato Date: Sun, 9 Aug 2020 21:33:14 +0800 Subject: [PATCH 005/119] format in to_proto::markup_content Signed-off-by: JmPotato --- crates/ra_ide/src/hover.rs | 31 ++++++++++++++++++++++++++++ crates/rust-analyzer/src/to_proto.rs | 3 ++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs index aa48cb412f..385e3e64e3 100644 --- a/crates/ra_ide/src/hover.rs +++ b/crates/ra_ide/src/hover.rs @@ -508,6 +508,37 @@ fn main() { } ); } + #[test] + fn hover_shows_fn_doc() { + check( + r#" +/// # Example +/// ``` +/// # use std::path::Path; +/// # +/// foo(Path::new("hello, world!")) +/// ``` +pub fn foo<|>(_: &Path) {} + +fn main() { } +"#, + expect![[r#" + *foo* + ```rust + pub fn foo(_: &Path) + ``` + ___ + + # Example + ``` + # use std::path::Path; + # + foo(Path::new("hello, world!")) + ``` + "#]], + ); + } + #[test] fn hover_shows_struct_field_info() { // Hovering over the field when instantiating diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index 5eba1f1555..27460db78c 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs @@ -755,7 +755,8 @@ pub(crate) fn runnable( } pub(crate) fn markup_content(markup: Markup) -> lsp_types::MarkupContent { - lsp_types::MarkupContent { kind: lsp_types::MarkupKind::Markdown, value: markup.into() } + let value = crate::markdown::format_docs(markup.as_str()); + lsp_types::MarkupContent { kind: lsp_types::MarkupKind::Markdown, value } } #[cfg(test)] From dbe7ede2eebc1301a40f0e1a3a408e11a86a0e84 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Mon, 10 Aug 2020 00:41:48 +0300 Subject: [PATCH 006/119] Let shutdown request to pass through when status == Loading --- crates/rust-analyzer/src/main_loop.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index d69f7941d8..eb7c96933c 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs @@ -337,7 +337,7 @@ impl GlobalState { fn on_request(&mut self, request_received: Instant, req: Request) -> Result<()> { self.register_request(&req, request_received); - if self.status == Status::Loading { + if self.status == Status::Loading && req.method != "shutdown" { self.respond(lsp_server::Response::new_err( req.id, // FIXME: i32 should impl From (from() guarantees lossless conversion) From 7252babc136b351d5011a78878607c7aaeea5ed8 Mon Sep 17 00:00:00 2001 From: Jeremy Kolb Date: Sun, 9 Aug 2020 17:57:27 -0400 Subject: [PATCH 007/119] Remove workaround for semantic token flickering See: https://github.com/microsoft/vscode-languageserver-node/issues/576#issuecomment-593384479 This has been fixed since vscode 1.44 --- editors/code/src/client.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts index 18948cb3c4..bd7a150f0a 100644 --- a/editors/code/src/client.ts +++ b/editors/code/src/client.ts @@ -4,7 +4,7 @@ import * as ra from '../src/lsp_ext'; import * as Is from 'vscode-languageclient/lib/utils/is'; import { CallHierarchyFeature } from 'vscode-languageclient/lib/callHierarchy.proposed'; -import { SemanticTokensFeature, DocumentSemanticsTokensSignature } from 'vscode-languageclient/lib/semanticTokens.proposed'; +import { SemanticTokensFeature } from 'vscode-languageclient/lib/semanticTokens.proposed'; import { assert } from './util'; function renderCommand(cmd: ra.CommandLink) { @@ -44,12 +44,6 @@ export function createClient(serverPath: string, cwd: string): lc.LanguageClient diagnosticCollectionName: "rustc", traceOutputChannel, middleware: { - // Workaround for https://github.com/microsoft/vscode-languageserver-node/issues/576 - async provideDocumentSemanticTokens(document: vscode.TextDocument, token: vscode.CancellationToken, next: DocumentSemanticsTokensSignature) { - const res = await next(document, token); - if (res === undefined) throw new Error('busy'); - return res; - }, async provideHover(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken, _next: lc.ProvideHoverSignature) { return client.sendRequest(lc.HoverRequest.type, client.code2ProtocolConverter.asTextDocumentPositionParams(document, position), token).then( (result) => { From 58c97bdcbf6d7df218028f75373cfc4916043693 Mon Sep 17 00:00:00 2001 From: Jeremy Kolb Date: Sun, 9 Aug 2020 18:09:27 -0400 Subject: [PATCH 008/119] Remove 'as any' --- editors/code/src/client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts index bd7a150f0a..f5db55b8cc 100644 --- a/editors/code/src/client.ts +++ b/editors/code/src/client.ts @@ -129,7 +129,7 @@ export function createClient(serverPath: string, cwd: string): lc.LanguageClient ); } - } as any + } }; const client = new lc.LanguageClient( From bf9b4578bbe038501ef7c337e22b448de477f61c Mon Sep 17 00:00:00 2001 From: Paul Daniel Faria Date: Sun, 9 Aug 2020 18:52:19 -0400 Subject: [PATCH 009/119] Remove Option<...> from result of Crate::root_module There doesn't seem to be any need for it, and removing it simplies several paths of code that depend on it. --- crates/ra_assists/src/utils.rs | 2 +- crates/ra_hir/src/code_model.rs | 4 ++-- crates/ra_ide/src/goto_definition.rs | 5 +++-- crates/ra_ide/src/hover.rs | 4 ++-- crates/ra_ide/src/references.rs | 4 ++-- crates/ra_ide_db/src/defs.rs | 22 +++++++++---------- .../rust-analyzer/src/cli/analysis_stats.rs | 2 +- crates/rust-analyzer/src/cli/diagnostics.rs | 2 +- 8 files changed, 22 insertions(+), 23 deletions(-) diff --git a/crates/ra_assists/src/utils.rs b/crates/ra_assists/src/utils.rs index 54d5678d14..0de6fdf3fb 100644 --- a/crates/ra_assists/src/utils.rs +++ b/crates/ra_assists/src/utils.rs @@ -257,7 +257,7 @@ pub use prelude::*; .find(|dep| &dep.name.to_string() == std_crate)? .krate; - let mut module = std_crate.root_module(db)?; + let mut module = std_crate.root_module(db); for segment in path { module = module.children(db).find_map(|child| { let name = child.name(db)?; diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 27cdabea03..44456e49e2 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs @@ -83,9 +83,9 @@ impl Crate { .collect() } - pub fn root_module(self, db: &dyn HirDatabase) -> Option { + pub fn root_module(self, db: &dyn HirDatabase) -> Module { let module_id = db.crate_def_map(self.id).root; - Some(Module::new(self, module_id)) + Module::new(self, module_id) } pub fn root_file(self, db: &dyn HirDatabase) -> FileId { diff --git a/crates/ra_ide/src/goto_definition.rs b/crates/ra_ide/src/goto_definition.rs index b44b6fe22f..45389fd23f 100644 --- a/crates/ra_ide/src/goto_definition.rs +++ b/crates/ra_ide/src/goto_definition.rs @@ -40,7 +40,7 @@ pub(crate) fn goto_definition( reference_definition(&sema, &name_ref).to_vec() }, ast::Name(name) => { - let def = classify_name(&sema, &name)?.definition(sema.db)?; + let def = classify_name(&sema, &name)?.definition(sema.db); let nav = def.try_to_nav(sema.db)?; vec![nav] }, @@ -82,7 +82,8 @@ pub(crate) fn reference_definition( name_ref: &ast::NameRef, ) -> ReferenceResult { let name_kind = classify_name_ref(sema, name_ref); - if let Some(def) = name_kind.and_then(|def| def.definition(sema.db)) { + if let Some(def) = name_kind { + let def = def.definition(sema.db); return match def.try_to_nav(sema.db) { Some(nav) => ReferenceResult::Exact(nav), None => ReferenceResult::Approximate(Vec::new()), diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs index a632ea6a20..f6e493817b 100644 --- a/crates/ra_ide/src/hover.rs +++ b/crates/ra_ide/src/hover.rs @@ -85,8 +85,8 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option classify_name_ref(&sema, &name_ref).and_then(|d| d.definition(sema.db)), - ast::Name(name) => classify_name(&sema, &name).and_then(|d| d.definition(sema.db)), + ast::NameRef(name_ref) => classify_name_ref(&sema, &name_ref).map(|d| d.definition(sema.db)), + ast::Name(name) => classify_name(&sema, &name).map(|d| d.definition(sema.db)), _ => None, } }; diff --git a/crates/ra_ide/src/references.rs b/crates/ra_ide/src/references.rs index 9dd228b9c3..453985de3e 100644 --- a/crates/ra_ide/src/references.rs +++ b/crates/ra_ide/src/references.rs @@ -130,13 +130,13 @@ fn find_name( opt_name: Option, ) -> Option> { if let Some(name) = opt_name { - let def = classify_name(sema, &name)?.definition(sema.db)?; + let def = classify_name(sema, &name)?.definition(sema.db); let range = name.syntax().text_range(); return Some(RangeInfo::new(range, def)); } let name_ref = sema.find_node_at_offset_with_descend::(&syntax, position.offset)?; - let def = classify_name_ref(sema, &name_ref)?.definition(sema.db)?; + let def = classify_name_ref(sema, &name_ref)?.definition(sema.db); let range = name_ref.syntax().text_range(); Some(RangeInfo::new(range, def)) } diff --git a/crates/ra_ide_db/src/defs.rs b/crates/ra_ide_db/src/defs.rs index e2a4f2983c..9bb95277d0 100644 --- a/crates/ra_ide_db/src/defs.rs +++ b/crates/ra_ide_db/src/defs.rs @@ -93,19 +93,19 @@ pub enum NameClass { impl NameClass { pub fn into_definition(self, db: &dyn HirDatabase) -> Option { Some(match self { - NameClass::ExternCrate(krate) => Definition::ModuleDef(krate.root_module(db)?.into()), + NameClass::ExternCrate(krate) => Definition::ModuleDef(krate.root_module(db).into()), NameClass::Definition(it) => it, NameClass::ConstReference(_) => return None, NameClass::FieldShorthand { local, field: _ } => Definition::Local(local), }) } - pub fn definition(self, db: &dyn HirDatabase) -> Option { - Some(match self { - NameClass::ExternCrate(krate) => Definition::ModuleDef(krate.root_module(db)?.into()), + pub fn definition(self, db: &dyn HirDatabase) -> Definition { + match self { + NameClass::ExternCrate(krate) => Definition::ModuleDef(krate.root_module(db).into()), NameClass::Definition(it) | NameClass::ConstReference(it) => it, NameClass::FieldShorthand { local: _, field } => field, - }) + } } } @@ -148,7 +148,7 @@ pub fn classify_name(sema: &Semantics, name: &ast::Name) -> Option }) .and_then(|name_ref| classify_name_ref(sema, &name_ref))?; - Some(NameClass::Definition(name_ref_class.definition(sema.db)?)) + Some(NameClass::Definition(name_ref_class.definition(sema.db))) } else { let extern_crate = it.syntax().parent().and_then(ast::ExternCrate::cast)?; let resolved = sema.resolve_extern_crate(&extern_crate)?; @@ -234,14 +234,12 @@ pub enum NameRefClass { } impl NameRefClass { - pub fn definition(self, db: &dyn HirDatabase) -> Option { - Some(match self { - NameRefClass::ExternCrate(krate) => { - Definition::ModuleDef(krate.root_module(db)?.into()) - } + pub fn definition(self, db: &dyn HirDatabase) -> Definition { + match self { + NameRefClass::ExternCrate(krate) => Definition::ModuleDef(krate.root_module(db).into()), NameRefClass::Definition(def) => def, NameRefClass::FieldShorthand { local, field: _ } => Definition::Local(local), - }) + } } } diff --git a/crates/rust-analyzer/src/cli/analysis_stats.rs b/crates/rust-analyzer/src/cli/analysis_stats.rs index 721d41a58f..0d386841e5 100644 --- a/crates/rust-analyzer/src/cli/analysis_stats.rs +++ b/crates/rust-analyzer/src/cli/analysis_stats.rs @@ -72,7 +72,7 @@ impl AnalysisStatsCmd { shuffle(&mut rng, &mut krates); } for krate in krates { - let module = krate.root_module(db).expect("crate without root module"); + let module = krate.root_module(db); let file_id = module.definition_source(db).file_id; let file_id = file_id.original_file(db); let source_root = db.file_source_root(file_id); diff --git a/crates/rust-analyzer/src/cli/diagnostics.rs b/crates/rust-analyzer/src/cli/diagnostics.rs index 4ac8c8772e..f17fc5dfe9 100644 --- a/crates/rust-analyzer/src/cli/diagnostics.rs +++ b/crates/rust-analyzer/src/cli/diagnostics.rs @@ -28,7 +28,7 @@ pub fn diagnostics( let mut work = Vec::new(); let krates = Crate::all(db); for krate in krates { - let module = krate.root_module(db).expect("crate without root module"); + let module = krate.root_module(db); let file_id = module.definition_source(db).file_id; let file_id = file_id.original_file(db); let source_root = db.file_source_root(file_id); From 4d9c8821e5c328f29b77667c86cabb3689947fd2 Mon Sep 17 00:00:00 2001 From: JmPotato Date: Mon, 10 Aug 2020 14:02:40 +0800 Subject: [PATCH 010/119] Show const body in short_label Signed-off-by: JmPotato --- crates/ra_ide/src/display/short_label.rs | 10 +++++++++- crates/ra_ide/src/hover.rs | 8 ++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/crates/ra_ide/src/display/short_label.rs b/crates/ra_ide/src/display/short_label.rs index b5ff9fa2de..d8acb3be76 100644 --- a/crates/ra_ide/src/display/short_label.rs +++ b/crates/ra_ide/src/display/short_label.rs @@ -61,7 +61,15 @@ impl ShortLabel for ast::TypeAlias { impl ShortLabel for ast::Const { fn short_label(&self) -> Option { - short_label_from_ty(self, self.ty(), "const ") + match short_label_from_ty(self, self.ty(), "const ") { + Some(buf) => { + let mut new_buf = buf; + let body = self.body().unwrap(); + format_to!(new_buf, " = {}", body.syntax()); + Some(new_buf) + } + None => None, + } } } diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs index 9c7348898a..f66f62bfb5 100644 --- a/crates/ra_ide/src/hover.rs +++ b/crates/ra_ide/src/hover.rs @@ -590,16 +590,16 @@ fn main() { #[test] fn hover_const_static() { check( - r#"const foo<|>: u32 = 0;"#, + r#"const foo<|>: u32 = 123;"#, expect![[r#" *foo* ```rust - const foo: u32 + const foo: u32 = 123 ``` "#]], ); check( - r#"static foo<|>: u32 = 0;"#, + r#"static foo<|>: u32 = 456;"#, expect![[r#" *foo* ```rust @@ -834,7 +834,7 @@ fn main() { expect![[r#" *C* ```rust - const C: u32 + const C: u32 = 1 ``` "#]], ) From 958b91c1e8394129216d1b8378d726f937592d3f Mon Sep 17 00:00:00 2001 From: JmPotato Date: Mon, 10 Aug 2020 17:51:45 +0800 Subject: [PATCH 011/119] Better codes Signed-off-by: JmPotato --- crates/ra_ide/src/display/short_label.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/crates/ra_ide/src/display/short_label.rs b/crates/ra_ide/src/display/short_label.rs index d8acb3be76..010c34705c 100644 --- a/crates/ra_ide/src/display/short_label.rs +++ b/crates/ra_ide/src/display/short_label.rs @@ -61,15 +61,11 @@ impl ShortLabel for ast::TypeAlias { impl ShortLabel for ast::Const { fn short_label(&self) -> Option { - match short_label_from_ty(self, self.ty(), "const ") { - Some(buf) => { - let mut new_buf = buf; - let body = self.body().unwrap(); - format_to!(new_buf, " = {}", body.syntax()); - Some(new_buf) - } - None => None, + let mut new_buf = short_label_from_ty(self, self.ty(), "const ")?; + if let Some(expr) = self.body() { + format_to!(new_buf, " = {}", expr.syntax()); } + Some(new_buf) } } From 6344a7f362b19eaf71547766135ece160aa3389e Mon Sep 17 00:00:00 2001 From: Igor Aleksanov Date: Mon, 10 Aug 2020 15:05:01 +0300 Subject: [PATCH 012/119] Fix clippy warnings --- crates/expect/src/lib.rs | 2 +- crates/flycheck/src/lib.rs | 6 +++--- crates/ra_arena/src/map.rs | 10 +++++----- crates/ra_mbe/src/mbe_expander/matcher.rs | 2 +- .../ra_parser/src/grammar/expressions/atom.rs | 8 +++----- crates/ra_proc_macro/src/process.rs | 2 +- crates/ra_text_edit/src/lib.rs | 13 ++++++++---- crates/ra_tt/src/lib.rs | 2 +- crates/stdx/src/lib.rs | 4 ++-- crates/vfs/src/file_set.rs | 3 +++ xtask/src/codegen/gen_syntax.rs | 20 +++++++++---------- 11 files changed, 38 insertions(+), 34 deletions(-) diff --git a/crates/expect/src/lib.rs b/crates/expect/src/lib.rs index 21a458d477..bd83895f78 100644 --- a/crates/expect/src/lib.rs +++ b/crates/expect/src/lib.rs @@ -74,7 +74,7 @@ impl fmt::Display for Position { impl Expect { pub fn assert_eq(&self, actual: &str) { let trimmed = self.trimmed(); - if &trimmed == actual { + if trimmed == actual { return; } Runtime::fail_expect(self, &trimmed, actual); diff --git a/crates/flycheck/src/lib.rs b/crates/flycheck/src/lib.rs index 7c38f5ef9d..36e0e085ac 100644 --- a/crates/flycheck/src/lib.rs +++ b/crates/flycheck/src/lib.rs @@ -108,7 +108,7 @@ struct FlycheckActor { enum Event { Restart(Restart), - CheckEvent(Option), + CheckEvent(Option>), } impl FlycheckActor { @@ -123,7 +123,7 @@ impl FlycheckActor { let check_chan = self.cargo_handle.as_ref().map(|cargo| &cargo.receiver); select! { recv(inbox) -> msg => msg.ok().map(Event::Restart), - recv(check_chan.unwrap_or(&never())) -> msg => Some(Event::CheckEvent(msg.ok())), + recv(check_chan.unwrap_or(&never())) -> msg => Some(Event::CheckEvent(msg.ok().map(Box::new))), } } fn run(mut self, inbox: Receiver) { @@ -149,7 +149,7 @@ impl FlycheckActor { let res = cargo_handle.join(); self.send(Message::Progress(Progress::DidFinish(res))); } - Event::CheckEvent(Some(message)) => match message { + Event::CheckEvent(Some(message)) => match *message { cargo_metadata::Message::CompilerArtifact(msg) => { self.send(Message::Progress(Progress::DidCheckCrate(msg.target.name))); } diff --git a/crates/ra_arena/src/map.rs b/crates/ra_arena/src/map.rs index 0f33907c0a..c1b58712c1 100644 --- a/crates/ra_arena/src/map.rs +++ b/crates/ra_arena/src/map.rs @@ -13,18 +13,18 @@ pub struct ArenaMap { impl ArenaMap, V> { pub fn insert(&mut self, id: Idx, t: V) { - let idx = Self::to_idx(id); + let idx = Self::into_idx(id); self.v.resize_with((idx + 1).max(self.v.len()), || None); self.v[idx] = Some(t); } pub fn get(&self, id: Idx) -> Option<&V> { - self.v.get(Self::to_idx(id)).and_then(|it| it.as_ref()) + self.v.get(Self::into_idx(id)).and_then(|it| it.as_ref()) } pub fn get_mut(&mut self, id: Idx) -> Option<&mut V> { - self.v.get_mut(Self::to_idx(id)).and_then(|it| it.as_mut()) + self.v.get_mut(Self::into_idx(id)).and_then(|it| it.as_mut()) } pub fn values(&self) -> impl Iterator { @@ -39,7 +39,7 @@ impl ArenaMap, V> { self.v.iter().enumerate().filter_map(|(idx, o)| Some((Self::from_idx(idx), o.as_ref()?))) } - fn to_idx(id: Idx) -> usize { + fn into_idx(id: Idx) -> usize { u32::from(id.into_raw()) as usize } @@ -51,7 +51,7 @@ impl ArenaMap, V> { impl std::ops::Index> for ArenaMap, T> { type Output = T; fn index(&self, id: Idx) -> &T { - self.v[Self::to_idx(id)].as_ref().unwrap() + self.v[Self::into_idx(id)].as_ref().unwrap() } } diff --git a/crates/ra_mbe/src/mbe_expander/matcher.rs b/crates/ra_mbe/src/mbe_expander/matcher.rs index f9e515b811..933a3a3b5e 100644 --- a/crates/ra_mbe/src/mbe_expander/matcher.rs +++ b/crates/ra_mbe/src/mbe_expander/matcher.rs @@ -276,7 +276,7 @@ impl<'a> TtIter<'a> { Ok(tt::Subtree { delimiter: None, token_trees: vec![ - tt::Leaf::Punct(punct.clone()).into(), + tt::Leaf::Punct(*punct).into(), tt::Leaf::Ident(ident.clone()).into(), ], } diff --git a/crates/ra_parser/src/grammar/expressions/atom.rs b/crates/ra_parser/src/grammar/expressions/atom.rs index 0b01d3bc64..ca6569c9f2 100644 --- a/crates/ra_parser/src/grammar/expressions/atom.rs +++ b/crates/ra_parser/src/grammar/expressions/atom.rs @@ -243,12 +243,10 @@ fn lambda_expr(p: &mut Parser) -> CompletedMarker { // test lambda_ret_block // fn main() { || -> i32 { 92 }(); } block_expr(p); + } else if p.at_ts(EXPR_FIRST) { + expr(p); } else { - if p.at_ts(EXPR_FIRST) { - expr(p); - } else { - p.error("expected expression"); - } + p.error("expected expression"); } m.complete(p, CLOSURE_EXPR) } diff --git a/crates/ra_proc_macro/src/process.rs b/crates/ra_proc_macro/src/process.rs index 5bcdacb487..37dd3f4965 100644 --- a/crates/ra_proc_macro/src/process.rs +++ b/crates/ra_proc_macro/src/process.rs @@ -90,7 +90,7 @@ impl ProcMacroProcessSrv { } Some(it) => it, }; - sender.send(Task { req: req.into(), result_tx }).unwrap(); + sender.send(Task { req, result_tx }).unwrap(); let res = result_rx .recv() .map_err(|_| ra_tt::ExpansionError::Unknown("Proc macro thread is closed.".into()))?; diff --git a/crates/ra_text_edit/src/lib.rs b/crates/ra_text_edit/src/lib.rs index 25554f583e..d68791cf1f 100644 --- a/crates/ra_text_edit/src/lib.rs +++ b/crates/ra_text_edit/src/lib.rs @@ -76,10 +76,6 @@ impl TextEdit { self.indels.iter() } - pub fn into_iter(self) -> vec::IntoIter { - self.indels.into_iter() - } - pub fn apply(&self, text: &mut String) { match self.len() { 0 => return, @@ -141,6 +137,15 @@ impl TextEdit { } } +impl IntoIterator for TextEdit { + type Item = Indel; + type IntoIter = vec::IntoIter; + + fn into_iter(self) -> Self::IntoIter { + self.indels.into_iter() + } +} + impl TextEditBuilder { pub fn replace(&mut self, range: TextRange, replace_with: String) { self.indels.push(Indel::replace(range, replace_with)) diff --git a/crates/ra_tt/src/lib.rs b/crates/ra_tt/src/lib.rs index 8faf1cc679..20c3f5eabf 100644 --- a/crates/ra_tt/src/lib.rs +++ b/crates/ra_tt/src/lib.rs @@ -107,7 +107,7 @@ fn print_debug_subtree(f: &mut fmt::Formatter<'_>, subtree: &Subtree, level: usi for (idx, child) in subtree.token_trees.iter().enumerate() { print_debug_token(f, child, level + 1)?; if idx != subtree.token_trees.len() - 1 { - writeln!(f, "")?; + writeln!(f)?; } } } diff --git a/crates/stdx/src/lib.rs b/crates/stdx/src/lib.rs index b65875c96e..00bfcd29ed 100644 --- a/crates/stdx/src/lib.rs +++ b/crates/stdx/src/lib.rs @@ -10,7 +10,7 @@ pub fn is_ci() -> bool { pub trait SepBy: Sized { /// Returns an `impl fmt::Display`, which joins elements via a separator. - fn sep_by<'a>(self, sep: &'a str) -> SepByBuilder<'a, Self>; + fn sep_by(self, sep: &str) -> SepByBuilder<'_, Self>; } impl SepBy for I @@ -18,7 +18,7 @@ where I: Iterator, I::Item: fmt::Display, { - fn sep_by<'a>(self, sep: &'a str) -> SepByBuilder<'a, Self> { + fn sep_by(self, sep: &str) -> SepByBuilder<'_, Self> { SepByBuilder::new(sep, self) } } diff --git a/crates/vfs/src/file_set.rs b/crates/vfs/src/file_set.rs index e9196fcd2f..9f11268eee 100644 --- a/crates/vfs/src/file_set.rs +++ b/crates/vfs/src/file_set.rs @@ -19,6 +19,9 @@ impl FileSet { pub fn len(&self) -> usize { self.files.len() } + pub fn is_empty(&self) -> bool { + self.len() == 0 + } pub fn resolve_path(&self, anchor: FileId, path: &str) -> Option { let mut base = self.paths[&anchor].clone(); base.pop(); diff --git a/xtask/src/codegen/gen_syntax.rs b/xtask/src/codegen/gen_syntax.rs index cafad8070d..af9d63b06e 100644 --- a/xtask/src/codegen/gen_syntax.rs +++ b/xtask/src/codegen/gen_syntax.rs @@ -91,18 +91,16 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: &AstSrc) -> Result { support::children(&self.syntax) } } - } else { - if let Some(token_kind) = field.token_kind() { - quote! { - pub fn #method_name(&self) -> Option<#ty> { - support::token(&self.syntax, #token_kind) - } + } else if let Some(token_kind) = field.token_kind() { + quote! { + pub fn #method_name(&self) -> Option<#ty> { + support::token(&self.syntax, #token_kind) } - } else { - quote! { - pub fn #method_name(&self) -> Option<#ty> { - support::child(&self.syntax) - } + } + } else { + quote! { + pub fn #method_name(&self) -> Option<#ty> { + support::child(&self.syntax) } } } From 263f9a7f231a474dd56d02adbcd7c57d079e88fd Mon Sep 17 00:00:00 2001 From: Paul Daniel Faria Date: Wed, 3 Jun 2020 23:38:25 -0400 Subject: [PATCH 013/119] Add tracking of packed repr, use it to highlight unsafe refs Taking a reference to a misaligned field on a packed struct is an unsafe operation. Highlight that behavior. Currently, the misaligned part isn't tracked, so this highlight is a bit too aggressive. --- crates/ra_hir/src/code_model.rs | 18 ++++++ crates/ra_hir_def/src/adt.rs | 56 +++++++++++++++++-- crates/ra_ide/src/syntax_highlighting.rs | 24 ++++++++ .../ra_ide/src/syntax_highlighting/tests.rs | 11 ++++ 4 files changed, 105 insertions(+), 4 deletions(-) diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 44456e49e2..6f9c56d294 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs @@ -4,6 +4,7 @@ use std::{iter, sync::Arc}; use arrayvec::ArrayVec; use either::Either; use hir_def::{ + adt::ReprKind, adt::StructKind, adt::VariantData, builtin_type::BuiltinType, @@ -431,6 +432,10 @@ impl Struct { Type::from_def(db, self.id.lookup(db.upcast()).container.module(db.upcast()).krate, self.id) } + pub fn is_packed(self, db: &dyn HirDatabase) -> bool { + matches!(db.struct_data(self.id).repr, Some(ReprKind::Packed)) + } + fn variant_data(self, db: &dyn HirDatabase) -> Arc { db.struct_data(self.id).variant_data.clone() } @@ -1253,6 +1258,19 @@ impl Type { ) } + pub fn is_packed(&self, db: &dyn HirDatabase) -> bool { + let adt_id = match self.ty.value { + Ty::Apply(ApplicationTy { ctor: TypeCtor::Adt(adt_id), .. }) => adt_id, + _ => return false, + }; + + let adt = adt_id.into(); + match adt { + Adt::Struct(s) => s.is_packed(db), + _ => false, + } + } + pub fn is_raw_ptr(&self) -> bool { matches!(&self.ty.value, Ty::Apply(ApplicationTy { ctor: TypeCtor::RawPtr(..), .. })) } diff --git a/crates/ra_hir_def/src/adt.rs b/crates/ra_hir_def/src/adt.rs index 6cb56a1cd0..6d59c86428 100644 --- a/crates/ra_hir_def/src/adt.rs +++ b/crates/ra_hir_def/src/adt.rs @@ -9,11 +9,13 @@ use hir_expand::{ }; use ra_arena::{map::ArenaMap, Arena}; use ra_syntax::ast::{self, NameOwner, VisibilityOwner}; +use tt::{Delimiter, DelimiterKind, Leaf, Subtree, TokenTree}; use crate::{ + attr::AttrInput, body::{CfgExpander, LowerCtx}, db::DefDatabase, - item_tree::{Field, Fields, ItemTree}, + item_tree::{AttrOwner, Field, Fields, ItemTree, ModItem}, src::HasChildSource, src::HasSource, trace::Trace, @@ -29,6 +31,7 @@ use ra_cfg::CfgOptions; pub struct StructData { pub name: Name, pub variant_data: Arc, + pub repr: Option, } #[derive(Debug, Clone, PartialEq, Eq)] @@ -58,26 +61,71 @@ pub struct FieldData { pub visibility: RawVisibility, } +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum ReprKind { + Packed, + Other, +} + +fn repr_from_value(item_tree: &ItemTree, of: AttrOwner) -> Option { + item_tree.attrs(of).iter().find_map(|a| { + if a.path.segments[0].to_string() == "repr" { + if let Some(AttrInput::TokenTree(subtree)) = &a.input { + parse_repr_tt(subtree) + } else { + None + } + } else { + None + } + }) +} + +fn parse_repr_tt(tt: &Subtree) -> Option { + match tt.delimiter { + Some(Delimiter { kind: DelimiterKind::Parenthesis, .. }) => {} + _ => return None, + } + + let mut it = tt.token_trees.iter(); + match it.next() { + None => None, + Some(TokenTree::Leaf(Leaf::Ident(ident))) if ident.text == "packed" => { + Some(ReprKind::Packed) + } + _ => Some(ReprKind::Other), + } +} + impl StructData { pub(crate) fn struct_data_query(db: &dyn DefDatabase, id: StructId) -> Arc { let loc = id.lookup(db); let item_tree = db.item_tree(loc.id.file_id); + let repr = repr_from_value(&item_tree, ModItem::from(loc.id.value).into()); let cfg_options = db.crate_graph()[loc.container.module(db).krate].cfg_options.clone(); let strukt = &item_tree[loc.id.value]; let variant_data = lower_fields(&item_tree, &cfg_options, &strukt.fields); - - Arc::new(StructData { name: strukt.name.clone(), variant_data: Arc::new(variant_data) }) + Arc::new(StructData { + name: strukt.name.clone(), + variant_data: Arc::new(variant_data), + repr, + }) } pub(crate) fn union_data_query(db: &dyn DefDatabase, id: UnionId) -> Arc { let loc = id.lookup(db); let item_tree = db.item_tree(loc.id.file_id); + let repr = repr_from_value(&item_tree, ModItem::from(loc.id.value).into()); let cfg_options = db.crate_graph()[loc.container.module(db).krate].cfg_options.clone(); let union = &item_tree[loc.id.value]; let variant_data = lower_fields(&item_tree, &cfg_options, &union.fields); - Arc::new(StructData { name: union.name.clone(), variant_data: Arc::new(variant_data) }) + Arc::new(StructData { + name: union.name.clone(), + variant_data: Arc::new(variant_data), + repr, + }) } } diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index 6b7874460a..0cab684eb4 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -565,6 +565,30 @@ fn highlight_element( _ => h, } } + REF_EXPR => { + let ref_expr = element.into_node().and_then(ast::RefExpr::cast)?; + let expr = ref_expr.expr()?; + let field_expr = match expr { + ast::Expr::FieldExpr(fe) => fe, + _ => return None, + }; + + let expr = field_expr.expr()?; + let ty = match sema.type_of_expr(&expr) { + Some(ty) => ty, + None => { + println!("No type :("); + return None; + } + }; + if !ty.is_packed(db) { + return None; + } + + // FIXME account for alignment... somehow + + Highlight::new(HighlightTag::Operator) | HighlightModifier::Unsafe + } p if p.is_punct() => match p { T![::] | T![->] | T![=>] | T![&] | T![..] | T![=] | T![@] => { HighlightTag::Operator.into() diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ra_ide/src/syntax_highlighting/tests.rs index 09062c38e7..f2c078d347 100644 --- a/crates/ra_ide/src/syntax_highlighting/tests.rs +++ b/crates/ra_ide/src/syntax_highlighting/tests.rs @@ -292,6 +292,13 @@ struct TypeForStaticMut { static mut global_mut: TypeForStaticMut = TypeForStaticMut { a: 0 }; +#[repr(packed)] +struct Packed { + a: u16, + b: u8, + c: u32, +} + fn main() { let x = &5 as *const usize; let u = Union { b: 0 }; @@ -306,6 +313,10 @@ fn main() { let y = *(x); let z = -x; let a = global_mut.a; + let packed = Packed { a: 0, b: 0, c: 0 }; + let a = &packed.a; + let b = &packed.b; + let c = &packed.c; } } "# From fd30134cf84b134259fe8140e513b152e37f3f88 Mon Sep 17 00:00:00 2001 From: Paul Daniel Faria Date: Mon, 15 Jun 2020 07:19:45 -0400 Subject: [PATCH 014/119] Remove token tree from ReprKind::Other variant, expose ReprKind higher, remove debug println. --- crates/ra_hir/src/code_model.rs | 6 +++--- crates/ra_ide/src/syntax_highlighting.rs | 8 +------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 6f9c56d294..0007d7fa88 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs @@ -432,8 +432,8 @@ impl Struct { Type::from_def(db, self.id.lookup(db.upcast()).container.module(db.upcast()).krate, self.id) } - pub fn is_packed(self, db: &dyn HirDatabase) -> bool { - matches!(db.struct_data(self.id).repr, Some(ReprKind::Packed)) + pub fn repr(self, db: &dyn HirDatabase) -> Option { + db.struct_data(self.id).repr.clone() } fn variant_data(self, db: &dyn HirDatabase) -> Arc { @@ -1266,7 +1266,7 @@ impl Type { let adt = adt_id.into(); match adt { - Adt::Struct(s) => s.is_packed(db), + Adt::Struct(s) => matches!(s.repr(db), Some(ReprKind::Packed)), _ => false, } } diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index 0cab684eb4..b82b51efda 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -574,13 +574,7 @@ fn highlight_element( }; let expr = field_expr.expr()?; - let ty = match sema.type_of_expr(&expr) { - Some(ty) => ty, - None => { - println!("No type :("); - return None; - } - }; + let ty = sema.type_of_expr(&expr)?; if !ty.is_packed(db) { return None; } From 4a4b1f48efeff4ebe578eb92b7bb8338d0181a83 Mon Sep 17 00:00:00 2001 From: Paul Daniel Faria Date: Mon, 15 Jun 2020 07:41:13 -0400 Subject: [PATCH 015/119] Limit scope of unsafe to & instead of all ref exprs, add test showing missing support for autoref behavior --- crates/ra_ide/src/syntax_highlighting.rs | 2 +- .../ra_ide/src/syntax_highlighting/tests.rs | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index b82b51efda..c5098189b3 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -565,7 +565,7 @@ fn highlight_element( _ => h, } } - REF_EXPR => { + T![&] => { let ref_expr = element.into_node().and_then(ast::RefExpr::cast)?; let expr = ref_expr.expr()?; let field_expr = match expr { diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ra_ide/src/syntax_highlighting/tests.rs index f2c078d347..c408058501 100644 --- a/crates/ra_ide/src/syntax_highlighting/tests.rs +++ b/crates/ra_ide/src/syntax_highlighting/tests.rs @@ -299,6 +299,23 @@ struct Packed { c: u32, } +trait DoTheAutoref { + fn calls_autoref(&self); +} + +struct NeedsAlign { + a: u16 +} + +#[repr(packed)] +struct HasAligned { + a: NeedsAlign +} + +impl DoTheAutoref for NeedsAlign { + fn calls_autored(&self) {} +} + fn main() { let x = &5 as *const usize; let u = Union { b: 0 }; @@ -317,6 +334,8 @@ fn main() { let a = &packed.a; let b = &packed.b; let c = &packed.c; + let h = HasAligned{ a: NeedsAlign { a: 1 } }; + h.a.calls_autoref(); } } "# From c9e670b8754b8262b5071a96c32cbcd22ff968f4 Mon Sep 17 00:00:00 2001 From: Paul Daniel Faria Date: Mon, 15 Jun 2020 08:21:32 -0400 Subject: [PATCH 016/119] Update FIXME comment to be more useful --- crates/ra_ide/src/syntax_highlighting.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index c5098189b3..9e8419c5f8 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -579,7 +579,8 @@ fn highlight_element( return None; } - // FIXME account for alignment... somehow + // FIXME This needs layout computation to be correct. It will highlight + // more than it should with the current implementation. Highlight::new(HighlightTag::Operator) | HighlightModifier::Unsafe } From 38440d53d8329ac9f3f2013c6e32b3f69b069c72 Mon Sep 17 00:00:00 2001 From: Paul Daniel Faria Date: Sat, 27 Jun 2020 14:42:42 -0400 Subject: [PATCH 017/119] Cleanup repr check, fix packed repr check and test --- crates/ra_hir_def/src/adt.rs | 11 ++++++++--- crates/ra_ide/src/syntax_highlighting.rs | 4 ++-- crates/ra_ide/src/syntax_highlighting/tests.rs | 14 +++++--------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/crates/ra_hir_def/src/adt.rs b/crates/ra_hir_def/src/adt.rs index 6d59c86428..4ba6944805 100644 --- a/crates/ra_hir_def/src/adt.rs +++ b/crates/ra_hir_def/src/adt.rs @@ -12,10 +12,11 @@ use ra_syntax::ast::{self, NameOwner, VisibilityOwner}; use tt::{Delimiter, DelimiterKind, Leaf, Subtree, TokenTree}; use crate::{ - attr::AttrInput, + attr::{Attr, AttrInput}, body::{CfgExpander, LowerCtx}, db::DefDatabase, item_tree::{AttrOwner, Field, Fields, ItemTree, ModItem}, + path::{ModPath, PathKind}, src::HasChildSource, src::HasSource, trace::Trace, @@ -69,8 +70,12 @@ pub enum ReprKind { fn repr_from_value(item_tree: &ItemTree, of: AttrOwner) -> Option { item_tree.attrs(of).iter().find_map(|a| { - if a.path.segments[0].to_string() == "repr" { - if let Some(AttrInput::TokenTree(subtree)) = &a.input { + if let Attr { + path: ModPath { kind: PathKind::Plain, segments }, + input: Some(AttrInput::TokenTree(subtree)), + } = a + { + if segments.len() == 1 && segments[0].to_string() == "repr" { parse_repr_tt(subtree) } else { None diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index 9e8419c5f8..a4a7aa2280 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -565,7 +565,7 @@ fn highlight_element( _ => h, } } - T![&] => { + REF_EXPR => { let ref_expr = element.into_node().and_then(ast::RefExpr::cast)?; let expr = ref_expr.expr()?; let field_expr = match expr { @@ -582,7 +582,7 @@ fn highlight_element( // FIXME This needs layout computation to be correct. It will highlight // more than it should with the current implementation. - Highlight::new(HighlightTag::Operator) | HighlightModifier::Unsafe + HighlightTag::Operator | HighlightModifier::Unsafe } p if p.is_punct() => match p { T![::] | T![->] | T![=>] | T![&] | T![..] | T![=] | T![@] => { diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ra_ide/src/syntax_highlighting/tests.rs index c408058501..a7f5ad8622 100644 --- a/crates/ra_ide/src/syntax_highlighting/tests.rs +++ b/crates/ra_ide/src/syntax_highlighting/tests.rs @@ -295,8 +295,6 @@ static mut global_mut: TypeForStaticMut = TypeForStaticMut { a: 0 }; #[repr(packed)] struct Packed { a: u16, - b: u8, - c: u32, } trait DoTheAutoref { @@ -313,11 +311,11 @@ struct HasAligned { } impl DoTheAutoref for NeedsAlign { - fn calls_autored(&self) {} + fn calls_autoref(&self) {} } fn main() { - let x = &5 as *const usize; + let x = &5 as *const _ as *const usize; let u = Union { b: 0 }; unsafe { unsafe_fn(); @@ -327,13 +325,11 @@ fn main() { Union { a } => (), } HasUnsafeFn.unsafe_method(); - let y = *(x); + let _y = *(x); let z = -x; let a = global_mut.a; - let packed = Packed { a: 0, b: 0, c: 0 }; - let a = &packed.a; - let b = &packed.b; - let c = &packed.c; + let packed = Packed { a: 0 }; + let _a = &packed.a; let h = HasAligned{ a: NeedsAlign { a: 1 } }; h.a.calls_autoref(); } From d5f11e530dbf6edbdd0ca32d6cd5fafe634c8c4a Mon Sep 17 00:00:00 2001 From: Paul Daniel Faria Date: Sat, 27 Jun 2020 17:11:43 -0400 Subject: [PATCH 018/119] Unsafe borrow of packed fields: account for borrow through ref binding, auto ref function calls --- crates/ra_hir/src/code_model.rs | 5 +- crates/ra_hir_def/src/data.rs | 6 +- crates/ra_hir_def/src/item_tree.rs | 8 +- crates/ra_hir_def/src/item_tree/lower.rs | 9 +- crates/ra_hir_ty/src/method_resolution.rs | 2 +- crates/ra_ide/src/completion/complete_dot.rs | 2 +- .../src/completion/complete_trait_impl.rs | 2 +- crates/ra_ide/src/completion/presentation.rs | 2 +- crates/ra_ide/src/syntax_highlighting.rs | 137 +++++++++++++++--- .../ra_ide/src/syntax_highlighting/tests.rs | 31 ++-- 10 files changed, 156 insertions(+), 48 deletions(-) diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 0007d7fa88..a880fa6713 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs @@ -11,6 +11,7 @@ use hir_def::{ docs::Documentation, expr::{BindingAnnotation, Pat, PatId}, import_map, + item_tree::SelfParam, per_ns::PerNs, resolver::{HasResolver, Resolver}, src::HasSource as _, @@ -670,8 +671,8 @@ impl Function { db.function_data(self.id).name.clone() } - pub fn has_self_param(self, db: &dyn HirDatabase) -> bool { - db.function_data(self.id).has_self_param + pub fn self_param(self, db: &dyn HirDatabase) -> Option { + db.function_data(self.id).self_param } pub fn params(self, db: &dyn HirDatabase) -> Vec { diff --git a/crates/ra_hir_def/src/data.rs b/crates/ra_hir_def/src/data.rs index 88a8ef9bff..2a26b0183e 100644 --- a/crates/ra_hir_def/src/data.rs +++ b/crates/ra_hir_def/src/data.rs @@ -10,7 +10,7 @@ use crate::{ attr::Attrs, body::Expander, db::DefDatabase, - item_tree::{AssocItem, ItemTreeId, ModItem}, + item_tree::{AssocItem, ItemTreeId, ModItem, SelfParam}, type_ref::{TypeBound, TypeRef}, visibility::RawVisibility, AssocContainerId, AssocItemId, ConstId, ConstLoc, FunctionId, FunctionLoc, HasModule, ImplId, @@ -25,7 +25,7 @@ pub struct FunctionData { pub attrs: Attrs, /// True if the first param is `self`. This is relevant to decide whether this /// can be called as a method. - pub has_self_param: bool, + pub self_param: Option, pub is_unsafe: bool, pub is_varargs: bool, pub visibility: RawVisibility, @@ -42,7 +42,7 @@ impl FunctionData { params: func.params.to_vec(), ret_type: func.ret_type.clone(), attrs: item_tree.attrs(ModItem::from(loc.id.value).into()).clone(), - has_self_param: func.has_self_param, + self_param: func.self_param, is_unsafe: func.is_unsafe, is_varargs: func.is_varargs, visibility: item_tree[func.visibility].clone(), diff --git a/crates/ra_hir_def/src/item_tree.rs b/crates/ra_hir_def/src/item_tree.rs index a67e75dac0..1eaea66e4a 100644 --- a/crates/ra_hir_def/src/item_tree.rs +++ b/crates/ra_hir_def/src/item_tree.rs @@ -500,7 +500,7 @@ pub struct Function { pub name: Name, pub visibility: RawVisibilityId, pub generic_params: GenericParamsId, - pub has_self_param: bool, + pub self_param: Option, pub is_unsafe: bool, pub params: Box<[TypeRef]>, pub is_varargs: bool, @@ -508,6 +508,12 @@ pub struct Function { pub ast_id: FileAstId, } +#[derive(Debug, Copy, Clone, Eq, PartialEq)] +pub struct SelfParam { + pub is_ref: bool, + pub is_mut: bool, +} + #[derive(Debug, Clone, Eq, PartialEq)] pub struct Struct { pub name: Name, diff --git a/crates/ra_hir_def/src/item_tree/lower.rs b/crates/ra_hir_def/src/item_tree/lower.rs index 450ef87981..89ad91d376 100644 --- a/crates/ra_hir_def/src/item_tree/lower.rs +++ b/crates/ra_hir_def/src/item_tree/lower.rs @@ -283,7 +283,7 @@ impl Ctx { let name = func.name()?.as_name(); let mut params = Vec::new(); - let mut has_self_param = false; + let mut func_self_param = None; if let Some(param_list) = func.param_list() { if let Some(self_param) = param_list.self_param() { let self_type = match self_param.ty() { @@ -302,7 +302,10 @@ impl Ctx { } }; params.push(self_type); - has_self_param = true; + func_self_param = Some(SelfParam { + is_ref: self_param.amp_token().is_some(), + is_mut: self_param.mut_token().is_some(), + }); } for param in param_list.params() { let type_ref = TypeRef::from_ast_opt(&self.body_ctx, param.ty()); @@ -335,7 +338,7 @@ impl Ctx { name, visibility, generic_params: GenericParamsId::EMPTY, - has_self_param, + self_param: func_self_param, is_unsafe: func.unsafe_token().is_some(), params: params.into_boxed_slice(), is_varargs, diff --git a/crates/ra_hir_ty/src/method_resolution.rs b/crates/ra_hir_ty/src/method_resolution.rs index fb4b30a131..79c5adf0f1 100644 --- a/crates/ra_hir_ty/src/method_resolution.rs +++ b/crates/ra_hir_ty/src/method_resolution.rs @@ -640,7 +640,7 @@ fn is_valid_candidate( } } if let Some(receiver_ty) = receiver_ty { - if !data.has_self_param { + if data.self_param.is_none() { return false; } let transformed_receiver_ty = match transform_receiver_ty(db, m, self_ty) { diff --git a/crates/ra_ide/src/completion/complete_dot.rs b/crates/ra_ide/src/completion/complete_dot.rs index 5326652852..5488db43f7 100644 --- a/crates/ra_ide/src/completion/complete_dot.rs +++ b/crates/ra_ide/src/completion/complete_dot.rs @@ -48,7 +48,7 @@ fn complete_methods(acc: &mut Completions, ctx: &CompletionContext, receiver: &T let mut seen_methods = FxHashSet::default(); let traits_in_scope = ctx.scope.traits_in_scope(); receiver.iterate_method_candidates(ctx.db, krate, &traits_in_scope, None, |_ty, func| { - if func.has_self_param(ctx.db) + if func.self_param(ctx.db).is_some() && ctx.scope.module().map_or(true, |m| func.is_visible_from(ctx.db, m)) && seen_methods.insert(func.name(ctx.db)) { diff --git a/crates/ra_ide/src/completion/complete_trait_impl.rs b/crates/ra_ide/src/completion/complete_trait_impl.rs index d9a0ef167d..e3ba7ebc47 100644 --- a/crates/ra_ide/src/completion/complete_trait_impl.rs +++ b/crates/ra_ide/src/completion/complete_trait_impl.rs @@ -136,7 +136,7 @@ fn add_function_impl( .lookup_by(fn_name) .set_documentation(func.docs(ctx.db)); - let completion_kind = if func.has_self_param(ctx.db) { + let completion_kind = if func.self_param(ctx.db).is_some() { CompletionItemKind::Method } else { CompletionItemKind::Function diff --git a/crates/ra_ide/src/completion/presentation.rs b/crates/ra_ide/src/completion/presentation.rs index 9a94ff4767..fc3d1a4bda 100644 --- a/crates/ra_ide/src/completion/presentation.rs +++ b/crates/ra_ide/src/completion/presentation.rs @@ -191,7 +191,7 @@ impl Completions { func: hir::Function, local_name: Option, ) { - let has_self_param = func.has_self_param(ctx.db); + let has_self_param = func.self_param(ctx.db).is_some(); let name = local_name.unwrap_or_else(|| func.name(ctx.db).to_string()); let ast_node = func.source(ctx.db).value; diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index a4a7aa2280..454fef39c6 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -497,9 +497,9 @@ fn highlight_element( match name_kind { Some(NameClass::ExternCrate(_)) => HighlightTag::Module.into(), Some(NameClass::Definition(def)) => { - highlight_name(db, def, false) | HighlightModifier::Definition + highlight_name(sema, db, def, None, false) | HighlightModifier::Definition } - Some(NameClass::ConstReference(def)) => highlight_name(db, def, false), + Some(NameClass::ConstReference(def)) => highlight_name(sema, db, def, None, false), Some(NameClass::FieldShorthand { field, .. }) => { let mut h = HighlightTag::Field.into(); if let Definition::Field(field) = field { @@ -532,7 +532,7 @@ fn highlight_element( binding_hash = Some(calc_binding_hash(&name, *shadow_count)) } }; - highlight_name(db, def, possibly_unsafe) + highlight_name(sema, db, def, Some(name_ref), possibly_unsafe) } NameRefClass::FieldShorthand { .. } => HighlightTag::Field.into(), }, @@ -565,8 +565,8 @@ fn highlight_element( _ => h, } } - REF_EXPR => { - let ref_expr = element.into_node().and_then(ast::RefExpr::cast)?; + T![&] => { + let ref_expr = element.parent().and_then(ast::RefExpr::cast)?; let expr = ref_expr.expr()?; let field_expr = match expr { ast::Expr::FieldExpr(fe) => fe, @@ -668,6 +668,52 @@ fn highlight_element( HighlightTag::SelfKeyword.into() } } + T![ref] => { + let modifier: Option = (|| { + let bind_pat = element.parent().and_then(ast::BindPat::cast)?; + let parent = bind_pat.syntax().parent()?; + + let ty = if let Some(pat_list) = + ast::RecordFieldPatList::cast(parent.clone()) + { + let record_pat = + pat_list.syntax().parent().and_then(ast::RecordPat::cast)?; + sema.type_of_pat(&ast::Pat::RecordPat(record_pat)) + } else if let Some(let_stmt) = ast::LetStmt::cast(parent.clone()) { + let field_expr = + if let ast::Expr::FieldExpr(field_expr) = let_stmt.initializer()? { + field_expr + } else { + return None; + }; + + sema.type_of_expr(&field_expr.expr()?) + } else if let Some(record_field_pat) = ast::RecordFieldPat::cast(parent) { + let record_pat = record_field_pat + .syntax() + .parent() + .and_then(ast::RecordFieldPatList::cast)? + .syntax() + .parent() + .and_then(ast::RecordPat::cast)?; + sema.type_of_pat(&ast::Pat::RecordPat(record_pat)) + } else { + None + }?; + + if !ty.is_packed(db) { + return None; + } + + Some(HighlightModifier::Unsafe) + })(); + + if let Some(modifier) = modifier { + h | modifier + } else { + h + } + } _ => h, } } @@ -697,7 +743,13 @@ fn is_child_of_impl(element: &SyntaxElement) -> bool { } } -fn highlight_name(db: &RootDatabase, def: Definition, possibly_unsafe: bool) -> Highlight { +fn highlight_name( + sema: &Semantics, + db: &RootDatabase, + def: Definition, + name_ref: Option, + possibly_unsafe: bool, +) -> Highlight { match def { Definition::Macro(_) => HighlightTag::Macro, Definition::Field(field) => { @@ -716,6 +768,29 @@ fn highlight_name(db: &RootDatabase, def: Definition, possibly_unsafe: bool) -> let mut h = HighlightTag::Function.into(); if func.is_unsafe(db) { h |= HighlightModifier::Unsafe; + } else { + (|| { + let method_call_expr = + name_ref?.syntax().parent().and_then(ast::MethodCallExpr::cast)?; + let expr = method_call_expr.expr()?; + let field_expr = if let ast::Expr::FieldExpr(field_expr) = expr { + Some(field_expr) + } else { + None + }?; + let ty = sema.type_of_expr(&field_expr.expr()?)?; + if !ty.is_packed(db) { + return None; + } + + let func = sema.resolve_method_call(&method_call_expr)?; + if func.self_param(db)?.is_ref { + Some(HighlightModifier::Unsafe) + } else { + None + } + })() + .map(|modifier| h |= modifier); } return h; } @@ -787,8 +862,33 @@ fn highlight_name_ref_by_syntax(name: ast::NameRef, sema: &Semantics return default.into(), }; - let tag = match parent.kind() { - METHOD_CALL_EXPR => HighlightTag::Function, + match parent.kind() { + METHOD_CALL_EXPR => { + let mut h = Highlight::new(HighlightTag::Function); + let modifier: Option = (|| { + let method_call_expr = ast::MethodCallExpr::cast(parent)?; + let expr = method_call_expr.expr()?; + let field_expr = if let ast::Expr::FieldExpr(field_expr) = expr { + field_expr + } else { + return None; + }; + + let expr = field_expr.expr()?; + let ty = sema.type_of_expr(&expr)?; + if ty.is_packed(sema.db) { + Some(HighlightModifier::Unsafe) + } else { + None + } + })(); + + if let Some(modifier) = modifier { + h |= modifier; + } + + h + } FIELD_EXPR => { let h = HighlightTag::Field; let is_union = ast::FieldExpr::cast(parent) @@ -801,7 +901,7 @@ fn highlight_name_ref_by_syntax(name: ast::NameRef, sema: &Semantics { let path = match parent.parent().and_then(ast::Path::cast) { @@ -826,18 +926,15 @@ fn highlight_name_ref_by_syntax(name: ast::NameRef, sema: &Semantics HighlightTag::Function, - _ => { - if name.text().chars().next().unwrap_or_default().is_uppercase() { - HighlightTag::Struct - } else { - HighlightTag::Constant - } + CALL_EXPR => HighlightTag::Function.into(), + _ => if name.text().chars().next().unwrap_or_default().is_uppercase() { + HighlightTag::Struct.into() + } else { + HighlightTag::Constant } + .into(), } } - _ => default, - }; - - tag.into() + _ => default.into(), + } } diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ra_ide/src/syntax_highlighting/tests.rs index a7f5ad8622..a8087635a8 100644 --- a/crates/ra_ide/src/syntax_highlighting/tests.rs +++ b/crates/ra_ide/src/syntax_highlighting/tests.rs @@ -301,16 +301,7 @@ trait DoTheAutoref { fn calls_autoref(&self); } -struct NeedsAlign { - a: u16 -} - -#[repr(packed)] -struct HasAligned { - a: NeedsAlign -} - -impl DoTheAutoref for NeedsAlign { +impl DoTheAutoref for u16 { fn calls_autoref(&self) {} } @@ -318,6 +309,7 @@ fn main() { let x = &5 as *const _ as *const usize; let u = Union { b: 0 }; unsafe { + // unsafe fn and method calls unsafe_fn(); let b = u.b; match u { @@ -325,13 +317,22 @@ fn main() { Union { a } => (), } HasUnsafeFn.unsafe_method(); - let _y = *(x); - let z = -x; + + // unsafe deref + let y = *x; + + // unsafe access to a static mut let a = global_mut.a; + + // unsafe ref of packed fields let packed = Packed { a: 0 }; - let _a = &packed.a; - let h = HasAligned{ a: NeedsAlign { a: 1 } }; - h.a.calls_autoref(); + let a = &packed.a; + let ref a = packed.a; + let Packed { ref a } = packed; + let Packed { a: ref _a } = packed; + + // unsafe auto ref of packed field + packed.a.calls_autoref(); } } "# From aca3d6c57ec2c668cdb51eca34d6f7bc8fa7412b Mon Sep 17 00:00:00 2001 From: Paul Daniel Faria Date: Sat, 27 Jun 2020 17:28:07 -0400 Subject: [PATCH 019/119] Deduplicate unsafe method call into a single function --- crates/ra_ide/src/syntax_highlighting.rs | 72 ++++++++++-------------- 1 file changed, 31 insertions(+), 41 deletions(-) diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index 454fef39c6..02b16b13c0 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -743,6 +743,26 @@ fn is_child_of_impl(element: &SyntaxElement) -> bool { } } +fn is_method_call_unsafe( + sema: &Semantics, + method_call_expr: ast::MethodCallExpr, +) -> Option<()> { + let expr = method_call_expr.expr()?; + let field_expr = + if let ast::Expr::FieldExpr(field_expr) = expr { field_expr } else { return None }; + let ty = sema.type_of_expr(&field_expr.expr()?)?; + if !ty.is_packed(sema.db) { + return None; + } + + let func = sema.resolve_method_call(&method_call_expr)?; + if func.self_param(sema.db)?.is_ref { + Some(()) + } else { + None + } +} + fn highlight_name( sema: &Semantics, db: &RootDatabase, @@ -769,28 +789,13 @@ fn highlight_name( if func.is_unsafe(db) { h |= HighlightModifier::Unsafe; } else { - (|| { - let method_call_expr = - name_ref?.syntax().parent().and_then(ast::MethodCallExpr::cast)?; - let expr = method_call_expr.expr()?; - let field_expr = if let ast::Expr::FieldExpr(field_expr) = expr { - Some(field_expr) - } else { - None - }?; - let ty = sema.type_of_expr(&field_expr.expr()?)?; - if !ty.is_packed(db) { - return None; - } - - let func = sema.resolve_method_call(&method_call_expr)?; - if func.self_param(db)?.is_ref { - Some(HighlightModifier::Unsafe) - } else { - None - } - })() - .map(|modifier| h |= modifier); + let is_unsafe = name_ref + .and_then(|name_ref| name_ref.syntax().parent()) + .and_then(ast::MethodCallExpr::cast) + .and_then(|method_call_expr| is_method_call_unsafe(sema, method_call_expr)); + if is_unsafe.is_some() { + h |= HighlightModifier::Unsafe; + } } return h; } @@ -865,26 +870,11 @@ fn highlight_name_ref_by_syntax(name: ast::NameRef, sema: &Semantics { let mut h = Highlight::new(HighlightTag::Function); - let modifier: Option = (|| { - let method_call_expr = ast::MethodCallExpr::cast(parent)?; - let expr = method_call_expr.expr()?; - let field_expr = if let ast::Expr::FieldExpr(field_expr) = expr { - field_expr - } else { - return None; - }; + let is_unsafe = ast::MethodCallExpr::cast(parent) + .and_then(|method_call_expr| is_method_call_unsafe(sema, method_call_expr)); - let expr = field_expr.expr()?; - let ty = sema.type_of_expr(&expr)?; - if ty.is_packed(sema.db) { - Some(HighlightModifier::Unsafe) - } else { - None - } - })(); - - if let Some(modifier) = modifier { - h |= modifier; + if is_unsafe.is_some() { + h |= HighlightModifier::Unsafe; } h From c5cc24cb312c70159e63315ea49769b575e8cb65 Mon Sep 17 00:00:00 2001 From: Paul Daniel Faria Date: Sun, 28 Jun 2020 16:04:00 -0400 Subject: [PATCH 020/119] Revert function structs back to using bool to track self param, use first param for self information in syntax highlighting instead --- crates/ra_hir/src/code_model.rs | 5 ++--- crates/ra_hir/src/lib.rs | 2 +- crates/ra_hir_def/src/data.rs | 6 +++--- crates/ra_hir_def/src/item_tree.rs | 8 +------- crates/ra_hir_def/src/item_tree/lower.rs | 9 +++------ crates/ra_hir_ty/src/method_resolution.rs | 2 +- crates/ra_ide/src/completion/complete_dot.rs | 2 +- crates/ra_ide/src/completion/complete_trait_impl.rs | 2 +- crates/ra_ide/src/completion/presentation.rs | 2 +- crates/ra_ide/src/syntax_highlighting.rs | 11 ++++++++--- 10 files changed, 22 insertions(+), 27 deletions(-) diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index a880fa6713..0007d7fa88 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs @@ -11,7 +11,6 @@ use hir_def::{ docs::Documentation, expr::{BindingAnnotation, Pat, PatId}, import_map, - item_tree::SelfParam, per_ns::PerNs, resolver::{HasResolver, Resolver}, src::HasSource as _, @@ -671,8 +670,8 @@ impl Function { db.function_data(self.id).name.clone() } - pub fn self_param(self, db: &dyn HirDatabase) -> Option { - db.function_data(self.id).self_param + pub fn has_self_param(self, db: &dyn HirDatabase) -> bool { + db.function_data(self.id).has_self_param } pub fn params(self, db: &dyn HirDatabase) -> Vec { diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs index 31f3241c9e..34b02c5365 100644 --- a/crates/ra_hir/src/lib.rs +++ b/crates/ra_hir/src/lib.rs @@ -49,7 +49,7 @@ pub use hir_def::{ docs::Documentation, nameres::ModuleSource, path::{ModPath, Path, PathKind}, - type_ref::Mutability, + type_ref::{Mutability, TypeRef}, }; pub use hir_expand::{ hygiene::Hygiene, name::Name, HirFileId, InFile, MacroCallId, MacroCallLoc, diff --git a/crates/ra_hir_def/src/data.rs b/crates/ra_hir_def/src/data.rs index 2a26b0183e..88a8ef9bff 100644 --- a/crates/ra_hir_def/src/data.rs +++ b/crates/ra_hir_def/src/data.rs @@ -10,7 +10,7 @@ use crate::{ attr::Attrs, body::Expander, db::DefDatabase, - item_tree::{AssocItem, ItemTreeId, ModItem, SelfParam}, + item_tree::{AssocItem, ItemTreeId, ModItem}, type_ref::{TypeBound, TypeRef}, visibility::RawVisibility, AssocContainerId, AssocItemId, ConstId, ConstLoc, FunctionId, FunctionLoc, HasModule, ImplId, @@ -25,7 +25,7 @@ pub struct FunctionData { pub attrs: Attrs, /// True if the first param is `self`. This is relevant to decide whether this /// can be called as a method. - pub self_param: Option, + pub has_self_param: bool, pub is_unsafe: bool, pub is_varargs: bool, pub visibility: RawVisibility, @@ -42,7 +42,7 @@ impl FunctionData { params: func.params.to_vec(), ret_type: func.ret_type.clone(), attrs: item_tree.attrs(ModItem::from(loc.id.value).into()).clone(), - self_param: func.self_param, + has_self_param: func.has_self_param, is_unsafe: func.is_unsafe, is_varargs: func.is_varargs, visibility: item_tree[func.visibility].clone(), diff --git a/crates/ra_hir_def/src/item_tree.rs b/crates/ra_hir_def/src/item_tree.rs index 1eaea66e4a..a67e75dac0 100644 --- a/crates/ra_hir_def/src/item_tree.rs +++ b/crates/ra_hir_def/src/item_tree.rs @@ -500,7 +500,7 @@ pub struct Function { pub name: Name, pub visibility: RawVisibilityId, pub generic_params: GenericParamsId, - pub self_param: Option, + pub has_self_param: bool, pub is_unsafe: bool, pub params: Box<[TypeRef]>, pub is_varargs: bool, @@ -508,12 +508,6 @@ pub struct Function { pub ast_id: FileAstId, } -#[derive(Debug, Copy, Clone, Eq, PartialEq)] -pub struct SelfParam { - pub is_ref: bool, - pub is_mut: bool, -} - #[derive(Debug, Clone, Eq, PartialEq)] pub struct Struct { pub name: Name, diff --git a/crates/ra_hir_def/src/item_tree/lower.rs b/crates/ra_hir_def/src/item_tree/lower.rs index 89ad91d376..450ef87981 100644 --- a/crates/ra_hir_def/src/item_tree/lower.rs +++ b/crates/ra_hir_def/src/item_tree/lower.rs @@ -283,7 +283,7 @@ impl Ctx { let name = func.name()?.as_name(); let mut params = Vec::new(); - let mut func_self_param = None; + let mut has_self_param = false; if let Some(param_list) = func.param_list() { if let Some(self_param) = param_list.self_param() { let self_type = match self_param.ty() { @@ -302,10 +302,7 @@ impl Ctx { } }; params.push(self_type); - func_self_param = Some(SelfParam { - is_ref: self_param.amp_token().is_some(), - is_mut: self_param.mut_token().is_some(), - }); + has_self_param = true; } for param in param_list.params() { let type_ref = TypeRef::from_ast_opt(&self.body_ctx, param.ty()); @@ -338,7 +335,7 @@ impl Ctx { name, visibility, generic_params: GenericParamsId::EMPTY, - self_param: func_self_param, + has_self_param, is_unsafe: func.unsafe_token().is_some(), params: params.into_boxed_slice(), is_varargs, diff --git a/crates/ra_hir_ty/src/method_resolution.rs b/crates/ra_hir_ty/src/method_resolution.rs index 79c5adf0f1..fb4b30a131 100644 --- a/crates/ra_hir_ty/src/method_resolution.rs +++ b/crates/ra_hir_ty/src/method_resolution.rs @@ -640,7 +640,7 @@ fn is_valid_candidate( } } if let Some(receiver_ty) = receiver_ty { - if data.self_param.is_none() { + if !data.has_self_param { return false; } let transformed_receiver_ty = match transform_receiver_ty(db, m, self_ty) { diff --git a/crates/ra_ide/src/completion/complete_dot.rs b/crates/ra_ide/src/completion/complete_dot.rs index 5488db43f7..5326652852 100644 --- a/crates/ra_ide/src/completion/complete_dot.rs +++ b/crates/ra_ide/src/completion/complete_dot.rs @@ -48,7 +48,7 @@ fn complete_methods(acc: &mut Completions, ctx: &CompletionContext, receiver: &T let mut seen_methods = FxHashSet::default(); let traits_in_scope = ctx.scope.traits_in_scope(); receiver.iterate_method_candidates(ctx.db, krate, &traits_in_scope, None, |_ty, func| { - if func.self_param(ctx.db).is_some() + if func.has_self_param(ctx.db) && ctx.scope.module().map_or(true, |m| func.is_visible_from(ctx.db, m)) && seen_methods.insert(func.name(ctx.db)) { diff --git a/crates/ra_ide/src/completion/complete_trait_impl.rs b/crates/ra_ide/src/completion/complete_trait_impl.rs index e3ba7ebc47..d9a0ef167d 100644 --- a/crates/ra_ide/src/completion/complete_trait_impl.rs +++ b/crates/ra_ide/src/completion/complete_trait_impl.rs @@ -136,7 +136,7 @@ fn add_function_impl( .lookup_by(fn_name) .set_documentation(func.docs(ctx.db)); - let completion_kind = if func.self_param(ctx.db).is_some() { + let completion_kind = if func.has_self_param(ctx.db) { CompletionItemKind::Method } else { CompletionItemKind::Function diff --git a/crates/ra_ide/src/completion/presentation.rs b/crates/ra_ide/src/completion/presentation.rs index fc3d1a4bda..9a94ff4767 100644 --- a/crates/ra_ide/src/completion/presentation.rs +++ b/crates/ra_ide/src/completion/presentation.rs @@ -191,7 +191,7 @@ impl Completions { func: hir::Function, local_name: Option, ) { - let has_self_param = func.self_param(ctx.db).is_some(); + let has_self_param = func.has_self_param(ctx.db); let name = local_name.unwrap_or_else(|| func.name(ctx.db).to_string()); let ast_node = func.source(ctx.db).value; diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index 02b16b13c0..d5a5f69cca 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -4,7 +4,7 @@ mod injection; #[cfg(test)] mod tests; -use hir::{Name, Semantics, VariantDef}; +use hir::{Name, Semantics, TypeRef, VariantDef}; use ra_ide_db::{ defs::{classify_name, classify_name_ref, Definition, NameClass, NameRefClass}, RootDatabase, @@ -756,8 +756,13 @@ fn is_method_call_unsafe( } let func = sema.resolve_method_call(&method_call_expr)?; - if func.self_param(sema.db)?.is_ref { - Some(()) + if func.has_self_param(sema.db) { + let params = func.params(sema.db); + if matches!(params.into_iter().next(), Some(TypeRef::Reference(..))) { + Some(()) + } else { + None + } } else { None } From 08182aa9fad4021e60cdc80ee0a578929507e115 Mon Sep 17 00:00:00 2001 From: Paul Daniel Faria Date: Sun, 19 Jul 2020 11:45:46 -0400 Subject: [PATCH 021/119] Move unsafe packed ref logic to Semantics, use `Attrs::by_key` to simplify repr attr lookup --- crates/ra_hir/src/semantics.rs | 41 ++ crates/ra_hir_def/src/adt.rs | 25 +- crates/ra_ide/src/call_info.rs.orig | 769 +++++++++++++++++++++++ crates/ra_ide/src/syntax_highlighting.rs | 34 +- 4 files changed, 815 insertions(+), 54 deletions(-) create mode 100644 crates/ra_ide/src/call_info.rs.orig diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs index e392130ab6..1072b39718 100644 --- a/crates/ra_hir/src/semantics.rs +++ b/crates/ra_hir/src/semantics.rs @@ -279,6 +279,47 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { pub fn assert_contains_node(&self, node: &SyntaxNode) { self.imp.assert_contains_node(node) } + + pub fn is_unsafe_pat(&self, pat: &ast::Pat) -> bool { + let ty = (|| { + let parent = match pat { + ast::Pat::BindPat(bind_pat) => bind_pat.syntax().parent()?, + _ => return None, + }; + + // `BindPat` can live under `RecordPat` directly under `RecordFieldPat` or + // `RecordFieldPatList`. `RecordFieldPat` also lives under `RecordFieldPatList`, + // so this tries to lookup the `BindPat` anywhere along that structure to the + // `RecordPat` so we can get the containing type. + let record_pat = ast::RecordFieldPat::cast(parent.clone()) + .and_then(|record_pat| record_pat.syntax().parent()) + .or_else(|| Some(parent.clone())) + .and_then(|parent| { + ast::RecordFieldPatList::cast(parent)? + .syntax() + .parent() + .and_then(ast::RecordPat::cast) + }); + + // If this doesn't match a `RecordPat`, fallback to a `LetStmt` to see if + // this is initialized from a `FieldExpr`. + if let Some(record_pat) = record_pat { + self.type_of_pat(&ast::Pat::RecordPat(record_pat)) + } else if let Some(let_stmt) = ast::LetStmt::cast(parent) { + let field_expr = match let_stmt.initializer()? { + ast::Expr::FieldExpr(field_expr) => field_expr, + _ => return None, + }; + + self.type_of_expr(&field_expr.expr()?) + } else { + None + } + })(); + + // Binding a reference to a packed type is possibly unsafe. + ty.map(|ty| ty.is_packed(self.db)).unwrap_or(false) + } } impl<'db> SemanticsImpl<'db> { diff --git a/crates/ra_hir_def/src/adt.rs b/crates/ra_hir_def/src/adt.rs index 4ba6944805..35c3a91402 100644 --- a/crates/ra_hir_def/src/adt.rs +++ b/crates/ra_hir_def/src/adt.rs @@ -12,11 +12,9 @@ use ra_syntax::ast::{self, NameOwner, VisibilityOwner}; use tt::{Delimiter, DelimiterKind, Leaf, Subtree, TokenTree}; use crate::{ - attr::{Attr, AttrInput}, body::{CfgExpander, LowerCtx}, db::DefDatabase, item_tree::{AttrOwner, Field, Fields, ItemTree, ModItem}, - path::{ModPath, PathKind}, src::HasChildSource, src::HasSource, trace::Trace, @@ -69,21 +67,7 @@ pub enum ReprKind { } fn repr_from_value(item_tree: &ItemTree, of: AttrOwner) -> Option { - item_tree.attrs(of).iter().find_map(|a| { - if let Attr { - path: ModPath { kind: PathKind::Plain, segments }, - input: Some(AttrInput::TokenTree(subtree)), - } = a - { - if segments.len() == 1 && segments[0].to_string() == "repr" { - parse_repr_tt(subtree) - } else { - None - } - } else { - None - } - }) + item_tree.attrs(of).by_key("repr").tt_values().find_map(parse_repr_tt) } fn parse_repr_tt(tt: &Subtree) -> Option { @@ -93,11 +77,8 @@ fn parse_repr_tt(tt: &Subtree) -> Option { } let mut it = tt.token_trees.iter(); - match it.next() { - None => None, - Some(TokenTree::Leaf(Leaf::Ident(ident))) if ident.text == "packed" => { - Some(ReprKind::Packed) - } + match it.next()? { + TokenTree::Leaf(Leaf::Ident(ident)) if ident.text == "packed" => Some(ReprKind::Packed), _ => Some(ReprKind::Other), } } diff --git a/crates/ra_ide/src/call_info.rs.orig b/crates/ra_ide/src/call_info.rs.orig new file mode 100644 index 0000000000..0e04c0b607 --- /dev/null +++ b/crates/ra_ide/src/call_info.rs.orig @@ -0,0 +1,769 @@ +//! FIXME: write short doc here +use either::Either; +use hir::{Docs, HirDisplay, Semantics, Type}; +use ra_ide_db::RootDatabase; +use ra_syntax::{ + ast::{self, ArgListOwner}, + match_ast, AstNode, SyntaxNode, SyntaxToken, TextRange, TextSize, +}; +use stdx::format_to; +use test_utils::mark; + +use crate::FilePosition; + +/// Contains information about a call site. Specifically the +/// `FunctionSignature`and current parameter. +#[derive(Debug)] +pub struct CallInfo { + pub doc: Option, + pub signature: String, + pub active_parameter: Option, + parameters: Vec, +} + +impl CallInfo { + pub fn parameter_labels(&self) -> impl Iterator + '_ { + self.parameters.iter().map(move |&it| &self.signature[it]) + } + pub fn parameter_ranges(&self) -> &[TextRange] { + &self.parameters + } + fn push_param(&mut self, param: &str) { + if !self.signature.ends_with('(') { + self.signature.push_str(", "); + } + let start = TextSize::of(&self.signature); + self.signature.push_str(param); + let end = TextSize::of(&self.signature); + self.parameters.push(TextRange::new(start, end)) + } +} + +/// Computes parameter information for the given call expression. +pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option { + let sema = Semantics::new(db); + let file = sema.parse(position.file_id); + let file = file.syntax(); + let token = file.token_at_offset(position.offset).next()?; + let token = sema.descend_into_macros(token); + + let (callable, active_parameter) = call_info_impl(&sema, token)?; + + let mut res = + CallInfo { doc: None, signature: String::new(), parameters: vec![], active_parameter }; + + match callable.kind() { + hir::CallableKind::Function(func) => { + res.doc = func.docs(db).map(|it| it.as_str().to_string()); + format_to!(res.signature, "fn {}", func.name(db)); + } + hir::CallableKind::TupleStruct(strukt) => { + res.doc = strukt.docs(db).map(|it| it.as_str().to_string()); + format_to!(res.signature, "struct {}", strukt.name(db)); + } + hir::CallableKind::TupleEnumVariant(variant) => { + res.doc = variant.docs(db).map(|it| it.as_str().to_string()); + format_to!( + res.signature, + "enum {}::{}", + variant.parent_enum(db).name(db), + variant.name(db) + ); + } + hir::CallableKind::Closure => (), + } + + res.signature.push('('); + { + if let Some(self_param) = callable.receiver_param(db) { + format_to!(res.signature, "{}", self_param) + } + let mut buf = String::new(); + for (pat, ty) in callable.params(db) { + buf.clear(); + if let Some(pat) = pat { + match pat { + Either::Left(_self) => format_to!(buf, "self: "), + Either::Right(pat) => format_to!(buf, "{}: ", pat), + } + } + format_to!(buf, "{}", ty.display(db)); + res.push_param(&buf); + } + } + res.signature.push(')'); + + match callable.kind() { + hir::CallableKind::Function(_) | hir::CallableKind::Closure => { + let ret_type = callable.return_type(); + if !ret_type.is_unit() { + format_to!(res.signature, " -> {}", ret_type.display(db)); + } + } + hir::CallableKind::TupleStruct(_) | hir::CallableKind::TupleEnumVariant(_) => {} + } + Some(res) +} + +fn call_info_impl( + sema: &Semantics, + token: SyntaxToken, +) -> Option<(hir::Callable, Option)> { + // Find the calling expression and it's NameRef + let calling_node = FnCallNode::with_node(&token.parent())?; + +<<<<<<< HEAD + let callable = match &calling_node { + FnCallNode::CallExpr(call) => sema.type_of_expr(&call.expr()?)?.as_callable(sema.db)?, + FnCallNode::MethodCallExpr(call) => sema.resolve_method_call_as_callable(call)?, + }; + let active_param = if let Some(arg_list) = calling_node.arg_list() { + // Number of arguments specified at the call site + let num_args_at_callsite = arg_list.args().count(); + + let arg_list_range = arg_list.syntax().text_range(); + if !arg_list_range.contains_inclusive(token.text_range().start()) { + mark::hit!(call_info_bad_offset); + return None; +======= + let (mut call_info, has_self) = match &calling_node { + FnCallNode::CallExpr(call) => { + //FIXME: Type::as_callable is broken + let callable_def = sema.type_of_expr(&call.expr()?)?.as_callable()?; + match callable_def { + hir::CallableDef::FunctionId(it) => { + let fn_def = it.into(); + (CallInfo::with_fn(sema.db, fn_def), fn_def.has_self_param(sema.db)) + } + hir::CallableDef::StructId(it) => { + (CallInfo::with_struct(sema.db, it.into())?, false) + } + hir::CallableDef::EnumVariantId(it) => { + (CallInfo::with_enum_variant(sema.db, it.into())?, false) + } + } + } + FnCallNode::MethodCallExpr(method_call) => { + let function = sema.resolve_method_call(&method_call)?; + (CallInfo::with_fn(sema.db, function), function.has_self_param(sema.db)) + } + FnCallNode::MacroCallExpr(macro_call) => { + let macro_def = sema.resolve_macro_call(¯o_call)?; + (CallInfo::with_macro(sema.db, macro_def)?, false) +>>>>>>> Revert function structs back to using bool to track self param, use first param for self information in syntax highlighting instead + } + let param = std::cmp::min( + num_args_at_callsite, + arg_list + .args() + .take_while(|arg| arg.syntax().text_range().end() <= token.text_range().start()) + .count(), + ); + + Some(param) + } else { + None + }; + Some((callable, active_param)) +} + +#[derive(Debug)] +pub(crate) struct ActiveParameter { + pub(crate) ty: Type, + pub(crate) name: String, +} + +impl ActiveParameter { + pub(crate) fn at(db: &RootDatabase, position: FilePosition) -> Option { + let sema = Semantics::new(db); + let file = sema.parse(position.file_id); + let file = file.syntax(); + let token = file.token_at_offset(position.offset).next()?; + let token = sema.descend_into_macros(token); + Self::at_token(&sema, token) + } + + pub(crate) fn at_token(sema: &Semantics, token: SyntaxToken) -> Option { + let (signature, active_parameter) = call_info_impl(&sema, token)?; + + let idx = active_parameter?; + let mut params = signature.params(sema.db); + if !(idx < params.len()) { + mark::hit!(too_many_arguments); + return None; + } + let (pat, ty) = params.swap_remove(idx); + let name = pat?.to_string(); + Some(ActiveParameter { ty, name }) + } +} + +#[derive(Debug)] +pub(crate) enum FnCallNode { + CallExpr(ast::CallExpr), + MethodCallExpr(ast::MethodCallExpr), +} + +impl FnCallNode { + fn with_node(syntax: &SyntaxNode) -> Option { + syntax.ancestors().find_map(|node| { + match_ast! { + match node { + ast::CallExpr(it) => Some(FnCallNode::CallExpr(it)), + ast::MethodCallExpr(it) => { + let arg_list = it.arg_list()?; + if !arg_list.syntax().text_range().contains_range(syntax.text_range()) { + return None; + } + Some(FnCallNode::MethodCallExpr(it)) + }, + _ => None, + } + } + }) + } + + pub(crate) fn with_node_exact(node: &SyntaxNode) -> Option { + match_ast! { + match node { + ast::CallExpr(it) => Some(FnCallNode::CallExpr(it)), + ast::MethodCallExpr(it) => Some(FnCallNode::MethodCallExpr(it)), + _ => None, + } + } + } + + pub(crate) fn name_ref(&self) -> Option { + match self { + FnCallNode::CallExpr(call_expr) => Some(match call_expr.expr()? { + ast::Expr::PathExpr(path_expr) => path_expr.path()?.segment()?.name_ref()?, + _ => return None, + }), + + FnCallNode::MethodCallExpr(call_expr) => { + call_expr.syntax().children().filter_map(ast::NameRef::cast).next() + } + } + } + + fn arg_list(&self) -> Option { + match self { + FnCallNode::CallExpr(expr) => expr.arg_list(), + FnCallNode::MethodCallExpr(expr) => expr.arg_list(), + } + } +} + +#[cfg(test)] +mod tests { + use expect::{expect, Expect}; + use test_utils::mark; + + use crate::mock_analysis::analysis_and_position; + + fn check(ra_fixture: &str, expect: Expect) { + let (analysis, position) = analysis_and_position(ra_fixture); + let call_info = analysis.call_info(position).unwrap(); + let actual = match call_info { + Some(call_info) => { + let docs = match &call_info.doc { + None => "".to_string(), + Some(docs) => format!("{}\n------\n", docs.as_str()), + }; + let params = call_info + .parameter_labels() + .enumerate() + .map(|(i, param)| { + if Some(i) == call_info.active_parameter { + format!("<{}>", param) + } else { + param.to_string() + } + }) + .collect::>() + .join(", "); + format!("{}{}\n({})\n", docs, call_info.signature, params) + } + None => String::new(), + }; + expect.assert_eq(&actual); + } + + #[test] + fn test_fn_signature_two_args() { + check( + r#" +fn foo(x: u32, y: u32) -> u32 {x + y} +fn bar() { foo(<|>3, ); } +"#, + expect![[r#" + fn foo(x: u32, y: u32) -> u32 + (, y: u32) + "#]], + ); + check( + r#" +fn foo(x: u32, y: u32) -> u32 {x + y} +fn bar() { foo(3<|>, ); } +"#, + expect![[r#" + fn foo(x: u32, y: u32) -> u32 + (, y: u32) + "#]], + ); + check( + r#" +fn foo(x: u32, y: u32) -> u32 {x + y} +fn bar() { foo(3,<|> ); } +"#, + expect![[r#" + fn foo(x: u32, y: u32) -> u32 + (x: u32, ) + "#]], + ); + check( + r#" +fn foo(x: u32, y: u32) -> u32 {x + y} +fn bar() { foo(3, <|>); } +"#, + expect![[r#" + fn foo(x: u32, y: u32) -> u32 + (x: u32, ) + "#]], + ); + } + + #[test] + fn test_fn_signature_two_args_empty() { + check( + r#" +fn foo(x: u32, y: u32) -> u32 {x + y} +fn bar() { foo(<|>); } +"#, + expect![[r#" + fn foo(x: u32, y: u32) -> u32 + (, y: u32) + "#]], + ); + } + + #[test] + fn test_fn_signature_two_args_first_generics() { + check( + r#" +fn foo(x: T, y: U) -> u32 + where T: Copy + Display, U: Debug +{ x + y } + +fn bar() { foo(<|>3, ); } +"#, + expect![[r#" + fn foo(x: i32, y: {unknown}) -> u32 + (, y: {unknown}) + "#]], + ); + } + + #[test] + fn test_fn_signature_no_params() { + check( + r#" +fn foo() -> T where T: Copy + Display {} +fn bar() { foo(<|>); } +"#, + expect![[r#" + fn foo() -> {unknown} + () + "#]], + ); + } + + #[test] + fn test_fn_signature_for_impl() { + check( + r#" +struct F; +impl F { pub fn new() { } } +fn bar() { + let _ : F = F::new(<|>); +} +"#, + expect![[r#" + fn new() + () + "#]], + ); + } + + #[test] + fn test_fn_signature_for_method_self() { + check( + r#" +struct S; +impl S { pub fn do_it(&self) {} } + +fn bar() { + let s: S = S; + s.do_it(<|>); +} +"#, + expect![[r#" + fn do_it(&self) + () + "#]], + ); + } + + #[test] + fn test_fn_signature_for_method_with_arg() { + check( + r#" +struct S; +impl S { + fn foo(&self, x: i32) {} +} + +fn main() { S.foo(<|>); } +"#, + expect![[r#" + fn foo(&self, x: i32) + () + "#]], + ); + } + + #[test] + fn test_fn_signature_for_method_with_arg_as_assoc_fn() { + check( + r#" +struct S; +impl S { + fn foo(&self, x: i32) {} +} + +fn main() { S::foo(<|>); } +"#, + expect![[r#" + fn foo(self: &S, x: i32) + (, x: i32) + "#]], + ); + } + + #[test] + fn test_fn_signature_with_docs_simple() { + check( + r#" +/// test +// non-doc-comment +fn foo(j: u32) -> u32 { + j +} + +fn bar() { + let _ = foo(<|>); +} +"#, + expect![[r#" + test + ------ + fn foo(j: u32) -> u32 + () + "#]], + ); + } + + #[test] + fn test_fn_signature_with_docs() { + check( + r#" +/// Adds one to the number given. +/// +/// # Examples +/// +/// ``` +/// let five = 5; +/// +/// assert_eq!(6, my_crate::add_one(5)); +/// ``` +pub fn add_one(x: i32) -> i32 { + x + 1 +} + +pub fn do() { + add_one(<|> +}"#, + expect![[r##" + Adds one to the number given. + + # Examples + + ``` + let five = 5; + + assert_eq!(6, my_crate::add_one(5)); + ``` + ------ + fn add_one(x: i32) -> i32 + () + "##]], + ); + } + + #[test] + fn test_fn_signature_with_docs_impl() { + check( + r#" +struct addr; +impl addr { + /// Adds one to the number given. + /// + /// # Examples + /// + /// ``` + /// let five = 5; + /// + /// assert_eq!(6, my_crate::add_one(5)); + /// ``` + pub fn add_one(x: i32) -> i32 { + x + 1 + } +} + +pub fn do_it() { + addr {}; + addr::add_one(<|>); +} +"#, + expect![[r##" + Adds one to the number given. + + # Examples + + ``` + let five = 5; + + assert_eq!(6, my_crate::add_one(5)); + ``` + ------ + fn add_one(x: i32) -> i32 + () + "##]], + ); + } + + #[test] + fn test_fn_signature_with_docs_from_actix() { + check( + r#" +struct WriteHandler; + +impl WriteHandler { + /// Method is called when writer emits error. + /// + /// If this method returns `ErrorAction::Continue` writer processing + /// continues otherwise stream processing stops. + fn error(&mut self, err: E, ctx: &mut Self::Context) -> Running { + Running::Stop + } + + /// Method is called when writer finishes. + /// + /// By default this method stops actor's `Context`. + fn finished(&mut self, ctx: &mut Self::Context) { + ctx.stop() + } +} + +pub fn foo(mut r: WriteHandler<()>) { + r.finished(<|>); +} +"#, + expect![[r#" + Method is called when writer finishes. + + By default this method stops actor's `Context`. + ------ + fn finished(&mut self, ctx: &mut {unknown}) + () + "#]], + ); + } + + #[test] + fn call_info_bad_offset() { + mark::check!(call_info_bad_offset); + check( + r#" +fn foo(x: u32, y: u32) -> u32 {x + y} +fn bar() { foo <|> (3, ); } +"#, + expect![[""]], + ); + } + + #[test] + fn test_nested_method_in_lambda() { + check( + r#" +struct Foo; +impl Foo { fn bar(&self, _: u32) { } } + +fn bar(_: u32) { } + +fn main() { + let foo = Foo; + std::thread::spawn(move || foo.bar(<|>)); +} +"#, + expect![[r#" + fn bar(&self, _: u32) + (<_: u32>) + "#]], + ); + } + + #[test] + fn works_for_tuple_structs() { + check( + r#" +/// A cool tuple struct +struct S(u32, i32); +fn main() { + let s = S(0, <|>); +} +"#, + expect![[r#" + A cool tuple struct + ------ + struct S(u32, i32) + (u32, ) + "#]], + ); + } + + #[test] + fn generic_struct() { + check( + r#" +struct S(T); +fn main() { + let s = S(<|>); +} +"#, + expect![[r#" + struct S({unknown}) + (<{unknown}>) + "#]], + ); + } + + #[test] + fn works_for_enum_variants() { + check( + r#" +enum E { + /// A Variant + A(i32), + /// Another + B, + /// And C + C { a: i32, b: i32 } +} + +fn main() { + let a = E::A(<|>); +} +"#, + expect![[r#" + A Variant + ------ + enum E::A(i32) + () + "#]], + ); + } + + #[test] + fn cant_call_struct_record() { + check( + r#" +struct S { x: u32, y: i32 } +fn main() { + let s = S(<|>); +} +"#, + expect![[""]], + ); + } + + #[test] + fn cant_call_enum_record() { + check( + r#" +enum E { + /// A Variant + A(i32), + /// Another + B, + /// And C + C { a: i32, b: i32 } +} + +fn main() { + let a = E::C(<|>); +} +"#, + expect![[""]], + ); + } + + #[test] + fn fn_signature_for_call_in_macro() { + check( + r#" +macro_rules! id { ($($tt:tt)*) => { $($tt)* } } +fn foo() { } +id! { + fn bar() { foo(<|>); } +} +"#, + expect![[r#" + fn foo() + () + "#]], + ); + } + + #[test] + fn call_info_for_lambdas() { + check( + r#" +struct S; +fn foo(s: S) -> i32 { 92 } +fn main() { + (|s| foo(s))(<|>) +} + "#, + expect![[r#" + (S) -> i32 + () + "#]], + ) + } + + #[test] + fn call_info_for_fn_ptr() { + check( + r#" +fn main(f: fn(i32, f64) -> char) { + f(0, <|>) +} + "#, + expect![[r#" + (i32, f64) -> char + (i32, ) + "#]], + ) + } +} diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index d5a5f69cca..cf93205b6e 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -671,41 +671,11 @@ fn highlight_element( T![ref] => { let modifier: Option = (|| { let bind_pat = element.parent().and_then(ast::BindPat::cast)?; - let parent = bind_pat.syntax().parent()?; - - let ty = if let Some(pat_list) = - ast::RecordFieldPatList::cast(parent.clone()) - { - let record_pat = - pat_list.syntax().parent().and_then(ast::RecordPat::cast)?; - sema.type_of_pat(&ast::Pat::RecordPat(record_pat)) - } else if let Some(let_stmt) = ast::LetStmt::cast(parent.clone()) { - let field_expr = - if let ast::Expr::FieldExpr(field_expr) = let_stmt.initializer()? { - field_expr - } else { - return None; - }; - - sema.type_of_expr(&field_expr.expr()?) - } else if let Some(record_field_pat) = ast::RecordFieldPat::cast(parent) { - let record_pat = record_field_pat - .syntax() - .parent() - .and_then(ast::RecordFieldPatList::cast)? - .syntax() - .parent() - .and_then(ast::RecordPat::cast)?; - sema.type_of_pat(&ast::Pat::RecordPat(record_pat)) + if sema.is_unsafe_pat(&ast::Pat::BindPat(bind_pat)) { + Some(HighlightModifier::Unsafe) } else { None - }?; - - if !ty.is_packed(db) { - return None; } - - Some(HighlightModifier::Unsafe) })(); if let Some(modifier) = modifier { From 55633f34048434de18d54b4300bca186db052cf5 Mon Sep 17 00:00:00 2001 From: Paul Daniel Faria Date: Thu, 23 Jul 2020 09:31:07 -0400 Subject: [PATCH 022/119] Fix rebase errors --- crates/ra_ide/test_data/highlight_doctest.html | 2 +- crates/ra_ide/test_data/highlight_injection.html | 2 +- crates/ra_ide/test_data/highlight_unsafe.html | 5 +++-- crates/ra_ide/test_data/highlighting.html | 10 +++++----- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/crates/ra_ide/test_data/highlight_doctest.html b/crates/ra_ide/test_data/highlight_doctest.html index 6322d404fb..46c1e0a11f 100644 --- a/crates/ra_ide/test_data/highlight_doctest.html +++ b/crates/ra_ide/test_data/highlight_doctest.html @@ -87,7 +87,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd /// ```sh /// echo 1 /// ``` - pub fn foo(&self) -> bool { + pub fn foo(&self) -> bool { true } } diff --git a/crates/ra_ide/test_data/highlight_injection.html b/crates/ra_ide/test_data/highlight_injection.html index 18addd00d2..60c3943994 100644 --- a/crates/ra_ide/test_data/highlight_injection.html +++ b/crates/ra_ide/test_data/highlight_injection.html @@ -35,7 +35,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd .unresolved_reference { color: #FC5555; text-decoration: wavy underline; } -
fn fixture(ra_fixture: &str) {}
+
fn fixture(ra_fixture: &str) {}
 
 fn main() {
     fixture(r#"
diff --git a/crates/ra_ide/test_data/highlight_unsafe.html b/crates/ra_ide/test_data/highlight_unsafe.html
index 79409fe816..454ff6d5f8 100644
--- a/crates/ra_ide/test_data/highlight_unsafe.html
+++ b/crates/ra_ide/test_data/highlight_unsafe.html
@@ -45,7 +45,7 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
 struct HasUnsafeFn;
 
 impl HasUnsafeFn {
-    unsafe fn unsafe_method(&self) {}
+    unsafe fn unsafe_method(&self) {}
 }
 
 struct TypeForStaticMut {
@@ -55,9 +55,10 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
 static mut global_mut: TypeForStaticMut = TypeForStaticMut { a: 0 };
 
 fn main() {
-    let x = &5 as *const usize;
+    let x = &5 as *const _ as *const usize;
     let u = Union { b: 0 };
     unsafe {
+        // unsafe fn and method calls
         unsafe_fn();
         let b = u.b;
         match u {
diff --git a/crates/ra_ide/test_data/highlighting.html b/crates/ra_ide/test_data/highlighting.html
index 8e0160eee5..678cf9bd33 100644
--- a/crates/ra_ide/test_data/highlighting.html
+++ b/crates/ra_ide/test_data/highlighting.html
@@ -45,11 +45,11 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
 }
 
 trait Bar {
-    fn bar(&self) -> i32;
+    fn bar(&self) -> i32;
 }
 
 impl Bar for Foo {
-    fn bar(&self) -> i32 {
+    fn bar(&self) -> i32 {
         self.x
     }
 }
@@ -59,7 +59,7 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
         self.x
     }
 
-    fn qux(&mut self) {
+    fn qux(&mut self) {
         self.x = 0;
     }
 }
@@ -107,8 +107,8 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
     noop!(noop!(1));
 
     let mut x = 42;
-    let y = &mut x;
-    let z = &y;
+    let y = &mut x;
+    let z = &y;
 
     let Foo { x: z, y } = Foo { x: z, y };
 

From 87cb09365cf841b559e76951eedb826f2d4d3dfd Mon Sep 17 00:00:00 2001
From: Paul Daniel Faria 
Date: Thu, 23 Jul 2020 09:39:53 -0400
Subject: [PATCH 023/119] Remove merge backup

---
 crates/ra_ide/src/call_info.rs.orig | 769 ----------------------------
 1 file changed, 769 deletions(-)
 delete mode 100644 crates/ra_ide/src/call_info.rs.orig

diff --git a/crates/ra_ide/src/call_info.rs.orig b/crates/ra_ide/src/call_info.rs.orig
deleted file mode 100644
index 0e04c0b607..0000000000
--- a/crates/ra_ide/src/call_info.rs.orig
+++ /dev/null
@@ -1,769 +0,0 @@
-//! FIXME: write short doc here
-use either::Either;
-use hir::{Docs, HirDisplay, Semantics, Type};
-use ra_ide_db::RootDatabase;
-use ra_syntax::{
-    ast::{self, ArgListOwner},
-    match_ast, AstNode, SyntaxNode, SyntaxToken, TextRange, TextSize,
-};
-use stdx::format_to;
-use test_utils::mark;
-
-use crate::FilePosition;
-
-/// Contains information about a call site. Specifically the
-/// `FunctionSignature`and current parameter.
-#[derive(Debug)]
-pub struct CallInfo {
-    pub doc: Option,
-    pub signature: String,
-    pub active_parameter: Option,
-    parameters: Vec,
-}
-
-impl CallInfo {
-    pub fn parameter_labels(&self) -> impl Iterator + '_ {
-        self.parameters.iter().map(move |&it| &self.signature[it])
-    }
-    pub fn parameter_ranges(&self) -> &[TextRange] {
-        &self.parameters
-    }
-    fn push_param(&mut self, param: &str) {
-        if !self.signature.ends_with('(') {
-            self.signature.push_str(", ");
-        }
-        let start = TextSize::of(&self.signature);
-        self.signature.push_str(param);
-        let end = TextSize::of(&self.signature);
-        self.parameters.push(TextRange::new(start, end))
-    }
-}
-
-/// Computes parameter information for the given call expression.
-pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option {
-    let sema = Semantics::new(db);
-    let file = sema.parse(position.file_id);
-    let file = file.syntax();
-    let token = file.token_at_offset(position.offset).next()?;
-    let token = sema.descend_into_macros(token);
-
-    let (callable, active_parameter) = call_info_impl(&sema, token)?;
-
-    let mut res =
-        CallInfo { doc: None, signature: String::new(), parameters: vec![], active_parameter };
-
-    match callable.kind() {
-        hir::CallableKind::Function(func) => {
-            res.doc = func.docs(db).map(|it| it.as_str().to_string());
-            format_to!(res.signature, "fn {}", func.name(db));
-        }
-        hir::CallableKind::TupleStruct(strukt) => {
-            res.doc = strukt.docs(db).map(|it| it.as_str().to_string());
-            format_to!(res.signature, "struct {}", strukt.name(db));
-        }
-        hir::CallableKind::TupleEnumVariant(variant) => {
-            res.doc = variant.docs(db).map(|it| it.as_str().to_string());
-            format_to!(
-                res.signature,
-                "enum {}::{}",
-                variant.parent_enum(db).name(db),
-                variant.name(db)
-            );
-        }
-        hir::CallableKind::Closure => (),
-    }
-
-    res.signature.push('(');
-    {
-        if let Some(self_param) = callable.receiver_param(db) {
-            format_to!(res.signature, "{}", self_param)
-        }
-        let mut buf = String::new();
-        for (pat, ty) in callable.params(db) {
-            buf.clear();
-            if let Some(pat) = pat {
-                match pat {
-                    Either::Left(_self) => format_to!(buf, "self: "),
-                    Either::Right(pat) => format_to!(buf, "{}: ", pat),
-                }
-            }
-            format_to!(buf, "{}", ty.display(db));
-            res.push_param(&buf);
-        }
-    }
-    res.signature.push(')');
-
-    match callable.kind() {
-        hir::CallableKind::Function(_) | hir::CallableKind::Closure => {
-            let ret_type = callable.return_type();
-            if !ret_type.is_unit() {
-                format_to!(res.signature, " -> {}", ret_type.display(db));
-            }
-        }
-        hir::CallableKind::TupleStruct(_) | hir::CallableKind::TupleEnumVariant(_) => {}
-    }
-    Some(res)
-}
-
-fn call_info_impl(
-    sema: &Semantics,
-    token: SyntaxToken,
-) -> Option<(hir::Callable, Option)> {
-    // Find the calling expression and it's NameRef
-    let calling_node = FnCallNode::with_node(&token.parent())?;
-
-<<<<<<< HEAD
-    let callable = match &calling_node {
-        FnCallNode::CallExpr(call) => sema.type_of_expr(&call.expr()?)?.as_callable(sema.db)?,
-        FnCallNode::MethodCallExpr(call) => sema.resolve_method_call_as_callable(call)?,
-    };
-    let active_param = if let Some(arg_list) = calling_node.arg_list() {
-        // Number of arguments specified at the call site
-        let num_args_at_callsite = arg_list.args().count();
-
-        let arg_list_range = arg_list.syntax().text_range();
-        if !arg_list_range.contains_inclusive(token.text_range().start()) {
-            mark::hit!(call_info_bad_offset);
-            return None;
-=======
-    let (mut call_info, has_self) = match &calling_node {
-        FnCallNode::CallExpr(call) => {
-            //FIXME: Type::as_callable is broken
-            let callable_def = sema.type_of_expr(&call.expr()?)?.as_callable()?;
-            match callable_def {
-                hir::CallableDef::FunctionId(it) => {
-                    let fn_def = it.into();
-                    (CallInfo::with_fn(sema.db, fn_def), fn_def.has_self_param(sema.db))
-                }
-                hir::CallableDef::StructId(it) => {
-                    (CallInfo::with_struct(sema.db, it.into())?, false)
-                }
-                hir::CallableDef::EnumVariantId(it) => {
-                    (CallInfo::with_enum_variant(sema.db, it.into())?, false)
-                }
-            }
-        }
-        FnCallNode::MethodCallExpr(method_call) => {
-            let function = sema.resolve_method_call(&method_call)?;
-            (CallInfo::with_fn(sema.db, function), function.has_self_param(sema.db))
-        }
-        FnCallNode::MacroCallExpr(macro_call) => {
-            let macro_def = sema.resolve_macro_call(¯o_call)?;
-            (CallInfo::with_macro(sema.db, macro_def)?, false)
->>>>>>> Revert function structs back to using bool to track self param, use first param for self information in syntax highlighting instead
-        }
-        let param = std::cmp::min(
-            num_args_at_callsite,
-            arg_list
-                .args()
-                .take_while(|arg| arg.syntax().text_range().end() <= token.text_range().start())
-                .count(),
-        );
-
-        Some(param)
-    } else {
-        None
-    };
-    Some((callable, active_param))
-}
-
-#[derive(Debug)]
-pub(crate) struct ActiveParameter {
-    pub(crate) ty: Type,
-    pub(crate) name: String,
-}
-
-impl ActiveParameter {
-    pub(crate) fn at(db: &RootDatabase, position: FilePosition) -> Option {
-        let sema = Semantics::new(db);
-        let file = sema.parse(position.file_id);
-        let file = file.syntax();
-        let token = file.token_at_offset(position.offset).next()?;
-        let token = sema.descend_into_macros(token);
-        Self::at_token(&sema, token)
-    }
-
-    pub(crate) fn at_token(sema: &Semantics, token: SyntaxToken) -> Option {
-        let (signature, active_parameter) = call_info_impl(&sema, token)?;
-
-        let idx = active_parameter?;
-        let mut params = signature.params(sema.db);
-        if !(idx < params.len()) {
-            mark::hit!(too_many_arguments);
-            return None;
-        }
-        let (pat, ty) = params.swap_remove(idx);
-        let name = pat?.to_string();
-        Some(ActiveParameter { ty, name })
-    }
-}
-
-#[derive(Debug)]
-pub(crate) enum FnCallNode {
-    CallExpr(ast::CallExpr),
-    MethodCallExpr(ast::MethodCallExpr),
-}
-
-impl FnCallNode {
-    fn with_node(syntax: &SyntaxNode) -> Option {
-        syntax.ancestors().find_map(|node| {
-            match_ast! {
-                match node {
-                    ast::CallExpr(it) => Some(FnCallNode::CallExpr(it)),
-                    ast::MethodCallExpr(it) => {
-                        let arg_list = it.arg_list()?;
-                        if !arg_list.syntax().text_range().contains_range(syntax.text_range()) {
-                            return None;
-                        }
-                        Some(FnCallNode::MethodCallExpr(it))
-                    },
-                    _ => None,
-                }
-            }
-        })
-    }
-
-    pub(crate) fn with_node_exact(node: &SyntaxNode) -> Option {
-        match_ast! {
-            match node {
-                ast::CallExpr(it) => Some(FnCallNode::CallExpr(it)),
-                ast::MethodCallExpr(it) => Some(FnCallNode::MethodCallExpr(it)),
-                _ => None,
-            }
-        }
-    }
-
-    pub(crate) fn name_ref(&self) -> Option {
-        match self {
-            FnCallNode::CallExpr(call_expr) => Some(match call_expr.expr()? {
-                ast::Expr::PathExpr(path_expr) => path_expr.path()?.segment()?.name_ref()?,
-                _ => return None,
-            }),
-
-            FnCallNode::MethodCallExpr(call_expr) => {
-                call_expr.syntax().children().filter_map(ast::NameRef::cast).next()
-            }
-        }
-    }
-
-    fn arg_list(&self) -> Option {
-        match self {
-            FnCallNode::CallExpr(expr) => expr.arg_list(),
-            FnCallNode::MethodCallExpr(expr) => expr.arg_list(),
-        }
-    }
-}
-
-#[cfg(test)]
-mod tests {
-    use expect::{expect, Expect};
-    use test_utils::mark;
-
-    use crate::mock_analysis::analysis_and_position;
-
-    fn check(ra_fixture: &str, expect: Expect) {
-        let (analysis, position) = analysis_and_position(ra_fixture);
-        let call_info = analysis.call_info(position).unwrap();
-        let actual = match call_info {
-            Some(call_info) => {
-                let docs = match &call_info.doc {
-                    None => "".to_string(),
-                    Some(docs) => format!("{}\n------\n", docs.as_str()),
-                };
-                let params = call_info
-                    .parameter_labels()
-                    .enumerate()
-                    .map(|(i, param)| {
-                        if Some(i) == call_info.active_parameter {
-                            format!("<{}>", param)
-                        } else {
-                            param.to_string()
-                        }
-                    })
-                    .collect::>()
-                    .join(", ");
-                format!("{}{}\n({})\n", docs, call_info.signature, params)
-            }
-            None => String::new(),
-        };
-        expect.assert_eq(&actual);
-    }
-
-    #[test]
-    fn test_fn_signature_two_args() {
-        check(
-            r#"
-fn foo(x: u32, y: u32) -> u32 {x + y}
-fn bar() { foo(<|>3, ); }
-"#,
-            expect![[r#"
-                fn foo(x: u32, y: u32) -> u32
-                (, y: u32)
-            "#]],
-        );
-        check(
-            r#"
-fn foo(x: u32, y: u32) -> u32 {x + y}
-fn bar() { foo(3<|>, ); }
-"#,
-            expect![[r#"
-                fn foo(x: u32, y: u32) -> u32
-                (, y: u32)
-            "#]],
-        );
-        check(
-            r#"
-fn foo(x: u32, y: u32) -> u32 {x + y}
-fn bar() { foo(3,<|> ); }
-"#,
-            expect![[r#"
-                fn foo(x: u32, y: u32) -> u32
-                (x: u32, )
-            "#]],
-        );
-        check(
-            r#"
-fn foo(x: u32, y: u32) -> u32 {x + y}
-fn bar() { foo(3, <|>); }
-"#,
-            expect![[r#"
-                fn foo(x: u32, y: u32) -> u32
-                (x: u32, )
-            "#]],
-        );
-    }
-
-    #[test]
-    fn test_fn_signature_two_args_empty() {
-        check(
-            r#"
-fn foo(x: u32, y: u32) -> u32 {x + y}
-fn bar() { foo(<|>); }
-"#,
-            expect![[r#"
-                fn foo(x: u32, y: u32) -> u32
-                (, y: u32)
-            "#]],
-        );
-    }
-
-    #[test]
-    fn test_fn_signature_two_args_first_generics() {
-        check(
-            r#"
-fn foo(x: T, y: U) -> u32
-    where T: Copy + Display, U: Debug
-{ x + y }
-
-fn bar() { foo(<|>3, ); }
-"#,
-            expect![[r#"
-                fn foo(x: i32, y: {unknown}) -> u32
-                (, y: {unknown})
-            "#]],
-        );
-    }
-
-    #[test]
-    fn test_fn_signature_no_params() {
-        check(
-            r#"
-fn foo() -> T where T: Copy + Display {}
-fn bar() { foo(<|>); }
-"#,
-            expect![[r#"
-                fn foo() -> {unknown}
-                ()
-            "#]],
-        );
-    }
-
-    #[test]
-    fn test_fn_signature_for_impl() {
-        check(
-            r#"
-struct F;
-impl F { pub fn new() { } }
-fn bar() {
-    let _ : F = F::new(<|>);
-}
-"#,
-            expect![[r#"
-                fn new()
-                ()
-            "#]],
-        );
-    }
-
-    #[test]
-    fn test_fn_signature_for_method_self() {
-        check(
-            r#"
-struct S;
-impl S { pub fn do_it(&self) {} }
-
-fn bar() {
-    let s: S = S;
-    s.do_it(<|>);
-}
-"#,
-            expect![[r#"
-                fn do_it(&self)
-                ()
-            "#]],
-        );
-    }
-
-    #[test]
-    fn test_fn_signature_for_method_with_arg() {
-        check(
-            r#"
-struct S;
-impl S {
-    fn foo(&self, x: i32) {}
-}
-
-fn main() { S.foo(<|>); }
-"#,
-            expect![[r#"
-                fn foo(&self, x: i32)
-                ()
-            "#]],
-        );
-    }
-
-    #[test]
-    fn test_fn_signature_for_method_with_arg_as_assoc_fn() {
-        check(
-            r#"
-struct S;
-impl S {
-    fn foo(&self, x: i32) {}
-}
-
-fn main() { S::foo(<|>); }
-"#,
-            expect![[r#"
-                fn foo(self: &S, x: i32)
-                (, x: i32)
-            "#]],
-        );
-    }
-
-    #[test]
-    fn test_fn_signature_with_docs_simple() {
-        check(
-            r#"
-/// test
-// non-doc-comment
-fn foo(j: u32) -> u32 {
-    j
-}
-
-fn bar() {
-    let _ = foo(<|>);
-}
-"#,
-            expect![[r#"
-                test
-                ------
-                fn foo(j: u32) -> u32
-                ()
-            "#]],
-        );
-    }
-
-    #[test]
-    fn test_fn_signature_with_docs() {
-        check(
-            r#"
-/// Adds one to the number given.
-///
-/// # Examples
-///
-/// ```
-/// let five = 5;
-///
-/// assert_eq!(6, my_crate::add_one(5));
-/// ```
-pub fn add_one(x: i32) -> i32 {
-    x + 1
-}
-
-pub fn do() {
-    add_one(<|>
-}"#,
-            expect![[r##"
-                Adds one to the number given.
-
-                # Examples
-
-                ```
-                let five = 5;
-
-                assert_eq!(6, my_crate::add_one(5));
-                ```
-                ------
-                fn add_one(x: i32) -> i32
-                ()
-            "##]],
-        );
-    }
-
-    #[test]
-    fn test_fn_signature_with_docs_impl() {
-        check(
-            r#"
-struct addr;
-impl addr {
-    /// Adds one to the number given.
-    ///
-    /// # Examples
-    ///
-    /// ```
-    /// let five = 5;
-    ///
-    /// assert_eq!(6, my_crate::add_one(5));
-    /// ```
-    pub fn add_one(x: i32) -> i32 {
-        x + 1
-    }
-}
-
-pub fn do_it() {
-    addr {};
-    addr::add_one(<|>);
-}
-"#,
-            expect![[r##"
-                Adds one to the number given.
-
-                # Examples
-
-                ```
-                let five = 5;
-
-                assert_eq!(6, my_crate::add_one(5));
-                ```
-                ------
-                fn add_one(x: i32) -> i32
-                ()
-            "##]],
-        );
-    }
-
-    #[test]
-    fn test_fn_signature_with_docs_from_actix() {
-        check(
-            r#"
-struct WriteHandler;
-
-impl WriteHandler {
-    /// Method is called when writer emits error.
-    ///
-    /// If this method returns `ErrorAction::Continue` writer processing
-    /// continues otherwise stream processing stops.
-    fn error(&mut self, err: E, ctx: &mut Self::Context) -> Running {
-        Running::Stop
-    }
-
-    /// Method is called when writer finishes.
-    ///
-    /// By default this method stops actor's `Context`.
-    fn finished(&mut self, ctx: &mut Self::Context) {
-        ctx.stop()
-    }
-}
-
-pub fn foo(mut r: WriteHandler<()>) {
-    r.finished(<|>);
-}
-"#,
-            expect![[r#"
-                Method is called when writer finishes.
-
-                By default this method stops actor's `Context`.
-                ------
-                fn finished(&mut self, ctx: &mut {unknown})
-                ()
-            "#]],
-        );
-    }
-
-    #[test]
-    fn call_info_bad_offset() {
-        mark::check!(call_info_bad_offset);
-        check(
-            r#"
-fn foo(x: u32, y: u32) -> u32 {x + y}
-fn bar() { foo <|> (3, ); }
-"#,
-            expect![[""]],
-        );
-    }
-
-    #[test]
-    fn test_nested_method_in_lambda() {
-        check(
-            r#"
-struct Foo;
-impl Foo { fn bar(&self, _: u32) { } }
-
-fn bar(_: u32) { }
-
-fn main() {
-    let foo = Foo;
-    std::thread::spawn(move || foo.bar(<|>));
-}
-"#,
-            expect![[r#"
-                fn bar(&self, _: u32)
-                (<_: u32>)
-            "#]],
-        );
-    }
-
-    #[test]
-    fn works_for_tuple_structs() {
-        check(
-            r#"
-/// A cool tuple struct
-struct S(u32, i32);
-fn main() {
-    let s = S(0, <|>);
-}
-"#,
-            expect![[r#"
-                A cool tuple struct
-                ------
-                struct S(u32, i32)
-                (u32, )
-            "#]],
-        );
-    }
-
-    #[test]
-    fn generic_struct() {
-        check(
-            r#"
-struct S(T);
-fn main() {
-    let s = S(<|>);
-}
-"#,
-            expect![[r#"
-                struct S({unknown})
-                (<{unknown}>)
-            "#]],
-        );
-    }
-
-    #[test]
-    fn works_for_enum_variants() {
-        check(
-            r#"
-enum E {
-    /// A Variant
-    A(i32),
-    /// Another
-    B,
-    /// And C
-    C { a: i32, b: i32 }
-}
-
-fn main() {
-    let a = E::A(<|>);
-}
-"#,
-            expect![[r#"
-                A Variant
-                ------
-                enum E::A(i32)
-                ()
-            "#]],
-        );
-    }
-
-    #[test]
-    fn cant_call_struct_record() {
-        check(
-            r#"
-struct S { x: u32, y: i32 }
-fn main() {
-    let s = S(<|>);
-}
-"#,
-            expect![[""]],
-        );
-    }
-
-    #[test]
-    fn cant_call_enum_record() {
-        check(
-            r#"
-enum E {
-    /// A Variant
-    A(i32),
-    /// Another
-    B,
-    /// And C
-    C { a: i32, b: i32 }
-}
-
-fn main() {
-    let a = E::C(<|>);
-}
-"#,
-            expect![[""]],
-        );
-    }
-
-    #[test]
-    fn fn_signature_for_call_in_macro() {
-        check(
-            r#"
-macro_rules! id { ($($tt:tt)*) => { $($tt)* } }
-fn foo() { }
-id! {
-    fn bar() { foo(<|>); }
-}
-"#,
-            expect![[r#"
-                fn foo()
-                ()
-            "#]],
-        );
-    }
-
-    #[test]
-    fn call_info_for_lambdas() {
-        check(
-            r#"
-struct S;
-fn foo(s: S) -> i32 { 92 }
-fn main() {
-    (|s| foo(s))(<|>)
-}
-        "#,
-            expect![[r#"
-                (S) -> i32
-                ()
-            "#]],
-        )
-    }
-
-    #[test]
-    fn call_info_for_fn_ptr() {
-        check(
-            r#"
-fn main(f: fn(i32, f64) -> char) {
-    f(0, <|>)
-}
-        "#,
-            expect![[r#"
-                (i32, f64) -> char
-                (i32, )
-            "#]],
-        )
-    }
-}

From a6af0272f7bf129a3063cdd7096f685fc58438e6 Mon Sep 17 00:00:00 2001
From: Paul Daniel Faria 
Date: Thu, 23 Jul 2020 10:11:37 -0400
Subject: [PATCH 024/119] Move semantic logic into Semantics, fix missing tag
 for safe amp operator, using functional methods rather than clunky inline
 closure

---
 crates/ra_hir/src/semantics.rs                | 110 ++++++++++++------
 crates/ra_ide/src/syntax_highlighting.rs      |  89 +++++---------
 .../ra_ide/test_data/highlight_doctest.html   |   2 +-
 .../ra_ide/test_data/highlight_injection.html |   2 +-
 crates/ra_ide/test_data/highlight_unsafe.html |   4 +-
 crates/ra_ide/test_data/highlighting.html     |  10 +-
 6 files changed, 112 insertions(+), 105 deletions(-)

diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs
index 1072b39718..f706a186e7 100644
--- a/crates/ra_hir/src/semantics.rs
+++ b/crates/ra_hir/src/semantics.rs
@@ -25,7 +25,8 @@ use crate::{
     semantics::source_to_def::{ChildContainer, SourceToDefCache, SourceToDefCtx},
     source_analyzer::{resolve_hir_path, resolve_hir_path_qualifier, SourceAnalyzer},
     AssocItem, Callable, Crate, Field, Function, HirFileId, ImplDef, InFile, Local, MacroDef,
-    Module, ModuleDef, Name, Origin, Path, ScopeDef, Trait, Type, TypeAlias, TypeParam, VariantDef,
+    Module, ModuleDef, Name, Origin, Path, ScopeDef, Trait, Type, TypeAlias, TypeParam, TypeRef,
+    VariantDef,
 };
 use resolver::TypeNs;
 
@@ -280,45 +281,84 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
         self.imp.assert_contains_node(node)
     }
 
-    pub fn is_unsafe_pat(&self, pat: &ast::Pat) -> bool {
-        let ty = (|| {
-            let parent = match pat {
-                ast::Pat::BindPat(bind_pat) => bind_pat.syntax().parent()?,
-                _ => return None,
-            };
+    pub fn is_unsafe_method_call(&self, method_call_expr: ast::MethodCallExpr) -> Option<()> {
+        let expr = method_call_expr.expr()?;
+        let field_expr =
+            if let ast::Expr::FieldExpr(field_expr) = expr { field_expr } else { return None };
+        let ty = self.type_of_expr(&field_expr.expr()?)?;
+        if !ty.is_packed(self.db) {
+            return None;
+        }
 
-            // `BindPat` can live under `RecordPat` directly under `RecordFieldPat` or
-            // `RecordFieldPatList`. `RecordFieldPat` also lives under `RecordFieldPatList`,
-            // so this tries to lookup the `BindPat` anywhere along that structure to the
-            // `RecordPat` so we can get the containing type.
-            let record_pat = ast::RecordFieldPat::cast(parent.clone())
-                .and_then(|record_pat| record_pat.syntax().parent())
-                .or_else(|| Some(parent.clone()))
-                .and_then(|parent| {
-                    ast::RecordFieldPatList::cast(parent)?
-                        .syntax()
-                        .parent()
-                        .and_then(ast::RecordPat::cast)
-                });
-
-            // If this doesn't match a `RecordPat`, fallback to a `LetStmt` to see if
-            // this is initialized from a `FieldExpr`.
-            if let Some(record_pat) = record_pat {
-                self.type_of_pat(&ast::Pat::RecordPat(record_pat))
-            } else if let Some(let_stmt) = ast::LetStmt::cast(parent) {
-                let field_expr = match let_stmt.initializer()? {
-                    ast::Expr::FieldExpr(field_expr) => field_expr,
-                    _ => return None,
-                };
-
-                self.type_of_expr(&field_expr.expr()?)
+        let func = self.resolve_method_call(&method_call_expr)?;
+        if func.has_self_param(self.db) {
+            let params = func.params(self.db);
+            if matches!(params.into_iter().next(), Some(TypeRef::Reference(..))) {
+                Some(())
             } else {
                 None
             }
-        })();
+        } else {
+            None
+        }
+    }
 
-        // Binding a reference to a packed type is possibly unsafe.
-        ty.map(|ty| ty.is_packed(self.db)).unwrap_or(false)
+    pub fn is_unsafe_ref_expr(&self, ref_expr: &ast::RefExpr) -> bool {
+        ref_expr
+            .expr()
+            .and_then(|expr| {
+                let field_expr = match expr {
+                    ast::Expr::FieldExpr(field_expr) => field_expr,
+                    _ => return None,
+                };
+                let expr = field_expr.expr()?;
+                self.type_of_expr(&expr)
+            })
+            // Binding a reference to a packed type is possibly unsafe.
+            .map(|ty| ty.is_packed(self.db))
+            .unwrap_or(false)
+
+        // FIXME This needs layout computation to be correct. It will highlight
+        // more than it should with the current implementation.
+    }
+
+    pub fn is_unsafe_bind_pat(&self, bind_pat: &ast::BindPat) -> bool {
+        bind_pat
+            .syntax()
+            .parent()
+            .and_then(|parent| {
+                // `BindPat` can live under `RecordPat` directly under `RecordFieldPat` or
+                // `RecordFieldPatList`. `RecordFieldPat` also lives under `RecordFieldPatList`,
+                // so this tries to lookup the `BindPat` anywhere along that structure to the
+                // `RecordPat` so we can get the containing type.
+                let record_pat = ast::RecordFieldPat::cast(parent.clone())
+                    .and_then(|record_pat| record_pat.syntax().parent())
+                    .or_else(|| Some(parent.clone()))
+                    .and_then(|parent| {
+                        ast::RecordFieldPatList::cast(parent)?
+                            .syntax()
+                            .parent()
+                            .and_then(ast::RecordPat::cast)
+                    });
+
+                // If this doesn't match a `RecordPat`, fallback to a `LetStmt` to see if
+                // this is initialized from a `FieldExpr`.
+                if let Some(record_pat) = record_pat {
+                    self.type_of_pat(&ast::Pat::RecordPat(record_pat))
+                } else if let Some(let_stmt) = ast::LetStmt::cast(parent) {
+                    let field_expr = match let_stmt.initializer()? {
+                        ast::Expr::FieldExpr(field_expr) => field_expr,
+                        _ => return None,
+                    };
+
+                    self.type_of_expr(&field_expr.expr()?)
+                } else {
+                    None
+                }
+            })
+            // Binding a reference to a packed type is possibly unsafe.
+            .map(|ty| ty.is_packed(self.db))
+            .unwrap_or(false)
     }
 }
 
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs
index cf93205b6e..e29f65a784 100644
--- a/crates/ra_ide/src/syntax_highlighting.rs
+++ b/crates/ra_ide/src/syntax_highlighting.rs
@@ -565,29 +565,21 @@ fn highlight_element(
                 _ => h,
             }
         }
-        T![&] => {
-            let ref_expr = element.parent().and_then(ast::RefExpr::cast)?;
-            let expr = ref_expr.expr()?;
-            let field_expr = match expr {
-                ast::Expr::FieldExpr(fe) => fe,
-                _ => return None,
-            };
-
-            let expr = field_expr.expr()?;
-            let ty = sema.type_of_expr(&expr)?;
-            if !ty.is_packed(db) {
-                return None;
-            }
-
-            // FIXME This needs layout computation to be correct. It will highlight
-            // more than it should with the current implementation.
-
-            HighlightTag::Operator | HighlightModifier::Unsafe
-        }
         p if p.is_punct() => match p {
-            T![::] | T![->] | T![=>] | T![&] | T![..] | T![=] | T![@] => {
-                HighlightTag::Operator.into()
+            T![&] => {
+                let h = HighlightTag::Operator.into();
+                let is_unsafe = element
+                    .parent()
+                    .and_then(ast::RefExpr::cast)
+                    .map(|ref_expr| sema.is_unsafe_ref_expr(&ref_expr))
+                    .unwrap_or(false);
+                if is_unsafe {
+                    h | HighlightModifier::Unsafe
+                } else {
+                    h
+                }
             }
+            T![::] | T![->] | T![=>] | T![..] | T![=] | T![@] => HighlightTag::Operator.into(),
             T![!] if element.parent().and_then(ast::MacroCall::cast).is_some() => {
                 HighlightTag::Macro.into()
             }
@@ -668,22 +660,18 @@ fn highlight_element(
                         HighlightTag::SelfKeyword.into()
                     }
                 }
-                T![ref] => {
-                    let modifier: Option = (|| {
-                        let bind_pat = element.parent().and_then(ast::BindPat::cast)?;
-                        if sema.is_unsafe_pat(&ast::Pat::BindPat(bind_pat)) {
+                T![ref] => element
+                    .parent()
+                    .and_then(ast::BindPat::cast)
+                    .and_then(|bind_pat| {
+                        if sema.is_unsafe_bind_pat(&bind_pat) {
                             Some(HighlightModifier::Unsafe)
                         } else {
                             None
                         }
-                    })();
-
-                    if let Some(modifier) = modifier {
-                        h | modifier
-                    } else {
-                        h
-                    }
-                }
+                    })
+                    .map(|modifier| h | modifier)
+                    .unwrap_or(h),
                 _ => h,
             }
         }
@@ -713,31 +701,6 @@ fn is_child_of_impl(element: &SyntaxElement) -> bool {
     }
 }
 
-fn is_method_call_unsafe(
-    sema: &Semantics,
-    method_call_expr: ast::MethodCallExpr,
-) -> Option<()> {
-    let expr = method_call_expr.expr()?;
-    let field_expr =
-        if let ast::Expr::FieldExpr(field_expr) = expr { field_expr } else { return None };
-    let ty = sema.type_of_expr(&field_expr.expr()?)?;
-    if !ty.is_packed(sema.db) {
-        return None;
-    }
-
-    let func = sema.resolve_method_call(&method_call_expr)?;
-    if func.has_self_param(sema.db) {
-        let params = func.params(sema.db);
-        if matches!(params.into_iter().next(), Some(TypeRef::Reference(..))) {
-            Some(())
-        } else {
-            None
-        }
-    } else {
-        None
-    }
-}
-
 fn highlight_name(
     sema: &Semantics,
     db: &RootDatabase,
@@ -767,7 +730,7 @@ fn highlight_name(
                     let is_unsafe = name_ref
                         .and_then(|name_ref| name_ref.syntax().parent())
                         .and_then(ast::MethodCallExpr::cast)
-                        .and_then(|method_call_expr| is_method_call_unsafe(sema, method_call_expr));
+                        .and_then(|method_call_expr| sema.is_unsafe_method_call(method_call_expr));
                     if is_unsafe.is_some() {
                         h |= HighlightModifier::Unsafe;
                     }
@@ -846,7 +809,7 @@ fn highlight_name_ref_by_syntax(name: ast::NameRef, sema: &Semantics {
             let mut h = Highlight::new(HighlightTag::Function);
             let is_unsafe = ast::MethodCallExpr::cast(parent)
-                .and_then(|method_call_expr| is_method_call_unsafe(sema, method_call_expr));
+                .and_then(|method_call_expr| sema.is_unsafe_method_call(method_call_expr));
 
             if is_unsafe.is_some() {
                 h |= HighlightModifier::Unsafe;
@@ -866,7 +829,11 @@ fn highlight_name_ref_by_syntax(name: ast::NameRef, sema: &Semantics {
             let path = match parent.parent().and_then(ast::Path::cast) {
diff --git a/crates/ra_ide/test_data/highlight_doctest.html b/crates/ra_ide/test_data/highlight_doctest.html
index 46c1e0a11f..6322d404fb 100644
--- a/crates/ra_ide/test_data/highlight_doctest.html
+++ b/crates/ra_ide/test_data/highlight_doctest.html
@@ -87,7 +87,7 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
     /// ```sh
     /// echo 1
     /// ```
-    pub fn foo(&self) -> bool {
+    pub fn foo(&self) -> bool {
         true
     }
 }
diff --git a/crates/ra_ide/test_data/highlight_injection.html b/crates/ra_ide/test_data/highlight_injection.html
index 60c3943994..18addd00d2 100644
--- a/crates/ra_ide/test_data/highlight_injection.html
+++ b/crates/ra_ide/test_data/highlight_injection.html
@@ -35,7 +35,7 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
 
 .unresolved_reference { color: #FC5555; text-decoration: wavy underline; }
 
-
fn fixture(ra_fixture: &str) {}
+
fn fixture(ra_fixture: &str) {}
 
 fn main() {
     fixture(r#"
diff --git a/crates/ra_ide/test_data/highlight_unsafe.html b/crates/ra_ide/test_data/highlight_unsafe.html
index 454ff6d5f8..a2df2c27e6 100644
--- a/crates/ra_ide/test_data/highlight_unsafe.html
+++ b/crates/ra_ide/test_data/highlight_unsafe.html
@@ -45,7 +45,7 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
 struct HasUnsafeFn;
 
 impl HasUnsafeFn {
-    unsafe fn unsafe_method(&self) {}
+    unsafe fn unsafe_method(&self) {}
 }
 
 struct TypeForStaticMut {
@@ -55,7 +55,7 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
 static mut global_mut: TypeForStaticMut = TypeForStaticMut { a: 0 };
 
 fn main() {
-    let x = &5 as *const _ as *const usize;
+    let x = &5 as *const _ as *const usize;
     let u = Union { b: 0 };
     unsafe {
         // unsafe fn and method calls
diff --git a/crates/ra_ide/test_data/highlighting.html b/crates/ra_ide/test_data/highlighting.html
index 678cf9bd33..8e0160eee5 100644
--- a/crates/ra_ide/test_data/highlighting.html
+++ b/crates/ra_ide/test_data/highlighting.html
@@ -45,11 +45,11 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
 }
 
 trait Bar {
-    fn bar(&self) -> i32;
+    fn bar(&self) -> i32;
 }
 
 impl Bar for Foo {
-    fn bar(&self) -> i32 {
+    fn bar(&self) -> i32 {
         self.x
     }
 }
@@ -59,7 +59,7 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
         self.x
     }
 
-    fn qux(&mut self) {
+    fn qux(&mut self) {
         self.x = 0;
     }
 }
@@ -107,8 +107,8 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
     noop!(noop!(1));
 
     let mut x = 42;
-    let y = &mut x;
-    let z = &y;
+    let y = &mut x;
+    let z = &y;
 
     let Foo { x: z, y } = Foo { x: z, y };
 

From 39fdd41df4052cef5da4876067ae28615012476b Mon Sep 17 00:00:00 2001
From: Paul Daniel Faria 
Date: Thu, 23 Jul 2020 18:31:28 -0400
Subject: [PATCH 025/119] Return bool from is_unsafe_method_call and cleanup
 usages

---
 crates/ra_hir/src/semantics.rs           | 38 ++++++++++++------------
 crates/ra_ide/src/syntax_highlighting.rs | 11 +++----
 2 files changed, 25 insertions(+), 24 deletions(-)

diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs
index f706a186e7..9697c7082b 100644
--- a/crates/ra_hir/src/semantics.rs
+++ b/crates/ra_hir/src/semantics.rs
@@ -281,26 +281,26 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
         self.imp.assert_contains_node(node)
     }
 
-    pub fn is_unsafe_method_call(&self, method_call_expr: ast::MethodCallExpr) -> Option<()> {
-        let expr = method_call_expr.expr()?;
-        let field_expr =
-            if let ast::Expr::FieldExpr(field_expr) = expr { field_expr } else { return None };
-        let ty = self.type_of_expr(&field_expr.expr()?)?;
-        if !ty.is_packed(self.db) {
-            return None;
-        }
+    pub fn is_unsafe_method_call(&self, method_call_expr: ast::MethodCallExpr) -> bool {
+        method_call_expr
+            .expr()
+            .and_then(|expr| {
+                let field_expr = if let ast::Expr::FieldExpr(field_expr) = expr {
+                    field_expr
+                } else {
+                    return None;
+                };
+                let ty = self.type_of_expr(&field_expr.expr()?)?;
+                if !ty.is_packed(self.db) {
+                    return None;
+                }
 
-        let func = self.resolve_method_call(&method_call_expr)?;
-        if func.has_self_param(self.db) {
-            let params = func.params(self.db);
-            if matches!(params.into_iter().next(), Some(TypeRef::Reference(..))) {
-                Some(())
-            } else {
-                None
-            }
-        } else {
-            None
-        }
+                let func = self.resolve_method_call(&method_call_expr)?;
+                let is_unsafe = func.has_self_param(self.db)
+                    && matches!(func.params(self.db).first(), Some(TypeRef::Reference(..)));
+                Some(is_unsafe)
+            })
+            .unwrap_or(false)
     }
 
     pub fn is_unsafe_ref_expr(&self, ref_expr: &ast::RefExpr) -> bool {
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs
index e29f65a784..4527885e93 100644
--- a/crates/ra_ide/src/syntax_highlighting.rs
+++ b/crates/ra_ide/src/syntax_highlighting.rs
@@ -730,8 +730,9 @@ fn highlight_name(
                     let is_unsafe = name_ref
                         .and_then(|name_ref| name_ref.syntax().parent())
                         .and_then(ast::MethodCallExpr::cast)
-                        .and_then(|method_call_expr| sema.is_unsafe_method_call(method_call_expr));
-                    if is_unsafe.is_some() {
+                        .map(|method_call_expr| sema.is_unsafe_method_call(method_call_expr))
+                        .unwrap_or(false);
+                    if is_unsafe {
                         h |= HighlightModifier::Unsafe;
                     }
                 }
@@ -809,9 +810,9 @@ fn highlight_name_ref_by_syntax(name: ast::NameRef, sema: &Semantics {
             let mut h = Highlight::new(HighlightTag::Function);
             let is_unsafe = ast::MethodCallExpr::cast(parent)
-                .and_then(|method_call_expr| sema.is_unsafe_method_call(method_call_expr));
-
-            if is_unsafe.is_some() {
+                .map(|method_call_expr| sema.is_unsafe_method_call(method_call_expr))
+                .unwrap_or(false);
+            if is_unsafe {
                 h |= HighlightModifier::Unsafe;
             }
 

From 61dff939f909e0c53bcd3be4c3e672c794022cde Mon Sep 17 00:00:00 2001
From: Paul Daniel Faria 
Date: Thu, 30 Jul 2020 09:26:40 -0400
Subject: [PATCH 026/119] Move unsafe semantics methods into `SemanticsImpl`
 and reference them in `Semantics`

---
 crates/ra_hir/src/semantics.rs | 154 ++++++++++++++++++---------------
 1 file changed, 83 insertions(+), 71 deletions(-)

diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs
index 9697c7082b..758d004098 100644
--- a/crates/ra_hir/src/semantics.rs
+++ b/crates/ra_hir/src/semantics.rs
@@ -282,83 +282,15 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
     }
 
     pub fn is_unsafe_method_call(&self, method_call_expr: ast::MethodCallExpr) -> bool {
-        method_call_expr
-            .expr()
-            .and_then(|expr| {
-                let field_expr = if let ast::Expr::FieldExpr(field_expr) = expr {
-                    field_expr
-                } else {
-                    return None;
-                };
-                let ty = self.type_of_expr(&field_expr.expr()?)?;
-                if !ty.is_packed(self.db) {
-                    return None;
-                }
-
-                let func = self.resolve_method_call(&method_call_expr)?;
-                let is_unsafe = func.has_self_param(self.db)
-                    && matches!(func.params(self.db).first(), Some(TypeRef::Reference(..)));
-                Some(is_unsafe)
-            })
-            .unwrap_or(false)
+        self.imp.is_unsafe_method_call(method_call_expr)
     }
 
     pub fn is_unsafe_ref_expr(&self, ref_expr: &ast::RefExpr) -> bool {
-        ref_expr
-            .expr()
-            .and_then(|expr| {
-                let field_expr = match expr {
-                    ast::Expr::FieldExpr(field_expr) => field_expr,
-                    _ => return None,
-                };
-                let expr = field_expr.expr()?;
-                self.type_of_expr(&expr)
-            })
-            // Binding a reference to a packed type is possibly unsafe.
-            .map(|ty| ty.is_packed(self.db))
-            .unwrap_or(false)
-
-        // FIXME This needs layout computation to be correct. It will highlight
-        // more than it should with the current implementation.
+        self.imp.is_unsafe_ref_expr(ref_expr)
     }
 
     pub fn is_unsafe_bind_pat(&self, bind_pat: &ast::BindPat) -> bool {
-        bind_pat
-            .syntax()
-            .parent()
-            .and_then(|parent| {
-                // `BindPat` can live under `RecordPat` directly under `RecordFieldPat` or
-                // `RecordFieldPatList`. `RecordFieldPat` also lives under `RecordFieldPatList`,
-                // so this tries to lookup the `BindPat` anywhere along that structure to the
-                // `RecordPat` so we can get the containing type.
-                let record_pat = ast::RecordFieldPat::cast(parent.clone())
-                    .and_then(|record_pat| record_pat.syntax().parent())
-                    .or_else(|| Some(parent.clone()))
-                    .and_then(|parent| {
-                        ast::RecordFieldPatList::cast(parent)?
-                            .syntax()
-                            .parent()
-                            .and_then(ast::RecordPat::cast)
-                    });
-
-                // If this doesn't match a `RecordPat`, fallback to a `LetStmt` to see if
-                // this is initialized from a `FieldExpr`.
-                if let Some(record_pat) = record_pat {
-                    self.type_of_pat(&ast::Pat::RecordPat(record_pat))
-                } else if let Some(let_stmt) = ast::LetStmt::cast(parent) {
-                    let field_expr = match let_stmt.initializer()? {
-                        ast::Expr::FieldExpr(field_expr) => field_expr,
-                        _ => return None,
-                    };
-
-                    self.type_of_expr(&field_expr.expr()?)
-                } else {
-                    None
-                }
-            })
-            // Binding a reference to a packed type is possibly unsafe.
-            .map(|ty| ty.is_packed(self.db))
-            .unwrap_or(false)
+        self.imp.is_unsafe_bind_pat(bind_pat)
     }
 }
 
@@ -655,6 +587,86 @@ impl<'db> SemanticsImpl<'db> {
         });
         InFile::new(file_id, node)
     }
+
+    pub fn is_unsafe_method_call(&self, method_call_expr: ast::MethodCallExpr) -> bool {
+        method_call_expr
+            .expr()
+            .and_then(|expr| {
+                let field_expr = if let ast::Expr::FieldExpr(field_expr) = expr {
+                    field_expr
+                } else {
+                    return None;
+                };
+                let ty = self.type_of_expr(&field_expr.expr()?)?;
+                if !ty.is_packed(self.db) {
+                    return None;
+                }
+
+                let func = self.resolve_method_call(&method_call_expr).map(Function::from)?;
+                let is_unsafe = func.has_self_param(self.db)
+                    && matches!(func.params(self.db).first(), Some(TypeRef::Reference(..)));
+                Some(is_unsafe)
+            })
+            .unwrap_or(false)
+    }
+
+    pub fn is_unsafe_ref_expr(&self, ref_expr: &ast::RefExpr) -> bool {
+        ref_expr
+            .expr()
+            .and_then(|expr| {
+                let field_expr = match expr {
+                    ast::Expr::FieldExpr(field_expr) => field_expr,
+                    _ => return None,
+                };
+                let expr = field_expr.expr()?;
+                self.type_of_expr(&expr)
+            })
+            // Binding a reference to a packed type is possibly unsafe.
+            .map(|ty| ty.is_packed(self.db))
+            .unwrap_or(false)
+
+        // FIXME This needs layout computation to be correct. It will highlight
+        // more than it should with the current implementation.
+    }
+
+    pub fn is_unsafe_bind_pat(&self, bind_pat: &ast::BindPat) -> bool {
+        bind_pat
+            .syntax()
+            .parent()
+            .and_then(|parent| {
+                // `BindPat` can live under `RecordPat` directly under `RecordFieldPat` or
+                // `RecordFieldPatList`. `RecordFieldPat` also lives under `RecordFieldPatList`,
+                // so this tries to lookup the `BindPat` anywhere along that structure to the
+                // `RecordPat` so we can get the containing type.
+                let record_pat = ast::RecordFieldPat::cast(parent.clone())
+                    .and_then(|record_pat| record_pat.syntax().parent())
+                    .or_else(|| Some(parent.clone()))
+                    .and_then(|parent| {
+                        ast::RecordFieldPatList::cast(parent)?
+                            .syntax()
+                            .parent()
+                            .and_then(ast::RecordPat::cast)
+                    });
+
+                // If this doesn't match a `RecordPat`, fallback to a `LetStmt` to see if
+                // this is initialized from a `FieldExpr`.
+                if let Some(record_pat) = record_pat {
+                    self.type_of_pat(&ast::Pat::RecordPat(record_pat))
+                } else if let Some(let_stmt) = ast::LetStmt::cast(parent) {
+                    let field_expr = match let_stmt.initializer()? {
+                        ast::Expr::FieldExpr(field_expr) => field_expr,
+                        _ => return None,
+                    };
+
+                    self.type_of_expr(&field_expr.expr()?)
+                } else {
+                    None
+                }
+            })
+            // Binding a reference to a packed type is possibly unsafe.
+            .map(|ty| ty.is_packed(self.db))
+            .unwrap_or(false)
+    }
 }
 
 pub trait ToDef: AstNode + Clone {

From 2199d0cda9c745ecb460dd987b8da982d02bc130 Mon Sep 17 00:00:00 2001
From: Paul Daniel Faria 
Date: Fri, 7 Aug 2020 10:40:09 -0400
Subject: [PATCH 027/119] Fix type names broken by rebase, redo expected test
 because of rebase

---
 crates/ra_hir/src/semantics.rs                | 22 ++++++++------
 crates/ra_ide/src/syntax_highlighting.rs      |  6 ++--
 crates/ra_ide/test_data/highlight_unsafe.html | 30 +++++++++++++++++--
 3 files changed, 44 insertions(+), 14 deletions(-)

diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs
index 758d004098..872f5fa4c7 100644
--- a/crates/ra_hir/src/semantics.rs
+++ b/crates/ra_hir/src/semantics.rs
@@ -289,8 +289,8 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
         self.imp.is_unsafe_ref_expr(ref_expr)
     }
 
-    pub fn is_unsafe_bind_pat(&self, bind_pat: &ast::BindPat) -> bool {
-        self.imp.is_unsafe_bind_pat(bind_pat)
+    pub fn is_unsafe_ident_pat(&self, ident_pat: &ast::IdentPat) -> bool {
+        self.imp.is_unsafe_ident_pat(ident_pat)
     }
 }
 
@@ -629,20 +629,24 @@ impl<'db> SemanticsImpl<'db> {
         // more than it should with the current implementation.
     }
 
-    pub fn is_unsafe_bind_pat(&self, bind_pat: &ast::BindPat) -> bool {
-        bind_pat
+    pub fn is_unsafe_ident_pat(&self, ident_pat: &ast::IdentPat) -> bool {
+        if !ident_pat.ref_token().is_some() {
+            return false;
+        }
+
+        ident_pat
             .syntax()
             .parent()
             .and_then(|parent| {
-                // `BindPat` can live under `RecordPat` directly under `RecordFieldPat` or
-                // `RecordFieldPatList`. `RecordFieldPat` also lives under `RecordFieldPatList`,
-                // so this tries to lookup the `BindPat` anywhere along that structure to the
+                // `IdentPat` can live under `RecordPat` directly under `RecordPatField` or
+                // `RecordPatFieldList`. `RecordPatField` also lives under `RecordPatFieldList`,
+                // so this tries to lookup the `IdentPat` anywhere along that structure to the
                 // `RecordPat` so we can get the containing type.
-                let record_pat = ast::RecordFieldPat::cast(parent.clone())
+                let record_pat = ast::RecordPatField::cast(parent.clone())
                     .and_then(|record_pat| record_pat.syntax().parent())
                     .or_else(|| Some(parent.clone()))
                     .and_then(|parent| {
-                        ast::RecordFieldPatList::cast(parent)?
+                        ast::RecordPatFieldList::cast(parent)?
                             .syntax()
                             .parent()
                             .and_then(ast::RecordPat::cast)
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs
index 4527885e93..c62bb3f1ab 100644
--- a/crates/ra_ide/src/syntax_highlighting.rs
+++ b/crates/ra_ide/src/syntax_highlighting.rs
@@ -662,9 +662,9 @@ fn highlight_element(
                 }
                 T![ref] => element
                     .parent()
-                    .and_then(ast::BindPat::cast)
-                    .and_then(|bind_pat| {
-                        if sema.is_unsafe_bind_pat(&bind_pat) {
+                    .and_then(ast::IdentPat::cast)
+                    .and_then(|ident_pat| {
+                        if sema.is_unsafe_ident_pat(&ident_pat) {
                             Some(HighlightModifier::Unsafe)
                         } else {
                             None
diff --git a/crates/ra_ide/test_data/highlight_unsafe.html b/crates/ra_ide/test_data/highlight_unsafe.html
index a2df2c27e6..552fea6689 100644
--- a/crates/ra_ide/test_data/highlight_unsafe.html
+++ b/crates/ra_ide/test_data/highlight_unsafe.html
@@ -54,6 +54,19 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
 
 static mut global_mut: TypeForStaticMut = TypeForStaticMut { a: 0 };
 
+#[repr(packed)]
+struct Packed {
+    a: u16,
+}
+
+trait DoTheAutoref {
+    fn calls_autoref(&self);
+}
+
+impl DoTheAutoref for u16 {
+    fn calls_autoref(&self) {}
+}
+
 fn main() {
     let x = &5 as *const _ as *const usize;
     let u = Union { b: 0 };
@@ -66,8 +79,21 @@ pre                 { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
             Union { a } => (),
         }
         HasUnsafeFn.unsafe_method();
-        let y = *(x);
-        let z = -x;
+
+        // unsafe deref
+        let y = *x;
+
+        // unsafe access to a static mut
         let a = global_mut.a;
+
+        // unsafe ref of packed fields
+        let packed = Packed { a: 0 };
+        let a = &packed.a;
+        let ref a = packed.a;
+        let Packed { ref a } = packed;
+        let Packed { a: ref _a } = packed;
+
+        // unsafe auto ref of packed field
+        packed.a.calls_autoref();
     }
 }
\ No newline at end of file From 72baf1acdd544c645fd69c16967b91be9e75371b Mon Sep 17 00:00:00 2001 From: Paul Daniel Faria Date: Sun, 9 Aug 2020 18:54:04 -0400 Subject: [PATCH 028/119] Remove unused import left behind after rebasing --- crates/ra_ide/src/syntax_highlighting.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index c62bb3f1ab..c10e15db8b 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -4,7 +4,7 @@ mod injection; #[cfg(test)] mod tests; -use hir::{Name, Semantics, TypeRef, VariantDef}; +use hir::{Name, Semantics, VariantDef}; use ra_ide_db::{ defs::{classify_name, classify_name_ref, Definition, NameClass, NameRefClass}, RootDatabase, From d180b8bbe8c9e31953069bae387b5214fbb51d64 Mon Sep 17 00:00:00 2001 From: Igor Aleksanov Date: Mon, 10 Aug 2020 15:50:27 +0300 Subject: [PATCH 029/119] Revert boxing for large enum variant --- crates/flycheck/src/lib.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/flycheck/src/lib.rs b/crates/flycheck/src/lib.rs index 36e0e085ac..ec769459c1 100644 --- a/crates/flycheck/src/lib.rs +++ b/crates/flycheck/src/lib.rs @@ -106,9 +106,10 @@ struct FlycheckActor { cargo_handle: Option, } +#[allow(clippy::large_enum_variant)] enum Event { Restart(Restart), - CheckEvent(Option>), + CheckEvent(Option), } impl FlycheckActor { @@ -123,7 +124,7 @@ impl FlycheckActor { let check_chan = self.cargo_handle.as_ref().map(|cargo| &cargo.receiver); select! { recv(inbox) -> msg => msg.ok().map(Event::Restart), - recv(check_chan.unwrap_or(&never())) -> msg => Some(Event::CheckEvent(msg.ok().map(Box::new))), + recv(check_chan.unwrap_or(&never())) -> msg => Some(Event::CheckEvent(msg.ok())), } } fn run(mut self, inbox: Receiver) { @@ -149,7 +150,7 @@ impl FlycheckActor { let res = cargo_handle.join(); self.send(Message::Progress(Progress::DidFinish(res))); } - Event::CheckEvent(Some(message)) => match *message { + Event::CheckEvent(Some(message)) => match message { cargo_metadata::Message::CompilerArtifact(msg) => { self.send(Message::Progress(Progress::DidCheckCrate(msg.target.name))); } From 9842bbfd275a65072bbfe05405daa73f7c27b2de Mon Sep 17 00:00:00 2001 From: kjeremy Date: Mon, 10 Aug 2020 10:56:16 -0400 Subject: [PATCH 030/119] cargo update --- Cargo.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dc49fc4bdc..a094ec4f7a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -418,9 +418,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34f595585f103464d8d2f6e9864682d74c1601fed5e07d62b1c9058dba8246fb" +checksum = "e91b62f79061a0bc2e046024cb7ba44b08419ed238ecbd9adbd787434b9e8c25" dependencies = [ "autocfg", ] @@ -465,9 +465,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b88cd59ee5f71fea89a62248fc8f387d44400cefe05ef548466d61ced9029a7" +checksum = "86b45e59b16c76b11bf9738fd5d38879d3bd28ad292d7b313608becb17ae2df9" dependencies = [ "autocfg", "hashbrown", @@ -871,9 +871,9 @@ dependencies = [ [[package]] name = "pico-args" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1eee8b1f4966c8343d7ca0f5a8452cd35d5610a2e0efbe2a68cae44bef2046" +checksum = "28b9b4df73455c861d7cbf8be42f01d3b373ed7f02e378d55fa84eafc6f638b1" [[package]] name = "plain" @@ -1694,9 +1694,9 @@ dependencies = [ [[package]] name = "tracing-tree" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37ee7f0f53ed2093971a698db799ef56a2dfd89b32e3aeb5165f0e637a02be04" +checksum = "e1a3dc4774db3a6b2d66a4f8d8de670e874ec3ed55615860c994927419b32c5f" dependencies = [ "ansi_term", "atty", From cf6d14cee7fee17ed668f502de5042136446945b Mon Sep 17 00:00:00 2001 From: Jeremy Kolb Date: Sun, 9 Aug 2020 16:27:48 -0400 Subject: [PATCH 031/119] Return InvalidRequest if Shutdown has been requested From the LSP 3.16 spec: "If a server receives requests after a shutdown request those requests should error with InvalidRequest." --- crates/rust-analyzer/src/global_state.rs | 2 ++ crates/rust-analyzer/src/main_loop.rs | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs index 0e592ac1be..658a50d150 100644 --- a/crates/rust-analyzer/src/global_state.rs +++ b/crates/rust-analyzer/src/global_state.rs @@ -73,6 +73,7 @@ pub(crate) struct GlobalState { pub(crate) mem_docs: FxHashMap, pub(crate) semantic_tokens_cache: Arc>>, pub(crate) vfs: Arc)>>, + pub(crate) shutdown_requested: bool, pub(crate) status: Status, pub(crate) source_root_config: SourceRootConfig, pub(crate) proc_macro_client: ProcMacroClient, @@ -124,6 +125,7 @@ impl GlobalState { mem_docs: FxHashMap::default(), semantic_tokens_cache: Arc::new(Default::default()), vfs: Arc::new(RwLock::new((vfs::Vfs::default(), FxHashMap::default()))), + shutdown_requested: false, status: Status::default(), source_root_config: SourceRootConfig::default(), proc_macro_client: ProcMacroClient::dummy(), diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index 0ac6434dd7..e6cf46df23 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs @@ -337,6 +337,16 @@ impl GlobalState { fn on_request(&mut self, request_received: Instant, req: Request) -> Result<()> { self.register_request(&req, request_received); + if self.shutdown_requested { + self.respond(Response::new_err( + req.id, + lsp_server::ErrorCode::InvalidRequest as i32, + "Shutdown already requested.".to_owned(), + )); + + return Ok(()); + } + if self.status == Status::Loading && req.method != "shutdown" { self.respond(lsp_server::Response::new_err( req.id, @@ -351,7 +361,10 @@ impl GlobalState { .on_sync::(|s, ()| Ok(s.fetch_workspaces()))? .on_sync::(|s, p| handlers::handle_join_lines(s.snapshot(), p))? .on_sync::(|s, p| handlers::handle_on_enter(s.snapshot(), p))? - .on_sync::(|_, ()| Ok(()))? + .on_sync::(|s, ()| { + s.shutdown_requested = true; + Ok(()) + })? .on_sync::(|s, p| { handlers::handle_selection_range(s.snapshot(), p) })? From ff60fdc315e324843589554f45e2e3c8f7cd1bf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Mon, 10 Aug 2020 21:31:38 +0300 Subject: [PATCH 032/119] Fix typos in syntax.md --- docs/dev/syntax.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/dev/syntax.md b/docs/dev/syntax.md index d4bc4b07c4..f1bcdc4aff 100644 --- a/docs/dev/syntax.md +++ b/docs/dev/syntax.md @@ -74,7 +74,7 @@ Points of note: * The original text can be recovered by concatenating the texts of all tokens in order. * Accessing a child of particular type (for example, parameter list of a function) generally involves linerary traversing the children, looking for a specific `kind`. * Modifying the tree is roughly `O(depth)`. - We don't make special efforts to guarantree that the depth is not liner, but, in practice, syntax trees are branchy and shallow. + We don't make special efforts to guarantee that the depth is not linear, but, in practice, syntax trees are branchy and shallow. * If mandatory (grammar wise) node is missing from the input, it's just missing from the tree. * If an extra erroneous input is present, it is wrapped into a node with `ERROR` kind, and treated just like any other node. * Parser errors are not a part of syntax tree. From a8beb79a160326ab04a74dfd18e4853b8cecf2cb Mon Sep 17 00:00:00 2001 From: Tim Weis Date: Tue, 11 Aug 2020 01:01:25 +0200 Subject: [PATCH 033/119] Update README.md Fixed formatting. --- docs/dev/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/dev/README.md b/docs/dev/README.md index 67813a9c07..51cf716b3d 100644 --- a/docs/dev/README.md +++ b/docs/dev/README.md @@ -256,9 +256,9 @@ Release steps: * checkout the `release` branch * reset it to `upstream/nightly` * push it to `upstream`. This triggers GitHub Actions which: - ** runs `cargo xtask dist` to package binaries and VS Code extension - ** makes a GitHub release - ** pushes VS Code extension to the marketplace + * runs `cargo xtask dist` to package binaries and VS Code extension + * makes a GitHub release + * pushes VS Code extension to the marketplace * create new changelog in `rust-analyzer.github.io` * create `rust-analyzer.github.io/git.log` file with the log of merge commits since last release 2. While the release is in progress, fill-in the changelog using `git.log` From 4f386afb16297f588484ff24e2b4693218893a94 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Tue, 11 Aug 2020 03:12:09 +0300 Subject: [PATCH 034/119] Log the command flycheck runs to debug misconfigurations Without this users have no clue why flycheck fails to run. This is what is printed to the output channel: ``` [ERROR rust_analyzer::main_loop] cargo check failed: Cargo watcher failed,the command produced no valid metadata (exit code: ExitStatus(ExitStatus(25856))) ``` I stumbled with this figuring out that rust-analyzer adds `--all-features` which is not intended for some crates in the workspace (e.g. they have mutually-exclusive features. Having the command rust-analyzer ran should help a lot --- crates/flycheck/src/lib.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/flycheck/src/lib.rs b/crates/flycheck/src/lib.rs index 7c38f5ef9d..31e14246de 100644 --- a/crates/flycheck/src/lib.rs +++ b/crates/flycheck/src/lib.rs @@ -1,4 +1,4 @@ -//! cargo_check provides the functionality needed to run `cargo check` or +//! Flycheck provides the functionality needed to run `cargo check` or //! another compatible command (f.x. clippy) in a background thread and provide //! LSP diagnostics based on the output of the command. @@ -147,6 +147,12 @@ impl FlycheckActor { // avoid busy-waiting. let cargo_handle = self.cargo_handle.take().unwrap(); let res = cargo_handle.join(); + if res.is_err() { + log::error!( + "Flycheck failed to run the following command: {:?}", + self.check_command() + ) + } self.send(Message::Progress(Progress::DidFinish(res))); } Event::CheckEvent(Some(message)) => match message { @@ -253,7 +259,7 @@ impl CargoHandle { return Err(io::Error::new( io::ErrorKind::Other, format!( - "Cargo watcher failed,the command produced no valid metadata (exit code: {:?})", + "Cargo watcher failed, the command produced no valid metadata (exit code: {:?})", exit_status ), )); From dc6e1e0dac318b36ec43ffced3d4059a9b8652e5 Mon Sep 17 00:00:00 2001 From: JmPotato Date: Tue, 11 Aug 2020 10:55:26 +0800 Subject: [PATCH 035/119] Address some FIXMEs Signed-off-by: JmPotato --- Cargo.lock | 1 + crates/ra_assists/Cargo.toml | 1 + crates/ra_assists/src/ast_transform.rs | 13 +++++-------- crates/ra_assists/src/lib.rs | 25 ++++++++++++++++++++----- crates/rust-analyzer/src/handlers.rs | 2 +- crates/rust-analyzer/src/to_proto.rs | 8 ++++---- 6 files changed, 32 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a094ec4f7a..936e863f52 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -912,6 +912,7 @@ dependencies = [ "ra_db", "ra_fmt", "ra_hir", + "ra_hir_expand", "ra_ide_db", "ra_prof", "ra_syntax", diff --git a/crates/ra_assists/Cargo.toml b/crates/ra_assists/Cargo.toml index bd2905f080..a436e861d7 100644 --- a/crates/ra_assists/Cargo.toml +++ b/crates/ra_assists/Cargo.toml @@ -22,4 +22,5 @@ ra_prof = { path = "../ra_prof" } ra_db = { path = "../ra_db" } ra_ide_db = { path = "../ra_ide_db" } hir = { path = "../ra_hir", package = "ra_hir" } +hir_expand = { path = "../ra_hir_expand", package = "ra_hir_expand" } test_utils = { path = "../test_utils" } diff --git a/crates/ra_assists/src/ast_transform.rs b/crates/ra_assists/src/ast_transform.rs index 15ec75c956..02c4a4baeb 100644 --- a/crates/ra_assists/src/ast_transform.rs +++ b/crates/ra_assists/src/ast_transform.rs @@ -2,6 +2,7 @@ use rustc_hash::FxHashMap; use hir::{HirDisplay, PathResolution, SemanticsScope}; +use hir_expand::hygiene::Hygiene; use ra_syntax::{ algo::SyntaxRewriter, ast::{self, AstNode}, @@ -51,7 +52,7 @@ impl<'a> SubstituteTypeParams<'a> { // this is a trait impl, so we need to skip the first type parameter -- this is a bit hacky .skip(1) // The actual list of trait type parameters may be longer than the one - // used in the `impl` block due to trailing default type parametrs. + // used in the `impl` block due to trailing default type parameters. // For that case we extend the `substs` with an empty iterator so we // can still hit those trailing values and check if they actually have // a default type. If they do, go for that type from `hir` to `ast` so @@ -110,9 +111,7 @@ impl<'a> SubstituteTypeParams<'a> { ast::Type::PathType(path_type) => path_type.path()?, _ => return None, }; - // FIXME: use `hir::Path::from_src` instead. - #[allow(deprecated)] - let path = hir::Path::from_ast(path)?; + let path = hir::Path::from_src(path, &Hygiene::new_unhygienic())?; let resolution = self.source_scope.resolve_hir_path(&path)?; match resolution { hir::PathResolution::TypeParam(tp) => Some(self.substs.get(&tp)?.syntax().clone()), @@ -152,10 +151,8 @@ impl<'a> QualifyPaths<'a> { // don't try to qualify `Fn(Foo) -> Bar` paths, they are in prelude anyway return None; } - // FIXME: use `hir::Path::from_src` instead. - #[allow(deprecated)] - let hir_path = hir::Path::from_ast(p.clone()); - let resolution = self.source_scope.resolve_hir_path(&hir_path?)?; + let hir_path = hir::Path::from_src(p.clone(), &Hygiene::new_unhygienic())?; + let resolution = self.source_scope.resolve_hir_path(&hir_path)?; match resolution { PathResolution::Def(def) => { let found_path = from.find_use_path(self.source_scope.db.upcast(), def)?; diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs index 507646cc80..890996a68d 100644 --- a/crates/ra_assists/src/lib.rs +++ b/crates/ra_assists/src/lib.rs @@ -66,13 +66,13 @@ pub struct GroupLabel(pub String); #[derive(Debug, Clone)] pub struct Assist { - pub id: AssistId, + id: AssistId, /// Short description of the assist, as shown in the UI. - pub label: String, - pub group: Option, + label: String, + group: Option, /// Target ranges are used to sort assists: the smaller the target range, /// the more specific assist is, and so it should be sorted first. - pub target: TextRange, + target: TextRange, } #[derive(Debug, Clone)] @@ -120,10 +120,25 @@ impl Assist { group: Option, target: TextRange, ) -> Assist { - // FIXME: make fields private, so that this invariant can't be broken assert!(label.starts_with(|c: char| c.is_uppercase())); Assist { id, label, group, target } } + + pub fn id(&self) -> AssistId { + self.id + } + + pub fn label(&self) -> String { + self.label.clone() + } + + pub fn group(&self) -> Option { + self.group.clone() + } + + pub fn target(&self) -> TextRange { + self.target + } } mod handlers { diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index 895af1dd78..c2afcf192d 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs @@ -864,7 +864,7 @@ pub(crate) fn handle_resolve_code_action( let (id_string, index) = split_once(¶ms.id, ':').unwrap(); let index = index.parse::().unwrap(); let assist = &assists[index]; - assert!(assist.assist.id.0 == id_string); + assert!(assist.assist.id().0 == id_string); Ok(to_proto::resolved_code_action(&snap, assist.clone())?.edit) } diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index 27460db78c..62fda8a1f2 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs @@ -704,10 +704,10 @@ pub(crate) fn unresolved_code_action( index: usize, ) -> Result { let res = lsp_ext::CodeAction { - title: assist.label, - id: Some(format!("{}:{}", assist.id.0.to_owned(), index.to_string())), - group: assist.group.filter(|_| snap.config.client_caps.code_action_group).map(|gr| gr.0), - kind: Some(code_action_kind(assist.id.1)), + title: assist.label(), + id: Some(format!("{}:{}", assist.id().0.to_owned(), index.to_string())), + group: assist.group().filter(|_| snap.config.client_caps.code_action_group).map(|gr| gr.0), + kind: Some(code_action_kind(assist.id().1)), edit: None, is_preferred: None, }; From ace75f95905564a34f46be57ead51828844da745 Mon Sep 17 00:00:00 2001 From: JmPotato Date: Tue, 11 Aug 2020 12:09:11 +0800 Subject: [PATCH 036/119] Typo fix Signed-off-by: JmPotato --- crates/ra_assists/src/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ra_assists/src/tests.rs b/crates/ra_assists/src/tests.rs index 18fcb90498..e738364220 100644 --- a/crates/ra_assists/src/tests.rs +++ b/crates/ra_assists/src/tests.rs @@ -20,7 +20,7 @@ pub(crate) fn check_assist(assist: Handler, ra_fixture_before: &str, ra_fixture_ // FIXME: instead of having a separate function here, maybe use // `extract_ranges` and mark the target as ` ` in the -// fixuture? +// fixture? pub(crate) fn check_assist_target(assist: Handler, ra_fixture: &str, target: &str) { check(assist, ra_fixture, ExpectedResult::Target(target)); } From b69dfddb572b9182f4880065ca5034aba8b15ce3 Mon Sep 17 00:00:00 2001 From: JmPotato Date: Tue, 11 Aug 2020 14:35:15 +0800 Subject: [PATCH 037/119] Remove redundant dependencies Signed-off-by: JmPotato --- Cargo.lock | 1 - crates/ra_assists/Cargo.toml | 1 - crates/ra_assists/src/ast_transform.rs | 5 ++--- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 936e863f52..a094ec4f7a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -912,7 +912,6 @@ dependencies = [ "ra_db", "ra_fmt", "ra_hir", - "ra_hir_expand", "ra_ide_db", "ra_prof", "ra_syntax", diff --git a/crates/ra_assists/Cargo.toml b/crates/ra_assists/Cargo.toml index a436e861d7..bd2905f080 100644 --- a/crates/ra_assists/Cargo.toml +++ b/crates/ra_assists/Cargo.toml @@ -22,5 +22,4 @@ ra_prof = { path = "../ra_prof" } ra_db = { path = "../ra_db" } ra_ide_db = { path = "../ra_ide_db" } hir = { path = "../ra_hir", package = "ra_hir" } -hir_expand = { path = "../ra_hir_expand", package = "ra_hir_expand" } test_utils = { path = "../test_utils" } diff --git a/crates/ra_assists/src/ast_transform.rs b/crates/ra_assists/src/ast_transform.rs index 02c4a4baeb..6c92124eda 100644 --- a/crates/ra_assists/src/ast_transform.rs +++ b/crates/ra_assists/src/ast_transform.rs @@ -2,7 +2,6 @@ use rustc_hash::FxHashMap; use hir::{HirDisplay, PathResolution, SemanticsScope}; -use hir_expand::hygiene::Hygiene; use ra_syntax::{ algo::SyntaxRewriter, ast::{self, AstNode}, @@ -111,7 +110,7 @@ impl<'a> SubstituteTypeParams<'a> { ast::Type::PathType(path_type) => path_type.path()?, _ => return None, }; - let path = hir::Path::from_src(path, &Hygiene::new_unhygienic())?; + let path = hir::Path::from_src(path, &hir::Hygiene::new_unhygienic())?; let resolution = self.source_scope.resolve_hir_path(&path)?; match resolution { hir::PathResolution::TypeParam(tp) => Some(self.substs.get(&tp)?.syntax().clone()), @@ -151,7 +150,7 @@ impl<'a> QualifyPaths<'a> { // don't try to qualify `Fn(Foo) -> Bar` paths, they are in prelude anyway return None; } - let hir_path = hir::Path::from_src(p.clone(), &Hygiene::new_unhygienic())?; + let hir_path = hir::Path::from_src(p.clone(), &hir::Hygiene::new_unhygienic())?; let resolution = self.source_scope.resolve_hir_path(&hir_path)?; match resolution { PathResolution::Def(def) => { From fc01c7846d5c6970e194dd223e49b863b3189432 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Tue, 11 Aug 2020 09:54:33 +0300 Subject: [PATCH 038/119] Use Hygiene in completion --- crates/ra_ide/src/completion/completion_context.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs index 6b03b30bb5..4aa761148d 100644 --- a/crates/ra_ide/src/completion/completion_context.rs +++ b/crates/ra_ide/src/completion/completion_context.rs @@ -27,7 +27,7 @@ pub(crate) struct CompletionContext<'a> { pub(super) scope: SemanticsScope<'a>, pub(super) db: &'a RootDatabase, pub(super) config: &'a CompletionConfig, - pub(super) offset: TextSize, + pub(super) position: FilePosition, /// The token before the cursor, in the original file. pub(super) original_token: SyntaxToken, /// The token before the cursor, in the macro-expanded file. @@ -117,7 +117,7 @@ impl<'a> CompletionContext<'a> { config, original_token, token, - offset: position.offset, + position, krate, expected_type: None, name_ref_syntax: None, @@ -209,7 +209,7 @@ impl<'a> CompletionContext<'a> { mark::hit!(completes_if_prefix_is_keyword); self.original_token.text_range() } else { - TextRange::empty(self.offset) + TextRange::empty(self.position.offset) } } @@ -379,8 +379,8 @@ impl<'a> CompletionContext<'a> { self.is_path_type = path.syntax().parent().and_then(ast::PathType::cast).is_some(); self.has_type_args = segment.generic_arg_list().is_some(); - #[allow(deprecated)] - if let Some(path) = hir::Path::from_ast(path.clone()) { + let hygiene = hir::Hygiene::new(self.db, self.position.file_id.into()); + if let Some(path) = hir::Path::from_src(path.clone(), &hygiene) { if let Some(path_prefix) = path.qualifier() { self.path_prefix = Some(path_prefix); return; From 7fbc9afca48240cf16c82a996ac7b14c554bade6 Mon Sep 17 00:00:00 2001 From: JmPotato Date: Tue, 11 Aug 2020 16:50:45 +0800 Subject: [PATCH 039/119] Typo fix Signed-off-by: JmPotato --- crates/ra_hir_expand/src/hygiene.rs | 2 +- crates/ra_hir_expand/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/ra_hir_expand/src/hygiene.rs b/crates/ra_hir_expand/src/hygiene.rs index 6b482a60c5..aefe47bd32 100644 --- a/crates/ra_hir_expand/src/hygiene.rs +++ b/crates/ra_hir_expand/src/hygiene.rs @@ -17,7 +17,7 @@ pub struct Hygiene { // This is what `$crate` expands to def_crate: Option, - // Indiciate this is a local inner macro + // Indicate this is a local inner macro local_inner: bool, } diff --git a/crates/ra_hir_expand/src/lib.rs b/crates/ra_hir_expand/src/lib.rs index 2e8d636917..abae498d82 100644 --- a/crates/ra_hir_expand/src/lib.rs +++ b/crates/ra_hir_expand/src/lib.rs @@ -44,7 +44,7 @@ mod test_db; /// containing the call plus the offset of the macro call in the file. Note that /// this is a recursive definition! However, the size_of of `HirFileId` is /// finite (because everything bottoms out at the real `FileId`) and small -/// (`MacroCallId` uses the location interner). +/// (`MacroCallId` uses the location internal). #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct HirFileId(HirFileIdRepr); From 6ef019bd4601b9dc36325e096d066a4ddbda1bdf Mon Sep 17 00:00:00 2001 From: JmPotato Date: Tue, 11 Aug 2020 17:19:02 +0800 Subject: [PATCH 040/119] Revert some FIXMEs Signed-off-by: JmPotato --- crates/ra_assists/src/ast_transform.rs | 10 +++++++--- crates/ra_hir_expand/src/lib.rs | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/crates/ra_assists/src/ast_transform.rs b/crates/ra_assists/src/ast_transform.rs index 6c92124eda..07c978378a 100644 --- a/crates/ra_assists/src/ast_transform.rs +++ b/crates/ra_assists/src/ast_transform.rs @@ -110,7 +110,9 @@ impl<'a> SubstituteTypeParams<'a> { ast::Type::PathType(path_type) => path_type.path()?, _ => return None, }; - let path = hir::Path::from_src(path, &hir::Hygiene::new_unhygienic())?; + // FIXME: use `hir::Path::from_src` instead. + #[allow(deprecated)] + let path = hir::Path::from_ast(path)?; let resolution = self.source_scope.resolve_hir_path(&path)?; match resolution { hir::PathResolution::TypeParam(tp) => Some(self.substs.get(&tp)?.syntax().clone()), @@ -150,8 +152,10 @@ impl<'a> QualifyPaths<'a> { // don't try to qualify `Fn(Foo) -> Bar` paths, they are in prelude anyway return None; } - let hir_path = hir::Path::from_src(p.clone(), &hir::Hygiene::new_unhygienic())?; - let resolution = self.source_scope.resolve_hir_path(&hir_path)?; + // FIXME: use `hir::Path::from_src` instead. + #[allow(deprecated)] + let hir_path = hir::Path::from_ast(p.clone()); + let resolution = self.source_scope.resolve_hir_path(&hir_path?)?; match resolution { PathResolution::Def(def) => { let found_path = from.find_use_path(self.source_scope.db.upcast(), def)?; diff --git a/crates/ra_hir_expand/src/lib.rs b/crates/ra_hir_expand/src/lib.rs index abae498d82..8bb735fc62 100644 --- a/crates/ra_hir_expand/src/lib.rs +++ b/crates/ra_hir_expand/src/lib.rs @@ -44,7 +44,8 @@ mod test_db; /// containing the call plus the offset of the macro call in the file. Note that /// this is a recursive definition! However, the size_of of `HirFileId` is /// finite (because everything bottoms out at the real `FileId`) and small -/// (`MacroCallId` uses the location internal). +/// (`MacroCallId` uses the location interning. You can check details here: +/// https://en.wikipedia.org/wiki/String_interning). #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct HirFileId(HirFileIdRepr); From 26e102a567aadcf86f2e5b575cb6b915991ba088 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Mon, 27 Jul 2020 15:53:57 +0300 Subject: [PATCH 041/119] Separate diagnostics and diagnostics fix ranges --- crates/ra_ide/src/diagnostics.rs | 98 ++++++++++++++++------------ crates/ra_ide/src/lib.rs | 2 +- crates/rust-analyzer/src/handlers.rs | 6 +- 3 files changed, 59 insertions(+), 47 deletions(-) diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs index 73c0b82754..5c8ea46abb 100644 --- a/crates/ra_ide/src/diagnostics.rs +++ b/crates/ra_ide/src/diagnostics.rs @@ -60,14 +60,16 @@ pub(crate) fn diagnostics( FileSystemEdit::CreateFile { anchor: original_file, dst: d.candidate.clone() } .into(), ); + let range = sema.diagnostics_range(d).range; res.borrow_mut().push(Diagnostic { - range: sema.diagnostics_range(d).range, + range, message: d.message(), severity: Severity::Error, - fix: Some(fix), + fix: Some((fix, range)), }) }) .on::(|d| { + let range = sema.diagnostics_range(d).range; // Note that although we could add a diagnostics to // fill the missing tuple field, e.g : // `struct A(usize);` @@ -91,11 +93,15 @@ pub(crate) fn diagnostics( .into_text_edit(&mut builder); builder.finish() }; - Some(Fix::new("Fill struct fields", SourceFileEdit { file_id, edit }.into())) + Some(( + Fix::new("Fill struct fields", SourceFileEdit { file_id, edit }.into()), + range, + )) }; res.borrow_mut().push(Diagnostic { - range: sema.diagnostics_range(d).range, + // TODO kb use a smaller range here + range, message: d.message(), severity: Severity::Error, fix, @@ -106,20 +112,21 @@ pub(crate) fn diagnostics( let replacement = format!("Ok({})", node.syntax()); let edit = TextEdit::replace(node.syntax().text_range(), replacement); let source_change = SourceFileEdit { file_id, edit }.into(); - let fix = Fix::new("Wrap with ok", source_change); + let range = sema.diagnostics_range(d).range; res.borrow_mut().push(Diagnostic { - range: sema.diagnostics_range(d).range, + range, message: d.message(), severity: Severity::Error, - fix: Some(fix), + fix: Some((Fix::new("Wrap with ok", source_change), range)), }) }) .on::(|d| { + let range = sema.diagnostics_range(d).range; res.borrow_mut().push(Diagnostic { - range: sema.diagnostics_range(d).range, + range, message: d.message(), severity: Severity::Error, - fix: missing_struct_field_fix(&sema, file_id, d), + fix: missing_struct_field_fix(&sema, file_id, d).map(|fix| (fix, range)), }) }) // Only collect experimental diagnostics when they're enabled. @@ -222,24 +229,24 @@ fn check_unnecessary_braces_in_use_statement( ) -> Option<()> { let use_tree_list = ast::UseTreeList::cast(node.clone())?; if let Some((single_use_tree,)) = use_tree_list.use_trees().collect_tuple() { - let range = use_tree_list.syntax().text_range(); + let use_range = use_tree_list.syntax().text_range(); let edit = text_edit_for_remove_unnecessary_braces_with_self_in_use_statement(&single_use_tree) .unwrap_or_else(|| { let to_replace = single_use_tree.syntax().text().to_string(); let mut edit_builder = TextEditBuilder::default(); - edit_builder.delete(range); - edit_builder.insert(range.start(), to_replace); + edit_builder.delete(use_range); + edit_builder.insert(use_range.start(), to_replace); edit_builder.finish() }); acc.push(Diagnostic { - range, + range: use_range, message: "Unnecessary braces in use statement".to_string(), severity: Severity::WeakWarning, - fix: Some(Fix::new( - "Remove unnecessary braces", - SourceFileEdit { file_id, edit }.into(), + fix: Some(( + Fix::new("Remove unnecessary braces", SourceFileEdit { file_id, edit }.into()), + use_range, )), }); } @@ -254,8 +261,7 @@ fn text_edit_for_remove_unnecessary_braces_with_self_in_use_statement( if single_use_tree.path()?.segment()?.syntax().first_child_or_token()?.kind() == T![self] { let start = use_tree_list_node.prev_sibling_or_token()?.text_range().start(); let end = use_tree_list_node.text_range().end(); - let range = TextRange::new(start, end); - return Some(TextEdit::delete(range)); + return Some(TextEdit::delete(TextRange::new(start, end))); } None } @@ -278,13 +284,17 @@ fn check_struct_shorthand_initialization( edit_builder.insert(record_field.syntax().text_range().start(), field_name); let edit = edit_builder.finish(); + let field_range = record_field.syntax().text_range(); acc.push(Diagnostic { - range: record_field.syntax().text_range(), + range: field_range, message: "Shorthand struct initialization".to_string(), severity: Severity::WeakWarning, - fix: Some(Fix::new( - "Use struct shorthand initialization", - SourceFileEdit { file_id, edit }.into(), + fix: Some(( + Fix::new( + "Use struct shorthand initialization", + SourceFileEdit { file_id, edit }.into(), + ), + field_range, )), }); } @@ -304,14 +314,14 @@ mod tests { /// Takes a multi-file input fixture with annotated cursor positions, /// and checks that: /// * a diagnostic is produced - /// * this diagnostic touches the input cursor position + /// * this diagnostic fix touches the input cursor position /// * that the contents of the file containing the cursor match `after` after the diagnostic fix is applied fn check_fix(ra_fixture_before: &str, ra_fixture_after: &str) { let after = trim_indent(ra_fixture_after); let (analysis, file_position) = analysis_and_position(ra_fixture_before); let diagnostic = analysis.diagnostics(file_position.file_id, true).unwrap().pop().unwrap(); - let mut fix = diagnostic.fix.unwrap(); + let (mut fix, fix_range) = diagnostic.fix.unwrap(); let edit = fix.source_change.source_file_edits.pop().unwrap().edit; let target_file_contents = analysis.file_text(file_position.file_id).unwrap(); let actual = { @@ -322,10 +332,9 @@ mod tests { assert_eq_text!(&after, &actual); assert!( - diagnostic.range.start() <= file_position.offset - && diagnostic.range.end() >= file_position.offset, - "diagnostic range {:?} does not touch cursor position {:?}", - diagnostic.range, + fix_range.start() <= file_position.offset && fix_range.end() >= file_position.offset, + "diagnostic fix range {:?} does not touch cursor position {:?}", + fix_range, file_position.offset ); } @@ -337,7 +346,7 @@ mod tests { let (analysis, file_pos) = analysis_and_position(ra_fixture_before); let current_file_id = file_pos.file_id; let diagnostic = analysis.diagnostics(current_file_id, true).unwrap().pop().unwrap(); - let mut fix = diagnostic.fix.unwrap(); + let mut fix = diagnostic.fix.unwrap().0; let edit = fix.source_change.source_file_edits.pop().unwrap(); let changed_file_id = edit.file_id; let before = analysis.file_text(changed_file_id).unwrap(); @@ -628,21 +637,24 @@ fn test_fn() { range: 0..8, severity: Error, fix: Some( - Fix { - label: "Create module", - source_change: SourceChange { - source_file_edits: [], - file_system_edits: [ - CreateFile { - anchor: FileId( - 1, - ), - dst: "foo.rs", - }, - ], - is_snippet: false, + ( + Fix { + label: "Create module", + source_change: SourceChange { + source_file_edits: [], + file_system_edits: [ + CreateFile { + anchor: FileId( + 1, + ), + dst: "foo.rs", + }, + ], + is_snippet: false, + }, }, - }, + 0..8, + ), ), }, ] diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs index 0fede0d879..45a4b2421e 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ra_ide/src/lib.rs @@ -105,7 +105,7 @@ pub struct Diagnostic { pub message: String, pub range: TextRange, pub severity: Severity, - pub fix: Option, + pub fix: Option<(Fix, TextRange)>, } #[derive(Debug)] diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index c2afcf192d..144c641b2a 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs @@ -775,9 +775,9 @@ fn handle_fixes( let fixes_from_diagnostics = diagnostics .into_iter() - .filter_map(|d| Some((d.range, d.fix?))) - .filter(|(diag_range, _fix)| diag_range.intersect(range).is_some()) - .map(|(_range, fix)| fix); + .filter_map(|d| d.fix) + .filter(|(_fix, fix_range)| fix_range.intersect(range).is_some()) + .map(|(fix, _range)| fix); for fix in fixes_from_diagnostics { let title = fix.label; let edit = to_proto::snippet_workspace_edit(&snap, fix.source_change)?; From 21e5224484b9214648826e1b15aa9150c79a407c Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Mon, 27 Jul 2020 18:45:08 +0300 Subject: [PATCH 042/119] Custom ranges for missing fields --- crates/ra_hir_expand/src/diagnostics.rs | 5 ++- crates/ra_hir_ty/src/diagnostics.rs | 52 ++++++++++++++++++++++-- crates/ra_hir_ty/src/diagnostics/expr.rs | 1 + crates/ra_ide/src/diagnostics.rs | 6 ++- 4 files changed, 56 insertions(+), 8 deletions(-) diff --git a/crates/ra_hir_expand/src/diagnostics.rs b/crates/ra_hir_expand/src/diagnostics.rs index 84ba97b14a..e889f070fa 100644 --- a/crates/ra_hir_expand/src/diagnostics.rs +++ b/crates/ra_hir_expand/src/diagnostics.rs @@ -36,8 +36,9 @@ pub trait AstDiagnostic { impl dyn Diagnostic { pub fn syntax_node(&self, db: &impl AstDatabase) -> SyntaxNode { - let node = db.parse_or_expand(self.source().file_id).unwrap(); - self.source().value.to_node(&node) + let source = self.source(); + let node = db.parse_or_expand(source.file_id).unwrap(); + source.value.to_node(&node) } pub fn downcast_ref(&self) -> Option<&D> { diff --git a/crates/ra_hir_ty/src/diagnostics.rs b/crates/ra_hir_ty/src/diagnostics.rs index 977c0525b5..a5b00ed485 100644 --- a/crates/ra_hir_ty/src/diagnostics.rs +++ b/crates/ra_hir_ty/src/diagnostics.rs @@ -9,7 +9,7 @@ use hir_def::DefWithBodyId; use hir_expand::diagnostics::{AstDiagnostic, Diagnostic, DiagnosticSink}; use hir_expand::{db::AstDatabase, name::Name, HirFileId, InFile}; use ra_prof::profile; -use ra_syntax::{ast, AstNode, AstPtr, SyntaxNodePtr}; +use ra_syntax::{ast, AstNode, AstPtr, SyntaxNode, SyntaxNodePtr}; use stdx::format_to; use crate::db::HirDatabase; @@ -61,6 +61,17 @@ pub struct MissingFields { pub file: HirFileId, pub field_list: AstPtr, pub missed_fields: Vec, + pub list_parent_path: Option>, +} + +impl MissingFields { + fn root(&self, db: &dyn AstDatabase) -> SyntaxNode { + db.parse_or_expand(self.file).unwrap() + } + + pub fn list_parent_ast(&self, db: &dyn AstDatabase) -> Option { + self.list_parent_path.as_ref().map(|path| path.to_node(&self.root(db))) + } } impl Diagnostic for MissingFields { @@ -83,9 +94,7 @@ impl AstDiagnostic for MissingFields { type AST = ast::RecordExprFieldList; fn ast(&self, db: &dyn AstDatabase) -> Self::AST { - let root = db.parse_or_expand(self.source().file_id).unwrap(); - let node = self.source().value.to_node(&root); - ast::RecordExprFieldList::cast(node).unwrap() + self.field_list.to_node(&self.root(db)) } } @@ -318,6 +327,41 @@ mod tests { assert_eq!(annotations, actual); } + #[test] + fn structure_name_highlighted_for_missing_fields() { + check_diagnostics( + r#" +struct Beefy { + one: i32, + two: i32, + three: i32, + four: i32, + five: i32, + six: i32, + seven: i32, + eight: i32, + nine: i32, + ten: i32, +} +fn baz() { + let zz = Beefy { + //^^^^^... Missing structure fields: + // | - seven + one: (), + two: (), + three: (), + four: (), + five: (), + six: (), + eight: (), + nine: (), + ten: (), + }; +} +"#, + ); + } + #[test] fn no_such_field_diagnostics() { check_diagnostics( diff --git a/crates/ra_hir_ty/src/diagnostics/expr.rs b/crates/ra_hir_ty/src/diagnostics/expr.rs index 95bbf2d955..3c37fc58e9 100644 --- a/crates/ra_hir_ty/src/diagnostics/expr.rs +++ b/crates/ra_hir_ty/src/diagnostics/expr.rs @@ -111,6 +111,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { file: source_ptr.file_id, field_list: AstPtr::new(&field_list), missed_fields, + list_parent_path: record_lit.path().map(|path| AstPtr::new(&path)), }) } } diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs index 5c8ea46abb..7ae4bda0b8 100644 --- a/crates/ra_ide/src/diagnostics.rs +++ b/crates/ra_ide/src/diagnostics.rs @@ -100,8 +100,10 @@ pub(crate) fn diagnostics( }; res.borrow_mut().push(Diagnostic { - // TODO kb use a smaller range here - range, + range: d + .list_parent_ast(db) + .map(|path| path.syntax().text_range()) + .unwrap_or(range), message: d.message(), severity: Severity::Error, fix, From a61f2445cba2a48bb7ea6c8477e3198b297f3c67 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Mon, 27 Jul 2020 22:30:55 +0300 Subject: [PATCH 043/119] Less stubs --- .../ra_assists/src/handlers/fix_visibility.rs | 2 +- crates/ra_hir_expand/src/diagnostics.rs | 11 ++---- crates/ra_hir_ty/src/diagnostics.rs | 38 ++++++++++--------- crates/ra_ide/src/diagnostics.rs | 8 +--- 4 files changed, 28 insertions(+), 31 deletions(-) diff --git a/crates/ra_assists/src/handlers/fix_visibility.rs b/crates/ra_assists/src/handlers/fix_visibility.rs index 1aefa79cc3..a19dbf33f6 100644 --- a/crates/ra_assists/src/handlers/fix_visibility.rs +++ b/crates/ra_assists/src/handlers/fix_visibility.rs @@ -121,7 +121,7 @@ fn add_vis_to_referenced_record_field(acc: &mut Assists, ctx: &AssistContext) -> Some(cap) => match current_visibility { Some(current_visibility) => builder.replace_snippet( cap, - dbg!(current_visibility.syntax()).text_range(), + current_visibility.syntax().text_range(), format!("$0{}", missing_visibility), ), None => builder.insert_snippet(cap, offset, format!("$0{} ", missing_visibility)), diff --git a/crates/ra_hir_expand/src/diagnostics.rs b/crates/ra_hir_expand/src/diagnostics.rs index e889f070fa..ffeca5e827 100644 --- a/crates/ra_hir_expand/src/diagnostics.rs +++ b/crates/ra_hir_expand/src/diagnostics.rs @@ -16,13 +16,16 @@ use std::{any::Any, fmt}; -use ra_syntax::{SyntaxNode, SyntaxNodePtr}; +use ra_syntax::SyntaxNodePtr; use crate::{db::AstDatabase, InFile}; pub trait Diagnostic: Any + Send + Sync + fmt::Debug + 'static { fn message(&self) -> String; fn source(&self) -> InFile; + fn highlighting_source(&self) -> InFile { + self.source() + } fn as_any(&self) -> &(dyn Any + Send + 'static); fn is_experimental(&self) -> bool { false @@ -35,12 +38,6 @@ pub trait AstDiagnostic { } impl dyn Diagnostic { - pub fn syntax_node(&self, db: &impl AstDatabase) -> SyntaxNode { - let source = self.source(); - let node = db.parse_or_expand(source.file_id).unwrap(); - source.value.to_node(&node) - } - pub fn downcast_ref(&self) -> Option<&D> { self.as_any().downcast_ref() } diff --git a/crates/ra_hir_ty/src/diagnostics.rs b/crates/ra_hir_ty/src/diagnostics.rs index a5b00ed485..73d2414343 100644 --- a/crates/ra_hir_ty/src/diagnostics.rs +++ b/crates/ra_hir_ty/src/diagnostics.rs @@ -9,7 +9,7 @@ use hir_def::DefWithBodyId; use hir_expand::diagnostics::{AstDiagnostic, Diagnostic, DiagnosticSink}; use hir_expand::{db::AstDatabase, name::Name, HirFileId, InFile}; use ra_prof::profile; -use ra_syntax::{ast, AstNode, AstPtr, SyntaxNode, SyntaxNodePtr}; +use ra_syntax::{ast, AstNode, AstPtr, SyntaxNodePtr}; use stdx::format_to; use crate::db::HirDatabase; @@ -64,16 +64,6 @@ pub struct MissingFields { pub list_parent_path: Option>, } -impl MissingFields { - fn root(&self, db: &dyn AstDatabase) -> SyntaxNode { - db.parse_or_expand(self.file).unwrap() - } - - pub fn list_parent_ast(&self, db: &dyn AstDatabase) -> Option { - self.list_parent_path.as_ref().map(|path| path.to_node(&self.root(db))) - } -} - impl Diagnostic for MissingFields { fn message(&self) -> String { let mut buf = String::from("Missing structure fields:\n"); @@ -85,16 +75,25 @@ impl Diagnostic for MissingFields { fn source(&self) -> InFile { InFile { file_id: self.file, value: self.field_list.clone().into() } } + fn as_any(&self) -> &(dyn Any + Send + 'static) { self } + + fn highlighting_source(&self) -> InFile { + self.list_parent_path + .clone() + .map(|path| InFile { file_id: self.file, value: path.into() }) + .unwrap_or_else(|| self.source()) + } } impl AstDiagnostic for MissingFields { type AST = ast::RecordExprFieldList; fn ast(&self, db: &dyn AstDatabase) -> Self::AST { - self.field_list.to_node(&self.root(db)) + let root = db.parse_or_expand(self.file).unwrap(); + self.field_list.to_node(&root) } } @@ -260,7 +259,10 @@ impl AstDiagnostic for MismatchedArgCount { #[cfg(test)] mod tests { use hir_def::{db::DefDatabase, AssocItemId, ModuleDefId}; - use hir_expand::diagnostics::{Diagnostic, DiagnosticSinkBuilder}; + use hir_expand::{ + db::AstDatabase, + diagnostics::{Diagnostic, DiagnosticSinkBuilder}, + }; use ra_db::{fixture::WithFixture, FileId, SourceDatabase, SourceDatabaseExt}; use ra_syntax::{TextRange, TextSize}; use rustc_hash::FxHashMap; @@ -307,7 +309,9 @@ mod tests { db.diagnostics(|d| { // FXIME: macros... let file_id = d.source().file_id.original_file(&db); - let range = d.syntax_node(&db).text_range(); + let highlighting_source = d.highlighting_source(); + let node = db.parse_or_expand(highlighting_source.file_id).unwrap(); + let range = highlighting_source.value.to_node(&node).text_range(); let message = d.message().to_owned(); actual.entry(file_id).or_default().push((range, message)); }); @@ -345,7 +349,7 @@ struct Beefy { } fn baz() { let zz = Beefy { - //^^^^^... Missing structure fields: + //^^^^^ Missing structure fields: // | - seven one: (), two: (), @@ -370,8 +374,8 @@ struct S { foo: i32, bar: () } impl S { fn new() -> S { S { - //^... Missing structure fields: - //| - bar + //^ Missing structure fields: + //| - bar foo: 92, baz: 62, //^^^^^^^ no such field diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs index 7ae4bda0b8..e847df6ea9 100644 --- a/crates/ra_ide/src/diagnostics.rs +++ b/crates/ra_ide/src/diagnostics.rs @@ -69,7 +69,6 @@ pub(crate) fn diagnostics( }) }) .on::(|d| { - let range = sema.diagnostics_range(d).range; // Note that although we could add a diagnostics to // fill the missing tuple field, e.g : // `struct A(usize);` @@ -95,15 +94,12 @@ pub(crate) fn diagnostics( }; Some(( Fix::new("Fill struct fields", SourceFileEdit { file_id, edit }.into()), - range, + sema.diagnostics_range(d).range, )) }; res.borrow_mut().push(Diagnostic { - range: d - .list_parent_ast(db) - .map(|path| path.syntax().text_range()) - .unwrap_or(range), + range: d.highlighting_source().file_syntax(db).text_range(), message: d.message(), severity: Severity::Error, fix, From ee1586c1ed058ff0f090b552d52fe6bbe2dd7f7f Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Mon, 27 Jul 2020 22:46:25 +0300 Subject: [PATCH 044/119] Better naming --- crates/ra_hir/src/semantics.rs | 11 +++++ crates/ra_hir_def/src/diagnostics.rs | 2 +- crates/ra_hir_expand/src/diagnostics.rs | 6 +-- crates/ra_hir_ty/src/diagnostics.rs | 57 +++++++++++-------------- crates/ra_ide/src/diagnostics.rs | 31 ++++++++------ 5 files changed, 58 insertions(+), 49 deletions(-) diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs index e392130ab6..1c5dc3d510 100644 --- a/crates/ra_hir/src/semantics.rs +++ b/crates/ra_hir/src/semantics.rs @@ -145,6 +145,10 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { self.imp.original_range(node) } + pub fn diagnostics_fix_range(&self, diagnostics: &dyn Diagnostic) -> FileRange { + self.imp.diagnostics_fix_range(diagnostics) + } + pub fn diagnostics_range(&self, diagnostics: &dyn Diagnostic) -> FileRange { self.imp.diagnostics_range(diagnostics) } @@ -376,6 +380,13 @@ impl<'db> SemanticsImpl<'db> { original_range(self.db, node.as_ref()) } + fn diagnostics_fix_range(&self, diagnostics: &dyn Diagnostic) -> FileRange { + let src = diagnostics.fix_source(); + let root = self.db.parse_or_expand(src.file_id).unwrap(); + let node = src.value.to_node(&root); + original_range(self.db, src.with_value(&node)) + } + fn diagnostics_range(&self, diagnostics: &dyn Diagnostic) -> FileRange { let src = diagnostics.source(); let root = self.db.parse_or_expand(src.file_id).unwrap(); diff --git a/crates/ra_hir_def/src/diagnostics.rs b/crates/ra_hir_def/src/diagnostics.rs index 30db48f868..e532695895 100644 --- a/crates/ra_hir_def/src/diagnostics.rs +++ b/crates/ra_hir_def/src/diagnostics.rs @@ -18,7 +18,7 @@ impl Diagnostic for UnresolvedModule { fn message(&self) -> String { "unresolved module".to_string() } - fn source(&self) -> InFile { + fn fix_source(&self) -> InFile { InFile::new(self.file, self.decl.clone().into()) } fn as_any(&self) -> &(dyn Any + Send + 'static) { diff --git a/crates/ra_hir_expand/src/diagnostics.rs b/crates/ra_hir_expand/src/diagnostics.rs index ffeca5e827..074a8c45e8 100644 --- a/crates/ra_hir_expand/src/diagnostics.rs +++ b/crates/ra_hir_expand/src/diagnostics.rs @@ -22,9 +22,9 @@ use crate::{db::AstDatabase, InFile}; pub trait Diagnostic: Any + Send + Sync + fmt::Debug + 'static { fn message(&self) -> String; - fn source(&self) -> InFile; - fn highlighting_source(&self) -> InFile { - self.source() + fn fix_source(&self) -> InFile; + fn source(&self) -> InFile { + self.fix_source() } fn as_any(&self) -> &(dyn Any + Send + 'static); fn is_experimental(&self) -> bool { diff --git a/crates/ra_hir_ty/src/diagnostics.rs b/crates/ra_hir_ty/src/diagnostics.rs index 73d2414343..a4cede81dc 100644 --- a/crates/ra_hir_ty/src/diagnostics.rs +++ b/crates/ra_hir_ty/src/diagnostics.rs @@ -37,7 +37,7 @@ impl Diagnostic for NoSuchField { "no such field".to_string() } - fn source(&self) -> InFile { + fn fix_source(&self) -> InFile { InFile::new(self.file, self.field.clone().into()) } @@ -50,9 +50,8 @@ impl AstDiagnostic for NoSuchField { type AST = ast::RecordExprField; fn ast(&self, db: &dyn AstDatabase) -> Self::AST { - let root = db.parse_or_expand(self.source().file_id).unwrap(); - let node = self.source().value.to_node(&root); - ast::RecordExprField::cast(node).unwrap() + let root = db.parse_or_expand(self.file).unwrap(); + self.field.to_node(&root) } } @@ -72,20 +71,20 @@ impl Diagnostic for MissingFields { } buf } - fn source(&self) -> InFile { + fn fix_source(&self) -> InFile { InFile { file_id: self.file, value: self.field_list.clone().into() } } + fn source(&self) -> InFile { + self.list_parent_path + .clone() + .map(|path| InFile { file_id: self.file, value: path.into() }) + .unwrap_or_else(|| self.fix_source()) + } + fn as_any(&self) -> &(dyn Any + Send + 'static) { self } - - fn highlighting_source(&self) -> InFile { - self.list_parent_path - .clone() - .map(|path| InFile { file_id: self.file, value: path.into() }) - .unwrap_or_else(|| self.source()) - } } impl AstDiagnostic for MissingFields { @@ -112,7 +111,7 @@ impl Diagnostic for MissingPatFields { } buf } - fn source(&self) -> InFile { + fn fix_source(&self) -> InFile { InFile { file_id: self.file, value: self.field_list.clone().into() } } fn as_any(&self) -> &(dyn Any + Send + 'static) { @@ -131,7 +130,7 @@ impl Diagnostic for MissingMatchArms { fn message(&self) -> String { String::from("Missing match arm") } - fn source(&self) -> InFile { + fn fix_source(&self) -> InFile { InFile { file_id: self.file, value: self.match_expr.clone().into() } } fn as_any(&self) -> &(dyn Any + Send + 'static) { @@ -149,7 +148,7 @@ impl Diagnostic for MissingOkInTailExpr { fn message(&self) -> String { "wrap return expression in Ok".to_string() } - fn source(&self) -> InFile { + fn fix_source(&self) -> InFile { InFile { file_id: self.file, value: self.expr.clone().into() } } fn as_any(&self) -> &(dyn Any + Send + 'static) { @@ -162,8 +161,7 @@ impl AstDiagnostic for MissingOkInTailExpr { fn ast(&self, db: &dyn AstDatabase) -> Self::AST { let root = db.parse_or_expand(self.file).unwrap(); - let node = self.source().value.to_node(&root); - ast::Expr::cast(node).unwrap() + self.expr.to_node(&root) } } @@ -177,7 +175,7 @@ impl Diagnostic for BreakOutsideOfLoop { fn message(&self) -> String { "break outside of loop".to_string() } - fn source(&self) -> InFile { + fn fix_source(&self) -> InFile { InFile { file_id: self.file, value: self.expr.clone().into() } } fn as_any(&self) -> &(dyn Any + Send + 'static) { @@ -190,8 +188,7 @@ impl AstDiagnostic for BreakOutsideOfLoop { fn ast(&self, db: &dyn AstDatabase) -> Self::AST { let root = db.parse_or_expand(self.file).unwrap(); - let node = self.source().value.to_node(&root); - ast::Expr::cast(node).unwrap() + self.expr.to_node(&root) } } @@ -205,7 +202,7 @@ impl Diagnostic for MissingUnsafe { fn message(&self) -> String { format!("This operation is unsafe and requires an unsafe function or block") } - fn source(&self) -> InFile { + fn fix_source(&self) -> InFile { InFile { file_id: self.file, value: self.expr.clone().into() } } fn as_any(&self) -> &(dyn Any + Send + 'static) { @@ -217,9 +214,8 @@ impl AstDiagnostic for MissingUnsafe { type AST = ast::Expr; fn ast(&self, db: &dyn AstDatabase) -> Self::AST { - let root = db.parse_or_expand(self.source().file_id).unwrap(); - let node = self.source().value.to_node(&root); - ast::Expr::cast(node).unwrap() + let root = db.parse_or_expand(self.file).unwrap(); + self.expr.to_node(&root) } } @@ -236,7 +232,7 @@ impl Diagnostic for MismatchedArgCount { let s = if self.expected == 1 { "" } else { "s" }; format!("Expected {} argument{}, found {}", self.expected, s, self.found) } - fn source(&self) -> InFile { + fn fix_source(&self) -> InFile { InFile { file_id: self.file, value: self.call_expr.clone().into() } } fn as_any(&self) -> &(dyn Any + Send + 'static) { @@ -250,7 +246,7 @@ impl Diagnostic for MismatchedArgCount { impl AstDiagnostic for MismatchedArgCount { type AST = ast::CallExpr; fn ast(&self, db: &dyn AstDatabase) -> Self::AST { - let root = db.parse_or_expand(self.source().file_id).unwrap(); + let root = db.parse_or_expand(self.file).unwrap(); let node = self.source().value.to_node(&root); ast::CallExpr::cast(node).unwrap() } @@ -308,12 +304,11 @@ mod tests { let mut actual: FxHashMap> = FxHashMap::default(); db.diagnostics(|d| { // FXIME: macros... - let file_id = d.source().file_id.original_file(&db); - let highlighting_source = d.highlighting_source(); - let node = db.parse_or_expand(highlighting_source.file_id).unwrap(); - let range = highlighting_source.value.to_node(&node).text_range(); + let source = d.source(); + let root = db.parse_or_expand(source.file_id).unwrap(); + let range = source.value.to_node(&root).text_range(); let message = d.message().to_owned(); - actual.entry(file_id).or_default().push((range, message)); + actual.entry(source.file_id.original_file(&db)).or_default().push((range, message)); }); for (file_id, diags) in actual.iter_mut() { diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs index e847df6ea9..0d2ff17e1f 100644 --- a/crates/ra_ide/src/diagnostics.rs +++ b/crates/ra_ide/src/diagnostics.rs @@ -54,18 +54,19 @@ pub(crate) fn diagnostics( let res = RefCell::new(res); let mut sink = DiagnosticSinkBuilder::new() .on::(|d| { - let original_file = d.source().file_id.original_file(db); let fix = Fix::new( "Create module", - FileSystemEdit::CreateFile { anchor: original_file, dst: d.candidate.clone() } - .into(), + FileSystemEdit::CreateFile { + anchor: d.file.original_file(db), + dst: d.candidate.clone(), + } + .into(), ); - let range = sema.diagnostics_range(d).range; res.borrow_mut().push(Diagnostic { - range, + range: sema.diagnostics_range(d).range, message: d.message(), severity: Severity::Error, - fix: Some((fix, range)), + fix: Some((fix, sema.diagnostics_fix_range(d).range)), }) }) .on::(|d| { @@ -94,12 +95,12 @@ pub(crate) fn diagnostics( }; Some(( Fix::new("Fill struct fields", SourceFileEdit { file_id, edit }.into()), - sema.diagnostics_range(d).range, + sema.diagnostics_fix_range(d).range, )) }; res.borrow_mut().push(Diagnostic { - range: d.highlighting_source().file_syntax(db).text_range(), + range: sema.diagnostics_range(d).range, message: d.message(), severity: Severity::Error, fix, @@ -110,21 +111,23 @@ pub(crate) fn diagnostics( let replacement = format!("Ok({})", node.syntax()); let edit = TextEdit::replace(node.syntax().text_range(), replacement); let source_change = SourceFileEdit { file_id, edit }.into(); - let range = sema.diagnostics_range(d).range; res.borrow_mut().push(Diagnostic { - range, + range: sema.diagnostics_range(d).range, message: d.message(), severity: Severity::Error, - fix: Some((Fix::new("Wrap with ok", source_change), range)), + fix: Some(( + Fix::new("Wrap with ok", source_change), + sema.diagnostics_fix_range(d).range, + )), }) }) .on::(|d| { - let range = sema.diagnostics_range(d).range; res.borrow_mut().push(Diagnostic { - range, + range: sema.diagnostics_range(d).range, message: d.message(), severity: Severity::Error, - fix: missing_struct_field_fix(&sema, file_id, d).map(|fix| (fix, range)), + fix: missing_struct_field_fix(&sema, file_id, d) + .map(|fix| (fix, sema.diagnostics_fix_range(d).range)), }) }) // Only collect experimental diagnostics when they're enabled. From cb0b13a583c0c20b57fd3529e2c01ab42bd8f04d Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Mon, 27 Jul 2020 23:32:16 +0300 Subject: [PATCH 045/119] Fix another missing fields diagnostics --- crates/ra_hir_ty/src/diagnostics.rs | 50 ++++--------------- crates/ra_hir_ty/src/diagnostics/expr.rs | 5 +- .../ra_hir_ty/src/diagnostics/match_check.rs | 8 +-- 3 files changed, 19 insertions(+), 44 deletions(-) diff --git a/crates/ra_hir_ty/src/diagnostics.rs b/crates/ra_hir_ty/src/diagnostics.rs index a4cede81dc..48b578fb0e 100644 --- a/crates/ra_hir_ty/src/diagnostics.rs +++ b/crates/ra_hir_ty/src/diagnostics.rs @@ -59,8 +59,8 @@ impl AstDiagnostic for NoSuchField { pub struct MissingFields { pub file: HirFileId, pub field_list: AstPtr, + pub field_list_parent_path: Option>, pub missed_fields: Vec, - pub list_parent_path: Option>, } impl Diagnostic for MissingFields { @@ -76,7 +76,7 @@ impl Diagnostic for MissingFields { } fn source(&self) -> InFile { - self.list_parent_path + self.field_list_parent_path .clone() .map(|path| InFile { file_id: self.file, value: path.into() }) .unwrap_or_else(|| self.fix_source()) @@ -100,6 +100,7 @@ impl AstDiagnostic for MissingFields { pub struct MissingPatFields { pub file: HirFileId, pub field_list: AstPtr, + pub field_list_parent_path: Option>, pub missed_fields: Vec, } @@ -114,6 +115,12 @@ impl Diagnostic for MissingPatFields { fn fix_source(&self) -> InFile { InFile { file_id: self.file, value: self.field_list.clone().into() } } + fn source(&self) -> InFile { + self.field_list_parent_path + .clone() + .map(|path| InFile { file_id: self.file, value: path.into() }) + .unwrap_or_else(|| self.fix_source()) + } fn as_any(&self) -> &(dyn Any + Send + 'static) { self } @@ -326,41 +333,6 @@ mod tests { assert_eq!(annotations, actual); } - #[test] - fn structure_name_highlighted_for_missing_fields() { - check_diagnostics( - r#" -struct Beefy { - one: i32, - two: i32, - three: i32, - four: i32, - five: i32, - six: i32, - seven: i32, - eight: i32, - nine: i32, - ten: i32, -} -fn baz() { - let zz = Beefy { - //^^^^^ Missing structure fields: - // | - seven - one: (), - two: (), - three: (), - four: (), - five: (), - six: (), - eight: (), - nine: (), - ten: (), - }; -} -"#, - ); - } - #[test] fn no_such_field_diagnostics() { check_diagnostics( @@ -491,8 +463,8 @@ impl Foo { struct S { foo: i32, bar: () } fn baz(s: S) { let S { foo: _ } = s; - //^^^^^^^^^^ Missing structure fields: - // | - bar + //^ Missing structure fields: + //| - bar } "#, ); diff --git a/crates/ra_hir_ty/src/diagnostics/expr.rs b/crates/ra_hir_ty/src/diagnostics/expr.rs index 3c37fc58e9..98959ab684 100644 --- a/crates/ra_hir_ty/src/diagnostics/expr.rs +++ b/crates/ra_hir_ty/src/diagnostics/expr.rs @@ -110,8 +110,8 @@ impl<'a, 'b> ExprValidator<'a, 'b> { self.sink.push(MissingFields { file: source_ptr.file_id, field_list: AstPtr::new(&field_list), + field_list_parent_path: record_lit.path().map(|path| AstPtr::new(&path)), missed_fields, - list_parent_path: record_lit.path().map(|path| AstPtr::new(&path)), }) } } @@ -141,6 +141,9 @@ impl<'a, 'b> ExprValidator<'a, 'b> { self.sink.push(MissingPatFields { file: source_ptr.file_id, field_list: AstPtr::new(&field_list), + field_list_parent_path: record_pat + .path() + .map(|path| AstPtr::new(&path)), missed_fields, }) } diff --git a/crates/ra_hir_ty/src/diagnostics/match_check.rs b/crates/ra_hir_ty/src/diagnostics/match_check.rs index 507edcb7de..deca244dbb 100644 --- a/crates/ra_hir_ty/src/diagnostics/match_check.rs +++ b/crates/ra_hir_ty/src/diagnostics/match_check.rs @@ -1161,15 +1161,15 @@ fn main() { //^ Missing match arm match a { Either::A { } => (), - //^^^ Missing structure fields: - // | - foo + //^^^^^^^^^ Missing structure fields: + // | - foo Either::B => (), } match a { //^ Missing match arm Either::A { } => (), - } //^^^ Missing structure fields: - // | - foo + } //^^^^^^^^^ Missing structure fields: + // | - foo match a { Either::A { foo: true } => (), From 21184a1b2a4bea57a7666432749b171414136c60 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Mon, 27 Jul 2020 23:56:57 +0300 Subject: [PATCH 046/119] Restore accidentally removed public method --- crates/ra_hir_expand/src/diagnostics.rs | 7 ++++++- crates/ra_hir_ty/src/diagnostics.rs | 14 +++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/crates/ra_hir_expand/src/diagnostics.rs b/crates/ra_hir_expand/src/diagnostics.rs index 074a8c45e8..23f28a7f71 100644 --- a/crates/ra_hir_expand/src/diagnostics.rs +++ b/crates/ra_hir_expand/src/diagnostics.rs @@ -16,7 +16,7 @@ use std::{any::Any, fmt}; -use ra_syntax::SyntaxNodePtr; +use ra_syntax::{SyntaxNode, SyntaxNodePtr}; use crate::{db::AstDatabase, InFile}; @@ -38,6 +38,11 @@ pub trait AstDiagnostic { } impl dyn Diagnostic { + pub fn syntax_node(&self, db: &impl AstDatabase) -> SyntaxNode { + let node = db.parse_or_expand(self.source().file_id).unwrap(); + self.source().value.to_node(&node) + } + pub fn downcast_ref(&self) -> Option<&D> { self.as_any().downcast_ref() } diff --git a/crates/ra_hir_ty/src/diagnostics.rs b/crates/ra_hir_ty/src/diagnostics.rs index 48b578fb0e..9d29f30716 100644 --- a/crates/ra_hir_ty/src/diagnostics.rs +++ b/crates/ra_hir_ty/src/diagnostics.rs @@ -262,10 +262,7 @@ impl AstDiagnostic for MismatchedArgCount { #[cfg(test)] mod tests { use hir_def::{db::DefDatabase, AssocItemId, ModuleDefId}; - use hir_expand::{ - db::AstDatabase, - diagnostics::{Diagnostic, DiagnosticSinkBuilder}, - }; + use hir_expand::diagnostics::{Diagnostic, DiagnosticSinkBuilder}; use ra_db::{fixture::WithFixture, FileId, SourceDatabase, SourceDatabaseExt}; use ra_syntax::{TextRange, TextSize}; use rustc_hash::FxHashMap; @@ -310,12 +307,11 @@ mod tests { let mut actual: FxHashMap> = FxHashMap::default(); db.diagnostics(|d| { - // FXIME: macros... - let source = d.source(); - let root = db.parse_or_expand(source.file_id).unwrap(); - let range = source.value.to_node(&root).text_range(); + // FIXME: macros... + let file_id = d.source().file_id.original_file(&db); + let range = d.syntax_node(&db).text_range(); let message = d.message().to_owned(); - actual.entry(source.file_id.original_file(&db)).or_default().push((range, message)); + actual.entry(file_id).or_default().push((range, message)); }); for (file_id, diags) in actual.iter_mut() { From cfbbd91a886e2394e7411f9d7f4966dcbd454764 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 28 Jul 2020 10:24:59 +0300 Subject: [PATCH 047/119] Require source implementations for Diagnostic --- crates/ra_hir_def/src/diagnostics.rs | 2 +- crates/ra_hir_expand/src/diagnostics.rs | 13 ++++++++----- crates/ra_hir_ty/src/diagnostics.rs | 12 ++++++------ 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/crates/ra_hir_def/src/diagnostics.rs b/crates/ra_hir_def/src/diagnostics.rs index e532695895..30db48f868 100644 --- a/crates/ra_hir_def/src/diagnostics.rs +++ b/crates/ra_hir_def/src/diagnostics.rs @@ -18,7 +18,7 @@ impl Diagnostic for UnresolvedModule { fn message(&self) -> String { "unresolved module".to_string() } - fn fix_source(&self) -> InFile { + fn source(&self) -> InFile { InFile::new(self.file, self.decl.clone().into()) } fn as_any(&self) -> &(dyn Any + Send + 'static) { diff --git a/crates/ra_hir_expand/src/diagnostics.rs b/crates/ra_hir_expand/src/diagnostics.rs index 23f28a7f71..90a3b87f96 100644 --- a/crates/ra_hir_expand/src/diagnostics.rs +++ b/crates/ra_hir_expand/src/diagnostics.rs @@ -22,9 +22,11 @@ use crate::{db::AstDatabase, InFile}; pub trait Diagnostic: Any + Send + Sync + fmt::Debug + 'static { fn message(&self) -> String; - fn fix_source(&self) -> InFile; - fn source(&self) -> InFile { - self.fix_source() + /// A source to be used in highlighting and other visual representations + fn source(&self) -> InFile; + /// A source to be used during the fix application + fn fix_source(&self) -> InFile { + self.source() } fn as_any(&self) -> &(dyn Any + Send + 'static); fn is_experimental(&self) -> bool { @@ -39,8 +41,9 @@ pub trait AstDiagnostic { impl dyn Diagnostic { pub fn syntax_node(&self, db: &impl AstDatabase) -> SyntaxNode { - let node = db.parse_or_expand(self.source().file_id).unwrap(); - self.source().value.to_node(&node) + let source = self.source(); + let node = db.parse_or_expand(source.file_id).unwrap(); + source.value.to_node(&node) } pub fn downcast_ref(&self) -> Option<&D> { diff --git a/crates/ra_hir_ty/src/diagnostics.rs b/crates/ra_hir_ty/src/diagnostics.rs index 9d29f30716..efca096199 100644 --- a/crates/ra_hir_ty/src/diagnostics.rs +++ b/crates/ra_hir_ty/src/diagnostics.rs @@ -37,7 +37,7 @@ impl Diagnostic for NoSuchField { "no such field".to_string() } - fn fix_source(&self) -> InFile { + fn source(&self) -> InFile { InFile::new(self.file, self.field.clone().into()) } @@ -137,7 +137,7 @@ impl Diagnostic for MissingMatchArms { fn message(&self) -> String { String::from("Missing match arm") } - fn fix_source(&self) -> InFile { + fn source(&self) -> InFile { InFile { file_id: self.file, value: self.match_expr.clone().into() } } fn as_any(&self) -> &(dyn Any + Send + 'static) { @@ -155,7 +155,7 @@ impl Diagnostic for MissingOkInTailExpr { fn message(&self) -> String { "wrap return expression in Ok".to_string() } - fn fix_source(&self) -> InFile { + fn source(&self) -> InFile { InFile { file_id: self.file, value: self.expr.clone().into() } } fn as_any(&self) -> &(dyn Any + Send + 'static) { @@ -182,7 +182,7 @@ impl Diagnostic for BreakOutsideOfLoop { fn message(&self) -> String { "break outside of loop".to_string() } - fn fix_source(&self) -> InFile { + fn source(&self) -> InFile { InFile { file_id: self.file, value: self.expr.clone().into() } } fn as_any(&self) -> &(dyn Any + Send + 'static) { @@ -209,7 +209,7 @@ impl Diagnostic for MissingUnsafe { fn message(&self) -> String { format!("This operation is unsafe and requires an unsafe function or block") } - fn fix_source(&self) -> InFile { + fn source(&self) -> InFile { InFile { file_id: self.file, value: self.expr.clone().into() } } fn as_any(&self) -> &(dyn Any + Send + 'static) { @@ -239,7 +239,7 @@ impl Diagnostic for MismatchedArgCount { let s = if self.expected == 1 { "" } else { "s" }; format!("Expected {} argument{}, found {}", self.expected, s, self.found) } - fn fix_source(&self) -> InFile { + fn source(&self) -> InFile { InFile { file_id: self.file, value: self.call_expr.clone().into() } } fn as_any(&self) -> &(dyn Any + Send + 'static) { From 9963f43d51071ea02f8f6d490b9c49882034b42c Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sun, 9 Aug 2020 01:59:26 +0300 Subject: [PATCH 048/119] Refactor the diagnostics --- crates/ra_hir/src/semantics.rs | 28 +++---- crates/ra_hir_def/src/diagnostics.rs | 12 ++- crates/ra_hir_expand/src/diagnostics.rs | 17 +---- crates/ra_hir_ty/src/diagnostics.rs | 97 ++++++++++-------------- crates/ra_hir_ty/src/diagnostics/expr.rs | 12 +-- crates/ra_ide/src/diagnostics.rs | 76 ++++++++++--------- 6 files changed, 106 insertions(+), 136 deletions(-) diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs index 1c5dc3d510..b4420d3785 100644 --- a/crates/ra_hir/src/semantics.rs +++ b/crates/ra_hir/src/semantics.rs @@ -109,11 +109,14 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { self.imp.parse(file_id) } - pub fn ast(&self, d: &T) -> ::AST { - let file_id = d.source().file_id; + pub fn diagnostic_fix_source( + &self, + d: &T, + ) -> ::AST { + let file_id = d.presentation().file_id; let root = self.db.parse_or_expand(file_id).unwrap(); self.imp.cache(root, file_id); - d.ast(self.db.upcast()) + d.fix_source(self.db.upcast()) } pub fn expand(&self, macro_call: &ast::MacroCall) -> Option { @@ -145,12 +148,8 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { self.imp.original_range(node) } - pub fn diagnostics_fix_range(&self, diagnostics: &dyn Diagnostic) -> FileRange { - self.imp.diagnostics_fix_range(diagnostics) - } - - pub fn diagnostics_range(&self, diagnostics: &dyn Diagnostic) -> FileRange { - self.imp.diagnostics_range(diagnostics) + pub fn diagnostics_presentation_range(&self, diagnostics: &dyn Diagnostic) -> FileRange { + self.imp.diagnostics_presentation_range(diagnostics) } pub fn ancestors_with_macros(&self, node: SyntaxNode) -> impl Iterator + '_ { @@ -380,15 +379,8 @@ impl<'db> SemanticsImpl<'db> { original_range(self.db, node.as_ref()) } - fn diagnostics_fix_range(&self, diagnostics: &dyn Diagnostic) -> FileRange { - let src = diagnostics.fix_source(); - let root = self.db.parse_or_expand(src.file_id).unwrap(); - let node = src.value.to_node(&root); - original_range(self.db, src.with_value(&node)) - } - - fn diagnostics_range(&self, diagnostics: &dyn Diagnostic) -> FileRange { - let src = diagnostics.source(); + fn diagnostics_presentation_range(&self, diagnostics: &dyn Diagnostic) -> FileRange { + let src = diagnostics.presentation(); let root = self.db.parse_or_expand(src.file_id).unwrap(); let node = src.value.to_node(&root); original_range(self.db, src.with_value(&node)) diff --git a/crates/ra_hir_def/src/diagnostics.rs b/crates/ra_hir_def/src/diagnostics.rs index 30db48f868..be96128465 100644 --- a/crates/ra_hir_def/src/diagnostics.rs +++ b/crates/ra_hir_def/src/diagnostics.rs @@ -2,7 +2,7 @@ use std::any::Any; -use hir_expand::diagnostics::Diagnostic; +use hir_expand::diagnostics::{AstDiagnostic, Diagnostic}; use ra_syntax::{ast, AstPtr, SyntaxNodePtr}; use hir_expand::{HirFileId, InFile}; @@ -18,10 +18,18 @@ impl Diagnostic for UnresolvedModule { fn message(&self) -> String { "unresolved module".to_string() } - fn source(&self) -> InFile { + fn presentation(&self) -> InFile { InFile::new(self.file, self.decl.clone().into()) } fn as_any(&self) -> &(dyn Any + Send + 'static) { self } } + +impl AstDiagnostic for UnresolvedModule { + type AST = ast::Module; + fn fix_source(&self, db: &dyn hir_expand::db::AstDatabase) -> Self::AST { + let root = db.parse_or_expand(self.file).unwrap(); + self.decl.to_node(&root) + } +} diff --git a/crates/ra_hir_expand/src/diagnostics.rs b/crates/ra_hir_expand/src/diagnostics.rs index 90a3b87f96..2b74473cec 100644 --- a/crates/ra_hir_expand/src/diagnostics.rs +++ b/crates/ra_hir_expand/src/diagnostics.rs @@ -16,18 +16,13 @@ use std::{any::Any, fmt}; -use ra_syntax::{SyntaxNode, SyntaxNodePtr}; +use ra_syntax::SyntaxNodePtr; use crate::{db::AstDatabase, InFile}; pub trait Diagnostic: Any + Send + Sync + fmt::Debug + 'static { fn message(&self) -> String; - /// A source to be used in highlighting and other visual representations - fn source(&self) -> InFile; - /// A source to be used during the fix application - fn fix_source(&self) -> InFile { - self.source() - } + fn presentation(&self) -> InFile; fn as_any(&self) -> &(dyn Any + Send + 'static); fn is_experimental(&self) -> bool { false @@ -36,16 +31,10 @@ pub trait Diagnostic: Any + Send + Sync + fmt::Debug + 'static { pub trait AstDiagnostic { type AST; - fn ast(&self, db: &dyn AstDatabase) -> Self::AST; + fn fix_source(&self, db: &dyn AstDatabase) -> Self::AST; } impl dyn Diagnostic { - pub fn syntax_node(&self, db: &impl AstDatabase) -> SyntaxNode { - let source = self.source(); - let node = db.parse_or_expand(source.file_id).unwrap(); - source.value.to_node(&node) - } - pub fn downcast_ref(&self) -> Option<&D> { self.as_any().downcast_ref() } diff --git a/crates/ra_hir_ty/src/diagnostics.rs b/crates/ra_hir_ty/src/diagnostics.rs index efca096199..1e3a446375 100644 --- a/crates/ra_hir_ty/src/diagnostics.rs +++ b/crates/ra_hir_ty/src/diagnostics.rs @@ -9,7 +9,7 @@ use hir_def::DefWithBodyId; use hir_expand::diagnostics::{AstDiagnostic, Diagnostic, DiagnosticSink}; use hir_expand::{db::AstDatabase, name::Name, HirFileId, InFile}; use ra_prof::profile; -use ra_syntax::{ast, AstNode, AstPtr, SyntaxNodePtr}; +use ra_syntax::{ast, AstPtr, SyntaxNodePtr}; use stdx::format_to; use crate::db::HirDatabase; @@ -37,7 +37,7 @@ impl Diagnostic for NoSuchField { "no such field".to_string() } - fn source(&self) -> InFile { + fn presentation(&self) -> InFile { InFile::new(self.file, self.field.clone().into()) } @@ -49,7 +49,7 @@ impl Diagnostic for NoSuchField { impl AstDiagnostic for NoSuchField { type AST = ast::RecordExprField; - fn ast(&self, db: &dyn AstDatabase) -> Self::AST { + fn fix_source(&self, db: &dyn AstDatabase) -> Self::AST { let root = db.parse_or_expand(self.file).unwrap(); self.field.to_node(&root) } @@ -58,7 +58,7 @@ impl AstDiagnostic for NoSuchField { #[derive(Debug)] pub struct MissingFields { pub file: HirFileId, - pub field_list: AstPtr, + pub field_list_parent: AstPtr, pub field_list_parent_path: Option>, pub missed_fields: Vec, } @@ -71,15 +71,16 @@ impl Diagnostic for MissingFields { } buf } - fn fix_source(&self) -> InFile { - InFile { file_id: self.file, value: self.field_list.clone().into() } - } - fn source(&self) -> InFile { - self.field_list_parent_path - .clone() - .map(|path| InFile { file_id: self.file, value: path.into() }) - .unwrap_or_else(|| self.fix_source()) + fn presentation(&self) -> InFile { + InFile { + file_id: self.file, + value: self + .field_list_parent_path + .clone() + .map(SyntaxNodePtr::from) + .unwrap_or_else(|| self.field_list_parent.clone().into()), + } } fn as_any(&self) -> &(dyn Any + Send + 'static) { @@ -88,18 +89,18 @@ impl Diagnostic for MissingFields { } impl AstDiagnostic for MissingFields { - type AST = ast::RecordExprFieldList; + type AST = ast::RecordExpr; - fn ast(&self, db: &dyn AstDatabase) -> Self::AST { + fn fix_source(&self, db: &dyn AstDatabase) -> Self::AST { let root = db.parse_or_expand(self.file).unwrap(); - self.field_list.to_node(&root) + self.field_list_parent.to_node(&root) } } #[derive(Debug)] pub struct MissingPatFields { pub file: HirFileId, - pub field_list: AstPtr, + pub field_list_parent: AstPtr, pub field_list_parent_path: Option>, pub missed_fields: Vec, } @@ -112,14 +113,13 @@ impl Diagnostic for MissingPatFields { } buf } - fn fix_source(&self) -> InFile { - InFile { file_id: self.file, value: self.field_list.clone().into() } - } - fn source(&self) -> InFile { - self.field_list_parent_path + fn presentation(&self) -> InFile { + let value = self + .field_list_parent_path .clone() - .map(|path| InFile { file_id: self.file, value: path.into() }) - .unwrap_or_else(|| self.fix_source()) + .map(SyntaxNodePtr::from) + .unwrap_or_else(|| self.field_list_parent.clone().into()); + InFile { file_id: self.file, value } } fn as_any(&self) -> &(dyn Any + Send + 'static) { self @@ -137,7 +137,7 @@ impl Diagnostic for MissingMatchArms { fn message(&self) -> String { String::from("Missing match arm") } - fn source(&self) -> InFile { + fn presentation(&self) -> InFile { InFile { file_id: self.file, value: self.match_expr.clone().into() } } fn as_any(&self) -> &(dyn Any + Send + 'static) { @@ -155,7 +155,7 @@ impl Diagnostic for MissingOkInTailExpr { fn message(&self) -> String { "wrap return expression in Ok".to_string() } - fn source(&self) -> InFile { + fn presentation(&self) -> InFile { InFile { file_id: self.file, value: self.expr.clone().into() } } fn as_any(&self) -> &(dyn Any + Send + 'static) { @@ -166,7 +166,7 @@ impl Diagnostic for MissingOkInTailExpr { impl AstDiagnostic for MissingOkInTailExpr { type AST = ast::Expr; - fn ast(&self, db: &dyn AstDatabase) -> Self::AST { + fn fix_source(&self, db: &dyn AstDatabase) -> Self::AST { let root = db.parse_or_expand(self.file).unwrap(); self.expr.to_node(&root) } @@ -182,7 +182,7 @@ impl Diagnostic for BreakOutsideOfLoop { fn message(&self) -> String { "break outside of loop".to_string() } - fn source(&self) -> InFile { + fn presentation(&self) -> InFile { InFile { file_id: self.file, value: self.expr.clone().into() } } fn as_any(&self) -> &(dyn Any + Send + 'static) { @@ -190,15 +190,6 @@ impl Diagnostic for BreakOutsideOfLoop { } } -impl AstDiagnostic for BreakOutsideOfLoop { - type AST = ast::Expr; - - fn ast(&self, db: &dyn AstDatabase) -> Self::AST { - let root = db.parse_or_expand(self.file).unwrap(); - self.expr.to_node(&root) - } -} - #[derive(Debug)] pub struct MissingUnsafe { pub file: HirFileId, @@ -209,7 +200,7 @@ impl Diagnostic for MissingUnsafe { fn message(&self) -> String { format!("This operation is unsafe and requires an unsafe function or block") } - fn source(&self) -> InFile { + fn presentation(&self) -> InFile { InFile { file_id: self.file, value: self.expr.clone().into() } } fn as_any(&self) -> &(dyn Any + Send + 'static) { @@ -217,15 +208,6 @@ impl Diagnostic for MissingUnsafe { } } -impl AstDiagnostic for MissingUnsafe { - type AST = ast::Expr; - - fn ast(&self, db: &dyn AstDatabase) -> Self::AST { - let root = db.parse_or_expand(self.file).unwrap(); - self.expr.to_node(&root) - } -} - #[derive(Debug)] pub struct MismatchedArgCount { pub file: HirFileId, @@ -239,7 +221,7 @@ impl Diagnostic for MismatchedArgCount { let s = if self.expected == 1 { "" } else { "s" }; format!("Expected {} argument{}, found {}", self.expected, s, self.found) } - fn source(&self) -> InFile { + fn presentation(&self) -> InFile { InFile { file_id: self.file, value: self.call_expr.clone().into() } } fn as_any(&self) -> &(dyn Any + Send + 'static) { @@ -250,19 +232,13 @@ impl Diagnostic for MismatchedArgCount { } } -impl AstDiagnostic for MismatchedArgCount { - type AST = ast::CallExpr; - fn ast(&self, db: &dyn AstDatabase) -> Self::AST { - let root = db.parse_or_expand(self.file).unwrap(); - let node = self.source().value.to_node(&root); - ast::CallExpr::cast(node).unwrap() - } -} - #[cfg(test)] mod tests { use hir_def::{db::DefDatabase, AssocItemId, ModuleDefId}; - use hir_expand::diagnostics::{Diagnostic, DiagnosticSinkBuilder}; + use hir_expand::{ + db::AstDatabase, + diagnostics::{Diagnostic, DiagnosticSinkBuilder}, + }; use ra_db::{fixture::WithFixture, FileId, SourceDatabase, SourceDatabaseExt}; use ra_syntax::{TextRange, TextSize}; use rustc_hash::FxHashMap; @@ -308,8 +284,11 @@ mod tests { let mut actual: FxHashMap> = FxHashMap::default(); db.diagnostics(|d| { // FIXME: macros... - let file_id = d.source().file_id.original_file(&db); - let range = d.syntax_node(&db).text_range(); + let diagnostics_presentation = d.presentation(); + let root = db.parse_or_expand(diagnostics_presentation.file_id).unwrap(); + + let file_id = diagnostics_presentation.file_id.original_file(&db); + let range = diagnostics_presentation.value.to_node(&root).text_range(); let message = d.message().to_owned(); actual.entry(file_id).or_default().push((range, message)); }); diff --git a/crates/ra_hir_ty/src/diagnostics/expr.rs b/crates/ra_hir_ty/src/diagnostics/expr.rs index 98959ab684..51adcecafa 100644 --- a/crates/ra_hir_ty/src/diagnostics/expr.rs +++ b/crates/ra_hir_ty/src/diagnostics/expr.rs @@ -100,8 +100,8 @@ impl<'a, 'b> ExprValidator<'a, 'b> { if let Ok(source_ptr) = source_map.expr_syntax(id) { let root = source_ptr.file_syntax(db.upcast()); - if let ast::Expr::RecordExpr(record_lit) = &source_ptr.value.to_node(&root) { - if let Some(field_list) = record_lit.record_expr_field_list() { + if let ast::Expr::RecordExpr(record_expr) = &source_ptr.value.to_node(&root) { + if let Some(_) = record_expr.record_expr_field_list() { let variant_data = variant_data(db.upcast(), variant_def); let missed_fields = missed_fields .into_iter() @@ -109,8 +109,8 @@ impl<'a, 'b> ExprValidator<'a, 'b> { .collect(); self.sink.push(MissingFields { file: source_ptr.file_id, - field_list: AstPtr::new(&field_list), - field_list_parent_path: record_lit.path().map(|path| AstPtr::new(&path)), + field_list_parent: AstPtr::new(&record_expr), + field_list_parent_path: record_expr.path().map(|path| AstPtr::new(&path)), missed_fields, }) } @@ -132,7 +132,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { if let Some(expr) = source_ptr.value.as_ref().left() { let root = source_ptr.file_syntax(db.upcast()); if let ast::Pat::RecordPat(record_pat) = expr.to_node(&root) { - if let Some(field_list) = record_pat.record_pat_field_list() { + if let Some(_) = record_pat.record_pat_field_list() { let variant_data = variant_data(db.upcast(), variant_def); let missed_fields = missed_fields .into_iter() @@ -140,7 +140,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { .collect(); self.sink.push(MissingPatFields { file: source_ptr.file_id, - field_list: AstPtr::new(&field_list), + field_list_parent: AstPtr::new(&record_pat), field_list_parent_path: record_pat .path() .map(|path| AstPtr::new(&path)), diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs index 0d2ff17e1f..55593a8cb8 100644 --- a/crates/ra_ide/src/diagnostics.rs +++ b/crates/ra_ide/src/diagnostics.rs @@ -7,7 +7,7 @@ use std::cell::RefCell; use hir::{ - diagnostics::{AstDiagnostic, Diagnostic as _, DiagnosticSinkBuilder}, + diagnostics::{Diagnostic as _, DiagnosticSinkBuilder}, HasSource, HirDisplay, Semantics, VariantDef, }; use itertools::Itertools; @@ -63,10 +63,10 @@ pub(crate) fn diagnostics( .into(), ); res.borrow_mut().push(Diagnostic { - range: sema.diagnostics_range(d).range, + range: sema.diagnostics_presentation_range(d).range, message: d.message(), severity: Severity::Error, - fix: Some((fix, sema.diagnostics_fix_range(d).range)), + fix: Some((fix, sema.diagnostic_fix_source(d).syntax().text_range())), }) }) .on::(|d| { @@ -78,56 +78,58 @@ pub(crate) fn diagnostics( let fix = if d.missed_fields.iter().any(|it| it.as_tuple_index().is_some()) { None } else { - let mut field_list = d.ast(db); - for f in d.missed_fields.iter() { - let field = make::record_expr_field( - make::name_ref(&f.to_string()), - Some(make::expr_unit()), - ); - field_list = field_list.append_field(&field); - } + let record_expr = sema.diagnostic_fix_source(d); + if let Some(old_field_list) = record_expr.record_expr_field_list() { + let mut new_field_list = old_field_list.clone(); + for f in d.missed_fields.iter() { + let field = make::record_expr_field( + make::name_ref(&f.to_string()), + Some(make::expr_unit()), + ); + new_field_list = new_field_list.append_field(&field); + } - let edit = { - let mut builder = TextEditBuilder::default(); - algo::diff(&d.ast(db).syntax(), &field_list.syntax()) - .into_text_edit(&mut builder); - builder.finish() - }; - Some(( - Fix::new("Fill struct fields", SourceFileEdit { file_id, edit }.into()), - sema.diagnostics_fix_range(d).range, - )) + let edit = { + let mut builder = TextEditBuilder::default(); + algo::diff(&old_field_list.syntax(), &new_field_list.syntax()) + .into_text_edit(&mut builder); + builder.finish() + }; + Some(( + Fix::new("Fill struct fields", SourceFileEdit { file_id, edit }.into()), + sema.original_range(&old_field_list.syntax()).range, + )) + } else { + None + } }; res.borrow_mut().push(Diagnostic { - range: sema.diagnostics_range(d).range, + range: sema.diagnostics_presentation_range(d).range, message: d.message(), severity: Severity::Error, fix, }) }) .on::(|d| { - let node = d.ast(db); - let replacement = format!("Ok({})", node.syntax()); - let edit = TextEdit::replace(node.syntax().text_range(), replacement); + let tail_expr = sema.diagnostic_fix_source(d); + let tail_expr_range = tail_expr.syntax().text_range(); + let edit = TextEdit::replace(tail_expr_range, format!("Ok({})", tail_expr.syntax())); let source_change = SourceFileEdit { file_id, edit }.into(); res.borrow_mut().push(Diagnostic { - range: sema.diagnostics_range(d).range, + range: sema.diagnostics_presentation_range(d).range, message: d.message(), severity: Severity::Error, - fix: Some(( - Fix::new("Wrap with ok", source_change), - sema.diagnostics_fix_range(d).range, - )), + fix: Some((Fix::new("Wrap with ok", source_change), tail_expr_range)), }) }) .on::(|d| { res.borrow_mut().push(Diagnostic { - range: sema.diagnostics_range(d).range, + range: sema.diagnostics_presentation_range(d).range, message: d.message(), severity: Severity::Error, fix: missing_struct_field_fix(&sema, file_id, d) - .map(|fix| (fix, sema.diagnostics_fix_range(d).range)), + .map(|fix| (fix, sema.diagnostic_fix_source(d).syntax().text_range())), }) }) // Only collect experimental diagnostics when they're enabled. @@ -136,7 +138,7 @@ pub(crate) fn diagnostics( .build(|d| { res.borrow_mut().push(Diagnostic { message: d.message(), - range: sema.diagnostics_range(d).range, + range: sema.diagnostics_presentation_range(d).range, severity: Severity::Error, fix: None, }) @@ -154,9 +156,9 @@ fn missing_struct_field_fix( usage_file_id: FileId, d: &hir::diagnostics::NoSuchField, ) -> Option { - let record_expr = sema.ast(d); + let record_expr_field = sema.diagnostic_fix_source(d); - let record_lit = ast::RecordExpr::cast(record_expr.syntax().parent()?.parent()?)?; + let record_lit = ast::RecordExpr::cast(record_expr_field.syntax().parent()?.parent()?)?; let def_id = sema.resolve_variant(record_lit)?; let module; let def_file_id; @@ -184,12 +186,12 @@ fn missing_struct_field_fix( }; let def_file_id = def_file_id.original_file(sema.db); - let new_field_type = sema.type_of_expr(&record_expr.expr()?)?; + let new_field_type = sema.type_of_expr(&record_expr_field.expr()?)?; if new_field_type.is_unknown() { return None; } let new_field = make::record_field( - record_expr.field_name()?, + record_expr_field.field_name()?, make::ty(&new_field_type.display_source_code(sema.db, module.into()).ok()?), ); From 936861993935d5b2c78b953e2f4b719e1992bd73 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Mon, 10 Aug 2020 22:53:10 +0300 Subject: [PATCH 049/119] Make the fix AST source Optional --- crates/ra_hir/src/diagnostics.rs | 2 +- crates/ra_hir/src/semantics.rs | 8 +-- crates/ra_hir_def/src/diagnostics.rs | 10 +-- crates/ra_hir_expand/src/diagnostics.rs | 19 ++---- crates/ra_hir_ty/src/diagnostics.rs | 26 ++++---- crates/ra_ide/src/diagnostics.rs | 85 ++++++++++++++----------- 6 files changed, 77 insertions(+), 73 deletions(-) diff --git a/crates/ra_hir/src/diagnostics.rs b/crates/ra_hir/src/diagnostics.rs index 266b513dcf..564f6a5db2 100644 --- a/crates/ra_hir/src/diagnostics.rs +++ b/crates/ra_hir/src/diagnostics.rs @@ -1,7 +1,7 @@ //! FIXME: write short doc here pub use hir_def::diagnostics::UnresolvedModule; pub use hir_expand::diagnostics::{ - AstDiagnostic, Diagnostic, DiagnosticSink, DiagnosticSinkBuilder, + Diagnostic, DiagnosticSink, DiagnosticSinkBuilder, DiagnosticWithFix, }; pub use hir_ty::diagnostics::{ MismatchedArgCount, MissingFields, MissingMatchArms, MissingOkInTailExpr, NoSuchField, diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs index b4420d3785..c5bc2baffe 100644 --- a/crates/ra_hir/src/semantics.rs +++ b/crates/ra_hir/src/semantics.rs @@ -8,7 +8,7 @@ use hir_def::{ resolver::{self, HasResolver, Resolver}, AsMacroCall, FunctionId, TraitId, VariantId, }; -use hir_expand::{diagnostics::AstDiagnostic, hygiene::Hygiene, name::AsName, ExpansionInfo}; +use hir_expand::{diagnostics::DiagnosticWithFix, hygiene::Hygiene, name::AsName, ExpansionInfo}; use hir_ty::associated_type_shorthand_candidates; use itertools::Itertools; use ra_db::{FileId, FileRange}; @@ -109,12 +109,12 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { self.imp.parse(file_id) } - pub fn diagnostic_fix_source( + pub fn diagnostic_fix_source( &self, d: &T, - ) -> ::AST { + ) -> Option<::AST> { let file_id = d.presentation().file_id; - let root = self.db.parse_or_expand(file_id).unwrap(); + let root = self.db.parse_or_expand(file_id)?; self.imp.cache(root, file_id); d.fix_source(self.db.upcast()) } diff --git a/crates/ra_hir_def/src/diagnostics.rs b/crates/ra_hir_def/src/diagnostics.rs index be96128465..033be683c4 100644 --- a/crates/ra_hir_def/src/diagnostics.rs +++ b/crates/ra_hir_def/src/diagnostics.rs @@ -2,7 +2,7 @@ use std::any::Any; -use hir_expand::diagnostics::{AstDiagnostic, Diagnostic}; +use hir_expand::diagnostics::{Diagnostic, DiagnosticWithFix}; use ra_syntax::{ast, AstPtr, SyntaxNodePtr}; use hir_expand::{HirFileId, InFile}; @@ -26,10 +26,10 @@ impl Diagnostic for UnresolvedModule { } } -impl AstDiagnostic for UnresolvedModule { +impl DiagnosticWithFix for UnresolvedModule { type AST = ast::Module; - fn fix_source(&self, db: &dyn hir_expand::db::AstDatabase) -> Self::AST { - let root = db.parse_or_expand(self.file).unwrap(); - self.decl.to_node(&root) + fn fix_source(&self, db: &dyn hir_expand::db::AstDatabase) -> Option { + let root = db.parse_or_expand(self.file)?; + Some(self.decl.to_node(&root)) } } diff --git a/crates/ra_hir_expand/src/diagnostics.rs b/crates/ra_hir_expand/src/diagnostics.rs index 2b74473cec..62a09a73ae 100644 --- a/crates/ra_hir_expand/src/diagnostics.rs +++ b/crates/ra_hir_expand/src/diagnostics.rs @@ -29,15 +29,9 @@ pub trait Diagnostic: Any + Send + Sync + fmt::Debug + 'static { } } -pub trait AstDiagnostic { +pub trait DiagnosticWithFix { type AST; - fn fix_source(&self, db: &dyn AstDatabase) -> Self::AST; -} - -impl dyn Diagnostic { - pub fn downcast_ref(&self) -> Option<&D> { - self.as_any().downcast_ref() - } + fn fix_source(&self, db: &dyn AstDatabase) -> Option; } pub struct DiagnosticSink<'a> { @@ -83,12 +77,9 @@ impl<'a> DiagnosticSinkBuilder<'a> { self } - pub fn on(mut self, mut cb: F) -> Self { - let cb = move |diag: &dyn Diagnostic| match diag.downcast_ref::() { - Some(d) => { - cb(d); - Ok(()) - } + pub fn on Option<()> + 'a>(mut self, mut cb: F) -> Self { + let cb = move |diag: &dyn Diagnostic| match diag.as_any().downcast_ref::() { + Some(d) => cb(d).ok_or(()), None => Err(()), }; self.callbacks.push(Box::new(cb)); diff --git a/crates/ra_hir_ty/src/diagnostics.rs b/crates/ra_hir_ty/src/diagnostics.rs index 1e3a446375..b34ba5bfc8 100644 --- a/crates/ra_hir_ty/src/diagnostics.rs +++ b/crates/ra_hir_ty/src/diagnostics.rs @@ -6,7 +6,7 @@ mod unsafe_check; use std::any::Any; use hir_def::DefWithBodyId; -use hir_expand::diagnostics::{AstDiagnostic, Diagnostic, DiagnosticSink}; +use hir_expand::diagnostics::{Diagnostic, DiagnosticSink, DiagnosticWithFix}; use hir_expand::{db::AstDatabase, name::Name, HirFileId, InFile}; use ra_prof::profile; use ra_syntax::{ast, AstPtr, SyntaxNodePtr}; @@ -46,12 +46,12 @@ impl Diagnostic for NoSuchField { } } -impl AstDiagnostic for NoSuchField { +impl DiagnosticWithFix for NoSuchField { type AST = ast::RecordExprField; - fn fix_source(&self, db: &dyn AstDatabase) -> Self::AST { - let root = db.parse_or_expand(self.file).unwrap(); - self.field.to_node(&root) + fn fix_source(&self, db: &dyn AstDatabase) -> Option { + let root = db.parse_or_expand(self.file)?; + Some(self.field.to_node(&root)) } } @@ -88,12 +88,12 @@ impl Diagnostic for MissingFields { } } -impl AstDiagnostic for MissingFields { +impl DiagnosticWithFix for MissingFields { type AST = ast::RecordExpr; - fn fix_source(&self, db: &dyn AstDatabase) -> Self::AST { - let root = db.parse_or_expand(self.file).unwrap(); - self.field_list_parent.to_node(&root) + fn fix_source(&self, db: &dyn AstDatabase) -> Option { + let root = db.parse_or_expand(self.file)?; + Some(self.field_list_parent.to_node(&root)) } } @@ -163,12 +163,12 @@ impl Diagnostic for MissingOkInTailExpr { } } -impl AstDiagnostic for MissingOkInTailExpr { +impl DiagnosticWithFix for MissingOkInTailExpr { type AST = ast::Expr; - fn fix_source(&self, db: &dyn AstDatabase) -> Self::AST { - let root = db.parse_or_expand(self.file).unwrap(); - self.expr.to_node(&root) + fn fix_source(&self, db: &dyn AstDatabase) -> Option { + let root = db.parse_or_expand(self.file)?; + Some(self.expr.to_node(&root)) } } diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs index 55593a8cb8..043ce357b9 100644 --- a/crates/ra_ide/src/diagnostics.rs +++ b/crates/ra_ide/src/diagnostics.rs @@ -62,12 +62,18 @@ pub(crate) fn diagnostics( } .into(), ); + let fix = sema + .diagnostic_fix_source(d) + .map(|unresolved_module| unresolved_module.syntax().text_range()) + .map(|fix_range| (fix, fix_range)); + res.borrow_mut().push(Diagnostic { range: sema.diagnostics_presentation_range(d).range, message: d.message(), severity: Severity::Error, - fix: Some((fix, sema.diagnostic_fix_source(d).syntax().text_range())), - }) + fix, + }); + Some(()) }) .on::(|d| { // Note that although we could add a diagnostics to @@ -78,30 +84,29 @@ pub(crate) fn diagnostics( let fix = if d.missed_fields.iter().any(|it| it.as_tuple_index().is_some()) { None } else { - let record_expr = sema.diagnostic_fix_source(d); - if let Some(old_field_list) = record_expr.record_expr_field_list() { - let mut new_field_list = old_field_list.clone(); - for f in d.missed_fields.iter() { - let field = make::record_expr_field( - make::name_ref(&f.to_string()), - Some(make::expr_unit()), - ); - new_field_list = new_field_list.append_field(&field); - } + sema.diagnostic_fix_source(d) + .and_then(|record_expr| record_expr.record_expr_field_list()) + .map(|old_field_list| { + let mut new_field_list = old_field_list.clone(); + for f in d.missed_fields.iter() { + let field = make::record_expr_field( + make::name_ref(&f.to_string()), + Some(make::expr_unit()), + ); + new_field_list = new_field_list.append_field(&field); + } - let edit = { - let mut builder = TextEditBuilder::default(); - algo::diff(&old_field_list.syntax(), &new_field_list.syntax()) - .into_text_edit(&mut builder); - builder.finish() - }; - Some(( - Fix::new("Fill struct fields", SourceFileEdit { file_id, edit }.into()), - sema.original_range(&old_field_list.syntax()).range, - )) - } else { - None - } + let edit = { + let mut builder = TextEditBuilder::default(); + algo::diff(&old_field_list.syntax(), &new_field_list.syntax()) + .into_text_edit(&mut builder); + builder.finish() + }; + ( + Fix::new("Fill struct fields", SourceFileEdit { file_id, edit }.into()), + sema.original_range(&old_field_list.syntax()).range, + ) + }) }; res.borrow_mut().push(Diagnostic { @@ -109,28 +114,36 @@ pub(crate) fn diagnostics( message: d.message(), severity: Severity::Error, fix, - }) + }); + Some(()) }) .on::(|d| { - let tail_expr = sema.diagnostic_fix_source(d); - let tail_expr_range = tail_expr.syntax().text_range(); - let edit = TextEdit::replace(tail_expr_range, format!("Ok({})", tail_expr.syntax())); - let source_change = SourceFileEdit { file_id, edit }.into(); + let fix = sema.diagnostic_fix_source(d).map(|tail_expr| { + let tail_expr_range = tail_expr.syntax().text_range(); + let edit = + TextEdit::replace(tail_expr_range, format!("Ok({})", tail_expr.syntax())); + let source_change = SourceFileEdit { file_id, edit }.into(); + (Fix::new("Wrap with ok", source_change), tail_expr_range) + }); + res.borrow_mut().push(Diagnostic { range: sema.diagnostics_presentation_range(d).range, message: d.message(), severity: Severity::Error, - fix: Some((Fix::new("Wrap with ok", source_change), tail_expr_range)), - }) + fix, + }); + Some(()) }) .on::(|d| { res.borrow_mut().push(Diagnostic { range: sema.diagnostics_presentation_range(d).range, message: d.message(), severity: Severity::Error, - fix: missing_struct_field_fix(&sema, file_id, d) - .map(|fix| (fix, sema.diagnostic_fix_source(d).syntax().text_range())), - }) + fix: missing_struct_field_fix(&sema, file_id, d).and_then(|fix| { + Some((fix, sema.diagnostic_fix_source(d)?.syntax().text_range())) + }), + }); + Some(()) }) // Only collect experimental diagnostics when they're enabled. .filter(|diag| !diag.is_experimental() || enable_experimental) @@ -156,7 +169,7 @@ fn missing_struct_field_fix( usage_file_id: FileId, d: &hir::diagnostics::NoSuchField, ) -> Option { - let record_expr_field = sema.diagnostic_fix_source(d); + let record_expr_field = sema.diagnostic_fix_source(d)?; let record_lit = ast::RecordExpr::cast(record_expr_field.syntax().parent()?.parent()?)?; let def_id = sema.resolve_variant(record_lit)?; From 29fbc8e02180aac1f4d7819a9626206aa64028a0 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 11 Aug 2020 00:37:23 +0300 Subject: [PATCH 050/119] Move the DiagnosticsWithFix trait on the ide level --- crates/ra_hir/src/diagnostics.rs | 4 +- crates/ra_hir/src/semantics.rs | 12 ++--- crates/ra_hir_def/src/diagnostics.rs | 10 +--- crates/ra_hir_expand/src/diagnostics.rs | 7 +-- crates/ra_hir_ty/src/diagnostics.rs | 31 +------------ crates/ra_ide/src/diagnostics.rs | 28 ++++++++--- .../src/diagnostics/diagnostics_with_fix.rs | 46 +++++++++++++++++++ 7 files changed, 75 insertions(+), 63 deletions(-) create mode 100644 crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs diff --git a/crates/ra_hir/src/diagnostics.rs b/crates/ra_hir/src/diagnostics.rs index 564f6a5db2..363164b9b4 100644 --- a/crates/ra_hir/src/diagnostics.rs +++ b/crates/ra_hir/src/diagnostics.rs @@ -1,8 +1,6 @@ //! FIXME: write short doc here pub use hir_def::diagnostics::UnresolvedModule; -pub use hir_expand::diagnostics::{ - Diagnostic, DiagnosticSink, DiagnosticSinkBuilder, DiagnosticWithFix, -}; +pub use hir_expand::diagnostics::{Diagnostic, DiagnosticSink, DiagnosticSinkBuilder}; pub use hir_ty::diagnostics::{ MismatchedArgCount, MissingFields, MissingMatchArms, MissingOkInTailExpr, NoSuchField, }; diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs index c5bc2baffe..e9f7a033c5 100644 --- a/crates/ra_hir/src/semantics.rs +++ b/crates/ra_hir/src/semantics.rs @@ -8,7 +8,7 @@ use hir_def::{ resolver::{self, HasResolver, Resolver}, AsMacroCall, FunctionId, TraitId, VariantId, }; -use hir_expand::{diagnostics::DiagnosticWithFix, hygiene::Hygiene, name::AsName, ExpansionInfo}; +use hir_expand::{hygiene::Hygiene, name::AsName, ExpansionInfo}; use hir_ty::associated_type_shorthand_candidates; use itertools::Itertools; use ra_db::{FileId, FileRange}; @@ -109,14 +109,8 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { self.imp.parse(file_id) } - pub fn diagnostic_fix_source( - &self, - d: &T, - ) -> Option<::AST> { - let file_id = d.presentation().file_id; - let root = self.db.parse_or_expand(file_id)?; - self.imp.cache(root, file_id); - d.fix_source(self.db.upcast()) + pub fn cache(&self, root_node: SyntaxNode, file_id: HirFileId) { + self.imp.cache(root_node, file_id) } pub fn expand(&self, macro_call: &ast::MacroCall) -> Option { diff --git a/crates/ra_hir_def/src/diagnostics.rs b/crates/ra_hir_def/src/diagnostics.rs index 033be683c4..9435c72544 100644 --- a/crates/ra_hir_def/src/diagnostics.rs +++ b/crates/ra_hir_def/src/diagnostics.rs @@ -2,7 +2,7 @@ use std::any::Any; -use hir_expand::diagnostics::{Diagnostic, DiagnosticWithFix}; +use hir_expand::diagnostics::Diagnostic; use ra_syntax::{ast, AstPtr, SyntaxNodePtr}; use hir_expand::{HirFileId, InFile}; @@ -25,11 +25,3 @@ impl Diagnostic for UnresolvedModule { self } } - -impl DiagnosticWithFix for UnresolvedModule { - type AST = ast::Module; - fn fix_source(&self, db: &dyn hir_expand::db::AstDatabase) -> Option { - let root = db.parse_or_expand(self.file)?; - Some(self.decl.to_node(&root)) - } -} diff --git a/crates/ra_hir_expand/src/diagnostics.rs b/crates/ra_hir_expand/src/diagnostics.rs index 62a09a73ae..8358c488b8 100644 --- a/crates/ra_hir_expand/src/diagnostics.rs +++ b/crates/ra_hir_expand/src/diagnostics.rs @@ -18,7 +18,7 @@ use std::{any::Any, fmt}; use ra_syntax::SyntaxNodePtr; -use crate::{db::AstDatabase, InFile}; +use crate::InFile; pub trait Diagnostic: Any + Send + Sync + fmt::Debug + 'static { fn message(&self) -> String; @@ -29,11 +29,6 @@ pub trait Diagnostic: Any + Send + Sync + fmt::Debug + 'static { } } -pub trait DiagnosticWithFix { - type AST; - fn fix_source(&self, db: &dyn AstDatabase) -> Option; -} - pub struct DiagnosticSink<'a> { callbacks: Vec Result<(), ()> + 'a>>, filters: Vec bool + 'a>>, diff --git a/crates/ra_hir_ty/src/diagnostics.rs b/crates/ra_hir_ty/src/diagnostics.rs index b34ba5bfc8..24435e8a71 100644 --- a/crates/ra_hir_ty/src/diagnostics.rs +++ b/crates/ra_hir_ty/src/diagnostics.rs @@ -6,8 +6,8 @@ mod unsafe_check; use std::any::Any; use hir_def::DefWithBodyId; -use hir_expand::diagnostics::{Diagnostic, DiagnosticSink, DiagnosticWithFix}; -use hir_expand::{db::AstDatabase, name::Name, HirFileId, InFile}; +use hir_expand::diagnostics::{Diagnostic, DiagnosticSink}; +use hir_expand::{name::Name, HirFileId, InFile}; use ra_prof::profile; use ra_syntax::{ast, AstPtr, SyntaxNodePtr}; use stdx::format_to; @@ -46,15 +46,6 @@ impl Diagnostic for NoSuchField { } } -impl DiagnosticWithFix for NoSuchField { - type AST = ast::RecordExprField; - - fn fix_source(&self, db: &dyn AstDatabase) -> Option { - let root = db.parse_or_expand(self.file)?; - Some(self.field.to_node(&root)) - } -} - #[derive(Debug)] pub struct MissingFields { pub file: HirFileId, @@ -88,15 +79,6 @@ impl Diagnostic for MissingFields { } } -impl DiagnosticWithFix for MissingFields { - type AST = ast::RecordExpr; - - fn fix_source(&self, db: &dyn AstDatabase) -> Option { - let root = db.parse_or_expand(self.file)?; - Some(self.field_list_parent.to_node(&root)) - } -} - #[derive(Debug)] pub struct MissingPatFields { pub file: HirFileId, @@ -163,15 +145,6 @@ impl Diagnostic for MissingOkInTailExpr { } } -impl DiagnosticWithFix for MissingOkInTailExpr { - type AST = ast::Expr; - - fn fix_source(&self, db: &dyn AstDatabase) -> Option { - let root = db.parse_or_expand(self.file)?; - Some(self.expr.to_node(&root)) - } -} - #[derive(Debug)] pub struct BreakOutsideOfLoop { pub file: HirFileId, diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs index 043ce357b9..ca1a7c1aae 100644 --- a/crates/ra_ide/src/diagnostics.rs +++ b/crates/ra_ide/src/diagnostics.rs @@ -7,11 +7,12 @@ use std::cell::RefCell; use hir::{ + db::AstDatabase, diagnostics::{Diagnostic as _, DiagnosticSinkBuilder}, HasSource, HirDisplay, Semantics, VariantDef, }; use itertools::Itertools; -use ra_db::SourceDatabase; +use ra_db::{SourceDatabase, Upcast}; use ra_ide_db::RootDatabase; use ra_prof::profile; use ra_syntax::{ @@ -23,6 +24,9 @@ use ra_text_edit::{TextEdit, TextEditBuilder}; use crate::{Diagnostic, FileId, FileSystemEdit, Fix, SourceFileEdit}; +mod diagnostics_with_fix; +use diagnostics_with_fix::DiagnosticWithFix; + #[derive(Debug, Copy, Clone)] pub enum Severity { Error, @@ -62,8 +66,7 @@ pub(crate) fn diagnostics( } .into(), ); - let fix = sema - .diagnostic_fix_source(d) + let fix = diagnostic_fix_source(&sema, d) .map(|unresolved_module| unresolved_module.syntax().text_range()) .map(|fix_range| (fix, fix_range)); @@ -84,7 +87,7 @@ pub(crate) fn diagnostics( let fix = if d.missed_fields.iter().any(|it| it.as_tuple_index().is_some()) { None } else { - sema.diagnostic_fix_source(d) + diagnostic_fix_source(&sema, d) .and_then(|record_expr| record_expr.record_expr_field_list()) .map(|old_field_list| { let mut new_field_list = old_field_list.clone(); @@ -105,6 +108,7 @@ pub(crate) fn diagnostics( ( Fix::new("Fill struct fields", SourceFileEdit { file_id, edit }.into()), sema.original_range(&old_field_list.syntax()).range, + // old_field_list.syntax().text_range(), ) }) }; @@ -118,7 +122,7 @@ pub(crate) fn diagnostics( Some(()) }) .on::(|d| { - let fix = sema.diagnostic_fix_source(d).map(|tail_expr| { + let fix = diagnostic_fix_source(&sema, d).map(|tail_expr| { let tail_expr_range = tail_expr.syntax().text_range(); let edit = TextEdit::replace(tail_expr_range, format!("Ok({})", tail_expr.syntax())); @@ -140,7 +144,7 @@ pub(crate) fn diagnostics( message: d.message(), severity: Severity::Error, fix: missing_struct_field_fix(&sema, file_id, d).and_then(|fix| { - Some((fix, sema.diagnostic_fix_source(d)?.syntax().text_range())) + Some((fix, diagnostic_fix_source(&sema, d)?.syntax().text_range())) }), }); Some(()) @@ -164,12 +168,22 @@ pub(crate) fn diagnostics( res.into_inner() } +fn diagnostic_fix_source( + sema: &Semantics, + d: &T, +) -> Option<::AST> { + let file_id = d.presentation().file_id; + let root = sema.db.parse_or_expand(file_id)?; + sema.cache(root, file_id); + d.fix_source(sema.db.upcast()) +} + fn missing_struct_field_fix( sema: &Semantics, usage_file_id: FileId, d: &hir::diagnostics::NoSuchField, ) -> Option { - let record_expr_field = sema.diagnostic_fix_source(d)?; + let record_expr_field = diagnostic_fix_source(&sema, d)?; let record_lit = ast::RecordExpr::cast(record_expr_field.syntax().parent()?.parent()?)?; let def_id = sema.resolve_variant(record_lit)?; diff --git a/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs b/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs new file mode 100644 index 0000000000..8578a90ec0 --- /dev/null +++ b/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs @@ -0,0 +1,46 @@ +use hir::{ + db::AstDatabase, + diagnostics::{MissingFields, MissingOkInTailExpr, NoSuchField, UnresolvedModule}, +}; +use ra_syntax::ast; + +// TODO kb +pub trait DiagnosticWithFix { + type AST; + fn fix_source(&self, db: &dyn AstDatabase) -> Option; +} + +impl DiagnosticWithFix for UnresolvedModule { + type AST = ast::Module; + fn fix_source(&self, db: &dyn AstDatabase) -> Option { + let root = db.parse_or_expand(self.file)?; + Some(self.decl.to_node(&root)) + } +} + +impl DiagnosticWithFix for NoSuchField { + type AST = ast::RecordExprField; + + fn fix_source(&self, db: &dyn AstDatabase) -> Option { + let root = db.parse_or_expand(self.file)?; + Some(self.field.to_node(&root)) + } +} + +impl DiagnosticWithFix for MissingFields { + type AST = ast::RecordExpr; + + fn fix_source(&self, db: &dyn AstDatabase) -> Option { + let root = db.parse_or_expand(self.file)?; + Some(self.field_list_parent.to_node(&root)) + } +} + +impl DiagnosticWithFix for MissingOkInTailExpr { + type AST = ast::Expr; + + fn fix_source(&self, db: &dyn AstDatabase) -> Option { + let root = db.parse_or_expand(self.file)?; + Some(self.expr.to_node(&root)) + } +} From c8cad76d25f7fab856c9646b70122e0f9f7d7218 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 11 Aug 2020 00:55:57 +0300 Subject: [PATCH 051/119] Improve the ide diagnostics trait API --- crates/ra_hir/src/semantics.rs | 5 +- crates/ra_hir_expand/src/diagnostics.rs | 7 +- crates/ra_ide/src/diagnostics.rs | 188 ++---------------- .../src/diagnostics/diagnostics_with_fix.rs | 165 +++++++++++++-- 4 files changed, 167 insertions(+), 198 deletions(-) diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs index e9f7a033c5..2dfe69039f 100644 --- a/crates/ra_hir/src/semantics.rs +++ b/crates/ra_hir/src/semantics.rs @@ -109,10 +109,6 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { self.imp.parse(file_id) } - pub fn cache(&self, root_node: SyntaxNode, file_id: HirFileId) { - self.imp.cache(root_node, file_id) - } - pub fn expand(&self, macro_call: &ast::MacroCall) -> Option { self.imp.expand(macro_call) } @@ -377,6 +373,7 @@ impl<'db> SemanticsImpl<'db> { let src = diagnostics.presentation(); let root = self.db.parse_or_expand(src.file_id).unwrap(); let node = src.value.to_node(&root); + self.cache(root, src.file_id); original_range(self.db, src.with_value(&node)) } diff --git a/crates/ra_hir_expand/src/diagnostics.rs b/crates/ra_hir_expand/src/diagnostics.rs index 8358c488b8..e58defa681 100644 --- a/crates/ra_hir_expand/src/diagnostics.rs +++ b/crates/ra_hir_expand/src/diagnostics.rs @@ -72,9 +72,12 @@ impl<'a> DiagnosticSinkBuilder<'a> { self } - pub fn on Option<()> + 'a>(mut self, mut cb: F) -> Self { + pub fn on(mut self, mut cb: F) -> Self { let cb = move |diag: &dyn Diagnostic| match diag.as_any().downcast_ref::() { - Some(d) => cb(d).ok_or(()), + Some(d) => { + cb(d); + Ok(()) + } None => Err(()), }; self.callbacks.push(Box::new(cb)); diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs index ca1a7c1aae..165ff5249c 100644 --- a/crates/ra_ide/src/diagnostics.rs +++ b/crates/ra_ide/src/diagnostics.rs @@ -7,22 +7,20 @@ use std::cell::RefCell; use hir::{ - db::AstDatabase, - diagnostics::{Diagnostic as _, DiagnosticSinkBuilder}, - HasSource, HirDisplay, Semantics, VariantDef, + diagnostics::{Diagnostic as HirDiagnostics, DiagnosticSinkBuilder}, + Semantics, }; use itertools::Itertools; -use ra_db::{SourceDatabase, Upcast}; +use ra_db::SourceDatabase; use ra_ide_db::RootDatabase; use ra_prof::profile; use ra_syntax::{ - algo, - ast::{self, edit::IndentLevel, make, AstNode}, + ast::{self, AstNode}, SyntaxNode, TextRange, T, }; use ra_text_edit::{TextEdit, TextEditBuilder}; -use crate::{Diagnostic, FileId, FileSystemEdit, Fix, SourceFileEdit}; +use crate::{Diagnostic, FileId, Fix, SourceFileEdit}; mod diagnostics_with_fix; use diagnostics_with_fix::DiagnosticWithFix; @@ -58,96 +56,16 @@ pub(crate) fn diagnostics( let res = RefCell::new(res); let mut sink = DiagnosticSinkBuilder::new() .on::(|d| { - let fix = Fix::new( - "Create module", - FileSystemEdit::CreateFile { - anchor: d.file.original_file(db), - dst: d.candidate.clone(), - } - .into(), - ); - let fix = diagnostic_fix_source(&sema, d) - .map(|unresolved_module| unresolved_module.syntax().text_range()) - .map(|fix_range| (fix, fix_range)); - - res.borrow_mut().push(Diagnostic { - range: sema.diagnostics_presentation_range(d).range, - message: d.message(), - severity: Severity::Error, - fix, - }); - Some(()) + res.borrow_mut().push(diagnostic_with_fix(d, &sema)); }) .on::(|d| { - // Note that although we could add a diagnostics to - // fill the missing tuple field, e.g : - // `struct A(usize);` - // `let a = A { 0: () }` - // but it is uncommon usage and it should not be encouraged. - let fix = if d.missed_fields.iter().any(|it| it.as_tuple_index().is_some()) { - None - } else { - diagnostic_fix_source(&sema, d) - .and_then(|record_expr| record_expr.record_expr_field_list()) - .map(|old_field_list| { - let mut new_field_list = old_field_list.clone(); - for f in d.missed_fields.iter() { - let field = make::record_expr_field( - make::name_ref(&f.to_string()), - Some(make::expr_unit()), - ); - new_field_list = new_field_list.append_field(&field); - } - - let edit = { - let mut builder = TextEditBuilder::default(); - algo::diff(&old_field_list.syntax(), &new_field_list.syntax()) - .into_text_edit(&mut builder); - builder.finish() - }; - ( - Fix::new("Fill struct fields", SourceFileEdit { file_id, edit }.into()), - sema.original_range(&old_field_list.syntax()).range, - // old_field_list.syntax().text_range(), - ) - }) - }; - - res.borrow_mut().push(Diagnostic { - range: sema.diagnostics_presentation_range(d).range, - message: d.message(), - severity: Severity::Error, - fix, - }); - Some(()) + res.borrow_mut().push(diagnostic_with_fix(d, &sema)); }) .on::(|d| { - let fix = diagnostic_fix_source(&sema, d).map(|tail_expr| { - let tail_expr_range = tail_expr.syntax().text_range(); - let edit = - TextEdit::replace(tail_expr_range, format!("Ok({})", tail_expr.syntax())); - let source_change = SourceFileEdit { file_id, edit }.into(); - (Fix::new("Wrap with ok", source_change), tail_expr_range) - }); - - res.borrow_mut().push(Diagnostic { - range: sema.diagnostics_presentation_range(d).range, - message: d.message(), - severity: Severity::Error, - fix, - }); - Some(()) + res.borrow_mut().push(diagnostic_with_fix(d, &sema)); }) .on::(|d| { - res.borrow_mut().push(Diagnostic { - range: sema.diagnostics_presentation_range(d).range, - message: d.message(), - severity: Severity::Error, - fix: missing_struct_field_fix(&sema, file_id, d).and_then(|fix| { - Some((fix, diagnostic_fix_source(&sema, d)?.syntax().text_range())) - }), - }); - Some(()) + res.borrow_mut().push(diagnostic_with_fix(d, &sema)); }) // Only collect experimental diagnostics when they're enabled. .filter(|diag| !diag.is_experimental() || enable_experimental) @@ -168,87 +86,15 @@ pub(crate) fn diagnostics( res.into_inner() } -fn diagnostic_fix_source( +fn diagnostic_with_fix( + d: &D, sema: &Semantics, - d: &T, -) -> Option<::AST> { - let file_id = d.presentation().file_id; - let root = sema.db.parse_or_expand(file_id)?; - sema.cache(root, file_id); - d.fix_source(sema.db.upcast()) -} - -fn missing_struct_field_fix( - sema: &Semantics, - usage_file_id: FileId, - d: &hir::diagnostics::NoSuchField, -) -> Option { - let record_expr_field = diagnostic_fix_source(&sema, d)?; - - let record_lit = ast::RecordExpr::cast(record_expr_field.syntax().parent()?.parent()?)?; - let def_id = sema.resolve_variant(record_lit)?; - let module; - let def_file_id; - let record_fields = match VariantDef::from(def_id) { - VariantDef::Struct(s) => { - module = s.module(sema.db); - let source = s.source(sema.db); - def_file_id = source.file_id; - let fields = source.value.field_list()?; - record_field_list(fields)? - } - VariantDef::Union(u) => { - module = u.module(sema.db); - let source = u.source(sema.db); - def_file_id = source.file_id; - source.value.record_field_list()? - } - VariantDef::EnumVariant(e) => { - module = e.module(sema.db); - let source = e.source(sema.db); - def_file_id = source.file_id; - let fields = source.value.field_list()?; - record_field_list(fields)? - } - }; - let def_file_id = def_file_id.original_file(sema.db); - - let new_field_type = sema.type_of_expr(&record_expr_field.expr()?)?; - if new_field_type.is_unknown() { - return None; - } - let new_field = make::record_field( - record_expr_field.field_name()?, - make::ty(&new_field_type.display_source_code(sema.db, module.into()).ok()?), - ); - - let last_field = record_fields.fields().last()?; - let last_field_syntax = last_field.syntax(); - let indent = IndentLevel::from_node(last_field_syntax); - - let mut new_field = new_field.to_string(); - if usage_file_id != def_file_id { - new_field = format!("pub(crate) {}", new_field); - } - new_field = format!("\n{}{}", indent, new_field); - - let needs_comma = !last_field_syntax.to_string().ends_with(','); - if needs_comma { - new_field = format!(",{}", new_field); - } - - let source_change = SourceFileEdit { - file_id: def_file_id, - edit: TextEdit::insert(last_field_syntax.text_range().end(), new_field), - }; - let fix = Fix::new("Create field", source_change.into()); - return Some(fix); - - fn record_field_list(field_def_list: ast::FieldList) -> Option { - match field_def_list { - ast::FieldList::RecordFieldList(it) => Some(it), - ast::FieldList::TupleFieldList(_) => None, - } +) -> Diagnostic { + Diagnostic { + range: sema.diagnostics_presentation_range(d).range, + message: d.message(), + severity: Severity::Error, + fix: d.fix(&sema), } } diff --git a/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs b/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs index 8578a90ec0..56d454ac61 100644 --- a/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs +++ b/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs @@ -1,46 +1,169 @@ +use crate::Fix; +use ast::{edit::IndentLevel, make}; use hir::{ db::AstDatabase, diagnostics::{MissingFields, MissingOkInTailExpr, NoSuchField, UnresolvedModule}, + HasSource, HirDisplay, Semantics, VariantDef, }; -use ra_syntax::ast; +use ra_db::FileId; +use ra_ide_db::{ + source_change::{FileSystemEdit, SourceFileEdit}, + RootDatabase, +}; +use ra_syntax::{algo, ast, AstNode, TextRange}; +use ra_text_edit::{TextEdit, TextEditBuilder}; // TODO kb pub trait DiagnosticWithFix { - type AST; - fn fix_source(&self, db: &dyn AstDatabase) -> Option; + fn fix(&self, sema: &Semantics) -> Option<(Fix, TextRange)>; } impl DiagnosticWithFix for UnresolvedModule { - type AST = ast::Module; - fn fix_source(&self, db: &dyn AstDatabase) -> Option { - let root = db.parse_or_expand(self.file)?; - Some(self.decl.to_node(&root)) + fn fix(&self, sema: &Semantics) -> Option<(Fix, TextRange)> { + let fix = Fix::new( + "Create module", + FileSystemEdit::CreateFile { + anchor: self.file.original_file(sema.db), + dst: self.candidate.clone(), + } + .into(), + ); + + let root = sema.db.parse_or_expand(self.file)?; + let unresolved_module = self.decl.to_node(&root); + Some((fix, unresolved_module.syntax().text_range())) } } impl DiagnosticWithFix for NoSuchField { - type AST = ast::RecordExprField; - - fn fix_source(&self, db: &dyn AstDatabase) -> Option { - let root = db.parse_or_expand(self.file)?; - Some(self.field.to_node(&root)) + fn fix(&self, sema: &Semantics) -> Option<(Fix, TextRange)> { + let root = sema.db.parse_or_expand(self.file)?; + let record_expr_field = self.field.to_node(&root); + let fix = + missing_struct_field_fix(&sema, self.file.original_file(sema.db), &record_expr_field)?; + Some((fix, record_expr_field.syntax().text_range())) } } impl DiagnosticWithFix for MissingFields { - type AST = ast::RecordExpr; + fn fix(&self, sema: &Semantics) -> Option<(Fix, TextRange)> { + // Note that although we could add a diagnostics to + // fill the missing tuple field, e.g : + // `struct A(usize);` + // `let a = A { 0: () }` + // but it is uncommon usage and it should not be encouraged. + if self.missed_fields.iter().any(|it| it.as_tuple_index().is_some()) { + None + } else { + let root = sema.db.parse_or_expand(self.file)?; + let old_field_list = self.field_list_parent.to_node(&root).record_expr_field_list()?; + let mut new_field_list = old_field_list.clone(); + for f in self.missed_fields.iter() { + let field = make::record_expr_field( + make::name_ref(&f.to_string()), + Some(make::expr_unit()), + ); + new_field_list = new_field_list.append_field(&field); + } - fn fix_source(&self, db: &dyn AstDatabase) -> Option { - let root = db.parse_or_expand(self.file)?; - Some(self.field_list_parent.to_node(&root)) + let edit = { + let mut builder = TextEditBuilder::default(); + algo::diff(&old_field_list.syntax(), &new_field_list.syntax()) + .into_text_edit(&mut builder); + builder.finish() + }; + Some(( + Fix::new( + "Fill struct fields", + SourceFileEdit { file_id: self.file.original_file(sema.db), edit }.into(), + ), + sema.original_range(&old_field_list.syntax()).range, + // old_field_list.syntax().text_range(), + )) + } } } impl DiagnosticWithFix for MissingOkInTailExpr { - type AST = ast::Expr; - - fn fix_source(&self, db: &dyn AstDatabase) -> Option { - let root = db.parse_or_expand(self.file)?; - Some(self.expr.to_node(&root)) + fn fix(&self, sema: &Semantics) -> Option<(Fix, TextRange)> { + let root = sema.db.parse_or_expand(self.file)?; + let tail_expr = self.expr.to_node(&root); + let tail_expr_range = tail_expr.syntax().text_range(); + let edit = TextEdit::replace(tail_expr_range, format!("Ok({})", tail_expr.syntax())); + let source_change = + SourceFileEdit { file_id: self.file.original_file(sema.db), edit }.into(); + Some((Fix::new("Wrap with ok", source_change), tail_expr_range)) + } +} + +fn missing_struct_field_fix( + sema: &Semantics, + usage_file_id: FileId, + record_expr_field: &ast::RecordExprField, +) -> Option { + let record_lit = ast::RecordExpr::cast(record_expr_field.syntax().parent()?.parent()?)?; + let def_id = sema.resolve_variant(record_lit)?; + let module; + let def_file_id; + let record_fields = match VariantDef::from(def_id) { + VariantDef::Struct(s) => { + module = s.module(sema.db); + let source = s.source(sema.db); + def_file_id = source.file_id; + let fields = source.value.field_list()?; + record_field_list(fields)? + } + VariantDef::Union(u) => { + module = u.module(sema.db); + let source = u.source(sema.db); + def_file_id = source.file_id; + source.value.record_field_list()? + } + VariantDef::EnumVariant(e) => { + module = e.module(sema.db); + let source = e.source(sema.db); + def_file_id = source.file_id; + let fields = source.value.field_list()?; + record_field_list(fields)? + } + }; + let def_file_id = def_file_id.original_file(sema.db); + + let new_field_type = sema.type_of_expr(&record_expr_field.expr()?)?; + if new_field_type.is_unknown() { + return None; + } + let new_field = make::record_field( + record_expr_field.field_name()?, + make::ty(&new_field_type.display_source_code(sema.db, module.into()).ok()?), + ); + + let last_field = record_fields.fields().last()?; + let last_field_syntax = last_field.syntax(); + let indent = IndentLevel::from_node(last_field_syntax); + + let mut new_field = new_field.to_string(); + if usage_file_id != def_file_id { + new_field = format!("pub(crate) {}", new_field); + } + new_field = format!("\n{}{}", indent, new_field); + + let needs_comma = !last_field_syntax.to_string().ends_with(','); + if needs_comma { + new_field = format!(",{}", new_field); + } + + let source_change = SourceFileEdit { + file_id: def_file_id, + edit: TextEdit::insert(last_field_syntax.text_range().end(), new_field), + }; + let fix = Fix::new("Create field", source_change.into()); + return Some(fix); + + fn record_field_list(field_def_list: ast::FieldList) -> Option { + match field_def_list { + ast::FieldList::RecordFieldList(it) => Some(it), + ast::FieldList::TupleFieldList(_) => None, + } } } From 37aa68f050fae0079db7b6ebd81bacea4441fb7e Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 11 Aug 2020 15:08:55 +0300 Subject: [PATCH 052/119] Add rustdocs --- crates/ra_hir_expand/src/diagnostics.rs | 1 + crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/ra_hir_expand/src/diagnostics.rs b/crates/ra_hir_expand/src/diagnostics.rs index e58defa681..cc7dc3af22 100644 --- a/crates/ra_hir_expand/src/diagnostics.rs +++ b/crates/ra_hir_expand/src/diagnostics.rs @@ -22,6 +22,7 @@ use crate::InFile; pub trait Diagnostic: Any + Send + Sync + fmt::Debug + 'static { fn message(&self) -> String; + /// A presentation source of the diagnostics, to use in highlighting and similar actions fn presentation(&self) -> InFile; fn as_any(&self) -> &(dyn Any + Send + 'static); fn is_experimental(&self) -> bool { diff --git a/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs b/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs index 56d454ac61..1955e15210 100644 --- a/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs +++ b/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs @@ -1,3 +1,4 @@ +//! Provides a way to derive fixes based on the diagnostic data. use crate::Fix; use ast::{edit::IndentLevel, make}; use hir::{ @@ -13,8 +14,9 @@ use ra_ide_db::{ use ra_syntax::{algo, ast, AstNode, TextRange}; use ra_text_edit::{TextEdit, TextEditBuilder}; -// TODO kb +/// A trait to implement fot the Diagnostic that has a fix available. pub trait DiagnosticWithFix { + /// Provides a fix with the fix range, if applicable in the current semantics. fn fix(&self, sema: &Semantics) -> Option<(Fix, TextRange)>; } From 188ec3459e795732ad097758f7bf6b6b95bdbf5e Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 11 Aug 2020 17:13:40 +0300 Subject: [PATCH 053/119] Simplify fix structure --- crates/ra_ide/src/diagnostics.rs | 68 +++++------- .../src/diagnostics/diagnostics_with_fix.rs | 103 +++++++++--------- crates/ra_ide/src/lib.rs | 12 +- crates/rust-analyzer/src/handlers.rs | 7 +- 4 files changed, 93 insertions(+), 97 deletions(-) diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs index 165ff5249c..757b76fd40 100644 --- a/crates/ra_ide/src/diagnostics.rs +++ b/crates/ra_ide/src/diagnostics.rs @@ -6,10 +6,7 @@ use std::cell::RefCell; -use hir::{ - diagnostics::{Diagnostic as HirDiagnostics, DiagnosticSinkBuilder}, - Semantics, -}; +use hir::{diagnostics::DiagnosticSinkBuilder, Semantics}; use itertools::Itertools; use ra_db::SourceDatabase; use ra_ide_db::RootDatabase; @@ -73,7 +70,7 @@ pub(crate) fn diagnostics( .build(|d| { res.borrow_mut().push(Diagnostic { message: d.message(), - range: sema.diagnostics_presentation_range(d).range, + range: sema.diagnostics_display_range(d).range, severity: Severity::Error, fix: None, }) @@ -86,12 +83,9 @@ pub(crate) fn diagnostics( res.into_inner() } -fn diagnostic_with_fix( - d: &D, - sema: &Semantics, -) -> Diagnostic { +fn diagnostic_with_fix(d: &D, sema: &Semantics) -> Diagnostic { Diagnostic { - range: sema.diagnostics_presentation_range(d).range, + range: sema.diagnostics_display_range(d).range, message: d.message(), severity: Severity::Error, fix: d.fix(&sema), @@ -120,8 +114,9 @@ fn check_unnecessary_braces_in_use_statement( range: use_range, message: "Unnecessary braces in use statement".to_string(), severity: Severity::WeakWarning, - fix: Some(( - Fix::new("Remove unnecessary braces", SourceFileEdit { file_id, edit }.into()), + fix: Some(Fix::new( + "Remove unnecessary braces", + SourceFileEdit { file_id, edit }.into(), use_range, )), }); @@ -165,11 +160,9 @@ fn check_struct_shorthand_initialization( range: field_range, message: "Shorthand struct initialization".to_string(), severity: Severity::WeakWarning, - fix: Some(( - Fix::new( - "Use struct shorthand initialization", - SourceFileEdit { file_id, edit }.into(), - ), + fix: Some(Fix::new( + "Use struct shorthand initialization", + SourceFileEdit { file_id, edit }.into(), field_range, )), }); @@ -197,7 +190,7 @@ mod tests { let (analysis, file_position) = analysis_and_position(ra_fixture_before); let diagnostic = analysis.diagnostics(file_position.file_id, true).unwrap().pop().unwrap(); - let (mut fix, fix_range) = diagnostic.fix.unwrap(); + let mut fix = diagnostic.fix.unwrap(); let edit = fix.source_change.source_file_edits.pop().unwrap().edit; let target_file_contents = analysis.file_text(file_position.file_id).unwrap(); let actual = { @@ -208,9 +201,10 @@ mod tests { assert_eq_text!(&after, &actual); assert!( - fix_range.start() <= file_position.offset && fix_range.end() >= file_position.offset, + fix.fix_trigger_range.start() <= file_position.offset + && fix.fix_trigger_range.end() >= file_position.offset, "diagnostic fix range {:?} does not touch cursor position {:?}", - fix_range, + fix.fix_trigger_range, file_position.offset ); } @@ -222,7 +216,7 @@ mod tests { let (analysis, file_pos) = analysis_and_position(ra_fixture_before); let current_file_id = file_pos.file_id; let diagnostic = analysis.diagnostics(current_file_id, true).unwrap().pop().unwrap(); - let mut fix = diagnostic.fix.unwrap().0; + let mut fix = diagnostic.fix.unwrap(); let edit = fix.source_change.source_file_edits.pop().unwrap(); let changed_file_id = edit.file_id; let before = analysis.file_text(changed_file_id).unwrap(); @@ -513,24 +507,22 @@ fn test_fn() { range: 0..8, severity: Error, fix: Some( - ( - Fix { - label: "Create module", - source_change: SourceChange { - source_file_edits: [], - file_system_edits: [ - CreateFile { - anchor: FileId( - 1, - ), - dst: "foo.rs", - }, - ], - is_snippet: false, - }, + Fix { + label: "Create module", + source_change: SourceChange { + source_file_edits: [], + file_system_edits: [ + CreateFile { + anchor: FileId( + 1, + ), + dst: "foo.rs", + }, + ], + is_snippet: false, }, - 0..8, - ), + fix_trigger_range: 0..8, + }, ), }, ] diff --git a/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs b/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs index 1955e15210..57b54a61ed 100644 --- a/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs +++ b/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs @@ -1,9 +1,9 @@ -//! Provides a way to derive fixes based on the diagnostic data. +//! Provides a way to attach fix actions to the use crate::Fix; use ast::{edit::IndentLevel, make}; use hir::{ db::AstDatabase, - diagnostics::{MissingFields, MissingOkInTailExpr, NoSuchField, UnresolvedModule}, + diagnostics::{Diagnostic, MissingFields, MissingOkInTailExpr, NoSuchField, UnresolvedModule}, HasSource, HirDisplay, Semantics, VariantDef, }; use ra_db::FileId; @@ -11,94 +11,90 @@ use ra_ide_db::{ source_change::{FileSystemEdit, SourceFileEdit}, RootDatabase, }; -use ra_syntax::{algo, ast, AstNode, TextRange}; +use ra_syntax::{algo, ast, AstNode}; use ra_text_edit::{TextEdit, TextEditBuilder}; -/// A trait to implement fot the Diagnostic that has a fix available. -pub trait DiagnosticWithFix { - /// Provides a fix with the fix range, if applicable in the current semantics. - fn fix(&self, sema: &Semantics) -> Option<(Fix, TextRange)>; +/// A [Diagnostic] that potentially has a fix available. +/// +/// [Diagnostic]: hir::diagnostics::Diagnostic +pub trait DiagnosticWithFix: Diagnostic { + fn fix(&self, sema: &Semantics) -> Option; } impl DiagnosticWithFix for UnresolvedModule { - fn fix(&self, sema: &Semantics) -> Option<(Fix, TextRange)> { - let fix = Fix::new( + fn fix(&self, sema: &Semantics) -> Option { + let root = sema.db.parse_or_expand(self.file)?; + let unresolved_module = self.decl.to_node(&root); + Some(Fix::new( "Create module", FileSystemEdit::CreateFile { anchor: self.file.original_file(sema.db), dst: self.candidate.clone(), } .into(), - ); - - let root = sema.db.parse_or_expand(self.file)?; - let unresolved_module = self.decl.to_node(&root); - Some((fix, unresolved_module.syntax().text_range())) + unresolved_module.syntax().text_range(), + )) } } impl DiagnosticWithFix for NoSuchField { - fn fix(&self, sema: &Semantics) -> Option<(Fix, TextRange)> { + fn fix(&self, sema: &Semantics) -> Option { let root = sema.db.parse_or_expand(self.file)?; - let record_expr_field = self.field.to_node(&root); - let fix = - missing_struct_field_fix(&sema, self.file.original_file(sema.db), &record_expr_field)?; - Some((fix, record_expr_field.syntax().text_range())) + missing_record_expr_field_fix( + &sema, + self.file.original_file(sema.db), + &self.field.to_node(&root), + ) } } impl DiagnosticWithFix for MissingFields { - fn fix(&self, sema: &Semantics) -> Option<(Fix, TextRange)> { + fn fix(&self, sema: &Semantics) -> Option { // Note that although we could add a diagnostics to // fill the missing tuple field, e.g : // `struct A(usize);` // `let a = A { 0: () }` // but it is uncommon usage and it should not be encouraged. if self.missed_fields.iter().any(|it| it.as_tuple_index().is_some()) { - None - } else { - let root = sema.db.parse_or_expand(self.file)?; - let old_field_list = self.field_list_parent.to_node(&root).record_expr_field_list()?; - let mut new_field_list = old_field_list.clone(); - for f in self.missed_fields.iter() { - let field = make::record_expr_field( - make::name_ref(&f.to_string()), - Some(make::expr_unit()), - ); - new_field_list = new_field_list.append_field(&field); - } - - let edit = { - let mut builder = TextEditBuilder::default(); - algo::diff(&old_field_list.syntax(), &new_field_list.syntax()) - .into_text_edit(&mut builder); - builder.finish() - }; - Some(( - Fix::new( - "Fill struct fields", - SourceFileEdit { file_id: self.file.original_file(sema.db), edit }.into(), - ), - sema.original_range(&old_field_list.syntax()).range, - // old_field_list.syntax().text_range(), - )) + return None; } + + let root = sema.db.parse_or_expand(self.file)?; + let old_field_list = self.field_list_parent.to_node(&root).record_expr_field_list()?; + let mut new_field_list = old_field_list.clone(); + for f in self.missed_fields.iter() { + let field = + make::record_expr_field(make::name_ref(&f.to_string()), Some(make::expr_unit())); + new_field_list = new_field_list.append_field(&field); + } + + let edit = { + let mut builder = TextEditBuilder::default(); + algo::diff(&old_field_list.syntax(), &new_field_list.syntax()) + .into_text_edit(&mut builder); + builder.finish() + }; + Some(Fix::new( + "Fill struct fields", + SourceFileEdit { file_id: self.file.original_file(sema.db), edit }.into(), + sema.original_range(&old_field_list.syntax()).range, + )) } } impl DiagnosticWithFix for MissingOkInTailExpr { - fn fix(&self, sema: &Semantics) -> Option<(Fix, TextRange)> { + fn fix(&self, sema: &Semantics) -> Option { let root = sema.db.parse_or_expand(self.file)?; let tail_expr = self.expr.to_node(&root); let tail_expr_range = tail_expr.syntax().text_range(); let edit = TextEdit::replace(tail_expr_range, format!("Ok({})", tail_expr.syntax())); let source_change = SourceFileEdit { file_id: self.file.original_file(sema.db), edit }.into(); - Some((Fix::new("Wrap with ok", source_change), tail_expr_range)) + Some(Fix::new("Wrap with ok", source_change, tail_expr_range)) } } -fn missing_struct_field_fix( +fn missing_record_expr_field_fix( sema: &Semantics, usage_file_id: FileId, record_expr_field: &ast::RecordExprField, @@ -159,8 +155,11 @@ fn missing_struct_field_fix( file_id: def_file_id, edit: TextEdit::insert(last_field_syntax.text_range().end(), new_field), }; - let fix = Fix::new("Create field", source_change.into()); - return Some(fix); + return Some(Fix::new( + "Create field", + source_change.into(), + record_expr_field.syntax().text_range(), + )); fn record_field_list(field_def_list: ast::FieldList) -> Option { match field_def_list { diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs index 45a4b2421e..89fcb6f178 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ra_ide/src/lib.rs @@ -105,20 +105,26 @@ pub struct Diagnostic { pub message: String, pub range: TextRange, pub severity: Severity, - pub fix: Option<(Fix, TextRange)>, + pub fix: Option, } #[derive(Debug)] pub struct Fix { pub label: String, pub source_change: SourceChange, + /// Allows to trigger the fix only when the caret is in the range given + pub fix_trigger_range: TextRange, } impl Fix { - pub fn new(label: impl Into, source_change: SourceChange) -> Self { + pub fn new( + label: impl Into, + source_change: SourceChange, + fix_trigger_range: TextRange, + ) -> Self { let label = label.into(); assert!(label.starts_with(char::is_uppercase) && !label.ends_with('.')); - Self { label, source_change } + Self { label, source_change, fix_trigger_range } } } diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index 144c641b2a..785dd2a267 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs @@ -773,12 +773,11 @@ fn handle_fixes( let diagnostics = snap.analysis.diagnostics(file_id, snap.config.experimental_diagnostics)?; - let fixes_from_diagnostics = diagnostics + for fix in diagnostics .into_iter() .filter_map(|d| d.fix) - .filter(|(_fix, fix_range)| fix_range.intersect(range).is_some()) - .map(|(fix, _range)| fix); - for fix in fixes_from_diagnostics { + .filter(|fix| fix.fix_trigger_range.intersect(range).is_some()) + { let title = fix.label; let edit = to_proto::snippet_workspace_edit(&snap, fix.source_change)?; let action = lsp_ext::CodeAction { From db12ccee96bf37367b39ad99638d06da7123c088 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 11 Aug 2020 17:15:11 +0300 Subject: [PATCH 054/119] Better naming and docs --- crates/ra_hir/src/semantics.rs | 8 ++-- crates/ra_hir_def/src/diagnostics.rs | 2 +- crates/ra_hir_expand/src/diagnostics.rs | 4 +- crates/ra_hir_ty/src/diagnostics.rs | 39 ++++++++++--------- crates/ra_ide/src/diagnostics.rs | 2 +- .../src/diagnostics/diagnostics_with_fix.rs | 3 +- 6 files changed, 30 insertions(+), 28 deletions(-) diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs index 2dfe69039f..e3c417b41b 100644 --- a/crates/ra_hir/src/semantics.rs +++ b/crates/ra_hir/src/semantics.rs @@ -138,8 +138,8 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { self.imp.original_range(node) } - pub fn diagnostics_presentation_range(&self, diagnostics: &dyn Diagnostic) -> FileRange { - self.imp.diagnostics_presentation_range(diagnostics) + pub fn diagnostics_display_range(&self, diagnostics: &dyn Diagnostic) -> FileRange { + self.imp.diagnostics_display_range(diagnostics) } pub fn ancestors_with_macros(&self, node: SyntaxNode) -> impl Iterator + '_ { @@ -369,8 +369,8 @@ impl<'db> SemanticsImpl<'db> { original_range(self.db, node.as_ref()) } - fn diagnostics_presentation_range(&self, diagnostics: &dyn Diagnostic) -> FileRange { - let src = diagnostics.presentation(); + fn diagnostics_display_range(&self, diagnostics: &dyn Diagnostic) -> FileRange { + let src = diagnostics.display_source(); let root = self.db.parse_or_expand(src.file_id).unwrap(); let node = src.value.to_node(&root); self.cache(root, src.file_id); diff --git a/crates/ra_hir_def/src/diagnostics.rs b/crates/ra_hir_def/src/diagnostics.rs index 9435c72544..71d177070d 100644 --- a/crates/ra_hir_def/src/diagnostics.rs +++ b/crates/ra_hir_def/src/diagnostics.rs @@ -18,7 +18,7 @@ impl Diagnostic for UnresolvedModule { fn message(&self) -> String { "unresolved module".to_string() } - fn presentation(&self) -> InFile { + fn display_source(&self) -> InFile { InFile::new(self.file, self.decl.clone().into()) } fn as_any(&self) -> &(dyn Any + Send + 'static) { diff --git a/crates/ra_hir_expand/src/diagnostics.rs b/crates/ra_hir_expand/src/diagnostics.rs index cc7dc3af22..b138500e73 100644 --- a/crates/ra_hir_expand/src/diagnostics.rs +++ b/crates/ra_hir_expand/src/diagnostics.rs @@ -22,8 +22,8 @@ use crate::InFile; pub trait Diagnostic: Any + Send + Sync + fmt::Debug + 'static { fn message(&self) -> String; - /// A presentation source of the diagnostics, to use in highlighting and similar actions - fn presentation(&self) -> InFile; + /// Used in highlighting and related purposes + fn display_source(&self) -> InFile; fn as_any(&self) -> &(dyn Any + Send + 'static); fn is_experimental(&self) -> bool { false diff --git a/crates/ra_hir_ty/src/diagnostics.rs b/crates/ra_hir_ty/src/diagnostics.rs index 24435e8a71..7ab7f79db6 100644 --- a/crates/ra_hir_ty/src/diagnostics.rs +++ b/crates/ra_hir_ty/src/diagnostics.rs @@ -37,7 +37,7 @@ impl Diagnostic for NoSuchField { "no such field".to_string() } - fn presentation(&self) -> InFile { + fn display_source(&self) -> InFile { InFile::new(self.file, self.field.clone().into()) } @@ -63,7 +63,7 @@ impl Diagnostic for MissingFields { buf } - fn presentation(&self) -> InFile { + fn display_source(&self) -> InFile { InFile { file_id: self.file, value: self @@ -95,13 +95,15 @@ impl Diagnostic for MissingPatFields { } buf } - fn presentation(&self) -> InFile { - let value = self - .field_list_parent_path - .clone() - .map(SyntaxNodePtr::from) - .unwrap_or_else(|| self.field_list_parent.clone().into()); - InFile { file_id: self.file, value } + fn display_source(&self) -> InFile { + InFile { + file_id: self.file, + value: self + .field_list_parent_path + .clone() + .map(SyntaxNodePtr::from) + .unwrap_or_else(|| self.field_list_parent.clone().into()), + } } fn as_any(&self) -> &(dyn Any + Send + 'static) { self @@ -119,7 +121,7 @@ impl Diagnostic for MissingMatchArms { fn message(&self) -> String { String::from("Missing match arm") } - fn presentation(&self) -> InFile { + fn display_source(&self) -> InFile { InFile { file_id: self.file, value: self.match_expr.clone().into() } } fn as_any(&self) -> &(dyn Any + Send + 'static) { @@ -137,7 +139,7 @@ impl Diagnostic for MissingOkInTailExpr { fn message(&self) -> String { "wrap return expression in Ok".to_string() } - fn presentation(&self) -> InFile { + fn display_source(&self) -> InFile { InFile { file_id: self.file, value: self.expr.clone().into() } } fn as_any(&self) -> &(dyn Any + Send + 'static) { @@ -155,7 +157,7 @@ impl Diagnostic for BreakOutsideOfLoop { fn message(&self) -> String { "break outside of loop".to_string() } - fn presentation(&self) -> InFile { + fn display_source(&self) -> InFile { InFile { file_id: self.file, value: self.expr.clone().into() } } fn as_any(&self) -> &(dyn Any + Send + 'static) { @@ -173,7 +175,7 @@ impl Diagnostic for MissingUnsafe { fn message(&self) -> String { format!("This operation is unsafe and requires an unsafe function or block") } - fn presentation(&self) -> InFile { + fn display_source(&self) -> InFile { InFile { file_id: self.file, value: self.expr.clone().into() } } fn as_any(&self) -> &(dyn Any + Send + 'static) { @@ -194,7 +196,7 @@ impl Diagnostic for MismatchedArgCount { let s = if self.expected == 1 { "" } else { "s" }; format!("Expected {} argument{}, found {}", self.expected, s, self.found) } - fn presentation(&self) -> InFile { + fn display_source(&self) -> InFile { InFile { file_id: self.file, value: self.call_expr.clone().into() } } fn as_any(&self) -> &(dyn Any + Send + 'static) { @@ -256,12 +258,11 @@ mod tests { let mut actual: FxHashMap> = FxHashMap::default(); db.diagnostics(|d| { + let src = d.display_source(); + let root = db.parse_or_expand(src.file_id).unwrap(); // FIXME: macros... - let diagnostics_presentation = d.presentation(); - let root = db.parse_or_expand(diagnostics_presentation.file_id).unwrap(); - - let file_id = diagnostics_presentation.file_id.original_file(&db); - let range = diagnostics_presentation.value.to_node(&root).text_range(); + let file_id = src.file_id.original_file(&db); + let range = src.value.to_node(&root).text_range(); let message = d.message().to_owned(); actual.entry(file_id).or_default().push((range, message)); }); diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs index 757b76fd40..1046d7ab37 100644 --- a/crates/ra_ide/src/diagnostics.rs +++ b/crates/ra_ide/src/diagnostics.rs @@ -183,7 +183,7 @@ mod tests { /// Takes a multi-file input fixture with annotated cursor positions, /// and checks that: /// * a diagnostic is produced - /// * this diagnostic fix touches the input cursor position + /// * this diagnostic fix trigger range touches the input cursor position /// * that the contents of the file containing the cursor match `after` after the diagnostic fix is applied fn check_fix(ra_fixture_before: &str, ra_fixture_after: &str) { let after = trim_indent(ra_fixture_after); diff --git a/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs b/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs index 57b54a61ed..f7c73773f3 100644 --- a/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs +++ b/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs @@ -1,4 +1,5 @@ -//! Provides a way to attach fix actions to the +//! Provides a way to attach fixes to the diagnostics. +//! The same module also has all curret custom fixes for the diagnostics implemented. use crate::Fix; use ast::{edit::IndentLevel, make}; use hir::{ From 7543b06d301024d10b803f4c2bc269af9d481296 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 11 Aug 2020 22:33:17 +0300 Subject: [PATCH 055/119] Display snippet in the completion label --- crates/ra_ide/src/completion/complete_snippet.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/ra_ide/src/completion/complete_snippet.rs b/crates/ra_ide/src/completion/complete_snippet.rs index 28d8f78768..4368e4eec8 100644 --- a/crates/ra_ide/src/completion/complete_snippet.rs +++ b/crates/ra_ide/src/completion/complete_snippet.rs @@ -36,7 +36,7 @@ pub(super) fn complete_item_snippet(acc: &mut Completions, ctx: &CompletionConte snippet( ctx, cap, - "Test module", + "tmod (Test module)", "\ #[cfg(test)] mod tests { @@ -54,7 +54,7 @@ mod tests { snippet( ctx, cap, - "Test function", + "tfn (Test function)", "\ #[test] fn ${1:feature}() { @@ -106,10 +106,10 @@ mod tests { } "#, expect![[r#" - sn Test function - sn Test module sn macro_rules sn pub(crate) + sn tfn (Test function) + sn tmod (Test module) "#]], ) } From 8aba6bfef511acb2c5dc968bd75ef291c2ad3425 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 12 Aug 2020 10:14:08 +0200 Subject: [PATCH 056/119] Simplify --- crates/ra_parser/src/parser.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/ra_parser/src/parser.rs b/crates/ra_parser/src/parser.rs index d797f2cc96..d2487acc3b 100644 --- a/crates/ra_parser/src/parser.rs +++ b/crates/ra_parser/src/parser.rs @@ -269,8 +269,8 @@ impl Marker { pub(crate) fn complete(mut self, p: &mut Parser, kind: SyntaxKind) -> CompletedMarker { self.bomb.defuse(); let idx = self.pos as usize; - match p.events[idx] { - Event::Start { kind: ref mut slot, .. } => { + match &mut p.events[idx] { + Event::Start { kind: slot, .. } => { *slot = kind; } _ => unreachable!(), @@ -320,8 +320,8 @@ impl CompletedMarker { pub(crate) fn precede(self, p: &mut Parser) -> Marker { let new_pos = p.start(); let idx = self.start_pos as usize; - match p.events[idx] { - Event::Start { ref mut forward_parent, .. } => { + match &mut p.events[idx] { + Event::Start { forward_parent, .. } => { *forward_parent = Some(new_pos.pos - self.start_pos); } _ => unreachable!(), @@ -333,12 +333,12 @@ impl CompletedMarker { pub(crate) fn undo_completion(self, p: &mut Parser) -> Marker { let start_idx = self.start_pos as usize; let finish_idx = self.finish_pos as usize; - match p.events[start_idx] { - Event::Start { ref mut kind, forward_parent: None } => *kind = TOMBSTONE, + match &mut p.events[start_idx] { + Event::Start { kind, forward_parent: None } => *kind = TOMBSTONE, _ => unreachable!(), } - match p.events[finish_idx] { - ref mut slot @ Event::Finish => *slot = Event::tombstone(), + match &mut p.events[finish_idx] { + slot @ Event::Finish => *slot = Event::tombstone(), _ => unreachable!(), } Marker::new(self.start_pos) From 96001921fc1a00fe4f13dbe140e2df01430d11ea Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 12 Aug 2020 12:21:03 +0200 Subject: [PATCH 057/119] Minor --- crates/ra_hir/src/source_analyzer.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/crates/ra_hir/src/source_analyzer.rs b/crates/ra_hir/src/source_analyzer.rs index d0cb62ef01..d3d62debfd 100644 --- a/crates/ra_hir/src/source_analyzer.rs +++ b/crates/ra_hir/src/source_analyzer.rs @@ -265,8 +265,7 @@ impl SourceAnalyzer { } // This must be a normal source file rather than macro file. - let hir_path = - crate::Path::from_src(path.clone(), &Hygiene::new(db.upcast(), self.file_id))?; + let hir_path = Path::from_src(path.clone(), &Hygiene::new(db.upcast(), self.file_id))?; // Case where path is a qualifier of another path, e.g. foo::bar::Baz where we // trying to resolve foo::bar. @@ -451,7 +450,7 @@ fn adjust( pub(crate) fn resolve_hir_path( db: &dyn HirDatabase, resolver: &Resolver, - path: &crate::Path, + path: &Path, ) -> Option { let types = resolver.resolve_path_in_type_ns_fully(db.upcast(), path.mod_path()).map(|ty| match ty { @@ -512,7 +511,7 @@ pub(crate) fn resolve_hir_path( pub(crate) fn resolve_hir_path_qualifier( db: &dyn HirDatabase, resolver: &Resolver, - path: &crate::Path, + path: &Path, ) -> Option { let items = resolver .resolve_module_path_in_items(db.upcast(), path.mod_path()) From 67b2b3d0ce59fe082b442de30627c3386048eaca Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Wed, 12 Aug 2020 11:49:49 +0200 Subject: [PATCH 058/119] Fix build on musl and test it in CI --- .github/workflows/ci.yaml | 18 +++++++++++++----- Cargo.lock | 4 ++-- crates/ra_prof/src/memory_usage.rs | 2 +- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2acd440122..f977c88bee 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -88,11 +88,14 @@ jobs: if: matrix.os == 'windows-latest' run: Remove-Item ./target/debug/xtask.exe, ./target/debug/deps/xtask.exe - # Weird target to catch non-portable code - rust-power: - name: Rust Power + # Weird targets to catch non-portable code + rust-cross: + name: Rust Cross runs-on: ubuntu-latest + env: + targets: "powerpc-unknown-linux-gnu x86_64-unknown-linux-musl" + steps: - name: Checkout repository uses: actions/checkout@v2 @@ -103,7 +106,9 @@ jobs: toolchain: stable profile: minimal override: true - target: 'powerpc-unknown-linux-gnu' + + - name: Install Rust targets + run: rustup target add ${{ env.targets }} - name: Cache cargo directories uses: actions/cache@v2 @@ -114,7 +119,10 @@ jobs: key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Check - run: cargo check --target=powerpc-unknown-linux-gnu --all-targets + run: | + for target in ${{ env.targets }}; do + cargo check --target=$target --all-targets + done typescript: name: TypeScript diff --git a/Cargo.lock b/Cargo.lock index a094ec4f7a..2658891625 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -852,9 +852,9 @@ dependencies = [ [[package]] name = "perf-event-open-sys" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95db63e37862bc1b842135d2234ef9418f222cc660c6752f45e7cf9ddfb97f96" +checksum = "83e7183862f36d10263d0a1ccaef50fef734ade948bf026afd1bd97355c78273" dependencies = [ "libc", ] diff --git a/crates/ra_prof/src/memory_usage.rs b/crates/ra_prof/src/memory_usage.rs index c2ecbd33cf..83390212ae 100644 --- a/crates/ra_prof/src/memory_usage.rs +++ b/crates/ra_prof/src/memory_usage.rs @@ -24,7 +24,7 @@ impl std::ops::Sub for MemoryUsage { impl MemoryUsage { pub fn current() -> MemoryUsage { cfg_if! { - if #[cfg(target_os = "linux")] { + if #[cfg(all(target_os = "linux", target_env = "gnu"))] { // Note: This is incredibly slow. let alloc = unsafe { libc::mallinfo() }.uordblks as isize; MemoryUsage { allocated: Bytes(alloc) } From 49af51129b943784a3e6dbe33b05b6f683965b28 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 12 Aug 2020 12:45:38 +0200 Subject: [PATCH 059/119] Deny clippy --- crates/ra_parser/src/grammar/expressions.rs | 1 - xtask/tests/tidy.rs | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/crates/ra_parser/src/grammar/expressions.rs b/crates/ra_parser/src/grammar/expressions.rs index e1c25a838f..51eaf7af65 100644 --- a/crates/ra_parser/src/grammar/expressions.rs +++ b/crates/ra_parser/src/grammar/expressions.rs @@ -509,7 +509,6 @@ fn method_call_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { // x.1i32; // x.0x01; // } -#[allow(clippy::if_same_then_else)] fn field_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { assert!(p.at(T![.])); let m = lhs.precede(p); diff --git a/xtask/tests/tidy.rs b/xtask/tests/tidy.rs index d65a2acbca..ca23010213 100644 --- a/xtask/tests/tidy.rs +++ b/xtask/tests/tidy.rs @@ -44,11 +44,25 @@ fn rust_files_are_tidy() { let text = fs2::read_to_string(&path).unwrap(); check_todo(&path, &text); check_trailing_ws(&path, &text); + deny_clippy(&path, &text); tidy_docs.visit(&path, &text); } tidy_docs.finish(); } +fn deny_clippy(path: &PathBuf, text: &String) { + if text.contains("[\u{61}llow(clippy") { + panic!( + "\n\nallowing lints is forbidden: {}. +rust-analyzer intentionally doesn't check clippy on CI. +You can allow lint globally via `xtask clippy`. + +", + path.display() + ) + } +} + #[test] fn check_licenses() { let expected = " From c81e7a3a5936688cbe94c32f4e872ff36100def2 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 12 Aug 2020 13:03:43 +0200 Subject: [PATCH 060/119] Minor --- xtask/tests/tidy.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/xtask/tests/tidy.rs b/xtask/tests/tidy.rs index ca23010213..4ff72865e8 100644 --- a/xtask/tests/tidy.rs +++ b/xtask/tests/tidy.rs @@ -56,6 +56,7 @@ fn deny_clippy(path: &PathBuf, text: &String) { "\n\nallowing lints is forbidden: {}. rust-analyzer intentionally doesn't check clippy on CI. You can allow lint globally via `xtask clippy`. +See https://github.com/rust-lang/rust-clippy/issues/5537 for discussion. ", path.display() From fcd4b0176f1544b389c9b028c547a1dfc92f9a56 Mon Sep 17 00:00:00 2001 From: Igor Aleksanov Date: Wed, 12 Aug 2020 14:08:55 +0300 Subject: [PATCH 061/119] Revert style preference-related fixes --- crates/flycheck/src/lib.rs | 1 - crates/ra_arena/src/map.rs | 10 +++++----- .../ra_parser/src/grammar/expressions/atom.rs | 8 +++++--- crates/vfs/src/file_set.rs | 3 --- xtask/src/codegen/gen_syntax.rs | 20 ++++++++++--------- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/crates/flycheck/src/lib.rs b/crates/flycheck/src/lib.rs index ec769459c1..7c38f5ef9d 100644 --- a/crates/flycheck/src/lib.rs +++ b/crates/flycheck/src/lib.rs @@ -106,7 +106,6 @@ struct FlycheckActor { cargo_handle: Option, } -#[allow(clippy::large_enum_variant)] enum Event { Restart(Restart), CheckEvent(Option), diff --git a/crates/ra_arena/src/map.rs b/crates/ra_arena/src/map.rs index c1b58712c1..0f33907c0a 100644 --- a/crates/ra_arena/src/map.rs +++ b/crates/ra_arena/src/map.rs @@ -13,18 +13,18 @@ pub struct ArenaMap { impl ArenaMap, V> { pub fn insert(&mut self, id: Idx, t: V) { - let idx = Self::into_idx(id); + let idx = Self::to_idx(id); self.v.resize_with((idx + 1).max(self.v.len()), || None); self.v[idx] = Some(t); } pub fn get(&self, id: Idx) -> Option<&V> { - self.v.get(Self::into_idx(id)).and_then(|it| it.as_ref()) + self.v.get(Self::to_idx(id)).and_then(|it| it.as_ref()) } pub fn get_mut(&mut self, id: Idx) -> Option<&mut V> { - self.v.get_mut(Self::into_idx(id)).and_then(|it| it.as_mut()) + self.v.get_mut(Self::to_idx(id)).and_then(|it| it.as_mut()) } pub fn values(&self) -> impl Iterator { @@ -39,7 +39,7 @@ impl ArenaMap, V> { self.v.iter().enumerate().filter_map(|(idx, o)| Some((Self::from_idx(idx), o.as_ref()?))) } - fn into_idx(id: Idx) -> usize { + fn to_idx(id: Idx) -> usize { u32::from(id.into_raw()) as usize } @@ -51,7 +51,7 @@ impl ArenaMap, V> { impl std::ops::Index> for ArenaMap, T> { type Output = T; fn index(&self, id: Idx) -> &T { - self.v[Self::into_idx(id)].as_ref().unwrap() + self.v[Self::to_idx(id)].as_ref().unwrap() } } diff --git a/crates/ra_parser/src/grammar/expressions/atom.rs b/crates/ra_parser/src/grammar/expressions/atom.rs index ca6569c9f2..0b01d3bc64 100644 --- a/crates/ra_parser/src/grammar/expressions/atom.rs +++ b/crates/ra_parser/src/grammar/expressions/atom.rs @@ -243,10 +243,12 @@ fn lambda_expr(p: &mut Parser) -> CompletedMarker { // test lambda_ret_block // fn main() { || -> i32 { 92 }(); } block_expr(p); - } else if p.at_ts(EXPR_FIRST) { - expr(p); } else { - p.error("expected expression"); + if p.at_ts(EXPR_FIRST) { + expr(p); + } else { + p.error("expected expression"); + } } m.complete(p, CLOSURE_EXPR) } diff --git a/crates/vfs/src/file_set.rs b/crates/vfs/src/file_set.rs index 9f11268eee..e9196fcd2f 100644 --- a/crates/vfs/src/file_set.rs +++ b/crates/vfs/src/file_set.rs @@ -19,9 +19,6 @@ impl FileSet { pub fn len(&self) -> usize { self.files.len() } - pub fn is_empty(&self) -> bool { - self.len() == 0 - } pub fn resolve_path(&self, anchor: FileId, path: &str) -> Option { let mut base = self.paths[&anchor].clone(); base.pop(); diff --git a/xtask/src/codegen/gen_syntax.rs b/xtask/src/codegen/gen_syntax.rs index af9d63b06e..cafad8070d 100644 --- a/xtask/src/codegen/gen_syntax.rs +++ b/xtask/src/codegen/gen_syntax.rs @@ -91,16 +91,18 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: &AstSrc) -> Result { support::children(&self.syntax) } } - } else if let Some(token_kind) = field.token_kind() { - quote! { - pub fn #method_name(&self) -> Option<#ty> { - support::token(&self.syntax, #token_kind) - } - } } else { - quote! { - pub fn #method_name(&self) -> Option<#ty> { - support::child(&self.syntax) + if let Some(token_kind) = field.token_kind() { + quote! { + pub fn #method_name(&self) -> Option<#ty> { + support::token(&self.syntax, #token_kind) + } + } + } else { + quote! { + pub fn #method_name(&self) -> Option<#ty> { + support::child(&self.syntax) + } } } } From c9a42c7c46bd4f8828082c7d1cbab7384a2bca93 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 12 Aug 2020 13:56:58 +0200 Subject: [PATCH 062/119] Fix docs --- crates/ra_assists/src/handlers/apply_demorgan.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ra_assists/src/handlers/apply_demorgan.rs b/crates/ra_assists/src/handlers/apply_demorgan.rs index de701f8b83..3ac4aed7d2 100644 --- a/crates/ra_assists/src/handlers/apply_demorgan.rs +++ b/crates/ra_assists/src/handlers/apply_demorgan.rs @@ -4,7 +4,7 @@ use crate::{utils::invert_boolean_expression, AssistContext, AssistId, AssistKin // Assist: apply_demorgan // -// Apply [De Morgan's law](https://en.wikipedia.org/wiki/De_Morgan%27s_laws). +// Apply https://en.wikipedia.org/wiki/De_Morgan%27s_laws[De Morgan's law]. // This transforms expressions of the form `!l || !r` into `!(l && r)`. // This also works with `&&`. This assist can only be applied with the cursor // on either `||` or `&&`, with both operands being a negation of some kind. From f73a6419d43b21d07b7ee5d3804bdd586ee8036f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 12 Aug 2020 14:26:36 +0200 Subject: [PATCH 063/119] Allow default everywhere closes #5681 --- crates/ra_parser/src/grammar.rs | 2 +- crates/ra_parser/src/grammar/expressions.rs | 2 +- crates/ra_parser/src/grammar/items.rs | 50 ++-- crates/ra_parser/src/grammar/items/traits.rs | 4 +- .../parser/err/0043_default_const.rast | 40 ---- .../parser/err/0043_default_const.rs | 3 - .../inline/err/0014_default_fn_type.rast | 58 ----- .../parser/inline/err/0014_default_fn_type.rs | 4 - .../inline/ok/0132_default_fn_type.rast | 55 ----- .../parser/inline/ok/0132_default_fn_type.rs | 4 - .../inline/ok/0163_default_unsafe_fn.rast | 40 ---- .../inline/ok/0163_default_unsafe_impl.rast | 18 -- .../inline/ok/0163_default_unsafe_impl.rs | 1 - .../inline/ok/0163_default_unsafe_item.rast | 44 ++++ ...safe_fn.rs => 0163_default_unsafe_item.rs} | 2 +- .../parser/inline/ok/0164_default_item.rast | 24 ++ .../parser/inline/ok/0164_default_item.rs | 1 + .../parser/ok/0066_default_const.rast | 44 ---- .../test_data/parser/ok/0066_default_const.rs | 3 - .../parser/ok/0066_default_modifier.rast | 218 ++++++++++++++++++ .../parser/ok/0066_default_modifier.rs | 16 ++ 21 files changed, 326 insertions(+), 307 deletions(-) delete mode 100644 crates/ra_syntax/test_data/parser/err/0043_default_const.rast delete mode 100644 crates/ra_syntax/test_data/parser/err/0043_default_const.rs delete mode 100644 crates/ra_syntax/test_data/parser/inline/err/0014_default_fn_type.rast delete mode 100644 crates/ra_syntax/test_data/parser/inline/err/0014_default_fn_type.rs delete mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.rast delete mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.rs delete mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_fn.rast delete mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_impl.rast delete mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_impl.rs create mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_item.rast rename crates/ra_syntax/test_data/parser/inline/ok/{0163_default_unsafe_fn.rs => 0163_default_unsafe_item.rs} (50%) create mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0164_default_item.rast create mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0164_default_item.rs delete mode 100644 crates/ra_syntax/test_data/parser/ok/0066_default_const.rast delete mode 100644 crates/ra_syntax/test_data/parser/ok/0066_default_const.rs create mode 100644 crates/ra_syntax/test_data/parser/ok/0066_default_modifier.rast create mode 100644 crates/ra_syntax/test_data/parser/ok/0066_default_modifier.rs diff --git a/crates/ra_parser/src/grammar.rs b/crates/ra_parser/src/grammar.rs index c2e1d701e2..88468bc971 100644 --- a/crates/ra_parser/src/grammar.rs +++ b/crates/ra_parser/src/grammar.rs @@ -110,7 +110,7 @@ pub(crate) mod fragments { } pub(crate) fn item(p: &mut Parser) { - items::item_or_macro(p, true, items::ItemFlavor::Mod) + items::item_or_macro(p, true) } pub(crate) fn macro_items(p: &mut Parser) { diff --git a/crates/ra_parser/src/grammar/expressions.rs b/crates/ra_parser/src/grammar/expressions.rs index 51eaf7af65..3291e3f146 100644 --- a/crates/ra_parser/src/grammar/expressions.rs +++ b/crates/ra_parser/src/grammar/expressions.rs @@ -73,7 +73,7 @@ pub(super) fn stmt(p: &mut Parser, with_semi: StmtWithSemi) { // test block_items // fn a() { fn b() {} } - let m = match items::maybe_item(p, m, items::ItemFlavor::Mod) { + let m = match items::maybe_item(p, m) { Ok(()) => return, Err(m) => m, }; diff --git a/crates/ra_parser/src/grammar/items.rs b/crates/ra_parser/src/grammar/items.rs index cca524ceaa..9b76234345 100644 --- a/crates/ra_parser/src/grammar/items.rs +++ b/crates/ra_parser/src/grammar/items.rs @@ -22,24 +22,19 @@ use super::*; pub(super) fn mod_contents(p: &mut Parser, stop_on_r_curly: bool) { attributes::inner_attributes(p); while !(stop_on_r_curly && p.at(T!['}']) || p.at(EOF)) { - item_or_macro(p, stop_on_r_curly, ItemFlavor::Mod) + item_or_macro(p, stop_on_r_curly) } } -pub(super) enum ItemFlavor { - Mod, - Trait, -} - pub(super) const ITEM_RECOVERY_SET: TokenSet = token_set![ FN_KW, STRUCT_KW, ENUM_KW, IMPL_KW, TRAIT_KW, CONST_KW, STATIC_KW, LET_KW, MOD_KW, PUB_KW, CRATE_KW, USE_KW, MACRO_KW ]; -pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool, flavor: ItemFlavor) { +pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool) { let m = p.start(); attributes::outer_attributes(p); - let m = match maybe_item(p, m, flavor) { + let m = match maybe_item(p, m) { Ok(()) => { if p.at(T![;]) { p.err_and_bump( @@ -76,7 +71,7 @@ pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool, flavor: ItemF } } -pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Result<(), Marker> { +pub(super) fn maybe_item(p: &mut Parser, m: Marker) -> Result<(), Marker> { // test_err pub_expr // fn foo() { pub 92; } let has_visibility = opt_visibility(p); @@ -114,38 +109,29 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul has_mods = true; } - if p.at(IDENT) - && p.at_contextual_kw("default") - && (match p.nth(1) { - T![impl] => true, + // test default_item + // default impl T for Foo {} + if p.at(IDENT) && p.at_contextual_kw("default") { + match p.nth(1) { + T![fn] | T![type] | T![const] | T![impl] => { + p.bump_remap(T![default]); + has_mods = true; + } T![unsafe] => { - // test default_unsafe_impl - // default unsafe impl Foo {} - - // test default_unsafe_fn - // impl T for Foo { + // test default_unsafe_item + // default unsafe impl T for Foo { // default unsafe fn foo() {} // } - if p.nth(2) == T![impl] || p.nth(2) == T![fn] { + if matches!(p.nth(2), T![impl] | T![fn]) { p.bump_remap(T![default]); p.bump(T![unsafe]); has_mods = true; } - false } - T![fn] | T![type] | T![const] => { - if let ItemFlavor::Mod = flavor { - true - } else { - false - } - } - _ => false, - }) - { - p.bump_remap(T![default]); - has_mods = true; + _ => (), + } } + if p.at(IDENT) && p.at_contextual_kw("existential") && p.nth(1) == T![type] { p.bump_remap(T![existential]); has_mods = true; diff --git a/crates/ra_parser/src/grammar/items/traits.rs b/crates/ra_parser/src/grammar/items/traits.rs index ef9c8ff5b0..751ce65f2d 100644 --- a/crates/ra_parser/src/grammar/items/traits.rs +++ b/crates/ra_parser/src/grammar/items/traits.rs @@ -47,7 +47,7 @@ pub(crate) fn trait_item_list(p: &mut Parser) { error_block(p, "expected an item"); continue; } - item_or_macro(p, true, ItemFlavor::Trait); + item_or_macro(p, true); } p.expect(T!['}']); m.complete(p, ASSOC_ITEM_LIST); @@ -104,7 +104,7 @@ pub(crate) fn impl_item_list(p: &mut Parser) { error_block(p, "expected an item"); continue; } - item_or_macro(p, true, ItemFlavor::Mod); + item_or_macro(p, true); } p.expect(T!['}']); m.complete(p, ASSOC_ITEM_LIST); diff --git a/crates/ra_syntax/test_data/parser/err/0043_default_const.rast b/crates/ra_syntax/test_data/parser/err/0043_default_const.rast deleted file mode 100644 index 51ad2a846f..0000000000 --- a/crates/ra_syntax/test_data/parser/err/0043_default_const.rast +++ /dev/null @@ -1,40 +0,0 @@ -SOURCE_FILE@0..39 - TRAIT@0..38 - TRAIT_KW@0..5 "trait" - WHITESPACE@5..6 " " - NAME@6..7 - IDENT@6..7 "T" - WHITESPACE@7..8 " " - ASSOC_ITEM_LIST@8..38 - L_CURLY@8..9 "{" - WHITESPACE@9..12 "\n " - MACRO_CALL@12..19 - PATH@12..19 - PATH_SEGMENT@12..19 - NAME_REF@12..19 - IDENT@12..19 "default" - WHITESPACE@19..20 " " - CONST@20..36 - CONST_KW@20..25 "const" - WHITESPACE@25..26 " " - NAME@26..27 - IDENT@26..27 "f" - COLON@27..28 ":" - WHITESPACE@28..29 " " - PATH_TYPE@29..31 - PATH@29..31 - PATH_SEGMENT@29..31 - NAME_REF@29..31 - IDENT@29..31 "u8" - WHITESPACE@31..32 " " - EQ@32..33 "=" - WHITESPACE@33..34 " " - LITERAL@34..35 - INT_NUMBER@34..35 "0" - SEMICOLON@35..36 ";" - WHITESPACE@36..37 "\n" - R_CURLY@37..38 "}" - WHITESPACE@38..39 "\n" -error 19..19: expected BANG -error 19..19: expected `{`, `[`, `(` -error 19..19: expected SEMICOLON diff --git a/crates/ra_syntax/test_data/parser/err/0043_default_const.rs b/crates/ra_syntax/test_data/parser/err/0043_default_const.rs deleted file mode 100644 index 80f15474a5..0000000000 --- a/crates/ra_syntax/test_data/parser/err/0043_default_const.rs +++ /dev/null @@ -1,3 +0,0 @@ -trait T { - default const f: u8 = 0; -} diff --git a/crates/ra_syntax/test_data/parser/inline/err/0014_default_fn_type.rast b/crates/ra_syntax/test_data/parser/inline/err/0014_default_fn_type.rast deleted file mode 100644 index acd72094b9..0000000000 --- a/crates/ra_syntax/test_data/parser/inline/err/0014_default_fn_type.rast +++ /dev/null @@ -1,58 +0,0 @@ -SOURCE_FILE@0..62 - TRAIT@0..61 - TRAIT_KW@0..5 "trait" - WHITESPACE@5..6 " " - NAME@6..7 - IDENT@6..7 "T" - WHITESPACE@7..8 " " - ASSOC_ITEM_LIST@8..61 - L_CURLY@8..9 "{" - WHITESPACE@9..14 "\n " - MACRO_CALL@14..21 - PATH@14..21 - PATH_SEGMENT@14..21 - NAME_REF@14..21 - IDENT@14..21 "default" - WHITESPACE@21..22 " " - TYPE_ALIAS@22..35 - TYPE_KW@22..26 "type" - WHITESPACE@26..27 " " - NAME@27..28 - IDENT@27..28 "T" - WHITESPACE@28..29 " " - EQ@29..30 "=" - WHITESPACE@30..31 " " - PATH_TYPE@31..34 - PATH@31..34 - PATH_SEGMENT@31..34 - NAME_REF@31..34 - IDENT@31..34 "Bar" - SEMICOLON@34..35 ";" - WHITESPACE@35..40 "\n " - MACRO_CALL@40..47 - PATH@40..47 - PATH_SEGMENT@40..47 - NAME_REF@40..47 - IDENT@40..47 "default" - WHITESPACE@47..48 " " - FN@48..59 - FN_KW@48..50 "fn" - WHITESPACE@50..51 " " - NAME@51..54 - IDENT@51..54 "foo" - PARAM_LIST@54..56 - L_PAREN@54..55 "(" - R_PAREN@55..56 ")" - WHITESPACE@56..57 " " - BLOCK_EXPR@57..59 - L_CURLY@57..58 "{" - R_CURLY@58..59 "}" - WHITESPACE@59..60 "\n" - R_CURLY@60..61 "}" - WHITESPACE@61..62 "\n" -error 21..21: expected BANG -error 21..21: expected `{`, `[`, `(` -error 21..21: expected SEMICOLON -error 47..47: expected BANG -error 47..47: expected `{`, `[`, `(` -error 47..47: expected SEMICOLON diff --git a/crates/ra_syntax/test_data/parser/inline/err/0014_default_fn_type.rs b/crates/ra_syntax/test_data/parser/inline/err/0014_default_fn_type.rs deleted file mode 100644 index 15ba8f4a85..0000000000 --- a/crates/ra_syntax/test_data/parser/inline/err/0014_default_fn_type.rs +++ /dev/null @@ -1,4 +0,0 @@ -trait T { - default type T = Bar; - default fn foo() {} -} diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.rast b/crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.rast deleted file mode 100644 index b8d26a53a5..0000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.rast +++ /dev/null @@ -1,55 +0,0 @@ -SOURCE_FILE@0..69 - IMPL@0..68 - IMPL_KW@0..4 "impl" - WHITESPACE@4..5 " " - PATH_TYPE@5..6 - PATH@5..6 - PATH_SEGMENT@5..6 - NAME_REF@5..6 - IDENT@5..6 "T" - WHITESPACE@6..7 " " - FOR_KW@7..10 "for" - WHITESPACE@10..11 " " - PATH_TYPE@11..14 - PATH@11..14 - PATH_SEGMENT@11..14 - NAME_REF@11..14 - IDENT@11..14 "Foo" - WHITESPACE@14..15 " " - ASSOC_ITEM_LIST@15..68 - L_CURLY@15..16 "{" - WHITESPACE@16..21 "\n " - TYPE_ALIAS@21..42 - DEFAULT_KW@21..28 "default" - WHITESPACE@28..29 " " - TYPE_KW@29..33 "type" - WHITESPACE@33..34 " " - NAME@34..35 - IDENT@34..35 "T" - WHITESPACE@35..36 " " - EQ@36..37 "=" - WHITESPACE@37..38 " " - PATH_TYPE@38..41 - PATH@38..41 - PATH_SEGMENT@38..41 - NAME_REF@38..41 - IDENT@38..41 "Bar" - SEMICOLON@41..42 ";" - WHITESPACE@42..47 "\n " - FN@47..66 - DEFAULT_KW@47..54 "default" - WHITESPACE@54..55 " " - FN_KW@55..57 "fn" - WHITESPACE@57..58 " " - NAME@58..61 - IDENT@58..61 "foo" - PARAM_LIST@61..63 - L_PAREN@61..62 "(" - R_PAREN@62..63 ")" - WHITESPACE@63..64 " " - BLOCK_EXPR@64..66 - L_CURLY@64..65 "{" - R_CURLY@65..66 "}" - WHITESPACE@66..67 "\n" - R_CURLY@67..68 "}" - WHITESPACE@68..69 "\n" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.rs b/crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.rs deleted file mode 100644 index 8f5d611139..0000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0132_default_fn_type.rs +++ /dev/null @@ -1,4 +0,0 @@ -impl T for Foo { - default type T = Bar; - default fn foo() {} -} diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_fn.rast b/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_fn.rast deleted file mode 100644 index 1269621dc2..0000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_fn.rast +++ /dev/null @@ -1,40 +0,0 @@ -SOURCE_FILE@0..50 - IMPL@0..49 - IMPL_KW@0..4 "impl" - WHITESPACE@4..5 " " - PATH_TYPE@5..6 - PATH@5..6 - PATH_SEGMENT@5..6 - NAME_REF@5..6 - IDENT@5..6 "T" - WHITESPACE@6..7 " " - FOR_KW@7..10 "for" - WHITESPACE@10..11 " " - PATH_TYPE@11..14 - PATH@11..14 - PATH_SEGMENT@11..14 - NAME_REF@11..14 - IDENT@11..14 "Foo" - WHITESPACE@14..15 " " - ASSOC_ITEM_LIST@15..49 - L_CURLY@15..16 "{" - WHITESPACE@16..21 "\n " - FN@21..47 - DEFAULT_KW@21..28 "default" - WHITESPACE@28..29 " " - UNSAFE_KW@29..35 "unsafe" - WHITESPACE@35..36 " " - FN_KW@36..38 "fn" - WHITESPACE@38..39 " " - NAME@39..42 - IDENT@39..42 "foo" - PARAM_LIST@42..44 - L_PAREN@42..43 "(" - R_PAREN@43..44 ")" - WHITESPACE@44..45 " " - BLOCK_EXPR@45..47 - L_CURLY@45..46 "{" - R_CURLY@46..47 "}" - WHITESPACE@47..48 "\n" - R_CURLY@48..49 "}" - WHITESPACE@49..50 "\n" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_impl.rast b/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_impl.rast deleted file mode 100644 index 6bfe925af2..0000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_impl.rast +++ /dev/null @@ -1,18 +0,0 @@ -SOURCE_FILE@0..27 - IMPL@0..26 - DEFAULT_KW@0..7 "default" - WHITESPACE@7..8 " " - UNSAFE_KW@8..14 "unsafe" - WHITESPACE@14..15 " " - IMPL_KW@15..19 "impl" - WHITESPACE@19..20 " " - PATH_TYPE@20..23 - PATH@20..23 - PATH_SEGMENT@20..23 - NAME_REF@20..23 - IDENT@20..23 "Foo" - WHITESPACE@23..24 " " - ASSOC_ITEM_LIST@24..26 - L_CURLY@24..25 "{" - R_CURLY@25..26 "}" - WHITESPACE@26..27 "\n" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_impl.rs b/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_impl.rs deleted file mode 100644 index ba0998ff4d..0000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_impl.rs +++ /dev/null @@ -1 +0,0 @@ -default unsafe impl Foo {} diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_item.rast b/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_item.rast new file mode 100644 index 0000000000..f2e2014605 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_item.rast @@ -0,0 +1,44 @@ +SOURCE_FILE@0..65 + IMPL@0..64 + DEFAULT_KW@0..7 "default" + WHITESPACE@7..8 " " + UNSAFE_KW@8..14 "unsafe" + WHITESPACE@14..15 " " + IMPL_KW@15..19 "impl" + WHITESPACE@19..20 " " + PATH_TYPE@20..21 + PATH@20..21 + PATH_SEGMENT@20..21 + NAME_REF@20..21 + IDENT@20..21 "T" + WHITESPACE@21..22 " " + FOR_KW@22..25 "for" + WHITESPACE@25..26 " " + PATH_TYPE@26..29 + PATH@26..29 + PATH_SEGMENT@26..29 + NAME_REF@26..29 + IDENT@26..29 "Foo" + WHITESPACE@29..30 " " + ASSOC_ITEM_LIST@30..64 + L_CURLY@30..31 "{" + WHITESPACE@31..36 "\n " + FN@36..62 + DEFAULT_KW@36..43 "default" + WHITESPACE@43..44 " " + UNSAFE_KW@44..50 "unsafe" + WHITESPACE@50..51 " " + FN_KW@51..53 "fn" + WHITESPACE@53..54 " " + NAME@54..57 + IDENT@54..57 "foo" + PARAM_LIST@57..59 + L_PAREN@57..58 "(" + R_PAREN@58..59 ")" + WHITESPACE@59..60 " " + BLOCK_EXPR@60..62 + L_CURLY@60..61 "{" + R_CURLY@61..62 "}" + WHITESPACE@62..63 "\n" + R_CURLY@63..64 "}" + WHITESPACE@64..65 "\n" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_fn.rs b/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_item.rs similarity index 50% rename from crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_fn.rs rename to crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_item.rs index 12926cd8a1..96340f84ab 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_fn.rs +++ b/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_item.rs @@ -1,3 +1,3 @@ -impl T for Foo { +default unsafe impl T for Foo { default unsafe fn foo() {} } diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0164_default_item.rast b/crates/ra_syntax/test_data/parser/inline/ok/0164_default_item.rast new file mode 100644 index 0000000000..9282772f34 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0164_default_item.rast @@ -0,0 +1,24 @@ +SOURCE_FILE@0..26 + IMPL@0..25 + DEFAULT_KW@0..7 "default" + WHITESPACE@7..8 " " + IMPL_KW@8..12 "impl" + WHITESPACE@12..13 " " + PATH_TYPE@13..14 + PATH@13..14 + PATH_SEGMENT@13..14 + NAME_REF@13..14 + IDENT@13..14 "T" + WHITESPACE@14..15 " " + FOR_KW@15..18 "for" + WHITESPACE@18..19 " " + PATH_TYPE@19..22 + PATH@19..22 + PATH_SEGMENT@19..22 + NAME_REF@19..22 + IDENT@19..22 "Foo" + WHITESPACE@22..23 " " + ASSOC_ITEM_LIST@23..25 + L_CURLY@23..24 "{" + R_CURLY@24..25 "}" + WHITESPACE@25..26 "\n" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0164_default_item.rs b/crates/ra_syntax/test_data/parser/inline/ok/0164_default_item.rs new file mode 100644 index 0000000000..a6836cbd57 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0164_default_item.rs @@ -0,0 +1 @@ +default impl T for Foo {} diff --git a/crates/ra_syntax/test_data/parser/ok/0066_default_const.rast b/crates/ra_syntax/test_data/parser/ok/0066_default_const.rast deleted file mode 100644 index 6246a31a66..0000000000 --- a/crates/ra_syntax/test_data/parser/ok/0066_default_const.rast +++ /dev/null @@ -1,44 +0,0 @@ -SOURCE_FILE@0..46 - IMPL@0..45 - IMPL_KW@0..4 "impl" - WHITESPACE@4..5 " " - PATH_TYPE@5..6 - PATH@5..6 - PATH_SEGMENT@5..6 - NAME_REF@5..6 - IDENT@5..6 "T" - WHITESPACE@6..7 " " - FOR_KW@7..10 "for" - WHITESPACE@10..11 " " - PATH_TYPE@11..14 - PATH@11..14 - PATH_SEGMENT@11..14 - NAME_REF@11..14 - IDENT@11..14 "Foo" - WHITESPACE@14..15 " " - ASSOC_ITEM_LIST@15..45 - L_CURLY@15..16 "{" - WHITESPACE@16..19 "\n " - CONST@19..43 - DEFAULT_KW@19..26 "default" - WHITESPACE@26..27 " " - CONST_KW@27..32 "const" - WHITESPACE@32..33 " " - NAME@33..34 - IDENT@33..34 "f" - COLON@34..35 ":" - WHITESPACE@35..36 " " - PATH_TYPE@36..38 - PATH@36..38 - PATH_SEGMENT@36..38 - NAME_REF@36..38 - IDENT@36..38 "u8" - WHITESPACE@38..39 " " - EQ@39..40 "=" - WHITESPACE@40..41 " " - LITERAL@41..42 - INT_NUMBER@41..42 "0" - SEMICOLON@42..43 ";" - WHITESPACE@43..44 "\n" - R_CURLY@44..45 "}" - WHITESPACE@45..46 "\n" diff --git a/crates/ra_syntax/test_data/parser/ok/0066_default_const.rs b/crates/ra_syntax/test_data/parser/ok/0066_default_const.rs deleted file mode 100644 index dfb3b92dca..0000000000 --- a/crates/ra_syntax/test_data/parser/ok/0066_default_const.rs +++ /dev/null @@ -1,3 +0,0 @@ -impl T for Foo { - default const f: u8 = 0; -} diff --git a/crates/ra_syntax/test_data/parser/ok/0066_default_modifier.rast b/crates/ra_syntax/test_data/parser/ok/0066_default_modifier.rast new file mode 100644 index 0000000000..e9b57ec3b3 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/ok/0066_default_modifier.rast @@ -0,0 +1,218 @@ +SOURCE_FILE@0..294 + TRAIT@0..113 + TRAIT_KW@0..5 "trait" + WHITESPACE@5..6 " " + NAME@6..7 + IDENT@6..7 "T" + WHITESPACE@7..8 " " + ASSOC_ITEM_LIST@8..113 + L_CURLY@8..9 "{" + WHITESPACE@9..12 "\n " + TYPE_ALIAS@12..33 + DEFAULT_KW@12..19 "default" + WHITESPACE@19..20 " " + TYPE_KW@20..24 "type" + WHITESPACE@24..25 " " + NAME@25..26 + IDENT@25..26 "T" + WHITESPACE@26..27 " " + EQ@27..28 "=" + WHITESPACE@28..29 " " + PATH_TYPE@29..32 + PATH@29..32 + PATH_SEGMENT@29..32 + NAME_REF@29..32 + IDENT@29..32 "Bar" + SEMICOLON@32..33 ";" + WHITESPACE@33..36 "\n " + CONST@36..60 + DEFAULT_KW@36..43 "default" + WHITESPACE@43..44 " " + CONST_KW@44..49 "const" + WHITESPACE@49..50 " " + NAME@50..51 + IDENT@50..51 "f" + COLON@51..52 ":" + WHITESPACE@52..53 " " + PATH_TYPE@53..55 + PATH@53..55 + PATH_SEGMENT@53..55 + NAME_REF@53..55 + IDENT@53..55 "u8" + WHITESPACE@55..56 " " + EQ@56..57 "=" + WHITESPACE@57..58 " " + LITERAL@58..59 + INT_NUMBER@58..59 "0" + SEMICOLON@59..60 ";" + WHITESPACE@60..63 "\n " + FN@63..82 + DEFAULT_KW@63..70 "default" + WHITESPACE@70..71 " " + FN_KW@71..73 "fn" + WHITESPACE@73..74 " " + NAME@74..77 + IDENT@74..77 "foo" + PARAM_LIST@77..79 + L_PAREN@77..78 "(" + R_PAREN@78..79 ")" + WHITESPACE@79..80 " " + BLOCK_EXPR@80..82 + L_CURLY@80..81 "{" + R_CURLY@81..82 "}" + WHITESPACE@82..85 "\n " + FN@85..111 + DEFAULT_KW@85..92 "default" + WHITESPACE@92..93 " " + UNSAFE_KW@93..99 "unsafe" + WHITESPACE@99..100 " " + FN_KW@100..102 "fn" + WHITESPACE@102..103 " " + NAME@103..106 + IDENT@103..106 "bar" + PARAM_LIST@106..108 + L_PAREN@106..107 "(" + R_PAREN@107..108 ")" + WHITESPACE@108..109 " " + BLOCK_EXPR@109..111 + L_CURLY@109..110 "{" + R_CURLY@110..111 "}" + WHITESPACE@111..112 "\n" + R_CURLY@112..113 "}" + WHITESPACE@113..115 "\n\n" + IMPL@115..235 + IMPL_KW@115..119 "impl" + WHITESPACE@119..120 " " + PATH_TYPE@120..121 + PATH@120..121 + PATH_SEGMENT@120..121 + NAME_REF@120..121 + IDENT@120..121 "T" + WHITESPACE@121..122 " " + FOR_KW@122..125 "for" + WHITESPACE@125..126 " " + PATH_TYPE@126..129 + PATH@126..129 + PATH_SEGMENT@126..129 + NAME_REF@126..129 + IDENT@126..129 "Foo" + WHITESPACE@129..130 " " + ASSOC_ITEM_LIST@130..235 + L_CURLY@130..131 "{" + WHITESPACE@131..134 "\n " + TYPE_ALIAS@134..155 + DEFAULT_KW@134..141 "default" + WHITESPACE@141..142 " " + TYPE_KW@142..146 "type" + WHITESPACE@146..147 " " + NAME@147..148 + IDENT@147..148 "T" + WHITESPACE@148..149 " " + EQ@149..150 "=" + WHITESPACE@150..151 " " + PATH_TYPE@151..154 + PATH@151..154 + PATH_SEGMENT@151..154 + NAME_REF@151..154 + IDENT@151..154 "Bar" + SEMICOLON@154..155 ";" + WHITESPACE@155..158 "\n " + CONST@158..182 + DEFAULT_KW@158..165 "default" + WHITESPACE@165..166 " " + CONST_KW@166..171 "const" + WHITESPACE@171..172 " " + NAME@172..173 + IDENT@172..173 "f" + COLON@173..174 ":" + WHITESPACE@174..175 " " + PATH_TYPE@175..177 + PATH@175..177 + PATH_SEGMENT@175..177 + NAME_REF@175..177 + IDENT@175..177 "u8" + WHITESPACE@177..178 " " + EQ@178..179 "=" + WHITESPACE@179..180 " " + LITERAL@180..181 + INT_NUMBER@180..181 "0" + SEMICOLON@181..182 ";" + WHITESPACE@182..185 "\n " + FN@185..204 + DEFAULT_KW@185..192 "default" + WHITESPACE@192..193 " " + FN_KW@193..195 "fn" + WHITESPACE@195..196 " " + NAME@196..199 + IDENT@196..199 "foo" + PARAM_LIST@199..201 + L_PAREN@199..200 "(" + R_PAREN@200..201 ")" + WHITESPACE@201..202 " " + BLOCK_EXPR@202..204 + L_CURLY@202..203 "{" + R_CURLY@203..204 "}" + WHITESPACE@204..207 "\n " + FN@207..233 + DEFAULT_KW@207..214 "default" + WHITESPACE@214..215 " " + UNSAFE_KW@215..221 "unsafe" + WHITESPACE@221..222 " " + FN_KW@222..224 "fn" + WHITESPACE@224..225 " " + NAME@225..228 + IDENT@225..228 "bar" + PARAM_LIST@228..230 + L_PAREN@228..229 "(" + R_PAREN@229..230 ")" + WHITESPACE@230..231 " " + BLOCK_EXPR@231..233 + L_CURLY@231..232 "{" + R_CURLY@232..233 "}" + WHITESPACE@233..234 "\n" + R_CURLY@234..235 "}" + WHITESPACE@235..237 "\n\n" + IMPL@237..261 + DEFAULT_KW@237..244 "default" + WHITESPACE@244..245 " " + IMPL_KW@245..249 "impl" + WHITESPACE@249..250 " " + PATH_TYPE@250..251 + PATH@250..251 + PATH_SEGMENT@250..251 + NAME_REF@250..251 + IDENT@250..251 "T" + WHITESPACE@251..252 " " + FOR_KW@252..255 "for" + WHITESPACE@255..256 " " + TUPLE_TYPE@256..258 + L_PAREN@256..257 "(" + R_PAREN@257..258 ")" + WHITESPACE@258..259 " " + ASSOC_ITEM_LIST@259..261 + L_CURLY@259..260 "{" + R_CURLY@260..261 "}" + WHITESPACE@261..262 "\n" + IMPL@262..293 + DEFAULT_KW@262..269 "default" + WHITESPACE@269..270 " " + UNSAFE_KW@270..276 "unsafe" + WHITESPACE@276..277 " " + IMPL_KW@277..281 "impl" + WHITESPACE@281..282 " " + PATH_TYPE@282..283 + PATH@282..283 + PATH_SEGMENT@282..283 + NAME_REF@282..283 + IDENT@282..283 "T" + WHITESPACE@283..284 " " + FOR_KW@284..287 "for" + WHITESPACE@287..288 " " + TUPLE_TYPE@288..290 + L_PAREN@288..289 "(" + R_PAREN@289..290 ")" + WHITESPACE@290..291 " " + ASSOC_ITEM_LIST@291..293 + L_CURLY@291..292 "{" + R_CURLY@292..293 "}" + WHITESPACE@293..294 "\n" diff --git a/crates/ra_syntax/test_data/parser/ok/0066_default_modifier.rs b/crates/ra_syntax/test_data/parser/ok/0066_default_modifier.rs new file mode 100644 index 0000000000..e443e3495e --- /dev/null +++ b/crates/ra_syntax/test_data/parser/ok/0066_default_modifier.rs @@ -0,0 +1,16 @@ +trait T { + default type T = Bar; + default const f: u8 = 0; + default fn foo() {} + default unsafe fn bar() {} +} + +impl T for Foo { + default type T = Bar; + default const f: u8 = 0; + default fn foo() {} + default unsafe fn bar() {} +} + +default impl T for () {} +default unsafe impl T for () {} From f8bfd77e84e5b51dc28ff219e99fdfd6fd9f92c2 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 12 Aug 2020 14:52:37 +0200 Subject: [PATCH 064/119] Cleanup parser modifiers tests --- crates/ra_parser/src/grammar/items.rs | 62 +---- ...ird_blocks.rast => 0043_weird_blocks.rast} | 0 ...3_weird_blocks.rs => 0043_weird_blocks.rs} | 0 .../0045_item_modifiers.rast} | 0 .../0045_item_modifiers.rs} | 0 .../parser/inline/ok/0016_unsafe_trait.rast | 13 -- .../parser/inline/ok/0016_unsafe_trait.rs | 1 - .../inline/ok/0036_unsafe_extern_fn.rast | 21 -- .../parser/inline/ok/0036_unsafe_extern_fn.rs | 1 - .../inline/ok/0047_unsafe_default_impl.rast | 18 -- .../inline/ok/0047_unsafe_default_impl.rs | 1 - .../parser/inline/ok/0057_const_fn.rast | 16 -- .../parser/inline/ok/0057_const_fn.rs | 1 - .../parser/inline/ok/0087_unsafe_impl.rast | 16 -- .../parser/inline/ok/0087_unsafe_impl.rs | 1 - .../parser/inline/ok/0089_extern_fn.rast | 17 -- .../parser/inline/ok/0089_extern_fn.rs | 1 - .../parser/inline/ok/0091_auto_trait.rast | 13 -- .../parser/inline/ok/0091_auto_trait.rs | 1 - .../inline/ok/0094_unsafe_auto_trait.rast | 15 -- .../inline/ok/0094_unsafe_auto_trait.rs | 1 - .../parser/inline/ok/0097_default_impl.rast | 16 -- .../parser/inline/ok/0097_default_impl.rs | 1 - .../inline/ok/0098_const_unsafe_fn.rast | 18 -- .../parser/inline/ok/0098_const_unsafe_fn.rs | 1 - .../parser/inline/ok/0101_unsafe_fn.rast | 16 -- .../parser/inline/ok/0101_unsafe_fn.rs | 1 - .../parser/inline/ok/0124_async_fn.rast | 16 -- .../parser/inline/ok/0124_async_fn.rs | 1 - .../parser/inline/ok/0128_combined_fns.rast | 35 --- .../parser/inline/ok/0128_combined_fns.rs | 2 - .../test_data/parser/inline/ok/0151_fn.rast | 14 ++ .../test_data/parser/inline/ok/0151_fn.rs | 1 + .../test_data/parser/inline/ok/0152_impl.rast | 22 ++ .../test_data/parser/inline/ok/0152_impl.rs | 1 + .../parser/inline/ok/0153_trait.rast | 11 + .../test_data/parser/inline/ok/0153_trait.rs | 1 + .../test_data/parser/ok/0021_extern_fn.rast | 56 ----- .../test_data/parser/ok/0021_extern_fn.rs | 8 - .../parser/ok/0068_item_modifiers.rast | 218 ++++++++++++++++++ .../parser/ok/0068_item_modifiers.rs | 16 ++ 41 files changed, 292 insertions(+), 362 deletions(-) rename crates/ra_syntax/test_data/parser/err/{0163_weird_blocks.rast => 0043_weird_blocks.rast} (100%) rename crates/ra_syntax/test_data/parser/err/{0163_weird_blocks.rs => 0043_weird_blocks.rs} (100%) rename crates/ra_syntax/test_data/parser/{inline/err/0010_wrong_order_fns.rast => err/0045_item_modifiers.rast} (100%) rename crates/ra_syntax/test_data/parser/{inline/err/0010_wrong_order_fns.rs => err/0045_item_modifiers.rs} (100%) delete mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0016_unsafe_trait.rast delete mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0016_unsafe_trait.rs delete mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0036_unsafe_extern_fn.rast delete mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0036_unsafe_extern_fn.rs delete mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.rast delete mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.rs delete mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0057_const_fn.rast delete mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0057_const_fn.rs delete mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.rast delete mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.rs delete mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0089_extern_fn.rast delete mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0089_extern_fn.rs delete mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0091_auto_trait.rast delete mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0091_auto_trait.rs delete mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0094_unsafe_auto_trait.rast delete mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0094_unsafe_auto_trait.rs delete mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.rast delete mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.rs delete mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0098_const_unsafe_fn.rast delete mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0098_const_unsafe_fn.rs delete mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0101_unsafe_fn.rast delete mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0101_unsafe_fn.rs delete mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0124_async_fn.rast delete mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0124_async_fn.rs delete mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.rast delete mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.rs create mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0151_fn.rast create mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0151_fn.rs create mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0152_impl.rast create mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0152_impl.rs create mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0153_trait.rast create mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0153_trait.rs delete mode 100644 crates/ra_syntax/test_data/parser/ok/0021_extern_fn.rast delete mode 100644 crates/ra_syntax/test_data/parser/ok/0021_extern_fn.rs create mode 100644 crates/ra_syntax/test_data/parser/ok/0068_item_modifiers.rast create mode 100644 crates/ra_syntax/test_data/parser/ok/0068_item_modifiers.rs diff --git a/crates/ra_parser/src/grammar/items.rs b/crates/ra_parser/src/grammar/items.rs index 9b76234345..d091b0fbb2 100644 --- a/crates/ra_parser/src/grammar/items.rs +++ b/crates/ra_parser/src/grammar/items.rs @@ -132,6 +132,8 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker) -> Result<(), Marker> { } } + // test existential_type + // existential type Foo: Fn() -> usize; if p.at(IDENT) && p.at_contextual_kw("existential") && p.nth(1) == T![type] { p.bump_remap(T![existential]); has_mods = true; @@ -139,79 +141,31 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker) -> Result<(), Marker> { // items match p.current() { - // test async_fn - // async fn foo() {} - - // test extern_fn - // extern fn foo() {} - - // test const_fn - // const fn foo() {} - - // test const_unsafe_fn - // const unsafe fn foo() {} - - // test unsafe_extern_fn - // unsafe extern "C" fn foo() {} - - // test unsafe_fn - // unsafe fn foo() {} - - // test combined_fns - // async unsafe fn foo() {} - // const unsafe fn bar() {} - - // test_err wrong_order_fns - // unsafe async fn foo() {} - // unsafe const fn bar() {} + // test fn + // fn foo() {} T![fn] => { fn_def(p); m.complete(p, FN); } - // test unsafe_trait - // unsafe trait T {} - - // test auto_trait - // auto trait T {} - - // test unsafe_auto_trait - // unsafe auto trait T {} + // test trait + // trait T {} T![trait] => { traits::trait_def(p); m.complete(p, TRAIT); } - // test unsafe_impl - // unsafe impl Foo {} - - // test default_impl - // default impl Foo {} - - // test_err default_fn_type - // trait T { - // default type T = Bar; - // default fn foo() {} - // } - - // test default_fn_type - // impl T for Foo { - // default type T = Bar; - // default fn foo() {} - // } T![const] => { consts::const_def(p, m); } - // test unsafe_default_impl - // unsafe default impl Foo {} + // test impl + // impl T for S {} T![impl] => { traits::impl_def(p); m.complete(p, IMPL); } - // test existential_type - // existential type Foo: Fn() -> usize; T![type] => { type_def(p, m); } diff --git a/crates/ra_syntax/test_data/parser/err/0163_weird_blocks.rast b/crates/ra_syntax/test_data/parser/err/0043_weird_blocks.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0163_weird_blocks.rast rename to crates/ra_syntax/test_data/parser/err/0043_weird_blocks.rast diff --git a/crates/ra_syntax/test_data/parser/err/0163_weird_blocks.rs b/crates/ra_syntax/test_data/parser/err/0043_weird_blocks.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0163_weird_blocks.rs rename to crates/ra_syntax/test_data/parser/err/0043_weird_blocks.rs diff --git a/crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.rast b/crates/ra_syntax/test_data/parser/err/0045_item_modifiers.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.rast rename to crates/ra_syntax/test_data/parser/err/0045_item_modifiers.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.rs b/crates/ra_syntax/test_data/parser/err/0045_item_modifiers.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.rs rename to crates/ra_syntax/test_data/parser/err/0045_item_modifiers.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0016_unsafe_trait.rast b/crates/ra_syntax/test_data/parser/inline/ok/0016_unsafe_trait.rast deleted file mode 100644 index 625ab4c2d9..0000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0016_unsafe_trait.rast +++ /dev/null @@ -1,13 +0,0 @@ -SOURCE_FILE@0..18 - TRAIT@0..17 - UNSAFE_KW@0..6 "unsafe" - WHITESPACE@6..7 " " - TRAIT_KW@7..12 "trait" - WHITESPACE@12..13 " " - NAME@13..14 - IDENT@13..14 "T" - WHITESPACE@14..15 " " - ASSOC_ITEM_LIST@15..17 - L_CURLY@15..16 "{" - R_CURLY@16..17 "}" - WHITESPACE@17..18 "\n" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0016_unsafe_trait.rs b/crates/ra_syntax/test_data/parser/inline/ok/0016_unsafe_trait.rs deleted file mode 100644 index 04e021550d..0000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0016_unsafe_trait.rs +++ /dev/null @@ -1 +0,0 @@ -unsafe trait T {} diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0036_unsafe_extern_fn.rast b/crates/ra_syntax/test_data/parser/inline/ok/0036_unsafe_extern_fn.rast deleted file mode 100644 index 293b1d64c7..0000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0036_unsafe_extern_fn.rast +++ /dev/null @@ -1,21 +0,0 @@ -SOURCE_FILE@0..30 - FN@0..29 - UNSAFE_KW@0..6 "unsafe" - WHITESPACE@6..7 " " - ABI@7..17 - EXTERN_KW@7..13 "extern" - WHITESPACE@13..14 " " - STRING@14..17 "\"C\"" - WHITESPACE@17..18 " " - FN_KW@18..20 "fn" - WHITESPACE@20..21 " " - NAME@21..24 - IDENT@21..24 "foo" - PARAM_LIST@24..26 - L_PAREN@24..25 "(" - R_PAREN@25..26 ")" - WHITESPACE@26..27 " " - BLOCK_EXPR@27..29 - L_CURLY@27..28 "{" - R_CURLY@28..29 "}" - WHITESPACE@29..30 "\n" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0036_unsafe_extern_fn.rs b/crates/ra_syntax/test_data/parser/inline/ok/0036_unsafe_extern_fn.rs deleted file mode 100644 index 1295c2cd22..0000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0036_unsafe_extern_fn.rs +++ /dev/null @@ -1 +0,0 @@ -unsafe extern "C" fn foo() {} diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.rast b/crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.rast deleted file mode 100644 index d6dfa83b70..0000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.rast +++ /dev/null @@ -1,18 +0,0 @@ -SOURCE_FILE@0..27 - IMPL@0..26 - UNSAFE_KW@0..6 "unsafe" - WHITESPACE@6..7 " " - DEFAULT_KW@7..14 "default" - WHITESPACE@14..15 " " - IMPL_KW@15..19 "impl" - WHITESPACE@19..20 " " - PATH_TYPE@20..23 - PATH@20..23 - PATH_SEGMENT@20..23 - NAME_REF@20..23 - IDENT@20..23 "Foo" - WHITESPACE@23..24 " " - ASSOC_ITEM_LIST@24..26 - L_CURLY@24..25 "{" - R_CURLY@25..26 "}" - WHITESPACE@26..27 "\n" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.rs b/crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.rs deleted file mode 100644 index 9cd6c57bd8..0000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0047_unsafe_default_impl.rs +++ /dev/null @@ -1 +0,0 @@ -unsafe default impl Foo {} diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0057_const_fn.rast b/crates/ra_syntax/test_data/parser/inline/ok/0057_const_fn.rast deleted file mode 100644 index 97548a5eeb..0000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0057_const_fn.rast +++ /dev/null @@ -1,16 +0,0 @@ -SOURCE_FILE@0..18 - FN@0..17 - CONST_KW@0..5 "const" - WHITESPACE@5..6 " " - FN_KW@6..8 "fn" - WHITESPACE@8..9 " " - NAME@9..12 - IDENT@9..12 "foo" - PARAM_LIST@12..14 - L_PAREN@12..13 "(" - R_PAREN@13..14 ")" - WHITESPACE@14..15 " " - BLOCK_EXPR@15..17 - L_CURLY@15..16 "{" - R_CURLY@16..17 "}" - WHITESPACE@17..18 "\n" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0057_const_fn.rs b/crates/ra_syntax/test_data/parser/inline/ok/0057_const_fn.rs deleted file mode 100644 index 8c84d9cd7c..0000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0057_const_fn.rs +++ /dev/null @@ -1 +0,0 @@ -const fn foo() {} diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.rast b/crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.rast deleted file mode 100644 index 43c09affed..0000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.rast +++ /dev/null @@ -1,16 +0,0 @@ -SOURCE_FILE@0..19 - IMPL@0..18 - UNSAFE_KW@0..6 "unsafe" - WHITESPACE@6..7 " " - IMPL_KW@7..11 "impl" - WHITESPACE@11..12 " " - PATH_TYPE@12..15 - PATH@12..15 - PATH_SEGMENT@12..15 - NAME_REF@12..15 - IDENT@12..15 "Foo" - WHITESPACE@15..16 " " - ASSOC_ITEM_LIST@16..18 - L_CURLY@16..17 "{" - R_CURLY@17..18 "}" - WHITESPACE@18..19 "\n" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.rs b/crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.rs deleted file mode 100644 index 41055f41d9..0000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0087_unsafe_impl.rs +++ /dev/null @@ -1 +0,0 @@ -unsafe impl Foo {} diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0089_extern_fn.rast b/crates/ra_syntax/test_data/parser/inline/ok/0089_extern_fn.rast deleted file mode 100644 index 405b6a259f..0000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0089_extern_fn.rast +++ /dev/null @@ -1,17 +0,0 @@ -SOURCE_FILE@0..19 - FN@0..18 - ABI@0..6 - EXTERN_KW@0..6 "extern" - WHITESPACE@6..7 " " - FN_KW@7..9 "fn" - WHITESPACE@9..10 " " - NAME@10..13 - IDENT@10..13 "foo" - PARAM_LIST@13..15 - L_PAREN@13..14 "(" - R_PAREN@14..15 ")" - WHITESPACE@15..16 " " - BLOCK_EXPR@16..18 - L_CURLY@16..17 "{" - R_CURLY@17..18 "}" - WHITESPACE@18..19 "\n" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0089_extern_fn.rs b/crates/ra_syntax/test_data/parser/inline/ok/0089_extern_fn.rs deleted file mode 100644 index 394a049f0f..0000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0089_extern_fn.rs +++ /dev/null @@ -1 +0,0 @@ -extern fn foo() {} diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0091_auto_trait.rast b/crates/ra_syntax/test_data/parser/inline/ok/0091_auto_trait.rast deleted file mode 100644 index 0cac9ac431..0000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0091_auto_trait.rast +++ /dev/null @@ -1,13 +0,0 @@ -SOURCE_FILE@0..16 - TRAIT@0..15 - AUTO_KW@0..4 "auto" - WHITESPACE@4..5 " " - TRAIT_KW@5..10 "trait" - WHITESPACE@10..11 " " - NAME@11..12 - IDENT@11..12 "T" - WHITESPACE@12..13 " " - ASSOC_ITEM_LIST@13..15 - L_CURLY@13..14 "{" - R_CURLY@14..15 "}" - WHITESPACE@15..16 "\n" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0091_auto_trait.rs b/crates/ra_syntax/test_data/parser/inline/ok/0091_auto_trait.rs deleted file mode 100644 index 72adf60351..0000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0091_auto_trait.rs +++ /dev/null @@ -1 +0,0 @@ -auto trait T {} diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0094_unsafe_auto_trait.rast b/crates/ra_syntax/test_data/parser/inline/ok/0094_unsafe_auto_trait.rast deleted file mode 100644 index 0ef11c6825..0000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0094_unsafe_auto_trait.rast +++ /dev/null @@ -1,15 +0,0 @@ -SOURCE_FILE@0..23 - TRAIT@0..22 - UNSAFE_KW@0..6 "unsafe" - WHITESPACE@6..7 " " - AUTO_KW@7..11 "auto" - WHITESPACE@11..12 " " - TRAIT_KW@12..17 "trait" - WHITESPACE@17..18 " " - NAME@18..19 - IDENT@18..19 "T" - WHITESPACE@19..20 " " - ASSOC_ITEM_LIST@20..22 - L_CURLY@20..21 "{" - R_CURLY@21..22 "}" - WHITESPACE@22..23 "\n" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0094_unsafe_auto_trait.rs b/crates/ra_syntax/test_data/parser/inline/ok/0094_unsafe_auto_trait.rs deleted file mode 100644 index 03d29f3241..0000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0094_unsafe_auto_trait.rs +++ /dev/null @@ -1 +0,0 @@ -unsafe auto trait T {} diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.rast b/crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.rast deleted file mode 100644 index 0a1b21d6e6..0000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.rast +++ /dev/null @@ -1,16 +0,0 @@ -SOURCE_FILE@0..20 - IMPL@0..19 - DEFAULT_KW@0..7 "default" - WHITESPACE@7..8 " " - IMPL_KW@8..12 "impl" - WHITESPACE@12..13 " " - PATH_TYPE@13..16 - PATH@13..16 - PATH_SEGMENT@13..16 - NAME_REF@13..16 - IDENT@13..16 "Foo" - WHITESPACE@16..17 " " - ASSOC_ITEM_LIST@17..19 - L_CURLY@17..18 "{" - R_CURLY@18..19 "}" - WHITESPACE@19..20 "\n" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.rs b/crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.rs deleted file mode 100644 index ef6aa84a29..0000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0097_default_impl.rs +++ /dev/null @@ -1 +0,0 @@ -default impl Foo {} diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0098_const_unsafe_fn.rast b/crates/ra_syntax/test_data/parser/inline/ok/0098_const_unsafe_fn.rast deleted file mode 100644 index 32a77ba490..0000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0098_const_unsafe_fn.rast +++ /dev/null @@ -1,18 +0,0 @@ -SOURCE_FILE@0..25 - FN@0..24 - CONST_KW@0..5 "const" - WHITESPACE@5..6 " " - UNSAFE_KW@6..12 "unsafe" - WHITESPACE@12..13 " " - FN_KW@13..15 "fn" - WHITESPACE@15..16 " " - NAME@16..19 - IDENT@16..19 "foo" - PARAM_LIST@19..21 - L_PAREN@19..20 "(" - R_PAREN@20..21 ")" - WHITESPACE@21..22 " " - BLOCK_EXPR@22..24 - L_CURLY@22..23 "{" - R_CURLY@23..24 "}" - WHITESPACE@24..25 "\n" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0098_const_unsafe_fn.rs b/crates/ra_syntax/test_data/parser/inline/ok/0098_const_unsafe_fn.rs deleted file mode 100644 index 31a1e435f5..0000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0098_const_unsafe_fn.rs +++ /dev/null @@ -1 +0,0 @@ -const unsafe fn foo() {} diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0101_unsafe_fn.rast b/crates/ra_syntax/test_data/parser/inline/ok/0101_unsafe_fn.rast deleted file mode 100644 index 73c94e5d43..0000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0101_unsafe_fn.rast +++ /dev/null @@ -1,16 +0,0 @@ -SOURCE_FILE@0..19 - FN@0..18 - UNSAFE_KW@0..6 "unsafe" - WHITESPACE@6..7 " " - FN_KW@7..9 "fn" - WHITESPACE@9..10 " " - NAME@10..13 - IDENT@10..13 "foo" - PARAM_LIST@13..15 - L_PAREN@13..14 "(" - R_PAREN@14..15 ")" - WHITESPACE@15..16 " " - BLOCK_EXPR@16..18 - L_CURLY@16..17 "{" - R_CURLY@17..18 "}" - WHITESPACE@18..19 "\n" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0101_unsafe_fn.rs b/crates/ra_syntax/test_data/parser/inline/ok/0101_unsafe_fn.rs deleted file mode 100644 index 33cfc4cd7a..0000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0101_unsafe_fn.rs +++ /dev/null @@ -1 +0,0 @@ -unsafe fn foo() {} diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0124_async_fn.rast b/crates/ra_syntax/test_data/parser/inline/ok/0124_async_fn.rast deleted file mode 100644 index a7df188bd6..0000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0124_async_fn.rast +++ /dev/null @@ -1,16 +0,0 @@ -SOURCE_FILE@0..18 - FN@0..17 - ASYNC_KW@0..5 "async" - WHITESPACE@5..6 " " - FN_KW@6..8 "fn" - WHITESPACE@8..9 " " - NAME@9..12 - IDENT@9..12 "foo" - PARAM_LIST@12..14 - L_PAREN@12..13 "(" - R_PAREN@13..14 ")" - WHITESPACE@14..15 " " - BLOCK_EXPR@15..17 - L_CURLY@15..16 "{" - R_CURLY@16..17 "}" - WHITESPACE@17..18 "\n" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0124_async_fn.rs b/crates/ra_syntax/test_data/parser/inline/ok/0124_async_fn.rs deleted file mode 100644 index f4adcb62b3..0000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0124_async_fn.rs +++ /dev/null @@ -1 +0,0 @@ -async fn foo() {} diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.rast b/crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.rast deleted file mode 100644 index 98a20f36d6..0000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.rast +++ /dev/null @@ -1,35 +0,0 @@ -SOURCE_FILE@0..50 - FN@0..24 - ASYNC_KW@0..5 "async" - WHITESPACE@5..6 " " - UNSAFE_KW@6..12 "unsafe" - WHITESPACE@12..13 " " - FN_KW@13..15 "fn" - WHITESPACE@15..16 " " - NAME@16..19 - IDENT@16..19 "foo" - PARAM_LIST@19..21 - L_PAREN@19..20 "(" - R_PAREN@20..21 ")" - WHITESPACE@21..22 " " - BLOCK_EXPR@22..24 - L_CURLY@22..23 "{" - R_CURLY@23..24 "}" - WHITESPACE@24..25 "\n" - FN@25..49 - CONST_KW@25..30 "const" - WHITESPACE@30..31 " " - UNSAFE_KW@31..37 "unsafe" - WHITESPACE@37..38 " " - FN_KW@38..40 "fn" - WHITESPACE@40..41 " " - NAME@41..44 - IDENT@41..44 "bar" - PARAM_LIST@44..46 - L_PAREN@44..45 "(" - R_PAREN@45..46 ")" - WHITESPACE@46..47 " " - BLOCK_EXPR@47..49 - L_CURLY@47..48 "{" - R_CURLY@48..49 "}" - WHITESPACE@49..50 "\n" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.rs b/crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.rs deleted file mode 100644 index 1262871453..0000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0128_combined_fns.rs +++ /dev/null @@ -1,2 +0,0 @@ -async unsafe fn foo() {} -const unsafe fn bar() {} diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0151_fn.rast b/crates/ra_syntax/test_data/parser/inline/ok/0151_fn.rast new file mode 100644 index 0000000000..23c4269b30 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0151_fn.rast @@ -0,0 +1,14 @@ +SOURCE_FILE@0..12 + FN@0..11 + FN_KW@0..2 "fn" + WHITESPACE@2..3 " " + NAME@3..6 + IDENT@3..6 "foo" + PARAM_LIST@6..8 + L_PAREN@6..7 "(" + R_PAREN@7..8 ")" + WHITESPACE@8..9 " " + BLOCK_EXPR@9..11 + L_CURLY@9..10 "{" + R_CURLY@10..11 "}" + WHITESPACE@11..12 "\n" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0151_fn.rs b/crates/ra_syntax/test_data/parser/inline/ok/0151_fn.rs new file mode 100644 index 0000000000..8f3b7ef112 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0151_fn.rs @@ -0,0 +1 @@ +fn foo() {} diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0152_impl.rast b/crates/ra_syntax/test_data/parser/inline/ok/0152_impl.rast new file mode 100644 index 0000000000..7968cf9ffa --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0152_impl.rast @@ -0,0 +1,22 @@ +SOURCE_FILE@0..16 + IMPL@0..15 + IMPL_KW@0..4 "impl" + WHITESPACE@4..5 " " + PATH_TYPE@5..6 + PATH@5..6 + PATH_SEGMENT@5..6 + NAME_REF@5..6 + IDENT@5..6 "T" + WHITESPACE@6..7 " " + FOR_KW@7..10 "for" + WHITESPACE@10..11 " " + PATH_TYPE@11..12 + PATH@11..12 + PATH_SEGMENT@11..12 + NAME_REF@11..12 + IDENT@11..12 "S" + WHITESPACE@12..13 " " + ASSOC_ITEM_LIST@13..15 + L_CURLY@13..14 "{" + R_CURLY@14..15 "}" + WHITESPACE@15..16 "\n" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0152_impl.rs b/crates/ra_syntax/test_data/parser/inline/ok/0152_impl.rs new file mode 100644 index 0000000000..a1a550d8a6 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0152_impl.rs @@ -0,0 +1 @@ +impl T for S {} diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0153_trait.rast b/crates/ra_syntax/test_data/parser/inline/ok/0153_trait.rast new file mode 100644 index 0000000000..9881e5048c --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0153_trait.rast @@ -0,0 +1,11 @@ +SOURCE_FILE@0..11 + TRAIT@0..10 + TRAIT_KW@0..5 "trait" + WHITESPACE@5..6 " " + NAME@6..7 + IDENT@6..7 "T" + WHITESPACE@7..8 " " + ASSOC_ITEM_LIST@8..10 + L_CURLY@8..9 "{" + R_CURLY@9..10 "}" + WHITESPACE@10..11 "\n" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0153_trait.rs b/crates/ra_syntax/test_data/parser/inline/ok/0153_trait.rs new file mode 100644 index 0000000000..8d183dbb5d --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0153_trait.rs @@ -0,0 +1 @@ +trait T {} diff --git a/crates/ra_syntax/test_data/parser/ok/0021_extern_fn.rast b/crates/ra_syntax/test_data/parser/ok/0021_extern_fn.rast deleted file mode 100644 index 5524efaafe..0000000000 --- a/crates/ra_syntax/test_data/parser/ok/0021_extern_fn.rast +++ /dev/null @@ -1,56 +0,0 @@ -SOURCE_FILE@0..71 - FN@0..19 - ABI@0..6 - EXTERN_KW@0..6 "extern" - WHITESPACE@6..7 " " - FN_KW@7..9 "fn" - WHITESPACE@9..10 " " - NAME@10..13 - IDENT@10..13 "foo" - PARAM_LIST@13..15 - L_PAREN@13..14 "(" - R_PAREN@14..15 ")" - WHITESPACE@15..16 " " - BLOCK_EXPR@16..19 - L_CURLY@16..17 "{" - WHITESPACE@17..18 "\n" - R_CURLY@18..19 "}" - WHITESPACE@19..21 "\n\n" - FN@21..44 - ABI@21..31 - EXTERN_KW@21..27 "extern" - WHITESPACE@27..28 " " - STRING@28..31 "\"C\"" - WHITESPACE@31..32 " " - FN_KW@32..34 "fn" - WHITESPACE@34..35 " " - NAME@35..38 - IDENT@35..38 "bar" - PARAM_LIST@38..40 - L_PAREN@38..39 "(" - R_PAREN@39..40 ")" - WHITESPACE@40..41 " " - BLOCK_EXPR@41..44 - L_CURLY@41..42 "{" - WHITESPACE@42..43 "\n" - R_CURLY@43..44 "}" - WHITESPACE@44..46 "\n\n" - FN@46..70 - ABI@46..57 - EXTERN_KW@46..52 "extern" - WHITESPACE@52..53 " " - RAW_STRING@53..57 "r\"D\"" - WHITESPACE@57..58 " " - FN_KW@58..60 "fn" - WHITESPACE@60..61 " " - NAME@61..64 - IDENT@61..64 "baz" - PARAM_LIST@64..66 - L_PAREN@64..65 "(" - R_PAREN@65..66 ")" - WHITESPACE@66..67 " " - BLOCK_EXPR@67..70 - L_CURLY@67..68 "{" - WHITESPACE@68..69 "\n" - R_CURLY@69..70 "}" - WHITESPACE@70..71 "\n" diff --git a/crates/ra_syntax/test_data/parser/ok/0021_extern_fn.rs b/crates/ra_syntax/test_data/parser/ok/0021_extern_fn.rs deleted file mode 100644 index e929eef741..0000000000 --- a/crates/ra_syntax/test_data/parser/ok/0021_extern_fn.rs +++ /dev/null @@ -1,8 +0,0 @@ -extern fn foo() { -} - -extern "C" fn bar() { -} - -extern r"D" fn baz() { -} diff --git a/crates/ra_syntax/test_data/parser/ok/0068_item_modifiers.rast b/crates/ra_syntax/test_data/parser/ok/0068_item_modifiers.rast new file mode 100644 index 0000000000..50a6d8ee9a --- /dev/null +++ b/crates/ra_syntax/test_data/parser/ok/0068_item_modifiers.rast @@ -0,0 +1,218 @@ +SOURCE_FILE@0..304 + FN@0..17 + ASYNC_KW@0..5 "async" + WHITESPACE@5..6 " " + FN_KW@6..8 "fn" + WHITESPACE@8..9 " " + NAME@9..12 + IDENT@9..12 "foo" + PARAM_LIST@12..14 + L_PAREN@12..13 "(" + R_PAREN@13..14 ")" + WHITESPACE@14..15 " " + BLOCK_EXPR@15..17 + L_CURLY@15..16 "{" + R_CURLY@16..17 "}" + WHITESPACE@17..18 "\n" + FN@18..36 + ABI@18..24 + EXTERN_KW@18..24 "extern" + WHITESPACE@24..25 " " + FN_KW@25..27 "fn" + WHITESPACE@27..28 " " + NAME@28..31 + IDENT@28..31 "foo" + PARAM_LIST@31..33 + L_PAREN@31..32 "(" + R_PAREN@32..33 ")" + WHITESPACE@33..34 " " + BLOCK_EXPR@34..36 + L_CURLY@34..35 "{" + R_CURLY@35..36 "}" + WHITESPACE@36..37 "\n" + FN@37..54 + CONST_KW@37..42 "const" + WHITESPACE@42..43 " " + FN_KW@43..45 "fn" + WHITESPACE@45..46 " " + NAME@46..49 + IDENT@46..49 "foo" + PARAM_LIST@49..51 + L_PAREN@49..50 "(" + R_PAREN@50..51 ")" + WHITESPACE@51..52 " " + BLOCK_EXPR@52..54 + L_CURLY@52..53 "{" + R_CURLY@53..54 "}" + WHITESPACE@54..55 "\n" + FN@55..79 + CONST_KW@55..60 "const" + WHITESPACE@60..61 " " + UNSAFE_KW@61..67 "unsafe" + WHITESPACE@67..68 " " + FN_KW@68..70 "fn" + WHITESPACE@70..71 " " + NAME@71..74 + IDENT@71..74 "foo" + PARAM_LIST@74..76 + L_PAREN@74..75 "(" + R_PAREN@75..76 ")" + WHITESPACE@76..77 " " + BLOCK_EXPR@77..79 + L_CURLY@77..78 "{" + R_CURLY@78..79 "}" + WHITESPACE@79..80 "\n" + FN@80..109 + UNSAFE_KW@80..86 "unsafe" + WHITESPACE@86..87 " " + ABI@87..97 + EXTERN_KW@87..93 "extern" + WHITESPACE@93..94 " " + STRING@94..97 "\"C\"" + WHITESPACE@97..98 " " + FN_KW@98..100 "fn" + WHITESPACE@100..101 " " + NAME@101..104 + IDENT@101..104 "foo" + PARAM_LIST@104..106 + L_PAREN@104..105 "(" + R_PAREN@105..106 ")" + WHITESPACE@106..107 " " + BLOCK_EXPR@107..109 + L_CURLY@107..108 "{" + R_CURLY@108..109 "}" + WHITESPACE@109..110 "\n" + FN@110..128 + UNSAFE_KW@110..116 "unsafe" + WHITESPACE@116..117 " " + FN_KW@117..119 "fn" + WHITESPACE@119..120 " " + NAME@120..123 + IDENT@120..123 "foo" + PARAM_LIST@123..125 + L_PAREN@123..124 "(" + R_PAREN@124..125 ")" + WHITESPACE@125..126 " " + BLOCK_EXPR@126..128 + L_CURLY@126..127 "{" + R_CURLY@127..128 "}" + WHITESPACE@128..129 "\n" + FN@129..153 + ASYNC_KW@129..134 "async" + WHITESPACE@134..135 " " + UNSAFE_KW@135..141 "unsafe" + WHITESPACE@141..142 " " + FN_KW@142..144 "fn" + WHITESPACE@144..145 " " + NAME@145..148 + IDENT@145..148 "foo" + PARAM_LIST@148..150 + L_PAREN@148..149 "(" + R_PAREN@149..150 ")" + WHITESPACE@150..151 " " + BLOCK_EXPR@151..153 + L_CURLY@151..152 "{" + R_CURLY@152..153 "}" + WHITESPACE@153..154 "\n" + FN@154..178 + CONST_KW@154..159 "const" + WHITESPACE@159..160 " " + UNSAFE_KW@160..166 "unsafe" + WHITESPACE@166..167 " " + FN_KW@167..169 "fn" + WHITESPACE@169..170 " " + NAME@170..173 + IDENT@170..173 "bar" + PARAM_LIST@173..175 + L_PAREN@173..174 "(" + R_PAREN@174..175 ")" + WHITESPACE@175..176 " " + BLOCK_EXPR@176..178 + L_CURLY@176..177 "{" + R_CURLY@177..178 "}" + WHITESPACE@178..180 "\n\n" + TRAIT@180..197 + UNSAFE_KW@180..186 "unsafe" + WHITESPACE@186..187 " " + TRAIT_KW@187..192 "trait" + WHITESPACE@192..193 " " + NAME@193..194 + IDENT@193..194 "T" + WHITESPACE@194..195 " " + ASSOC_ITEM_LIST@195..197 + L_CURLY@195..196 "{" + R_CURLY@196..197 "}" + WHITESPACE@197..198 "\n" + TRAIT@198..213 + AUTO_KW@198..202 "auto" + WHITESPACE@202..203 " " + TRAIT_KW@203..208 "trait" + WHITESPACE@208..209 " " + NAME@209..210 + IDENT@209..210 "T" + WHITESPACE@210..211 " " + ASSOC_ITEM_LIST@211..213 + L_CURLY@211..212 "{" + R_CURLY@212..213 "}" + WHITESPACE@213..214 "\n" + TRAIT@214..236 + UNSAFE_KW@214..220 "unsafe" + WHITESPACE@220..221 " " + AUTO_KW@221..225 "auto" + WHITESPACE@225..226 " " + TRAIT_KW@226..231 "trait" + WHITESPACE@231..232 " " + NAME@232..233 + IDENT@232..233 "T" + WHITESPACE@233..234 " " + ASSOC_ITEM_LIST@234..236 + L_CURLY@234..235 "{" + R_CURLY@235..236 "}" + WHITESPACE@236..238 "\n\n" + IMPL@238..256 + UNSAFE_KW@238..244 "unsafe" + WHITESPACE@244..245 " " + IMPL_KW@245..249 "impl" + WHITESPACE@249..250 " " + PATH_TYPE@250..253 + PATH@250..253 + PATH_SEGMENT@250..253 + NAME_REF@250..253 + IDENT@250..253 "Foo" + WHITESPACE@253..254 " " + ASSOC_ITEM_LIST@254..256 + L_CURLY@254..255 "{" + R_CURLY@255..256 "}" + WHITESPACE@256..257 "\n" + IMPL@257..276 + DEFAULT_KW@257..264 "default" + WHITESPACE@264..265 " " + IMPL_KW@265..269 "impl" + WHITESPACE@269..270 " " + PATH_TYPE@270..273 + PATH@270..273 + PATH_SEGMENT@270..273 + NAME_REF@270..273 + IDENT@270..273 "Foo" + WHITESPACE@273..274 " " + ASSOC_ITEM_LIST@274..276 + L_CURLY@274..275 "{" + R_CURLY@275..276 "}" + WHITESPACE@276..277 "\n" + IMPL@277..303 + UNSAFE_KW@277..283 "unsafe" + WHITESPACE@283..284 " " + DEFAULT_KW@284..291 "default" + WHITESPACE@291..292 " " + IMPL_KW@292..296 "impl" + WHITESPACE@296..297 " " + PATH_TYPE@297..300 + PATH@297..300 + PATH_SEGMENT@297..300 + NAME_REF@297..300 + IDENT@297..300 "Foo" + WHITESPACE@300..301 " " + ASSOC_ITEM_LIST@301..303 + L_CURLY@301..302 "{" + R_CURLY@302..303 "}" + WHITESPACE@303..304 "\n" diff --git a/crates/ra_syntax/test_data/parser/ok/0068_item_modifiers.rs b/crates/ra_syntax/test_data/parser/ok/0068_item_modifiers.rs new file mode 100644 index 0000000000..8d697c04b9 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/ok/0068_item_modifiers.rs @@ -0,0 +1,16 @@ +async fn foo() {} +extern fn foo() {} +const fn foo() {} +const unsafe fn foo() {} +unsafe extern "C" fn foo() {} +unsafe fn foo() {} +async unsafe fn foo() {} +const unsafe fn bar() {} + +unsafe trait T {} +auto trait T {} +unsafe auto trait T {} + +unsafe impl Foo {} +default impl Foo {} +unsafe default impl Foo {} From 1c359ab634edb81b51e3c7eadfb83d46c926e890 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 12 Aug 2020 15:04:06 +0200 Subject: [PATCH 065/119] Replace SepBy with Itertools --- .../src/handlers/add_custom_impl.rs | 4 +- .../ra_assists/src/handlers/generate_impl.rs | 5 +- .../ra_assists/src/handlers/generate_new.rs | 9 +-- crates/ra_ide/src/completion/presentation.rs | 31 +++++---- .../src/syntax_highlighting/injection.rs | 5 +- crates/ra_syntax/src/ast/traits.rs | 5 +- crates/stdx/src/lib.rs | 65 +------------------ 7 files changed, 30 insertions(+), 94 deletions(-) diff --git a/crates/ra_assists/src/handlers/add_custom_impl.rs b/crates/ra_assists/src/handlers/add_custom_impl.rs index b67438b6ba..ebdf00e676 100644 --- a/crates/ra_assists/src/handlers/add_custom_impl.rs +++ b/crates/ra_assists/src/handlers/add_custom_impl.rs @@ -1,10 +1,10 @@ +use itertools::Itertools; use ra_syntax::{ ast::{self, AstNode}, Direction, SmolStr, SyntaxKind::{IDENT, WHITESPACE}, TextRange, TextSize, }; -use stdx::SepBy; use crate::{ assist_context::{AssistContext, Assists}, @@ -61,9 +61,9 @@ pub(crate) fn add_custom_impl(acc: &mut Assists, ctx: &AssistContext) -> Option< .filter(|t| t != trait_token.text()) .collect::>(); let has_more_derives = !new_attr_input.is_empty(); - let new_attr_input = new_attr_input.iter().sep_by(", ").surround_with("(", ")").to_string(); if has_more_derives { + let new_attr_input = format!("({})", new_attr_input.iter().format(", ")); builder.replace(input.syntax().text_range(), new_attr_input); } else { let attr_range = attr.syntax().text_range(); diff --git a/crates/ra_assists/src/handlers/generate_impl.rs b/crates/ra_assists/src/handlers/generate_impl.rs index d9b87c9c0d..7162dc1848 100644 --- a/crates/ra_assists/src/handlers/generate_impl.rs +++ b/crates/ra_assists/src/handlers/generate_impl.rs @@ -1,5 +1,6 @@ +use itertools::Itertools; use ra_syntax::ast::{self, AstNode, GenericParamsOwner, NameOwner}; -use stdx::{format_to, SepBy}; +use stdx::format_to; use crate::{AssistContext, AssistId, AssistKind, Assists}; @@ -50,7 +51,7 @@ pub(crate) fn generate_impl(acc: &mut Assists, ctx: &AssistContext) -> Option<() .filter_map(|it| it.name()) .map(|it| it.text().clone()); - let generic_params = lifetime_params.chain(type_params).sep_by(", "); + let generic_params = lifetime_params.chain(type_params).format(", "); format_to!(buf, "<{}>", generic_params) } match ctx.config.snippet_cap { diff --git a/crates/ra_assists/src/handlers/generate_new.rs b/crates/ra_assists/src/handlers/generate_new.rs index b84aa24b6c..32dfed274a 100644 --- a/crates/ra_assists/src/handlers/generate_new.rs +++ b/crates/ra_assists/src/handlers/generate_new.rs @@ -1,9 +1,10 @@ use hir::Adt; +use itertools::Itertools; use ra_syntax::{ ast::{self, AstNode, GenericParamsOwner, NameOwner, StructKind, VisibilityOwner}, T, }; -use stdx::{format_to, SepBy}; +use stdx::format_to; use crate::{AssistContext, AssistId, AssistKind, Assists}; @@ -52,8 +53,8 @@ pub(crate) fn generate_new(acc: &mut Assists, ctx: &AssistContext) -> Option<()> let params = field_list .fields() .filter_map(|f| Some(format!("{}: {}", f.name()?.syntax(), f.ty()?.syntax()))) - .sep_by(", "); - let fields = field_list.fields().filter_map(|f| f.name()).sep_by(", "); + .format(", "); + let fields = field_list.fields().filter_map(|f| f.name()).format(", "); format_to!(buf, " {}fn new({}) -> Self {{ Self {{ {} }} }}", vis, params, fields); @@ -102,7 +103,7 @@ fn generate_impl_text(strukt: &ast::Struct, code: &str) -> String { .map(|it| it.text().clone()); let type_params = type_params.type_params().filter_map(|it| it.name()).map(|it| it.text().clone()); - format_to!(buf, "<{}>", lifetime_params.chain(type_params).sep_by(", ")) + format_to!(buf, "<{}>", lifetime_params.chain(type_params).format(", ")) } format_to!(buf, " {{\n{}\n}}\n", code); diff --git a/crates/ra_ide/src/completion/presentation.rs b/crates/ra_ide/src/completion/presentation.rs index 9a94ff4767..59f1b14246 100644 --- a/crates/ra_ide/src/completion/presentation.rs +++ b/crates/ra_ide/src/completion/presentation.rs @@ -2,8 +2,8 @@ //! It also handles scoring (sorting) completions. use hir::{Docs, HasAttrs, HasSource, HirDisplay, ModPath, ScopeDef, StructKind, Type}; +use itertools::Itertools; use ra_syntax::ast::NameOwner; -use stdx::SepBy; use test_utils::mark; use crate::{ @@ -289,16 +289,16 @@ impl Completions { .map(|field| (field.name(ctx.db), field.signature_ty(ctx.db))); let variant_kind = variant.kind(ctx.db); let detail = match variant_kind { - StructKind::Tuple | StructKind::Unit => detail_types - .map(|(_, t)| t.display(ctx.db).to_string()) - .sep_by(", ") - .surround_with("(", ")") - .to_string(), - StructKind::Record => detail_types - .map(|(n, t)| format!("{}: {}", n, t.display(ctx.db).to_string())) - .sep_by(", ") - .surround_with("{ ", " }") - .to_string(), + StructKind::Tuple | StructKind::Unit => format!( + "({})", + detail_types.map(|(_, t)| t.display(ctx.db).to_string()).format(", ") + ), + StructKind::Record => format!( + "{{ {} }}", + detail_types + .map(|(n, t)| format!("{}: {}", n, t.display(ctx.db).to_string())) + .format(", ") + ), }; let mut res = CompletionItem::new( CompletionKind::Reference, @@ -412,11 +412,10 @@ impl Builder { self = self.trigger_call_info(); let snippet = match (ctx.config.add_call_argument_snippets, params) { (true, Params::Named(params)) => { - let function_params_snippet = params - .iter() - .enumerate() - .map(|(index, param_name)| format!("${{{}:{}}}", index + 1, param_name)) - .sep_by(", "); + let function_params_snippet = + params.iter().enumerate().format_with(", ", |(index, param_name), f| { + f(&format_args!("${{{}:{}}}", index + 1, param_name)) + }); format!("{}({})$0", name, function_params_snippet) } _ => { diff --git a/crates/ra_ide/src/syntax_highlighting/injection.rs b/crates/ra_ide/src/syntax_highlighting/injection.rs index 8665b480fd..6046643ef1 100644 --- a/crates/ra_ide/src/syntax_highlighting/injection.rs +++ b/crates/ra_ide/src/syntax_highlighting/injection.rs @@ -4,8 +4,8 @@ use std::{collections::BTreeMap, convert::TryFrom}; use ast::{HasQuotes, HasStringValue}; use hir::Semantics; +use itertools::Itertools; use ra_syntax::{ast, AstToken, SyntaxNode, SyntaxToken, TextRange, TextSize}; -use stdx::SepBy; use crate::{ call_info::ActiveParameter, Analysis, Highlight, HighlightModifier, HighlightTag, @@ -129,8 +129,7 @@ pub(super) fn extract_doc_comments( line[pos..].to_owned() }) - .sep_by("\n") - .to_string(); + .join("\n"); if doctest.is_empty() { return None; diff --git a/crates/ra_syntax/src/ast/traits.rs b/crates/ra_syntax/src/ast/traits.rs index 3a56b1674c..0bdc22d953 100644 --- a/crates/ra_syntax/src/ast/traits.rs +++ b/crates/ra_syntax/src/ast/traits.rs @@ -1,7 +1,7 @@ //! Various traits that are implemented by ast nodes. //! //! The implementations are usually trivial, and live in generated.rs -use stdx::SepBy; +use itertools::Itertools; use crate::{ ast::{self, support, AstChildren, AstNode, AstToken}, @@ -119,8 +119,7 @@ impl CommentIter { // of a line in markdown. line[pos..end].to_owned() }) - .sep_by("\n") - .to_string(); + .join("\n"); if has_comments { Some(docs) diff --git a/crates/stdx/src/lib.rs b/crates/stdx/src/lib.rs index 00bfcd29ed..3c5027fe57 100644 --- a/crates/stdx/src/lib.rs +++ b/crates/stdx/src/lib.rs @@ -1,5 +1,5 @@ //! Missing batteries for standard libraries. -use std::{cell::Cell, fmt, time::Instant}; +use std::time::Instant; mod macros; @@ -8,69 +8,6 @@ pub fn is_ci() -> bool { option_env!("CI").is_some() } -pub trait SepBy: Sized { - /// Returns an `impl fmt::Display`, which joins elements via a separator. - fn sep_by(self, sep: &str) -> SepByBuilder<'_, Self>; -} - -impl SepBy for I -where - I: Iterator, - I::Item: fmt::Display, -{ - fn sep_by(self, sep: &str) -> SepByBuilder<'_, Self> { - SepByBuilder::new(sep, self) - } -} - -pub struct SepByBuilder<'a, I> { - sep: &'a str, - prefix: &'a str, - suffix: &'a str, - iter: Cell>, -} - -impl<'a, I> SepByBuilder<'a, I> { - fn new(sep: &'a str, iter: I) -> SepByBuilder<'a, I> { - SepByBuilder { sep, prefix: "", suffix: "", iter: Cell::new(Some(iter)) } - } - - pub fn prefix(mut self, prefix: &'a str) -> Self { - self.prefix = prefix; - self - } - - pub fn suffix(mut self, suffix: &'a str) -> Self { - self.suffix = suffix; - self - } - - /// Set both suffix and prefix. - pub fn surround_with(self, prefix: &'a str, suffix: &'a str) -> Self { - self.prefix(prefix).suffix(suffix) - } -} - -impl fmt::Display for SepByBuilder<'_, I> -where - I: Iterator, - I::Item: fmt::Display, -{ - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str(self.prefix)?; - let mut first = true; - for item in self.iter.take().unwrap() { - if !first { - f.write_str(self.sep)?; - } - first = false; - fmt::Display::fmt(&item, f)?; - } - f.write_str(self.suffix)?; - Ok(()) - } -} - #[must_use] pub fn timeit(label: &'static str) -> impl Drop { struct Guard { From 5534bc0321f3a1174882b3fbbf2a08eb19a9868d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 12 Aug 2020 15:54:39 +0200 Subject: [PATCH 066/119] Completely remove cargo audit My current feeling is that the build maintenance friction it creates is not proportional to the benefits it provides. We are pretty frugal with the set of Rust dependencies, and our security model is "we run build.rs and proc macros", so it doesn't seem like cargo audit could help us much. --- .github/workflows/ci.yaml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f977c88bee..f46fb8fecc 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -16,20 +16,6 @@ env: RUSTUP_MAX_RETRIES: 10 jobs: - # rust-audit: - # name: Audit Rust vulnerabilities - # runs-on: ubuntu-latest - # steps: - # - name: Checkout repository - # uses: actions/checkout@v2 - - # - uses: actions-rs/install@v0.1 - # with: - # crate: cargo-audit - # use-tool-cache: true - - # - run: cargo audit - rust: name: Rust runs-on: ${{ matrix.os }} From 98baa9b569b49162392ed4149dd435854fe941b8 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 12 Aug 2020 16:22:05 +0200 Subject: [PATCH 067/119] Rename ra_arena --- Cargo.lock | 18 +++++++++--------- crates/{ra_arena => arena}/Cargo.toml | 8 ++++---- crates/{ra_arena => arena}/src/lib.rs | 0 crates/{ra_arena => arena}/src/map.rs | 0 crates/ra_hir_def/Cargo.toml | 2 +- crates/ra_hir_def/src/adt.rs | 2 +- crates/ra_hir_def/src/body.rs | 2 +- crates/ra_hir_def/src/body/lower.rs | 2 +- crates/ra_hir_def/src/body/scope.rs | 2 +- crates/ra_hir_def/src/expr.rs | 2 +- crates/ra_hir_def/src/generics.rs | 2 +- crates/ra_hir_def/src/item_tree.rs | 2 +- crates/ra_hir_def/src/item_tree/lower.rs | 2 +- crates/ra_hir_def/src/lib.rs | 2 +- crates/ra_hir_def/src/nameres.rs | 2 +- crates/ra_hir_def/src/nameres/collector.rs | 2 +- crates/ra_hir_def/src/src.rs | 2 +- crates/ra_hir_def/src/trace.rs | 2 +- crates/ra_hir_expand/Cargo.toml | 2 +- crates/ra_hir_expand/src/ast_id_map.rs | 2 +- crates/ra_hir_ty/Cargo.toml | 2 +- crates/ra_hir_ty/src/db.rs | 2 +- .../ra_hir_ty/src/diagnostics/match_check.rs | 2 +- crates/ra_hir_ty/src/infer.rs | 2 +- crates/ra_hir_ty/src/lower.rs | 2 +- crates/ra_prof/Cargo.toml | 2 +- crates/ra_prof/src/tree.rs | 4 ++-- crates/ra_project_model/Cargo.toml | 2 +- crates/ra_project_model/src/cargo_workspace.rs | 2 +- crates/ra_project_model/src/sysroot.rs | 2 +- 30 files changed, 40 insertions(+), 40 deletions(-) rename crates/{ra_arena => arena}/Cargo.toml (76%) rename crates/{ra_arena => arena}/src/lib.rs (100%) rename crates/{ra_arena => arena}/src/map.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 2658891625..ab1698b11a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,6 +45,10 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33954243bd79057c2de7338850b85983a44588021f8a5fee574a8888c6de4344" +[[package]] +name = "arena" +version = "0.0.0" + [[package]] name = "arrayvec" version = "0.5.1" @@ -899,10 +903,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "ra_arena" -version = "0.1.0" - [[package]] name = "ra_assists" version = "0.1.0" @@ -977,6 +977,7 @@ name = "ra_hir_def" version = "0.1.0" dependencies = [ "anymap", + "arena", "drop_bomb", "either", "expect", @@ -985,7 +986,6 @@ dependencies = [ "itertools", "log", "once_cell", - "ra_arena", "ra_cfg", "ra_db", "ra_hir_expand", @@ -1003,9 +1003,9 @@ dependencies = [ name = "ra_hir_expand" version = "0.1.0" dependencies = [ + "arena", "either", "log", - "ra_arena", "ra_db", "ra_mbe", "ra_parser", @@ -1020,6 +1020,7 @@ dependencies = [ name = "ra_hir_ty" version = "0.1.0" dependencies = [ + "arena", "arrayvec", "chalk-ir", "chalk-recursive", @@ -1028,7 +1029,6 @@ dependencies = [ "expect", "itertools", "log", - "ra_arena", "ra_db", "ra_hir_def", "ra_hir_expand", @@ -1141,12 +1141,12 @@ dependencies = [ name = "ra_prof" version = "0.1.0" dependencies = [ + "arena", "backtrace", "cfg-if", "libc", "once_cell", "perf-event", - "ra_arena", ] [[package]] @@ -1154,10 +1154,10 @@ name = "ra_project_model" version = "0.1.0" dependencies = [ "anyhow", + "arena", "cargo_metadata", "log", "paths", - "ra_arena", "ra_cfg", "ra_db", "ra_proc_macro", diff --git a/crates/ra_arena/Cargo.toml b/crates/arena/Cargo.toml similarity index 76% rename from crates/ra_arena/Cargo.toml rename to crates/arena/Cargo.toml index 66c3738f4d..f2bb5cc456 100644 --- a/crates/ra_arena/Cargo.toml +++ b/crates/arena/Cargo.toml @@ -1,9 +1,9 @@ [package] -edition = "2018" -name = "ra_arena" -version = "0.1.0" -authors = ["rust-analyzer developers"] +name = "arena" +version = "0.0.0" license = "MIT OR Apache-2.0" +authors = ["rust-analyzer developers"] +edition = "2018" [lib] doctest = false diff --git a/crates/ra_arena/src/lib.rs b/crates/arena/src/lib.rs similarity index 100% rename from crates/ra_arena/src/lib.rs rename to crates/arena/src/lib.rs diff --git a/crates/ra_arena/src/map.rs b/crates/arena/src/map.rs similarity index 100% rename from crates/ra_arena/src/map.rs rename to crates/arena/src/map.rs diff --git a/crates/ra_hir_def/Cargo.toml b/crates/ra_hir_def/Cargo.toml index d96a86b80f..6dd6fdde60 100644 --- a/crates/ra_hir_def/Cargo.toml +++ b/crates/ra_hir_def/Cargo.toml @@ -22,7 +22,7 @@ smallvec = "1.4.0" stdx = { path = "../stdx" } -ra_arena = { path = "../ra_arena" } +arena = { path = "../arena" } ra_db = { path = "../ra_db" } ra_syntax = { path = "../ra_syntax" } ra_prof = { path = "../ra_prof" } diff --git a/crates/ra_hir_def/src/adt.rs b/crates/ra_hir_def/src/adt.rs index 35c3a91402..896a69ca80 100644 --- a/crates/ra_hir_def/src/adt.rs +++ b/crates/ra_hir_def/src/adt.rs @@ -2,12 +2,12 @@ use std::sync::Arc; +use arena::{map::ArenaMap, Arena}; use either::Either; use hir_expand::{ name::{AsName, Name}, InFile, }; -use ra_arena::{map::ArenaMap, Arena}; use ra_syntax::ast::{self, NameOwner, VisibilityOwner}; use tt::{Delimiter, DelimiterKind, Leaf, Subtree, TokenTree}; diff --git a/crates/ra_hir_def/src/body.rs b/crates/ra_hir_def/src/body.rs index d5f18b9201..cb178655b4 100644 --- a/crates/ra_hir_def/src/body.rs +++ b/crates/ra_hir_def/src/body.rs @@ -5,10 +5,10 @@ pub mod scope; use std::{mem, ops::Index, sync::Arc}; +use arena::{map::ArenaMap, Arena}; use drop_bomb::DropBomb; use either::Either; use hir_expand::{ast_id_map::AstIdMap, hygiene::Hygiene, AstId, HirFileId, InFile, MacroDefId}; -use ra_arena::{map::ArenaMap, Arena}; use ra_cfg::CfgOptions; use ra_db::CrateId; use ra_prof::profile; diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index f5c37edb30..4823930062 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs @@ -3,13 +3,13 @@ use std::{any::type_name, sync::Arc}; +use arena::Arena; use either::Either; use hir_expand::{ hygiene::Hygiene, name::{name, AsName, Name}, HirFileId, MacroDefId, MacroDefKind, }; -use ra_arena::Arena; use ra_syntax::{ ast::{ self, ArgListOwner, ArrayExprKind, AstChildren, LiteralKind, LoopBodyOwner, NameOwner, diff --git a/crates/ra_hir_def/src/body/scope.rs b/crates/ra_hir_def/src/body/scope.rs index 99e8766835..f783e18b54 100644 --- a/crates/ra_hir_def/src/body/scope.rs +++ b/crates/ra_hir_def/src/body/scope.rs @@ -1,8 +1,8 @@ //! Name resolution for expressions. use std::sync::Arc; +use arena::{Arena, Idx}; use hir_expand::name::Name; -use ra_arena::{Arena, Idx}; use rustc_hash::FxHashMap; use crate::{ diff --git a/crates/ra_hir_def/src/expr.rs b/crates/ra_hir_def/src/expr.rs index e41cfc16b9..befe41c2ae 100644 --- a/crates/ra_hir_def/src/expr.rs +++ b/crates/ra_hir_def/src/expr.rs @@ -12,8 +12,8 @@ //! //! See also a neighboring `body` module. +use arena::{Idx, RawId}; use hir_expand::name::Name; -use ra_arena::{Idx, RawId}; use ra_syntax::ast::RangeOp; use crate::{ diff --git a/crates/ra_hir_def/src/generics.rs b/crates/ra_hir_def/src/generics.rs index 699ba9c923..90daa46b4c 100644 --- a/crates/ra_hir_def/src/generics.rs +++ b/crates/ra_hir_def/src/generics.rs @@ -4,12 +4,12 @@ //! in rustc. use std::sync::Arc; +use arena::{map::ArenaMap, Arena}; use either::Either; use hir_expand::{ name::{name, AsName, Name}, InFile, }; -use ra_arena::{map::ArenaMap, Arena}; use ra_db::FileId; use ra_prof::profile; use ra_syntax::ast::{self, GenericParamsOwner, NameOwner, TypeBoundsOwner}; diff --git a/crates/ra_hir_def/src/item_tree.rs b/crates/ra_hir_def/src/item_tree.rs index a67e75dac0..fc05bb3075 100644 --- a/crates/ra_hir_def/src/item_tree.rs +++ b/crates/ra_hir_def/src/item_tree.rs @@ -13,6 +13,7 @@ use std::{ sync::Arc, }; +use arena::{Arena, Idx, RawId}; use ast::{AstNode, AttrsOwner, NameOwner, StructKind}; use either::Either; use hir_expand::{ @@ -21,7 +22,6 @@ use hir_expand::{ name::{name, AsName, Name}, HirFileId, InFile, }; -use ra_arena::{Arena, Idx, RawId}; use ra_syntax::{ast, match_ast}; use rustc_hash::FxHashMap; use smallvec::SmallVec; diff --git a/crates/ra_hir_def/src/item_tree/lower.rs b/crates/ra_hir_def/src/item_tree/lower.rs index 450ef87981..4523d0fbbf 100644 --- a/crates/ra_hir_def/src/item_tree/lower.rs +++ b/crates/ra_hir_def/src/item_tree/lower.rs @@ -2,8 +2,8 @@ use std::{collections::hash_map::Entry, mem, sync::Arc}; +use arena::map::ArenaMap; use hir_expand::{ast_id_map::AstIdMap, hygiene::Hygiene, HirFileId}; -use ra_arena::map::ArenaMap; use ra_syntax::{ ast::{self, ModuleItemOwner}, SyntaxNode, diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index 237b1038af..8103937397 100644 --- a/crates/ra_hir_def/src/lib.rs +++ b/crates/ra_hir_def/src/lib.rs @@ -52,11 +52,11 @@ mod test_db; use std::hash::{Hash, Hasher}; +use arena::Idx; use hir_expand::{ ast_id_map::FileAstId, eager::expand_eager_macro, hygiene::Hygiene, AstId, HirFileId, InFile, MacroCallId, MacroCallKind, MacroDefId, MacroDefKind, }; -use ra_arena::Idx; use ra_db::{impl_intern_key, salsa, CrateId}; use ra_syntax::ast; diff --git a/crates/ra_hir_def/src/nameres.rs b/crates/ra_hir_def/src/nameres.rs index 3d9b55a73c..b4b97eb086 100644 --- a/crates/ra_hir_def/src/nameres.rs +++ b/crates/ra_hir_def/src/nameres.rs @@ -56,8 +56,8 @@ mod tests; use std::sync::Arc; +use arena::Arena; use hir_expand::{diagnostics::DiagnosticSink, name::Name, InFile}; -use ra_arena::Arena; use ra_db::{CrateId, Edition, FileId}; use ra_prof::profile; use ra_syntax::ast; diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index 28b7a20c55..52ee401d9e 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs @@ -1208,7 +1208,7 @@ fn is_macro_rules(path: &ModPath) -> bool { #[cfg(test)] mod tests { use crate::{db::DefDatabase, test_db::TestDB}; - use ra_arena::Arena; + use arena::Arena; use ra_db::{fixture::WithFixture, SourceDatabase}; use super::*; diff --git a/crates/ra_hir_def/src/src.rs b/crates/ra_hir_def/src/src.rs index 043b93fad5..7a79b03149 100644 --- a/crates/ra_hir_def/src/src.rs +++ b/crates/ra_hir_def/src/src.rs @@ -1,7 +1,7 @@ //! Utilities for mapping between hir IDs and the surface syntax. +use arena::map::ArenaMap; use hir_expand::InFile; -use ra_arena::map::ArenaMap; use crate::{db::DefDatabase, item_tree::ItemTreeNode, AssocItemLoc, ItemLoc}; diff --git a/crates/ra_hir_def/src/trace.rs b/crates/ra_hir_def/src/trace.rs index ced07577dc..fd64e70188 100644 --- a/crates/ra_hir_def/src/trace.rs +++ b/crates/ra_hir_def/src/trace.rs @@ -9,7 +9,7 @@ //! absolute offsets. The `Trace` structure (inspired, at least in name, by //! Kotlin's `BindingTrace`) allows use the same code to compute both //! projections. -use ra_arena::{map::ArenaMap, Arena, Idx, RawId}; +use arena::{map::ArenaMap, Arena, Idx, RawId}; pub(crate) struct Trace { arena: Option>, diff --git a/crates/ra_hir_expand/Cargo.toml b/crates/ra_hir_expand/Cargo.toml index 6da0e2a165..808c36fd8f 100644 --- a/crates/ra_hir_expand/Cargo.toml +++ b/crates/ra_hir_expand/Cargo.toml @@ -13,7 +13,7 @@ log = "0.4.8" either = "1.5.3" rustc-hash = "1.0.0" -ra_arena = { path = "../ra_arena" } +arena = { path = "../arena" } ra_db = { path = "../ra_db" } ra_syntax = { path = "../ra_syntax" } ra_parser = { path = "../ra_parser" } diff --git a/crates/ra_hir_expand/src/ast_id_map.rs b/crates/ra_hir_expand/src/ast_id_map.rs index 8bfe1b4ba7..703a85b0f7 100644 --- a/crates/ra_hir_expand/src/ast_id_map.rs +++ b/crates/ra_hir_expand/src/ast_id_map.rs @@ -12,7 +12,7 @@ use std::{ marker::PhantomData, }; -use ra_arena::{Arena, Idx}; +use arena::{Arena, Idx}; use ra_syntax::{ast, AstNode, AstPtr, SyntaxNode, SyntaxNodePtr}; /// `AstId` points to an AST node in a specific file. diff --git a/crates/ra_hir_ty/Cargo.toml b/crates/ra_hir_ty/Cargo.toml index 83397d5793..fc68eaa8f1 100644 --- a/crates/ra_hir_ty/Cargo.toml +++ b/crates/ra_hir_ty/Cargo.toml @@ -20,7 +20,7 @@ stdx = { path = "../stdx" } hir_def = { path = "../ra_hir_def", package = "ra_hir_def" } hir_expand = { path = "../ra_hir_expand", package = "ra_hir_expand" } -ra_arena = { path = "../ra_arena" } +arena = { path = "../arena" } ra_db = { path = "../ra_db" } ra_prof = { path = "../ra_prof" } ra_syntax = { path = "../ra_syntax" } diff --git a/crates/ra_hir_ty/src/db.rs b/crates/ra_hir_ty/src/db.rs index c773adc674..d396017bf4 100644 --- a/crates/ra_hir_ty/src/db.rs +++ b/crates/ra_hir_ty/src/db.rs @@ -2,11 +2,11 @@ use std::sync::Arc; +use arena::map::ArenaMap; use hir_def::{ db::DefDatabase, expr::ExprId, DefWithBodyId, FunctionId, GenericDefId, ImplId, LocalFieldId, TypeParamId, VariantId, }; -use ra_arena::map::ArenaMap; use ra_db::{impl_intern_key, salsa, CrateId, Upcast}; use ra_prof::profile; diff --git a/crates/ra_hir_ty/src/diagnostics/match_check.rs b/crates/ra_hir_ty/src/diagnostics/match_check.rs index deca244dbb..7f007f1d65 100644 --- a/crates/ra_hir_ty/src/diagnostics/match_check.rs +++ b/crates/ra_hir_ty/src/diagnostics/match_check.rs @@ -218,13 +218,13 @@ //! ``` use std::sync::Arc; +use arena::Idx; use hir_def::{ adt::VariantData, body::Body, expr::{Expr, Literal, Pat, PatId}, AdtId, EnumVariantId, VariantId, }; -use ra_arena::Idx; use smallvec::{smallvec, SmallVec}; use crate::{db::HirDatabase, ApplicationTy, InferenceResult, Ty, TypeCtor}; diff --git a/crates/ra_hir_ty/src/infer.rs b/crates/ra_hir_ty/src/infer.rs index 3d12039a6d..e003690b3d 100644 --- a/crates/ra_hir_ty/src/infer.rs +++ b/crates/ra_hir_ty/src/infer.rs @@ -18,6 +18,7 @@ use std::mem; use std::ops::Index; use std::sync::Arc; +use arena::map::ArenaMap; use hir_def::{ body::Body, data::{ConstData, FunctionData, StaticData}, @@ -30,7 +31,6 @@ use hir_def::{ TypeAliasId, VariantId, }; use hir_expand::{diagnostics::DiagnosticSink, name::name}; -use ra_arena::map::ArenaMap; use ra_prof::profile; use ra_syntax::SmolStr; use rustc_hash::FxHashMap; diff --git a/crates/ra_hir_ty/src/lower.rs b/crates/ra_hir_ty/src/lower.rs index 7638f167b5..7b805fe7ae 100644 --- a/crates/ra_hir_ty/src/lower.rs +++ b/crates/ra_hir_ty/src/lower.rs @@ -7,6 +7,7 @@ //! This usually involves resolving names, collecting generic arguments etc. use std::{iter, sync::Arc}; +use arena::map::ArenaMap; use hir_def::{ adt::StructKind, builtin_type::BuiltinType, @@ -19,7 +20,6 @@ use hir_def::{ UnionId, VariantId, }; use hir_expand::name::Name; -use ra_arena::map::ArenaMap; use ra_db::CrateId; use smallvec::SmallVec; use stdx::impl_from; diff --git a/crates/ra_prof/Cargo.toml b/crates/ra_prof/Cargo.toml index c82b9f76d4..9880c587f2 100644 --- a/crates/ra_prof/Cargo.toml +++ b/crates/ra_prof/Cargo.toml @@ -10,7 +10,7 @@ license = "MIT OR Apache-2.0" doctest = false [dependencies] -ra_arena = { path = "../ra_arena" } +arena = { path = "../arena" } once_cell = "1.3.1" backtrace = { version = "0.3.44", optional = true } cfg-if = "0.1.10" diff --git a/crates/ra_prof/src/tree.rs b/crates/ra_prof/src/tree.rs index 9ea5b5db8e..096f58511c 100644 --- a/crates/ra_prof/src/tree.rs +++ b/crates/ra_prof/src/tree.rs @@ -1,7 +1,7 @@ //! A simple tree implementation which tries to not allocate all over the place. use std::ops; -use ra_arena::Arena; +use arena::Arena; #[derive(Default)] pub struct Tree { @@ -9,7 +9,7 @@ pub struct Tree { current_path: Vec<(Idx, Option>)>, } -pub type Idx = ra_arena::Idx>; +pub type Idx = arena::Idx>; impl Tree { pub fn start(&mut self) diff --git a/crates/ra_project_model/Cargo.toml b/crates/ra_project_model/Cargo.toml index 99adea8e44..27b1f5d33f 100644 --- a/crates/ra_project_model/Cargo.toml +++ b/crates/ra_project_model/Cargo.toml @@ -14,7 +14,7 @@ rustc-hash = "1.1.0" cargo_metadata = "0.11.1" -ra_arena = { path = "../ra_arena" } +arena = { path = "../arena" } ra_cfg = { path = "../ra_cfg" } ra_db = { path = "../ra_db" } ra_toolchain = { path = "../ra_toolchain" } diff --git a/crates/ra_project_model/src/cargo_workspace.rs b/crates/ra_project_model/src/cargo_workspace.rs index 10513542e2..a526d743d4 100644 --- a/crates/ra_project_model/src/cargo_workspace.rs +++ b/crates/ra_project_model/src/cargo_workspace.rs @@ -8,9 +8,9 @@ use std::{ }; use anyhow::{Context, Result}; +use arena::{Arena, Idx}; use cargo_metadata::{BuildScript, CargoOpt, Message, MetadataCommand, PackageId}; use paths::{AbsPath, AbsPathBuf}; -use ra_arena::{Arena, Idx}; use ra_db::Edition; use rustc_hash::FxHashMap; diff --git a/crates/ra_project_model/src/sysroot.rs b/crates/ra_project_model/src/sysroot.rs index a10ade3757..6ef001769c 100644 --- a/crates/ra_project_model/src/sysroot.rs +++ b/crates/ra_project_model/src/sysroot.rs @@ -3,8 +3,8 @@ use std::{convert::TryFrom, env, ops, path::Path, process::Command}; use anyhow::{bail, format_err, Result}; +use arena::{Arena, Idx}; use paths::{AbsPath, AbsPathBuf}; -use ra_arena::{Arena, Idx}; use crate::utf8_stdout; From 208b7bd7ba687fb570feb1b89219f14c63712ce8 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 12 Aug 2020 16:32:36 +0200 Subject: [PATCH 068/119] Rename ra_prof -> profile --- Cargo.lock | 42 +++++----- crates/{ra_prof => profile}/Cargo.toml | 14 ++-- .../src/google_cpu_profiler.rs | 0 crates/{ra_prof => profile}/src/hprof.rs | 21 +++-- crates/{ra_prof => profile}/src/lib.rs | 12 +-- .../{ra_prof => profile}/src/memory_usage.rs | 0 crates/{ra_prof => profile}/src/stop_watch.rs | 0 crates/{ra_prof => profile}/src/tree.rs | 0 crates/ra_assists/Cargo.toml | 2 +- .../src/handlers/add_missing_impl_members.rs | 2 +- crates/ra_assists/src/handlers/auto_import.rs | 3 +- crates/ra_db/Cargo.toml | 2 +- crates/ra_db/src/lib.rs | 3 +- crates/ra_hir/Cargo.toml | 2 +- crates/ra_hir/src/code_model.rs | 3 +- crates/ra_hir/src/semantics.rs | 5 +- crates/ra_hir/src/semantics/source_to_def.rs | 5 +- crates/ra_hir_def/Cargo.toml | 2 +- crates/ra_hir_def/src/body.rs | 3 +- crates/ra_hir_def/src/data.rs | 3 +- crates/ra_hir_def/src/db.rs | 3 +- crates/ra_hir_def/src/find_path.rs | 5 +- crates/ra_hir_def/src/generics.rs | 3 +- crates/ra_hir_def/src/import_map.rs | 4 +- crates/ra_hir_def/src/item_tree.rs | 2 +- crates/ra_hir_def/src/lang_item.rs | 7 +- crates/ra_hir_def/src/nameres.rs | 3 +- crates/ra_hir_expand/Cargo.toml | 2 +- crates/ra_hir_expand/src/db.rs | 3 +- crates/ra_hir_ty/Cargo.toml | 2 +- crates/ra_hir_ty/src/db.rs | 3 +- crates/ra_hir_ty/src/diagnostics.rs | 3 +- crates/ra_hir_ty/src/infer.rs | 3 +- crates/ra_hir_ty/src/method_resolution.rs | 5 +- crates/ra_hir_ty/src/traits.rs | 3 +- crates/ra_hir_ty/src/traits/chalk.rs | 2 +- crates/ra_ide/Cargo.toml | 2 +- crates/ra_ide/src/diagnostics.rs | 3 +- crates/ra_ide/src/inlay_hints.rs | 3 +- crates/ra_ide/src/lib.rs | 2 +- crates/ra_ide/src/references.rs | 3 +- crates/ra_ide/src/status.rs | 2 +- crates/ra_ide/src/syntax_highlighting.rs | 3 +- crates/ra_ide_db/Cargo.toml | 2 +- crates/ra_ide_db/src/change.rs | 8 +- crates/ra_ide_db/src/defs.rs | 5 +- crates/ra_ide_db/src/imports_locator.rs | 5 +- crates/ra_ide_db/src/search.rs | 5 +- crates/ra_ide_db/src/symbol_index.rs | 5 +- crates/rust-analyzer/Cargo.toml | 2 +- crates/rust-analyzer/src/bin/main.rs | 2 +- crates/rust-analyzer/src/cli.rs | 3 +- .../rust-analyzer/src/cli/analysis_bench.rs | 2 +- .../rust-analyzer/src/cli/analysis_stats.rs | 2 +- crates/rust-analyzer/src/global_state.rs | 3 +- crates/rust-analyzer/src/handlers.rs | 77 +++++++++---------- crates/rust-analyzer/src/lib.rs | 10 +-- crates/rust-analyzer/src/main_loop.rs | 5 +- crates/rust-analyzer/src/reload.rs | 7 +- .../tests/heavy_tests/support.rs | 2 +- xtask/tests/tidy.rs | 2 +- 61 files changed, 154 insertions(+), 188 deletions(-) rename crates/{ra_prof => profile}/Cargo.toml (90%) rename crates/{ra_prof => profile}/src/google_cpu_profiler.rs (100%) rename crates/{ra_prof => profile}/src/hprof.rs (94%) rename crates/{ra_prof => profile}/src/lib.rs (91%) rename crates/{ra_prof => profile}/src/memory_usage.rs (100%) rename crates/{ra_prof => profile}/src/stop_watch.rs (100%) rename crates/{ra_prof => profile}/src/tree.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index ab1698b11a..c2a0457c76 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -894,6 +894,18 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "profile" +version = "0.0.0" +dependencies = [ + "arena", + "backtrace", + "cfg-if", + "libc", + "once_cell", + "perf-event", +] + [[package]] name = "quote" version = "1.0.7" @@ -909,11 +921,11 @@ version = "0.1.0" dependencies = [ "either", "itertools", + "profile", "ra_db", "ra_fmt", "ra_hir", "ra_ide_db", - "ra_prof", "ra_syntax", "ra_text_edit", "rustc-hash", @@ -935,8 +947,8 @@ dependencies = [ name = "ra_db" version = "0.1.0" dependencies = [ + "profile", "ra_cfg", - "ra_prof", "ra_syntax", "ra_tt", "rustc-hash", @@ -962,11 +974,11 @@ dependencies = [ "either", "itertools", "log", + "profile", "ra_db", "ra_hir_def", "ra_hir_expand", "ra_hir_ty", - "ra_prof", "ra_syntax", "rustc-hash", "stdx", @@ -986,11 +998,11 @@ dependencies = [ "itertools", "log", "once_cell", + "profile", "ra_cfg", "ra_db", "ra_hir_expand", "ra_mbe", - "ra_prof", "ra_syntax", "ra_tt", "rustc-hash", @@ -1006,10 +1018,10 @@ dependencies = [ "arena", "either", "log", + "profile", "ra_db", "ra_mbe", "ra_parser", - "ra_prof", "ra_syntax", "ra_tt", "rustc-hash", @@ -1029,10 +1041,10 @@ dependencies = [ "expect", "itertools", "log", + "profile", "ra_db", "ra_hir_def", "ra_hir_expand", - "ra_prof", "ra_syntax", "rustc-hash", "scoped-tls", @@ -1054,13 +1066,13 @@ dependencies = [ "itertools", "log", "oorandom", + "profile", "ra_assists", "ra_cfg", "ra_db", "ra_fmt", "ra_hir", "ra_ide_db", - "ra_prof", "ra_ssr", "ra_syntax", "ra_text_edit", @@ -1077,9 +1089,9 @@ dependencies = [ "fst", "log", "once_cell", + "profile", "ra_db", "ra_hir", - "ra_prof", "ra_syntax", "ra_text_edit", "rayon", @@ -1137,18 +1149,6 @@ dependencies = [ "test_utils", ] -[[package]] -name = "ra_prof" -version = "0.1.0" -dependencies = [ - "arena", - "backtrace", - "cfg-if", - "libc", - "once_cell", - "perf-event", -] - [[package]] name = "ra_project_model" version = "0.1.0" @@ -1314,6 +1314,7 @@ dependencies = [ "oorandom", "parking_lot", "pico-args", + "profile", "ra_cfg", "ra_db", "ra_hir", @@ -1323,7 +1324,6 @@ dependencies = [ "ra_ide_db", "ra_mbe", "ra_proc_macro_srv", - "ra_prof", "ra_project_model", "ra_ssr", "ra_syntax", diff --git a/crates/ra_prof/Cargo.toml b/crates/profile/Cargo.toml similarity index 90% rename from crates/ra_prof/Cargo.toml rename to crates/profile/Cargo.toml index 9880c587f2..e271e3a567 100644 --- a/crates/ra_prof/Cargo.toml +++ b/crates/profile/Cargo.toml @@ -1,20 +1,20 @@ [package] -edition = "2018" -name = "ra_prof" -version = "0.1.0" -authors = ["rust-analyzer developers"] -publish = false +name = "profile" +version = "0.0.0" license = "MIT OR Apache-2.0" +authors = ["rust-analyzer developers"] +edition = "2018" [lib] doctest = false [dependencies] -arena = { path = "../arena" } once_cell = "1.3.1" -backtrace = { version = "0.3.44", optional = true } cfg-if = "0.1.10" libc = "0.2.73" +backtrace = { version = "0.3.44", optional = true } + +arena = { path = "../arena" } [target.'cfg(target_os = "linux")'.dependencies] perf-event = "0.4" diff --git a/crates/ra_prof/src/google_cpu_profiler.rs b/crates/profile/src/google_cpu_profiler.rs similarity index 100% rename from crates/ra_prof/src/google_cpu_profiler.rs rename to crates/profile/src/google_cpu_profiler.rs diff --git a/crates/ra_prof/src/hprof.rs b/crates/profile/src/hprof.rs similarity index 94% rename from crates/ra_prof/src/hprof.rs rename to crates/profile/src/hprof.rs index a3f5321fb3..934cc8e37a 100644 --- a/crates/ra_prof/src/hprof.rs +++ b/crates/profile/src/hprof.rs @@ -37,19 +37,16 @@ pub type Label = &'static str; /// /// # Example /// ``` -/// use ra_prof::{profile, set_filter, Filter}; -/// -/// let f = Filter::from_spec("profile1|profile2@2"); -/// set_filter(f); +/// profile::init_from("profile1|profile2@2"); /// profiling_function1(); /// /// fn profiling_function1() { -/// let _p = profile("profile1"); +/// let _p = profile::span("profile1"); /// profiling_function2(); /// } /// /// fn profiling_function2() { -/// let _p = profile("profile2"); +/// let _p = profile::span("profile2"); /// } /// ``` /// This will print in the stderr the following: @@ -57,27 +54,27 @@ pub type Label = &'static str; /// 0ms - profile /// 0ms - profile2 /// ``` -pub fn profile(label: Label) -> Profiler { +pub fn span(label: Label) -> ProfileSpan { assert!(!label.is_empty()); if PROFILING_ENABLED.load(Ordering::Relaxed) && PROFILE_STACK.with(|stack| stack.borrow_mut().push(label)) { - Profiler(Some(ProfilerImpl { label, detail: None })) + ProfileSpan(Some(ProfilerImpl { label, detail: None })) } else { - Profiler(None) + ProfileSpan(None) } } -pub struct Profiler(Option); +pub struct ProfileSpan(Option); struct ProfilerImpl { label: Label, detail: Option, } -impl Profiler { - pub fn detail(mut self, detail: impl FnOnce() -> String) -> Profiler { +impl ProfileSpan { + pub fn detail(mut self, detail: impl FnOnce() -> String) -> ProfileSpan { if let Some(profiler) = &mut self.0 { profiler.detail = Some(detail()) } diff --git a/crates/ra_prof/src/lib.rs b/crates/profile/src/lib.rs similarity index 91% rename from crates/ra_prof/src/lib.rs rename to crates/profile/src/lib.rs index eb50965ae6..ab19271c70 100644 --- a/crates/ra_prof/src/lib.rs +++ b/crates/profile/src/lib.rs @@ -10,7 +10,7 @@ mod tree; use std::cell::RefCell; pub use crate::{ - hprof::{init, init_from, profile}, + hprof::{init, init_from, span}, memory_usage::{Bytes, MemoryUsage}, stop_watch::{StopWatch, StopWatchSpan}, }; @@ -25,7 +25,7 @@ pub fn print_backtrace() { pub fn print_backtrace() { eprintln!( r#"enable the backtrace feature: - ra_prof = {{ path = "../ra_prof", features = [ "backtrace"] }} + profile = {{ path = "../profile", features = [ "backtrace"] }} "# ); } @@ -76,12 +76,12 @@ impl Drop for Scope { /// /// https://github.com/rust-analyzer/rust-analyzer/pull/5306 #[derive(Debug)] -pub struct CpuProfiler { +pub struct CpuSpan { _private: (), } #[must_use] -pub fn cpu_profiler() -> CpuProfiler { +pub fn cpu_span() -> CpuSpan { #[cfg(feature = "cpu_profiler")] { google_cpu_profiler::start("./out.profile".as_ref()) @@ -92,10 +92,10 @@ pub fn cpu_profiler() -> CpuProfiler { eprintln!("cpu_profiler feature is disabled") } - CpuProfiler { _private: () } + CpuSpan { _private: () } } -impl Drop for CpuProfiler { +impl Drop for CpuSpan { fn drop(&mut self) { #[cfg(feature = "cpu_profiler")] { diff --git a/crates/ra_prof/src/memory_usage.rs b/crates/profile/src/memory_usage.rs similarity index 100% rename from crates/ra_prof/src/memory_usage.rs rename to crates/profile/src/memory_usage.rs diff --git a/crates/ra_prof/src/stop_watch.rs b/crates/profile/src/stop_watch.rs similarity index 100% rename from crates/ra_prof/src/stop_watch.rs rename to crates/profile/src/stop_watch.rs diff --git a/crates/ra_prof/src/tree.rs b/crates/profile/src/tree.rs similarity index 100% rename from crates/ra_prof/src/tree.rs rename to crates/profile/src/tree.rs diff --git a/crates/ra_assists/Cargo.toml b/crates/ra_assists/Cargo.toml index bd2905f080..6f5ace941f 100644 --- a/crates/ra_assists/Cargo.toml +++ b/crates/ra_assists/Cargo.toml @@ -18,7 +18,7 @@ stdx = { path = "../stdx" } ra_syntax = { path = "../ra_syntax" } ra_text_edit = { path = "../ra_text_edit" } ra_fmt = { path = "../ra_fmt" } -ra_prof = { path = "../ra_prof" } +profile = { path = "../profile" } ra_db = { path = "../ra_db" } ra_ide_db = { path = "../ra_ide_db" } hir = { path = "../ra_hir", package = "ra_hir" } diff --git a/crates/ra_assists/src/handlers/add_missing_impl_members.rs b/crates/ra_assists/src/handlers/add_missing_impl_members.rs index 95a750aeec..dd1406228c 100644 --- a/crates/ra_assists/src/handlers/add_missing_impl_members.rs +++ b/crates/ra_assists/src/handlers/add_missing_impl_members.rs @@ -110,7 +110,7 @@ fn add_missing_impl_members_inner( assist_id: &'static str, label: &'static str, ) -> Option<()> { - let _p = ra_prof::profile("add_missing_impl_members_inner"); + let _p = profile::span("add_missing_impl_members_inner"); let impl_def = ctx.find_node_at_offset::()?; let impl_item_list = impl_def.assoc_item_list()?; diff --git a/crates/ra_assists/src/handlers/auto_import.rs b/crates/ra_assists/src/handlers/auto_import.rs index 01e7b7a44c..6ec59ec4d4 100644 --- a/crates/ra_assists/src/handlers/auto_import.rs +++ b/crates/ra_assists/src/handlers/auto_import.rs @@ -6,7 +6,6 @@ use hir::{ Type, }; use ra_ide_db::{imports_locator, RootDatabase}; -use ra_prof::profile; use ra_syntax::{ ast::{self, AstNode}, SyntaxNode, @@ -130,7 +129,7 @@ impl AutoImportAssets { } fn search_for_imports(&self, ctx: &AssistContext) -> BTreeSet { - let _p = profile("auto_import::search_for_imports"); + let _p = profile::span("auto_import::search_for_imports"); let db = ctx.db(); let current_crate = self.module_with_name_to_import.krate(); imports_locator::find_imports(&ctx.sema, current_crate, &self.get_search_query()) diff --git a/crates/ra_db/Cargo.toml b/crates/ra_db/Cargo.toml index fe73dc0157..9cb9ba11c7 100644 --- a/crates/ra_db/Cargo.toml +++ b/crates/ra_db/Cargo.toml @@ -14,7 +14,7 @@ rustc-hash = "1.1.0" ra_syntax = { path = "../ra_syntax" } ra_cfg = { path = "../ra_cfg" } -ra_prof = { path = "../ra_prof" } +profile = { path = "../profile" } ra_tt = { path = "../ra_tt" } test_utils = { path = "../test_utils" } vfs = { path = "../vfs" } diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs index f25be24fe2..795d7d2b61 100644 --- a/crates/ra_db/src/lib.rs +++ b/crates/ra_db/src/lib.rs @@ -5,7 +5,6 @@ pub mod fixture; use std::{panic, sync::Arc}; -use ra_prof::profile; use ra_syntax::{ast, Parse, SourceFile, TextRange, TextSize}; use rustc_hash::FxHashSet; @@ -113,7 +112,7 @@ pub trait SourceDatabase: CheckCanceled + FileLoader + std::fmt::Debug { } fn parse_query(db: &dyn SourceDatabase, file_id: FileId) -> Parse { - let _p = profile("parse_query").detail(|| format!("{:?}", file_id)); + let _p = profile::span("parse_query").detail(|| format!("{:?}", file_id)); let text = db.file_text(file_id); SourceFile::parse(&*text) } diff --git a/crates/ra_hir/Cargo.toml b/crates/ra_hir/Cargo.toml index c260bb193c..903406e849 100644 --- a/crates/ra_hir/Cargo.toml +++ b/crates/ra_hir/Cargo.toml @@ -19,7 +19,7 @@ itertools = "0.9.0" stdx = { path = "../stdx" } ra_syntax = { path = "../ra_syntax" } ra_db = { path = "../ra_db" } -ra_prof = { path = "../ra_prof" } +profile = { path = "../profile" } hir_expand = { path = "../ra_hir_expand", package = "ra_hir_expand" } hir_def = { path = "../ra_hir_def", package = "ra_hir_def" } hir_ty = { path = "../ra_hir_ty", package = "ra_hir_ty" } diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 0007d7fa88..5c0c6184a7 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs @@ -31,7 +31,6 @@ use hir_ty::{ InEnvironment, Substs, TraitEnvironment, Ty, TyDefId, TypeCtor, }; use ra_db::{CrateId, Edition, FileId}; -use ra_prof::profile; use ra_syntax::{ ast::{self, AttrsOwner, NameOwner}, AstNode, @@ -304,7 +303,7 @@ impl Module { } pub fn diagnostics(self, db: &dyn HirDatabase, sink: &mut DiagnosticSink) { - let _p = profile("Module::diagnostics"); + let _p = profile::span("Module::diagnostics"); let crate_def_map = db.crate_def_map(self.id.krate); crate_def_map.add_diagnostics(db.upcast(), self.id.local_id, sink); for decl in self.declarations(db) { diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs index 36b688ccb6..7e3ec6315e 100644 --- a/crates/ra_hir/src/semantics.rs +++ b/crates/ra_hir/src/semantics.rs @@ -12,7 +12,6 @@ use hir_expand::{hygiene::Hygiene, name::AsName, ExpansionInfo}; use hir_ty::associated_type_shorthand_candidates; use itertools::Itertools; use ra_db::{FileId, FileRange}; -use ra_prof::profile; use ra_syntax::{ algo::{find_node_at_offset, skip_trivia_token}, ast, AstNode, Direction, SyntaxNode, SyntaxToken, TextRange, TextSize, @@ -334,7 +333,7 @@ impl<'db> SemanticsImpl<'db> { } fn descend_into_macros(&self, token: SyntaxToken) -> SyntaxToken { - let _p = profile("descend_into_macros"); + let _p = profile::span("descend_into_macros"); let parent = token.parent(); let parent = self.find_file(parent); let sa = self.analyze2(parent.as_ref(), None); @@ -523,7 +522,7 @@ impl<'db> SemanticsImpl<'db> { } fn analyze2(&self, src: InFile<&SyntaxNode>, offset: Option) -> SourceAnalyzer { - let _p = profile("Semantics::analyze2"); + let _p = profile::span("Semantics::analyze2"); let container = match self.with_ctx(|ctx| ctx.find_container(src)) { Some(it) => it, diff --git a/crates/ra_hir/src/semantics/source_to_def.rs b/crates/ra_hir/src/semantics/source_to_def.rs index 863e8e5ff7..a6ff8b0bfc 100644 --- a/crates/ra_hir/src/semantics/source_to_def.rs +++ b/crates/ra_hir/src/semantics/source_to_def.rs @@ -10,7 +10,6 @@ use hir_def::{ }; use hir_expand::{name::AsName, AstId, MacroDefKind}; use ra_db::FileId; -use ra_prof::profile; use ra_syntax::{ ast::{self, NameOwner}, match_ast, AstNode, SyntaxNode, @@ -29,7 +28,7 @@ pub(super) struct SourceToDefCtx<'a, 'b> { impl SourceToDefCtx<'_, '_> { pub(super) fn file_to_def(&mut self, file: FileId) -> Option { - let _p = profile("SourceBinder::to_module_def"); + let _p = profile::span("SourceBinder::to_module_def"); let (krate, local_id) = self.db.relevant_crates(file).iter().find_map(|&crate_id| { let crate_def_map = self.db.crate_def_map(crate_id); let local_id = crate_def_map.modules_for_file(file).next()?; @@ -39,7 +38,7 @@ impl SourceToDefCtx<'_, '_> { } pub(super) fn module_to_def(&mut self, src: InFile) -> Option { - let _p = profile("module_to_def"); + let _p = profile::span("module_to_def"); let parent_declaration = src .as_ref() .map(|it| it.syntax()) diff --git a/crates/ra_hir_def/Cargo.toml b/crates/ra_hir_def/Cargo.toml index 6dd6fdde60..adfd8c7b71 100644 --- a/crates/ra_hir_def/Cargo.toml +++ b/crates/ra_hir_def/Cargo.toml @@ -25,7 +25,7 @@ stdx = { path = "../stdx" } arena = { path = "../arena" } ra_db = { path = "../ra_db" } ra_syntax = { path = "../ra_syntax" } -ra_prof = { path = "../ra_prof" } +profile = { path = "../profile" } hir_expand = { path = "../ra_hir_expand", package = "ra_hir_expand" } test_utils = { path = "../test_utils" } mbe = { path = "../ra_mbe", package = "ra_mbe" } diff --git a/crates/ra_hir_def/src/body.rs b/crates/ra_hir_def/src/body.rs index cb178655b4..1deb1a8371 100644 --- a/crates/ra_hir_def/src/body.rs +++ b/crates/ra_hir_def/src/body.rs @@ -11,7 +11,6 @@ use either::Either; use hir_expand::{ast_id_map::AstIdMap, hygiene::Hygiene, AstId, HirFileId, InFile, MacroDefId}; use ra_cfg::CfgOptions; use ra_db::CrateId; -use ra_prof::profile; use ra_syntax::{ast, AstNode, AstPtr}; use rustc_hash::FxHashMap; use test_utils::mark; @@ -228,7 +227,7 @@ impl Body { db: &dyn DefDatabase, def: DefWithBodyId, ) -> (Arc, Arc) { - let _p = profile("body_with_source_map_query"); + let _p = profile::span("body_with_source_map_query"); let mut params = None; let (file_id, module, body) = match def { diff --git a/crates/ra_hir_def/src/data.rs b/crates/ra_hir_def/src/data.rs index 88a8ef9bff..758c12f331 100644 --- a/crates/ra_hir_def/src/data.rs +++ b/crates/ra_hir_def/src/data.rs @@ -3,7 +3,6 @@ use std::sync::Arc; use hir_expand::{name::Name, InFile}; -use ra_prof::profile; use ra_syntax::ast; use crate::{ @@ -133,7 +132,7 @@ pub struct ImplData { impl ImplData { pub(crate) fn impl_data_query(db: &dyn DefDatabase, id: ImplId) -> Arc { - let _p = profile("impl_data_query"); + let _p = profile::span("impl_data_query"); let impl_loc = id.lookup(db); let item_tree = db.item_tree(impl_loc.id.file_id); diff --git a/crates/ra_hir_def/src/db.rs b/crates/ra_hir_def/src/db.rs index 9c3ede2d79..1dd4197f85 100644 --- a/crates/ra_hir_def/src/db.rs +++ b/crates/ra_hir_def/src/db.rs @@ -3,7 +3,6 @@ use std::sync::Arc; use hir_expand::{db::AstDatabase, HirFileId}; use ra_db::{salsa, CrateId, SourceDatabase, Upcast}; -use ra_prof::profile; use ra_syntax::SmolStr; use crate::{ @@ -116,6 +115,6 @@ pub trait DefDatabase: InternDatabase + AstDatabase + Upcast { } fn crate_def_map_wait(db: &impl DefDatabase, krate: CrateId) -> Arc { - let _p = profile("crate_def_map:wait"); + let _p = profile::span("crate_def_map:wait"); db.crate_def_map_query(krate) } diff --git a/crates/ra_hir_def/src/find_path.rs b/crates/ra_hir_def/src/find_path.rs index 06701a8309..46e70eb48a 100644 --- a/crates/ra_hir_def/src/find_path.rs +++ b/crates/ra_hir_def/src/find_path.rs @@ -1,7 +1,6 @@ //! An algorithm to find a path to refer to a certain item. use hir_expand::name::{known, AsName, Name}; -use ra_prof::profile; use rustc_hash::FxHashSet; use test_utils::mark; @@ -18,7 +17,7 @@ use crate::{ /// Find a path that can be used to refer to a certain item. This can depend on /// *from where* you're referring to the item, hence the `from` parameter. pub fn find_path(db: &dyn DefDatabase, item: ItemInNs, from: ModuleId) -> Option { - let _p = profile("find_path"); + let _p = profile::span("find_path"); find_path_inner(db, item, from, MAX_PATH_LEN) } @@ -215,7 +214,7 @@ fn find_local_import_locations( item: ItemInNs, from: ModuleId, ) -> Vec<(ModuleId, Name)> { - let _p = profile("find_local_import_locations"); + let _p = profile::span("find_local_import_locations"); // `from` can import anything below `from` with visibility of at least `from`, and anything // above `from` with any visibility. That means we do not need to descend into private siblings diff --git a/crates/ra_hir_def/src/generics.rs b/crates/ra_hir_def/src/generics.rs index 90daa46b4c..0e06a0b12e 100644 --- a/crates/ra_hir_def/src/generics.rs +++ b/crates/ra_hir_def/src/generics.rs @@ -11,7 +11,6 @@ use hir_expand::{ InFile, }; use ra_db::FileId; -use ra_prof::profile; use ra_syntax::ast::{self, GenericParamsOwner, NameOwner, TypeBoundsOwner}; use crate::{ @@ -73,7 +72,7 @@ impl GenericParams { db: &dyn DefDatabase, def: GenericDefId, ) -> Arc { - let _p = profile("generic_params_query"); + let _p = profile::span("generic_params_query"); let generics = match def { GenericDefId::FunctionId(id) => { diff --git a/crates/ra_hir_def/src/import_map.rs b/crates/ra_hir_def/src/import_map.rs index 9e4c30b1ab..3a9eec8873 100644 --- a/crates/ra_hir_def/src/import_map.rs +++ b/crates/ra_hir_def/src/import_map.rs @@ -56,7 +56,7 @@ pub struct ImportMap { impl ImportMap { pub fn import_map_query(db: &dyn DefDatabase, krate: CrateId) -> Arc { - let _p = ra_prof::profile("import_map_query"); + let _p = profile::span("import_map_query"); let def_map = db.crate_def_map(krate); let mut import_map = Self::default(); @@ -254,7 +254,7 @@ pub fn search_dependencies<'a>( krate: CrateId, query: Query, ) -> Vec { - let _p = ra_prof::profile("search_dependencies").detail(|| format!("{:?}", query)); + let _p = profile::span("search_dependencies").detail(|| format!("{:?}", query)); let graph = db.crate_graph(); let import_maps: Vec<_> = diff --git a/crates/ra_hir_def/src/item_tree.rs b/crates/ra_hir_def/src/item_tree.rs index fc05bb3075..104966c7f2 100644 --- a/crates/ra_hir_def/src/item_tree.rs +++ b/crates/ra_hir_def/src/item_tree.rs @@ -77,7 +77,7 @@ pub struct ItemTree { impl ItemTree { pub fn item_tree_query(db: &dyn DefDatabase, file_id: HirFileId) -> Arc { - let _p = ra_prof::profile("item_tree_query").detail(|| format!("{:?}", file_id)); + let _p = profile::span("item_tree_query").detail(|| format!("{:?}", file_id)); let syntax = if let Some(node) = db.parse_or_expand(file_id) { node } else { diff --git a/crates/ra_hir_def/src/lang_item.rs b/crates/ra_hir_def/src/lang_item.rs index 3516784b8d..3631499bf7 100644 --- a/crates/ra_hir_def/src/lang_item.rs +++ b/crates/ra_hir_def/src/lang_item.rs @@ -4,7 +4,6 @@ //! features, such as Fn family of traits. use std::sync::Arc; -use ra_prof::profile; use ra_syntax::SmolStr; use rustc_hash::FxHashMap; @@ -79,7 +78,7 @@ impl LangItems { /// Salsa query. This will look for lang items in a specific crate. pub(crate) fn crate_lang_items_query(db: &dyn DefDatabase, krate: CrateId) -> Arc { - let _p = profile("crate_lang_items_query"); + let _p = profile::span("crate_lang_items_query"); let mut lang_items = LangItems::default(); @@ -98,7 +97,7 @@ impl LangItems { db: &dyn DefDatabase, module: ModuleId, ) -> Option> { - let _p = profile("module_lang_items_query"); + let _p = profile::span("module_lang_items_query"); let mut lang_items = LangItems::default(); lang_items.collect_lang_items(db, module); if lang_items.items.is_empty() { @@ -115,7 +114,7 @@ impl LangItems { start_crate: CrateId, item: SmolStr, ) -> Option { - let _p = profile("lang_item_query"); + let _p = profile::span("lang_item_query"); let lang_items = db.crate_lang_items(start_crate); let start_crate_target = lang_items.items.get(&item); if let Some(target) = start_crate_target { diff --git a/crates/ra_hir_def/src/nameres.rs b/crates/ra_hir_def/src/nameres.rs index b4b97eb086..dc239997f9 100644 --- a/crates/ra_hir_def/src/nameres.rs +++ b/crates/ra_hir_def/src/nameres.rs @@ -59,7 +59,6 @@ use std::sync::Arc; use arena::Arena; use hir_expand::{diagnostics::DiagnosticSink, name::Name, InFile}; use ra_db::{CrateId, Edition, FileId}; -use ra_prof::profile; use ra_syntax::ast; use rustc_hash::FxHashMap; use stdx::format_to; @@ -172,7 +171,7 @@ pub struct ModuleData { impl CrateDefMap { pub(crate) fn crate_def_map_query(db: &dyn DefDatabase, krate: CrateId) -> Arc { - let _p = profile("crate_def_map_query").detail(|| { + let _p = profile::span("crate_def_map_query").detail(|| { db.crate_graph()[krate] .display_name .as_ref() diff --git a/crates/ra_hir_expand/Cargo.toml b/crates/ra_hir_expand/Cargo.toml index 808c36fd8f..711a93c56b 100644 --- a/crates/ra_hir_expand/Cargo.toml +++ b/crates/ra_hir_expand/Cargo.toml @@ -17,7 +17,7 @@ arena = { path = "../arena" } ra_db = { path = "../ra_db" } ra_syntax = { path = "../ra_syntax" } ra_parser = { path = "../ra_parser" } -ra_prof = { path = "../ra_prof" } +profile = { path = "../profile" } tt = { path = "../ra_tt", package = "ra_tt" } mbe = { path = "../ra_mbe", package = "ra_mbe" } test_utils = { path = "../test_utils"} diff --git a/crates/ra_hir_expand/src/db.rs b/crates/ra_hir_expand/src/db.rs index f3b7cd492c..f30528b3e2 100644 --- a/crates/ra_hir_expand/src/db.rs +++ b/crates/ra_hir_expand/src/db.rs @@ -5,7 +5,6 @@ use std::sync::Arc; use mbe::{ExpandResult, MacroRules}; use ra_db::{salsa, SourceDatabase}; use ra_parser::FragmentKind; -use ra_prof::profile; use ra_syntax::{algo::diff, AstNode, GreenNode, Parse, SyntaxKind::*, SyntaxNode}; use crate::{ @@ -278,7 +277,7 @@ pub fn parse_macro_with_arg( macro_file: MacroFile, arg: Option>, ) -> Option<(Parse, Arc)> { - let _p = profile("parse_macro_query"); + let _p = profile::span("parse_macro_query"); let macro_call_id = macro_file.macro_call_id; let (tt, err) = if let Some(arg) = arg { diff --git a/crates/ra_hir_ty/Cargo.toml b/crates/ra_hir_ty/Cargo.toml index fc68eaa8f1..380d5e6015 100644 --- a/crates/ra_hir_ty/Cargo.toml +++ b/crates/ra_hir_ty/Cargo.toml @@ -22,7 +22,7 @@ hir_def = { path = "../ra_hir_def", package = "ra_hir_def" } hir_expand = { path = "../ra_hir_expand", package = "ra_hir_expand" } arena = { path = "../arena" } ra_db = { path = "../ra_db" } -ra_prof = { path = "../ra_prof" } +profile = { path = "../profile" } ra_syntax = { path = "../ra_syntax" } test_utils = { path = "../test_utils" } diff --git a/crates/ra_hir_ty/src/db.rs b/crates/ra_hir_ty/src/db.rs index d396017bf4..7a28673b16 100644 --- a/crates/ra_hir_ty/src/db.rs +++ b/crates/ra_hir_ty/src/db.rs @@ -8,7 +8,6 @@ use hir_def::{ TypeParamId, VariantId, }; use ra_db::{impl_intern_key, salsa, CrateId, Upcast}; -use ra_prof::profile; use crate::{ method_resolution::{InherentImpls, TraitImpls}, @@ -123,7 +122,7 @@ pub trait HirDatabase: DefDatabase + Upcast { } fn infer_wait(db: &impl HirDatabase, def: DefWithBodyId) -> Arc { - let _p = profile("infer:wait").detail(|| match def { + let _p = profile::span("infer:wait").detail(|| match def { DefWithBodyId::FunctionId(it) => db.function_data(it).name.to_string(), DefWithBodyId::StaticId(it) => { db.static_data(it).name.clone().unwrap_or_else(Name::missing).to_string() diff --git a/crates/ra_hir_ty/src/diagnostics.rs b/crates/ra_hir_ty/src/diagnostics.rs index 7ab7f79db6..55c02c1feb 100644 --- a/crates/ra_hir_ty/src/diagnostics.rs +++ b/crates/ra_hir_ty/src/diagnostics.rs @@ -8,7 +8,6 @@ use std::any::Any; use hir_def::DefWithBodyId; use hir_expand::diagnostics::{Diagnostic, DiagnosticSink}; use hir_expand::{name::Name, HirFileId, InFile}; -use ra_prof::profile; use ra_syntax::{ast, AstPtr, SyntaxNodePtr}; use stdx::format_to; @@ -17,7 +16,7 @@ use crate::db::HirDatabase; pub use crate::diagnostics::expr::{record_literal_missing_fields, record_pattern_missing_fields}; pub fn validate_body(db: &dyn HirDatabase, owner: DefWithBodyId, sink: &mut DiagnosticSink<'_>) { - let _p = profile("validate_body"); + let _p = profile::span("validate_body"); let infer = db.infer(owner); infer.add_diagnostics(db, owner, sink); let mut validator = expr::ExprValidator::new(owner, infer.clone(), sink); diff --git a/crates/ra_hir_ty/src/infer.rs b/crates/ra_hir_ty/src/infer.rs index e003690b3d..784ae1c3cc 100644 --- a/crates/ra_hir_ty/src/infer.rs +++ b/crates/ra_hir_ty/src/infer.rs @@ -31,7 +31,6 @@ use hir_def::{ TypeAliasId, VariantId, }; use hir_expand::{diagnostics::DiagnosticSink, name::name}; -use ra_prof::profile; use ra_syntax::SmolStr; use rustc_hash::FxHashMap; use stdx::impl_from; @@ -64,7 +63,7 @@ mod coerce; /// The entry point of type inference. pub(crate) fn infer_query(db: &dyn HirDatabase, def: DefWithBodyId) -> Arc { - let _p = profile("infer_query"); + let _p = profile::span("infer_query"); let resolver = def.resolver(db.upcast()); let mut ctx = InferenceContext::new(db, def, resolver); diff --git a/crates/ra_hir_ty/src/method_resolution.rs b/crates/ra_hir_ty/src/method_resolution.rs index fb4b30a131..3b3bee6a70 100644 --- a/crates/ra_hir_ty/src/method_resolution.rs +++ b/crates/ra_hir_ty/src/method_resolution.rs @@ -13,7 +13,6 @@ use hir_def::{ }; use hir_expand::name::Name; use ra_db::CrateId; -use ra_prof::profile; use rustc_hash::{FxHashMap, FxHashSet}; use super::Substs; @@ -109,7 +108,7 @@ pub struct TraitImpls { impl TraitImpls { pub(crate) fn trait_impls_in_crate_query(db: &dyn HirDatabase, krate: CrateId) -> Arc { - let _p = profile("trait_impls_in_crate_query"); + let _p = profile::span("trait_impls_in_crate_query"); let mut impls = Self { map: FxHashMap::default() }; let crate_def_map = db.crate_def_map(krate); @@ -135,7 +134,7 @@ impl TraitImpls { } pub(crate) fn trait_impls_in_deps_query(db: &dyn HirDatabase, krate: CrateId) -> Arc { - let _p = profile("trait_impls_in_deps_query"); + let _p = profile::span("trait_impls_in_deps_query"); let crate_graph = db.crate_graph(); let mut res = Self { map: FxHashMap::default() }; diff --git a/crates/ra_hir_ty/src/traits.rs b/crates/ra_hir_ty/src/traits.rs index 3f6d2cf352..2576a9dfc3 100644 --- a/crates/ra_hir_ty/src/traits.rs +++ b/crates/ra_hir_ty/src/traits.rs @@ -5,7 +5,6 @@ use chalk_ir::cast::Cast; use chalk_solve::Solver; use hir_def::{lang_item::LangItemTarget, TraitId}; use ra_db::CrateId; -use ra_prof::profile; use crate::{db::HirDatabase, DebruijnIndex, Substs}; @@ -125,7 +124,7 @@ pub(crate) fn trait_solve_query( krate: CrateId, goal: Canonical>, ) -> Option { - let _p = profile("trait_solve_query").detail(|| match &goal.value.value { + let _p = profile::span("trait_solve_query").detail(|| match &goal.value.value { Obligation::Trait(it) => db.trait_data(it.trait_).name.to_string(), Obligation::Projection(_) => "projection".to_string(), }); diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/ra_hir_ty/src/traits/chalk.rs index 1c70653644..3b6af5c9a8 100644 --- a/crates/ra_hir_ty/src/traits/chalk.rs +++ b/crates/ra_hir_ty/src/traits/chalk.rs @@ -410,7 +410,7 @@ pub(crate) fn impl_datum_query( krate: CrateId, impl_id: ImplId, ) -> Arc { - let _p = ra_prof::profile("impl_datum"); + let _p = profile::span("impl_datum"); debug!("impl_datum {:?}", impl_id); let impl_: hir_def::ImplId = from_chalk(db, impl_id); impl_def_datum(db, krate, impl_id, impl_) diff --git a/crates/ra_ide/Cargo.toml b/crates/ra_ide/Cargo.toml index f4181c4eb8..bbc9ba4e77 100644 --- a/crates/ra_ide/Cargo.toml +++ b/crates/ra_ide/Cargo.toml @@ -27,7 +27,7 @@ ra_db = { path = "../ra_db" } ra_ide_db = { path = "../ra_ide_db" } ra_cfg = { path = "../ra_cfg" } ra_fmt = { path = "../ra_fmt" } -ra_prof = { path = "../ra_prof" } +profile = { path = "../profile" } test_utils = { path = "../test_utils" } ra_assists = { path = "../ra_assists" } ra_ssr = { path = "../ra_ssr" } diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs index 1046d7ab37..07bf133bd6 100644 --- a/crates/ra_ide/src/diagnostics.rs +++ b/crates/ra_ide/src/diagnostics.rs @@ -10,7 +10,6 @@ use hir::{diagnostics::DiagnosticSinkBuilder, Semantics}; use itertools::Itertools; use ra_db::SourceDatabase; use ra_ide_db::RootDatabase; -use ra_prof::profile; use ra_syntax::{ ast::{self, AstNode}, SyntaxNode, TextRange, T, @@ -33,7 +32,7 @@ pub(crate) fn diagnostics( file_id: FileId, enable_experimental: bool, ) -> Vec { - let _p = profile("diagnostics"); + let _p = profile::span("diagnostics"); let sema = Semantics::new(db); let parse = db.parse(file_id); let mut res = Vec::new(); diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs index 1bacead63c..920b04e8d7 100644 --- a/crates/ra_ide/src/inlay_hints.rs +++ b/crates/ra_ide/src/inlay_hints.rs @@ -1,6 +1,5 @@ use hir::{Adt, Callable, HirDisplay, Semantics, Type}; use ra_ide_db::RootDatabase; -use ra_prof::profile; use ra_syntax::{ ast::{self, ArgListOwner, AstNode}, match_ast, Direction, NodeOrToken, SmolStr, SyntaxKind, TextRange, T, @@ -64,7 +63,7 @@ pub(crate) fn inlay_hints( file_id: FileId, config: &InlayHintsConfig, ) -> Vec { - let _p = profile("inlay_hints"); + let _p = profile::span("inlay_hints"); let sema = Semantics::new(db); let file = sema.parse(file_id); diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs index 89fcb6f178..bfcf5d750a 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ra_ide/src/lib.rs @@ -176,7 +176,7 @@ impl AnalysisHost { self.db.collect_garbage(); } /// NB: this clears the database - pub fn per_query_memory_usage(&mut self) -> Vec<(String, ra_prof::Bytes)> { + pub fn per_query_memory_usage(&mut self) -> Vec<(String, profile::Bytes)> { self.db.per_query_memory_usage() } pub fn request_cancellation(&mut self) { diff --git a/crates/ra_ide/src/references.rs b/crates/ra_ide/src/references.rs index 453985de3e..c4eea3a45b 100644 --- a/crates/ra_ide/src/references.rs +++ b/crates/ra_ide/src/references.rs @@ -17,7 +17,6 @@ use ra_ide_db::{ search::SearchScope, RootDatabase, }; -use ra_prof::profile; use ra_syntax::{ algo::find_node_at_offset, ast::{self, NameOwner}, @@ -90,7 +89,7 @@ pub(crate) fn find_all_refs( position: FilePosition, search_scope: Option, ) -> Option> { - let _p = profile("find_all_refs"); + let _p = profile::span("find_all_refs"); let syntax = sema.parse(position.file_id).syntax().clone(); let (opt_name, search_kind) = if let Some(name) = diff --git a/crates/ra_ide/src/status.rs b/crates/ra_ide/src/status.rs index 08e6f69cb3..009bb662f7 100644 --- a/crates/ra_ide/src/status.rs +++ b/crates/ra_ide/src/status.rs @@ -1,6 +1,7 @@ use std::{fmt, iter::FromIterator, sync::Arc}; use hir::MacroFile; +use profile::{memory_usage, Bytes}; use ra_db::{ salsa::debug::{DebugQueryTable, TableEntry}, FileTextQuery, SourceRootId, @@ -9,7 +10,6 @@ use ra_ide_db::{ symbol_index::{LibrarySymbolsQuery, SymbolIndex}, RootDatabase, }; -use ra_prof::{memory_usage, Bytes}; use ra_syntax::{ast, Parse, SyntaxNode}; use rustc_hash::FxHashMap; diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index c10e15db8b..ebdf05127a 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -9,7 +9,6 @@ use ra_ide_db::{ defs::{classify_name, classify_name_ref, Definition, NameClass, NameRefClass}, RootDatabase, }; -use ra_prof::profile; use ra_syntax::{ ast::{self, HasFormatSpecifier}, AstNode, AstToken, Direction, NodeOrToken, SyntaxElement, @@ -46,7 +45,7 @@ pub(crate) fn highlight( range_to_highlight: Option, syntactic_name_ref_highlighting: bool, ) -> Vec { - let _p = profile("highlight"); + let _p = profile::span("highlight"); let sema = Semantics::new(db); // Determine the root based on the given range. diff --git a/crates/ra_ide_db/Cargo.toml b/crates/ra_ide_db/Cargo.toml index 2716a38cc9..92b8ef82a7 100644 --- a/crates/ra_ide_db/Cargo.toml +++ b/crates/ra_ide_db/Cargo.toml @@ -24,7 +24,7 @@ stdx = { path = "../stdx" } ra_syntax = { path = "../ra_syntax" } ra_text_edit = { path = "../ra_text_edit" } ra_db = { path = "../ra_db" } -ra_prof = { path = "../ra_prof" } +profile = { path = "../profile" } test_utils = { path = "../test_utils" } # ra_ide should depend only on the top-level `hir` package. if you need diff --git a/crates/ra_ide_db/src/change.rs b/crates/ra_ide_db/src/change.rs index b13df8b855..7a4e04ca9b 100644 --- a/crates/ra_ide_db/src/change.rs +++ b/crates/ra_ide_db/src/change.rs @@ -3,11 +3,11 @@ use std::{fmt, sync::Arc, time}; +use profile::{memory_usage, Bytes}; use ra_db::{ salsa::{Database, Durability, SweepStrategy}, CrateGraph, FileId, SourceDatabase, SourceDatabaseExt, SourceRoot, SourceRootId, }; -use ra_prof::{memory_usage, profile, Bytes}; use rustc_hash::FxHashSet; use crate::{symbol_index::SymbolsDatabase, RootDatabase}; @@ -85,12 +85,12 @@ const GC_COOLDOWN: time::Duration = time::Duration::from_millis(100); impl RootDatabase { pub fn request_cancellation(&mut self) { - let _p = profile("RootDatabase::request_cancellation"); + let _p = profile::span("RootDatabase::request_cancellation"); self.salsa_runtime_mut().synthetic_write(Durability::LOW); } pub fn apply_change(&mut self, change: AnalysisChange) { - let _p = profile("RootDatabase::apply_change"); + let _p = profile::span("RootDatabase::apply_change"); self.request_cancellation(); log::info!("apply_change {:?}", change); if let Some(roots) = change.roots { @@ -141,7 +141,7 @@ impl RootDatabase { return; } - let _p = profile("RootDatabase::collect_garbage"); + let _p = profile::span("RootDatabase::collect_garbage"); self.last_gc = crate::wasm_shims::Instant::now(); let sweep = SweepStrategy::default().discard_values().sweep_all_revisions(); diff --git a/crates/ra_ide_db/src/defs.rs b/crates/ra_ide_db/src/defs.rs index 9bb95277d0..d46d1fe71b 100644 --- a/crates/ra_ide_db/src/defs.rs +++ b/crates/ra_ide_db/src/defs.rs @@ -9,7 +9,6 @@ use hir::{ db::HirDatabase, Crate, Field, HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef, Name, PathResolution, Semantics, TypeParam, Visibility, }; -use ra_prof::profile; use ra_syntax::{ ast::{self, AstNode}, match_ast, SyntaxNode, @@ -110,7 +109,7 @@ impl NameClass { } pub fn classify_name(sema: &Semantics, name: &ast::Name) -> Option { - let _p = profile("classify_name"); + let _p = profile::span("classify_name"); let parent = name.syntax().parent()?; @@ -249,7 +248,7 @@ pub fn classify_name_ref( sema: &Semantics, name_ref: &ast::NameRef, ) -> Option { - let _p = profile("classify_name_ref"); + let _p = profile::span("classify_name_ref"); let parent = name_ref.syntax().parent()?; diff --git a/crates/ra_ide_db/src/imports_locator.rs b/crates/ra_ide_db/src/imports_locator.rs index 9e040973b3..d510ce3b76 100644 --- a/crates/ra_ide_db/src/imports_locator.rs +++ b/crates/ra_ide_db/src/imports_locator.rs @@ -2,7 +2,6 @@ //! Later, this should be moved away to a separate crate that is accessible from the ra_assists module. use hir::{Crate, MacroDef, ModuleDef, Semantics}; -use ra_prof::profile; use ra_syntax::{ast, AstNode, SyntaxKind::NAME}; use crate::{ @@ -18,7 +17,7 @@ pub fn find_imports<'a>( krate: Crate, name_to_import: &str, ) -> Vec> { - let _p = profile("search_for_imports"); + let _p = profile::span("search_for_imports"); let db = sema.db; // Query dependencies first. @@ -51,7 +50,7 @@ fn get_name_definition<'a>( sema: &Semantics<'a, RootDatabase>, import_candidate: &FileSymbol, ) -> Option { - let _p = profile("get_name_definition"); + let _p = profile::span("get_name_definition"); let file_id = import_candidate.file_id; let candidate_node = import_candidate.ptr.to_node(sema.parse(file_id).syntax()); diff --git a/crates/ra_ide_db/src/search.rs b/crates/ra_ide_db/src/search.rs index 0b862b449f..d90b830d0c 100644 --- a/crates/ra_ide_db/src/search.rs +++ b/crates/ra_ide_db/src/search.rs @@ -9,7 +9,6 @@ use std::{convert::TryInto, mem}; use hir::{DefWithBody, HasSource, Module, ModuleSource, Semantics, Visibility}; use once_cell::unsync::Lazy; use ra_db::{FileId, FileRange, SourceDatabaseExt}; -use ra_prof::profile; use ra_syntax::{ast, match_ast, AstNode, TextRange, TextSize}; use rustc_hash::FxHashMap; @@ -107,7 +106,7 @@ impl IntoIterator for SearchScope { impl Definition { fn search_scope(&self, db: &RootDatabase) -> SearchScope { - let _p = profile("search_scope"); + let _p = profile::span("search_scope"); let module = match self.module(db) { Some(it) => it, None => return SearchScope::empty(), @@ -187,7 +186,7 @@ impl Definition { sema: &Semantics, search_scope: Option, ) -> Vec { - let _p = profile("Definition::find_usages"); + let _p = profile::span("Definition::find_usages"); let search_scope = { let base = self.search_scope(sema.db); diff --git a/crates/ra_ide_db/src/symbol_index.rs b/crates/ra_ide_db/src/symbol_index.rs index 35a2c5be3b..6ca8bb5169 100644 --- a/crates/ra_ide_db/src/symbol_index.rs +++ b/crates/ra_ide_db/src/symbol_index.rs @@ -34,7 +34,6 @@ use ra_db::{ salsa::{self, ParallelDatabase}, CrateId, FileId, SourceDatabaseExt, SourceRootId, }; -use ra_prof::profile; use ra_syntax::{ ast::{self, NameOwner}, match_ast, AstNode, Parse, SmolStr, SourceFile, @@ -101,7 +100,7 @@ pub trait SymbolsDatabase: hir::db::HirDatabase + SourceDatabaseExt { } fn library_symbols(db: &dyn SymbolsDatabase) -> Arc> { - let _p = profile("library_symbols"); + let _p = profile::span("library_symbols"); let roots = db.library_roots(); let res = roots @@ -162,7 +161,7 @@ impl Clone for Snap> { // | VS Code | kbd:[Ctrl+T] // |=== pub fn world_symbols(db: &RootDatabase, query: Query) -> Vec { - let _p = ra_prof::profile("world_symbols").detail(|| query.query.clone()); + let _p = profile::span("world_symbols").detail(|| query.query.clone()); let tmp1; let tmp2; diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index 02c1371ac0..6cbf43bb2e 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml @@ -36,7 +36,7 @@ stdx = { path = "../stdx" } lsp-server = "0.3.3" flycheck = { path = "../flycheck" } ra_ide = { path = "../ra_ide" } -ra_prof = { path = "../ra_prof" } +profile = { path = "../profile" } ra_project_model = { path = "../ra_project_model" } ra_syntax = { path = "../ra_syntax" } ra_text_edit = { path = "../ra_text_edit" } diff --git a/crates/rust-analyzer/src/bin/main.rs b/crates/rust-analyzer/src/bin/main.rs index fc7f8b01d2..9622d71c06 100644 --- a/crates/rust-analyzer/src/bin/main.rs +++ b/crates/rust-analyzer/src/bin/main.rs @@ -55,7 +55,7 @@ fn try_main() -> Result<()> { fn setup_logging() -> Result<()> { std::env::set_var("RUST_BACKTRACE", "short"); env_logger::try_init_from_env("RA_LOG")?; - ra_prof::init(); + profile::init(); Ok(()) } diff --git a/crates/rust-analyzer/src/cli.rs b/crates/rust-analyzer/src/cli.rs index 1034d11bd8..46d70fcb2a 100644 --- a/crates/rust-analyzer/src/cli.rs +++ b/crates/rust-analyzer/src/cli.rs @@ -11,7 +11,6 @@ use std::io::Read; use anyhow::Result; use ra_ide::Analysis; -use ra_prof::profile; use ra_syntax::{AstNode, SourceFile}; pub use analysis_bench::{BenchCmd, BenchWhat, Position}; @@ -38,7 +37,7 @@ impl Verbosity { } pub fn parse(no_dump: bool) -> Result<()> { - let _p = profile("parsing"); + let _p = profile::span("parsing"); let file = file()?; if !no_dump { println!("{:#?}", file.syntax()); diff --git a/crates/rust-analyzer/src/cli/analysis_bench.rs b/crates/rust-analyzer/src/cli/analysis_bench.rs index c54ee5f4de..bc5f77e1a9 100644 --- a/crates/rust-analyzer/src/cli/analysis_bench.rs +++ b/crates/rust-analyzer/src/cli/analysis_bench.rs @@ -52,7 +52,7 @@ impl FromStr for Position { impl BenchCmd { pub fn run(self, verbosity: Verbosity) -> Result<()> { - ra_prof::init(); + profile::init(); let start = Instant::now(); eprint!("loading: "); diff --git a/crates/rust-analyzer/src/cli/analysis_stats.rs b/crates/rust-analyzer/src/cli/analysis_stats.rs index 0d386841e5..a30c1ec798 100644 --- a/crates/rust-analyzer/src/cli/analysis_stats.rs +++ b/crates/rust-analyzer/src/cli/analysis_stats.rs @@ -29,7 +29,7 @@ use crate::{ }, print_memory_usage, }; -use ra_prof::StopWatch; +use profile::StopWatch; /// Need to wrap Snapshot to provide `Clone` impl for `map_with` struct Snap(DB); diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs index 658a50d150..8c115c8a67 100644 --- a/crates/rust-analyzer/src/global_state.rs +++ b/crates/rust-analyzer/src/global_state.rs @@ -27,7 +27,6 @@ use crate::{ to_proto::url_from_abs_path, Result, }; -use ra_prof::profile; #[derive(Eq, PartialEq, Copy, Clone)] pub(crate) enum Status { @@ -135,7 +134,7 @@ impl GlobalState { } pub(crate) fn process_changes(&mut self) -> bool { - let _p = profile("GlobalState::process_changes"); + let _p = profile::span("GlobalState::process_changes"); let mut fs_changes = Vec::new(); let mut has_fs_changes = false; diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index 785dd2a267..d9b75eed45 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs @@ -22,7 +22,6 @@ use ra_ide::{ FileId, FilePosition, FileRange, HoverAction, HoverGotoTypeData, NavigationTarget, Query, RangeInfo, Runnable, RunnableKind, SearchScope, TextEdit, }; -use ra_prof::profile; use ra_project_model::TargetKind; use ra_syntax::{algo, ast, AstNode, SyntaxKind, TextRange, TextSize}; use serde::{Deserialize, Serialize}; @@ -39,7 +38,7 @@ use crate::{ }; pub(crate) fn handle_analyzer_status(snap: GlobalStateSnapshot, _: ()) -> Result { - let _p = profile("handle_analyzer_status"); + let _p = profile::span("handle_analyzer_status"); let mut buf = String::new(); if snap.workspaces.is_empty() { @@ -64,7 +63,7 @@ pub(crate) fn handle_analyzer_status(snap: GlobalStateSnapshot, _: ()) -> Result } pub(crate) fn handle_memory_usage(state: &mut GlobalState, _: ()) -> Result { - let _p = profile("handle_memory_usage"); + let _p = profile::span("handle_memory_usage"); let mem = state.analysis_host.per_query_memory_usage(); let mut out = String::new(); @@ -78,7 +77,7 @@ pub(crate) fn handle_syntax_tree( snap: GlobalStateSnapshot, params: lsp_ext::SyntaxTreeParams, ) -> Result { - let _p = profile("handle_syntax_tree"); + let _p = profile::span("handle_syntax_tree"); let id = from_proto::file_id(&snap, ¶ms.text_document.uri)?; let line_index = snap.analysis.file_line_index(id)?; let text_range = params.range.map(|r| from_proto::text_range(&line_index, r)); @@ -90,7 +89,7 @@ pub(crate) fn handle_expand_macro( snap: GlobalStateSnapshot, params: lsp_ext::ExpandMacroParams, ) -> Result> { - let _p = profile("handle_expand_macro"); + let _p = profile::span("handle_expand_macro"); let file_id = from_proto::file_id(&snap, ¶ms.text_document.uri)?; let line_index = snap.analysis.file_line_index(file_id)?; let offset = from_proto::offset(&line_index, params.position); @@ -103,7 +102,7 @@ pub(crate) fn handle_selection_range( snap: GlobalStateSnapshot, params: lsp_types::SelectionRangeParams, ) -> Result>> { - let _p = profile("handle_selection_range"); + let _p = profile::span("handle_selection_range"); let file_id = from_proto::file_id(&snap, ¶ms.text_document.uri)?; let line_index = snap.analysis.file_line_index(file_id)?; let res: Result> = params @@ -146,7 +145,7 @@ pub(crate) fn handle_matching_brace( snap: GlobalStateSnapshot, params: lsp_ext::MatchingBraceParams, ) -> Result> { - let _p = profile("handle_matching_brace"); + let _p = profile::span("handle_matching_brace"); let file_id = from_proto::file_id(&snap, ¶ms.text_document.uri)?; let line_index = snap.analysis.file_line_index(file_id)?; let res = params @@ -168,7 +167,7 @@ pub(crate) fn handle_join_lines( snap: GlobalStateSnapshot, params: lsp_ext::JoinLinesParams, ) -> Result> { - let _p = profile("handle_join_lines"); + let _p = profile::span("handle_join_lines"); let file_id = from_proto::file_id(&snap, ¶ms.text_document.uri)?; let line_index = snap.analysis.file_line_index(file_id)?; let line_endings = snap.file_line_endings(file_id); @@ -191,7 +190,7 @@ pub(crate) fn handle_on_enter( snap: GlobalStateSnapshot, params: lsp_types::TextDocumentPositionParams, ) -> Result>> { - let _p = profile("handle_on_enter"); + let _p = profile::span("handle_on_enter"); let position = from_proto::file_position(&snap, params)?; let edit = match snap.analysis.on_enter(position)? { None => return Ok(None), @@ -208,7 +207,7 @@ pub(crate) fn handle_on_type_formatting( snap: GlobalStateSnapshot, params: lsp_types::DocumentOnTypeFormattingParams, ) -> Result>> { - let _p = profile("handle_on_type_formatting"); + let _p = profile::span("handle_on_type_formatting"); let mut position = from_proto::file_position(&snap, params.text_document_position)?; let line_index = snap.analysis.file_line_index(position.file_id)?; let line_endings = snap.file_line_endings(position.file_id); @@ -247,7 +246,7 @@ pub(crate) fn handle_document_symbol( snap: GlobalStateSnapshot, params: lsp_types::DocumentSymbolParams, ) -> Result> { - let _p = profile("handle_document_symbol"); + let _p = profile::span("handle_document_symbol"); let file_id = from_proto::file_id(&snap, ¶ms.text_document.uri)?; let line_index = snap.analysis.file_line_index(file_id)?; @@ -332,7 +331,7 @@ pub(crate) fn handle_workspace_symbol( snap: GlobalStateSnapshot, params: lsp_types::WorkspaceSymbolParams, ) -> Result>> { - let _p = profile("handle_workspace_symbol"); + let _p = profile::span("handle_workspace_symbol"); let all_symbols = params.query.contains('#'); let libs = params.query.contains('*'); let query = { @@ -380,7 +379,7 @@ pub(crate) fn handle_goto_definition( snap: GlobalStateSnapshot, params: lsp_types::GotoDefinitionParams, ) -> Result> { - let _p = profile("handle_goto_definition"); + let _p = profile::span("handle_goto_definition"); let position = from_proto::file_position(&snap, params.text_document_position_params)?; let nav_info = match snap.analysis.goto_definition(position)? { None => return Ok(None), @@ -395,7 +394,7 @@ pub(crate) fn handle_goto_implementation( snap: GlobalStateSnapshot, params: lsp_types::request::GotoImplementationParams, ) -> Result> { - let _p = profile("handle_goto_implementation"); + let _p = profile::span("handle_goto_implementation"); let position = from_proto::file_position(&snap, params.text_document_position_params)?; let nav_info = match snap.analysis.goto_implementation(position)? { None => return Ok(None), @@ -410,7 +409,7 @@ pub(crate) fn handle_goto_type_definition( snap: GlobalStateSnapshot, params: lsp_types::request::GotoTypeDefinitionParams, ) -> Result> { - let _p = profile("handle_goto_type_definition"); + let _p = profile::span("handle_goto_type_definition"); let position = from_proto::file_position(&snap, params.text_document_position_params)?; let nav_info = match snap.analysis.goto_type_definition(position)? { None => return Ok(None), @@ -425,7 +424,7 @@ pub(crate) fn handle_parent_module( snap: GlobalStateSnapshot, params: lsp_types::TextDocumentPositionParams, ) -> Result> { - let _p = profile("handle_parent_module"); + let _p = profile::span("handle_parent_module"); let position = from_proto::file_position(&snap, params)?; let navs = snap.analysis.parent_module(position)?; let res = to_proto::goto_definition_response(&snap, None, navs)?; @@ -436,7 +435,7 @@ pub(crate) fn handle_runnables( snap: GlobalStateSnapshot, params: lsp_ext::RunnablesParams, ) -> Result> { - let _p = profile("handle_runnables"); + let _p = profile::span("handle_runnables"); let file_id = from_proto::file_id(&snap, ¶ms.text_document.uri)?; let line_index = snap.analysis.file_line_index(file_id)?; let offset = params.position.map(|it| from_proto::offset(&line_index, it)); @@ -513,7 +512,7 @@ pub(crate) fn handle_completion( snap: GlobalStateSnapshot, params: lsp_types::CompletionParams, ) -> Result> { - let _p = profile("handle_completion"); + let _p = profile::span("handle_completion"); let position = from_proto::file_position(&snap, params.text_document_position)?; let completion_triggered_after_single_colon = { let mut res = false; @@ -555,7 +554,7 @@ pub(crate) fn handle_folding_range( snap: GlobalStateSnapshot, params: FoldingRangeParams, ) -> Result>> { - let _p = profile("handle_folding_range"); + let _p = profile::span("handle_folding_range"); let file_id = from_proto::file_id(&snap, ¶ms.text_document.uri)?; let folds = snap.analysis.folding_ranges(file_id)?; let text = snap.analysis.file_text(file_id)?; @@ -572,7 +571,7 @@ pub(crate) fn handle_signature_help( snap: GlobalStateSnapshot, params: lsp_types::SignatureHelpParams, ) -> Result> { - let _p = profile("handle_signature_help"); + let _p = profile::span("handle_signature_help"); let position = from_proto::file_position(&snap, params.text_document_position_params)?; let call_info = match snap.analysis.call_info(position)? { Some(it) => it, @@ -591,7 +590,7 @@ pub(crate) fn handle_hover( snap: GlobalStateSnapshot, params: lsp_types::HoverParams, ) -> Result> { - let _p = profile("handle_hover"); + let _p = profile::span("handle_hover"); let position = from_proto::file_position(&snap, params.text_document_position_params)?; let info = match snap.analysis.hover(position)? { None => return Ok(None), @@ -614,7 +613,7 @@ pub(crate) fn handle_prepare_rename( snap: GlobalStateSnapshot, params: lsp_types::TextDocumentPositionParams, ) -> Result> { - let _p = profile("handle_prepare_rename"); + let _p = profile::span("handle_prepare_rename"); let position = from_proto::file_position(&snap, params)?; let optional_change = snap.analysis.rename(position, "dummy")?; @@ -632,7 +631,7 @@ pub(crate) fn handle_rename( snap: GlobalStateSnapshot, params: RenameParams, ) -> Result> { - let _p = profile("handle_rename"); + let _p = profile::span("handle_rename"); let position = from_proto::file_position(&snap, params.text_document_position)?; if params.new_name.is_empty() { @@ -656,7 +655,7 @@ pub(crate) fn handle_references( snap: GlobalStateSnapshot, params: lsp_types::ReferenceParams, ) -> Result>> { - let _p = profile("handle_references"); + let _p = profile::span("handle_references"); let position = from_proto::file_position(&snap, params.text_document_position)?; let refs = match snap.analysis.find_all_refs(position, None)? { @@ -683,7 +682,7 @@ pub(crate) fn handle_formatting( snap: GlobalStateSnapshot, params: DocumentFormattingParams, ) -> Result>> { - let _p = profile("handle_formatting"); + let _p = profile::span("handle_formatting"); let file_id = from_proto::file_id(&snap, ¶ms.text_document.uri)?; let file = snap.analysis.file_text(file_id)?; let crate_ids = snap.analysis.crate_for(file_id)?; @@ -805,7 +804,7 @@ pub(crate) fn handle_code_action( mut snap: GlobalStateSnapshot, params: lsp_types::CodeActionParams, ) -> Result>> { - let _p = profile("handle_code_action"); + let _p = profile::span("handle_code_action"); // We intentionally don't support command-based actions, as those either // requires custom client-code anyway, or requires server-initiated edits. // Server initiated edits break causality, so we avoid those as well. @@ -847,7 +846,7 @@ pub(crate) fn handle_resolve_code_action( mut snap: GlobalStateSnapshot, params: lsp_ext::ResolveCodeActionParams, ) -> Result> { - let _p = profile("handle_resolve_code_action"); + let _p = profile::span("handle_resolve_code_action"); let file_id = from_proto::file_id(&snap, ¶ms.code_action_params.text_document.uri)?; let line_index = snap.analysis.file_line_index(file_id)?; let range = from_proto::text_range(&line_index, params.code_action_params.range); @@ -871,7 +870,7 @@ pub(crate) fn handle_code_lens( snap: GlobalStateSnapshot, params: lsp_types::CodeLensParams, ) -> Result>> { - let _p = profile("handle_code_lens"); + let _p = profile::span("handle_code_lens"); let mut lenses: Vec = Default::default(); if snap.config.lens.none() { @@ -957,7 +956,7 @@ pub(crate) fn handle_code_lens_resolve( snap: GlobalStateSnapshot, code_lens: CodeLens, ) -> Result { - let _p = profile("handle_code_lens_resolve"); + let _p = profile::span("handle_code_lens_resolve"); let data = code_lens.data.unwrap(); let resolve = from_json::>("CodeLensResolveData", data)?; match resolve { @@ -994,7 +993,7 @@ pub(crate) fn handle_document_highlight( snap: GlobalStateSnapshot, params: lsp_types::DocumentHighlightParams, ) -> Result>> { - let _p = profile("handle_document_highlight"); + let _p = profile::span("handle_document_highlight"); let position = from_proto::file_position(&snap, params.text_document_position_params)?; let line_index = snap.analysis.file_line_index(position.file_id)?; @@ -1021,7 +1020,7 @@ pub(crate) fn handle_ssr( snap: GlobalStateSnapshot, params: lsp_ext::SsrParams, ) -> Result { - let _p = profile("handle_ssr"); + let _p = profile::span("handle_ssr"); let selections = params .selections .iter() @@ -1041,7 +1040,7 @@ pub(crate) fn publish_diagnostics( snap: &GlobalStateSnapshot, file_id: FileId, ) -> Result> { - let _p = profile("publish_diagnostics"); + let _p = profile::span("publish_diagnostics"); let line_index = snap.analysis.file_line_index(file_id)?; let diagnostics: Vec = snap .analysis @@ -1064,7 +1063,7 @@ pub(crate) fn handle_inlay_hints( snap: GlobalStateSnapshot, params: InlayHintsParams, ) -> Result> { - let _p = profile("handle_inlay_hints"); + let _p = profile::span("handle_inlay_hints"); let file_id = from_proto::file_id(&snap, ¶ms.text_document.uri)?; let line_index = snap.analysis.file_line_index(file_id)?; Ok(snap @@ -1079,7 +1078,7 @@ pub(crate) fn handle_call_hierarchy_prepare( snap: GlobalStateSnapshot, params: CallHierarchyPrepareParams, ) -> Result>> { - let _p = profile("handle_call_hierarchy_prepare"); + let _p = profile::span("handle_call_hierarchy_prepare"); let position = from_proto::file_position(&snap, params.text_document_position_params)?; let nav_info = match snap.analysis.call_hierarchy(position)? { @@ -1101,7 +1100,7 @@ pub(crate) fn handle_call_hierarchy_incoming( snap: GlobalStateSnapshot, params: CallHierarchyIncomingCallsParams, ) -> Result>> { - let _p = profile("handle_call_hierarchy_incoming"); + let _p = profile::span("handle_call_hierarchy_incoming"); let item = params.item; let doc = TextDocumentIdentifier::new(item.uri); @@ -1136,7 +1135,7 @@ pub(crate) fn handle_call_hierarchy_outgoing( snap: GlobalStateSnapshot, params: CallHierarchyOutgoingCallsParams, ) -> Result>> { - let _p = profile("handle_call_hierarchy_outgoing"); + let _p = profile::span("handle_call_hierarchy_outgoing"); let item = params.item; let doc = TextDocumentIdentifier::new(item.uri); @@ -1171,7 +1170,7 @@ pub(crate) fn handle_semantic_tokens( snap: GlobalStateSnapshot, params: SemanticTokensParams, ) -> Result> { - let _p = profile("handle_semantic_tokens"); + let _p = profile::span("handle_semantic_tokens"); let file_id = from_proto::file_id(&snap, ¶ms.text_document.uri)?; let text = snap.analysis.file_text(file_id)?; @@ -1190,7 +1189,7 @@ pub(crate) fn handle_semantic_tokens_edits( snap: GlobalStateSnapshot, params: SemanticTokensEditsParams, ) -> Result> { - let _p = profile("handle_semantic_tokens_edits"); + let _p = profile::span("handle_semantic_tokens_edits"); let file_id = from_proto::file_id(&snap, ¶ms.text_document.uri)?; let text = snap.analysis.file_text(file_id)?; @@ -1220,7 +1219,7 @@ pub(crate) fn handle_semantic_tokens_range( snap: GlobalStateSnapshot, params: SemanticTokensRangeParams, ) -> Result> { - let _p = profile("handle_semantic_tokens_range"); + let _p = profile::span("handle_semantic_tokens_range"); let frange = from_proto::file_range(&snap, params.text_document, params.range)?; let text = snap.analysis.file_text(frange.file_id)?; diff --git a/crates/rust-analyzer/src/lib.rs b/crates/rust-analyzer/src/lib.rs index ed37992cd3..8d2e76cc24 100644 --- a/crates/rust-analyzer/src/lib.rs +++ b/crates/rust-analyzer/src/lib.rs @@ -74,16 +74,16 @@ impl std::error::Error for LspError {} fn print_memory_usage(mut host: AnalysisHost, vfs: Vfs) { let mut mem = host.per_query_memory_usage(); - let before = ra_prof::memory_usage(); + let before = profile::memory_usage(); drop(vfs); - let vfs = before.allocated - ra_prof::memory_usage().allocated; + let vfs = before.allocated - profile::memory_usage().allocated; mem.push(("VFS".into(), vfs)); - let before = ra_prof::memory_usage(); + let before = profile::memory_usage(); drop(host); - mem.push(("Unaccounted".into(), before.allocated - ra_prof::memory_usage().allocated)); + mem.push(("Unaccounted".into(), before.allocated - profile::memory_usage().allocated)); - mem.push(("Remaining".into(), ra_prof::memory_usage().allocated)); + mem.push(("Remaining".into(), profile::memory_usage().allocated)); for (name, bytes) in mem { eprintln!("{:>8} {}", bytes, name); diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index e6cf46df23..32962b0885 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs @@ -10,7 +10,6 @@ use lsp_server::{Connection, Notification, Request, Response}; use lsp_types::notification::Notification as _; use ra_db::VfsPath; use ra_ide::{Canceled, FileId}; -use ra_prof::profile; use crate::{ config::Config, @@ -173,7 +172,7 @@ impl GlobalState { fn handle_event(&mut self, event: Event) -> Result<()> { let loop_start = Instant::now(); // NOTE: don't count blocking select! call as a loop-turn time - let _p = profile("GlobalState::handle_event"); + let _p = profile::span("GlobalState::handle_event"); log::info!("handle_event({:?})", event); let queue_count = self.task_pool.handle.len(); @@ -204,7 +203,7 @@ impl GlobalState { self.analysis_host.maybe_collect_garbage(); } Event::Vfs(mut task) => { - let _p = profile("GlobalState::handle_event/vfs"); + let _p = profile::span("GlobalState::handle_event/vfs"); loop { match task { vfs::loader::Message::Loaded { files } => { diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs index 1907f2f132..f74f2c02c8 100644 --- a/crates/rust-analyzer/src/reload.rs +++ b/crates/rust-analyzer/src/reload.rs @@ -4,7 +4,6 @@ use std::{mem, sync::Arc}; use flycheck::FlycheckHandle; use ra_db::{CrateGraph, SourceRoot, VfsPath}; use ra_ide::AnalysisChange; -use ra_prof::profile; use ra_project_model::{ProcMacroClient, ProjectWorkspace}; use vfs::{file_set::FileSetConfig, AbsPath, AbsPathBuf, ChangeKind}; @@ -17,7 +16,7 @@ use crate::{ impl GlobalState { pub(crate) fn update_configuration(&mut self, config: Config) { - let _p = profile("GlobalState::update_configuration"); + let _p = profile::span("GlobalState::update_configuration"); let old_config = mem::replace(&mut self.config, config); if self.config.lru_capacity != old_config.lru_capacity { self.analysis_host.update_lru_capacity(old_config.lru_capacity); @@ -115,7 +114,7 @@ impl GlobalState { }); } pub(crate) fn switch_workspaces(&mut self, workspaces: Vec>) { - let _p = profile("GlobalState::switch_workspaces"); + let _p = profile::span("GlobalState::switch_workspaces"); log::info!("reloading projects: {:?}", self.config.linked_projects); let mut has_errors = false; @@ -300,7 +299,7 @@ pub(crate) struct SourceRootConfig { impl SourceRootConfig { pub(crate) fn partition(&self, vfs: &vfs::Vfs) -> Vec { - let _p = profile("SourceRootConfig::partition"); + let _p = profile::span("SourceRootConfig::partition"); self.fsc .partition(vfs) .into_iter() diff --git a/crates/rust-analyzer/tests/heavy_tests/support.rs b/crates/rust-analyzer/tests/heavy_tests/support.rs index f242c8165c..15866fbb16 100644 --- a/crates/rust-analyzer/tests/heavy_tests/support.rs +++ b/crates/rust-analyzer/tests/heavy_tests/support.rs @@ -62,7 +62,7 @@ impl<'a> Project<'a> { static INIT: Once = Once::new(); INIT.call_once(|| { env_logger::builder().is_test(true).try_init().unwrap(); - ra_prof::init_from(crate::PROFILE); + profile::init_from(crate::PROFILE); }); for entry in Fixture::parse(self.fixture) { diff --git a/xtask/tests/tidy.rs b/xtask/tests/tidy.rs index 4ff72865e8..7384205db4 100644 --- a/xtask/tests/tidy.rs +++ b/xtask/tests/tidy.rs @@ -197,7 +197,7 @@ impl TidyDocs { "ra_ide", "ra_mbe", "ra_parser", - "ra_prof", + "profile", "ra_project_model", "ra_syntax", "ra_tt", From 550d7fbe3cbf2af4a47fca6c9bbefaf798cd7b7b Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 12 Aug 2020 16:46:20 +0200 Subject: [PATCH 069/119] Rename ra_tt -> tt --- Cargo.lock | 32 ++++++++--------- crates/ra_cfg/Cargo.toml | 2 +- crates/ra_db/Cargo.toml | 2 +- crates/ra_db/src/input.rs | 4 +-- crates/ra_hir_def/Cargo.toml | 2 +- crates/ra_hir_expand/Cargo.toml | 2 +- crates/ra_mbe/Cargo.toml | 2 +- crates/ra_mbe/src/lib.rs | 2 +- crates/ra_proc_macro/Cargo.toml | 2 +- crates/ra_proc_macro/src/lib.rs | 17 +++++---- crates/ra_proc_macro/src/msg.rs | 3 +- crates/ra_proc_macro/src/process.rs | 38 ++++++++++---------- crates/ra_proc_macro/src/rpc.rs | 13 +++---- crates/ra_proc_macro_srv/Cargo.toml | 2 +- crates/ra_proc_macro_srv/src/dylib.rs | 6 ++-- crates/ra_proc_macro_srv/src/lib.rs | 2 +- crates/ra_proc_macro_srv/src/rustc_server.rs | 8 ++--- crates/rust-analyzer/Cargo.toml | 2 +- crates/{ra_tt => tt}/Cargo.toml | 11 +++--- crates/{ra_tt => tt}/src/buffer.rs | 0 crates/{ra_tt => tt}/src/lib.rs | 0 xtask/tests/tidy.rs | 2 +- 22 files changed, 77 insertions(+), 77 deletions(-) rename crates/{ra_tt => tt}/Cargo.toml (90%) rename crates/{ra_tt => tt}/src/buffer.rs (100%) rename crates/{ra_tt => tt}/src/lib.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index c2a0457c76..598b739c7e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -939,8 +939,8 @@ version = "0.1.0" dependencies = [ "ra_mbe", "ra_syntax", - "ra_tt", "rustc-hash", + "tt", ] [[package]] @@ -950,11 +950,11 @@ dependencies = [ "profile", "ra_cfg", "ra_syntax", - "ra_tt", "rustc-hash", "salsa", "stdx", "test_utils", + "tt", "vfs", ] @@ -1004,11 +1004,11 @@ dependencies = [ "ra_hir_expand", "ra_mbe", "ra_syntax", - "ra_tt", "rustc-hash", "smallvec", "stdx", "test_utils", + "tt", ] [[package]] @@ -1023,9 +1023,9 @@ dependencies = [ "ra_mbe", "ra_parser", "ra_syntax", - "ra_tt", "rustc-hash", "test_utils", + "tt", ] [[package]] @@ -1107,10 +1107,10 @@ dependencies = [ "log", "ra_parser", "ra_syntax", - "ra_tt", "rustc-hash", "smallvec", "test_utils", + "tt", ] [[package]] @@ -1127,9 +1127,9 @@ dependencies = [ "crossbeam-channel", "jod-thread", "log", - "ra_tt", "serde", "serde_json", + "tt", ] [[package]] @@ -1144,9 +1144,9 @@ dependencies = [ "ra_mbe", "ra_proc_macro", "ra_toolchain", - "ra_tt", "serde_derive", "test_utils", + "tt", ] [[package]] @@ -1217,14 +1217,6 @@ dependencies = [ "home", ] -[[package]] -name = "ra_tt" -version = "0.1.0" -dependencies = [ - "smol_str", - "stdx", -] - [[package]] name = "rayon" version = "1.3.1" @@ -1329,7 +1321,6 @@ dependencies = [ "ra_syntax", "ra_text_edit", "ra_toolchain", - "ra_tt", "rayon", "rustc-hash", "serde", @@ -1337,6 +1328,7 @@ dependencies = [ "stdx", "test_utils", "threadpool", + "tt", "vfs", "vfs-notify", "winapi 0.3.9", @@ -1706,6 +1698,14 @@ dependencies = [ "tracing-subscriber", ] +[[package]] +name = "tt" +version = "0.0.0" +dependencies = [ + "smol_str", + "stdx", +] + [[package]] name = "ungrammar" version = "1.1.1" diff --git a/crates/ra_cfg/Cargo.toml b/crates/ra_cfg/Cargo.toml index 6425cd6d6f..770a407428 100644 --- a/crates/ra_cfg/Cargo.toml +++ b/crates/ra_cfg/Cargo.toml @@ -12,7 +12,7 @@ doctest = false rustc-hash = "1.1.0" ra_syntax = { path = "../ra_syntax" } -tt = { path = "../ra_tt", package = "ra_tt" } +tt = { path = "../tt" } [dev-dependencies] mbe = { path = "../ra_mbe", package = "ra_mbe" } diff --git a/crates/ra_db/Cargo.toml b/crates/ra_db/Cargo.toml index 9cb9ba11c7..47a0f6248f 100644 --- a/crates/ra_db/Cargo.toml +++ b/crates/ra_db/Cargo.toml @@ -15,7 +15,7 @@ rustc-hash = "1.1.0" ra_syntax = { path = "../ra_syntax" } ra_cfg = { path = "../ra_cfg" } profile = { path = "../profile" } -ra_tt = { path = "../ra_tt" } +tt = { path = "../tt" } test_utils = { path = "../test_utils" } vfs = { path = "../vfs" } stdx = { path = "../stdx" } diff --git a/crates/ra_db/src/input.rs b/crates/ra_db/src/input.rs index 6f2e5cfc76..02a1abee0f 100644 --- a/crates/ra_db/src/input.rs +++ b/crates/ra_db/src/input.rs @@ -10,8 +10,8 @@ use std::{fmt, iter::FromIterator, ops, str::FromStr, sync::Arc}; use ra_cfg::CfgOptions; use ra_syntax::SmolStr; -use ra_tt::TokenExpander; use rustc_hash::{FxHashMap, FxHashSet}; +use tt::TokenExpander; use vfs::file_set::FileSet; pub use vfs::FileId; @@ -156,7 +156,7 @@ impl CrateGraph { display_name: Option, cfg_options: CfgOptions, env: Env, - proc_macro: Vec<(SmolStr, Arc)>, + proc_macro: Vec<(SmolStr, Arc)>, ) -> CrateId { let proc_macro = proc_macro.into_iter().map(|(name, it)| ProcMacro { name, expander: it }).collect(); diff --git a/crates/ra_hir_def/Cargo.toml b/crates/ra_hir_def/Cargo.toml index adfd8c7b71..1a080a8b4b 100644 --- a/crates/ra_hir_def/Cargo.toml +++ b/crates/ra_hir_def/Cargo.toml @@ -30,7 +30,7 @@ hir_expand = { path = "../ra_hir_expand", package = "ra_hir_expand" } test_utils = { path = "../test_utils" } mbe = { path = "../ra_mbe", package = "ra_mbe" } ra_cfg = { path = "../ra_cfg" } -tt = { path = "../ra_tt", package = "ra_tt" } +tt = { path = "../tt" } [dev-dependencies] expect = { path = "../expect" } diff --git a/crates/ra_hir_expand/Cargo.toml b/crates/ra_hir_expand/Cargo.toml index 711a93c56b..7d8ccd56fc 100644 --- a/crates/ra_hir_expand/Cargo.toml +++ b/crates/ra_hir_expand/Cargo.toml @@ -18,6 +18,6 @@ ra_db = { path = "../ra_db" } ra_syntax = { path = "../ra_syntax" } ra_parser = { path = "../ra_parser" } profile = { path = "../profile" } -tt = { path = "../ra_tt", package = "ra_tt" } +tt = { path = "../tt" } mbe = { path = "../ra_mbe", package = "ra_mbe" } test_utils = { path = "../test_utils"} diff --git a/crates/ra_mbe/Cargo.toml b/crates/ra_mbe/Cargo.toml index a26746a194..23315910c4 100644 --- a/crates/ra_mbe/Cargo.toml +++ b/crates/ra_mbe/Cargo.toml @@ -11,7 +11,7 @@ doctest = false [dependencies] ra_syntax = { path = "../ra_syntax" } ra_parser = { path = "../ra_parser" } -tt = { path = "../ra_tt", package = "ra_tt" } +tt = { path = "../tt" } rustc-hash = "1.1.0" smallvec = "1.2.0" log = "0.4.8" diff --git a/crates/ra_mbe/src/lib.rs b/crates/ra_mbe/src/lib.rs index dec7ba22ea..f854ca09ab 100644 --- a/crates/ra_mbe/src/lib.rs +++ b/crates/ra_mbe/src/lib.rs @@ -1,5 +1,5 @@ //! `mbe` (short for Macro By Example) crate contains code for handling -//! `macro_rules` macros. It uses `TokenTree` (from `ra_tt` package) as the +//! `macro_rules` macros. It uses `TokenTree` (from `tt` package) as the //! interface, although it contains some code to bridge `SyntaxNode`s and //! `TokenTree`s as well! diff --git a/crates/ra_proc_macro/Cargo.toml b/crates/ra_proc_macro/Cargo.toml index c4b6e9e7ba..d2d1bc228d 100644 --- a/crates/ra_proc_macro/Cargo.toml +++ b/crates/ra_proc_macro/Cargo.toml @@ -10,7 +10,7 @@ license = "MIT OR Apache-2.0" doctest = false [dependencies] -ra_tt = { path = "../ra_tt" } +tt = { path = "../tt" } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" log = "0.4.8" diff --git a/crates/ra_proc_macro/src/lib.rs b/crates/ra_proc_macro/src/lib.rs index 004943b9e0..15db57eb28 100644 --- a/crates/ra_proc_macro/src/lib.rs +++ b/crates/ra_proc_macro/src/lib.rs @@ -9,8 +9,6 @@ mod rpc; mod process; pub mod msg; -use process::{ProcMacroProcessSrv, ProcMacroProcessThread}; -use ra_tt::{SmolStr, Subtree}; use std::{ ffi::OsStr, io, @@ -18,6 +16,10 @@ use std::{ sync::Arc, }; +use tt::{SmolStr, Subtree}; + +use crate::process::{ProcMacroProcessSrv, ProcMacroProcessThread}; + pub use rpc::{ExpansionResult, ExpansionTask, ListMacrosResult, ListMacrosTask, ProcMacroKind}; #[derive(Debug, Clone)] @@ -36,12 +38,12 @@ impl PartialEq for ProcMacroProcessExpander { } } -impl ra_tt::TokenExpander for ProcMacroProcessExpander { +impl tt::TokenExpander for ProcMacroProcessExpander { fn expand( &self, subtree: &Subtree, _attr: Option<&Subtree>, - ) -> Result { + ) -> Result { self.process.custom_derive(&self.dylib_path, subtree, &self.name) } } @@ -72,10 +74,7 @@ impl ProcMacroClient { ProcMacroClient { kind: ProcMacroClientKind::Dummy } } - pub fn by_dylib_path( - &self, - dylib_path: &Path, - ) -> Vec<(SmolStr, Arc)> { + pub fn by_dylib_path(&self, dylib_path: &Path) -> Vec<(SmolStr, Arc)> { match &self.kind { ProcMacroClientKind::Dummy => vec![], ProcMacroClientKind::Process { process, .. } => { @@ -94,7 +93,7 @@ impl ProcMacroClient { match kind { ProcMacroKind::CustomDerive => { let name = SmolStr::new(&name); - let expander: Arc = + let expander: Arc = Arc::new(ProcMacroProcessExpander { process: process.clone(), name: name.clone(), diff --git a/crates/ra_proc_macro/src/msg.rs b/crates/ra_proc_macro/src/msg.rs index 95d9b8804e..f84ebdbc57 100644 --- a/crates/ra_proc_macro/src/msg.rs +++ b/crates/ra_proc_macro/src/msg.rs @@ -5,11 +5,12 @@ use std::{ io::{self, BufRead, Write}, }; +use serde::{de::DeserializeOwned, Deserialize, Serialize}; + use crate::{ rpc::{ListMacrosResult, ListMacrosTask}, ExpansionResult, ExpansionTask, }; -use serde::{de::DeserializeOwned, Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize, Clone)] pub enum Request { diff --git a/crates/ra_proc_macro/src/process.rs b/crates/ra_proc_macro/src/process.rs index 37dd3f4965..51ffcaa786 100644 --- a/crates/ra_proc_macro/src/process.rs +++ b/crates/ra_proc_macro/src/process.rs @@ -1,21 +1,22 @@ //! Handle process life-time and message passing for proc-macro client -use crossbeam_channel::{bounded, Receiver, Sender}; -use ra_tt::Subtree; - -use crate::msg::{ErrorCode, Message, Request, Response, ResponseError}; -use crate::rpc::{ExpansionResult, ExpansionTask, ListMacrosResult, ListMacrosTask, ProcMacroKind}; - -use io::{BufRead, BufReader}; use std::{ convert::{TryFrom, TryInto}, ffi::{OsStr, OsString}, - io::{self, Write}, + io::{self, BufRead, BufReader, Write}, path::{Path, PathBuf}, process::{Child, Command, Stdio}, sync::{Arc, Weak}, }; +use crossbeam_channel::{bounded, Receiver, Sender}; +use tt::Subtree; + +use crate::{ + msg::{ErrorCode, Message, Request, Response, ResponseError}, + rpc::{ExpansionResult, ExpansionTask, ListMacrosResult, ListMacrosTask, ProcMacroKind}, +}; + #[derive(Debug, Default)] pub(crate) struct ProcMacroProcessSrv { inner: Option>>, @@ -50,7 +51,7 @@ impl ProcMacroProcessSrv { pub fn find_proc_macros( &self, dylib_path: &Path, - ) -> Result, ra_tt::ExpansionError> { + ) -> Result, tt::ExpansionError> { let task = ListMacrosTask { lib: dylib_path.to_path_buf() }; let result: ListMacrosResult = self.send_task(Request::ListMacro(task))?; @@ -62,7 +63,7 @@ impl ProcMacroProcessSrv { dylib_path: &Path, subtree: &Subtree, derive_name: &str, - ) -> Result { + ) -> Result { let task = ExpansionTask { macro_body: subtree.clone(), macro_name: derive_name.to_string(), @@ -74,38 +75,35 @@ impl ProcMacroProcessSrv { Ok(result.expansion) } - pub fn send_task(&self, req: Request) -> Result + pub fn send_task(&self, req: Request) -> Result where R: TryFrom, { let sender = match &self.inner { - None => return Err(ra_tt::ExpansionError::Unknown("No sender is found.".to_string())), + None => return Err(tt::ExpansionError::Unknown("No sender is found.".to_string())), Some(it) => it, }; let (result_tx, result_rx) = bounded(0); let sender = match sender.upgrade() { None => { - return Err(ra_tt::ExpansionError::Unknown("Proc macro process is closed.".into())) + return Err(tt::ExpansionError::Unknown("Proc macro process is closed.".into())) } Some(it) => it, }; sender.send(Task { req, result_tx }).unwrap(); let res = result_rx .recv() - .map_err(|_| ra_tt::ExpansionError::Unknown("Proc macro thread is closed.".into()))?; + .map_err(|_| tt::ExpansionError::Unknown("Proc macro thread is closed.".into()))?; match res { Some(Response::Error(err)) => { - return Err(ra_tt::ExpansionError::ExpansionError(err.message)); + return Err(tt::ExpansionError::ExpansionError(err.message)); } Some(res) => Ok(res.try_into().map_err(|err| { - ra_tt::ExpansionError::Unknown(format!( - "Fail to get response, reason : {:#?} ", - err - )) + tt::ExpansionError::Unknown(format!("Fail to get response, reason : {:#?} ", err)) })?), - None => Err(ra_tt::ExpansionError::Unknown("Empty result".into())), + None => Err(tt::ExpansionError::Unknown("Empty result".into())), } } } diff --git a/crates/ra_proc_macro/src/rpc.rs b/crates/ra_proc_macro/src/rpc.rs index 4ce4859263..5e5d78d067 100644 --- a/crates/ra_proc_macro/src/rpc.rs +++ b/crates/ra_proc_macro/src/rpc.rs @@ -1,17 +1,18 @@ //! Data struture serialization related stuff for RPC //! //! Defines all necessary rpc serialization data structures, -//! which includes `ra_tt` related data and some task messages. -//! Although adding `Serialize` and `Deserialize` traits to `ra_tt` directly seems -//! to be much easier, we deliberately duplicate `ra_tt` structs with `#[serde(with = "XXDef")]` +//! which includes `tt` related data and some task messages. +//! Although adding `Serialize` and `Deserialize` traits to `tt` directly seems +//! to be much easier, we deliberately duplicate `tt` structs with `#[serde(with = "XXDef")]` //! for separation of code responsibility. -use ra_tt::{ +use std::path::PathBuf; + +use serde::{Deserialize, Serialize}; +use tt::{ Delimiter, DelimiterKind, Ident, Leaf, Literal, Punct, SmolStr, Spacing, Subtree, TokenId, TokenTree, }; -use serde::{Deserialize, Serialize}; -use std::path::PathBuf; #[derive(Clone, Eq, PartialEq, Debug, Serialize, Deserialize)] pub struct ListMacrosTask { diff --git a/crates/ra_proc_macro_srv/Cargo.toml b/crates/ra_proc_macro_srv/Cargo.toml index bc119a6c71..a690cc0443 100644 --- a/crates/ra_proc_macro_srv/Cargo.toml +++ b/crates/ra_proc_macro_srv/Cargo.toml @@ -10,7 +10,7 @@ license = "MIT OR Apache-2.0" doctest = false [dependencies] -ra_tt = { path = "../ra_tt" } +tt = { path = "../tt" } ra_mbe = { path = "../ra_mbe" } ra_proc_macro = { path = "../ra_proc_macro" } goblin = "0.2.1" diff --git a/crates/ra_proc_macro_srv/src/dylib.rs b/crates/ra_proc_macro_srv/src/dylib.rs index 1addbbd54f..9b6cc91ef9 100644 --- a/crates/ra_proc_macro_srv/src/dylib.rs +++ b/crates/ra_proc_macro_srv/src/dylib.rs @@ -128,9 +128,9 @@ impl Expander { pub fn expand( &self, macro_name: &str, - macro_body: &ra_tt::Subtree, - attributes: Option<&ra_tt::Subtree>, - ) -> Result { + macro_body: &tt::Subtree, + attributes: Option<&tt::Subtree>, + ) -> Result { let parsed_body = TokenStream::with_subtree(macro_body.clone()); let parsed_attributes = attributes diff --git a/crates/ra_proc_macro_srv/src/lib.rs b/crates/ra_proc_macro_srv/src/lib.rs index 922bb84bbf..1fc2eef82e 100644 --- a/crates/ra_proc_macro_srv/src/lib.rs +++ b/crates/ra_proc_macro_srv/src/lib.rs @@ -5,7 +5,7 @@ //! //! But we adapt it to better fit RA needs: //! -//! * We use `ra_tt` for proc-macro `TokenStream` server, it is easier to manipulate and interact with +//! * We use `tt` for proc-macro `TokenStream` server, it is easier to manipulate and interact with //! RA than `proc-macro2` token stream. //! * By **copying** the whole rustc `lib_proc_macro` code, we are able to build this with `stable` //! rustc rather than `unstable`. (Although in gerenal ABI compatibility is still an issue) diff --git a/crates/ra_proc_macro_srv/src/rustc_server.rs b/crates/ra_proc_macro_srv/src/rustc_server.rs index cc32d5a6dd..d534d1337f 100644 --- a/crates/ra_proc_macro_srv/src/rustc_server.rs +++ b/crates/ra_proc_macro_srv/src/rustc_server.rs @@ -1,15 +1,14 @@ -//! Rustc proc-macro server implementation with ra_tt +//! Rustc proc-macro server implementation with tt //! //! Based on idea from https://github.com/fedochet/rust-proc-macro-expander //! The lib-proc-macro server backend is `TokenStream`-agnostic, such that //! we could provide any TokenStream implementation. //! The original idea from fedochet is using proc-macro2 as backend, -//! we use ra_tt instead for better intergation with RA. +//! we use tt instead for better intergation with RA. //! //! FIXME: No span and source file information is implemented yet use crate::proc_macro::bridge::{self, server}; -use ra_tt as tt; use std::collections::{Bound, HashMap}; use std::hash::Hash; @@ -153,9 +152,10 @@ pub struct TokenStreamBuilder { /// Public implementation details for the `TokenStream` type, such as iterators. pub mod token_stream { - use super::{tt, TokenStream, TokenTree}; use std::str::FromStr; + use super::{TokenStream, TokenTree}; + /// An iterator over `TokenStream`'s `TokenTree`s. /// The iteration is "shallow", e.g., the iterator doesn't recurse into delimited groups, /// and returns whole groups as token trees. diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index 6cbf43bb2e..9bc5cc6314 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml @@ -61,4 +61,4 @@ winapi = "0.3.8" expect = { path = "../expect" } test_utils = { path = "../test_utils" } mbe = { path = "../ra_mbe", package = "ra_mbe" } -tt = { path = "../ra_tt", package = "ra_tt" } +tt = { path = "../tt" } diff --git a/crates/ra_tt/Cargo.toml b/crates/tt/Cargo.toml similarity index 90% rename from crates/ra_tt/Cargo.toml rename to crates/tt/Cargo.toml index 3c45248c3e..dfcdcf03e8 100644 --- a/crates/ra_tt/Cargo.toml +++ b/crates/tt/Cargo.toml @@ -1,15 +1,16 @@ [package] -edition = "2018" -name = "ra_tt" -version = "0.1.0" -authors = ["rust-analyzer developers"] +name = "tt" +version = "0.0.0" license = "MIT OR Apache-2.0" +authors = ["rust-analyzer developers"] +edition = "2018" [lib] doctest = false [dependencies] -stdx = { path = "../stdx" } # ideally, `serde` should be enabled by `rust-analyzer`, but we enable it here # to reduce number of compilations smol_str = { version = "0.1.15", features = ["serde"] } + +stdx = { path = "../stdx" } diff --git a/crates/ra_tt/src/buffer.rs b/crates/tt/src/buffer.rs similarity index 100% rename from crates/ra_tt/src/buffer.rs rename to crates/tt/src/buffer.rs diff --git a/crates/ra_tt/src/lib.rs b/crates/tt/src/lib.rs similarity index 100% rename from crates/ra_tt/src/lib.rs rename to crates/tt/src/lib.rs diff --git a/xtask/tests/tidy.rs b/xtask/tests/tidy.rs index 7384205db4..ddaab93ab7 100644 --- a/xtask/tests/tidy.rs +++ b/xtask/tests/tidy.rs @@ -200,7 +200,7 @@ impl TidyDocs { "profile", "ra_project_model", "ra_syntax", - "ra_tt", + "tt", "ra_hir_ty", ]; From 8d34262956059aca7e6fded351a9299b3581a5cf Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 12 Aug 2020 16:52:28 +0200 Subject: [PATCH 070/119] Rename ra_toolchain -> toolchain --- Cargo.lock | 22 +++++++++---------- crates/flycheck/Cargo.toml | 2 +- crates/flycheck/src/lib.rs | 2 +- crates/ra_proc_macro_srv/Cargo.toml | 2 +- crates/ra_proc_macro_srv/src/tests/utils.rs | 2 +- crates/ra_project_model/Cargo.toml | 2 +- .../ra_project_model/src/cargo_workspace.rs | 4 ++-- crates/ra_project_model/src/lib.rs | 2 +- crates/ra_project_model/src/sysroot.rs | 4 ++-- crates/rust-analyzer/Cargo.toml | 2 +- crates/rust-analyzer/src/handlers.rs | 2 +- crates/{ra_toolchain => toolchain}/Cargo.toml | 8 +++---- crates/{ra_toolchain => toolchain}/src/lib.rs | 4 +--- editors/code/src/toolchain.ts | 4 ++-- 14 files changed, 30 insertions(+), 32 deletions(-) rename crates/{ra_toolchain => toolchain}/Cargo.toml (78%) rename crates/{ra_toolchain => toolchain}/src/lib.rs (93%) diff --git a/Cargo.lock b/Cargo.lock index 598b739c7e..c48c6a5977 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -358,8 +358,8 @@ dependencies = [ "crossbeam-channel", "jod-thread", "log", - "ra_toolchain", "serde_json", + "toolchain", ] [[package]] @@ -1143,9 +1143,9 @@ dependencies = [ "memmap", "ra_mbe", "ra_proc_macro", - "ra_toolchain", "serde_derive", "test_utils", + "toolchain", "tt", ] @@ -1161,11 +1161,11 @@ dependencies = [ "ra_cfg", "ra_db", "ra_proc_macro", - "ra_toolchain", "rustc-hash", "serde", "serde_json", "stdx", + "toolchain", ] [[package]] @@ -1210,13 +1210,6 @@ dependencies = [ "text-size", ] -[[package]] -name = "ra_toolchain" -version = "0.1.0" -dependencies = [ - "home", -] - [[package]] name = "rayon" version = "1.3.1" @@ -1320,7 +1313,6 @@ dependencies = [ "ra_ssr", "ra_syntax", "ra_text_edit", - "ra_toolchain", "rayon", "rustc-hash", "serde", @@ -1328,6 +1320,7 @@ dependencies = [ "stdx", "test_utils", "threadpool", + "toolchain", "tt", "vfs", "vfs-notify", @@ -1612,6 +1605,13 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53953d2d3a5ad81d9f844a32f14ebb121f50b650cd59d0ee2a07cf13c617efed" +[[package]] +name = "toolchain" +version = "0.0.0" +dependencies = [ + "home", +] + [[package]] name = "tracing" version = "0.1.18" diff --git a/crates/flycheck/Cargo.toml b/crates/flycheck/Cargo.toml index ff8a1e5689..acc72bc59c 100644 --- a/crates/flycheck/Cargo.toml +++ b/crates/flycheck/Cargo.toml @@ -14,4 +14,4 @@ log = "0.4.8" cargo_metadata = "0.11.1" serde_json = "1.0.48" jod-thread = "0.1.1" -ra_toolchain = { path = "../ra_toolchain" } +toolchain = { path = "../toolchain" } diff --git a/crates/flycheck/src/lib.rs b/crates/flycheck/src/lib.rs index 31e14246de..16078d1043 100644 --- a/crates/flycheck/src/lib.rs +++ b/crates/flycheck/src/lib.rs @@ -193,7 +193,7 @@ impl FlycheckActor { extra_args, features, } => { - let mut cmd = Command::new(ra_toolchain::cargo()); + let mut cmd = Command::new(toolchain::cargo()); cmd.arg(command); cmd.args(&["--workspace", "--message-format=json", "--manifest-path"]) .arg(self.workspace_root.join("Cargo.toml")); diff --git a/crates/ra_proc_macro_srv/Cargo.toml b/crates/ra_proc_macro_srv/Cargo.toml index a690cc0443..1c25e72296 100644 --- a/crates/ra_proc_macro_srv/Cargo.toml +++ b/crates/ra_proc_macro_srv/Cargo.toml @@ -23,4 +23,4 @@ cargo_metadata = "0.11.1" difference = "2.0.0" # used as proc macro test target serde_derive = "1.0.106" -ra_toolchain = { path = "../ra_toolchain" } +toolchain = { path = "../toolchain" } diff --git a/crates/ra_proc_macro_srv/src/tests/utils.rs b/crates/ra_proc_macro_srv/src/tests/utils.rs index dcb00671ff..1b6a0b6fb7 100644 --- a/crates/ra_proc_macro_srv/src/tests/utils.rs +++ b/crates/ra_proc_macro_srv/src/tests/utils.rs @@ -12,7 +12,7 @@ mod fixtures { // Use current project metadata to get the proc-macro dylib path pub fn dylib_path(crate_name: &str, version: &str) -> std::path::PathBuf { - let command = Command::new(ra_toolchain::cargo()) + let command = Command::new(toolchain::cargo()) .args(&["check", "--message-format", "json"]) .output() .unwrap() diff --git a/crates/ra_project_model/Cargo.toml b/crates/ra_project_model/Cargo.toml index 27b1f5d33f..171fe86264 100644 --- a/crates/ra_project_model/Cargo.toml +++ b/crates/ra_project_model/Cargo.toml @@ -17,7 +17,7 @@ cargo_metadata = "0.11.1" arena = { path = "../arena" } ra_cfg = { path = "../ra_cfg" } ra_db = { path = "../ra_db" } -ra_toolchain = { path = "../ra_toolchain" } +toolchain = { path = "../toolchain" } ra_proc_macro = { path = "../ra_proc_macro" } paths = { path = "../paths" } stdx = { path = "../stdx" } diff --git a/crates/ra_project_model/src/cargo_workspace.rs b/crates/ra_project_model/src/cargo_workspace.rs index a526d743d4..abf8dca964 100644 --- a/crates/ra_project_model/src/cargo_workspace.rs +++ b/crates/ra_project_model/src/cargo_workspace.rs @@ -140,7 +140,7 @@ impl CargoWorkspace { cargo_features: &CargoConfig, ) -> Result { let mut meta = MetadataCommand::new(); - meta.cargo_path(ra_toolchain::cargo()); + meta.cargo_path(toolchain::cargo()); meta.manifest_path(cargo_toml.to_path_buf()); if cargo_features.all_features { meta.features(CargoOpt::AllFeatures); @@ -288,7 +288,7 @@ pub fn load_extern_resources( cargo_toml: &Path, cargo_features: &CargoConfig, ) -> Result { - let mut cmd = Command::new(ra_toolchain::cargo()); + let mut cmd = Command::new(toolchain::cargo()); cmd.args(&["check", "--message-format=json", "--manifest-path"]).arg(cargo_toml); if cargo_features.all_features { cmd.arg("--all-features"); diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs index 300e751355..46f44910c0 100644 --- a/crates/ra_project_model/src/lib.rs +++ b/crates/ra_project_model/src/lib.rs @@ -513,7 +513,7 @@ fn get_rustc_cfg_options(target: Option<&str>) -> Vec { } let rustc_cfgs = { - let mut cmd = Command::new(ra_toolchain::rustc()); + let mut cmd = Command::new(toolchain::rustc()); cmd.args(&["--print", "cfg", "-O"]); if let Some(target) = target { cmd.args(&["--target", target]); diff --git a/crates/ra_project_model/src/sysroot.rs b/crates/ra_project_model/src/sysroot.rs index 6ef001769c..8239797b6b 100644 --- a/crates/ra_project_model/src/sysroot.rs +++ b/crates/ra_project_model/src/sysroot.rs @@ -101,13 +101,13 @@ fn get_or_install_rust_src(cargo_toml: &AbsPath) -> Result { return Ok(path); } let current_dir = cargo_toml.parent().unwrap(); - let mut rustc = Command::new(ra_toolchain::rustc()); + let mut rustc = Command::new(toolchain::rustc()); rustc.current_dir(current_dir).args(&["--print", "sysroot"]); let stdout = utf8_stdout(rustc)?; let sysroot_path = AbsPath::assert(Path::new(stdout.trim())); let mut src = get_rust_src(sysroot_path); if src.is_none() { - let mut rustup = Command::new(ra_toolchain::rustup()); + let mut rustup = Command::new(toolchain::rustup()); rustup.current_dir(current_dir).args(&["component", "add", "rust-src"]); utf8_stdout(rustup)?; src = get_rust_src(sysroot_path); diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index 9bc5cc6314..3f70510fd7 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml @@ -43,7 +43,7 @@ ra_text_edit = { path = "../ra_text_edit" } vfs = { path = "../vfs" } vfs-notify = { path = "../vfs-notify" } ra_cfg = { path = "../ra_cfg" } -ra_toolchain = { path = "../ra_toolchain" } +toolchain = { path = "../toolchain" } # This should only be used in CLI ra_db = { path = "../ra_db" } diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index d9b75eed45..07f4af3d3b 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs @@ -692,7 +692,7 @@ pub(crate) fn handle_formatting( let mut rustfmt = match &snap.config.rustfmt { RustfmtConfig::Rustfmt { extra_args } => { - let mut cmd = process::Command::new(ra_toolchain::rustfmt()); + let mut cmd = process::Command::new(toolchain::rustfmt()); cmd.args(extra_args); if let Some(&crate_id) = crate_ids.first() { // Assume all crates are in the same edition diff --git a/crates/ra_toolchain/Cargo.toml b/crates/toolchain/Cargo.toml similarity index 78% rename from crates/ra_toolchain/Cargo.toml rename to crates/toolchain/Cargo.toml index 84b748c0a4..4856668f84 100644 --- a/crates/ra_toolchain/Cargo.toml +++ b/crates/toolchain/Cargo.toml @@ -1,9 +1,9 @@ [package] -edition = "2018" -name = "ra_toolchain" -version = "0.1.0" -authors = ["rust-analyzer developers"] +name = "toolchain" +version = "0.0.0" license = "MIT OR Apache-2.0" +authors = ["rust-analyzer developers"] +edition = "2018" [lib] doctest = false diff --git a/crates/ra_toolchain/src/lib.rs b/crates/toolchain/src/lib.rs similarity index 93% rename from crates/ra_toolchain/src/lib.rs rename to crates/toolchain/src/lib.rs index 9916e52c48..3b6886f5b5 100644 --- a/crates/ra_toolchain/src/lib.rs +++ b/crates/toolchain/src/lib.rs @@ -1,6 +1,4 @@ -//! This crate contains a single public function -//! [`get_path_for_executable`](fn.get_path_for_executable.html). -//! See docs there for more information. +//! Discovery of `cargo` & `rustc` executables. use std::{env, iter, path::PathBuf}; pub fn cargo() -> PathBuf { diff --git a/editors/code/src/toolchain.ts b/editors/code/src/toolchain.ts index 80a7915e90..a5dc3cf0cc 100644 --- a/editors/code/src/toolchain.ts +++ b/editors/code/src/toolchain.ts @@ -121,12 +121,12 @@ export class Cargo { } } -/** Mirrors `ra_toolchain::cargo()` implementation */ +/** Mirrors `toolchain::cargo()` implementation */ export function cargoPath(): string { return getPathForExecutable("cargo"); } -/** Mirrors `ra_toolchain::get_path_for_executable()` implementation */ +/** Mirrors `toolchain::get_path_for_executable()` implementation */ export const getPathForExecutable = memoize( // We apply caching to decrease file-system interactions (executableName: "cargo" | "rustc" | "rustup"): string => { From 7510048ec0a5d5e7136e3ea258954eb244d15baf Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 12 Aug 2020 16:58:56 +0200 Subject: [PATCH 071/119] Cleanup TextEdit API --- Cargo.lock | 2 +- crates/ra_assists/src/assist_context.rs | 4 +-- crates/ra_ide/src/diagnostics.rs | 6 ++--- .../src/diagnostics/diagnostics_with_fix.rs | 4 +-- crates/ra_ide/src/join_lines.rs | 4 +-- crates/ra_ide/src/references/rename.rs | 2 +- crates/ra_ssr/src/replacing.rs | 2 +- crates/ra_text_edit/Cargo.toml | 7 +++-- crates/ra_text_edit/src/lib.rs | 27 +++++++++++++------ 9 files changed, 34 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c48c6a5977..daa8725464 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1205,7 +1205,7 @@ dependencies = [ [[package]] name = "ra_text_edit" -version = "0.1.0" +version = "0.0.0" dependencies = [ "text-size", ] diff --git a/crates/ra_assists/src/assist_context.rs b/crates/ra_assists/src/assist_context.rs index afd3fd4b9e..afba860d1d 100644 --- a/crates/ra_assists/src/assist_context.rs +++ b/crates/ra_assists/src/assist_context.rs @@ -15,7 +15,7 @@ use ra_syntax::{ AstNode, SourceFile, SyntaxElement, SyntaxKind, SyntaxNode, SyntaxToken, TextRange, TextSize, TokenAtOffset, }; -use ra_text_edit::TextEditBuilder; +use ra_text_edit::{TextEdit, TextEditBuilder}; use crate::{ assist_config::{AssistConfig, SnippetCap}, @@ -214,7 +214,7 @@ pub(crate) struct AssistBuilder { impl AssistBuilder { pub(crate) fn new(file_id: FileId) -> AssistBuilder { AssistBuilder { - edit: TextEditBuilder::default(), + edit: TextEdit::builder(), file_id, is_snippet: false, change: SourceChange::default(), diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs index 07bf133bd6..e006c77754 100644 --- a/crates/ra_ide/src/diagnostics.rs +++ b/crates/ra_ide/src/diagnostics.rs @@ -14,7 +14,7 @@ use ra_syntax::{ ast::{self, AstNode}, SyntaxNode, TextRange, T, }; -use ra_text_edit::{TextEdit, TextEditBuilder}; +use ra_text_edit::TextEdit; use crate::{Diagnostic, FileId, Fix, SourceFileEdit}; @@ -103,7 +103,7 @@ fn check_unnecessary_braces_in_use_statement( text_edit_for_remove_unnecessary_braces_with_self_in_use_statement(&single_use_tree) .unwrap_or_else(|| { let to_replace = single_use_tree.syntax().text().to_string(); - let mut edit_builder = TextEditBuilder::default(); + let mut edit_builder = TextEdit::builder(); edit_builder.delete(use_range); edit_builder.insert(use_range.start(), to_replace); edit_builder.finish() @@ -149,7 +149,7 @@ fn check_struct_shorthand_initialization( let field_expr = expr.syntax().text().to_string(); let field_name_is_tup_index = name_ref.as_tuple_field().is_some(); if field_name == field_expr && !field_name_is_tup_index { - let mut edit_builder = TextEditBuilder::default(); + let mut edit_builder = TextEdit::builder(); edit_builder.delete(record_field.syntax().text_range()); edit_builder.insert(record_field.syntax().text_range().start(), field_name); let edit = edit_builder.finish(); diff --git a/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs b/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs index f7c73773f3..88e593e003 100644 --- a/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs +++ b/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs @@ -13,7 +13,7 @@ use ra_ide_db::{ RootDatabase, }; use ra_syntax::{algo, ast, AstNode}; -use ra_text_edit::{TextEdit, TextEditBuilder}; +use ra_text_edit::TextEdit; /// A [Diagnostic] that potentially has a fix available. /// @@ -70,7 +70,7 @@ impl DiagnosticWithFix for MissingFields { } let edit = { - let mut builder = TextEditBuilder::default(); + let mut builder = TextEdit::builder(); algo::diff(&old_field_list.syntax(), &new_field_list.syntax()) .into_text_edit(&mut builder); builder.finish() diff --git a/crates/ra_ide/src/join_lines.rs b/crates/ra_ide/src/join_lines.rs index 6907c09e80..1c881386f7 100644 --- a/crates/ra_ide/src/join_lines.rs +++ b/crates/ra_ide/src/join_lines.rs @@ -23,7 +23,7 @@ pub fn join_lines(file: &SourceFile, range: TextRange) -> TextEdit { let syntax = file.syntax(); let text = syntax.text().slice(range.start()..); let pos = match text.find_char('\n') { - None => return TextEditBuilder::default().finish(), + None => return TextEdit::builder().finish(), Some(pos) => pos, }; TextRange::at(range.start() + pos, TextSize::of('\n')) @@ -35,7 +35,7 @@ pub fn join_lines(file: &SourceFile, range: TextRange) -> TextEdit { NodeOrToken::Node(node) => node, NodeOrToken::Token(token) => token.parent(), }; - let mut edit = TextEditBuilder::default(); + let mut edit = TextEdit::builder(); for token in node.descendants_with_tokens().filter_map(|it| it.into_token()) { let range = match range.intersect(token.text_range()) { Some(range) => range, diff --git a/crates/ra_ide/src/references/rename.rs b/crates/ra_ide/src/references/rename.rs index c8d80fcf7c..8c1ac3c560 100644 --- a/crates/ra_ide/src/references/rename.rs +++ b/crates/ra_ide/src/references/rename.rs @@ -281,7 +281,7 @@ mod tests { let ra_fixture_after = &trim_indent(ra_fixture_after); let (analysis, position) = analysis_and_position(ra_fixture_before); let source_change = analysis.rename(position, new_name).unwrap(); - let mut text_edit_builder = TextEditBuilder::default(); + let mut text_edit_builder = TextEdit::builder(); let mut file_id: Option = None; if let Some(change) = source_change { for edit in change.info.source_file_edits { diff --git a/crates/ra_ssr/src/replacing.rs b/crates/ra_ssr/src/replacing.rs index 0943244ff9..36ced3842d 100644 --- a/crates/ra_ssr/src/replacing.rs +++ b/crates/ra_ssr/src/replacing.rs @@ -24,7 +24,7 @@ fn matches_to_edit_at_offset( relative_start: TextSize, rules: &[ResolvedRule], ) -> TextEdit { - let mut edit_builder = ra_text_edit::TextEditBuilder::default(); + let mut edit_builder = TextEdit::builder(); for m in &matches.matches { edit_builder.replace( m.range.range.checked_sub(relative_start).unwrap(), diff --git a/crates/ra_text_edit/Cargo.toml b/crates/ra_text_edit/Cargo.toml index dbb2233504..427862a5cc 100644 --- a/crates/ra_text_edit/Cargo.toml +++ b/crates/ra_text_edit/Cargo.toml @@ -1,10 +1,9 @@ [package] -edition = "2018" name = "ra_text_edit" -version = "0.1.0" -authors = ["rust-analyzer developers"] -publish = false +version = "0.0.0" license = "MIT OR Apache-2.0" +authors = ["rust-analyzer developers"] +edition = "2018" [lib] doctest = false diff --git a/crates/ra_text_edit/src/lib.rs b/crates/ra_text_edit/src/lib.rs index d68791cf1f..ab8cd7fd11 100644 --- a/crates/ra_text_edit/src/lib.rs +++ b/crates/ra_text_edit/src/lib.rs @@ -3,8 +3,6 @@ //! `rust-analyzer` never mutates text itself and only sends diffs to clients, //! so `TextEdit` is the ultimate representation of the work done by //! rust-analyzer. -use std::{slice, vec}; - pub use text_size::{TextRange, TextSize}; /// `InsertDelete` -- a single "atomic" change to text @@ -46,20 +44,24 @@ impl Indel { } impl TextEdit { + pub fn builder() -> TextEditBuilder { + TextEditBuilder::default() + } + pub fn insert(offset: TextSize, text: String) -> TextEdit { - let mut builder = TextEditBuilder::default(); + let mut builder = TextEdit::builder(); builder.insert(offset, text); builder.finish() } pub fn delete(range: TextRange) -> TextEdit { - let mut builder = TextEditBuilder::default(); + let mut builder = TextEdit::builder(); builder.delete(range); builder.finish() } pub fn replace(range: TextRange, replace_with: String) -> TextEdit { - let mut builder = TextEditBuilder::default(); + let mut builder = TextEdit::builder(); builder.replace(range, replace_with); builder.finish() } @@ -72,8 +74,8 @@ impl TextEdit { self.indels.is_empty() } - pub fn iter(&self) -> slice::Iter<'_, Indel> { - self.indels.iter() + pub fn iter(&self) -> std::slice::Iter<'_, Indel> { + self.into_iter() } pub fn apply(&self, text: &mut String) { @@ -139,13 +141,22 @@ impl TextEdit { impl IntoIterator for TextEdit { type Item = Indel; - type IntoIter = vec::IntoIter; + type IntoIter = std::vec::IntoIter; fn into_iter(self) -> Self::IntoIter { self.indels.into_iter() } } +impl<'a> IntoIterator for &'a TextEdit { + type Item = &'a Indel; + type IntoIter = std::slice::Iter<'a, Indel>; + + fn into_iter(self) -> Self::IntoIter { + self.indels.iter() + } +} + impl TextEditBuilder { pub fn replace(&mut self, range: TextRange, replace_with: String) { self.indels.push(Indel::replace(range, replace_with)) From 6dafc13f5f776980cd2560fb79d3d4790811c96d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 12 Aug 2020 17:03:06 +0200 Subject: [PATCH 072/119] Rename ra_text_edit -> text_edit --- Cargo.lock | 26 +++++++++---------- crates/ra_assists/Cargo.toml | 2 +- crates/ra_assists/src/assist_context.rs | 2 +- crates/ra_assists/src/utils/insert_use.rs | 4 +-- crates/ra_ide/Cargo.toml | 2 +- .../ra_ide/src/completion/complete_postfix.rs | 2 +- .../src/completion/complete_trait_impl.rs | 2 +- .../src/completion/completion_context.rs | 2 +- .../ra_ide/src/completion/completion_item.rs | 2 +- crates/ra_ide/src/diagnostics.rs | 2 +- .../src/diagnostics/diagnostics_with_fix.rs | 2 +- crates/ra_ide/src/join_lines.rs | 2 +- crates/ra_ide/src/lib.rs | 2 +- crates/ra_ide/src/references/rename.rs | 4 +-- crates/ra_ide/src/typing.rs | 2 +- crates/ra_ide/src/typing/on_enter.rs | 2 +- crates/ra_ide_db/Cargo.toml | 2 +- crates/ra_ide_db/src/source_change.rs | 2 +- crates/ra_ssr/Cargo.toml | 2 +- crates/ra_ssr/src/replacing.rs | 2 +- crates/ra_syntax/Cargo.toml | 2 +- crates/ra_syntax/fuzz/Cargo.toml | 2 +- crates/ra_syntax/src/algo.rs | 2 +- crates/ra_syntax/src/fuzz.rs | 2 +- crates/ra_syntax/src/lib.rs | 2 +- crates/ra_syntax/src/parsing/reparsing.rs | 2 +- crates/rust-analyzer/Cargo.toml | 2 +- crates/{ra_text_edit => text_edit}/Cargo.toml | 2 +- crates/{ra_text_edit => text_edit}/src/lib.rs | 0 29 files changed, 42 insertions(+), 42 deletions(-) rename crates/{ra_text_edit => text_edit}/Cargo.toml (88%) rename crates/{ra_text_edit => text_edit}/src/lib.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index daa8725464..4a6a659341 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -927,10 +927,10 @@ dependencies = [ "ra_hir", "ra_ide_db", "ra_syntax", - "ra_text_edit", "rustc-hash", "stdx", "test_utils", + "text_edit", ] [[package]] @@ -1075,10 +1075,10 @@ dependencies = [ "ra_ide_db", "ra_ssr", "ra_syntax", - "ra_text_edit", "rustc-hash", "stdx", "test_utils", + "text_edit", ] [[package]] @@ -1093,11 +1093,11 @@ dependencies = [ "ra_db", "ra_hir", "ra_syntax", - "ra_text_edit", "rayon", "rustc-hash", "stdx", "test_utils", + "text_edit", ] [[package]] @@ -1177,9 +1177,9 @@ dependencies = [ "ra_hir", "ra_ide_db", "ra_syntax", - "ra_text_edit", "rustc-hash", "test_utils", + "text_edit", ] [[package]] @@ -1191,7 +1191,6 @@ dependencies = [ "itertools", "once_cell", "ra_parser", - "ra_text_edit", "rayon", "rowan", "rustc-ap-rustc_lexer", @@ -1200,16 +1199,10 @@ dependencies = [ "smol_str", "stdx", "test_utils", + "text_edit", "walkdir", ] -[[package]] -name = "ra_text_edit" -version = "0.0.0" -dependencies = [ - "text-size", -] - [[package]] name = "rayon" version = "1.3.1" @@ -1312,13 +1305,13 @@ dependencies = [ "ra_project_model", "ra_ssr", "ra_syntax", - "ra_text_edit", "rayon", "rustc-hash", "serde", "serde_json", "stdx", "test_utils", + "text_edit", "threadpool", "toolchain", "tt", @@ -1565,6 +1558,13 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f03e7efdedc3bc78cb2337f1e2785c39e45f5ef762d9e4ebb137fff7380a6d8a" +[[package]] +name = "text_edit" +version = "0.0.0" +dependencies = [ + "text-size", +] + [[package]] name = "thin-dst" version = "1.1.0" diff --git a/crates/ra_assists/Cargo.toml b/crates/ra_assists/Cargo.toml index 6f5ace941f..e4a5ee6c1c 100644 --- a/crates/ra_assists/Cargo.toml +++ b/crates/ra_assists/Cargo.toml @@ -16,7 +16,7 @@ either = "1.5.3" stdx = { path = "../stdx" } ra_syntax = { path = "../ra_syntax" } -ra_text_edit = { path = "../ra_text_edit" } +text_edit = { path = "../text_edit" } ra_fmt = { path = "../ra_fmt" } profile = { path = "../profile" } ra_db = { path = "../ra_db" } diff --git a/crates/ra_assists/src/assist_context.rs b/crates/ra_assists/src/assist_context.rs index afba860d1d..fcaa1aedcf 100644 --- a/crates/ra_assists/src/assist_context.rs +++ b/crates/ra_assists/src/assist_context.rs @@ -15,7 +15,7 @@ use ra_syntax::{ AstNode, SourceFile, SyntaxElement, SyntaxKind, SyntaxNode, SyntaxToken, TextRange, TextSize, TokenAtOffset, }; -use ra_text_edit::{TextEdit, TextEditBuilder}; +use text_edit::{TextEdit, TextEditBuilder}; use crate::{ assist_config::{AssistConfig, SnippetCap}, diff --git a/crates/ra_assists/src/utils/insert_use.rs b/crates/ra_assists/src/utils/insert_use.rs index 32780fceb5..13dbe1919c 100644 --- a/crates/ra_assists/src/utils/insert_use.rs +++ b/crates/ra_assists/src/utils/insert_use.rs @@ -2,6 +2,7 @@ // FIXME: rewrite according to the plan, outlined in // https://github.com/rust-analyzer/rust-analyzer/issues/3301#issuecomment-592931553 +use either::Either; use hir::{self, ModPath}; use ra_syntax::{ ast::{self, NameOwner, VisibilityOwner}, @@ -9,10 +10,9 @@ use ra_syntax::{ SyntaxKind::{PATH, PATH_SEGMENT}, SyntaxNode, T, }; -use ra_text_edit::TextEditBuilder; +use text_edit::TextEditBuilder; use crate::assist_context::AssistContext; -use either::Either; /// Determines the containing syntax node in which to insert a `use` statement affecting `position`. pub(crate) fn find_insert_use_container( diff --git a/crates/ra_ide/Cargo.toml b/crates/ra_ide/Cargo.toml index bbc9ba4e77..84c25f0b8a 100644 --- a/crates/ra_ide/Cargo.toml +++ b/crates/ra_ide/Cargo.toml @@ -22,7 +22,7 @@ oorandom = "11.1.2" stdx = { path = "../stdx" } ra_syntax = { path = "../ra_syntax" } -ra_text_edit = { path = "../ra_text_edit" } +text_edit = { path = "../text_edit" } ra_db = { path = "../ra_db" } ra_ide_db = { path = "../ra_ide_db" } ra_cfg = { path = "../ra_cfg" } diff --git a/crates/ra_ide/src/completion/complete_postfix.rs b/crates/ra_ide/src/completion/complete_postfix.rs index 8735b90103..42087da8dc 100644 --- a/crates/ra_ide/src/completion/complete_postfix.rs +++ b/crates/ra_ide/src/completion/complete_postfix.rs @@ -4,7 +4,7 @@ use ra_syntax::{ ast::{self, AstNode}, TextRange, TextSize, }; -use ra_text_edit::TextEdit; +use text_edit::TextEdit; use crate::{ completion::{ diff --git a/crates/ra_ide/src/completion/complete_trait_impl.rs b/crates/ra_ide/src/completion/complete_trait_impl.rs index d9a0ef167d..b397baf107 100644 --- a/crates/ra_ide/src/completion/complete_trait_impl.rs +++ b/crates/ra_ide/src/completion/complete_trait_impl.rs @@ -37,7 +37,7 @@ use ra_syntax::{ ast::{self, edit, Impl}, AstNode, SyntaxKind, SyntaxNode, TextRange, T, }; -use ra_text_edit::TextEdit; +use text_edit::TextEdit; use crate::{ completion::{ diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs index 4aa761148d..0cb57fb1b4 100644 --- a/crates/ra_ide/src/completion/completion_context.rs +++ b/crates/ra_ide/src/completion/completion_context.rs @@ -9,7 +9,7 @@ use ra_syntax::{ SyntaxKind::*, SyntaxNode, SyntaxToken, TextRange, TextSize, }; -use ra_text_edit::Indel; +use text_edit::Indel; use super::patterns::{ has_bind_pat_parent, has_block_expr_parent, has_impl_as_prev_sibling, has_impl_parent, diff --git a/crates/ra_ide/src/completion/completion_item.rs b/crates/ra_ide/src/completion/completion_item.rs index 7bdda316c4..1c0684f4ed 100644 --- a/crates/ra_ide/src/completion/completion_item.rs +++ b/crates/ra_ide/src/completion/completion_item.rs @@ -4,7 +4,7 @@ use std::fmt; use hir::Documentation; use ra_syntax::TextRange; -use ra_text_edit::TextEdit; +use text_edit::TextEdit; use crate::completion::completion_config::SnippetCap; diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs index e006c77754..54810d5bbf 100644 --- a/crates/ra_ide/src/diagnostics.rs +++ b/crates/ra_ide/src/diagnostics.rs @@ -14,7 +14,7 @@ use ra_syntax::{ ast::{self, AstNode}, SyntaxNode, TextRange, T, }; -use ra_text_edit::TextEdit; +use text_edit::TextEdit; use crate::{Diagnostic, FileId, Fix, SourceFileEdit}; diff --git a/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs b/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs index 88e593e003..8fb25de6c1 100644 --- a/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs +++ b/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs @@ -13,7 +13,7 @@ use ra_ide_db::{ RootDatabase, }; use ra_syntax::{algo, ast, AstNode}; -use ra_text_edit::TextEdit; +use text_edit::TextEdit; /// A [Diagnostic] that potentially has a fix available. /// diff --git a/crates/ra_ide/src/join_lines.rs b/crates/ra_ide/src/join_lines.rs index 1c881386f7..caf63933a9 100644 --- a/crates/ra_ide/src/join_lines.rs +++ b/crates/ra_ide/src/join_lines.rs @@ -7,7 +7,7 @@ use ra_syntax::{ SyntaxKind::{self, WHITESPACE}, SyntaxNode, SyntaxToken, TextRange, TextSize, T, }; -use ra_text_edit::{TextEdit, TextEditBuilder}; +use text_edit::{TextEdit, TextEditBuilder}; // Feature: Join Lines // diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs index bfcf5d750a..09cb5faf68 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ra_ide/src/lib.rs @@ -96,7 +96,7 @@ pub use ra_ide_db::{ RootDatabase, }; pub use ra_ssr::SsrError; -pub use ra_text_edit::{Indel, TextEdit}; +pub use text_edit::{Indel, TextEdit}; pub type Cancelable = Result; diff --git a/crates/ra_ide/src/references/rename.rs b/crates/ra_ide/src/references/rename.rs index 8c1ac3c560..9c688fb063 100644 --- a/crates/ra_ide/src/references/rename.rs +++ b/crates/ra_ide/src/references/rename.rs @@ -11,9 +11,9 @@ use ra_syntax::{ ast::{self, NameOwner}, lex_single_valid_syntax_kind, match_ast, AstNode, SyntaxKind, SyntaxNode, SyntaxToken, }; -use ra_text_edit::TextEdit; use std::convert::TryInto; use test_utils::mark; +use text_edit::TextEdit; use crate::{ references::find_all_refs, FilePosition, FileSystemEdit, RangeInfo, Reference, ReferenceKind, @@ -271,9 +271,9 @@ fn rename_reference( #[cfg(test)] mod tests { use expect::{expect, Expect}; - use ra_text_edit::TextEditBuilder; use stdx::trim_indent; use test_utils::{assert_eq_text, mark}; + use text_edit::TextEdit; use crate::{mock_analysis::analysis_and_position, FileId}; diff --git a/crates/ra_ide/src/typing.rs b/crates/ra_ide/src/typing.rs index d3ce744b44..952429cde6 100644 --- a/crates/ra_ide/src/typing.rs +++ b/crates/ra_ide/src/typing.rs @@ -26,7 +26,7 @@ use ra_syntax::{ TextRange, TextSize, }; -use ra_text_edit::TextEdit; +use text_edit::TextEdit; use crate::SourceChange; diff --git a/crates/ra_ide/src/typing/on_enter.rs b/crates/ra_ide/src/typing/on_enter.rs index 143b1ae413..c0c5ce3bcd 100644 --- a/crates/ra_ide/src/typing/on_enter.rs +++ b/crates/ra_ide/src/typing/on_enter.rs @@ -9,8 +9,8 @@ use ra_syntax::{ SyntaxKind::*, SyntaxToken, TextRange, TextSize, TokenAtOffset, }; -use ra_text_edit::TextEdit; use test_utils::mark; +use text_edit::TextEdit; // Feature: On Enter // diff --git a/crates/ra_ide_db/Cargo.toml b/crates/ra_ide_db/Cargo.toml index 92b8ef82a7..5446a59614 100644 --- a/crates/ra_ide_db/Cargo.toml +++ b/crates/ra_ide_db/Cargo.toml @@ -22,7 +22,7 @@ either = "1.5.3" stdx = { path = "../stdx" } ra_syntax = { path = "../ra_syntax" } -ra_text_edit = { path = "../ra_text_edit" } +text_edit = { path = "../text_edit" } ra_db = { path = "../ra_db" } profile = { path = "../profile" } test_utils = { path = "../test_utils" } diff --git a/crates/ra_ide_db/src/source_change.rs b/crates/ra_ide_db/src/source_change.rs index abb83f4213..ae21132dd7 100644 --- a/crates/ra_ide_db/src/source_change.rs +++ b/crates/ra_ide_db/src/source_change.rs @@ -4,7 +4,7 @@ //! It can be viewed as a dual for `AnalysisChange`. use ra_db::FileId; -use ra_text_edit::TextEdit; +use text_edit::TextEdit; #[derive(Default, Debug, Clone)] pub struct SourceChange { diff --git a/crates/ra_ssr/Cargo.toml b/crates/ra_ssr/Cargo.toml index 84e4b171e1..d0f2ae7339 100644 --- a/crates/ra_ssr/Cargo.toml +++ b/crates/ra_ssr/Cargo.toml @@ -11,7 +11,7 @@ repository = "https://github.com/rust-analyzer/rust-analyzer" doctest = false [dependencies] -ra_text_edit = { path = "../ra_text_edit" } +text_edit = { path = "../text_edit" } ra_syntax = { path = "../ra_syntax" } ra_db = { path = "../ra_db" } ra_ide_db = { path = "../ra_ide_db" } diff --git a/crates/ra_ssr/src/replacing.rs b/crates/ra_ssr/src/replacing.rs index 36ced3842d..74f9e7db61 100644 --- a/crates/ra_ssr/src/replacing.rs +++ b/crates/ra_ssr/src/replacing.rs @@ -4,8 +4,8 @@ use crate::matching::Var; use crate::{resolving::ResolvedRule, Match, SsrMatches}; use ra_syntax::ast::{self, AstToken}; use ra_syntax::{SyntaxElement, SyntaxKind, SyntaxNode, SyntaxToken, TextRange, TextSize}; -use ra_text_edit::TextEdit; use rustc_hash::{FxHashMap, FxHashSet}; +use text_edit::TextEdit; /// Returns a text edit that will replace each match in `matches` with its corresponding replacement /// template. Placeholders in the template will have been substituted with whatever they matched to diff --git a/crates/ra_syntax/Cargo.toml b/crates/ra_syntax/Cargo.toml index fc4d7aa048..f2789e6a35 100644 --- a/crates/ra_syntax/Cargo.toml +++ b/crates/ra_syntax/Cargo.toml @@ -20,7 +20,7 @@ once_cell = "1.3.1" stdx = { path = "../stdx" } -ra_text_edit = { path = "../ra_text_edit" } +text_edit = { path = "../text_edit" } ra_parser = { path = "../ra_parser" } # This crate transitively depends on `smol_str` via `rowan`. diff --git a/crates/ra_syntax/fuzz/Cargo.toml b/crates/ra_syntax/fuzz/Cargo.toml index 613ad2857d..4cec3c4cd8 100644 --- a/crates/ra_syntax/fuzz/Cargo.toml +++ b/crates/ra_syntax/fuzz/Cargo.toml @@ -11,7 +11,7 @@ cargo-fuzz = true [dependencies] ra_syntax = { path = ".." } -ra_text_edit = { path = "../../ra_text_edit" } +text_edit = { path = "../../text_edit" } libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer-sys.git" } # Prevent this from interfering with workspaces diff --git a/crates/ra_syntax/src/algo.rs b/crates/ra_syntax/src/algo.rs index 26b3c813a1..6254b38ba1 100644 --- a/crates/ra_syntax/src/algo.rs +++ b/crates/ra_syntax/src/algo.rs @@ -6,8 +6,8 @@ use std::{ }; use itertools::Itertools; -use ra_text_edit::TextEditBuilder; use rustc_hash::FxHashMap; +use text_edit::TextEditBuilder; use crate::{ AstNode, Direction, NodeOrToken, SyntaxElement, SyntaxKind, SyntaxNode, SyntaxNodePtr, diff --git a/crates/ra_syntax/src/fuzz.rs b/crates/ra_syntax/src/fuzz.rs index 39f9b12ab2..fbb97aa273 100644 --- a/crates/ra_syntax/src/fuzz.rs +++ b/crates/ra_syntax/src/fuzz.rs @@ -5,7 +5,7 @@ use std::{ str::{self, FromStr}, }; -use ra_text_edit::Indel; +use text_edit::Indel; use crate::{validation, AstNode, SourceFile, TextRange}; diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs index 8a4d453862..465607f550 100644 --- a/crates/ra_syntax/src/lib.rs +++ b/crates/ra_syntax/src/lib.rs @@ -39,8 +39,8 @@ pub mod fuzz; use std::{marker::PhantomData, sync::Arc}; -use ra_text_edit::Indel; use stdx::format_to; +use text_edit::Indel; pub use crate::{ algo::InsertPosition, diff --git a/crates/ra_syntax/src/parsing/reparsing.rs b/crates/ra_syntax/src/parsing/reparsing.rs index ed5a42ea38..6644ffca4f 100644 --- a/crates/ra_syntax/src/parsing/reparsing.rs +++ b/crates/ra_syntax/src/parsing/reparsing.rs @@ -7,7 +7,7 @@ //! and try to parse only this block. use ra_parser::Reparser; -use ra_text_edit::Indel; +use text_edit::Indel; use crate::{ algo, diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index 3f70510fd7..ef244da597 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml @@ -39,7 +39,7 @@ ra_ide = { path = "../ra_ide" } profile = { path = "../profile" } ra_project_model = { path = "../ra_project_model" } ra_syntax = { path = "../ra_syntax" } -ra_text_edit = { path = "../ra_text_edit" } +text_edit = { path = "../text_edit" } vfs = { path = "../vfs" } vfs-notify = { path = "../vfs-notify" } ra_cfg = { path = "../ra_cfg" } diff --git a/crates/ra_text_edit/Cargo.toml b/crates/text_edit/Cargo.toml similarity index 88% rename from crates/ra_text_edit/Cargo.toml rename to crates/text_edit/Cargo.toml index 427862a5cc..a69b1ef2b5 100644 --- a/crates/ra_text_edit/Cargo.toml +++ b/crates/text_edit/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "ra_text_edit" +name = "text_edit" version = "0.0.0" license = "MIT OR Apache-2.0" authors = ["rust-analyzer developers"] diff --git a/crates/ra_text_edit/src/lib.rs b/crates/text_edit/src/lib.rs similarity index 100% rename from crates/ra_text_edit/src/lib.rs rename to crates/text_edit/src/lib.rs From 50a02eb3593591a02677e1b56f24d7ff0459b9d0 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 12 Aug 2020 17:06:49 +0200 Subject: [PATCH 073/119] Rename ra_parser -> parser --- Cargo.lock | 20 +++++++++---------- crates/{ra_parser => parser}/Cargo.toml | 9 ++++----- crates/{ra_parser => parser}/src/event.rs | 0 crates/{ra_parser => parser}/src/grammar.rs | 0 .../src/grammar/attributes.rs | 0 .../src/grammar/expressions.rs | 0 .../src/grammar/expressions/atom.rs | 0 .../src/grammar/items.rs | 0 .../src/grammar/items/adt.rs | 0 .../src/grammar/items/consts.rs | 0 .../src/grammar/items/traits.rs | 0 .../src/grammar/items/use_item.rs | 0 .../src/grammar/params.rs | 0 .../src/grammar/paths.rs | 0 .../src/grammar/patterns.rs | 0 .../src/grammar/type_args.rs | 0 .../src/grammar/type_params.rs | 0 .../src/grammar/types.rs | 0 crates/{ra_parser => parser}/src/lib.rs | 0 crates/{ra_parser => parser}/src/parser.rs | 0 .../{ra_parser => parser}/src/syntax_kind.rs | 0 .../src/syntax_kind/generated.rs | 0 crates/{ra_parser => parser}/src/token_set.rs | 0 crates/ra_hir_expand/Cargo.toml | 2 +- crates/ra_hir_expand/src/builtin_derive.rs | 2 +- crates/ra_hir_expand/src/builtin_macro.rs | 2 +- crates/ra_hir_expand/src/db.rs | 2 +- crates/ra_hir_expand/src/eager.rs | 2 +- crates/ra_hir_expand/src/lib.rs | 2 +- crates/ra_mbe/Cargo.toml | 2 +- crates/ra_mbe/src/mbe_expander/matcher.rs | 8 ++++---- crates/ra_mbe/src/subtree_source.rs | 2 +- crates/ra_mbe/src/syntax_bridge.rs | 6 +++--- crates/ra_mbe/src/tests.rs | 5 +++-- crates/ra_syntax/Cargo.toml | 2 +- crates/ra_syntax/src/ast/node_ext.rs | 2 +- crates/ra_syntax/src/lib.rs | 14 ++++++------- crates/ra_syntax/src/parsing.rs | 14 ++++++------- crates/ra_syntax/src/parsing/reparsing.rs | 2 +- .../src/parsing/text_token_source.rs | 14 ++++++------- .../ra_syntax/src/parsing/text_tree_sink.rs | 2 +- crates/ra_syntax/src/syntax_node.rs | 2 +- docs/dev/README.md | 4 ++-- docs/dev/architecture.md | 2 +- docs/dev/syntax.md | 2 +- xtask/src/codegen.rs | 4 ++-- xtask/tests/tidy.rs | 2 +- 47 files changed, 65 insertions(+), 65 deletions(-) rename crates/{ra_parser => parser}/Cargo.toml (74%) rename crates/{ra_parser => parser}/src/event.rs (100%) rename crates/{ra_parser => parser}/src/grammar.rs (100%) rename crates/{ra_parser => parser}/src/grammar/attributes.rs (100%) rename crates/{ra_parser => parser}/src/grammar/expressions.rs (100%) rename crates/{ra_parser => parser}/src/grammar/expressions/atom.rs (100%) rename crates/{ra_parser => parser}/src/grammar/items.rs (100%) rename crates/{ra_parser => parser}/src/grammar/items/adt.rs (100%) rename crates/{ra_parser => parser}/src/grammar/items/consts.rs (100%) rename crates/{ra_parser => parser}/src/grammar/items/traits.rs (100%) rename crates/{ra_parser => parser}/src/grammar/items/use_item.rs (100%) rename crates/{ra_parser => parser}/src/grammar/params.rs (100%) rename crates/{ra_parser => parser}/src/grammar/paths.rs (100%) rename crates/{ra_parser => parser}/src/grammar/patterns.rs (100%) rename crates/{ra_parser => parser}/src/grammar/type_args.rs (100%) rename crates/{ra_parser => parser}/src/grammar/type_params.rs (100%) rename crates/{ra_parser => parser}/src/grammar/types.rs (100%) rename crates/{ra_parser => parser}/src/lib.rs (100%) rename crates/{ra_parser => parser}/src/parser.rs (100%) rename crates/{ra_parser => parser}/src/syntax_kind.rs (100%) rename crates/{ra_parser => parser}/src/syntax_kind/generated.rs (100%) rename crates/{ra_parser => parser}/src/token_set.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 4a6a659341..095127b99f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -834,6 +834,13 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "parser" +version = "0.0.0" +dependencies = [ + "drop_bomb", +] + [[package]] name = "paths" version = "0.1.0" @@ -1018,10 +1025,10 @@ dependencies = [ "arena", "either", "log", + "parser", "profile", "ra_db", "ra_mbe", - "ra_parser", "ra_syntax", "rustc-hash", "test_utils", @@ -1105,7 +1112,7 @@ name = "ra_mbe" version = "0.1.0" dependencies = [ "log", - "ra_parser", + "parser", "ra_syntax", "rustc-hash", "smallvec", @@ -1113,13 +1120,6 @@ dependencies = [ "tt", ] -[[package]] -name = "ra_parser" -version = "0.1.0" -dependencies = [ - "drop_bomb", -] - [[package]] name = "ra_proc_macro" version = "0.1.0" @@ -1190,7 +1190,7 @@ dependencies = [ "expect", "itertools", "once_cell", - "ra_parser", + "parser", "rayon", "rowan", "rustc-ap-rustc_lexer", diff --git a/crates/ra_parser/Cargo.toml b/crates/parser/Cargo.toml similarity index 74% rename from crates/ra_parser/Cargo.toml rename to crates/parser/Cargo.toml index 72ec3e4d9a..358be92d12 100644 --- a/crates/ra_parser/Cargo.toml +++ b/crates/parser/Cargo.toml @@ -1,10 +1,9 @@ [package] -edition = "2018" -name = "ra_parser" -version = "0.1.0" -authors = ["rust-analyzer developers"] -publish = false +name = "parser" +version = "0.0.0" license = "MIT OR Apache-2.0" +authors = ["rust-analyzer developers"] +edition = "2018" [lib] doctest = false diff --git a/crates/ra_parser/src/event.rs b/crates/parser/src/event.rs similarity index 100% rename from crates/ra_parser/src/event.rs rename to crates/parser/src/event.rs diff --git a/crates/ra_parser/src/grammar.rs b/crates/parser/src/grammar.rs similarity index 100% rename from crates/ra_parser/src/grammar.rs rename to crates/parser/src/grammar.rs diff --git a/crates/ra_parser/src/grammar/attributes.rs b/crates/parser/src/grammar/attributes.rs similarity index 100% rename from crates/ra_parser/src/grammar/attributes.rs rename to crates/parser/src/grammar/attributes.rs diff --git a/crates/ra_parser/src/grammar/expressions.rs b/crates/parser/src/grammar/expressions.rs similarity index 100% rename from crates/ra_parser/src/grammar/expressions.rs rename to crates/parser/src/grammar/expressions.rs diff --git a/crates/ra_parser/src/grammar/expressions/atom.rs b/crates/parser/src/grammar/expressions/atom.rs similarity index 100% rename from crates/ra_parser/src/grammar/expressions/atom.rs rename to crates/parser/src/grammar/expressions/atom.rs diff --git a/crates/ra_parser/src/grammar/items.rs b/crates/parser/src/grammar/items.rs similarity index 100% rename from crates/ra_parser/src/grammar/items.rs rename to crates/parser/src/grammar/items.rs diff --git a/crates/ra_parser/src/grammar/items/adt.rs b/crates/parser/src/grammar/items/adt.rs similarity index 100% rename from crates/ra_parser/src/grammar/items/adt.rs rename to crates/parser/src/grammar/items/adt.rs diff --git a/crates/ra_parser/src/grammar/items/consts.rs b/crates/parser/src/grammar/items/consts.rs similarity index 100% rename from crates/ra_parser/src/grammar/items/consts.rs rename to crates/parser/src/grammar/items/consts.rs diff --git a/crates/ra_parser/src/grammar/items/traits.rs b/crates/parser/src/grammar/items/traits.rs similarity index 100% rename from crates/ra_parser/src/grammar/items/traits.rs rename to crates/parser/src/grammar/items/traits.rs diff --git a/crates/ra_parser/src/grammar/items/use_item.rs b/crates/parser/src/grammar/items/use_item.rs similarity index 100% rename from crates/ra_parser/src/grammar/items/use_item.rs rename to crates/parser/src/grammar/items/use_item.rs diff --git a/crates/ra_parser/src/grammar/params.rs b/crates/parser/src/grammar/params.rs similarity index 100% rename from crates/ra_parser/src/grammar/params.rs rename to crates/parser/src/grammar/params.rs diff --git a/crates/ra_parser/src/grammar/paths.rs b/crates/parser/src/grammar/paths.rs similarity index 100% rename from crates/ra_parser/src/grammar/paths.rs rename to crates/parser/src/grammar/paths.rs diff --git a/crates/ra_parser/src/grammar/patterns.rs b/crates/parser/src/grammar/patterns.rs similarity index 100% rename from crates/ra_parser/src/grammar/patterns.rs rename to crates/parser/src/grammar/patterns.rs diff --git a/crates/ra_parser/src/grammar/type_args.rs b/crates/parser/src/grammar/type_args.rs similarity index 100% rename from crates/ra_parser/src/grammar/type_args.rs rename to crates/parser/src/grammar/type_args.rs diff --git a/crates/ra_parser/src/grammar/type_params.rs b/crates/parser/src/grammar/type_params.rs similarity index 100% rename from crates/ra_parser/src/grammar/type_params.rs rename to crates/parser/src/grammar/type_params.rs diff --git a/crates/ra_parser/src/grammar/types.rs b/crates/parser/src/grammar/types.rs similarity index 100% rename from crates/ra_parser/src/grammar/types.rs rename to crates/parser/src/grammar/types.rs diff --git a/crates/ra_parser/src/lib.rs b/crates/parser/src/lib.rs similarity index 100% rename from crates/ra_parser/src/lib.rs rename to crates/parser/src/lib.rs diff --git a/crates/ra_parser/src/parser.rs b/crates/parser/src/parser.rs similarity index 100% rename from crates/ra_parser/src/parser.rs rename to crates/parser/src/parser.rs diff --git a/crates/ra_parser/src/syntax_kind.rs b/crates/parser/src/syntax_kind.rs similarity index 100% rename from crates/ra_parser/src/syntax_kind.rs rename to crates/parser/src/syntax_kind.rs diff --git a/crates/ra_parser/src/syntax_kind/generated.rs b/crates/parser/src/syntax_kind/generated.rs similarity index 100% rename from crates/ra_parser/src/syntax_kind/generated.rs rename to crates/parser/src/syntax_kind/generated.rs diff --git a/crates/ra_parser/src/token_set.rs b/crates/parser/src/token_set.rs similarity index 100% rename from crates/ra_parser/src/token_set.rs rename to crates/parser/src/token_set.rs diff --git a/crates/ra_hir_expand/Cargo.toml b/crates/ra_hir_expand/Cargo.toml index 7d8ccd56fc..052330fdef 100644 --- a/crates/ra_hir_expand/Cargo.toml +++ b/crates/ra_hir_expand/Cargo.toml @@ -16,7 +16,7 @@ rustc-hash = "1.0.0" arena = { path = "../arena" } ra_db = { path = "../ra_db" } ra_syntax = { path = "../ra_syntax" } -ra_parser = { path = "../ra_parser" } +parser = { path = "../parser" } profile = { path = "../profile" } tt = { path = "../tt" } mbe = { path = "../ra_mbe", package = "ra_mbe" } diff --git a/crates/ra_hir_expand/src/builtin_derive.rs b/crates/ra_hir_expand/src/builtin_derive.rs index 69fa907cb8..95e6977f24 100644 --- a/crates/ra_hir_expand/src/builtin_derive.rs +++ b/crates/ra_hir_expand/src/builtin_derive.rs @@ -2,7 +2,7 @@ use log::debug; -use ra_parser::FragmentKind; +use parser::FragmentKind; use ra_syntax::{ ast::{self, AstNode, GenericParamsOwner, ModuleItemOwner, NameOwner}, match_ast, diff --git a/crates/ra_hir_expand/src/builtin_macro.rs b/crates/ra_hir_expand/src/builtin_macro.rs index 9f50569dc4..24dc0b4e7f 100644 --- a/crates/ra_hir_expand/src/builtin_macro.rs +++ b/crates/ra_hir_expand/src/builtin_macro.rs @@ -6,8 +6,8 @@ use crate::{ use either::Either; use mbe::parse_to_token_tree; +use parser::FragmentKind; use ra_db::FileId; -use ra_parser::FragmentKind; use ra_syntax::ast::{self, AstToken, HasStringValue}; macro_rules! register_builtin { diff --git a/crates/ra_hir_expand/src/db.rs b/crates/ra_hir_expand/src/db.rs index f30528b3e2..d83c391a90 100644 --- a/crates/ra_hir_expand/src/db.rs +++ b/crates/ra_hir_expand/src/db.rs @@ -3,8 +3,8 @@ use std::sync::Arc; use mbe::{ExpandResult, MacroRules}; +use parser::FragmentKind; use ra_db::{salsa, SourceDatabase}; -use ra_parser::FragmentKind; use ra_syntax::{algo::diff, AstNode, GreenNode, Parse, SyntaxKind::*, SyntaxNode}; use crate::{ diff --git a/crates/ra_hir_expand/src/eager.rs b/crates/ra_hir_expand/src/eager.rs index 302d2b3e09..dc83044ea4 100644 --- a/crates/ra_hir_expand/src/eager.rs +++ b/crates/ra_hir_expand/src/eager.rs @@ -25,8 +25,8 @@ use crate::{ EagerCallLoc, EagerMacroId, InFile, MacroCallId, MacroCallKind, MacroDefId, MacroDefKind, }; +use parser::FragmentKind; use ra_db::CrateId; -use ra_parser::FragmentKind; use ra_syntax::{algo::SyntaxRewriter, SyntaxNode}; use std::sync::Arc; diff --git a/crates/ra_hir_expand/src/lib.rs b/crates/ra_hir_expand/src/lib.rs index 8bb735fc62..38f0ffff81 100644 --- a/crates/ra_hir_expand/src/lib.rs +++ b/crates/ra_hir_expand/src/lib.rs @@ -317,7 +317,7 @@ pub struct ExpansionInfo { } pub use mbe::Origin; -use ra_parser::FragmentKind; +use parser::FragmentKind; impl ExpansionInfo { pub fn call_node(&self) -> Option> { diff --git a/crates/ra_mbe/Cargo.toml b/crates/ra_mbe/Cargo.toml index 23315910c4..e518f73e32 100644 --- a/crates/ra_mbe/Cargo.toml +++ b/crates/ra_mbe/Cargo.toml @@ -10,7 +10,7 @@ doctest = false [dependencies] ra_syntax = { path = "../ra_syntax" } -ra_parser = { path = "../ra_parser" } +parser = { path = "../parser" } tt = { path = "../tt" } rustc-hash = "1.1.0" smallvec = "1.2.0" diff --git a/crates/ra_mbe/src/mbe_expander/matcher.rs b/crates/ra_mbe/src/mbe_expander/matcher.rs index 933a3a3b5e..c752804b29 100644 --- a/crates/ra_mbe/src/mbe_expander/matcher.rs +++ b/crates/ra_mbe/src/mbe_expander/matcher.rs @@ -9,7 +9,7 @@ use crate::{ }; use super::ExpandResult; -use ra_parser::{FragmentKind::*, TreeSink}; +use parser::{FragmentKind::*, TreeSink}; use ra_syntax::{SmolStr, SyntaxKind}; use tt::buffer::{Cursor, TokenBuffer}; @@ -285,7 +285,7 @@ impl<'a> TtIter<'a> { pub(crate) fn expect_fragment( &mut self, - fragment_kind: ra_parser::FragmentKind, + fragment_kind: parser::FragmentKind, ) -> ExpandResult> { pub(crate) struct OffsetTokenSink<'a> { pub(crate) cursor: Cursor<'a>, @@ -303,7 +303,7 @@ impl<'a> TtIter<'a> { } fn start_node(&mut self, _kind: SyntaxKind) {} fn finish_node(&mut self) {} - fn error(&mut self, _error: ra_parser::ParseError) { + fn error(&mut self, _error: parser::ParseError) { self.error = true; } } @@ -312,7 +312,7 @@ impl<'a> TtIter<'a> { let mut src = SubtreeTokenSource::new(&buffer); let mut sink = OffsetTokenSink { cursor: buffer.begin(), error: false }; - ra_parser::parse_fragment(&mut src, &mut sink, fragment_kind); + parser::parse_fragment(&mut src, &mut sink, fragment_kind); let mut err = None; if !sink.cursor.is_root() || sink.error { diff --git a/crates/ra_mbe/src/subtree_source.rs b/crates/ra_mbe/src/subtree_source.rs index d7866452dd..1a1cb08cf7 100644 --- a/crates/ra_mbe/src/subtree_source.rs +++ b/crates/ra_mbe/src/subtree_source.rs @@ -1,6 +1,6 @@ //! FIXME: write short doc here -use ra_parser::{Token, TokenSource}; +use parser::{Token, TokenSource}; use ra_syntax::{lex_single_syntax_kind, SmolStr, SyntaxKind, SyntaxKind::*, T}; use std::cell::{Cell, Ref, RefCell}; use tt::buffer::{Cursor, TokenBuffer}; diff --git a/crates/ra_mbe/src/syntax_bridge.rs b/crates/ra_mbe/src/syntax_bridge.rs index 5fc48507ff..7b9c88ae64 100644 --- a/crates/ra_mbe/src/syntax_bridge.rs +++ b/crates/ra_mbe/src/syntax_bridge.rs @@ -1,6 +1,6 @@ //! FIXME: write short doc here -use ra_parser::{FragmentKind, ParseError, TreeSink}; +use parser::{FragmentKind, ParseError, TreeSink}; use ra_syntax::{ ast::{self, make::tokens::doc_comment}, tokenize, AstToken, Parse, SmolStr, SyntaxKind, @@ -81,7 +81,7 @@ pub fn token_tree_to_syntax_node( let buffer = TokenBuffer::new(&tokens); let mut token_source = SubtreeTokenSource::new(&buffer); let mut tree_sink = TtTreeSink::new(buffer.begin()); - ra_parser::parse_fragment(&mut token_source, &mut tree_sink, fragment_kind); + parser::parse_fragment(&mut token_source, &mut tree_sink, fragment_kind); if tree_sink.roots.len() != 1 { return Err(ExpandError::ConversionError); } @@ -715,7 +715,7 @@ impl<'a> TreeSink for TtTreeSink<'a> { mod tests { use super::*; use crate::tests::parse_macro; - use ra_parser::TokenSource; + use parser::TokenSource; use ra_syntax::{ algo::{insert_children, InsertPosition}, ast::AstNode, diff --git a/crates/ra_mbe/src/tests.rs b/crates/ra_mbe/src/tests.rs index 286983d60b..be39b0e45e 100644 --- a/crates/ra_mbe/src/tests.rs +++ b/crates/ra_mbe/src/tests.rs @@ -1,6 +1,6 @@ use std::fmt::Write; -use ra_parser::FragmentKind; +use ::parser::FragmentKind; use ra_syntax::{ast, AstNode, NodeOrToken, SyntaxKind::IDENT, SyntaxNode, WalkEvent, T}; use test_utils::assert_eq_text; @@ -9,9 +9,10 @@ use super::*; mod rule_parsing { use ra_syntax::{ast, AstNode}; - use super::*; use crate::ast_to_token_tree; + use super::*; + #[test] fn test_valid_arms() { fn check(macro_body: &str) { diff --git a/crates/ra_syntax/Cargo.toml b/crates/ra_syntax/Cargo.toml index f2789e6a35..eec4bd845e 100644 --- a/crates/ra_syntax/Cargo.toml +++ b/crates/ra_syntax/Cargo.toml @@ -21,7 +21,7 @@ once_cell = "1.3.1" stdx = { path = "../stdx" } text_edit = { path = "../text_edit" } -ra_parser = { path = "../ra_parser" } +parser = { path = "../parser" } # This crate transitively depends on `smol_str` via `rowan`. # ideally, `serde` should be enabled by `rust-analyzer`, but we enable it here diff --git a/crates/ra_syntax/src/ast/node_ext.rs b/crates/ra_syntax/src/ast/node_ext.rs index 733e978772..50c1c157d8 100644 --- a/crates/ra_syntax/src/ast/node_ext.rs +++ b/crates/ra_syntax/src/ast/node_ext.rs @@ -4,7 +4,7 @@ use std::fmt; use itertools::Itertools; -use ra_parser::SyntaxKind; +use parser::SyntaxKind; use crate::{ ast::{self, support, AstNode, NameOwner, SyntaxNode}, diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs index 465607f550..7f8da66af0 100644 --- a/crates/ra_syntax/src/lib.rs +++ b/crates/ra_syntax/src/lib.rs @@ -11,7 +11,7 @@ //! //! The most interesting modules here are `syntax_node` (which defines concrete //! syntax tree) and `ast` (which defines abstract syntax tree on top of the -//! CST). The actual parser live in a separate `ra_parser` crate, though the +//! CST). The actual parser live in a separate `parser` crate, though the //! lexer lives in this crate. //! //! See `api_walkthrough` test in this file for a quick API tour! @@ -53,7 +53,7 @@ pub use crate::{ SyntaxNodeChildren, SyntaxToken, SyntaxTreeBuilder, }, }; -pub use ra_parser::{SyntaxKind, T}; +pub use parser::{SyntaxKind, T}; pub use rowan::{SmolStr, SyntaxText, TextRange, TextSize, TokenAtOffset, WalkEvent}; /// `Parse` is the result of the parsing: a syntax tree and a collection of @@ -169,35 +169,35 @@ impl SourceFile { impl ast::Path { /// Returns `text`, parsed as a path, but only if it has no errors. pub fn parse(text: &str) -> Result { - parsing::parse_text_fragment(text, ra_parser::FragmentKind::Path) + parsing::parse_text_fragment(text, parser::FragmentKind::Path) } } impl ast::Pat { /// Returns `text`, parsed as a pattern, but only if it has no errors. pub fn parse(text: &str) -> Result { - parsing::parse_text_fragment(text, ra_parser::FragmentKind::Pattern) + parsing::parse_text_fragment(text, parser::FragmentKind::Pattern) } } impl ast::Expr { /// Returns `text`, parsed as an expression, but only if it has no errors. pub fn parse(text: &str) -> Result { - parsing::parse_text_fragment(text, ra_parser::FragmentKind::Expr) + parsing::parse_text_fragment(text, parser::FragmentKind::Expr) } } impl ast::Item { /// Returns `text`, parsed as an item, but only if it has no errors. pub fn parse(text: &str) -> Result { - parsing::parse_text_fragment(text, ra_parser::FragmentKind::Item) + parsing::parse_text_fragment(text, parser::FragmentKind::Item) } } impl ast::Type { /// Returns `text`, parsed as an type reference, but only if it has no errors. pub fn parse(text: &str) -> Result { - parsing::parse_text_fragment(text, ra_parser::FragmentKind::Type) + parsing::parse_text_fragment(text, parser::FragmentKind::Type) } } diff --git a/crates/ra_syntax/src/parsing.rs b/crates/ra_syntax/src/parsing.rs index 0ed3c20ef9..68a39eb210 100644 --- a/crates/ra_syntax/src/parsing.rs +++ b/crates/ra_syntax/src/parsing.rs @@ -1,4 +1,4 @@ -//! Lexing, bridging to ra_parser (which does the actual parsing) and +//! Lexing, bridging to parser (which does the actual parsing) and //! incremental reparsing. mod lexer; @@ -13,7 +13,7 @@ use text_tree_sink::TextTreeSink; pub use lexer::*; pub(crate) use self::reparsing::incremental_reparse; -use ra_parser::SyntaxKind; +use parser::SyntaxKind; pub(crate) fn parse_text(text: &str) -> (GreenNode, Vec) { let (tokens, lexer_errors) = tokenize(&text); @@ -21,7 +21,7 @@ pub(crate) fn parse_text(text: &str) -> (GreenNode, Vec) { let mut token_source = TextTokenSource::new(text, &tokens); let mut tree_sink = TextTreeSink::new(text, &tokens); - ra_parser::parse(&mut token_source, &mut tree_sink); + parser::parse(&mut token_source, &mut tree_sink); let (tree, mut parser_errors) = tree_sink.finish(); parser_errors.extend(lexer_errors); @@ -32,7 +32,7 @@ pub(crate) fn parse_text(text: &str) -> (GreenNode, Vec) { /// Returns `text` parsed as a `T` provided there are no parse errors. pub(crate) fn parse_text_fragment( text: &str, - fragment_kind: ra_parser::FragmentKind, + fragment_kind: parser::FragmentKind, ) -> Result { let (tokens, lexer_errors) = tokenize(&text); if !lexer_errors.is_empty() { @@ -44,13 +44,13 @@ pub(crate) fn parse_text_fragment( // TextTreeSink assumes that there's at least some root node to which it can attach errors and // tokens. We arbitrarily give it a SourceFile. - use ra_parser::TreeSink; + use parser::TreeSink; tree_sink.start_node(SyntaxKind::SOURCE_FILE); - ra_parser::parse_fragment(&mut token_source, &mut tree_sink, fragment_kind); + parser::parse_fragment(&mut token_source, &mut tree_sink, fragment_kind); tree_sink.finish_node(); let (tree, parser_errors) = tree_sink.finish(); - use ra_parser::TokenSource; + use parser::TokenSource; if !parser_errors.is_empty() || token_source.current().kind != SyntaxKind::EOF { return Err(()); } diff --git a/crates/ra_syntax/src/parsing/reparsing.rs b/crates/ra_syntax/src/parsing/reparsing.rs index 6644ffca4f..4149f856a8 100644 --- a/crates/ra_syntax/src/parsing/reparsing.rs +++ b/crates/ra_syntax/src/parsing/reparsing.rs @@ -6,7 +6,7 @@ //! - otherwise, we search for the nearest `{}` block which contains the edit //! and try to parse only this block. -use ra_parser::Reparser; +use parser::Reparser; use text_edit::Indel; use crate::{ diff --git a/crates/ra_syntax/src/parsing/text_token_source.rs b/crates/ra_syntax/src/parsing/text_token_source.rs index 97aa3e7951..df866dc2b7 100644 --- a/crates/ra_syntax/src/parsing/text_token_source.rs +++ b/crates/ra_syntax/src/parsing/text_token_source.rs @@ -1,10 +1,10 @@ //! See `TextTokenSource` docs. -use ra_parser::TokenSource; +use parser::TokenSource; use crate::{parsing::lexer::Token, SyntaxKind::EOF, TextRange, TextSize}; -/// Implementation of `ra_parser::TokenSource` that takes tokens from source code text. +/// Implementation of `parser::TokenSource` that takes tokens from source code text. pub(crate) struct TextTokenSource<'t> { text: &'t str, /// token and its start position (non-whitespace/comment tokens) @@ -20,15 +20,15 @@ pub(crate) struct TextTokenSource<'t> { token_offset_pairs: Vec<(Token, TextSize)>, /// Current token and position - curr: (ra_parser::Token, usize), + curr: (parser::Token, usize), } impl<'t> TokenSource for TextTokenSource<'t> { - fn current(&self) -> ra_parser::Token { + fn current(&self) -> parser::Token { self.curr.0 } - fn lookahead_nth(&self, n: usize) -> ra_parser::Token { + fn lookahead_nth(&self, n: usize) -> parser::Token { mk_token(self.curr.1 + n, &self.token_offset_pairs) } @@ -49,7 +49,7 @@ impl<'t> TokenSource for TextTokenSource<'t> { } } -fn mk_token(pos: usize, token_offset_pairs: &[(Token, TextSize)]) -> ra_parser::Token { +fn mk_token(pos: usize, token_offset_pairs: &[(Token, TextSize)]) -> parser::Token { let (kind, is_jointed_to_next) = match token_offset_pairs.get(pos) { Some((token, offset)) => ( token.kind, @@ -60,7 +60,7 @@ fn mk_token(pos: usize, token_offset_pairs: &[(Token, TextSize)]) -> ra_parser:: ), None => (EOF, false), }; - ra_parser::Token { kind, is_jointed_to_next } + parser::Token { kind, is_jointed_to_next } } impl<'t> TextTokenSource<'t> { diff --git a/crates/ra_syntax/src/parsing/text_tree_sink.rs b/crates/ra_syntax/src/parsing/text_tree_sink.rs index 6d1828d203..c1b5f246d1 100644 --- a/crates/ra_syntax/src/parsing/text_tree_sink.rs +++ b/crates/ra_syntax/src/parsing/text_tree_sink.rs @@ -2,7 +2,7 @@ use std::mem; -use ra_parser::{ParseError, TreeSink}; +use parser::{ParseError, TreeSink}; use crate::{ parsing::Token, diff --git a/crates/ra_syntax/src/syntax_node.rs b/crates/ra_syntax/src/syntax_node.rs index a7dbdba7b1..b2abcbfbb3 100644 --- a/crates/ra_syntax/src/syntax_node.rs +++ b/crates/ra_syntax/src/syntax_node.rs @@ -71,7 +71,7 @@ impl SyntaxTreeBuilder { self.inner.finish_node() } - pub fn error(&mut self, error: ra_parser::ParseError, text_pos: TextSize) { + pub fn error(&mut self, error: parser::ParseError, text_pos: TextSize) { self.errors.push(SyntaxError::new_at_offset(*error.0, text_pos)) } } diff --git a/docs/dev/README.md b/docs/dev/README.md index 51cf716b3d..33829c5937 100644 --- a/docs/dev/README.md +++ b/docs/dev/README.md @@ -92,11 +92,11 @@ This is primarily useful for performance optimizations, or for bug minimization. ## Parser Tests -Tests for the parser (`ra_parser`) live in the `ra_syntax` crate (see `test_data` directory). +Tests for the parser (`parser`) live in the `ra_syntax` crate (see `test_data` directory). There are two kinds of tests: * Manually written test cases in `parser/ok` and `parser/err` -* "Inline" tests in `parser/inline` (these are generated) from comments in `ra_parser` crate. +* "Inline" tests in `parser/inline` (these are generated) from comments in `parser` crate. The purpose of inline tests is not to achieve full coverage by test cases, but to explain to the reader of the code what each particular `if` and `match` is responsible for. If you are tempted to add a large inline test, it might be a good idea to leave only the simplest example in place, and move the test to a manual `parser/ok` test. diff --git a/docs/dev/architecture.md b/docs/dev/architecture.md index d0c6eea61f..21373729c7 100644 --- a/docs/dev/architecture.md +++ b/docs/dev/architecture.md @@ -64,7 +64,7 @@ The source for 1 and 2 is in [`ast_src.rs`](https://github.com/rust-analyzer/rus ## Code Walk-Through -### `crates/ra_syntax`, `crates/ra_parser` +### `crates/ra_syntax`, `crates/parser` Rust syntax tree structure and parser. See [RFC](https://github.com/rust-lang/rfcs/pull/2256) and [./syntax.md](./syntax.md) for some design notes. diff --git a/docs/dev/syntax.md b/docs/dev/syntax.md index f1bcdc4aff..c08062ef4d 100644 --- a/docs/dev/syntax.md +++ b/docs/dev/syntax.md @@ -11,7 +11,7 @@ The things described are implemented in two places * [rowan](https://github.com/rust-analyzer/rowan/tree/v0.9.0) -- a generic library for rowan syntax trees. * [ra_syntax](https://github.com/rust-analyzer/rust-analyzer/tree/cf5bdf464cad7ceb9a67e07985a3f4d3799ec0b6/crates/ra_syntax) crate inside rust-analyzer which wraps `rowan` into rust-analyzer specific API. Nothing in rust-analyzer except this crate knows about `rowan`. -* [ra_parser](https://github.com/rust-analyzer/rust-analyzer/tree/cf5bdf464cad7ceb9a67e07985a3f4d3799ec0b6/crates/ra_parser) crate parses input tokens into an `ra_syntax` tree +* [parser](https://github.com/rust-analyzer/rust-analyzer/tree/cf5bdf464cad7ceb9a67e07985a3f4d3799ec0b6/crates/parser) crate parses input tokens into an `ra_syntax` tree ## Design Goals diff --git a/xtask/src/codegen.rs b/xtask/src/codegen.rs index f5f4b964a4..08e7a10b75 100644 --- a/xtask/src/codegen.rs +++ b/xtask/src/codegen.rs @@ -24,11 +24,11 @@ pub use self::{ gen_syntax::generate_syntax, }; -const GRAMMAR_DIR: &str = "crates/ra_parser/src/grammar"; +const GRAMMAR_DIR: &str = "crates/parser/src/grammar"; const OK_INLINE_TESTS_DIR: &str = "crates/ra_syntax/test_data/parser/inline/ok"; const ERR_INLINE_TESTS_DIR: &str = "crates/ra_syntax/test_data/parser/inline/err"; -const SYNTAX_KINDS: &str = "crates/ra_parser/src/syntax_kind/generated.rs"; +const SYNTAX_KINDS: &str = "crates/parser/src/syntax_kind/generated.rs"; const AST_NODES: &str = "crates/ra_syntax/src/ast/generated/nodes.rs"; const AST_TOKENS: &str = "crates/ra_syntax/src/ast/generated/tokens.rs"; diff --git a/xtask/tests/tidy.rs b/xtask/tests/tidy.rs index ddaab93ab7..f1a7e8288e 100644 --- a/xtask/tests/tidy.rs +++ b/xtask/tests/tidy.rs @@ -196,7 +196,7 @@ impl TidyDocs { "ra_hir_expand", "ra_ide", "ra_mbe", - "ra_parser", + "parser", "profile", "ra_project_model", "ra_syntax", From a1c187eef3ba08076aedb5154929f7eda8d1b424 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 12 Aug 2020 18:26:51 +0200 Subject: [PATCH 074/119] Rename ra_syntax -> syntax --- .gitattributes | 2 +- Cargo.lock | 68 +++++++++--------- crates/parser/src/grammar.rs | 2 +- crates/parser/src/lib.rs | 2 +- crates/ra_assists/Cargo.toml | 2 +- crates/ra_assists/src/assist_context.rs | 4 +- crates/ra_assists/src/ast_transform.rs | 22 +++--- .../src/handlers/add_custom_impl.rs | 2 +- .../src/handlers/add_explicit_type.rs | 2 +- .../src/handlers/add_missing_impl_members.rs | 2 +- .../ra_assists/src/handlers/add_turbo_fish.rs | 2 +- .../ra_assists/src/handlers/apply_demorgan.rs | 2 +- crates/ra_assists/src/handlers/auto_import.rs | 4 +- .../handlers/change_return_type_to_result.rs | 2 +- .../src/handlers/change_visibility.rs | 2 +- .../ra_assists/src/handlers/early_return.rs | 2 +- .../src/handlers/expand_glob_import.rs | 2 +- .../extract_struct_from_enum_variant.rs | 4 +- .../src/handlers/extract_variable.rs | 4 +- .../src/handlers/fill_match_arms.rs | 2 +- .../ra_assists/src/handlers/fix_visibility.rs | 2 +- .../ra_assists/src/handlers/flip_binexpr.rs | 2 +- crates/ra_assists/src/handlers/flip_comma.rs | 2 +- .../src/handlers/flip_trait_bound.rs | 2 +- .../src/handlers/generate_derive.rs | 2 +- .../handlers/generate_from_impl_for_enum.rs | 2 +- .../src/handlers/generate_function.rs | 4 +- .../ra_assists/src/handlers/generate_impl.rs | 2 +- .../ra_assists/src/handlers/generate_new.rs | 4 +- .../src/handlers/inline_local_variable.rs | 2 +- .../src/handlers/introduce_named_lifetime.rs | 4 +- crates/ra_assists/src/handlers/invert_if.rs | 2 +- .../ra_assists/src/handlers/merge_imports.rs | 2 +- .../src/handlers/merge_match_arms.rs | 2 +- crates/ra_assists/src/handlers/move_bounds.rs | 2 +- crates/ra_assists/src/handlers/move_guard.rs | 2 +- crates/ra_assists/src/handlers/raw_string.rs | 2 +- crates/ra_assists/src/handlers/remove_dbg.rs | 2 +- crates/ra_assists/src/handlers/remove_mut.rs | 2 +- .../ra_assists/src/handlers/reorder_fields.rs | 2 +- .../src/handlers/replace_if_let_with_match.rs | 2 +- .../src/handlers/replace_let_with_if_let.rs | 2 +- .../replace_qualified_name_with_use.rs | 2 +- .../src/handlers/replace_unwrap_with_match.rs | 2 +- .../ra_assists/src/handlers/split_import.rs | 2 +- .../ra_assists/src/handlers/unwrap_block.rs | 2 +- crates/ra_assists/src/lib.rs | 2 +- crates/ra_assists/src/tests.rs | 2 +- crates/ra_assists/src/utils.rs | 4 +- crates/ra_assists/src/utils/insert_use.rs | 2 +- crates/ra_cfg/Cargo.toml | 2 +- crates/ra_cfg/src/cfg_expr.rs | 4 +- crates/ra_cfg/src/lib.rs | 2 +- crates/ra_db/Cargo.toml | 2 +- crates/ra_db/src/input.rs | 2 +- crates/ra_db/src/lib.rs | 2 +- crates/ra_fmt/Cargo.toml | 2 +- crates/ra_fmt/src/lib.rs | 2 +- crates/ra_hir/Cargo.toml | 2 +- crates/ra_hir/src/code_model.rs | 6 +- crates/ra_hir/src/has_source.rs | 2 +- crates/ra_hir/src/semantics.rs | 4 +- crates/ra_hir/src/semantics/source_to_def.rs | 6 +- crates/ra_hir/src/source_analyzer.rs | 2 +- crates/ra_hir_def/Cargo.toml | 2 +- crates/ra_hir_def/src/adt.rs | 2 +- crates/ra_hir_def/src/attr.rs | 2 +- crates/ra_hir_def/src/body.rs | 2 +- crates/ra_hir_def/src/body/lower.rs | 4 +- crates/ra_hir_def/src/body/scope.rs | 2 +- crates/ra_hir_def/src/data.rs | 2 +- crates/ra_hir_def/src/db.rs | 2 +- crates/ra_hir_def/src/diagnostics.rs | 2 +- crates/ra_hir_def/src/docs.rs | 2 +- crates/ra_hir_def/src/expr.rs | 4 +- crates/ra_hir_def/src/find_path.rs | 23 +++--- crates/ra_hir_def/src/generics.rs | 2 +- crates/ra_hir_def/src/import_map.rs | 2 +- crates/ra_hir_def/src/item_tree.rs | 2 +- crates/ra_hir_def/src/item_tree/lower.rs | 4 +- crates/ra_hir_def/src/item_tree/tests.rs | 62 ++++++++-------- crates/ra_hir_def/src/keys.rs | 2 +- crates/ra_hir_def/src/lang_item.rs | 2 +- crates/ra_hir_def/src/lib.rs | 2 +- crates/ra_hir_def/src/nameres.rs | 4 +- crates/ra_hir_def/src/nameres/collector.rs | 2 +- .../ra_hir_def/src/nameres/mod_resolution.rs | 2 +- .../src/nameres/tests/mod_resolution.rs | 2 +- crates/ra_hir_def/src/path.rs | 2 +- crates/ra_hir_def/src/path/lower.rs | 2 +- crates/ra_hir_def/src/path/lower/lower_use.rs | 2 +- crates/ra_hir_def/src/type_ref.rs | 2 +- crates/ra_hir_def/src/visibility.rs | 2 +- crates/ra_hir_expand/Cargo.toml | 2 +- crates/ra_hir_expand/src/ast_id_map.rs | 2 +- crates/ra_hir_expand/src/builtin_derive.rs | 2 +- crates/ra_hir_expand/src/builtin_macro.rs | 4 +- crates/ra_hir_expand/src/db.rs | 10 +-- crates/ra_hir_expand/src/diagnostics.rs | 2 +- crates/ra_hir_expand/src/eager.rs | 2 +- crates/ra_hir_expand/src/hygiene.rs | 2 +- crates/ra_hir_expand/src/lib.rs | 2 +- crates/ra_hir_expand/src/name.rs | 6 +- crates/ra_hir_ty/Cargo.toml | 2 +- crates/ra_hir_ty/src/diagnostics.rs | 4 +- crates/ra_hir_ty/src/diagnostics/expr.rs | 2 +- crates/ra_hir_ty/src/infer.rs | 2 +- crates/ra_hir_ty/src/infer/expr.rs | 2 +- crates/ra_hir_ty/src/test_db.rs | 2 +- crates/ra_hir_ty/src/tests.rs | 4 +- crates/ra_hir_ty/src/tests/macros.rs | 2 +- crates/ra_ide/Cargo.toml | 2 +- crates/ra_ide/src/call_hierarchy.rs | 2 +- crates/ra_ide/src/call_info.rs | 4 +- .../src/completion/complete_attribute.rs | 2 +- .../src/completion/complete_fn_param.rs | 4 +- .../ra_ide/src/completion/complete_keyword.rs | 2 +- .../ra_ide/src/completion/complete_postfix.rs | 2 +- .../src/completion/complete_qualified_path.rs | 2 +- .../src/completion/complete_trait_impl.rs | 2 +- .../completion/complete_unqualified_path.rs | 2 +- .../src/completion/completion_context.rs | 2 +- .../ra_ide/src/completion/completion_item.rs | 2 +- crates/ra_ide/src/completion/patterns.rs | 2 +- crates/ra_ide/src/completion/presentation.rs | 2 +- crates/ra_ide/src/completion/test_utils.rs | 2 +- crates/ra_ide/src/diagnostics.rs | 2 +- .../src/diagnostics/diagnostics_with_fix.rs | 2 +- crates/ra_ide/src/display.rs | 2 +- .../ra_ide/src/display/navigation_target.rs | 2 +- crates/ra_ide/src/display/short_label.rs | 2 +- crates/ra_ide/src/expand_macro.rs | 2 +- crates/ra_ide/src/extend_selection.rs | 2 +- crates/ra_ide/src/file_structure.rs | 2 +- crates/ra_ide/src/folding_ranges.rs | 2 +- crates/ra_ide/src/goto_definition.rs | 4 +- crates/ra_ide/src/goto_implementation.rs | 2 +- crates/ra_ide/src/goto_type_definition.rs | 2 +- crates/ra_ide/src/hover.rs | 2 +- crates/ra_ide/src/inlay_hints.rs | 4 +- crates/ra_ide/src/join_lines.rs | 20 +++--- crates/ra_ide/src/lib.rs | 2 +- crates/ra_ide/src/matching_brace.rs | 2 +- crates/ra_ide/src/parent_module.rs | 2 +- crates/ra_ide/src/references.rs | 2 +- crates/ra_ide/src/references/rename.rs | 4 +- crates/ra_ide/src/runnables.rs | 2 +- crates/ra_ide/src/status.rs | 2 +- crates/ra_ide/src/syntax_highlighting.rs | 4 +- crates/ra_ide/src/syntax_highlighting/html.rs | 2 +- .../src/syntax_highlighting/injection.rs | 2 +- .../ra_ide/src/syntax_highlighting/tests.rs | 2 +- crates/ra_ide/src/syntax_tree.rs | 2 +- crates/ra_ide/src/typing.rs | 2 +- crates/ra_ide/src/typing/on_enter.rs | 2 +- crates/ra_ide_db/Cargo.toml | 2 +- crates/ra_ide_db/src/defs.rs | 2 +- crates/ra_ide_db/src/imports_locator.rs | 2 +- crates/ra_ide_db/src/line_index.rs | 2 +- crates/ra_ide_db/src/search.rs | 2 +- crates/ra_ide_db/src/symbol_index.rs | 6 +- crates/ra_mbe/Cargo.toml | 2 +- crates/ra_mbe/src/mbe_expander.rs | 4 +- crates/ra_mbe/src/mbe_expander/matcher.rs | 2 +- crates/ra_mbe/src/mbe_expander/transcriber.rs | 2 +- crates/ra_mbe/src/parser.rs | 2 +- crates/ra_mbe/src/subtree_source.rs | 2 +- crates/ra_mbe/src/syntax_bridge.rs | 8 +-- crates/ra_mbe/src/tests.rs | 8 +-- crates/ra_ssr/Cargo.toml | 2 +- crates/ra_ssr/src/lib.rs | 2 +- crates/ra_ssr/src/matching.rs | 8 +-- crates/ra_ssr/src/nester.rs | 2 +- crates/ra_ssr/src/parsing.rs | 4 +- crates/ra_ssr/src/replacing.rs | 8 +-- crates/ra_ssr/src/resolving.rs | 8 +-- crates/ra_ssr/src/search.rs | 2 +- crates/rust-analyzer/Cargo.toml | 2 +- crates/rust-analyzer/src/cargo_target_spec.rs | 2 +- crates/rust-analyzer/src/cli.rs | 2 +- .../rust-analyzer/src/cli/analysis_stats.rs | 2 +- crates/rust-analyzer/src/from_proto.rs | 2 +- crates/rust-analyzer/src/handlers.rs | 2 +- crates/rust-analyzer/src/to_proto.rs | 2 +- crates/{ra_syntax => syntax}/Cargo.toml | 25 ++++--- crates/{ra_syntax => syntax}/fuzz/.gitignore | 0 crates/{ra_syntax => syntax}/fuzz/Cargo.toml | 4 +- .../fuzz/fuzz_targets/parser.rs | 2 +- .../fuzz/fuzz_targets/reparse.rs | 2 +- crates/{ra_syntax => syntax}/src/algo.rs | 0 crates/{ra_syntax => syntax}/src/ast.rs | 0 crates/{ra_syntax => syntax}/src/ast/edit.rs | 0 .../{ra_syntax => syntax}/src/ast/expr_ext.rs | 0 .../src/ast/generated.rs | 0 .../src/ast/generated/nodes.rs | 0 .../src/ast/generated/tokens.rs | 0 crates/{ra_syntax => syntax}/src/ast/make.rs | 0 .../{ra_syntax => syntax}/src/ast/node_ext.rs | 0 .../src/ast/token_ext.rs | 0 .../{ra_syntax => syntax}/src/ast/traits.rs | 0 crates/{ra_syntax => syntax}/src/fuzz.rs | 0 crates/{ra_syntax => syntax}/src/lib.rs | 0 crates/{ra_syntax => syntax}/src/parsing.rs | 0 .../src/parsing/lexer.rs | 0 .../src/parsing/reparsing.rs | 0 .../src/parsing/text_token_source.rs | 0 .../src/parsing/text_tree_sink.rs | 0 crates/{ra_syntax => syntax}/src/ptr.rs | 0 .../{ra_syntax => syntax}/src/syntax_error.rs | 0 .../{ra_syntax => syntax}/src/syntax_node.rs | 0 crates/{ra_syntax => syntax}/src/tests.rs | 4 +- .../{ra_syntax => syntax}/src/validation.rs | 0 .../src/validation/block.rs | 0 .../test_data/accidentally_quadratic | 0 .../lexer/err/0001_unclosed_char_at_eof.rs | 0 .../lexer/err/0001_unclosed_char_at_eof.txt | 0 .../err/0002_unclosed_char_with_ferris.rs | 0 .../err/0002_unclosed_char_with_ferris.txt | 0 .../0003_unclosed_char_with_ascii_escape.rs | 0 .../0003_unclosed_char_with_ascii_escape.txt | 0 .../0004_unclosed_char_with_unicode_escape.rs | 0 ...0004_unclosed_char_with_unicode_escape.txt | 0 .../err/0005_unclosed_char_with_space.rs | 0 .../err/0005_unclosed_char_with_space.txt | 0 .../err/0006_unclosed_char_with_slash.rs | 0 .../err/0006_unclosed_char_with_slash.txt | 0 .../err/0007_unclosed_char_with_slash_n.rs | 0 .../err/0007_unclosed_char_with_slash_n.txt | 0 ...8_unclosed_char_with_slash_single_quote.rs | 0 ..._unclosed_char_with_slash_single_quote.txt | 0 .../lexer/err/0009_unclosed_byte_at_eof.rs | 0 .../lexer/err/0009_unclosed_byte_at_eof.txt | 0 .../err/0010_unclosed_byte_with_ferris.rs | 0 .../err/0010_unclosed_byte_with_ferris.txt | 0 .../0011_unclosed_byte_with_ascii_escape.rs | 0 .../0011_unclosed_byte_with_ascii_escape.txt | 0 .../0012_unclosed_byte_with_unicode_escape.rs | 0 ...0012_unclosed_byte_with_unicode_escape.txt | 0 .../err/0013_unclosed_byte_with_space.rs | 0 .../err/0013_unclosed_byte_with_space.txt | 0 .../err/0014_unclosed_byte_with_slash.rs | 0 .../err/0014_unclosed_byte_with_slash.txt | 0 .../err/0015_unclosed_byte_with_slash_n.rs | 0 .../err/0015_unclosed_byte_with_slash_n.txt | 0 ...6_unclosed_byte_with_slash_single_quote.rs | 0 ..._unclosed_byte_with_slash_single_quote.txt | 0 .../lexer/err/0017_unclosed_string_at_eof.rs | 0 .../lexer/err/0017_unclosed_string_at_eof.txt | 0 .../err/0018_unclosed_string_with_ferris.rs | 0 .../err/0018_unclosed_string_with_ferris.txt | 0 .../0019_unclosed_string_with_ascii_escape.rs | 0 ...0019_unclosed_string_with_ascii_escape.txt | 0 ...020_unclosed_string_with_unicode_escape.rs | 0 ...20_unclosed_string_with_unicode_escape.txt | 0 .../err/0021_unclosed_string_with_space.rs | 0 .../err/0021_unclosed_string_with_space.txt | 0 .../err/0022_unclosed_string_with_slash.rs | 0 .../err/0022_unclosed_string_with_slash.txt | 0 .../err/0023_unclosed_string_with_slash_n.rs | 0 .../err/0023_unclosed_string_with_slash_n.txt | 0 ...unclosed_string_with_slash_double_quote.rs | 0 ...nclosed_string_with_slash_double_quote.txt | 0 .../err/0025_unclosed_byte_string_at_eof.rs | 0 .../err/0025_unclosed_byte_string_at_eof.txt | 0 .../0026_unclosed_byte_string_with_ferris.rs | 0 .../0026_unclosed_byte_string_with_ferris.txt | 0 ..._unclosed_byte_string_with_ascii_escape.rs | 0 ...unclosed_byte_string_with_ascii_escape.txt | 0 ...nclosed_byte_string_with_unicode_escape.rs | 0 ...closed_byte_string_with_unicode_escape.txt | 0 .../0029_unclosed_byte_string_with_space.rs | 0 .../0029_unclosed_byte_string_with_space.txt | 0 .../0030_unclosed_byte_string_with_slash.rs | 0 .../0030_unclosed_byte_string_with_slash.txt | 0 .../0031_unclosed_byte_string_with_slash_n.rs | 0 ...0031_unclosed_byte_string_with_slash_n.txt | 0 ...sed_byte_string_with_slash_double_quote.rs | 0 ...ed_byte_string_with_slash_double_quote.txt | 0 .../err/0033_unclosed_raw_string_at_eof.rs | 0 .../err/0033_unclosed_raw_string_at_eof.txt | 0 .../0034_unclosed_raw_string_with_ferris.rs | 0 .../0034_unclosed_raw_string_with_ferris.txt | 0 ...5_unclosed_raw_string_with_ascii_escape.rs | 0 ..._unclosed_raw_string_with_ascii_escape.txt | 0 ...unclosed_raw_string_with_unicode_escape.rs | 0 ...nclosed_raw_string_with_unicode_escape.txt | 0 .../0037_unclosed_raw_string_with_space.rs | 0 .../0037_unclosed_raw_string_with_space.txt | 0 .../0038_unclosed_raw_string_with_slash.rs | 0 .../0038_unclosed_raw_string_with_slash.txt | 0 .../0039_unclosed_raw_string_with_slash_n.rs | 0 .../0039_unclosed_raw_string_with_slash_n.txt | 0 .../0040_unclosed_raw_byte_string_at_eof.rs | 0 .../0040_unclosed_raw_byte_string_at_eof.txt | 0 ...41_unclosed_raw_byte_string_with_ferris.rs | 0 ...1_unclosed_raw_byte_string_with_ferris.txt | 0 ...losed_raw_byte_string_with_ascii_escape.rs | 0 ...osed_raw_byte_string_with_ascii_escape.txt | 0 ...sed_raw_byte_string_with_unicode_escape.rs | 0 ...ed_raw_byte_string_with_unicode_escape.txt | 0 ...044_unclosed_raw_byte_string_with_space.rs | 0 ...44_unclosed_raw_byte_string_with_space.txt | 0 ...045_unclosed_raw_byte_string_with_slash.rs | 0 ...45_unclosed_raw_byte_string_with_slash.txt | 0 ...6_unclosed_raw_byte_string_with_slash_n.rs | 0 ..._unclosed_raw_byte_string_with_slash_n.txt | 0 .../err/0047_unstarted_raw_string_at_eof.rs | 0 .../err/0047_unstarted_raw_string_at_eof.txt | 0 .../0048_unstarted_raw_byte_string_at_eof.rs | 0 .../0048_unstarted_raw_byte_string_at_eof.txt | 0 .../0049_unstarted_raw_string_with_ascii.rs | 0 .../0049_unstarted_raw_string_with_ascii.txt | 0 ...50_unstarted_raw_byte_string_with_ascii.rs | 0 ...0_unstarted_raw_byte_string_with_ascii.txt | 0 .../err/0051_unclosed_block_comment_at_eof.rs | 0 .../0051_unclosed_block_comment_at_eof.txt | 0 ...052_unclosed_block_comment_with_content.rs | 0 ...52_unclosed_block_comment_with_content.txt | 0 ..._unclosed_nested_block_comment_entirely.rs | 0 ...unclosed_nested_block_comment_entirely.txt | 0 ...unclosed_nested_block_comment_partially.rs | 0 ...nclosed_nested_block_comment_partially.txt | 0 .../test_data/lexer/err/0055_empty_int.rs | 0 .../test_data/lexer/err/0055_empty_int.txt | 0 .../lexer/err/0056_empty_exponent.rs | 0 .../lexer/err/0056_empty_exponent.txt | 0 .../0057_lifetime_strarts_with_a_number.rs | 0 .../0057_lifetime_strarts_with_a_number.txt | 0 .../test_data/lexer/ok/0001_hello.rs | 0 .../test_data/lexer/ok/0001_hello.txt | 0 .../test_data/lexer/ok/0002_whitespace.rs | 0 .../test_data/lexer/ok/0002_whitespace.txt | 0 .../test_data/lexer/ok/0003_ident.rs | 0 .../test_data/lexer/ok/0003_ident.txt | 0 .../test_data/lexer/ok/0004_numbers.rs | 0 .../test_data/lexer/ok/0004_numbers.txt | 0 .../test_data/lexer/ok/0005_symbols.rs | 0 .../test_data/lexer/ok/0005_symbols.txt | 0 .../test_data/lexer/ok/0006_chars.rs | 0 .../test_data/lexer/ok/0006_chars.txt | 0 .../test_data/lexer/ok/0007_lifetimes.rs | 0 .../test_data/lexer/ok/0007_lifetimes.txt | 0 .../test_data/lexer/ok/0008_byte_strings.rs | 0 .../test_data/lexer/ok/0008_byte_strings.txt | 0 .../test_data/lexer/ok/0009_strings.rs | 0 .../test_data/lexer/ok/0009_strings.txt | 0 .../lexer/ok/0010_single_line_comments.rs | 0 .../lexer/ok/0010_single_line_comments.txt | 0 .../test_data/lexer/ok/0011_keywords.rs | 0 .../test_data/lexer/ok/0011_keywords.txt | 0 .../test_data/lexer/ok/0012_block_comment.rs | 0 .../test_data/lexer/ok/0012_block_comment.txt | 0 .../test_data/lexer/ok/0013_raw_strings.rs | 0 .../test_data/lexer/ok/0013_raw_strings.txt | 0 .../test_data/lexer/ok/0014_raw_ident.rs | 0 .../test_data/lexer/ok/0014_raw_ident.txt | 0 .../err/0000_struct_field_missing_comma.rast | 0 .../err/0000_struct_field_missing_comma.rs | 0 .../err/0001_item_recovery_in_file.rast | 0 .../parser/err/0001_item_recovery_in_file.rs | 0 .../parser/err/0002_duplicate_shebang.rast | 0 .../parser/err/0002_duplicate_shebang.rs | 0 .../parser/err/0003_C++_semicolon.rast | 0 .../parser/err/0003_C++_semicolon.rs | 0 .../parser/err/0004_use_path_bad_segment.rast | 0 .../parser/err/0004_use_path_bad_segment.rs | 0 .../parser/err/0005_attribute_recover.rast | 0 .../parser/err/0005_attribute_recover.rs | 0 .../parser/err/0006_named_field_recovery.rast | 0 .../parser/err/0006_named_field_recovery.rs | 0 .../parser/err/0007_stray_curly_in_file.rast | 0 .../parser/err/0007_stray_curly_in_file.rs | 0 .../parser/err/0008_item_block_recovery.rast | 0 .../parser/err/0008_item_block_recovery.rs | 0 .../0009_broken_struct_type_parameter.rast | 0 .../err/0009_broken_struct_type_parameter.rs | 0 .../parser/err/0010_unsafe_lambda_block.rast | 0 .../parser/err/0010_unsafe_lambda_block.rs | 0 .../parser/err/0011_extern_struct.rast | 0 .../parser/err/0011_extern_struct.rs | 0 .../parser/err/0012_broken_lambda.rast | 0 .../parser/err/0013_invalid_type.rast | 0 .../test_data/parser/err/0013_invalid_type.rs | 0 .../parser/err/0014_where_no_bounds.rast | 0 .../parser/err/0014_where_no_bounds.rs | 0 .../parser/err/0015_curly_in_params.rast | 0 .../parser/err/0015_curly_in_params.rs | 0 .../parser/err/0016_missing_semi.rast | 0 .../test_data/parser/err/0016_missing_semi.rs | 0 .../parser/err/0017_incomplete_binexpr.rast | 0 .../parser/err/0017_incomplete_binexpr.rs | 0 .../parser/err/0018_incomplete_fn.rast | 0 .../parser/err/0018_incomplete_fn.rs | 0 .../parser/err/0019_let_recover.rast | 0 .../test_data/parser/err/0019_let_recover.rs | 0 .../test_data/parser/err/0020_fn_recover.rast | 0 .../test_data/parser/err/0020_fn_recover.rs | 0 .../parser/err/0021_incomplete_param.rast | 0 .../parser/err/0021_incomplete_param.rs | 0 .../test_data/parser/err/0022_bad_exprs.rast | 0 .../test_data/parser/err/0022_bad_exprs.rs | 0 .../parser/err/0023_mismatched_paren.rast | 0 .../parser/err/0023_mismatched_paren.rs | 0 .../parser/err/0024_many_type_parens.rast | 0 .../parser/err/0024_many_type_parens.rs | 0 .../test_data/parser/err/0025_nope.rast | 0 .../test_data/parser/err/0025_nope.rs | 0 .../parser/err/0026_imp_recovery.rast | 0 .../test_data/parser/err/0026_imp_recovery.rs | 0 .../parser/err/0027_incomplere_where_for.rast | 0 .../parser/err/0027_incomplere_where_for.rs | 0 .../parser/err/0029_field_completion.rast | 0 .../parser/err/0029_field_completion.rs | 0 .../parser/err/0031_block_inner_attrs.rast | 0 .../parser/err/0031_block_inner_attrs.rs | 0 .../err/0032_match_arms_inner_attrs.rast | 0 .../parser/err/0032_match_arms_inner_attrs.rs | 0 .../err/0033_match_arms_outer_attrs.rast | 0 .../parser/err/0033_match_arms_outer_attrs.rs | 0 .../parser/err/0034_bad_box_pattern.rast | 0 .../parser/err/0034_bad_box_pattern.rs | 0 .../parser/err/0035_use_recover.rast | 0 .../test_data/parser/err/0035_use_recover.rs | 0 .../parser/err/0036_partial_use.rast | 0 .../test_data/parser/err/0036_partial_use.rs | 0 .../parser/err/0037_visibility_in_traits.rast | 0 .../parser/err/0037_visibility_in_traits.rs | 0 .../err/0038_endless_inclusive_range.rast | 0 .../err/0038_endless_inclusive_range.rs | 0 .../parser/err/0039_lambda_recovery.rast | 0 .../parser/err/0039_lambda_recovery.rs | 0 .../err/0040_illegal_crate_kw_location.rast | 0 .../err/0040_illegal_crate_kw_location.rs | 0 .../0041_illegal_super_keyword_location.rast | 0 .../0041_illegal_super_keyword_location.rs | 0 .../0042_illegal_self_keyword_location.rast | 0 .../err/0042_illegal_self_keyword_location.rs | 0 .../parser/err/0043_weird_blocks.rast | 0 .../test_data/parser/err/0043_weird_blocks.rs | 0 .../parser/err/0044_unexpected_for_type.rast | 0 .../parser/err/0044_unexpected_for_type.rs | 0 .../parser/err/0045_item_modifiers.rast | 0 .../parser/err/0045_item_modifiers.rs | 0 .../expr/err/0000_truncated_add.rast | 0 .../fragments/expr/err/0000_truncated_add.rs | 0 .../parser/fragments/expr/ok/0000_add.rast | 0 .../parser/fragments/expr/ok/0000_add.rs | 0 .../item/err/0000_extra_keyword.rast | 0 .../fragments/item/err/0000_extra_keyword.rs | 0 .../parser/fragments/item/ok/0000_fn.rast | 0 .../parser/fragments/item/ok/0000_fn.rs | 0 .../path/err/0000_reserved_word.rast | 0 .../fragments/path/err/0000_reserved_word.rs | 0 .../fragments/path/err/0001_expression.rast | 0 .../fragments/path/err/0001_expression.rs | 0 .../fragments/path/ok/0000_single_ident.rast | 0 .../fragments/path/ok/0000_single_ident.rs | 0 .../fragments/path/ok/0001_multipart.rast | 0 .../fragments/path/ok/0001_multipart.rs | 0 .../pattern/err/0000_reserved_word.rast | 0 .../pattern/err/0000_reserved_word.rs | 0 .../pattern/err/0001_missing_paren.rast | 0 .../pattern/err/0001_missing_paren.rs | 0 .../fragments/pattern/ok/0000_enum.rast | 0 .../parser/fragments/pattern/ok/0000_enum.rs | 0 .../type/err/0000_missing_close.rast | 0 .../fragments/type/err/0000_missing_close.rs | 0 .../parser/fragments/type/ok/0000_result.rast | 0 .../parser/fragments/type/ok/0000_result.rs | 0 .../test_data/parser/fuzz-failures/0000.rs | 0 .../test_data/parser/fuzz-failures/0001.rs | 2 +- .../test_data/parser/fuzz-failures/0002.rs | 0 .../test_data/parser/fuzz-failures/0003.rs | 0 .../test_data/parser/fuzz-failures/0004.rs | 0 .../err/0001_array_type_missing_semi.rast | 0 .../err/0001_array_type_missing_semi.rs | 0 .../inline/err/0002_misplaced_label_err.rast | 0 .../inline/err/0002_misplaced_label_err.rs | 0 .../err/0003_pointer_type_no_mutability.rast | 0 .../err/0003_pointer_type_no_mutability.rs | 0 .../parser/inline/err/0004_impl_type.rast | 0 .../parser/inline/err/0004_impl_type.rs | 0 .../err/0005_fn_pointer_type_missing_fn.rast | 0 .../err/0005_fn_pointer_type_missing_fn.rs | 0 .../inline/err/0006_unsafe_block_in_mod.rast | 0 .../inline/err/0006_unsafe_block_in_mod.rs | 0 .../err/0007_async_without_semicolon.rast | 0 .../err/0007_async_without_semicolon.rs | 0 .../parser/inline/err/0008_pub_expr.rast | 0 .../parser/inline/err/0008_pub_expr.rs | 0 .../err/0009_attr_on_expr_not_allowed.rast | 0 .../err/0009_attr_on_expr_not_allowed.rs | 0 .../inline/err/0010_bad_tuple_index_expr.rast | 0 .../inline/err/0010_bad_tuple_index_expr.rs | 0 .../inline/err/0013_static_underscore.rast | 0 .../inline/err/0013_static_underscore.rs | 0 ...cord_literal_before_ellipsis_recovery.rast | 0 ...record_literal_before_ellipsis_recovery.rs | 0 .../parser/inline/err/0015_empty_segment.rast | 0 .../parser/inline/err/0015_empty_segment.rs | 0 .../inline/ok/0001_trait_item_list.rast | 0 .../parser/inline/ok/0001_trait_item_list.rs | 0 .../parser/inline/ok/0002_use_tree_list.rast | 0 .../parser/inline/ok/0002_use_tree_list.rs | 0 .../parser/inline/ok/0003_where_pred_for.rast | 0 .../parser/inline/ok/0003_where_pred_for.rs | 0 .../ok/0004_value_parameters_no_patterns.rast | 0 .../ok/0004_value_parameters_no_patterns.rs | 0 .../inline/ok/0005_function_type_params.rast | 0 .../inline/ok/0005_function_type_params.rs | 0 .../parser/inline/ok/0006_self_param.rast | 0 .../parser/inline/ok/0006_self_param.rs | 0 .../inline/ok/0007_type_param_bounds.rast | 0 .../inline/ok/0007_type_param_bounds.rs | 0 .../parser/inline/ok/0008_path_part.rast | 0 .../parser/inline/ok/0008_path_part.rs | 0 .../parser/inline/ok/0009_loop_expr.rast | 0 .../parser/inline/ok/0009_loop_expr.rs | 0 .../parser/inline/ok/0010_extern_block.rast | 0 .../parser/inline/ok/0010_extern_block.rs | 0 .../parser/inline/ok/0011_field_expr.rast | 0 .../parser/inline/ok/0011_field_expr.rs | 0 .../ok/0012_type_item_where_clause.rast | 0 .../inline/ok/0012_type_item_where_clause.rs | 0 .../inline/ok/0013_pointer_type_mut.rast | 0 .../parser/inline/ok/0013_pointer_type_mut.rs | 0 .../parser/inline/ok/0014_never_type.rast | 0 .../parser/inline/ok/0014_never_type.rs | 0 .../parser/inline/ok/0015_continue_expr.rast | 0 .../parser/inline/ok/0015_continue_expr.rs | 0 .../parser/inline/ok/0017_array_type.rast | 0 .../parser/inline/ok/0017_array_type.rs | 0 .../parser/inline/ok/0018_arb_self_types.rast | 0 .../parser/inline/ok/0018_arb_self_types.rs | 0 .../parser/inline/ok/0019_unary_expr.rast | 0 .../parser/inline/ok/0019_unary_expr.rs | 0 .../parser/inline/ok/0020_use_star.rast | 0 .../parser/inline/ok/0020_use_star.rs | 0 .../parser/inline/ok/0021_impl_item_list.rast | 0 .../parser/inline/ok/0021_impl_item_list.rs | 0 .../inline/ok/0022_crate_visibility.rast | 0 .../parser/inline/ok/0022_crate_visibility.rs | 0 .../inline/ok/0023_placeholder_type.rast | 0 .../parser/inline/ok/0023_placeholder_type.rs | 0 .../parser/inline/ok/0024_slice_pat.rast | 0 .../parser/inline/ok/0024_slice_pat.rs | 0 .../parser/inline/ok/0025_slice_type.rast | 0 .../parser/inline/ok/0025_slice_type.rs | 0 .../inline/ok/0026_tuple_pat_fields.rast | 0 .../parser/inline/ok/0026_tuple_pat_fields.rs | 0 .../parser/inline/ok/0027_ref_pat.rast | 0 .../parser/inline/ok/0027_ref_pat.rs | 0 .../inline/ok/0028_impl_trait_type.rast | 0 .../parser/inline/ok/0028_impl_trait_type.rs | 0 .../parser/inline/ok/0029_cast_expr.rast | 0 .../parser/inline/ok/0029_cast_expr.rs | 0 .../test_data/parser/inline/ok/0030_cond.rast | 0 .../test_data/parser/inline/ok/0030_cond.rs | 0 .../parser/inline/ok/0031_while_expr.rast | 0 .../parser/inline/ok/0031_while_expr.rs | 0 .../inline/ok/0032_fn_pointer_type.rast | 0 .../parser/inline/ok/0032_fn_pointer_type.rs | 0 .../inline/ok/0033_reference_type;.rast | 0 .../parser/inline/ok/0033_reference_type;.rs | 0 .../parser/inline/ok/0034_break_expr.rast | 0 .../parser/inline/ok/0034_break_expr.rs | 0 .../parser/inline/ok/0037_qual_paths.rast | 0 .../parser/inline/ok/0037_qual_paths.rs | 0 .../inline/ok/0038_full_range_expr.rast | 0 .../parser/inline/ok/0038_full_range_expr.rs | 0 .../parser/inline/ok/0039_type_arg.rast | 0 .../parser/inline/ok/0039_type_arg.rs | 0 .../inline/ok/0040_crate_keyword_vis.rast | 0 .../inline/ok/0040_crate_keyword_vis.rs | 0 .../parser/inline/ok/0041_trait_item.rast | 0 .../parser/inline/ok/0041_trait_item.rs | 0 .../parser/inline/ok/0042_call_expr.rast | 0 .../parser/inline/ok/0042_call_expr.rs | 0 .../parser/inline/ok/0043_use_alias.rast | 0 .../parser/inline/ok/0043_use_alias.rs | 0 .../parser/inline/ok/0044_block_items.rast | 0 .../parser/inline/ok/0044_block_items.rs | 0 .../ok/0045_param_list_opt_patterns.rast | 0 .../inline/ok/0045_param_list_opt_patterns.rs | 0 .../inline/ok/0046_singleton_tuple_type.rast | 0 .../inline/ok/0046_singleton_tuple_type.rs | 0 .../inline/ok/0048_path_type_with_bounds.rast | 0 .../inline/ok/0048_path_type_with_bounds.rs | 0 .../parser/inline/ok/0050_fn_decl.rast | 0 .../parser/inline/ok/0050_fn_decl.rs | 0 .../parser/inline/ok/0051_unit_type.rast | 0 .../parser/inline/ok/0051_unit_type.rs | 0 .../parser/inline/ok/0052_path_type.rast | 0 .../parser/inline/ok/0052_path_type.rs | 0 .../parser/inline/ok/0053_path_expr.rast | 0 .../parser/inline/ok/0053_path_expr.rs | 0 .../inline/ok/0054_record_field_attrs.rast | 0 .../inline/ok/0054_record_field_attrs.rs | 0 .../inline/ok/0055_literal_pattern.rast | 0 .../parser/inline/ok/0055_literal_pattern.rs | 0 .../parser/inline/ok/0056_where_clause.rast | 0 .../parser/inline/ok/0056_where_clause.rs | 0 .../parser/inline/ok/0058_range_pat.rast | 0 .../parser/inline/ok/0058_range_pat.rs | 0 .../inline/ok/0059_match_arms_commas.rast | 0 .../inline/ok/0059_match_arms_commas.rs | 0 .../parser/inline/ok/0060_extern_crate.rast | 0 .../parser/inline/ok/0060_extern_crate.rs | 0 .../parser/inline/ok/0061_record_lit.rast | 0 .../parser/inline/ok/0061_record_lit.rs | 0 .../parser/inline/ok/0062_mod_contents.rast | 0 .../parser/inline/ok/0062_mod_contents.rs | 0 .../parser/inline/ok/0063_impl_def_neg.rast | 0 .../parser/inline/ok/0063_impl_def_neg.rs | 0 .../parser/inline/ok/0064_if_expr.rast | 0 .../parser/inline/ok/0064_if_expr.rs | 0 .../parser/inline/ok/0065_dyn_trait_type.rast | 0 .../parser/inline/ok/0065_dyn_trait_type.rs | 0 .../parser/inline/ok/0066_match_arm.rast | 0 .../parser/inline/ok/0066_match_arm.rs | 0 .../parser/inline/ok/0067_crate_path.rast | 0 .../parser/inline/ok/0067_crate_path.rs | 0 .../parser/inline/ok/0068_union_items.rast | 0 .../parser/inline/ok/0068_union_items.rs | 0 .../ok/0069_use_tree_list_after_path.rast | 0 .../ok/0069_use_tree_list_after_path.rs | 0 .../ok/0070_stmt_bin_expr_ambiguity.rast | 0 .../inline/ok/0070_stmt_bin_expr_ambiguity.rs | 0 .../parser/inline/ok/0071_match_expr.rast | 0 .../parser/inline/ok/0071_match_expr.rs | 0 .../parser/inline/ok/0072_return_expr.rast | 0 .../parser/inline/ok/0072_return_expr.rs | 0 .../inline/ok/0073_type_item_type_params.rast | 0 .../inline/ok/0073_type_item_type_params.rs | 0 .../ok/0074_stmt_postfix_expr_ambiguity.rast | 0 .../ok/0074_stmt_postfix_expr_ambiguity.rs | 0 .../parser/inline/ok/0075_block.rast | 0 .../test_data/parser/inline/ok/0075_block.rs | 0 .../inline/ok/0076_function_where_clause.rast | 0 .../inline/ok/0076_function_where_clause.rs | 0 .../parser/inline/ok/0077_try_expr.rast | 0 .../parser/inline/ok/0077_try_expr.rs | 0 .../parser/inline/ok/0078_type_item.rast | 0 .../parser/inline/ok/0078_type_item.rs | 0 .../parser/inline/ok/0079_impl_def.rast | 0 .../parser/inline/ok/0079_impl_def.rs | 0 .../parser/inline/ok/0080_postfix_range.rast | 0 .../parser/inline/ok/0080_postfix_range.rs | 0 .../parser/inline/ok/0081_for_type.rast | 0 .../parser/inline/ok/0081_for_type.rs | 0 .../parser/inline/ok/0082_ref_expr.rast | 0 .../parser/inline/ok/0082_ref_expr.rs | 0 .../parser/inline/ok/0083_struct_items.rast | 0 .../parser/inline/ok/0083_struct_items.rs | 0 .../parser/inline/ok/0084_paren_type.rast | 0 .../parser/inline/ok/0084_paren_type.rs | 0 .../parser/inline/ok/0085_expr_literals.rast | 0 .../parser/inline/ok/0085_expr_literals.rs | 0 .../inline/ok/0086_function_ret_type.rast | 0 .../inline/ok/0086_function_ret_type.rs | 0 .../inline/ok/0088_break_ambiguity.rast | 0 .../parser/inline/ok/0088_break_ambiguity.rs | 0 .../inline/ok/0090_type_param_default.rast | 0 .../inline/ok/0090_type_param_default.rs | 0 .../ok/0092_fn_pointer_type_with_ret.rast | 0 .../ok/0092_fn_pointer_type_with_ret.rs | 0 .../parser/inline/ok/0093_index_expr.rast | 0 .../parser/inline/ok/0093_index_expr.rs | 0 .../inline/ok/0095_placeholder_pat.rast | 0 .../parser/inline/ok/0095_placeholder_pat.rs | 0 .../inline/ok/0096_no_semi_after_block.rast | 0 .../inline/ok/0096_no_semi_after_block.rs | 0 .../parser/inline/ok/0099_param_list.rast | 0 .../parser/inline/ok/0099_param_list.rs | 0 .../parser/inline/ok/0100_for_expr.rast | 0 .../parser/inline/ok/0100_for_expr.rs | 0 .../inline/ok/0102_record_field_pat_list.rast | 0 .../inline/ok/0102_record_field_pat_list.rs | 0 .../parser/inline/ok/0103_array_expr.rast | 0 .../parser/inline/ok/0103_array_expr.rs | 0 .../inline/ok/0104_path_fn_trait_args.rast | 0 .../inline/ok/0104_path_fn_trait_args.rs | 0 .../parser/inline/ok/0106_lambda_expr.rast | 0 .../parser/inline/ok/0106_lambda_expr.rs | 0 .../inline/ok/0107_method_call_expr.rast | 0 .../parser/inline/ok/0107_method_call_expr.rs | 0 .../parser/inline/ok/0108_tuple_expr.rast | 0 .../parser/inline/ok/0108_tuple_expr.rs | 0 .../parser/inline/ok/0109_label.rast | 0 .../test_data/parser/inline/ok/0109_label.rs | 0 .../parser/inline/ok/0110_use_path.rast | 0 .../parser/inline/ok/0110_use_path.rs | 0 .../parser/inline/ok/0111_tuple_pat.rast | 0 .../parser/inline/ok/0111_tuple_pat.rs | 0 .../parser/inline/ok/0112_bind_pat.rast | 0 .../parser/inline/ok/0112_bind_pat.rs | 0 .../parser/inline/ok/0113_nocontentexpr.rast | 0 .../parser/inline/ok/0113_nocontentexpr.rs | 0 .../inline/ok/0114_tuple_struct_where.rast | 0 .../inline/ok/0114_tuple_struct_where.rs | 0 .../inline/ok/0115_tuple_field_attrs.rast | 0 .../inline/ok/0115_tuple_field_attrs.rs | 0 .../inline/ok/0117_macro_call_type.rast | 0 .../parser/inline/ok/0117_macro_call_type.rs | 0 .../inline/ok/0118_impl_inner_attributes.rast | 0 .../inline/ok/0118_impl_inner_attributes.rs | 0 .../parser/inline/ok/0118_match_guard.rast | 0 .../parser/inline/ok/0118_match_guard.rs | 0 .../ok/0120_match_arms_inner_attribute.rast | 0 .../ok/0120_match_arms_inner_attribute.rs | 0 .../ok/0121_match_arms_outer_attributes.rast | 0 .../ok/0121_match_arms_outer_attributes.rs | 0 .../0122_generic_lifetime_type_attribute.rast | 0 .../0122_generic_lifetime_type_attribute.rs | 0 .../inline/ok/0123_param_list_vararg.rast | 0 .../inline/ok/0123_param_list_vararg.rs | 0 .../inline/ok/0125_crate_keyword_path.rast | 0 .../inline/ok/0125_crate_keyword_path.rs | 0 .../0125_record_literal_field_with_attr.rast | 0 .../ok/0125_record_literal_field_with_attr.rs | 0 .../inline/ok/0126_attr_on_expr_stmt.rast | 0 .../inline/ok/0126_attr_on_expr_stmt.rs | 0 .../ok/0127_attr_on_last_expr_in_block.rast | 0 .../ok/0127_attr_on_last_expr_in_block.rs | 0 .../parser/inline/ok/0129_marco_pat.rast | 0 .../parser/inline/ok/0129_marco_pat.rs | 0 .../parser/inline/ok/0130_let_stmt.rast | 0 .../parser/inline/ok/0130_let_stmt.rs | 0 .../parser/inline/ok/0130_try_block_expr.rast | 0 .../parser/inline/ok/0130_try_block_expr.rs | 0 .../inline/ok/0131_existential_type.rast | 0 .../parser/inline/ok/0131_existential_type.rs | 0 .../parser/inline/ok/0132_box_expr.rast | 0 .../parser/inline/ok/0132_box_expr.rs | 0 .../ok/0134_nocontentexpr_after_item.rast | 0 .../ok/0134_nocontentexpr_after_item.rs | 0 .../parser/inline/ok/0137_await_expr.rast | 0 .../parser/inline/ok/0137_await_expr.rs | 0 .../ok/0138_associated_type_bounds.rast | 0 .../inline/ok/0138_associated_type_bounds.rs | 0 .../ok/0138_expression_after_block.rast | 0 .../inline/ok/0138_expression_after_block.rs | 0 .../inline/ok/0138_self_param_outer_attr.rast | 0 .../inline/ok/0138_self_param_outer_attr.rs | 0 .../inline/ok/0139_param_outer_arg.rast | 0 .../parser/inline/ok/0139_param_outer_arg.rs | 0 .../parser/inline/ok/0142_for_range_from.rast | 0 .../parser/inline/ok/0142_for_range_from.rs | 0 .../parser/inline/ok/0143_box_pat.rast | 0 .../parser/inline/ok/0143_box_pat.rs | 0 .../parser/inline/ok/0144_dot_dot_pat.rast | 0 .../parser/inline/ok/0144_dot_dot_pat.rs | 0 .../inline/ok/0145_record_field_pat.rast | 0 .../parser/inline/ok/0145_record_field_pat.rs | 0 .../parser/inline/ok/0146_as_precedence.rast | 0 .../parser/inline/ok/0146_as_precedence.rs | 0 .../parser/inline/ok/0147_const_param.rast | 0 .../parser/inline/ok/0147_const_param.rs | 0 .../parser/inline/ok/0147_macro_def.rast | 0 .../parser/inline/ok/0147_macro_def.rs | 0 .../parser/inline/ok/0148_pub_macro_def.rast | 0 .../parser/inline/ok/0148_pub_macro_def.rs | 0 .../parser/inline/ok/0150_array_attrs.rast | 0 .../parser/inline/ok/0150_array_attrs.rs | 0 .../inline/ok/0150_impl_type_params.rast | 0 .../parser/inline/ok/0150_impl_type_params.rs | 0 .../test_data/parser/inline/ok/0151_fn.rast | 0 .../test_data/parser/inline/ok/0151_fn.rs | 0 .../parser/inline/ok/0151_trait_alias.rast | 0 .../parser/inline/ok/0151_trait_alias.rs | 0 .../parser/inline/ok/0152_arg_with_attr.rast | 0 .../parser/inline/ok/0152_arg_with_attr.rs | 0 .../test_data/parser/inline/ok/0152_impl.rast | 0 .../test_data/parser/inline/ok/0152_impl.rs | 0 .../parser/inline/ok/0153_trait.rast | 0 .../test_data/parser/inline/ok/0153_trait.rs | 0 .../ok/0154_fn_pointer_param_ident_path.rast | 0 .../ok/0154_fn_pointer_param_ident_path.rs | 0 .../parser/inline/ok/0155_closure_params.rast | 0 .../parser/inline/ok/0155_closure_params.rs | 0 .../parser/inline/ok/0156_fn_def_param.rast | 0 .../parser/inline/ok/0156_fn_def_param.rs | 0 .../parser/inline/ok/0156_or_pattern.rast | 0 .../parser/inline/ok/0156_or_pattern.rs | 0 .../ok/0157_fn_pointer_unnamed_arg.rast | 0 .../inline/ok/0157_fn_pointer_unnamed_arg.rs | 0 .../inline/ok/0157_variant_discriminant.rast | 0 .../inline/ok/0157_variant_discriminant.rs | 0 .../ok/0158_binop_resets_statementness.rast | 0 .../ok/0158_binop_resets_statementness.rs | 0 .../inline/ok/0158_lambda_ret_block.rast | 0 .../parser/inline/ok/0158_lambda_ret_block.rs | 0 .../inline/ok/0159_try_macro_fallback.rast | 0 .../inline/ok/0159_try_macro_fallback.rs | 0 .../inline/ok/0160_try_macro_rules.rast | 0 .../parser/inline/ok/0160_try_macro_rules.rs | 0 .../parser/inline/ok/0161_labeled_block.rast | 0 .../parser/inline/ok/0161_labeled_block.rs | 0 .../parser/inline/ok/0162_unsafe_block.rast | 0 .../parser/inline/ok/0162_unsafe_block.rs | 0 .../inline/ok/0163_default_unsafe_item.rast | 0 .../inline/ok/0163_default_unsafe_item.rs | 0 .../parser/inline/ok/0164_default_item.rast | 0 .../parser/inline/ok/0164_default_item.rs | 0 .../inline/ok/0164_type_path_in_pattern.rast | 0 .../inline/ok/0164_type_path_in_pattern.rs | 0 .../test_data/parser/ok/0000_empty.rast | 0 .../test_data/parser/ok/0000_empty.rs | 0 .../test_data/parser/ok/0001_struct_item.rast | 0 .../test_data/parser/ok/0001_struct_item.rs | 0 .../parser/ok/0002_struct_item_field.rast | 0 .../parser/ok/0002_struct_item_field.rs | 0 .../parser/ok/0004_file_shebang.rast | 0 .../test_data/parser/ok/0004_file_shebang.rs | 0 .../test_data/parser/ok/0005_fn_item.rast | 0 .../test_data/parser/ok/0005_fn_item.rs | 0 .../parser/ok/0006_inner_attributes.rast | 0 .../parser/ok/0006_inner_attributes.rs | 0 .../parser/ok/0007_extern_crate.rast | 0 .../test_data/parser/ok/0007_extern_crate.rs | 0 .../test_data/parser/ok/0008_mod_item.rast | 0 .../test_data/parser/ok/0008_mod_item.rs | 0 .../test_data/parser/ok/0009_use_item.rast | 0 .../test_data/parser/ok/0009_use_item.rs | 0 .../parser/ok/0010_use_path_segments.rast | 0 .../parser/ok/0010_use_path_segments.rs | 0 .../parser/ok/0011_outer_attribute.rast | 0 .../parser/ok/0011_outer_attribute.rs | 0 .../test_data/parser/ok/0012_visibility.rast | 0 .../test_data/parser/ok/0012_visibility.rs | 0 .../parser/ok/0013_use_path_self_super.rast | 0 .../parser/ok/0013_use_path_self_super.rs | 0 .../test_data/parser/ok/0014_use_tree.rast | 0 .../test_data/parser/ok/0014_use_tree.rs | 0 .../test_data/parser/ok/0015_use_tree.rast | 0 .../test_data/parser/ok/0015_use_tree.rs | 0 .../parser/ok/0016_struct_flavors.rast | 0 .../parser/ok/0016_struct_flavors.rs | 0 .../parser/ok/0017_attr_trailing_comma.rast | 0 .../parser/ok/0017_attr_trailing_comma.rs | 0 .../parser/ok/0018_struct_type_params.rast | 0 .../parser/ok/0018_struct_type_params.rs | 0 .../test_data/parser/ok/0019_enums.rast | 0 .../test_data/parser/ok/0019_enums.rs | 0 .../parser/ok/0020_type_param_bounds.rast | 0 .../parser/ok/0020_type_param_bounds.rs | 0 .../parser/ok/0022_empty_extern_block.rast | 0 .../parser/ok/0022_empty_extern_block.rs | 0 .../parser/ok/0023_static_items.rast | 0 .../test_data/parser/ok/0023_static_items.rs | 0 .../test_data/parser/ok/0024_const_item.rast | 0 .../test_data/parser/ok/0024_const_item.rs | 0 .../parser/ok/0025_extern_fn_in_block.rast | 0 .../parser/ok/0025_extern_fn_in_block.rs | 0 .../parser/ok/0026_const_fn_in_block.rast | 0 .../parser/ok/0026_const_fn_in_block.rs | 0 .../parser/ok/0027_unsafe_fn_in_block.rast | 0 .../parser/ok/0027_unsafe_fn_in_block.rs | 0 .../ok/0028_operator_binding_power.rast | 0 .../parser/ok/0028_operator_binding_power.rs | 0 .../test_data/parser/ok/0029_range_forms.rast | 0 .../test_data/parser/ok/0029_range_forms.rs | 0 .../parser/ok/0030_string_suffixes.rast | 0 .../parser/ok/0030_string_suffixes.rs | 0 .../test_data/parser/ok/0030_traits.rast | 0 .../test_data/parser/ok/0030_traits.rs | 0 .../test_data/parser/ok/0031_extern.rast | 0 .../test_data/parser/ok/0031_extern.rs | 0 .../test_data/parser/ok/0032_where_for.rast | 0 .../test_data/parser/ok/0032_where_for.rs | 0 .../test_data/parser/ok/0033_label_break.rast | 0 .../test_data/parser/ok/0033_label_break.rs | 0 .../parser/ok/0034_crate_path_in_call.rast | 0 .../parser/ok/0034_crate_path_in_call.rs | 0 .../test_data/parser/ok/0035_weird_exprs.rast | 0 .../test_data/parser/ok/0035_weird_exprs.rs | 0 .../parser/ok/0036_fully_qualified.rast | 0 .../parser/ok/0036_fully_qualified.rs | 0 .../test_data/parser/ok/0037_mod.rast | 0 .../test_data/parser/ok/0037_mod.rs | 0 .../parser/ok/0038_where_pred_type.rast | 0 .../parser/ok/0038_where_pred_type.rs | 0 .../test_data/parser/ok/0039_raw_fn_item.rast | 0 .../test_data/parser/ok/0039_raw_fn_item.rs | 0 .../parser/ok/0040_raw_struct_item_field.rast | 0 .../parser/ok/0040_raw_struct_item_field.rs | 0 .../parser/ok/0041_raw_keywords.rast | 0 .../test_data/parser/ok/0041_raw_keywords.rs | 0 .../parser/ok/0042_ufcs_call_list.rast | 0 .../parser/ok/0042_ufcs_call_list.rs | 0 .../parser/ok/0043_complex_assignment.rast | 0 .../parser/ok/0043_complex_assignment.rs | 0 .../test_data/parser/ok/0044_let_attrs.rast | 0 .../test_data/parser/ok/0044_let_attrs.rs | 0 .../parser/ok/0045_block_inner_attrs.rast | 0 .../parser/ok/0045_block_inner_attrs.rs | 0 .../ok/0046_extern_inner_attributes.rast | 0 .../parser/ok/0046_extern_inner_attributes.rs | 0 .../ok/0047_minus_in_inner_pattern.rast | 0 .../parser/ok/0047_minus_in_inner_pattern.rs | 0 .../parser/ok/0048_compound_assignment.rast | 0 .../parser/ok/0048_compound_assignment.rs | 0 .../test_data/parser/ok/0049_async_block.rast | 0 .../test_data/parser/ok/0049_async_block.rs | 0 .../ok/0050_async_block_as_argument.rast | 0 .../parser/ok/0050_async_block_as_argument.rs | 0 .../parser/ok/0051_parameter_attrs.rast | 0 .../parser/ok/0051_parameter_attrs.rs | 0 .../parser/ok/0052_for_range_block.rast | 0 .../parser/ok/0052_for_range_block.rs | 0 .../0053_outer_attribute_on_macro_rules.rast | 0 .../ok/0053_outer_attribute_on_macro_rules.rs | 0 .../parser/ok/0054_qual_path_in_type_arg.rast | 0 .../parser/ok/0054_qual_path_in_type_arg.rs | 0 .../test_data/parser/ok/0055_dot_dot_dot.rast | 0 .../test_data/parser/ok/0055_dot_dot_dot.rs | 0 .../test_data/parser/ok/0056_neq_in_type.rast | 0 .../test_data/parser/ok/0056_neq_in_type.rs | 0 .../parser/ok/0057_loop_in_call.rast | 0 .../test_data/parser/ok/0057_loop_in_call.rs | 0 .../parser/ok/0058_unary_expr_precedence.rast | 0 .../parser/ok/0058_unary_expr_precedence.rs | 0 .../parser/ok/0059_loops_in_parens.rast | 0 .../parser/ok/0059_loops_in_parens.rs | 0 .../test_data/parser/ok/0060_as_range.rast | 0 .../test_data/parser/ok/0060_as_range.rs | 0 .../parser/ok/0061_match_full_range.rast | 0 .../parser/ok/0061_match_full_range.rs | 0 .../test_data/parser/ok/0062_macro_2.0.rast | 0 .../test_data/parser/ok/0062_macro_2.0.rs | 0 .../parser/ok/0063_trait_fn_patterns.rast | 0 .../parser/ok/0063_trait_fn_patterns.rs | 0 .../parser/ok/0063_variadic_fun.rast | 0 .../test_data/parser/ok/0063_variadic_fun.rs | 0 .../parser/ok/0064_impl_fn_params.rast | 0 .../parser/ok/0064_impl_fn_params.rs | 0 .../parser/ok/0065_comment_newline.rast | 0 .../parser/ok/0065_comment_newline.rs | 0 .../ok/0065_plus_after_fn_trait_bound.rast | 0 .../ok/0065_plus_after_fn_trait_bound.rs | 0 .../parser/ok/0066_default_modifier.rast | 0 .../parser/ok/0066_default_modifier.rs | 0 .../parser/ok/0067_where_for_pred.rast | 0 .../parser/ok/0067_where_for_pred.rs | 0 .../parser/ok/0068_item_modifiers.rast | 0 .../parser/ok/0068_item_modifiers.rs | 0 .../test_data/reparse/fuzz-failures/0000.rs | 0 .../test_data/reparse/fuzz-failures/0001.rs | 0 .../test_data/reparse/fuzz-failures/0002.rs | 0 .../test_data/reparse/fuzz-failures/0003.rs | Bin .../test_data/reparse/fuzz-failures/0004.rs | 0 .../test_data/reparse/fuzz-failures/0005.rs | 0 docs/dev/README.md | 2 +- docs/dev/style.md | 4 +- xtask/src/codegen.rs | 8 +-- xtask/src/codegen/gen_syntax.rs | 2 +- xtask/src/lib.rs | 2 +- xtask/tests/tidy.rs | 2 +- 958 files changed, 353 insertions(+), 363 deletions(-) rename crates/{ra_syntax => syntax}/Cargo.toml (96%) rename crates/{ra_syntax => syntax}/fuzz/.gitignore (100%) rename crates/{ra_syntax => syntax}/fuzz/Cargo.toml (89%) rename crates/{ra_syntax => syntax}/fuzz/fuzz_targets/parser.rs (84%) rename crates/{ra_syntax => syntax}/fuzz/fuzz_targets/reparse.rs (84%) rename crates/{ra_syntax => syntax}/src/algo.rs (100%) rename crates/{ra_syntax => syntax}/src/ast.rs (100%) rename crates/{ra_syntax => syntax}/src/ast/edit.rs (100%) rename crates/{ra_syntax => syntax}/src/ast/expr_ext.rs (100%) rename crates/{ra_syntax => syntax}/src/ast/generated.rs (100%) rename crates/{ra_syntax => syntax}/src/ast/generated/nodes.rs (100%) rename crates/{ra_syntax => syntax}/src/ast/generated/tokens.rs (100%) rename crates/{ra_syntax => syntax}/src/ast/make.rs (100%) rename crates/{ra_syntax => syntax}/src/ast/node_ext.rs (100%) rename crates/{ra_syntax => syntax}/src/ast/token_ext.rs (100%) rename crates/{ra_syntax => syntax}/src/ast/traits.rs (100%) rename crates/{ra_syntax => syntax}/src/fuzz.rs (100%) rename crates/{ra_syntax => syntax}/src/lib.rs (100%) rename crates/{ra_syntax => syntax}/src/parsing.rs (100%) rename crates/{ra_syntax => syntax}/src/parsing/lexer.rs (100%) rename crates/{ra_syntax => syntax}/src/parsing/reparsing.rs (100%) rename crates/{ra_syntax => syntax}/src/parsing/text_token_source.rs (100%) rename crates/{ra_syntax => syntax}/src/parsing/text_tree_sink.rs (100%) rename crates/{ra_syntax => syntax}/src/ptr.rs (100%) rename crates/{ra_syntax => syntax}/src/syntax_error.rs (100%) rename crates/{ra_syntax => syntax}/src/syntax_node.rs (100%) rename crates/{ra_syntax => syntax}/src/tests.rs (98%) rename crates/{ra_syntax => syntax}/src/validation.rs (100%) rename crates/{ra_syntax => syntax}/src/validation/block.rs (100%) rename crates/{ra_syntax => syntax}/test_data/accidentally_quadratic (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0001_unclosed_char_at_eof.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0001_unclosed_char_at_eof.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0002_unclosed_char_with_ferris.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0002_unclosed_char_with_ferris.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0003_unclosed_char_with_ascii_escape.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0003_unclosed_char_with_ascii_escape.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0004_unclosed_char_with_unicode_escape.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0004_unclosed_char_with_unicode_escape.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0005_unclosed_char_with_space.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0005_unclosed_char_with_space.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0006_unclosed_char_with_slash.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0006_unclosed_char_with_slash.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0007_unclosed_char_with_slash_n.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0007_unclosed_char_with_slash_n.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0008_unclosed_char_with_slash_single_quote.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0008_unclosed_char_with_slash_single_quote.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0009_unclosed_byte_at_eof.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0009_unclosed_byte_at_eof.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0010_unclosed_byte_with_ferris.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0010_unclosed_byte_with_ferris.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0011_unclosed_byte_with_ascii_escape.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0011_unclosed_byte_with_ascii_escape.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0012_unclosed_byte_with_unicode_escape.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0012_unclosed_byte_with_unicode_escape.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0013_unclosed_byte_with_space.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0013_unclosed_byte_with_space.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0014_unclosed_byte_with_slash.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0014_unclosed_byte_with_slash.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0015_unclosed_byte_with_slash_n.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0015_unclosed_byte_with_slash_n.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0016_unclosed_byte_with_slash_single_quote.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0016_unclosed_byte_with_slash_single_quote.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0017_unclosed_string_at_eof.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0017_unclosed_string_at_eof.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0018_unclosed_string_with_ferris.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0018_unclosed_string_with_ferris.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0019_unclosed_string_with_ascii_escape.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0019_unclosed_string_with_ascii_escape.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0020_unclosed_string_with_unicode_escape.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0020_unclosed_string_with_unicode_escape.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0021_unclosed_string_with_space.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0021_unclosed_string_with_space.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0022_unclosed_string_with_slash.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0022_unclosed_string_with_slash.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0023_unclosed_string_with_slash_n.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0023_unclosed_string_with_slash_n.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0024_unclosed_string_with_slash_double_quote.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0024_unclosed_string_with_slash_double_quote.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0025_unclosed_byte_string_at_eof.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0025_unclosed_byte_string_at_eof.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0026_unclosed_byte_string_with_ferris.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0026_unclosed_byte_string_with_ferris.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0027_unclosed_byte_string_with_ascii_escape.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0027_unclosed_byte_string_with_ascii_escape.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0028_unclosed_byte_string_with_unicode_escape.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0028_unclosed_byte_string_with_unicode_escape.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0029_unclosed_byte_string_with_space.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0029_unclosed_byte_string_with_space.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0030_unclosed_byte_string_with_slash.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0030_unclosed_byte_string_with_slash.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0031_unclosed_byte_string_with_slash_n.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0031_unclosed_byte_string_with_slash_n.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0032_unclosed_byte_string_with_slash_double_quote.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0032_unclosed_byte_string_with_slash_double_quote.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0033_unclosed_raw_string_at_eof.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0033_unclosed_raw_string_at_eof.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0034_unclosed_raw_string_with_ferris.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0034_unclosed_raw_string_with_ferris.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0035_unclosed_raw_string_with_ascii_escape.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0035_unclosed_raw_string_with_ascii_escape.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0036_unclosed_raw_string_with_unicode_escape.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0036_unclosed_raw_string_with_unicode_escape.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0037_unclosed_raw_string_with_space.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0037_unclosed_raw_string_with_space.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0038_unclosed_raw_string_with_slash.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0038_unclosed_raw_string_with_slash.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0039_unclosed_raw_string_with_slash_n.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0039_unclosed_raw_string_with_slash_n.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0040_unclosed_raw_byte_string_at_eof.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0040_unclosed_raw_byte_string_at_eof.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0041_unclosed_raw_byte_string_with_ferris.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0041_unclosed_raw_byte_string_with_ferris.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0042_unclosed_raw_byte_string_with_ascii_escape.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0042_unclosed_raw_byte_string_with_ascii_escape.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0043_unclosed_raw_byte_string_with_unicode_escape.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0043_unclosed_raw_byte_string_with_unicode_escape.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0044_unclosed_raw_byte_string_with_space.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0044_unclosed_raw_byte_string_with_space.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0045_unclosed_raw_byte_string_with_slash.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0045_unclosed_raw_byte_string_with_slash.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0046_unclosed_raw_byte_string_with_slash_n.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0046_unclosed_raw_byte_string_with_slash_n.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0047_unstarted_raw_string_at_eof.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0047_unstarted_raw_string_at_eof.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0048_unstarted_raw_byte_string_at_eof.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0048_unstarted_raw_byte_string_at_eof.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0049_unstarted_raw_string_with_ascii.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0049_unstarted_raw_string_with_ascii.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0050_unstarted_raw_byte_string_with_ascii.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0050_unstarted_raw_byte_string_with_ascii.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0051_unclosed_block_comment_at_eof.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0051_unclosed_block_comment_at_eof.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0052_unclosed_block_comment_with_content.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0052_unclosed_block_comment_with_content.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0053_unclosed_nested_block_comment_entirely.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0053_unclosed_nested_block_comment_entirely.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0054_unclosed_nested_block_comment_partially.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0054_unclosed_nested_block_comment_partially.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0055_empty_int.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0055_empty_int.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0056_empty_exponent.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0056_empty_exponent.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0057_lifetime_strarts_with_a_number.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/err/0057_lifetime_strarts_with_a_number.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/ok/0001_hello.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/ok/0001_hello.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/ok/0002_whitespace.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/ok/0002_whitespace.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/ok/0003_ident.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/ok/0003_ident.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/ok/0004_numbers.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/ok/0004_numbers.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/ok/0005_symbols.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/ok/0005_symbols.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/ok/0006_chars.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/ok/0006_chars.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/ok/0007_lifetimes.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/ok/0007_lifetimes.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/ok/0008_byte_strings.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/ok/0008_byte_strings.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/ok/0009_strings.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/ok/0009_strings.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/ok/0010_single_line_comments.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/ok/0010_single_line_comments.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/ok/0011_keywords.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/ok/0011_keywords.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/ok/0012_block_comment.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/ok/0012_block_comment.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/ok/0013_raw_strings.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/ok/0013_raw_strings.txt (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/ok/0014_raw_ident.rs (100%) rename crates/{ra_syntax => syntax}/test_data/lexer/ok/0014_raw_ident.txt (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0000_struct_field_missing_comma.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0000_struct_field_missing_comma.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0001_item_recovery_in_file.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0001_item_recovery_in_file.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0002_duplicate_shebang.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0002_duplicate_shebang.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0003_C++_semicolon.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0003_C++_semicolon.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0004_use_path_bad_segment.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0004_use_path_bad_segment.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0005_attribute_recover.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0005_attribute_recover.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0006_named_field_recovery.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0006_named_field_recovery.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0007_stray_curly_in_file.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0007_stray_curly_in_file.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0008_item_block_recovery.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0008_item_block_recovery.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0009_broken_struct_type_parameter.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0009_broken_struct_type_parameter.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0010_unsafe_lambda_block.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0010_unsafe_lambda_block.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0011_extern_struct.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0011_extern_struct.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0012_broken_lambda.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0013_invalid_type.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0013_invalid_type.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0014_where_no_bounds.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0014_where_no_bounds.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0015_curly_in_params.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0015_curly_in_params.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0016_missing_semi.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0016_missing_semi.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0017_incomplete_binexpr.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0017_incomplete_binexpr.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0018_incomplete_fn.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0018_incomplete_fn.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0019_let_recover.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0019_let_recover.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0020_fn_recover.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0020_fn_recover.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0021_incomplete_param.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0021_incomplete_param.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0022_bad_exprs.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0022_bad_exprs.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0023_mismatched_paren.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0023_mismatched_paren.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0024_many_type_parens.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0024_many_type_parens.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0025_nope.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0025_nope.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0026_imp_recovery.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0026_imp_recovery.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0027_incomplere_where_for.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0027_incomplere_where_for.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0029_field_completion.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0029_field_completion.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0031_block_inner_attrs.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0031_block_inner_attrs.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0032_match_arms_inner_attrs.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0032_match_arms_inner_attrs.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0033_match_arms_outer_attrs.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0033_match_arms_outer_attrs.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0034_bad_box_pattern.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0034_bad_box_pattern.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0035_use_recover.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0035_use_recover.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0036_partial_use.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0036_partial_use.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0037_visibility_in_traits.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0037_visibility_in_traits.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0038_endless_inclusive_range.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0038_endless_inclusive_range.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0039_lambda_recovery.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0039_lambda_recovery.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0040_illegal_crate_kw_location.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0040_illegal_crate_kw_location.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0041_illegal_super_keyword_location.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0041_illegal_super_keyword_location.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0042_illegal_self_keyword_location.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0042_illegal_self_keyword_location.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0043_weird_blocks.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0043_weird_blocks.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0044_unexpected_for_type.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0044_unexpected_for_type.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0045_item_modifiers.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/err/0045_item_modifiers.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/fragments/expr/err/0000_truncated_add.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/fragments/expr/err/0000_truncated_add.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/fragments/expr/ok/0000_add.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/fragments/expr/ok/0000_add.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/fragments/item/err/0000_extra_keyword.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/fragments/item/err/0000_extra_keyword.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/fragments/item/ok/0000_fn.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/fragments/item/ok/0000_fn.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/fragments/path/err/0000_reserved_word.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/fragments/path/err/0000_reserved_word.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/fragments/path/err/0001_expression.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/fragments/path/err/0001_expression.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/fragments/path/ok/0000_single_ident.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/fragments/path/ok/0000_single_ident.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/fragments/path/ok/0001_multipart.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/fragments/path/ok/0001_multipart.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/fragments/pattern/err/0000_reserved_word.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/fragments/pattern/err/0000_reserved_word.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/fragments/pattern/err/0001_missing_paren.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/fragments/pattern/err/0001_missing_paren.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/fragments/pattern/ok/0000_enum.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/fragments/pattern/ok/0000_enum.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/fragments/type/err/0000_missing_close.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/fragments/type/err/0000_missing_close.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/fragments/type/ok/0000_result.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/fragments/type/ok/0000_result.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/fuzz-failures/0000.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/fuzz-failures/0001.rs (99%) rename crates/{ra_syntax => syntax}/test_data/parser/fuzz-failures/0002.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/fuzz-failures/0003.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/fuzz-failures/0004.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/err/0001_array_type_missing_semi.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/err/0001_array_type_missing_semi.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/err/0002_misplaced_label_err.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/err/0002_misplaced_label_err.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/err/0003_pointer_type_no_mutability.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/err/0003_pointer_type_no_mutability.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/err/0004_impl_type.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/err/0004_impl_type.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/err/0005_fn_pointer_type_missing_fn.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/err/0005_fn_pointer_type_missing_fn.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/err/0006_unsafe_block_in_mod.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/err/0006_unsafe_block_in_mod.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/err/0007_async_without_semicolon.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/err/0007_async_without_semicolon.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/err/0008_pub_expr.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/err/0008_pub_expr.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/err/0009_attr_on_expr_not_allowed.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/err/0009_attr_on_expr_not_allowed.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/err/0010_bad_tuple_index_expr.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/err/0010_bad_tuple_index_expr.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/err/0013_static_underscore.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/err/0013_static_underscore.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/err/0014_record_literal_before_ellipsis_recovery.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/err/0014_record_literal_before_ellipsis_recovery.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/err/0015_empty_segment.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/err/0015_empty_segment.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0001_trait_item_list.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0001_trait_item_list.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0002_use_tree_list.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0002_use_tree_list.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0003_where_pred_for.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0003_where_pred_for.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0004_value_parameters_no_patterns.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0004_value_parameters_no_patterns.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0005_function_type_params.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0005_function_type_params.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0006_self_param.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0006_self_param.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0007_type_param_bounds.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0007_type_param_bounds.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0008_path_part.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0008_path_part.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0009_loop_expr.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0009_loop_expr.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0010_extern_block.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0010_extern_block.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0011_field_expr.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0011_field_expr.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0012_type_item_where_clause.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0012_type_item_where_clause.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0013_pointer_type_mut.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0013_pointer_type_mut.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0014_never_type.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0014_never_type.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0015_continue_expr.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0015_continue_expr.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0017_array_type.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0017_array_type.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0018_arb_self_types.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0018_arb_self_types.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0019_unary_expr.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0019_unary_expr.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0020_use_star.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0020_use_star.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0021_impl_item_list.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0021_impl_item_list.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0022_crate_visibility.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0022_crate_visibility.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0023_placeholder_type.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0023_placeholder_type.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0024_slice_pat.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0024_slice_pat.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0025_slice_type.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0025_slice_type.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0026_tuple_pat_fields.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0026_tuple_pat_fields.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0027_ref_pat.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0027_ref_pat.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0028_impl_trait_type.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0028_impl_trait_type.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0029_cast_expr.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0029_cast_expr.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0030_cond.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0030_cond.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0031_while_expr.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0031_while_expr.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0032_fn_pointer_type.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0032_fn_pointer_type.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0033_reference_type;.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0033_reference_type;.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0034_break_expr.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0034_break_expr.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0037_qual_paths.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0037_qual_paths.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0038_full_range_expr.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0038_full_range_expr.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0039_type_arg.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0039_type_arg.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0040_crate_keyword_vis.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0040_crate_keyword_vis.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0041_trait_item.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0041_trait_item.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0042_call_expr.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0042_call_expr.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0043_use_alias.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0043_use_alias.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0044_block_items.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0044_block_items.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0045_param_list_opt_patterns.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0045_param_list_opt_patterns.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0046_singleton_tuple_type.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0046_singleton_tuple_type.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0048_path_type_with_bounds.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0048_path_type_with_bounds.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0050_fn_decl.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0050_fn_decl.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0051_unit_type.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0051_unit_type.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0052_path_type.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0052_path_type.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0053_path_expr.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0053_path_expr.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0054_record_field_attrs.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0054_record_field_attrs.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0055_literal_pattern.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0055_literal_pattern.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0056_where_clause.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0056_where_clause.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0058_range_pat.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0058_range_pat.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0059_match_arms_commas.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0059_match_arms_commas.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0060_extern_crate.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0060_extern_crate.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0061_record_lit.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0061_record_lit.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0062_mod_contents.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0062_mod_contents.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0063_impl_def_neg.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0063_impl_def_neg.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0064_if_expr.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0064_if_expr.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0065_dyn_trait_type.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0065_dyn_trait_type.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0066_match_arm.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0066_match_arm.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0067_crate_path.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0067_crate_path.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0068_union_items.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0068_union_items.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0069_use_tree_list_after_path.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0069_use_tree_list_after_path.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0070_stmt_bin_expr_ambiguity.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0070_stmt_bin_expr_ambiguity.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0071_match_expr.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0071_match_expr.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0072_return_expr.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0072_return_expr.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0073_type_item_type_params.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0073_type_item_type_params.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0074_stmt_postfix_expr_ambiguity.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0074_stmt_postfix_expr_ambiguity.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0075_block.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0075_block.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0076_function_where_clause.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0076_function_where_clause.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0077_try_expr.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0077_try_expr.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0078_type_item.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0078_type_item.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0079_impl_def.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0079_impl_def.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0080_postfix_range.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0080_postfix_range.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0081_for_type.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0081_for_type.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0082_ref_expr.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0082_ref_expr.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0083_struct_items.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0083_struct_items.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0084_paren_type.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0084_paren_type.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0085_expr_literals.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0085_expr_literals.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0086_function_ret_type.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0086_function_ret_type.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0088_break_ambiguity.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0088_break_ambiguity.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0090_type_param_default.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0090_type_param_default.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0092_fn_pointer_type_with_ret.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0092_fn_pointer_type_with_ret.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0093_index_expr.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0093_index_expr.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0095_placeholder_pat.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0095_placeholder_pat.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0096_no_semi_after_block.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0096_no_semi_after_block.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0099_param_list.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0099_param_list.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0100_for_expr.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0100_for_expr.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0102_record_field_pat_list.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0102_record_field_pat_list.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0103_array_expr.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0103_array_expr.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0104_path_fn_trait_args.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0104_path_fn_trait_args.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0106_lambda_expr.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0106_lambda_expr.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0107_method_call_expr.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0107_method_call_expr.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0108_tuple_expr.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0108_tuple_expr.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0109_label.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0109_label.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0110_use_path.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0110_use_path.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0111_tuple_pat.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0111_tuple_pat.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0112_bind_pat.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0112_bind_pat.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0113_nocontentexpr.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0113_nocontentexpr.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0114_tuple_struct_where.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0114_tuple_struct_where.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0115_tuple_field_attrs.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0115_tuple_field_attrs.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0117_macro_call_type.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0117_macro_call_type.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0118_impl_inner_attributes.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0118_impl_inner_attributes.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0118_match_guard.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0118_match_guard.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0120_match_arms_inner_attribute.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0120_match_arms_inner_attribute.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0121_match_arms_outer_attributes.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0121_match_arms_outer_attributes.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0122_generic_lifetime_type_attribute.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0122_generic_lifetime_type_attribute.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0123_param_list_vararg.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0123_param_list_vararg.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0125_crate_keyword_path.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0125_crate_keyword_path.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0125_record_literal_field_with_attr.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0125_record_literal_field_with_attr.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0126_attr_on_expr_stmt.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0126_attr_on_expr_stmt.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0127_attr_on_last_expr_in_block.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0127_attr_on_last_expr_in_block.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0129_marco_pat.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0129_marco_pat.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0130_let_stmt.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0130_let_stmt.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0130_try_block_expr.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0130_try_block_expr.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0131_existential_type.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0131_existential_type.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0132_box_expr.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0132_box_expr.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0134_nocontentexpr_after_item.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0134_nocontentexpr_after_item.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0137_await_expr.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0137_await_expr.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0138_associated_type_bounds.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0138_associated_type_bounds.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0138_expression_after_block.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0138_expression_after_block.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0138_self_param_outer_attr.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0138_self_param_outer_attr.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0139_param_outer_arg.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0139_param_outer_arg.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0142_for_range_from.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0142_for_range_from.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0143_box_pat.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0143_box_pat.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0144_dot_dot_pat.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0144_dot_dot_pat.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0145_record_field_pat.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0145_record_field_pat.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0146_as_precedence.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0146_as_precedence.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0147_const_param.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0147_const_param.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0147_macro_def.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0147_macro_def.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0148_pub_macro_def.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0148_pub_macro_def.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0150_array_attrs.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0150_array_attrs.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0150_impl_type_params.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0150_impl_type_params.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0151_fn.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0151_fn.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0151_trait_alias.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0151_trait_alias.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0152_arg_with_attr.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0152_arg_with_attr.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0152_impl.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0152_impl.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0153_trait.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0153_trait.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0154_fn_pointer_param_ident_path.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0154_fn_pointer_param_ident_path.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0155_closure_params.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0155_closure_params.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0156_fn_def_param.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0156_fn_def_param.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0156_or_pattern.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0156_or_pattern.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0157_fn_pointer_unnamed_arg.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0157_fn_pointer_unnamed_arg.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0157_variant_discriminant.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0157_variant_discriminant.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0158_binop_resets_statementness.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0158_binop_resets_statementness.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0158_lambda_ret_block.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0158_lambda_ret_block.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0159_try_macro_fallback.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0159_try_macro_fallback.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0160_try_macro_rules.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0160_try_macro_rules.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0161_labeled_block.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0161_labeled_block.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0162_unsafe_block.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0162_unsafe_block.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0163_default_unsafe_item.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0163_default_unsafe_item.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0164_default_item.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0164_default_item.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0164_type_path_in_pattern.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/inline/ok/0164_type_path_in_pattern.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0000_empty.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0000_empty.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0001_struct_item.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0001_struct_item.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0002_struct_item_field.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0002_struct_item_field.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0004_file_shebang.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0004_file_shebang.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0005_fn_item.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0005_fn_item.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0006_inner_attributes.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0006_inner_attributes.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0007_extern_crate.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0007_extern_crate.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0008_mod_item.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0008_mod_item.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0009_use_item.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0009_use_item.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0010_use_path_segments.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0010_use_path_segments.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0011_outer_attribute.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0011_outer_attribute.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0012_visibility.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0012_visibility.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0013_use_path_self_super.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0013_use_path_self_super.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0014_use_tree.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0014_use_tree.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0015_use_tree.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0015_use_tree.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0016_struct_flavors.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0016_struct_flavors.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0017_attr_trailing_comma.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0017_attr_trailing_comma.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0018_struct_type_params.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0018_struct_type_params.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0019_enums.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0019_enums.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0020_type_param_bounds.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0020_type_param_bounds.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0022_empty_extern_block.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0022_empty_extern_block.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0023_static_items.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0023_static_items.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0024_const_item.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0024_const_item.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0025_extern_fn_in_block.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0025_extern_fn_in_block.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0026_const_fn_in_block.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0026_const_fn_in_block.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0027_unsafe_fn_in_block.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0027_unsafe_fn_in_block.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0028_operator_binding_power.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0028_operator_binding_power.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0029_range_forms.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0029_range_forms.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0030_string_suffixes.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0030_string_suffixes.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0030_traits.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0030_traits.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0031_extern.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0031_extern.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0032_where_for.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0032_where_for.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0033_label_break.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0033_label_break.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0034_crate_path_in_call.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0034_crate_path_in_call.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0035_weird_exprs.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0035_weird_exprs.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0036_fully_qualified.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0036_fully_qualified.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0037_mod.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0037_mod.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0038_where_pred_type.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0038_where_pred_type.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0039_raw_fn_item.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0039_raw_fn_item.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0040_raw_struct_item_field.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0040_raw_struct_item_field.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0041_raw_keywords.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0041_raw_keywords.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0042_ufcs_call_list.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0042_ufcs_call_list.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0043_complex_assignment.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0043_complex_assignment.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0044_let_attrs.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0044_let_attrs.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0045_block_inner_attrs.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0045_block_inner_attrs.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0046_extern_inner_attributes.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0046_extern_inner_attributes.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0047_minus_in_inner_pattern.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0047_minus_in_inner_pattern.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0048_compound_assignment.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0048_compound_assignment.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0049_async_block.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0049_async_block.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0050_async_block_as_argument.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0050_async_block_as_argument.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0051_parameter_attrs.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0051_parameter_attrs.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0052_for_range_block.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0052_for_range_block.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0053_outer_attribute_on_macro_rules.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0053_outer_attribute_on_macro_rules.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0054_qual_path_in_type_arg.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0054_qual_path_in_type_arg.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0055_dot_dot_dot.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0055_dot_dot_dot.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0056_neq_in_type.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0056_neq_in_type.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0057_loop_in_call.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0057_loop_in_call.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0058_unary_expr_precedence.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0058_unary_expr_precedence.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0059_loops_in_parens.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0059_loops_in_parens.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0060_as_range.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0060_as_range.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0061_match_full_range.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0061_match_full_range.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0062_macro_2.0.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0062_macro_2.0.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0063_trait_fn_patterns.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0063_trait_fn_patterns.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0063_variadic_fun.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0063_variadic_fun.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0064_impl_fn_params.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0064_impl_fn_params.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0065_comment_newline.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0065_comment_newline.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0065_plus_after_fn_trait_bound.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0065_plus_after_fn_trait_bound.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0066_default_modifier.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0066_default_modifier.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0067_where_for_pred.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0067_where_for_pred.rs (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0068_item_modifiers.rast (100%) rename crates/{ra_syntax => syntax}/test_data/parser/ok/0068_item_modifiers.rs (100%) rename crates/{ra_syntax => syntax}/test_data/reparse/fuzz-failures/0000.rs (100%) rename crates/{ra_syntax => syntax}/test_data/reparse/fuzz-failures/0001.rs (100%) rename crates/{ra_syntax => syntax}/test_data/reparse/fuzz-failures/0002.rs (100%) rename crates/{ra_syntax => syntax}/test_data/reparse/fuzz-failures/0003.rs (100%) rename crates/{ra_syntax => syntax}/test_data/reparse/fuzz-failures/0004.rs (100%) rename crates/{ra_syntax => syntax}/test_data/reparse/fuzz-failures/0005.rs (100%) diff --git a/.gitattributes b/.gitattributes index 4cd50e4810..7c2f752d69 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,5 +1,5 @@ * text=auto eol=lf -crates/ra_syntax/test_data/** -text eof=LF +crates/syntax/test_data/** -text eof=LF # Older git versions try to fix line endings on images, this prevents it. *.png binary *.jpg binary diff --git a/Cargo.lock b/Cargo.lock index 095127b99f..c95ef002d3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -933,9 +933,9 @@ dependencies = [ "ra_fmt", "ra_hir", "ra_ide_db", - "ra_syntax", "rustc-hash", "stdx", + "syntax", "test_utils", "text_edit", ] @@ -945,8 +945,8 @@ name = "ra_cfg" version = "0.1.0" dependencies = [ "ra_mbe", - "ra_syntax", "rustc-hash", + "syntax", "tt", ] @@ -956,10 +956,10 @@ version = "0.1.0" dependencies = [ "profile", "ra_cfg", - "ra_syntax", "rustc-hash", "salsa", "stdx", + "syntax", "test_utils", "tt", "vfs", @@ -970,7 +970,7 @@ name = "ra_fmt" version = "0.1.0" dependencies = [ "itertools", - "ra_syntax", + "syntax", ] [[package]] @@ -986,9 +986,9 @@ dependencies = [ "ra_hir_def", "ra_hir_expand", "ra_hir_ty", - "ra_syntax", "rustc-hash", "stdx", + "syntax", ] [[package]] @@ -1010,10 +1010,10 @@ dependencies = [ "ra_db", "ra_hir_expand", "ra_mbe", - "ra_syntax", "rustc-hash", "smallvec", "stdx", + "syntax", "test_utils", "tt", ] @@ -1029,8 +1029,8 @@ dependencies = [ "profile", "ra_db", "ra_mbe", - "ra_syntax", "rustc-hash", + "syntax", "test_utils", "tt", ] @@ -1052,11 +1052,11 @@ dependencies = [ "ra_db", "ra_hir_def", "ra_hir_expand", - "ra_syntax", "rustc-hash", "scoped-tls", "smallvec", "stdx", + "syntax", "test_utils", "tracing", "tracing-subscriber", @@ -1081,9 +1081,9 @@ dependencies = [ "ra_hir", "ra_ide_db", "ra_ssr", - "ra_syntax", "rustc-hash", "stdx", + "syntax", "test_utils", "text_edit", ] @@ -1099,10 +1099,10 @@ dependencies = [ "profile", "ra_db", "ra_hir", - "ra_syntax", "rayon", "rustc-hash", "stdx", + "syntax", "test_utils", "text_edit", ] @@ -1113,9 +1113,9 @@ version = "0.1.0" dependencies = [ "log", "parser", - "ra_syntax", "rustc-hash", "smallvec", + "syntax", "test_utils", "tt", ] @@ -1176,33 +1176,12 @@ dependencies = [ "ra_db", "ra_hir", "ra_ide_db", - "ra_syntax", "rustc-hash", + "syntax", "test_utils", "text_edit", ] -[[package]] -name = "ra_syntax" -version = "0.1.0" -dependencies = [ - "arrayvec", - "expect", - "itertools", - "once_cell", - "parser", - "rayon", - "rowan", - "rustc-ap-rustc_lexer", - "rustc-hash", - "serde", - "smol_str", - "stdx", - "test_utils", - "text_edit", - "walkdir", -] - [[package]] name = "rayon" version = "1.3.1" @@ -1304,12 +1283,12 @@ dependencies = [ "ra_proc_macro_srv", "ra_project_model", "ra_ssr", - "ra_syntax", "rayon", "rustc-hash", "serde", "serde_json", "stdx", + "syntax", "test_utils", "text_edit", "threadpool", @@ -1532,6 +1511,27 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "syntax" +version = "0.0.0" +dependencies = [ + "arrayvec", + "expect", + "itertools", + "once_cell", + "parser", + "rayon", + "rowan", + "rustc-ap-rustc_lexer", + "rustc-hash", + "serde", + "smol_str", + "stdx", + "test_utils", + "text_edit", + "walkdir", +] + [[package]] name = "termcolor" version = "1.1.0" diff --git a/crates/parser/src/grammar.rs b/crates/parser/src/grammar.rs index 88468bc971..9dbd2ebc44 100644 --- a/crates/parser/src/grammar.rs +++ b/crates/parser/src/grammar.rs @@ -20,7 +20,7 @@ //! //! After adding a new inline-test, run `cargo xtask codegen` to //! extract it as a standalone text-fixture into -//! `crates/ra_syntax/test_data/parser/`, and run `cargo test` once to +//! `crates/syntax/test_data/parser/`, and run `cargo test` once to //! create the "gold" value. //! //! Coding convention: rules like `where_clause` always produce either a diff --git a/crates/parser/src/lib.rs b/crates/parser/src/lib.rs index eeb8ad66bd..41e62116f8 100644 --- a/crates/parser/src/lib.rs +++ b/crates/parser/src/lib.rs @@ -10,7 +10,7 @@ //! //! The actual parsing happens in the `grammar` module. //! -//! Tests for this crate live in `ra_syntax` crate. +//! Tests for this crate live in `syntax` crate. #[macro_use] mod token_set; diff --git a/crates/ra_assists/Cargo.toml b/crates/ra_assists/Cargo.toml index e4a5ee6c1c..abc290463a 100644 --- a/crates/ra_assists/Cargo.toml +++ b/crates/ra_assists/Cargo.toml @@ -15,7 +15,7 @@ either = "1.5.3" stdx = { path = "../stdx" } -ra_syntax = { path = "../ra_syntax" } +syntax = { path = "../syntax" } text_edit = { path = "../text_edit" } ra_fmt = { path = "../ra_fmt" } profile = { path = "../profile" } diff --git a/crates/ra_assists/src/assist_context.rs b/crates/ra_assists/src/assist_context.rs index fcaa1aedcf..217f692a4e 100644 --- a/crates/ra_assists/src/assist_context.rs +++ b/crates/ra_assists/src/assist_context.rs @@ -10,7 +10,7 @@ use ra_ide_db::{ source_change::{SourceChange, SourceFileEdit}, RootDatabase, }; -use ra_syntax::{ +use syntax::{ algo::{self, find_node_at_offset, SyntaxRewriter}, AstNode, SourceFile, SyntaxElement, SyntaxKind, SyntaxNode, SyntaxToken, TextRange, TextSize, TokenAtOffset, @@ -271,7 +271,7 @@ impl AssistBuilder { } /// Replaces specified `node` of text with a given string, reindenting the /// string to maintain `node`'s existing indent. - // FIXME: remove in favor of ra_syntax::edit::IndentLevel::increase_indent + // FIXME: remove in favor of syntax::edit::IndentLevel::increase_indent pub(crate) fn replace_node_and_indent( &mut self, node: &SyntaxNode, diff --git a/crates/ra_assists/src/ast_transform.rs b/crates/ra_assists/src/ast_transform.rs index 07c978378a..4c41c16d86 100644 --- a/crates/ra_assists/src/ast_transform.rs +++ b/crates/ra_assists/src/ast_transform.rs @@ -2,13 +2,13 @@ use rustc_hash::FxHashMap; use hir::{HirDisplay, PathResolution, SemanticsScope}; -use ra_syntax::{ +use syntax::{ algo::SyntaxRewriter, ast::{self, AstNode}, }; pub trait AstTransform<'a> { - fn get_substitution(&self, node: &ra_syntax::SyntaxNode) -> Option; + fn get_substitution(&self, node: &syntax::SyntaxNode) -> Option; fn chain_before(self, other: Box + 'a>) -> Box + 'a>; fn or + 'a>(self, other: T) -> Box + 'a> @@ -22,7 +22,7 @@ pub trait AstTransform<'a> { struct NullTransformer; impl<'a> AstTransform<'a> for NullTransformer { - fn get_substitution(&self, _node: &ra_syntax::SyntaxNode) -> Option { + fn get_substitution(&self, _node: &syntax::SyntaxNode) -> Option { None } fn chain_before(self, other: Box + 'a>) -> Box + 'a> { @@ -101,10 +101,7 @@ impl<'a> SubstituteTypeParams<'a> { Some(result) } } - fn get_substitution_inner( - &self, - node: &ra_syntax::SyntaxNode, - ) -> Option { + fn get_substitution_inner(&self, node: &syntax::SyntaxNode) -> Option { let type_ref = ast::Type::cast(node.clone())?; let path = match &type_ref { ast::Type::PathType(path_type) => path_type.path()?, @@ -122,7 +119,7 @@ impl<'a> SubstituteTypeParams<'a> { } impl<'a> AstTransform<'a> for SubstituteTypeParams<'a> { - fn get_substitution(&self, node: &ra_syntax::SyntaxNode) -> Option { + fn get_substitution(&self, node: &syntax::SyntaxNode) -> Option { self.get_substitution_inner(node).or_else(|| self.previous.get_substitution(node)) } fn chain_before(self, other: Box + 'a>) -> Box + 'a> { @@ -141,10 +138,7 @@ impl<'a> QualifyPaths<'a> { Self { target_scope, source_scope, previous: Box::new(NullTransformer) } } - fn get_substitution_inner( - &self, - node: &ra_syntax::SyntaxNode, - ) -> Option { + fn get_substitution_inner(&self, node: &syntax::SyntaxNode) -> Option { // FIXME handle value ns? let from = self.target_scope.module()?; let p = ast::Path::cast(node.clone())?; @@ -183,7 +177,7 @@ impl<'a> QualifyPaths<'a> { pub fn apply<'a, N: AstNode>(transformer: &dyn AstTransform<'a>, node: N) -> N { SyntaxRewriter::from_fn(|element| match element { - ra_syntax::SyntaxElement::Node(n) => { + syntax::SyntaxElement::Node(n) => { let replacement = transformer.get_substitution(&n)?; Some(replacement.into()) } @@ -193,7 +187,7 @@ pub fn apply<'a, N: AstNode>(transformer: &dyn AstTransform<'a>, node: N) -> N { } impl<'a> AstTransform<'a> for QualifyPaths<'a> { - fn get_substitution(&self, node: &ra_syntax::SyntaxNode) -> Option { + fn get_substitution(&self, node: &syntax::SyntaxNode) -> Option { self.get_substitution_inner(node).or_else(|| self.previous.get_substitution(node)) } fn chain_before(self, other: Box + 'a>) -> Box + 'a> { diff --git a/crates/ra_assists/src/handlers/add_custom_impl.rs b/crates/ra_assists/src/handlers/add_custom_impl.rs index ebdf00e676..8757fa33f2 100644 --- a/crates/ra_assists/src/handlers/add_custom_impl.rs +++ b/crates/ra_assists/src/handlers/add_custom_impl.rs @@ -1,5 +1,5 @@ use itertools::Itertools; -use ra_syntax::{ +use syntax::{ ast::{self, AstNode}, Direction, SmolStr, SyntaxKind::{IDENT, WHITESPACE}, diff --git a/crates/ra_assists/src/handlers/add_explicit_type.rs b/crates/ra_assists/src/handlers/add_explicit_type.rs index 135a2ac9c9..563cbf505f 100644 --- a/crates/ra_assists/src/handlers/add_explicit_type.rs +++ b/crates/ra_assists/src/handlers/add_explicit_type.rs @@ -1,5 +1,5 @@ use hir::HirDisplay; -use ra_syntax::{ +use syntax::{ ast::{self, AstNode, LetStmt, NameOwner}, TextRange, }; diff --git a/crates/ra_assists/src/handlers/add_missing_impl_members.rs b/crates/ra_assists/src/handlers/add_missing_impl_members.rs index dd1406228c..81b61ebf8e 100644 --- a/crates/ra_assists/src/handlers/add_missing_impl_members.rs +++ b/crates/ra_assists/src/handlers/add_missing_impl_members.rs @@ -1,5 +1,5 @@ use hir::HasSource; -use ra_syntax::{ +use syntax::{ ast::{ self, edit::{self, AstNodeEdit, IndentLevel}, diff --git a/crates/ra_assists/src/handlers/add_turbo_fish.rs b/crates/ra_assists/src/handlers/add_turbo_fish.rs index 537322a72c..8c7ffae3dd 100644 --- a/crates/ra_assists/src/handlers/add_turbo_fish.rs +++ b/crates/ra_assists/src/handlers/add_turbo_fish.rs @@ -1,5 +1,5 @@ use ra_ide_db::defs::{classify_name_ref, Definition, NameRefClass}; -use ra_syntax::{ast, AstNode, SyntaxKind, T}; +use syntax::{ast, AstNode, SyntaxKind, T}; use test_utils::mark; use crate::{ diff --git a/crates/ra_assists/src/handlers/apply_demorgan.rs b/crates/ra_assists/src/handlers/apply_demorgan.rs index 3ac4aed7d2..1a6fdafda2 100644 --- a/crates/ra_assists/src/handlers/apply_demorgan.rs +++ b/crates/ra_assists/src/handlers/apply_demorgan.rs @@ -1,4 +1,4 @@ -use ra_syntax::ast::{self, AstNode}; +use syntax::ast::{self, AstNode}; use crate::{utils::invert_boolean_expression, AssistContext, AssistId, AssistKind, Assists}; diff --git a/crates/ra_assists/src/handlers/auto_import.rs b/crates/ra_assists/src/handlers/auto_import.rs index 6ec59ec4d4..e19b197d9e 100644 --- a/crates/ra_assists/src/handlers/auto_import.rs +++ b/crates/ra_assists/src/handlers/auto_import.rs @@ -6,11 +6,11 @@ use hir::{ Type, }; use ra_ide_db::{imports_locator, RootDatabase}; -use ra_syntax::{ +use rustc_hash::FxHashSet; +use syntax::{ ast::{self, AstNode}, SyntaxNode, }; -use rustc_hash::FxHashSet; use crate::{ utils::insert_use_statement, AssistContext, AssistId, AssistKind, Assists, GroupLabel, diff --git a/crates/ra_assists/src/handlers/change_return_type_to_result.rs b/crates/ra_assists/src/handlers/change_return_type_to_result.rs index b83c944049..d5a68a24c9 100644 --- a/crates/ra_assists/src/handlers/change_return_type_to_result.rs +++ b/crates/ra_assists/src/handlers/change_return_type_to_result.rs @@ -1,4 +1,4 @@ -use ra_syntax::{ +use syntax::{ ast::{self, BlockExpr, Expr, LoopBodyOwner}, AstNode, SyntaxNode, }; diff --git a/crates/ra_assists/src/handlers/change_visibility.rs b/crates/ra_assists/src/handlers/change_visibility.rs index 724daa93f4..32dc053789 100644 --- a/crates/ra_assists/src/handlers/change_visibility.rs +++ b/crates/ra_assists/src/handlers/change_visibility.rs @@ -1,4 +1,4 @@ -use ra_syntax::{ +use syntax::{ ast::{self, NameOwner, VisibilityOwner}, AstNode, SyntaxKind::{CONST, ENUM, FN, MODULE, STATIC, STRUCT, TRAIT, VISIBILITY}, diff --git a/crates/ra_assists/src/handlers/early_return.rs b/crates/ra_assists/src/handlers/early_return.rs index 6816a2709e..7fd78e9d47 100644 --- a/crates/ra_assists/src/handlers/early_return.rs +++ b/crates/ra_assists/src/handlers/early_return.rs @@ -1,6 +1,6 @@ use std::{iter::once, ops::RangeInclusive}; -use ra_syntax::{ +use syntax::{ algo::replace_children, ast::{ self, diff --git a/crates/ra_assists/src/handlers/expand_glob_import.rs b/crates/ra_assists/src/handlers/expand_glob_import.rs index eb216a81a1..cf34ffaf7f 100644 --- a/crates/ra_assists/src/handlers/expand_glob_import.rs +++ b/crates/ra_assists/src/handlers/expand_glob_import.rs @@ -3,7 +3,7 @@ use ra_ide_db::{ defs::{classify_name_ref, Definition, NameRefClass}, RootDatabase, }; -use ra_syntax::{algo, ast, match_ast, AstNode, SyntaxNode, SyntaxToken, T}; +use syntax::{algo, ast, match_ast, AstNode, SyntaxNode, SyntaxToken, T}; use crate::{ assist_context::{AssistBuilder, AssistContext, Assists}, diff --git a/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs b/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs index ccec688cae..6e9f2d0fc7 100644 --- a/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs +++ b/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs @@ -2,12 +2,12 @@ use hir::{EnumVariant, Module, ModuleDef, Name}; use ra_db::FileId; use ra_fmt::leading_indent; use ra_ide_db::{defs::Definition, search::Reference, RootDatabase}; -use ra_syntax::{ +use rustc_hash::FxHashSet; +use syntax::{ algo::find_node_at_offset, ast::{self, ArgListOwner, AstNode, NameOwner, VisibilityOwner}, SourceFile, SyntaxNode, TextRange, TextSize, }; -use rustc_hash::FxHashSet; use crate::{ assist_context::AssistBuilder, utils::insert_use_statement, AssistContext, AssistId, diff --git a/crates/ra_assists/src/handlers/extract_variable.rs b/crates/ra_assists/src/handlers/extract_variable.rs index cc62db0c44..d2ae137cdd 100644 --- a/crates/ra_assists/src/handlers/extract_variable.rs +++ b/crates/ra_assists/src/handlers/extract_variable.rs @@ -1,11 +1,11 @@ -use ra_syntax::{ +use stdx::format_to; +use syntax::{ ast::{self, AstNode}, SyntaxKind::{ BLOCK_EXPR, BREAK_EXPR, CLOSURE_EXPR, COMMENT, LOOP_EXPR, MATCH_ARM, PATH_EXPR, RETURN_EXPR, }, SyntaxNode, }; -use stdx::format_to; use test_utils::mark; use crate::{AssistContext, AssistId, AssistKind, Assists}; diff --git a/crates/ra_assists/src/handlers/fill_match_arms.rs b/crates/ra_assists/src/handlers/fill_match_arms.rs index 6698d1a27a..8f66606372 100644 --- a/crates/ra_assists/src/handlers/fill_match_arms.rs +++ b/crates/ra_assists/src/handlers/fill_match_arms.rs @@ -3,7 +3,7 @@ use std::iter; use hir::{Adt, HasSource, ModuleDef, Semantics}; use itertools::Itertools; use ra_ide_db::RootDatabase; -use ra_syntax::ast::{self, make, AstNode, MatchArm, NameOwner, Pat}; +use syntax::ast::{self, make, AstNode, MatchArm, NameOwner, Pat}; use test_utils::mark; use crate::{ diff --git a/crates/ra_assists/src/handlers/fix_visibility.rs b/crates/ra_assists/src/handlers/fix_visibility.rs index a19dbf33f6..b6cc1a3204 100644 --- a/crates/ra_assists/src/handlers/fix_visibility.rs +++ b/crates/ra_assists/src/handlers/fix_visibility.rs @@ -1,6 +1,6 @@ use hir::{db::HirDatabase, HasSource, HasVisibility, PathResolution}; use ra_db::FileId; -use ra_syntax::{ast, AstNode, TextRange, TextSize}; +use syntax::{ast, AstNode, TextRange, TextSize}; use crate::{utils::vis_offset, AssistContext, AssistId, AssistKind, Assists}; use ast::VisibilityOwner; diff --git a/crates/ra_assists/src/handlers/flip_binexpr.rs b/crates/ra_assists/src/handlers/flip_binexpr.rs index 3cd5326505..404f06133d 100644 --- a/crates/ra_assists/src/handlers/flip_binexpr.rs +++ b/crates/ra_assists/src/handlers/flip_binexpr.rs @@ -1,4 +1,4 @@ -use ra_syntax::ast::{AstNode, BinExpr, BinOp}; +use syntax::ast::{AstNode, BinExpr, BinOp}; use crate::{AssistContext, AssistId, AssistKind, Assists}; diff --git a/crates/ra_assists/src/handlers/flip_comma.rs b/crates/ra_assists/src/handlers/flip_comma.rs index 55a971dc77..5c69db53e5 100644 --- a/crates/ra_assists/src/handlers/flip_comma.rs +++ b/crates/ra_assists/src/handlers/flip_comma.rs @@ -1,4 +1,4 @@ -use ra_syntax::{algo::non_trivia_sibling, Direction, T}; +use syntax::{algo::non_trivia_sibling, Direction, T}; use crate::{AssistContext, AssistId, AssistKind, Assists}; diff --git a/crates/ra_assists/src/handlers/flip_trait_bound.rs b/crates/ra_assists/src/handlers/flip_trait_bound.rs index 1234f4d296..347e79b1da 100644 --- a/crates/ra_assists/src/handlers/flip_trait_bound.rs +++ b/crates/ra_assists/src/handlers/flip_trait_bound.rs @@ -1,4 +1,4 @@ -use ra_syntax::{ +use syntax::{ algo::non_trivia_sibling, ast::{self, AstNode}, Direction, T, diff --git a/crates/ra_assists/src/handlers/generate_derive.rs b/crates/ra_assists/src/handlers/generate_derive.rs index 90ece9fab0..314504e15c 100644 --- a/crates/ra_assists/src/handlers/generate_derive.rs +++ b/crates/ra_assists/src/handlers/generate_derive.rs @@ -1,4 +1,4 @@ -use ra_syntax::{ +use syntax::{ ast::{self, AstNode, AttrsOwner}, SyntaxKind::{COMMENT, WHITESPACE}, TextSize, diff --git a/crates/ra_assists/src/handlers/generate_from_impl_for_enum.rs b/crates/ra_assists/src/handlers/generate_from_impl_for_enum.rs index 4c1aef8a21..302b6b67d4 100644 --- a/crates/ra_assists/src/handlers/generate_from_impl_for_enum.rs +++ b/crates/ra_assists/src/handlers/generate_from_impl_for_enum.rs @@ -1,5 +1,5 @@ use ra_ide_db::RootDatabase; -use ra_syntax::ast::{self, AstNode, NameOwner}; +use syntax::ast::{self, AstNode, NameOwner}; use test_utils::mark; use crate::{utils::FamousDefs, AssistContext, AssistId, AssistKind, Assists}; diff --git a/crates/ra_assists/src/handlers/generate_function.rs b/crates/ra_assists/src/handlers/generate_function.rs index acc97e6482..b5df441019 100644 --- a/crates/ra_assists/src/handlers/generate_function.rs +++ b/crates/ra_assists/src/handlers/generate_function.rs @@ -1,6 +1,7 @@ use hir::HirDisplay; use ra_db::FileId; -use ra_syntax::{ +use rustc_hash::{FxHashMap, FxHashSet}; +use syntax::{ ast::{ self, edit::{AstNodeEdit, IndentLevel}, @@ -8,7 +9,6 @@ use ra_syntax::{ }, SyntaxKind, SyntaxNode, TextSize, }; -use rustc_hash::{FxHashMap, FxHashSet}; use crate::{ assist_config::SnippetCap, diff --git a/crates/ra_assists/src/handlers/generate_impl.rs b/crates/ra_assists/src/handlers/generate_impl.rs index 7162dc1848..9989109b5a 100644 --- a/crates/ra_assists/src/handlers/generate_impl.rs +++ b/crates/ra_assists/src/handlers/generate_impl.rs @@ -1,6 +1,6 @@ use itertools::Itertools; -use ra_syntax::ast::{self, AstNode, GenericParamsOwner, NameOwner}; use stdx::format_to; +use syntax::ast::{self, AstNode, GenericParamsOwner, NameOwner}; use crate::{AssistContext, AssistId, AssistKind, Assists}; diff --git a/crates/ra_assists/src/handlers/generate_new.rs b/crates/ra_assists/src/handlers/generate_new.rs index 32dfed274a..7db10f2768 100644 --- a/crates/ra_assists/src/handlers/generate_new.rs +++ b/crates/ra_assists/src/handlers/generate_new.rs @@ -1,10 +1,10 @@ use hir::Adt; use itertools::Itertools; -use ra_syntax::{ +use stdx::format_to; +use syntax::{ ast::{self, AstNode, GenericParamsOwner, NameOwner, StructKind, VisibilityOwner}, T, }; -use stdx::format_to; use crate::{AssistContext, AssistId, AssistKind, Assists}; diff --git a/crates/ra_assists/src/handlers/inline_local_variable.rs b/crates/ra_assists/src/handlers/inline_local_variable.rs index 3c58020f80..5315923206 100644 --- a/crates/ra_assists/src/handlers/inline_local_variable.rs +++ b/crates/ra_assists/src/handlers/inline_local_variable.rs @@ -1,5 +1,5 @@ use ra_ide_db::defs::Definition; -use ra_syntax::{ +use syntax::{ ast::{self, AstNode, AstToken}, TextRange, }; diff --git a/crates/ra_assists/src/handlers/introduce_named_lifetime.rs b/crates/ra_assists/src/handlers/introduce_named_lifetime.rs index fbaf3c06b5..5f623e5f7a 100644 --- a/crates/ra_assists/src/handlers/introduce_named_lifetime.rs +++ b/crates/ra_assists/src/handlers/introduce_named_lifetime.rs @@ -1,8 +1,8 @@ -use ra_syntax::{ +use rustc_hash::FxHashSet; +use syntax::{ ast::{self, GenericParamsOwner, NameOwner}, AstNode, SyntaxKind, TextRange, TextSize, }; -use rustc_hash::FxHashSet; use crate::{assist_context::AssistBuilder, AssistContext, AssistId, AssistKind, Assists}; diff --git a/crates/ra_assists/src/handlers/invert_if.rs b/crates/ra_assists/src/handlers/invert_if.rs index bbe3f36436..f0e0475389 100644 --- a/crates/ra_assists/src/handlers/invert_if.rs +++ b/crates/ra_assists/src/handlers/invert_if.rs @@ -1,4 +1,4 @@ -use ra_syntax::{ +use syntax::{ ast::{self, AstNode}, T, }; diff --git a/crates/ra_assists/src/handlers/merge_imports.rs b/crates/ra_assists/src/handlers/merge_imports.rs index c775fe25c5..9c5c6eda72 100644 --- a/crates/ra_assists/src/handlers/merge_imports.rs +++ b/crates/ra_assists/src/handlers/merge_imports.rs @@ -1,6 +1,6 @@ use std::iter::successors; -use ra_syntax::{ +use syntax::{ algo::{neighbor, skip_trivia_token, SyntaxRewriter}, ast::{self, edit::AstNodeEdit, make}, AstNode, Direction, InsertPosition, SyntaxElement, T, diff --git a/crates/ra_assists/src/handlers/merge_match_arms.rs b/crates/ra_assists/src/handlers/merge_match_arms.rs index 5632922823..c347eb40ef 100644 --- a/crates/ra_assists/src/handlers/merge_match_arms.rs +++ b/crates/ra_assists/src/handlers/merge_match_arms.rs @@ -1,6 +1,6 @@ use std::iter::successors; -use ra_syntax::{ +use syntax::{ algo::neighbor, ast::{self, AstNode}, Direction, diff --git a/crates/ra_assists/src/handlers/move_bounds.rs b/crates/ra_assists/src/handlers/move_bounds.rs index 6d394443eb..e2e461520d 100644 --- a/crates/ra_assists/src/handlers/move_bounds.rs +++ b/crates/ra_assists/src/handlers/move_bounds.rs @@ -1,4 +1,4 @@ -use ra_syntax::{ +use syntax::{ ast::{self, edit::AstNodeEdit, make, AstNode, NameOwner, TypeBoundsOwner}, match_ast, SyntaxKind::*, diff --git a/crates/ra_assists/src/handlers/move_guard.rs b/crates/ra_assists/src/handlers/move_guard.rs index 4060d34c64..c62ebc3061 100644 --- a/crates/ra_assists/src/handlers/move_guard.rs +++ b/crates/ra_assists/src/handlers/move_guard.rs @@ -1,4 +1,4 @@ -use ra_syntax::{ +use syntax::{ ast::{AstNode, IfExpr, MatchArm}, SyntaxKind::WHITESPACE, }; diff --git a/crates/ra_assists/src/handlers/raw_string.rs b/crates/ra_assists/src/handlers/raw_string.rs index 4c797178f1..9ddd116e01 100644 --- a/crates/ra_assists/src/handlers/raw_string.rs +++ b/crates/ra_assists/src/handlers/raw_string.rs @@ -1,6 +1,6 @@ use std::borrow::Cow; -use ra_syntax::{ +use syntax::{ ast::{self, HasQuotes, HasStringValue}, AstToken, SyntaxKind::{RAW_STRING, STRING}, diff --git a/crates/ra_assists/src/handlers/remove_dbg.rs b/crates/ra_assists/src/handlers/remove_dbg.rs index 9430ce1b5b..f3dcca5348 100644 --- a/crates/ra_assists/src/handlers/remove_dbg.rs +++ b/crates/ra_assists/src/handlers/remove_dbg.rs @@ -1,4 +1,4 @@ -use ra_syntax::{ +use syntax::{ ast::{self, AstNode}, TextRange, TextSize, T, }; diff --git a/crates/ra_assists/src/handlers/remove_mut.rs b/crates/ra_assists/src/handlers/remove_mut.rs index ef55c354ee..44f41daa92 100644 --- a/crates/ra_assists/src/handlers/remove_mut.rs +++ b/crates/ra_assists/src/handlers/remove_mut.rs @@ -1,4 +1,4 @@ -use ra_syntax::{SyntaxKind, TextRange, T}; +use syntax::{SyntaxKind, TextRange, T}; use crate::{AssistContext, AssistId, AssistKind, Assists}; diff --git a/crates/ra_assists/src/handlers/reorder_fields.rs b/crates/ra_assists/src/handlers/reorder_fields.rs index c9b743a06b..013720dfcb 100644 --- a/crates/ra_assists/src/handlers/reorder_fields.rs +++ b/crates/ra_assists/src/handlers/reorder_fields.rs @@ -3,7 +3,7 @@ use rustc_hash::FxHashMap; use hir::{Adt, ModuleDef, PathResolution, Semantics, Struct}; use ra_ide_db::RootDatabase; -use ra_syntax::{algo, ast, match_ast, AstNode, SyntaxKind, SyntaxKind::*, SyntaxNode}; +use syntax::{algo, ast, match_ast, AstNode, SyntaxKind, SyntaxKind::*, SyntaxNode}; use crate::{AssistContext, AssistId, AssistKind, Assists}; diff --git a/crates/ra_assists/src/handlers/replace_if_let_with_match.rs b/crates/ra_assists/src/handlers/replace_if_let_with_match.rs index ecafb74a1e..2442f049b6 100644 --- a/crates/ra_assists/src/handlers/replace_if_let_with_match.rs +++ b/crates/ra_assists/src/handlers/replace_if_let_with_match.rs @@ -1,5 +1,5 @@ use ra_fmt::unwrap_trivial_block; -use ra_syntax::{ +use syntax::{ ast::{ self, edit::{AstNodeEdit, IndentLevel}, diff --git a/crates/ra_assists/src/handlers/replace_let_with_if_let.rs b/crates/ra_assists/src/handlers/replace_let_with_if_let.rs index e4d436decc..ed6d0c29be 100644 --- a/crates/ra_assists/src/handlers/replace_let_with_if_let.rs +++ b/crates/ra_assists/src/handlers/replace_let_with_if_let.rs @@ -1,6 +1,6 @@ use std::iter::once; -use ra_syntax::{ +use syntax::{ ast::{ self, edit::{AstNodeEdit, IndentLevel}, diff --git a/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs b/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs index da0a860c59..011bf1106d 100644 --- a/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs +++ b/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs @@ -1,5 +1,5 @@ use hir; -use ra_syntax::{algo::SyntaxRewriter, ast, match_ast, AstNode, SmolStr, SyntaxNode}; +use syntax::{algo::SyntaxRewriter, ast, match_ast, AstNode, SmolStr, SyntaxNode}; use crate::{ utils::{find_insert_use_container, insert_use_statement}, diff --git a/crates/ra_assists/src/handlers/replace_unwrap_with_match.rs b/crates/ra_assists/src/handlers/replace_unwrap_with_match.rs index d69f2c1b0e..9705f11b76 100644 --- a/crates/ra_assists/src/handlers/replace_unwrap_with_match.rs +++ b/crates/ra_assists/src/handlers/replace_unwrap_with_match.rs @@ -1,6 +1,6 @@ use std::iter; -use ra_syntax::{ +use syntax::{ ast::{ self, edit::{AstNodeEdit, IndentLevel}, diff --git a/crates/ra_assists/src/handlers/split_import.rs b/crates/ra_assists/src/handlers/split_import.rs index 4ca5c3ca14..15e67eaa19 100644 --- a/crates/ra_assists/src/handlers/split_import.rs +++ b/crates/ra_assists/src/handlers/split_import.rs @@ -1,6 +1,6 @@ use std::iter::successors; -use ra_syntax::{ast, AstNode, T}; +use syntax::{ast, AstNode, T}; use crate::{AssistContext, AssistId, AssistKind, Assists}; diff --git a/crates/ra_assists/src/handlers/unwrap_block.rs b/crates/ra_assists/src/handlers/unwrap_block.rs index 8b38695a94..2879090b86 100644 --- a/crates/ra_assists/src/handlers/unwrap_block.rs +++ b/crates/ra_assists/src/handlers/unwrap_block.rs @@ -1,5 +1,5 @@ use ra_fmt::unwrap_trivial_block; -use ra_syntax::{ +use syntax::{ ast::{ self, edit::{AstNodeEdit, IndentLevel}, diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs index 890996a68d..e2ef561fee 100644 --- a/crates/ra_assists/src/lib.rs +++ b/crates/ra_assists/src/lib.rs @@ -20,7 +20,7 @@ pub mod ast_transform; use hir::Semantics; use ra_db::FileRange; use ra_ide_db::{source_change::SourceChange, RootDatabase}; -use ra_syntax::TextRange; +use syntax::TextRange; pub(crate) use crate::assist_context::{AssistContext, Assists}; diff --git a/crates/ra_assists/src/tests.rs b/crates/ra_assists/src/tests.rs index e738364220..1ae7aaa09b 100644 --- a/crates/ra_assists/src/tests.rs +++ b/crates/ra_assists/src/tests.rs @@ -3,7 +3,7 @@ mod generated; use hir::Semantics; use ra_db::{fixture::WithFixture, FileId, FileRange, SourceDatabaseExt}; use ra_ide_db::RootDatabase; -use ra_syntax::TextRange; +use syntax::TextRange; use test_utils::{assert_eq_text, extract_offset, extract_range}; use crate::{handlers::Handler, Assist, AssistConfig, AssistContext, AssistKind, Assists}; diff --git a/crates/ra_assists/src/utils.rs b/crates/ra_assists/src/utils.rs index 0de6fdf3fb..6d85661c46 100644 --- a/crates/ra_assists/src/utils.rs +++ b/crates/ra_assists/src/utils.rs @@ -5,13 +5,13 @@ use std::{iter, ops}; use hir::{Adt, Crate, Enum, ScopeDef, Semantics, Trait, Type}; use ra_ide_db::RootDatabase; -use ra_syntax::{ +use rustc_hash::FxHashSet; +use syntax::{ ast::{self, make, NameOwner}, AstNode, SyntaxKind::*, SyntaxNode, TextSize, T, }; -use rustc_hash::FxHashSet; use crate::assist_config::SnippetCap; diff --git a/crates/ra_assists/src/utils/insert_use.rs b/crates/ra_assists/src/utils/insert_use.rs index 13dbe1919c..f89c288da4 100644 --- a/crates/ra_assists/src/utils/insert_use.rs +++ b/crates/ra_assists/src/utils/insert_use.rs @@ -4,7 +4,7 @@ use either::Either; use hir::{self, ModPath}; -use ra_syntax::{ +use syntax::{ ast::{self, NameOwner, VisibilityOwner}, AstNode, Direction, SmolStr, SyntaxKind::{PATH, PATH_SEGMENT}, diff --git a/crates/ra_cfg/Cargo.toml b/crates/ra_cfg/Cargo.toml index 770a407428..cb0d2b9d73 100644 --- a/crates/ra_cfg/Cargo.toml +++ b/crates/ra_cfg/Cargo.toml @@ -11,7 +11,7 @@ doctest = false [dependencies] rustc-hash = "1.1.0" -ra_syntax = { path = "../ra_syntax" } +syntax = { path = "../syntax" } tt = { path = "../tt" } [dev-dependencies] diff --git a/crates/ra_cfg/src/cfg_expr.rs b/crates/ra_cfg/src/cfg_expr.rs index f48928aee8..940091465c 100644 --- a/crates/ra_cfg/src/cfg_expr.rs +++ b/crates/ra_cfg/src/cfg_expr.rs @@ -4,7 +4,7 @@ use std::slice::Iter as SliceIter; -use ra_syntax::SmolStr; +use syntax::SmolStr; #[derive(Debug, Clone, PartialEq, Eq)] pub enum CfgExpr { @@ -87,7 +87,7 @@ mod tests { use super::*; use mbe::{ast_to_token_tree, TokenMap}; - use ra_syntax::ast::{self, AstNode}; + use syntax::ast::{self, AstNode}; fn get_token_tree_generated(input: &str) -> (tt::Subtree, TokenMap) { let source_file = ast::SourceFile::parse(input).ok().unwrap(); diff --git a/crates/ra_cfg/src/lib.rs b/crates/ra_cfg/src/lib.rs index cd5a0a7b64..7e025143bd 100644 --- a/crates/ra_cfg/src/lib.rs +++ b/crates/ra_cfg/src/lib.rs @@ -2,8 +2,8 @@ mod cfg_expr; -use ra_syntax::SmolStr; use rustc_hash::FxHashSet; +use syntax::SmolStr; pub use cfg_expr::CfgExpr; diff --git a/crates/ra_db/Cargo.toml b/crates/ra_db/Cargo.toml index 47a0f6248f..156ea1ee4b 100644 --- a/crates/ra_db/Cargo.toml +++ b/crates/ra_db/Cargo.toml @@ -12,7 +12,7 @@ doctest = false salsa = "0.15.2" rustc-hash = "1.1.0" -ra_syntax = { path = "../ra_syntax" } +syntax = { path = "../syntax" } ra_cfg = { path = "../ra_cfg" } profile = { path = "../profile" } tt = { path = "../tt" } diff --git a/crates/ra_db/src/input.rs b/crates/ra_db/src/input.rs index 02a1abee0f..12a8634997 100644 --- a/crates/ra_db/src/input.rs +++ b/crates/ra_db/src/input.rs @@ -9,8 +9,8 @@ use std::{fmt, iter::FromIterator, ops, str::FromStr, sync::Arc}; use ra_cfg::CfgOptions; -use ra_syntax::SmolStr; use rustc_hash::{FxHashMap, FxHashSet}; +use syntax::SmolStr; use tt::TokenExpander; use vfs::file_set::FileSet; diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs index 795d7d2b61..73ac243d66 100644 --- a/crates/ra_db/src/lib.rs +++ b/crates/ra_db/src/lib.rs @@ -5,8 +5,8 @@ pub mod fixture; use std::{panic, sync::Arc}; -use ra_syntax::{ast, Parse, SourceFile, TextRange, TextSize}; use rustc_hash::FxHashSet; +use syntax::{ast, Parse, SourceFile, TextRange, TextSize}; pub use crate::{ cancellation::Canceled, diff --git a/crates/ra_fmt/Cargo.toml b/crates/ra_fmt/Cargo.toml index b4ef93f2b2..d42ca62be2 100644 --- a/crates/ra_fmt/Cargo.toml +++ b/crates/ra_fmt/Cargo.toml @@ -12,4 +12,4 @@ doctest = false [dependencies] itertools = "0.9.0" -ra_syntax = { path = "../ra_syntax" } +syntax = { path = "../syntax" } diff --git a/crates/ra_fmt/src/lib.rs b/crates/ra_fmt/src/lib.rs index f910ded9da..d0bf0593f7 100644 --- a/crates/ra_fmt/src/lib.rs +++ b/crates/ra_fmt/src/lib.rs @@ -3,7 +3,7 @@ use std::iter::successors; use itertools::Itertools; -use ra_syntax::{ +use syntax::{ ast::{self, AstNode, AstToken}, SmolStr, SyntaxKind, SyntaxKind::*, diff --git a/crates/ra_hir/Cargo.toml b/crates/ra_hir/Cargo.toml index 903406e849..ee5622a7d9 100644 --- a/crates/ra_hir/Cargo.toml +++ b/crates/ra_hir/Cargo.toml @@ -17,7 +17,7 @@ arrayvec = "0.5.1" itertools = "0.9.0" stdx = { path = "../stdx" } -ra_syntax = { path = "../ra_syntax" } +syntax = { path = "../syntax" } ra_db = { path = "../ra_db" } profile = { path = "../profile" } hir_expand = { path = "../ra_hir_expand", package = "ra_hir_expand" } diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 5c0c6184a7..98724c1462 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs @@ -31,12 +31,12 @@ use hir_ty::{ InEnvironment, Substs, TraitEnvironment, Ty, TyDefId, TypeCtor, }; use ra_db::{CrateId, Edition, FileId}; -use ra_syntax::{ +use rustc_hash::FxHashSet; +use stdx::impl_from; +use syntax::{ ast::{self, AttrsOwner, NameOwner}, AstNode, }; -use rustc_hash::FxHashSet; -use stdx::impl_from; use crate::{ db::{DefDatabase, HirDatabase}, diff --git a/crates/ra_hir/src/has_source.rs b/crates/ra_hir/src/has_source.rs index 1c691d9619..a50d4ff029 100644 --- a/crates/ra_hir/src/has_source.rs +++ b/crates/ra_hir/src/has_source.rs @@ -6,7 +6,7 @@ use hir_def::{ src::{HasChildSource, HasSource as _}, Lookup, VariantId, }; -use ra_syntax::ast; +use syntax::ast; use crate::{ db::HirDatabase, Const, Enum, EnumVariant, Field, FieldSource, Function, ImplDef, MacroDef, diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs index 7e3ec6315e..2e0ef44085 100644 --- a/crates/ra_hir/src/semantics.rs +++ b/crates/ra_hir/src/semantics.rs @@ -12,11 +12,11 @@ use hir_expand::{hygiene::Hygiene, name::AsName, ExpansionInfo}; use hir_ty::associated_type_shorthand_candidates; use itertools::Itertools; use ra_db::{FileId, FileRange}; -use ra_syntax::{ +use rustc_hash::{FxHashMap, FxHashSet}; +use syntax::{ algo::{find_node_at_offset, skip_trivia_token}, ast, AstNode, Direction, SyntaxNode, SyntaxToken, TextRange, TextSize, }; -use rustc_hash::{FxHashMap, FxHashSet}; use crate::{ db::HirDatabase, diff --git a/crates/ra_hir/src/semantics/source_to_def.rs b/crates/ra_hir/src/semantics/source_to_def.rs index a6ff8b0bfc..ab2fd0957f 100644 --- a/crates/ra_hir/src/semantics/source_to_def.rs +++ b/crates/ra_hir/src/semantics/source_to_def.rs @@ -10,12 +10,12 @@ use hir_def::{ }; use hir_expand::{name::AsName, AstId, MacroDefKind}; use ra_db::FileId; -use ra_syntax::{ +use rustc_hash::FxHashMap; +use stdx::impl_from; +use syntax::{ ast::{self, NameOwner}, match_ast, AstNode, SyntaxNode, }; -use rustc_hash::FxHashMap; -use stdx::impl_from; use crate::{db::HirDatabase, InFile, MacroDefId}; diff --git a/crates/ra_hir/src/source_analyzer.rs b/crates/ra_hir/src/source_analyzer.rs index d3d62debfd..6b2de3a06f 100644 --- a/crates/ra_hir/src/source_analyzer.rs +++ b/crates/ra_hir/src/source_analyzer.rs @@ -21,7 +21,7 @@ use hir_ty::{ diagnostics::{record_literal_missing_fields, record_pattern_missing_fields}, InferenceResult, Substs, Ty, }; -use ra_syntax::{ +use syntax::{ ast::{self, AstNode}, SyntaxNode, TextRange, TextSize, }; diff --git a/crates/ra_hir_def/Cargo.toml b/crates/ra_hir_def/Cargo.toml index 1a080a8b4b..38129782fe 100644 --- a/crates/ra_hir_def/Cargo.toml +++ b/crates/ra_hir_def/Cargo.toml @@ -24,7 +24,7 @@ stdx = { path = "../stdx" } arena = { path = "../arena" } ra_db = { path = "../ra_db" } -ra_syntax = { path = "../ra_syntax" } +syntax = { path = "../syntax" } profile = { path = "../profile" } hir_expand = { path = "../ra_hir_expand", package = "ra_hir_expand" } test_utils = { path = "../test_utils" } diff --git a/crates/ra_hir_def/src/adt.rs b/crates/ra_hir_def/src/adt.rs index 896a69ca80..c83219d771 100644 --- a/crates/ra_hir_def/src/adt.rs +++ b/crates/ra_hir_def/src/adt.rs @@ -8,7 +8,7 @@ use hir_expand::{ name::{AsName, Name}, InFile, }; -use ra_syntax::ast::{self, NameOwner, VisibilityOwner}; +use syntax::ast::{self, NameOwner, VisibilityOwner}; use tt::{Delimiter, DelimiterKind, Leaf, Subtree, TokenTree}; use crate::{ diff --git a/crates/ra_hir_def/src/attr.rs b/crates/ra_hir_def/src/attr.rs index 050832ce01..36dc8b8166 100644 --- a/crates/ra_hir_def/src/attr.rs +++ b/crates/ra_hir_def/src/attr.rs @@ -6,7 +6,7 @@ use either::Either; use hir_expand::{hygiene::Hygiene, AstId, InFile}; use mbe::ast_to_token_tree; use ra_cfg::{CfgExpr, CfgOptions}; -use ra_syntax::{ +use syntax::{ ast::{self, AstNode, AttrsOwner}, SmolStr, }; diff --git a/crates/ra_hir_def/src/body.rs b/crates/ra_hir_def/src/body.rs index 1deb1a8371..7c33966a71 100644 --- a/crates/ra_hir_def/src/body.rs +++ b/crates/ra_hir_def/src/body.rs @@ -11,8 +11,8 @@ use either::Either; use hir_expand::{ast_id_map::AstIdMap, hygiene::Hygiene, AstId, HirFileId, InFile, MacroDefId}; use ra_cfg::CfgOptions; use ra_db::CrateId; -use ra_syntax::{ast, AstNode, AstPtr}; use rustc_hash::FxHashMap; +use syntax::{ast, AstNode, AstPtr}; use test_utils::mark; pub(crate) use lower::LowerCtx; diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index 4823930062..a26251cdeb 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs @@ -10,14 +10,14 @@ use hir_expand::{ name::{name, AsName, Name}, HirFileId, MacroDefId, MacroDefKind, }; -use ra_syntax::{ +use rustc_hash::FxHashMap; +use syntax::{ ast::{ self, ArgListOwner, ArrayExprKind, AstChildren, LiteralKind, LoopBodyOwner, NameOwner, SlicePatComponents, }, AstNode, AstPtr, }; -use rustc_hash::FxHashMap; use test_utils::mark; use crate::{ diff --git a/crates/ra_hir_def/src/body/scope.rs b/crates/ra_hir_def/src/body/scope.rs index f783e18b54..079f14c298 100644 --- a/crates/ra_hir_def/src/body/scope.rs +++ b/crates/ra_hir_def/src/body/scope.rs @@ -171,7 +171,7 @@ fn compute_expr_scopes(expr: ExprId, body: &Body, scopes: &mut ExprScopes, scope mod tests { use hir_expand::{name::AsName, InFile}; use ra_db::{fixture::WithFixture, FileId, SourceDatabase}; - use ra_syntax::{algo::find_node_at_offset, ast, AstNode}; + use syntax::{algo::find_node_at_offset, ast, AstNode}; use test_utils::{assert_eq_text, extract_offset, mark}; use crate::{db::DefDatabase, test_db::TestDB, FunctionId, ModuleDefId}; diff --git a/crates/ra_hir_def/src/data.rs b/crates/ra_hir_def/src/data.rs index 758c12f331..9a8eb4edec 100644 --- a/crates/ra_hir_def/src/data.rs +++ b/crates/ra_hir_def/src/data.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use hir_expand::{name::Name, InFile}; -use ra_syntax::ast; +use syntax::ast; use crate::{ attr::Attrs, diff --git a/crates/ra_hir_def/src/db.rs b/crates/ra_hir_def/src/db.rs index 1dd4197f85..a925548b58 100644 --- a/crates/ra_hir_def/src/db.rs +++ b/crates/ra_hir_def/src/db.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use hir_expand::{db::AstDatabase, HirFileId}; use ra_db::{salsa, CrateId, SourceDatabase, Upcast}; -use ra_syntax::SmolStr; +use syntax::SmolStr; use crate::{ adt::{EnumData, StructData}, diff --git a/crates/ra_hir_def/src/diagnostics.rs b/crates/ra_hir_def/src/diagnostics.rs index 71d177070d..2e38a978f8 100644 --- a/crates/ra_hir_def/src/diagnostics.rs +++ b/crates/ra_hir_def/src/diagnostics.rs @@ -3,7 +3,7 @@ use std::any::Any; use hir_expand::diagnostics::Diagnostic; -use ra_syntax::{ast, AstPtr, SyntaxNodePtr}; +use syntax::{ast, AstPtr, SyntaxNodePtr}; use hir_expand::{HirFileId, InFile}; diff --git a/crates/ra_hir_def/src/docs.rs b/crates/ra_hir_def/src/docs.rs index 2630b3d895..e9a02b11bb 100644 --- a/crates/ra_hir_def/src/docs.rs +++ b/crates/ra_hir_def/src/docs.rs @@ -6,7 +6,7 @@ use std::sync::Arc; use either::Either; -use ra_syntax::ast; +use syntax::ast; use crate::{ db::DefDatabase, diff --git a/crates/ra_hir_def/src/expr.rs b/crates/ra_hir_def/src/expr.rs index befe41c2ae..c94b3a36f5 100644 --- a/crates/ra_hir_def/src/expr.rs +++ b/crates/ra_hir_def/src/expr.rs @@ -14,7 +14,7 @@ use arena::{Idx, RawId}; use hir_expand::name::Name; -use ra_syntax::ast::RangeOp; +use syntax::ast::RangeOp; use crate::{ builtin_type::{BuiltinFloat, BuiltinInt}, @@ -197,7 +197,7 @@ pub enum ArithOp { BitAnd, } -pub use ra_syntax::ast::PrefixOp as UnaryOp; +pub use syntax::ast::PrefixOp as UnaryOp; #[derive(Debug, Clone, Eq, PartialEq)] pub enum Array { ElementList(Vec), diff --git a/crates/ra_hir_def/src/find_path.rs b/crates/ra_hir_def/src/find_path.rs index 46e70eb48a..5099f417d3 100644 --- a/crates/ra_hir_def/src/find_path.rs +++ b/crates/ra_hir_def/src/find_path.rs @@ -294,7 +294,7 @@ fn find_local_import_locations( mod tests { use hir_expand::hygiene::Hygiene; use ra_db::fixture::WithFixture; - use ra_syntax::ast::AstNode; + use syntax::ast::AstNode; use test_utils::mark; use crate::test_db::TestDB; @@ -307,12 +307,9 @@ mod tests { fn check_found_path(ra_fixture: &str, path: &str) { let (db, pos) = TestDB::with_position(ra_fixture); let module = db.module_for_file(pos.file_id); - let parsed_path_file = ra_syntax::SourceFile::parse(&format!("use {};", path)); - let ast_path = parsed_path_file - .syntax_node() - .descendants() - .find_map(ra_syntax::ast::Path::cast) - .unwrap(); + let parsed_path_file = syntax::SourceFile::parse(&format!("use {};", path)); + let ast_path = + parsed_path_file.syntax_node().descendants().find_map(syntax::ast::Path::cast).unwrap(); let mod_path = ModPath::from_src(ast_path, &Hygiene::new_unhygienic()).unwrap(); let crate_def_map = db.crate_def_map(module.krate); @@ -441,12 +438,12 @@ mod tests { // already in scope. check_found_path( r#" - //- /main.rs crate:main deps:ra_syntax + //- /main.rs crate:main deps:syntax - use ra_syntax::ast; + use syntax::ast; <|> - //- /lib.rs crate:ra_syntax + //- /lib.rs crate:syntax pub mod ast { pub enum ModuleItem { A, B, C, @@ -458,18 +455,18 @@ mod tests { check_found_path( r#" - //- /main.rs crate:main deps:ra_syntax + //- /main.rs crate:main deps:syntax <|> - //- /lib.rs crate:ra_syntax + //- /lib.rs crate:syntax pub mod ast { pub enum ModuleItem { A, B, C, } } "#, - "ra_syntax::ast::ModuleItem", + "syntax::ast::ModuleItem", ); } diff --git a/crates/ra_hir_def/src/generics.rs b/crates/ra_hir_def/src/generics.rs index 0e06a0b12e..4476f03162 100644 --- a/crates/ra_hir_def/src/generics.rs +++ b/crates/ra_hir_def/src/generics.rs @@ -11,7 +11,7 @@ use hir_expand::{ InFile, }; use ra_db::FileId; -use ra_syntax::ast::{self, GenericParamsOwner, NameOwner, TypeBoundsOwner}; +use syntax::ast::{self, GenericParamsOwner, NameOwner, TypeBoundsOwner}; use crate::{ body::LowerCtx, diff --git a/crates/ra_hir_def/src/import_map.rs b/crates/ra_hir_def/src/import_map.rs index 3a9eec8873..431ff30abd 100644 --- a/crates/ra_hir_def/src/import_map.rs +++ b/crates/ra_hir_def/src/import_map.rs @@ -5,9 +5,9 @@ use std::{cmp::Ordering, fmt, hash::BuildHasherDefault, sync::Arc}; use fst::{self, Streamer}; use indexmap::{map::Entry, IndexMap}; use ra_db::CrateId; -use ra_syntax::SmolStr; use rustc_hash::{FxHashMap, FxHasher}; use smallvec::SmallVec; +use syntax::SmolStr; use crate::{ db::DefDatabase, diff --git a/crates/ra_hir_def/src/item_tree.rs b/crates/ra_hir_def/src/item_tree.rs index 104966c7f2..e14722caeb 100644 --- a/crates/ra_hir_def/src/item_tree.rs +++ b/crates/ra_hir_def/src/item_tree.rs @@ -22,9 +22,9 @@ use hir_expand::{ name::{name, AsName, Name}, HirFileId, InFile, }; -use ra_syntax::{ast, match_ast}; use rustc_hash::FxHashMap; use smallvec::SmallVec; +use syntax::{ast, match_ast}; use test_utils::mark; use crate::{ diff --git a/crates/ra_hir_def/src/item_tree/lower.rs b/crates/ra_hir_def/src/item_tree/lower.rs index 4523d0fbbf..391ab5d392 100644 --- a/crates/ra_hir_def/src/item_tree/lower.rs +++ b/crates/ra_hir_def/src/item_tree/lower.rs @@ -4,11 +4,11 @@ use std::{collections::hash_map::Entry, mem, sync::Arc}; use arena::map::ArenaMap; use hir_expand::{ast_id_map::AstIdMap, hygiene::Hygiene, HirFileId}; -use ra_syntax::{ +use smallvec::SmallVec; +use syntax::{ ast::{self, ModuleItemOwner}, SyntaxNode, }; -use smallvec::SmallVec; use crate::{ attr::Attrs, diff --git a/crates/ra_hir_def/src/item_tree/tests.rs b/crates/ra_hir_def/src/item_tree/tests.rs index a81497fa8a..6c843e339a 100644 --- a/crates/ra_hir_def/src/item_tree/tests.rs +++ b/crates/ra_hir_def/src/item_tree/tests.rs @@ -1,10 +1,10 @@ use expect::{expect, Expect}; use hir_expand::{db::AstDatabase, HirFileId, InFile}; use ra_db::fixture::WithFixture; -use ra_syntax::{ast, AstNode}; use rustc_hash::FxHashSet; use std::sync::Arc; use stdx::format_to; +use syntax::{ast, AstNode}; use crate::{db::DefDatabase, test_db::TestDB}; @@ -228,31 +228,31 @@ fn smoke() { top-level items: #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_on_use"))] }, input: None }]) }] - Import { path: ModPath { kind: Plain, segments: [Name(Text("a"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_glob: false, is_prelude: false, ast_id: FileAstId::(0) } + Import { path: ModPath { kind: Plain, segments: [Name(Text("a"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_glob: false, is_prelude: false, ast_id: FileAstId::(0) } #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_on_use"))] }, input: None }]) }] - Import { path: ModPath { kind: Plain, segments: [Name(Text("b"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_glob: true, is_prelude: false, ast_id: FileAstId::(0) } + Import { path: ModPath { kind: Plain, segments: [Name(Text("b"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_glob: true, is_prelude: false, ast_id: FileAstId::(0) } #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("ext_crate"))] }, input: None }]) }] - ExternCrate { path: ModPath { kind: Plain, segments: [Name(Text("krate"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_macro_use: false, ast_id: FileAstId::(1) } + ExternCrate { path: ModPath { kind: Plain, segments: [Name(Text("krate"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_macro_use: false, ast_id: FileAstId::(1) } #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("on_trait"))] }, input: None }]) }] - Trait { name: Name(Text("Tr")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(0), auto: false, items: [TypeAlias(Idx::(0)), Const(Idx::(0)), Function(Idx::(0)), Function(Idx::(1))], ast_id: FileAstId::(2) } + Trait { name: Name(Text("Tr")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(0), auto: false, items: [TypeAlias(Idx::(0)), Const(Idx::(0)), Function(Idx::(0)), Function(Idx::(1))], ast_id: FileAstId::(2) } > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_ty"))] }, input: None }]) }] - > TypeAlias { name: Name(Text("AssocTy")), visibility: RawVisibilityId("pub(self)"), bounds: [Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Tr"))] }, generic_args: [Some(GenericArgs { args: [Type(Tuple([]))], has_self_type: false, bindings: [] })] })], generic_params: GenericParamsId(4294967295), type_ref: None, ast_id: FileAstId::(8) } + > TypeAlias { name: Name(Text("AssocTy")), visibility: RawVisibilityId("pub(self)"), bounds: [Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Tr"))] }, generic_args: [Some(GenericArgs { args: [Type(Tuple([]))], has_self_type: false, bindings: [] })] })], generic_params: GenericParamsId(4294967295), type_ref: None, ast_id: FileAstId::(8) } > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_const"))] }, input: None }]) }] - > Const { name: Some(Name(Text("CONST"))), visibility: RawVisibilityId("pub(self)"), type_ref: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("u8"))] }, generic_args: [None] }), ast_id: FileAstId::(9) } + > Const { name: Some(Name(Text("CONST"))), visibility: RawVisibilityId("pub(self)"), type_ref: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("u8"))] }, generic_args: [None] }), ast_id: FileAstId::(9) } > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_method"))] }, input: None }]) }] - > Function { name: Name(Text("method")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: true, is_unsafe: false, params: [Reference(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Self"))] }, generic_args: [None] }), Shared)], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::(10) } + > Function { name: Name(Text("method")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: true, is_unsafe: false, params: [Reference(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Self"))] }, generic_args: [None] }), Shared)], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::(10) } > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_dfl_method"))] }, input: None }]) }] - > Function { name: Name(Text("dfl_method")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: true, is_unsafe: false, params: [Reference(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Self"))] }, generic_args: [None] }), Mut)], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::(11) } + > Function { name: Name(Text("dfl_method")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: true, is_unsafe: false, params: [Reference(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Self"))] }, generic_args: [None] }), Mut)], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::(11) } #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct0"))] }, input: None }]) }] - Struct { name: Name(Text("Struct0")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(1), fields: Unit, ast_id: FileAstId::(3), kind: Unit } + Struct { name: Name(Text("Struct0")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(1), fields: Unit, ast_id: FileAstId::(3), kind: Unit } #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct1"))] }, input: None }]) }] - Struct { name: Name(Text("Struct1")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(2), fields: Tuple(IdRange::(0..1)), ast_id: FileAstId::(4), kind: Tuple } + Struct { name: Name(Text("Struct1")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(2), fields: Tuple(IdRange::(0..1)), ast_id: FileAstId::(4), kind: Tuple } #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct2"))] }, input: None }]) }] - Struct { name: Name(Text("Struct2")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(3), fields: Record(IdRange::(1..2)), ast_id: FileAstId::(5), kind: Record } + Struct { name: Name(Text("Struct2")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(3), fields: Record(IdRange::(1..2)), ast_id: FileAstId::(5), kind: Record } #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("en"))] }, input: None }]) }] - Enum { name: Name(Text("En")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), variants: IdRange::(0..1), ast_id: FileAstId::(6) } + Enum { name: Name(Text("En")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), variants: IdRange::(0..1), ast_id: FileAstId::(6) } #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("un"))] }, input: None }]) }] - Union { name: Name(Text("Un")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), fields: Record(IdRange::(3..4)), ast_id: FileAstId::(7) } + Union { name: Name(Text("Un")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), fields: Record(IdRange::(3..4)), ast_id: FileAstId::(7) } "##]], ); } @@ -274,13 +274,13 @@ fn simple_inner_items() { inner attrs: Attrs { entries: None } top-level items: - Impl { generic_params: GenericParamsId(0), target_trait: Some(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("D"))] }, generic_args: [None] })), target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Response"))] }, generic_args: [Some(GenericArgs { args: [Type(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("T"))] }, generic_args: [None] }))], has_self_type: false, bindings: [] })] }), is_negative: false, items: [Function(Idx::(1))], ast_id: FileAstId::(0) } - > Function { name: Name(Text("foo")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::(1) } + Impl { generic_params: GenericParamsId(0), target_trait: Some(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("D"))] }, generic_args: [None] })), target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Response"))] }, generic_args: [Some(GenericArgs { args: [Type(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("T"))] }, generic_args: [None] }))], has_self_type: false, bindings: [] })] }), is_negative: false, items: [Function(Idx::(1))], ast_id: FileAstId::(0) } + > Function { name: Name(Text("foo")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::(1) } inner items: - for AST FileAstId::(2): - Function { name: Name(Text("end")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(1), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::(2) } + for AST FileAstId::(2): + Function { name: Name(Text("end")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(1), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::(2) } "#]], ); @@ -303,9 +303,9 @@ fn extern_attrs() { top-level items: #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_a"))] }, input: None }, Attr { path: ModPath { kind: Plain, segments: [Name(Text("block_attr"))] }, input: None }]) }] - Function { name: Name(Text("a")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: true, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::(1) } + Function { name: Name(Text("a")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: true, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::(1) } #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_b"))] }, input: None }, Attr { path: ModPath { kind: Plain, segments: [Name(Text("block_attr"))] }, input: None }]) }] - Function { name: Name(Text("b")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: true, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::(2) } + Function { name: Name(Text("b")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: true, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::(2) } "##]], ); } @@ -327,11 +327,11 @@ fn trait_attrs() { top-level items: #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("trait_attr"))] }, input: None }]) }] - Trait { name: Name(Text("Tr")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(0), auto: false, items: [Function(Idx::(0)), Function(Idx::(1))], ast_id: FileAstId::(0) } + Trait { name: Name(Text("Tr")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(0), auto: false, items: [Function(Idx::(0)), Function(Idx::(1))], ast_id: FileAstId::(0) } > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_a"))] }, input: None }]) }] - > Function { name: Name(Text("a")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::(1) } + > Function { name: Name(Text("a")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::(1) } > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_b"))] }, input: None }]) }] - > Function { name: Name(Text("b")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::(2) } + > Function { name: Name(Text("b")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::(2) } "##]], ); } @@ -353,11 +353,11 @@ fn impl_attrs() { top-level items: #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("impl_attr"))] }, input: None }]) }] - Impl { generic_params: GenericParamsId(4294967295), target_trait: None, target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Ty"))] }, generic_args: [None] }), is_negative: false, items: [Function(Idx::(0)), Function(Idx::(1))], ast_id: FileAstId::(0) } + Impl { generic_params: GenericParamsId(4294967295), target_trait: None, target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Ty"))] }, generic_args: [None] }), is_negative: false, items: [Function(Idx::(0)), Function(Idx::(1))], ast_id: FileAstId::(0) } > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_a"))] }, input: None }]) }] - > Function { name: Name(Text("a")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::(1) } + > Function { name: Name(Text("a")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::(1) } > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_b"))] }, input: None }]) }] - > Function { name: Name(Text("b")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::(2) } + > Function { name: Name(Text("b")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::(2) } "##]], ); } @@ -408,13 +408,13 @@ fn inner_item_attrs() { inner attrs: Attrs { entries: None } top-level items: - Function { name: Name(Text("foo")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::(0) } + Function { name: Name(Text("foo")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::(0) } inner items: - for AST FileAstId::(1): + for AST FileAstId::(1): #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("on_inner"))] }, input: None }]) }] - Function { name: Name(Text("inner")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::(1) } + Function { name: Name(Text("inner")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], is_varargs: false, ret_type: Tuple([]), ast_id: FileAstId::(1) } "##]], ); @@ -432,8 +432,8 @@ fn assoc_item_macros() { inner attrs: Attrs { entries: None } top-level items: - Impl { generic_params: GenericParamsId(4294967295), target_trait: None, target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("S"))] }, generic_args: [None] }), is_negative: false, items: [MacroCall(Idx::(0))], ast_id: FileAstId::(0) } - > MacroCall { name: None, path: ModPath { kind: Plain, segments: [Name(Text("items"))] }, is_export: false, is_local_inner: false, is_builtin: false, ast_id: FileAstId::(1) } + Impl { generic_params: GenericParamsId(4294967295), target_trait: None, target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("S"))] }, generic_args: [None] }), is_negative: false, items: [MacroCall(Idx::(0))], ast_id: FileAstId::(0) } + > MacroCall { name: None, path: ModPath { kind: Plain, segments: [Name(Text("items"))] }, is_export: false, is_local_inner: false, is_builtin: false, ast_id: FileAstId::(1) } "#]], ); } diff --git a/crates/ra_hir_def/src/keys.rs b/crates/ra_hir_def/src/keys.rs index 441bdbead8..40a5d92b50 100644 --- a/crates/ra_hir_def/src/keys.rs +++ b/crates/ra_hir_def/src/keys.rs @@ -3,8 +3,8 @@ use std::marker::PhantomData; use hir_expand::{InFile, MacroDefId}; -use ra_syntax::{ast, AstNode, AstPtr}; use rustc_hash::FxHashMap; +use syntax::{ast, AstNode, AstPtr}; use crate::{ dyn_map::{DynMap, Policy}, diff --git a/crates/ra_hir_def/src/lang_item.rs b/crates/ra_hir_def/src/lang_item.rs index 3631499bf7..063eadccb2 100644 --- a/crates/ra_hir_def/src/lang_item.rs +++ b/crates/ra_hir_def/src/lang_item.rs @@ -4,8 +4,8 @@ //! features, such as Fn family of traits. use std::sync::Arc; -use ra_syntax::SmolStr; use rustc_hash::FxHashMap; +use syntax::SmolStr; use crate::{ db::DefDatabase, AdtId, AttrDefId, CrateId, EnumId, FunctionId, ImplId, ModuleDefId, ModuleId, diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index 8103937397..806ac731f5 100644 --- a/crates/ra_hir_def/src/lib.rs +++ b/crates/ra_hir_def/src/lib.rs @@ -58,7 +58,7 @@ use hir_expand::{ MacroCallId, MacroCallKind, MacroDefId, MacroDefKind, }; use ra_db::{impl_intern_key, salsa, CrateId}; -use ra_syntax::ast; +use syntax::ast; use crate::builtin_type::BuiltinType; use item_tree::{ diff --git a/crates/ra_hir_def/src/nameres.rs b/crates/ra_hir_def/src/nameres.rs index dc239997f9..d26c837cc8 100644 --- a/crates/ra_hir_def/src/nameres.rs +++ b/crates/ra_hir_def/src/nameres.rs @@ -59,9 +59,9 @@ use std::sync::Arc; use arena::Arena; use hir_expand::{diagnostics::DiagnosticSink, name::Name, InFile}; use ra_db::{CrateId, Edition, FileId}; -use ra_syntax::ast; use rustc_hash::FxHashMap; use stdx::format_to; +use syntax::ast; use crate::{ db::DefDatabase, @@ -288,7 +288,7 @@ pub enum ModuleSource { mod diagnostics { use hir_expand::diagnostics::DiagnosticSink; - use ra_syntax::{ast, AstPtr}; + use syntax::{ast, AstPtr}; use crate::{db::DefDatabase, diagnostics::UnresolvedModule, nameres::LocalModuleId, AstId}; diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index 52ee401d9e..f7270ec91c 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs @@ -13,8 +13,8 @@ use hir_expand::{ }; use ra_cfg::CfgOptions; use ra_db::{CrateId, FileId, ProcMacroId}; -use ra_syntax::ast; use rustc_hash::FxHashMap; +use syntax::ast; use test_utils::mark; use crate::{ diff --git a/crates/ra_hir_def/src/nameres/mod_resolution.rs b/crates/ra_hir_def/src/nameres/mod_resolution.rs index 9539616325..316245d6ba 100644 --- a/crates/ra_hir_def/src/nameres/mod_resolution.rs +++ b/crates/ra_hir_def/src/nameres/mod_resolution.rs @@ -1,7 +1,7 @@ //! This module resolves `mod foo;` declaration to file. use hir_expand::name::Name; use ra_db::FileId; -use ra_syntax::SmolStr; +use syntax::SmolStr; use crate::{db::DefDatabase, HirFileId}; diff --git a/crates/ra_hir_def/src/nameres/tests/mod_resolution.rs b/crates/ra_hir_def/src/nameres/tests/mod_resolution.rs index ae58948c42..1f619787e1 100644 --- a/crates/ra_hir_def/src/nameres/tests/mod_resolution.rs +++ b/crates/ra_hir_def/src/nameres/tests/mod_resolution.rs @@ -698,7 +698,7 @@ fn unresolved_module_diagnostics() { ), ), ), - value: FileAstId::(1), + value: FileAstId::(1), }, candidate: "bar.rs", }, diff --git a/crates/ra_hir_def/src/path.rs b/crates/ra_hir_def/src/path.rs index cc1726e9e0..88be07c8a7 100644 --- a/crates/ra_hir_def/src/path.rs +++ b/crates/ra_hir_def/src/path.rs @@ -13,7 +13,7 @@ use hir_expand::{ name::{AsName, Name}, }; use ra_db::CrateId; -use ra_syntax::ast; +use syntax::ast; use crate::{ type_ref::{TypeBound, TypeRef}, diff --git a/crates/ra_hir_def/src/path/lower.rs b/crates/ra_hir_def/src/path/lower.rs index d09fc66e4d..07b9723ce0 100644 --- a/crates/ra_hir_def/src/path/lower.rs +++ b/crates/ra_hir_def/src/path/lower.rs @@ -9,7 +9,7 @@ use hir_expand::{ hygiene::Hygiene, name::{name, AsName}, }; -use ra_syntax::ast::{self, AstNode, TypeBoundsOwner}; +use syntax::ast::{self, AstNode, TypeBoundsOwner}; use super::AssociatedTypeBinding; use crate::{ diff --git a/crates/ra_hir_def/src/path/lower/lower_use.rs b/crates/ra_hir_def/src/path/lower/lower_use.rs index 794be45e89..53cecb05fb 100644 --- a/crates/ra_hir_def/src/path/lower/lower_use.rs +++ b/crates/ra_hir_def/src/path/lower/lower_use.rs @@ -5,7 +5,7 @@ use std::iter; use either::Either; use hir_expand::{hygiene::Hygiene, name::AsName}; -use ra_syntax::ast::{self, NameOwner}; +use syntax::ast::{self, NameOwner}; use test_utils::mark; use crate::path::{ImportAlias, ModPath, PathKind}; diff --git a/crates/ra_hir_def/src/type_ref.rs b/crates/ra_hir_def/src/type_ref.rs index 6f7884ffe5..1a78c1444c 100644 --- a/crates/ra_hir_def/src/type_ref.rs +++ b/crates/ra_hir_def/src/type_ref.rs @@ -1,6 +1,6 @@ //! HIR for references to types. Paths in these are not yet resolved. They can //! be directly created from an ast::TypeRef, without further queries. -use ra_syntax::ast::{self}; +use syntax::ast::{self}; use crate::{body::LowerCtx, path::Path}; diff --git a/crates/ra_hir_def/src/visibility.rs b/crates/ra_hir_def/src/visibility.rs index 1abffb4c3c..e6e0853a30 100644 --- a/crates/ra_hir_def/src/visibility.rs +++ b/crates/ra_hir_def/src/visibility.rs @@ -1,7 +1,7 @@ //! Defines hir-level representation of visibility (e.g. `pub` and `pub(crate)`). use hir_expand::{hygiene::Hygiene, InFile}; -use ra_syntax::ast; +use syntax::ast; use crate::{ db::DefDatabase, diff --git a/crates/ra_hir_expand/Cargo.toml b/crates/ra_hir_expand/Cargo.toml index 052330fdef..153a70bdf5 100644 --- a/crates/ra_hir_expand/Cargo.toml +++ b/crates/ra_hir_expand/Cargo.toml @@ -15,7 +15,7 @@ rustc-hash = "1.0.0" arena = { path = "../arena" } ra_db = { path = "../ra_db" } -ra_syntax = { path = "../ra_syntax" } +syntax = { path = "../syntax" } parser = { path = "../parser" } profile = { path = "../profile" } tt = { path = "../tt" } diff --git a/crates/ra_hir_expand/src/ast_id_map.rs b/crates/ra_hir_expand/src/ast_id_map.rs index 703a85b0f7..f63629b305 100644 --- a/crates/ra_hir_expand/src/ast_id_map.rs +++ b/crates/ra_hir_expand/src/ast_id_map.rs @@ -13,7 +13,7 @@ use std::{ }; use arena::{Arena, Idx}; -use ra_syntax::{ast, AstNode, AstPtr, SyntaxNode, SyntaxNodePtr}; +use syntax::{ast, AstNode, AstPtr, SyntaxNode, SyntaxNodePtr}; /// `AstId` points to an AST node in a specific file. pub struct FileAstId { diff --git a/crates/ra_hir_expand/src/builtin_derive.rs b/crates/ra_hir_expand/src/builtin_derive.rs index 95e6977f24..2d2f8bcb84 100644 --- a/crates/ra_hir_expand/src/builtin_derive.rs +++ b/crates/ra_hir_expand/src/builtin_derive.rs @@ -3,7 +3,7 @@ use log::debug; use parser::FragmentKind; -use ra_syntax::{ +use syntax::{ ast::{self, AstNode, GenericParamsOwner, ModuleItemOwner, NameOwner}, match_ast, }; diff --git a/crates/ra_hir_expand/src/builtin_macro.rs b/crates/ra_hir_expand/src/builtin_macro.rs index 24dc0b4e7f..ae4c843820 100644 --- a/crates/ra_hir_expand/src/builtin_macro.rs +++ b/crates/ra_hir_expand/src/builtin_macro.rs @@ -8,7 +8,7 @@ use either::Either; use mbe::parse_to_token_tree; use parser::FragmentKind; use ra_db::FileId; -use ra_syntax::ast::{self, AstToken, HasStringValue}; +use syntax::ast::{self, AstToken, HasStringValue}; macro_rules! register_builtin { ( LAZY: $(($name:ident, $kind: ident) => $expand:ident),* , EAGER: $(($e_name:ident, $e_kind: ident) => $e_expand:ident),* ) => { @@ -427,8 +427,8 @@ mod tests { MacroCallLoc, }; use ra_db::{fixture::WithFixture, SourceDatabase}; - use ra_syntax::ast::NameOwner; use std::sync::Arc; + use syntax::ast::NameOwner; fn expand_builtin_macro(ra_fixture: &str) -> String { let (db, file_id) = TestDB::with_single_file(&ra_fixture); diff --git a/crates/ra_hir_expand/src/db.rs b/crates/ra_hir_expand/src/db.rs index d83c391a90..c275f6b017 100644 --- a/crates/ra_hir_expand/src/db.rs +++ b/crates/ra_hir_expand/src/db.rs @@ -5,7 +5,7 @@ use std::sync::Arc; use mbe::{ExpandResult, MacroRules}; use parser::FragmentKind; use ra_db::{salsa, SourceDatabase}; -use ra_syntax::{algo::diff, AstNode, GreenNode, Parse, SyntaxKind::*, SyntaxNode}; +use syntax::{algo::diff, AstNode, GreenNode, Parse, SyntaxKind::*, SyntaxNode}; use crate::{ ast_id_map::AstIdMap, BuiltinDeriveExpander, BuiltinFnLikeExpander, EagerCallLoc, EagerMacroId, @@ -92,9 +92,9 @@ pub trait AstDatabase: SourceDatabase { pub fn expand_hypothetical( db: &dyn AstDatabase, actual_macro_call: MacroCallId, - hypothetical_args: &ra_syntax::ast::TokenTree, - token_to_map: ra_syntax::SyntaxToken, -) -> Option<(SyntaxNode, ra_syntax::SyntaxToken)> { + hypothetical_args: &syntax::ast::TokenTree, + token_to_map: syntax::SyntaxToken, +) -> Option<(SyntaxNode, syntax::SyntaxToken)> { let macro_file = MacroFile { macro_call_id: actual_macro_call }; let (tt, tmap_1) = mbe::syntax_node_to_token_tree(hypothetical_args.syntax()).unwrap(); let range = @@ -105,7 +105,7 @@ pub fn expand_hypothetical( parse_macro_with_arg(db, macro_file, Some(std::sync::Arc::new((tt, tmap_1))))?; let token_id = macro_def.0.map_id_down(token_id); let range = tmap_2.range_by_token(token_id)?.by_kind(token_to_map.kind())?; - let token = ra_syntax::algo::find_covering_element(&node.syntax_node(), range).into_token()?; + let token = syntax::algo::find_covering_element(&node.syntax_node(), range).into_token()?; Some((node.syntax_node(), token)) } diff --git a/crates/ra_hir_expand/src/diagnostics.rs b/crates/ra_hir_expand/src/diagnostics.rs index b138500e73..59d35debe3 100644 --- a/crates/ra_hir_expand/src/diagnostics.rs +++ b/crates/ra_hir_expand/src/diagnostics.rs @@ -16,7 +16,7 @@ use std::{any::Any, fmt}; -use ra_syntax::SyntaxNodePtr; +use syntax::SyntaxNodePtr; use crate::InFile; diff --git a/crates/ra_hir_expand/src/eager.rs b/crates/ra_hir_expand/src/eager.rs index dc83044ea4..bd3409f973 100644 --- a/crates/ra_hir_expand/src/eager.rs +++ b/crates/ra_hir_expand/src/eager.rs @@ -27,8 +27,8 @@ use crate::{ use parser::FragmentKind; use ra_db::CrateId; -use ra_syntax::{algo::SyntaxRewriter, SyntaxNode}; use std::sync::Arc; +use syntax::{algo::SyntaxRewriter, SyntaxNode}; pub fn expand_eager_macro( db: &dyn AstDatabase, diff --git a/crates/ra_hir_expand/src/hygiene.rs b/crates/ra_hir_expand/src/hygiene.rs index aefe47bd32..23b5eac270 100644 --- a/crates/ra_hir_expand/src/hygiene.rs +++ b/crates/ra_hir_expand/src/hygiene.rs @@ -4,7 +4,7 @@ //! this moment, this is horribly incomplete and handles only `$crate`. use either::Either; use ra_db::CrateId; -use ra_syntax::ast; +use syntax::ast; use crate::{ db::AstDatabase, diff --git a/crates/ra_hir_expand/src/lib.rs b/crates/ra_hir_expand/src/lib.rs index 38f0ffff81..af0cc445f7 100644 --- a/crates/ra_hir_expand/src/lib.rs +++ b/crates/ra_hir_expand/src/lib.rs @@ -19,7 +19,7 @@ use std::hash::Hash; use std::sync::Arc; use ra_db::{impl_intern_key, salsa, CrateId, FileId}; -use ra_syntax::{ +use syntax::{ algo, ast::{self, AstNode}, SyntaxNode, SyntaxToken, TextSize, diff --git a/crates/ra_hir_expand/src/name.rs b/crates/ra_hir_expand/src/name.rs index 969a2e5b83..4dcaff0885 100644 --- a/crates/ra_hir_expand/src/name.rs +++ b/crates/ra_hir_expand/src/name.rs @@ -2,7 +2,7 @@ use std::fmt; -use ra_syntax::{ast, SmolStr}; +use syntax::{ast, SmolStr}; /// `Name` is a wrapper around string, which is used in hir for both references /// and declarations. In theory, names should also carry hygiene info, but we are @@ -37,8 +37,8 @@ impl Name { Name(Repr::TupleField(idx)) } - pub fn new_lifetime(lt: &ra_syntax::SyntaxToken) -> Name { - assert!(lt.kind() == ra_syntax::SyntaxKind::LIFETIME); + pub fn new_lifetime(lt: &syntax::SyntaxToken) -> Name { + assert!(lt.kind() == syntax::SyntaxKind::LIFETIME); Name(Repr::Text(lt.text().clone())) } diff --git a/crates/ra_hir_ty/Cargo.toml b/crates/ra_hir_ty/Cargo.toml index 380d5e6015..6156e4a854 100644 --- a/crates/ra_hir_ty/Cargo.toml +++ b/crates/ra_hir_ty/Cargo.toml @@ -23,7 +23,7 @@ hir_expand = { path = "../ra_hir_expand", package = "ra_hir_expand" } arena = { path = "../arena" } ra_db = { path = "../ra_db" } profile = { path = "../profile" } -ra_syntax = { path = "../ra_syntax" } +syntax = { path = "../syntax" } test_utils = { path = "../test_utils" } scoped-tls = "1" diff --git a/crates/ra_hir_ty/src/diagnostics.rs b/crates/ra_hir_ty/src/diagnostics.rs index 55c02c1feb..bf35d2d0ee 100644 --- a/crates/ra_hir_ty/src/diagnostics.rs +++ b/crates/ra_hir_ty/src/diagnostics.rs @@ -8,8 +8,8 @@ use std::any::Any; use hir_def::DefWithBodyId; use hir_expand::diagnostics::{Diagnostic, DiagnosticSink}; use hir_expand::{name::Name, HirFileId, InFile}; -use ra_syntax::{ast, AstPtr, SyntaxNodePtr}; use stdx::format_to; +use syntax::{ast, AstPtr, SyntaxNodePtr}; use crate::db::HirDatabase; @@ -214,8 +214,8 @@ mod tests { diagnostics::{Diagnostic, DiagnosticSinkBuilder}, }; use ra_db::{fixture::WithFixture, FileId, SourceDatabase, SourceDatabaseExt}; - use ra_syntax::{TextRange, TextSize}; use rustc_hash::FxHashMap; + use syntax::{TextRange, TextSize}; use crate::{diagnostics::validate_body, test_db::TestDB}; diff --git a/crates/ra_hir_ty/src/diagnostics/expr.rs b/crates/ra_hir_ty/src/diagnostics/expr.rs index 51adcecafa..fb76e2e4ec 100644 --- a/crates/ra_hir_ty/src/diagnostics/expr.rs +++ b/crates/ra_hir_ty/src/diagnostics/expr.rs @@ -4,8 +4,8 @@ use std::sync::Arc; use hir_def::{path::path, resolver::HasResolver, AdtId, DefWithBodyId}; use hir_expand::diagnostics::DiagnosticSink; -use ra_syntax::{ast, AstPtr}; use rustc_hash::FxHashSet; +use syntax::{ast, AstPtr}; use crate::{ db::HirDatabase, diff --git a/crates/ra_hir_ty/src/infer.rs b/crates/ra_hir_ty/src/infer.rs index 784ae1c3cc..03b00b101c 100644 --- a/crates/ra_hir_ty/src/infer.rs +++ b/crates/ra_hir_ty/src/infer.rs @@ -31,9 +31,9 @@ use hir_def::{ TypeAliasId, VariantId, }; use hir_expand::{diagnostics::DiagnosticSink, name::name}; -use ra_syntax::SmolStr; use rustc_hash::FxHashMap; use stdx::impl_from; +use syntax::SmolStr; use super::{ primitive::{FloatTy, IntTy}, diff --git a/crates/ra_hir_ty/src/infer/expr.rs b/crates/ra_hir_ty/src/infer/expr.rs index 731b062c2d..a2f849d021 100644 --- a/crates/ra_hir_ty/src/infer/expr.rs +++ b/crates/ra_hir_ty/src/infer/expr.rs @@ -11,7 +11,7 @@ use hir_def::{ AdtId, AssocContainerId, FieldId, Lookup, }; use hir_expand::name::{name, Name}; -use ra_syntax::ast::RangeOp; +use syntax::ast::RangeOp; use crate::{ autoderef, method_resolution, op, diff --git a/crates/ra_hir_ty/src/test_db.rs b/crates/ra_hir_ty/src/test_db.rs index a1714ff0fc..0e2a69eec2 100644 --- a/crates/ra_hir_ty/src/test_db.rs +++ b/crates/ra_hir_ty/src/test_db.rs @@ -8,8 +8,8 @@ use std::{ use hir_def::{db::DefDatabase, ModuleId}; use hir_expand::db::AstDatabase; use ra_db::{salsa, CrateId, FileId, FileLoader, FileLoaderDelegate, SourceDatabase, Upcast}; -use ra_syntax::TextRange; use rustc_hash::{FxHashMap, FxHashSet}; +use syntax::TextRange; use test_utils::extract_annotations; #[salsa::database( diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/ra_hir_ty/src/tests.rs index 016e689fff..5f6f8869ae 100644 --- a/crates/ra_hir_ty/src/tests.rs +++ b/crates/ra_hir_ty/src/tests.rs @@ -22,12 +22,12 @@ use hir_def::{ }; use hir_expand::{db::AstDatabase, InFile}; use ra_db::{fixture::WithFixture, FileRange, SourceDatabase, SourceDatabaseExt}; -use ra_syntax::{ +use stdx::format_to; +use syntax::{ algo, ast::{self, AstNode}, SyntaxNode, }; -use stdx::format_to; use crate::{ db::HirDatabase, display::HirDisplay, infer::TypeMismatch, test_db::TestDB, InferenceResult, Ty, diff --git a/crates/ra_hir_ty/src/tests/macros.rs b/crates/ra_hir_ty/src/tests/macros.rs index 24c53eb022..d887c7a799 100644 --- a/crates/ra_hir_ty/src/tests/macros.rs +++ b/crates/ra_hir_ty/src/tests/macros.rs @@ -543,7 +543,7 @@ fn bar() -> u32 {0} #[test] #[ignore] fn include_accidentally_quadratic() { - let file = project_dir().join("crates/ra_syntax/test_data/accidentally_quadratic"); + let file = project_dir().join("crates/syntax/test_data/accidentally_quadratic"); let big_file = fs::read_to_string(file).unwrap(); let big_file = vec![big_file; 10].join("\n"); diff --git a/crates/ra_ide/Cargo.toml b/crates/ra_ide/Cargo.toml index 84c25f0b8a..8e0fa59178 100644 --- a/crates/ra_ide/Cargo.toml +++ b/crates/ra_ide/Cargo.toml @@ -21,7 +21,7 @@ oorandom = "11.1.2" stdx = { path = "../stdx" } -ra_syntax = { path = "../ra_syntax" } +syntax = { path = "../syntax" } text_edit = { path = "../text_edit" } ra_db = { path = "../ra_db" } ra_ide_db = { path = "../ra_ide_db" } diff --git a/crates/ra_ide/src/call_hierarchy.rs b/crates/ra_ide/src/call_hierarchy.rs index 1fcaf4a32b..116e6bf83e 100644 --- a/crates/ra_ide/src/call_hierarchy.rs +++ b/crates/ra_ide/src/call_hierarchy.rs @@ -4,7 +4,7 @@ use indexmap::IndexMap; use hir::Semantics; use ra_ide_db::RootDatabase; -use ra_syntax::{ast, match_ast, AstNode, TextRange}; +use syntax::{ast, match_ast, AstNode, TextRange}; use crate::{ call_info::FnCallNode, display::ToNav, goto_definition, references, FilePosition, diff --git a/crates/ra_ide/src/call_info.rs b/crates/ra_ide/src/call_info.rs index ff602202f2..703cbc6b43 100644 --- a/crates/ra_ide/src/call_info.rs +++ b/crates/ra_ide/src/call_info.rs @@ -2,11 +2,11 @@ use either::Either; use hir::{Docs, HirDisplay, Semantics, Type}; use ra_ide_db::RootDatabase; -use ra_syntax::{ +use stdx::format_to; +use syntax::{ ast::{self, ArgListOwner}, match_ast, AstNode, SyntaxNode, SyntaxToken, TextRange, TextSize, }; -use stdx::format_to; use test_utils::mark; use crate::FilePosition; diff --git a/crates/ra_ide/src/completion/complete_attribute.rs b/crates/ra_ide/src/completion/complete_attribute.rs index 2faaae9746..603d935deb 100644 --- a/crates/ra_ide/src/completion/complete_attribute.rs +++ b/crates/ra_ide/src/completion/complete_attribute.rs @@ -3,8 +3,8 @@ //! This module uses a bit of static metadata to provide completions //! for built-in attributes. -use ra_syntax::{ast, AstNode, SyntaxKind}; use rustc_hash::FxHashSet; +use syntax::{ast, AstNode, SyntaxKind}; use crate::completion::{ completion_context::CompletionContext, diff --git a/crates/ra_ide/src/completion/complete_fn_param.rs b/crates/ra_ide/src/completion/complete_fn_param.rs index 4063342572..7c63ce58f8 100644 --- a/crates/ra_ide/src/completion/complete_fn_param.rs +++ b/crates/ra_ide/src/completion/complete_fn_param.rs @@ -1,10 +1,10 @@ //! See `complete_fn_param`. -use ra_syntax::{ +use rustc_hash::FxHashMap; +use syntax::{ ast::{self, ModuleItemOwner}, match_ast, AstNode, }; -use rustc_hash::FxHashMap; use crate::completion::{CompletionContext, CompletionItem, CompletionKind, Completions}; diff --git a/crates/ra_ide/src/completion/complete_keyword.rs b/crates/ra_ide/src/completion/complete_keyword.rs index b62064797b..a80708935e 100644 --- a/crates/ra_ide/src/completion/complete_keyword.rs +++ b/crates/ra_ide/src/completion/complete_keyword.rs @@ -1,6 +1,6 @@ //! FIXME: write short doc here -use ra_syntax::{ast, SyntaxKind}; +use syntax::{ast, SyntaxKind}; use test_utils::mark; use crate::completion::{ diff --git a/crates/ra_ide/src/completion/complete_postfix.rs b/crates/ra_ide/src/completion/complete_postfix.rs index 42087da8dc..05e15d4647 100644 --- a/crates/ra_ide/src/completion/complete_postfix.rs +++ b/crates/ra_ide/src/completion/complete_postfix.rs @@ -1,6 +1,6 @@ //! FIXME: write short doc here use ra_assists::utils::TryEnum; -use ra_syntax::{ +use syntax::{ ast::{self, AstNode}, TextRange, TextSize, }; diff --git a/crates/ra_ide/src/completion/complete_qualified_path.rs b/crates/ra_ide/src/completion/complete_qualified_path.rs index b08f5b9b45..cb7dd23c18 100644 --- a/crates/ra_ide/src/completion/complete_qualified_path.rs +++ b/crates/ra_ide/src/completion/complete_qualified_path.rs @@ -1,8 +1,8 @@ //! Completion of paths, i.e. `some::prefix::<|>`. use hir::{Adt, HasVisibility, PathResolution, ScopeDef}; -use ra_syntax::AstNode; use rustc_hash::FxHashSet; +use syntax::AstNode; use test_utils::mark; use crate::completion::{CompletionContext, Completions}; diff --git a/crates/ra_ide/src/completion/complete_trait_impl.rs b/crates/ra_ide/src/completion/complete_trait_impl.rs index b397baf107..d7edd92cf0 100644 --- a/crates/ra_ide/src/completion/complete_trait_impl.rs +++ b/crates/ra_ide/src/completion/complete_trait_impl.rs @@ -33,7 +33,7 @@ use hir::{self, Docs, HasSource}; use ra_assists::utils::get_missing_assoc_items; -use ra_syntax::{ +use syntax::{ ast::{self, edit, Impl}, AstNode, SyntaxKind, SyntaxNode, TextRange, T, }; diff --git a/crates/ra_ide/src/completion/complete_unqualified_path.rs b/crates/ra_ide/src/completion/complete_unqualified_path.rs index bd9551f358..824227f310 100644 --- a/crates/ra_ide/src/completion/complete_unqualified_path.rs +++ b/crates/ra_ide/src/completion/complete_unqualified_path.rs @@ -1,7 +1,7 @@ //! Completion of names from the current scope, e.g. locals and imported items. use hir::{Adt, ModuleDef, ScopeDef, Type}; -use ra_syntax::AstNode; +use syntax::AstNode; use test_utils::mark; use crate::completion::{CompletionContext, Completions}; diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs index 0cb57fb1b4..b5efb6cd67 100644 --- a/crates/ra_ide/src/completion/completion_context.rs +++ b/crates/ra_ide/src/completion/completion_context.rs @@ -3,7 +3,7 @@ use hir::{Semantics, SemanticsScope, Type}; use ra_db::SourceDatabase; use ra_ide_db::RootDatabase; -use ra_syntax::{ +use syntax::{ algo::{find_covering_element, find_node_at_offset}, ast, match_ast, AstNode, NodeOrToken, SyntaxKind::*, diff --git a/crates/ra_ide/src/completion/completion_item.rs b/crates/ra_ide/src/completion/completion_item.rs index 1c0684f4ed..9377cdc577 100644 --- a/crates/ra_ide/src/completion/completion_item.rs +++ b/crates/ra_ide/src/completion/completion_item.rs @@ -3,7 +3,7 @@ use std::fmt; use hir::Documentation; -use ra_syntax::TextRange; +use syntax::TextRange; use text_edit::TextEdit; use crate::completion::completion_config::SnippetCap; diff --git a/crates/ra_ide/src/completion/patterns.rs b/crates/ra_ide/src/completion/patterns.rs index 7c4feff6d1..ffc97c076a 100644 --- a/crates/ra_ide/src/completion/patterns.rs +++ b/crates/ra_ide/src/completion/patterns.rs @@ -1,6 +1,6 @@ //! Patterns telling us certain facts about current syntax element, they are used in completion context -use ra_syntax::{ +use syntax::{ algo::non_trivia_sibling, ast::{self, LoopBodyOwner}, match_ast, AstNode, Direction, NodeOrToken, SyntaxElement, diff --git a/crates/ra_ide/src/completion/presentation.rs b/crates/ra_ide/src/completion/presentation.rs index 59f1b14246..e1b1ea4ce4 100644 --- a/crates/ra_ide/src/completion/presentation.rs +++ b/crates/ra_ide/src/completion/presentation.rs @@ -3,7 +3,7 @@ use hir::{Docs, HasAttrs, HasSource, HirDisplay, ModPath, ScopeDef, StructKind, Type}; use itertools::Itertools; -use ra_syntax::ast::NameOwner; +use syntax::ast::NameOwner; use test_utils::mark; use crate::{ diff --git a/crates/ra_ide/src/completion/test_utils.rs b/crates/ra_ide/src/completion/test_utils.rs index 9191777455..1452d7e9e5 100644 --- a/crates/ra_ide/src/completion/test_utils.rs +++ b/crates/ra_ide/src/completion/test_utils.rs @@ -2,8 +2,8 @@ use hir::Semantics; use itertools::Itertools; -use ra_syntax::{AstNode, NodeOrToken, SyntaxElement}; use stdx::{format_to, trim_indent}; +use syntax::{AstNode, NodeOrToken, SyntaxElement}; use test_utils::assert_eq_text; use crate::{ diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs index 54810d5bbf..18def6115d 100644 --- a/crates/ra_ide/src/diagnostics.rs +++ b/crates/ra_ide/src/diagnostics.rs @@ -10,7 +10,7 @@ use hir::{diagnostics::DiagnosticSinkBuilder, Semantics}; use itertools::Itertools; use ra_db::SourceDatabase; use ra_ide_db::RootDatabase; -use ra_syntax::{ +use syntax::{ ast::{self, AstNode}, SyntaxNode, TextRange, T, }; diff --git a/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs b/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs index 8fb25de6c1..efcd631b31 100644 --- a/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs +++ b/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs @@ -12,7 +12,7 @@ use ra_ide_db::{ source_change::{FileSystemEdit, SourceFileEdit}, RootDatabase, }; -use ra_syntax::{algo, ast, AstNode}; +use syntax::{algo, ast, AstNode}; use text_edit::TextEdit; /// A [Diagnostic] that potentially has a fix available. diff --git a/crates/ra_ide/src/display.rs b/crates/ra_ide/src/display.rs index fd42aa4352..41b5bdc490 100644 --- a/crates/ra_ide/src/display.rs +++ b/crates/ra_ide/src/display.rs @@ -4,7 +4,7 @@ mod navigation_target; mod short_label; -use ra_syntax::{ +use syntax::{ ast::{self, AstNode, AttrsOwner, GenericParamsOwner, NameOwner}, SyntaxKind::{ATTR, COMMENT}, }; diff --git a/crates/ra_ide/src/display/navigation_target.rs b/crates/ra_ide/src/display/navigation_target.rs index fdbf75abd9..683088a748 100644 --- a/crates/ra_ide/src/display/navigation_target.rs +++ b/crates/ra_ide/src/display/navigation_target.rs @@ -4,7 +4,7 @@ use either::Either; use hir::{original_range, AssocItem, FieldSource, HasSource, InFile, ModuleSource}; use ra_db::{FileId, SourceDatabase}; use ra_ide_db::{defs::Definition, RootDatabase}; -use ra_syntax::{ +use syntax::{ ast::{self, DocCommentsOwner, NameOwner}, match_ast, AstNode, SmolStr, SyntaxKind::{self, IDENT_PAT, TYPE_PARAM}, diff --git a/crates/ra_ide/src/display/short_label.rs b/crates/ra_ide/src/display/short_label.rs index 010c34705c..ea49d9f970 100644 --- a/crates/ra_ide/src/display/short_label.rs +++ b/crates/ra_ide/src/display/short_label.rs @@ -1,7 +1,7 @@ //! FIXME: write short doc here -use ra_syntax::ast::{self, AstNode, NameOwner, VisibilityOwner}; use stdx::format_to; +use syntax::ast::{self, AstNode, NameOwner, VisibilityOwner}; pub(crate) trait ShortLabel { fn short_label(&self) -> Option; diff --git a/crates/ra_ide/src/expand_macro.rs b/crates/ra_ide/src/expand_macro.rs index 043515f541..c25e068d60 100644 --- a/crates/ra_ide/src/expand_macro.rs +++ b/crates/ra_ide/src/expand_macro.rs @@ -1,6 +1,6 @@ use hir::Semantics; use ra_ide_db::RootDatabase; -use ra_syntax::{ +use syntax::{ algo::{find_node_at_offset, SyntaxRewriter}, ast, AstNode, NodeOrToken, SyntaxKind, SyntaxKind::*, diff --git a/crates/ra_ide/src/extend_selection.rs b/crates/ra_ide/src/extend_selection.rs index 7230a0ff9e..f30df2bff4 100644 --- a/crates/ra_ide/src/extend_selection.rs +++ b/crates/ra_ide/src/extend_selection.rs @@ -2,7 +2,7 @@ use std::iter::successors; use hir::Semantics; use ra_ide_db::RootDatabase; -use ra_syntax::{ +use syntax::{ algo::{self, find_covering_element, skip_trivia_token}, ast::{self, AstNode, AstToken}, Direction, NodeOrToken, diff --git a/crates/ra_ide/src/file_structure.rs b/crates/ra_ide/src/file_structure.rs index 87cab45037..c90247ba65 100644 --- a/crates/ra_ide/src/file_structure.rs +++ b/crates/ra_ide/src/file_structure.rs @@ -1,4 +1,4 @@ -use ra_syntax::{ +use syntax::{ ast::{self, AttrsOwner, GenericParamsOwner, NameOwner}, match_ast, AstNode, SourceFile, SyntaxKind, SyntaxNode, TextRange, WalkEvent, }; diff --git a/crates/ra_ide/src/folding_ranges.rs b/crates/ra_ide/src/folding_ranges.rs index 0fbc9babd5..7523aec557 100644 --- a/crates/ra_ide/src/folding_ranges.rs +++ b/crates/ra_ide/src/folding_ranges.rs @@ -2,7 +2,7 @@ use rustc_hash::FxHashSet; -use ra_syntax::{ +use syntax::{ ast::{self, AstNode, AstToken, VisibilityOwner}, Direction, NodeOrToken, SourceFile, SyntaxKind::{self, *}, diff --git a/crates/ra_ide/src/goto_definition.rs b/crates/ra_ide/src/goto_definition.rs index 45389fd23f..77f374ea2a 100644 --- a/crates/ra_ide/src/goto_definition.rs +++ b/crates/ra_ide/src/goto_definition.rs @@ -3,7 +3,7 @@ use ra_ide_db::{ defs::{classify_name, classify_name_ref}, symbol_index, RootDatabase, }; -use ra_syntax::{ +use syntax::{ ast::{self}, match_ast, AstNode, SyntaxKind::*, @@ -101,7 +101,7 @@ pub(crate) fn reference_definition( #[cfg(test)] mod tests { use ra_db::FileRange; - use ra_syntax::{TextRange, TextSize}; + use syntax::{TextRange, TextSize}; use crate::mock_analysis::MockAnalysis; diff --git a/crates/ra_ide/src/goto_implementation.rs b/crates/ra_ide/src/goto_implementation.rs index 9912b71421..91a8c1dd17 100644 --- a/crates/ra_ide/src/goto_implementation.rs +++ b/crates/ra_ide/src/goto_implementation.rs @@ -1,6 +1,6 @@ use hir::{Crate, ImplDef, Semantics}; use ra_ide_db::RootDatabase; -use ra_syntax::{algo::find_node_at_offset, ast, AstNode}; +use syntax::{algo::find_node_at_offset, ast, AstNode}; use crate::{display::ToNav, FilePosition, NavigationTarget, RangeInfo}; diff --git a/crates/ra_ide/src/goto_type_definition.rs b/crates/ra_ide/src/goto_type_definition.rs index 8f52feea6e..3ec2ee59de 100644 --- a/crates/ra_ide/src/goto_type_definition.rs +++ b/crates/ra_ide/src/goto_type_definition.rs @@ -1,5 +1,5 @@ use ra_ide_db::RootDatabase; -use ra_syntax::{ast, match_ast, AstNode, SyntaxKind::*, SyntaxToken, TokenAtOffset, T}; +use syntax::{ast, match_ast, AstNode, SyntaxKind::*, SyntaxToken, TokenAtOffset, T}; use crate::{display::ToNav, FilePosition, NavigationTarget, RangeInfo}; diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs index f66f62bfb5..37e68ff7a5 100644 --- a/crates/ra_ide/src/hover.rs +++ b/crates/ra_ide/src/hover.rs @@ -8,8 +8,8 @@ use ra_ide_db::{ defs::{classify_name, classify_name_ref, Definition}, RootDatabase, }; -use ra_syntax::{ast, match_ast, AstNode, SyntaxKind::*, SyntaxToken, TokenAtOffset, T}; use stdx::format_to; +use syntax::{ast, match_ast, AstNode, SyntaxKind::*, SyntaxToken, TokenAtOffset, T}; use test_utils::mark; use crate::{ diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs index 920b04e8d7..46ddc528e5 100644 --- a/crates/ra_ide/src/inlay_hints.rs +++ b/crates/ra_ide/src/inlay_hints.rs @@ -1,10 +1,10 @@ use hir::{Adt, Callable, HirDisplay, Semantics, Type}; use ra_ide_db::RootDatabase; -use ra_syntax::{ +use stdx::to_lower_snake_case; +use syntax::{ ast::{self, ArgListOwner, AstNode}, match_ast, Direction, NodeOrToken, SmolStr, SyntaxKind, TextRange, T, }; -use stdx::to_lower_snake_case; use crate::FileId; use ast::NameOwner; diff --git a/crates/ra_ide/src/join_lines.rs b/crates/ra_ide/src/join_lines.rs index caf63933a9..35cec87f67 100644 --- a/crates/ra_ide/src/join_lines.rs +++ b/crates/ra_ide/src/join_lines.rs @@ -1,6 +1,6 @@ use itertools::Itertools; use ra_fmt::{compute_ws, extract_trivial_expression}; -use ra_syntax::{ +use syntax::{ algo::{find_covering_element, non_trivia_sibling}, ast::{self, AstNode, AstToken}, Direction, NodeOrToken, SourceFile, @@ -170,7 +170,7 @@ fn is_trailing_comma(left: SyntaxKind, right: SyntaxKind) -> bool { #[cfg(test)] mod tests { - use ra_syntax::SourceFile; + use syntax::SourceFile; use test_utils::{add_cursor, assert_eq_text, extract_offset, extract_range}; use super::*; @@ -437,11 +437,11 @@ fn foo() { // No space after the '{' check_join_lines( r" -<|>use ra_syntax::{ +<|>use syntax::{ TextSize, TextRange, };", r" -<|>use ra_syntax::{TextSize, TextRange, +<|>use syntax::{TextSize, TextRange, };", ); } @@ -451,11 +451,11 @@ fn foo() { // No space after the '}' check_join_lines( r" -use ra_syntax::{ +use syntax::{ <|> TextSize, TextRange };", r" -use ra_syntax::{ +use syntax::{ <|> TextSize, TextRange};", ); } @@ -465,11 +465,11 @@ use ra_syntax::{ // No space after the '}' check_join_lines( r" -use ra_syntax::{ +use syntax::{ <|> TextSize, TextRange, };", r" -use ra_syntax::{ +use syntax::{ <|> TextSize, TextRange};", ); } @@ -478,14 +478,14 @@ use ra_syntax::{ fn test_join_lines_use_tree() { check_join_lines( r" -use ra_syntax::{ +use syntax::{ algo::<|>{ find_token_at_offset, }, ast, };", r" -use ra_syntax::{ +use syntax::{ algo::<|>find_token_at_offset, ast, };", diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs index 09cb5faf68..20967ba990 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ra_ide/src/lib.rs @@ -56,7 +56,7 @@ use ra_ide_db::{ symbol_index::{self, FileSymbol}, LineIndexDatabase, }; -use ra_syntax::{SourceFile, TextRange, TextSize}; +use syntax::{SourceFile, TextRange, TextSize}; use crate::display::ToNav; diff --git a/crates/ra_ide/src/matching_brace.rs b/crates/ra_ide/src/matching_brace.rs index 742d70c9c0..cb6abb0db9 100644 --- a/crates/ra_ide/src/matching_brace.rs +++ b/crates/ra_ide/src/matching_brace.rs @@ -1,4 +1,4 @@ -use ra_syntax::{ +use syntax::{ ast::{self, AstNode}, SourceFile, SyntaxKind, TextSize, T, }; diff --git a/crates/ra_ide/src/parent_module.rs b/crates/ra_ide/src/parent_module.rs index e3e0c76392..69af0c86ad 100644 --- a/crates/ra_ide/src/parent_module.rs +++ b/crates/ra_ide/src/parent_module.rs @@ -1,7 +1,7 @@ use hir::Semantics; use ra_db::{CrateId, FileId, FilePosition}; use ra_ide_db::RootDatabase; -use ra_syntax::{ +use syntax::{ algo::find_node_at_offset, ast::{self, AstNode}, }; diff --git a/crates/ra_ide/src/references.rs b/crates/ra_ide/src/references.rs index c4eea3a45b..e89dca869c 100644 --- a/crates/ra_ide/src/references.rs +++ b/crates/ra_ide/src/references.rs @@ -17,7 +17,7 @@ use ra_ide_db::{ search::SearchScope, RootDatabase, }; -use ra_syntax::{ +use syntax::{ algo::find_node_at_offset, ast::{self, NameOwner}, AstNode, SyntaxKind, SyntaxNode, TextRange, TokenAtOffset, diff --git a/crates/ra_ide/src/references/rename.rs b/crates/ra_ide/src/references/rename.rs index 9c688fb063..a075618e74 100644 --- a/crates/ra_ide/src/references/rename.rs +++ b/crates/ra_ide/src/references/rename.rs @@ -6,12 +6,12 @@ use ra_ide_db::{ defs::{classify_name, classify_name_ref, Definition, NameClass, NameRefClass}, RootDatabase, }; -use ra_syntax::{ +use std::convert::TryInto; +use syntax::{ algo::find_node_at_offset, ast::{self, NameOwner}, lex_single_valid_syntax_kind, match_ast, AstNode, SyntaxKind, SyntaxNode, SyntaxToken, }; -use std::convert::TryInto; use test_utils::mark; use text_edit::TextEdit; diff --git a/crates/ra_ide/src/runnables.rs b/crates/ra_ide/src/runnables.rs index 3b7162b841..54cb3b3094 100644 --- a/crates/ra_ide/src/runnables.rs +++ b/crates/ra_ide/src/runnables.rs @@ -4,7 +4,7 @@ use hir::{AsAssocItem, Attrs, HirFileId, InFile, Semantics}; use itertools::Itertools; use ra_cfg::CfgExpr; use ra_ide_db::RootDatabase; -use ra_syntax::{ +use syntax::{ ast::{self, AstNode, AttrsOwner, DocCommentsOwner, ModuleItemOwner, NameOwner}, match_ast, SyntaxNode, }; diff --git a/crates/ra_ide/src/status.rs b/crates/ra_ide/src/status.rs index 009bb662f7..797ead1ada 100644 --- a/crates/ra_ide/src/status.rs +++ b/crates/ra_ide/src/status.rs @@ -10,8 +10,8 @@ use ra_ide_db::{ symbol_index::{LibrarySymbolsQuery, SymbolIndex}, RootDatabase, }; -use ra_syntax::{ast, Parse, SyntaxNode}; use rustc_hash::FxHashMap; +use syntax::{ast, Parse, SyntaxNode}; use crate::FileId; diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index ebdf05127a..4b41ceb1dc 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -9,13 +9,13 @@ use ra_ide_db::{ defs::{classify_name, classify_name_ref, Definition, NameClass, NameRefClass}, RootDatabase, }; -use ra_syntax::{ +use rustc_hash::FxHashMap; +use syntax::{ ast::{self, HasFormatSpecifier}, AstNode, AstToken, Direction, NodeOrToken, SyntaxElement, SyntaxKind::*, TextRange, WalkEvent, T, }; -use rustc_hash::FxHashMap; use crate::FileId; diff --git a/crates/ra_ide/src/syntax_highlighting/html.rs b/crates/ra_ide/src/syntax_highlighting/html.rs index a5e7d28676..418122648a 100644 --- a/crates/ra_ide/src/syntax_highlighting/html.rs +++ b/crates/ra_ide/src/syntax_highlighting/html.rs @@ -2,7 +2,7 @@ use oorandom::Rand32; use ra_db::SourceDatabase; -use ra_syntax::{AstNode, TextRange, TextSize}; +use syntax::{AstNode, TextRange, TextSize}; use crate::{syntax_highlighting::highlight, FileId, RootDatabase}; diff --git a/crates/ra_ide/src/syntax_highlighting/injection.rs b/crates/ra_ide/src/syntax_highlighting/injection.rs index 6046643ef1..43f4e6feab 100644 --- a/crates/ra_ide/src/syntax_highlighting/injection.rs +++ b/crates/ra_ide/src/syntax_highlighting/injection.rs @@ -5,7 +5,7 @@ use std::{collections::BTreeMap, convert::TryFrom}; use ast::{HasQuotes, HasStringValue}; use hir::Semantics; use itertools::Itertools; -use ra_syntax::{ast, AstToken, SyntaxNode, SyntaxToken, TextRange, TextSize}; +use syntax::{ast, AstToken, SyntaxNode, SyntaxToken, TextRange, TextSize}; use crate::{ call_info::ActiveParameter, Analysis, Highlight, HighlightModifier, HighlightTag, diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ra_ide/src/syntax_highlighting/tests.rs index a8087635a8..594f61e85b 100644 --- a/crates/ra_ide/src/syntax_highlighting/tests.rs +++ b/crates/ra_ide/src/syntax_highlighting/tests.rs @@ -135,7 +135,7 @@ fn bar() { #[test] fn accidentally_quadratic() { - let file = project_dir().join("crates/ra_syntax/test_data/accidentally_quadratic"); + let file = project_dir().join("crates/syntax/test_data/accidentally_quadratic"); let src = fs::read_to_string(file).unwrap(); let (analysis, file_id) = single_file(&src); diff --git a/crates/ra_ide/src/syntax_tree.rs b/crates/ra_ide/src/syntax_tree.rs index 07217e8087..d05ff22149 100644 --- a/crates/ra_ide/src/syntax_tree.rs +++ b/crates/ra_ide/src/syntax_tree.rs @@ -1,6 +1,6 @@ use ra_db::{FileId, SourceDatabase}; use ra_ide_db::RootDatabase; -use ra_syntax::{ +use syntax::{ algo, AstNode, NodeOrToken, SourceFile, SyntaxKind::{RAW_STRING, STRING}, SyntaxToken, TextRange, TextSize, diff --git a/crates/ra_ide/src/typing.rs b/crates/ra_ide/src/typing.rs index 952429cde6..c408b1d521 100644 --- a/crates/ra_ide/src/typing.rs +++ b/crates/ra_ide/src/typing.rs @@ -18,7 +18,7 @@ mod on_enter; use ra_db::{FilePosition, SourceDatabase}; use ra_fmt::leading_indent; use ra_ide_db::{source_change::SourceFileEdit, RootDatabase}; -use ra_syntax::{ +use syntax::{ algo::find_node_at_offset, ast::{self, AstToken}, AstNode, SourceFile, diff --git a/crates/ra_ide/src/typing/on_enter.rs b/crates/ra_ide/src/typing/on_enter.rs index c0c5ce3bcd..9cd153f94a 100644 --- a/crates/ra_ide/src/typing/on_enter.rs +++ b/crates/ra_ide/src/typing/on_enter.rs @@ -3,7 +3,7 @@ use ra_db::{FilePosition, SourceDatabase}; use ra_ide_db::RootDatabase; -use ra_syntax::{ +use syntax::{ ast::{self, AstToken}, AstNode, SmolStr, SourceFile, SyntaxKind::*, diff --git a/crates/ra_ide_db/Cargo.toml b/crates/ra_ide_db/Cargo.toml index 5446a59614..9ed13a13db 100644 --- a/crates/ra_ide_db/Cargo.toml +++ b/crates/ra_ide_db/Cargo.toml @@ -21,7 +21,7 @@ either = "1.5.3" stdx = { path = "../stdx" } -ra_syntax = { path = "../ra_syntax" } +syntax = { path = "../syntax" } text_edit = { path = "../text_edit" } ra_db = { path = "../ra_db" } profile = { path = "../profile" } diff --git a/crates/ra_ide_db/src/defs.rs b/crates/ra_ide_db/src/defs.rs index d46d1fe71b..7b5d6ac491 100644 --- a/crates/ra_ide_db/src/defs.rs +++ b/crates/ra_ide_db/src/defs.rs @@ -9,7 +9,7 @@ use hir::{ db::HirDatabase, Crate, Field, HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef, Name, PathResolution, Semantics, TypeParam, Visibility, }; -use ra_syntax::{ +use syntax::{ ast::{self, AstNode}, match_ast, SyntaxNode, }; diff --git a/crates/ra_ide_db/src/imports_locator.rs b/crates/ra_ide_db/src/imports_locator.rs index d510ce3b76..1d0c202915 100644 --- a/crates/ra_ide_db/src/imports_locator.rs +++ b/crates/ra_ide_db/src/imports_locator.rs @@ -2,7 +2,7 @@ //! Later, this should be moved away to a separate crate that is accessible from the ra_assists module. use hir::{Crate, MacroDef, ModuleDef, Semantics}; -use ra_syntax::{ast, AstNode, SyntaxKind::NAME}; +use syntax::{ast, AstNode, SyntaxKind::NAME}; use crate::{ defs::{classify_name, Definition}, diff --git a/crates/ra_ide_db/src/line_index.rs b/crates/ra_ide_db/src/line_index.rs index 2ab662098a..a381f7fb8d 100644 --- a/crates/ra_ide_db/src/line_index.rs +++ b/crates/ra_ide_db/src/line_index.rs @@ -2,9 +2,9 @@ //! representation. use std::iter; -use ra_syntax::{TextRange, TextSize}; use rustc_hash::FxHashMap; use stdx::partition_point; +use syntax::{TextRange, TextSize}; #[derive(Clone, Debug, PartialEq, Eq)] pub struct LineIndex { diff --git a/crates/ra_ide_db/src/search.rs b/crates/ra_ide_db/src/search.rs index d90b830d0c..7827cc71cf 100644 --- a/crates/ra_ide_db/src/search.rs +++ b/crates/ra_ide_db/src/search.rs @@ -9,8 +9,8 @@ use std::{convert::TryInto, mem}; use hir::{DefWithBody, HasSource, Module, ModuleSource, Semantics, Visibility}; use once_cell::unsync::Lazy; use ra_db::{FileId, FileRange, SourceDatabaseExt}; -use ra_syntax::{ast, match_ast, AstNode, TextRange, TextSize}; use rustc_hash::FxHashMap; +use syntax::{ast, match_ast, AstNode, TextRange, TextSize}; use crate::{ defs::{classify_name_ref, Definition, NameRefClass}, diff --git a/crates/ra_ide_db/src/symbol_index.rs b/crates/ra_ide_db/src/symbol_index.rs index 6ca8bb5169..896092b467 100644 --- a/crates/ra_ide_db/src/symbol_index.rs +++ b/crates/ra_ide_db/src/symbol_index.rs @@ -34,14 +34,14 @@ use ra_db::{ salsa::{self, ParallelDatabase}, CrateId, FileId, SourceDatabaseExt, SourceRootId, }; -use ra_syntax::{ +use rayon::prelude::*; +use rustc_hash::{FxHashMap, FxHashSet}; +use syntax::{ ast::{self, NameOwner}, match_ast, AstNode, Parse, SmolStr, SourceFile, SyntaxKind::{self, *}, SyntaxNode, SyntaxNodePtr, TextRange, WalkEvent, }; -use rayon::prelude::*; -use rustc_hash::{FxHashMap, FxHashSet}; use crate::RootDatabase; diff --git a/crates/ra_mbe/Cargo.toml b/crates/ra_mbe/Cargo.toml index e518f73e32..4a4be65ebc 100644 --- a/crates/ra_mbe/Cargo.toml +++ b/crates/ra_mbe/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT OR Apache-2.0" doctest = false [dependencies] -ra_syntax = { path = "../ra_syntax" } +syntax = { path = "../syntax" } parser = { path = "../parser" } tt = { path = "../tt" } rustc-hash = "1.1.0" diff --git a/crates/ra_mbe/src/mbe_expander.rs b/crates/ra_mbe/src/mbe_expander.rs index b1eacf1242..1ad8b9f8a5 100644 --- a/crates/ra_mbe/src/mbe_expander.rs +++ b/crates/ra_mbe/src/mbe_expander.rs @@ -5,8 +5,8 @@ mod matcher; mod transcriber; -use ra_syntax::SmolStr; use rustc_hash::FxHashMap; +use syntax::SmolStr; use crate::{ExpandError, ExpandResult}; @@ -123,7 +123,7 @@ enum Fragment { #[cfg(test)] mod tests { - use ra_syntax::{ast, AstNode}; + use syntax::{ast, AstNode}; use super::*; use crate::ast_to_token_tree; diff --git a/crates/ra_mbe/src/mbe_expander/matcher.rs b/crates/ra_mbe/src/mbe_expander/matcher.rs index c752804b29..b698b98326 100644 --- a/crates/ra_mbe/src/mbe_expander/matcher.rs +++ b/crates/ra_mbe/src/mbe_expander/matcher.rs @@ -10,7 +10,7 @@ use crate::{ use super::ExpandResult; use parser::{FragmentKind::*, TreeSink}; -use ra_syntax::{SmolStr, SyntaxKind}; +use syntax::{SmolStr, SyntaxKind}; use tt::buffer::{Cursor, TokenBuffer}; impl Bindings { diff --git a/crates/ra_mbe/src/mbe_expander/transcriber.rs b/crates/ra_mbe/src/mbe_expander/transcriber.rs index 7c9bb4d00e..c9525c5bf2 100644 --- a/crates/ra_mbe/src/mbe_expander/transcriber.rs +++ b/crates/ra_mbe/src/mbe_expander/transcriber.rs @@ -1,7 +1,7 @@ //! Transcriber takes a template, like `fn $ident() {}`, a set of bindings like //! `$ident => foo`, interpolates variables in the template, to get `fn foo() {}` -use ra_syntax::SmolStr; +use syntax::SmolStr; use super::ExpandResult; use crate::{ diff --git a/crates/ra_mbe/src/parser.rs b/crates/ra_mbe/src/parser.rs index 1e5dafbdf9..6b46a1673c 100644 --- a/crates/ra_mbe/src/parser.rs +++ b/crates/ra_mbe/src/parser.rs @@ -1,8 +1,8 @@ //! Parser recognizes special macro syntax, `$var` and `$(repeat)*`, in token //! trees. -use ra_syntax::SmolStr; use smallvec::SmallVec; +use syntax::SmolStr; use crate::{tt_iter::TtIter, ExpandError}; diff --git a/crates/ra_mbe/src/subtree_source.rs b/crates/ra_mbe/src/subtree_source.rs index 1a1cb08cf7..41461b3150 100644 --- a/crates/ra_mbe/src/subtree_source.rs +++ b/crates/ra_mbe/src/subtree_source.rs @@ -1,8 +1,8 @@ //! FIXME: write short doc here use parser::{Token, TokenSource}; -use ra_syntax::{lex_single_syntax_kind, SmolStr, SyntaxKind, SyntaxKind::*, T}; use std::cell::{Cell, Ref, RefCell}; +use syntax::{lex_single_syntax_kind, SmolStr, SyntaxKind, SyntaxKind::*, T}; use tt::buffer::{Cursor, TokenBuffer}; #[derive(Debug, Clone, Eq, PartialEq)] diff --git a/crates/ra_mbe/src/syntax_bridge.rs b/crates/ra_mbe/src/syntax_bridge.rs index 7b9c88ae64..a8ad917fb8 100644 --- a/crates/ra_mbe/src/syntax_bridge.rs +++ b/crates/ra_mbe/src/syntax_bridge.rs @@ -1,13 +1,13 @@ //! FIXME: write short doc here use parser::{FragmentKind, ParseError, TreeSink}; -use ra_syntax::{ +use rustc_hash::FxHashMap; +use syntax::{ ast::{self, make::tokens::doc_comment}, tokenize, AstToken, Parse, SmolStr, SyntaxKind, SyntaxKind::*, SyntaxNode, SyntaxToken, SyntaxTreeBuilder, TextRange, TextSize, Token as RawToken, T, }; -use rustc_hash::FxHashMap; use tt::buffer::{Cursor, TokenBuffer}; use crate::subtree_source::SubtreeTokenSource; @@ -176,7 +176,7 @@ fn doc_comment_text(comment: &ast::Comment) -> SmolStr { text.into() } -fn convert_doc_comment(token: &ra_syntax::SyntaxToken) -> Option> { +fn convert_doc_comment(token: &syntax::SyntaxToken) -> Option> { let comment = ast::Comment::cast(token.clone())?; let doc = comment.kind().doc?; @@ -716,7 +716,7 @@ mod tests { use super::*; use crate::tests::parse_macro; use parser::TokenSource; - use ra_syntax::{ + use syntax::{ algo::{insert_children, InsertPosition}, ast::AstNode, }; diff --git a/crates/ra_mbe/src/tests.rs b/crates/ra_mbe/src/tests.rs index be39b0e45e..0796ceee1a 100644 --- a/crates/ra_mbe/src/tests.rs +++ b/crates/ra_mbe/src/tests.rs @@ -1,13 +1,13 @@ use std::fmt::Write; use ::parser::FragmentKind; -use ra_syntax::{ast, AstNode, NodeOrToken, SyntaxKind::IDENT, SyntaxNode, WalkEvent, T}; +use syntax::{ast, AstNode, NodeOrToken, SyntaxKind::IDENT, SyntaxNode, WalkEvent, T}; use test_utils::assert_eq_text; use super::*; mod rule_parsing { - use ra_syntax::{ast, AstNode}; + use syntax::{ast, AstNode}; use crate::ast_to_token_tree; @@ -1698,7 +1698,7 @@ pub(crate) fn parse_to_token_tree_by_syntax(ra_fixture: &str) -> tt::Subtree { parsed } -fn debug_dump_ignore_spaces(node: &ra_syntax::SyntaxNode) -> String { +fn debug_dump_ignore_spaces(node: &syntax::SyntaxNode) -> String { let mut level = 0; let mut buf = String::new(); macro_rules! indent { @@ -1718,7 +1718,7 @@ fn debug_dump_ignore_spaces(node: &ra_syntax::SyntaxNode) -> String { writeln!(buf, "{:?}", node.kind()).unwrap(); } NodeOrToken::Token(token) => match token.kind() { - ra_syntax::SyntaxKind::WHITESPACE => {} + syntax::SyntaxKind::WHITESPACE => {} _ => { indent!(); writeln!(buf, "{:?}", token.kind()).unwrap(); diff --git a/crates/ra_ssr/Cargo.toml b/crates/ra_ssr/Cargo.toml index d0f2ae7339..958baa2df7 100644 --- a/crates/ra_ssr/Cargo.toml +++ b/crates/ra_ssr/Cargo.toml @@ -12,7 +12,7 @@ doctest = false [dependencies] text_edit = { path = "../text_edit" } -ra_syntax = { path = "../ra_syntax" } +syntax = { path = "../syntax" } ra_db = { path = "../ra_db" } ra_ide_db = { path = "../ra_ide_db" } hir = { path = "../ra_hir", package = "ra_hir" } diff --git a/crates/ra_ssr/src/lib.rs b/crates/ra_ssr/src/lib.rs index c780b460a7..fb53212a3a 100644 --- a/crates/ra_ssr/src/lib.rs +++ b/crates/ra_ssr/src/lib.rs @@ -21,9 +21,9 @@ use crate::matching::MatchFailureReason; use hir::Semantics; use ra_db::{FileId, FilePosition, FileRange}; use ra_ide_db::source_change::SourceFileEdit; -use ra_syntax::{ast, AstNode, SyntaxNode, TextRange}; use resolving::ResolvedRule; use rustc_hash::FxHashMap; +use syntax::{ast, AstNode, SyntaxNode, TextRange}; // A structured search replace rule. Create by calling `parse` on a str. #[derive(Debug)] diff --git a/crates/ra_ssr/src/matching.rs b/crates/ra_ssr/src/matching.rs index 0f72fea691..125bf38951 100644 --- a/crates/ra_ssr/src/matching.rs +++ b/crates/ra_ssr/src/matching.rs @@ -8,10 +8,10 @@ use crate::{ }; use hir::Semantics; use ra_db::FileRange; -use ra_syntax::ast::{AstNode, AstToken}; -use ra_syntax::{ast, SyntaxElement, SyntaxElementChildren, SyntaxKind, SyntaxNode, SyntaxToken}; use rustc_hash::FxHashMap; use std::{cell::Cell, iter::Peekable}; +use syntax::ast::{AstNode, AstToken}; +use syntax::{ast, SyntaxElement, SyntaxElementChildren, SyntaxKind, SyntaxNode, SyntaxToken}; use test_utils::mark; // Creates a match error. If we're currently attempting to match some code that we thought we were @@ -264,7 +264,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> { &self, phase: &mut Phase, pattern: &mut Peekable, - code: &ra_syntax::SyntaxToken, + code: &syntax::SyntaxToken, ) -> Result<(), MatchFailed> { phase.record_ignored_comments(code); // Ignore whitespace and comments. @@ -444,7 +444,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> { &self, phase: &mut Phase, pattern: &SyntaxNode, - code: &ra_syntax::SyntaxNode, + code: &syntax::SyntaxNode, ) -> Result<(), MatchFailed> { let mut pattern = PatternIterator::new(pattern).peekable(); let mut children = code.children_with_tokens(); diff --git a/crates/ra_ssr/src/nester.rs b/crates/ra_ssr/src/nester.rs index b3e20579bd..8be570d3cf 100644 --- a/crates/ra_ssr/src/nester.rs +++ b/crates/ra_ssr/src/nester.rs @@ -8,8 +8,8 @@ //! middle match would take the second `foo` from the outer match. use crate::{Match, SsrMatches}; -use ra_syntax::SyntaxNode; use rustc_hash::FxHashMap; +use syntax::SyntaxNode; pub(crate) fn nest_and_remove_collisions( mut matches: Vec, diff --git a/crates/ra_ssr/src/parsing.rs b/crates/ra_ssr/src/parsing.rs index f455eb5b7e..9570e96e36 100644 --- a/crates/ra_ssr/src/parsing.rs +++ b/crates/ra_ssr/src/parsing.rs @@ -7,9 +7,9 @@ use crate::errors::bail; use crate::{SsrError, SsrPattern, SsrRule}; -use ra_syntax::{ast, AstNode, SmolStr, SyntaxKind, SyntaxNode, T}; use rustc_hash::{FxHashMap, FxHashSet}; use std::str::FromStr; +use syntax::{ast, AstNode, SmolStr, SyntaxKind, SyntaxNode, T}; use test_utils::mark; #[derive(Debug)] @@ -243,7 +243,7 @@ fn validate_rule(rule: &SsrRule) -> Result<(), SsrError> { fn tokenize(source: &str) -> Result, SsrError> { let mut start = 0; - let (raw_tokens, errors) = ra_syntax::tokenize(source); + let (raw_tokens, errors) = syntax::tokenize(source); if let Some(first_error) = errors.first() { bail!("Failed to parse pattern: {}", first_error); } diff --git a/crates/ra_ssr/src/replacing.rs b/crates/ra_ssr/src/replacing.rs index 74f9e7db61..8f8fe6149a 100644 --- a/crates/ra_ssr/src/replacing.rs +++ b/crates/ra_ssr/src/replacing.rs @@ -2,9 +2,9 @@ use crate::matching::Var; use crate::{resolving::ResolvedRule, Match, SsrMatches}; -use ra_syntax::ast::{self, AstToken}; -use ra_syntax::{SyntaxElement, SyntaxKind, SyntaxNode, SyntaxToken, TextRange, TextSize}; use rustc_hash::{FxHashMap, FxHashSet}; +use syntax::ast::{self, AstToken}; +use syntax::{SyntaxElement, SyntaxKind, SyntaxNode, SyntaxToken, TextRange, TextSize}; use text_edit::TextEdit; /// Returns a text edit that will replace each match in `matches` with its corresponding replacement @@ -92,7 +92,7 @@ impl ReplacementRenderer<'_> { } fn render_node(&mut self, node: &SyntaxNode) { - use ra_syntax::ast::AstNode; + use syntax::ast::AstNode; if let Some(mod_path) = self.match_info.rendered_template_paths.get(&node) { self.out.push_str(&mod_path.to_string()); // Emit everything except for the segment's name-ref, since we already effectively @@ -180,7 +180,7 @@ impl ReplacementRenderer<'_> { } fn parse_as_kind(code: &str, kind: SyntaxKind) -> Option { - use ra_syntax::ast::AstNode; + use syntax::ast::AstNode; if ast::Expr::can_cast(kind) { if let Ok(expr) = ast::Expr::parse(code) { return Some(expr.syntax().clone()); diff --git a/crates/ra_ssr/src/resolving.rs b/crates/ra_ssr/src/resolving.rs index d53bd46c77..7e7585c8bb 100644 --- a/crates/ra_ssr/src/resolving.rs +++ b/crates/ra_ssr/src/resolving.rs @@ -4,8 +4,8 @@ use crate::errors::error; use crate::{parsing, SsrError}; use parsing::Placeholder; use ra_db::FilePosition; -use ra_syntax::{ast, SmolStr, SyntaxKind, SyntaxNode, SyntaxToken}; use rustc_hash::FxHashMap; +use syntax::{ast, SmolStr, SyntaxKind, SyntaxNode, SyntaxToken}; use test_utils::mark; pub(crate) struct ResolutionScope<'db> { @@ -70,7 +70,7 @@ struct Resolver<'a, 'db> { impl Resolver<'_, '_> { fn resolve_pattern_tree(&self, pattern: SyntaxNode) -> Result { - use ra_syntax::{SyntaxElement, T}; + use syntax::{SyntaxElement, T}; let mut resolved_paths = FxHashMap::default(); self.resolve(pattern.clone(), 0, &mut resolved_paths)?; let ufcs_function_calls = resolved_paths @@ -108,7 +108,7 @@ impl Resolver<'_, '_> { depth: u32, resolved_paths: &mut FxHashMap, ) -> Result<(), SsrError> { - use ra_syntax::ast::AstNode; + use syntax::ast::AstNode; if let Some(path) = ast::Path::cast(node.clone()) { if is_self(&path) { // Self cannot be resolved like other paths. @@ -179,7 +179,7 @@ impl<'db> ResolutionScope<'db> { sema: &hir::Semantics<'db, ra_ide_db::RootDatabase>, resolve_context: FilePosition, ) -> ResolutionScope<'db> { - use ra_syntax::ast::AstNode; + use syntax::ast::AstNode; let file = sema.parse(resolve_context.file_id); // Find a node at the requested position, falling back to the whole file. let node = file diff --git a/crates/ra_ssr/src/search.rs b/crates/ra_ssr/src/search.rs index 85ffa2ac23..e44e149599 100644 --- a/crates/ra_ssr/src/search.rs +++ b/crates/ra_ssr/src/search.rs @@ -10,8 +10,8 @@ use ra_ide_db::{ defs::Definition, search::{Reference, SearchScope}, }; -use ra_syntax::{ast, AstNode, SyntaxKind, SyntaxNode}; use rustc_hash::FxHashSet; +use syntax::{ast, AstNode, SyntaxKind, SyntaxNode}; use test_utils::mark; /// A cache for the results of find_usages. This is for when we have multiple patterns that have the diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index ef244da597..86c786e25c 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml @@ -38,7 +38,7 @@ flycheck = { path = "../flycheck" } ra_ide = { path = "../ra_ide" } profile = { path = "../profile" } ra_project_model = { path = "../ra_project_model" } -ra_syntax = { path = "../ra_syntax" } +syntax = { path = "../syntax" } text_edit = { path = "../text_edit" } vfs = { path = "../vfs" } vfs-notify = { path = "../vfs-notify" } diff --git a/crates/rust-analyzer/src/cargo_target_spec.rs b/crates/rust-analyzer/src/cargo_target_spec.rs index 03c41263aa..7929368c0c 100644 --- a/crates/rust-analyzer/src/cargo_target_spec.rs +++ b/crates/rust-analyzer/src/cargo_target_spec.rs @@ -179,7 +179,7 @@ mod tests { use mbe::ast_to_token_tree; use ra_cfg::CfgExpr; - use ra_syntax::{ + use syntax::{ ast::{self, AstNode}, SmolStr, }; diff --git a/crates/rust-analyzer/src/cli.rs b/crates/rust-analyzer/src/cli.rs index 46d70fcb2a..420abaccb9 100644 --- a/crates/rust-analyzer/src/cli.rs +++ b/crates/rust-analyzer/src/cli.rs @@ -11,7 +11,7 @@ use std::io::Read; use anyhow::Result; use ra_ide::Analysis; -use ra_syntax::{AstNode, SourceFile}; +use syntax::{AstNode, SourceFile}; pub use analysis_bench::{BenchCmd, BenchWhat, Position}; pub use analysis_stats::AnalysisStatsCmd; diff --git a/crates/rust-analyzer/src/cli/analysis_stats.rs b/crates/rust-analyzer/src/cli/analysis_stats.rs index a30c1ec798..cfc1b22440 100644 --- a/crates/rust-analyzer/src/cli/analysis_stats.rs +++ b/crates/rust-analyzer/src/cli/analysis_stats.rs @@ -18,10 +18,10 @@ use ra_db::{ salsa::{self, ParallelDatabase}, SourceDatabaseExt, }; -use ra_syntax::AstNode; use rayon::prelude::*; use rustc_hash::FxHashSet; use stdx::format_to; +use syntax::AstNode; use crate::{ cli::{ diff --git a/crates/rust-analyzer/src/from_proto.rs b/crates/rust-analyzer/src/from_proto.rs index 9f8ce3b991..ad88ffdd72 100644 --- a/crates/rust-analyzer/src/from_proto.rs +++ b/crates/rust-analyzer/src/from_proto.rs @@ -3,7 +3,7 @@ use std::convert::TryFrom; use ra_db::{FileId, FilePosition, FileRange}; use ra_ide::{AssistKind, LineCol, LineIndex}; -use ra_syntax::{TextRange, TextSize}; +use syntax::{TextRange, TextSize}; use vfs::AbsPathBuf; use crate::{global_state::GlobalStateSnapshot, Result}; diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index 07f4af3d3b..86e7833f2f 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs @@ -23,10 +23,10 @@ use ra_ide::{ RangeInfo, Runnable, RunnableKind, SearchScope, TextEdit, }; use ra_project_model::TargetKind; -use ra_syntax::{algo, ast, AstNode, SyntaxKind, TextRange, TextSize}; use serde::{Deserialize, Serialize}; use serde_json::to_value; use stdx::{format_to, split_once}; +use syntax::{algo, ast, AstNode, SyntaxKind, TextRange, TextSize}; use crate::{ cargo_target_spec::CargoTargetSpec, diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index 62fda8a1f2..278819a5c3 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs @@ -12,7 +12,7 @@ use ra_ide::{ Indel, InlayHint, InlayKind, InsertTextFormat, LineIndex, Markup, NavigationTarget, ReferenceAccess, ResolvedAssist, Runnable, Severity, SourceChange, SourceFileEdit, TextEdit, }; -use ra_syntax::{SyntaxKind, TextRange, TextSize}; +use syntax::{SyntaxKind, TextRange, TextSize}; use crate::{ cargo_target_spec::CargoTargetSpec, global_state::GlobalStateSnapshot, diff --git a/crates/ra_syntax/Cargo.toml b/crates/syntax/Cargo.toml similarity index 96% rename from crates/ra_syntax/Cargo.toml rename to crates/syntax/Cargo.toml index eec4bd845e..47e351f9d1 100644 --- a/crates/ra_syntax/Cargo.toml +++ b/crates/syntax/Cargo.toml @@ -1,11 +1,11 @@ [package] -edition = "2018" -name = "ra_syntax" -version = "0.1.0" -authors = ["rust-analyzer developers"] -license = "MIT OR Apache-2.0" +name = "syntax" +version = "0.0.0" description = "Comment and whitespace preserving parser for the Rust language" +license = "MIT OR Apache-2.0" repository = "https://github.com/rust-analyzer/rust-analyzer" +authors = ["rust-analyzer developers"] +edition = "2018" [lib] doctest = false @@ -17,20 +17,19 @@ rustc_lexer = { version = "671.0.0", package = "rustc-ap-rustc_lexer" } rustc-hash = "1.1.0" arrayvec = "0.5.1" once_cell = "1.3.1" - -stdx = { path = "../stdx" } - -text_edit = { path = "../text_edit" } -parser = { path = "../parser" } - # This crate transitively depends on `smol_str` via `rowan`. # ideally, `serde` should be enabled by `rust-analyzer`, but we enable it here # to reduce number of compilations smol_str = { version = "0.1.15", features = ["serde"] } serde = { version = "1.0.106", features = ["derive"] } +stdx = { path = "../stdx" } +text_edit = { path = "../text_edit" } +parser = { path = "../parser" } + [dev-dependencies] -test_utils = { path = "../test_utils" } -expect = { path = "../expect" } walkdir = "2.3.1" rayon = "1" + +test_utils = { path = "../test_utils" } +expect = { path = "../expect" } diff --git a/crates/ra_syntax/fuzz/.gitignore b/crates/syntax/fuzz/.gitignore similarity index 100% rename from crates/ra_syntax/fuzz/.gitignore rename to crates/syntax/fuzz/.gitignore diff --git a/crates/ra_syntax/fuzz/Cargo.toml b/crates/syntax/fuzz/Cargo.toml similarity index 89% rename from crates/ra_syntax/fuzz/Cargo.toml rename to crates/syntax/fuzz/Cargo.toml index 4cec3c4cd8..32c40d1b95 100644 --- a/crates/ra_syntax/fuzz/Cargo.toml +++ b/crates/syntax/fuzz/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "ra_syntax-fuzz" +name = "syntax-fuzz" version = "0.0.1" authors = ["rust-analyzer developers"] publish = false @@ -10,7 +10,7 @@ edition = "2018" cargo-fuzz = true [dependencies] -ra_syntax = { path = ".." } +syntax = { path = ".." } text_edit = { path = "../../text_edit" } libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer-sys.git" } diff --git a/crates/ra_syntax/fuzz/fuzz_targets/parser.rs b/crates/syntax/fuzz/fuzz_targets/parser.rs similarity index 84% rename from crates/ra_syntax/fuzz/fuzz_targets/parser.rs rename to crates/syntax/fuzz/fuzz_targets/parser.rs index 7bc4ef30d0..386768343b 100644 --- a/crates/ra_syntax/fuzz/fuzz_targets/parser.rs +++ b/crates/syntax/fuzz/fuzz_targets/parser.rs @@ -2,7 +2,7 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use ra_syntax::fuzz::check_parser; +use syntax::fuzz::check_parser; fuzz_target!(|data: &[u8]| { if let Ok(text) = std::str::from_utf8(data) { diff --git a/crates/ra_syntax/fuzz/fuzz_targets/reparse.rs b/crates/syntax/fuzz/fuzz_targets/reparse.rs similarity index 84% rename from crates/ra_syntax/fuzz/fuzz_targets/reparse.rs rename to crates/syntax/fuzz/fuzz_targets/reparse.rs index 16598f5f11..5ac99fdafd 100644 --- a/crates/ra_syntax/fuzz/fuzz_targets/reparse.rs +++ b/crates/syntax/fuzz/fuzz_targets/reparse.rs @@ -2,7 +2,7 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use ra_syntax::fuzz::CheckReparse; +use syntax::fuzz::CheckReparse; fuzz_target!(|data: &[u8]| { if let Some(check) = CheckReparse::from_data(data) { diff --git a/crates/ra_syntax/src/algo.rs b/crates/syntax/src/algo.rs similarity index 100% rename from crates/ra_syntax/src/algo.rs rename to crates/syntax/src/algo.rs diff --git a/crates/ra_syntax/src/ast.rs b/crates/syntax/src/ast.rs similarity index 100% rename from crates/ra_syntax/src/ast.rs rename to crates/syntax/src/ast.rs diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/syntax/src/ast/edit.rs similarity index 100% rename from crates/ra_syntax/src/ast/edit.rs rename to crates/syntax/src/ast/edit.rs diff --git a/crates/ra_syntax/src/ast/expr_ext.rs b/crates/syntax/src/ast/expr_ext.rs similarity index 100% rename from crates/ra_syntax/src/ast/expr_ext.rs rename to crates/syntax/src/ast/expr_ext.rs diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/syntax/src/ast/generated.rs similarity index 100% rename from crates/ra_syntax/src/ast/generated.rs rename to crates/syntax/src/ast/generated.rs diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/syntax/src/ast/generated/nodes.rs similarity index 100% rename from crates/ra_syntax/src/ast/generated/nodes.rs rename to crates/syntax/src/ast/generated/nodes.rs diff --git a/crates/ra_syntax/src/ast/generated/tokens.rs b/crates/syntax/src/ast/generated/tokens.rs similarity index 100% rename from crates/ra_syntax/src/ast/generated/tokens.rs rename to crates/syntax/src/ast/generated/tokens.rs diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/syntax/src/ast/make.rs similarity index 100% rename from crates/ra_syntax/src/ast/make.rs rename to crates/syntax/src/ast/make.rs diff --git a/crates/ra_syntax/src/ast/node_ext.rs b/crates/syntax/src/ast/node_ext.rs similarity index 100% rename from crates/ra_syntax/src/ast/node_ext.rs rename to crates/syntax/src/ast/node_ext.rs diff --git a/crates/ra_syntax/src/ast/token_ext.rs b/crates/syntax/src/ast/token_ext.rs similarity index 100% rename from crates/ra_syntax/src/ast/token_ext.rs rename to crates/syntax/src/ast/token_ext.rs diff --git a/crates/ra_syntax/src/ast/traits.rs b/crates/syntax/src/ast/traits.rs similarity index 100% rename from crates/ra_syntax/src/ast/traits.rs rename to crates/syntax/src/ast/traits.rs diff --git a/crates/ra_syntax/src/fuzz.rs b/crates/syntax/src/fuzz.rs similarity index 100% rename from crates/ra_syntax/src/fuzz.rs rename to crates/syntax/src/fuzz.rs diff --git a/crates/ra_syntax/src/lib.rs b/crates/syntax/src/lib.rs similarity index 100% rename from crates/ra_syntax/src/lib.rs rename to crates/syntax/src/lib.rs diff --git a/crates/ra_syntax/src/parsing.rs b/crates/syntax/src/parsing.rs similarity index 100% rename from crates/ra_syntax/src/parsing.rs rename to crates/syntax/src/parsing.rs diff --git a/crates/ra_syntax/src/parsing/lexer.rs b/crates/syntax/src/parsing/lexer.rs similarity index 100% rename from crates/ra_syntax/src/parsing/lexer.rs rename to crates/syntax/src/parsing/lexer.rs diff --git a/crates/ra_syntax/src/parsing/reparsing.rs b/crates/syntax/src/parsing/reparsing.rs similarity index 100% rename from crates/ra_syntax/src/parsing/reparsing.rs rename to crates/syntax/src/parsing/reparsing.rs diff --git a/crates/ra_syntax/src/parsing/text_token_source.rs b/crates/syntax/src/parsing/text_token_source.rs similarity index 100% rename from crates/ra_syntax/src/parsing/text_token_source.rs rename to crates/syntax/src/parsing/text_token_source.rs diff --git a/crates/ra_syntax/src/parsing/text_tree_sink.rs b/crates/syntax/src/parsing/text_tree_sink.rs similarity index 100% rename from crates/ra_syntax/src/parsing/text_tree_sink.rs rename to crates/syntax/src/parsing/text_tree_sink.rs diff --git a/crates/ra_syntax/src/ptr.rs b/crates/syntax/src/ptr.rs similarity index 100% rename from crates/ra_syntax/src/ptr.rs rename to crates/syntax/src/ptr.rs diff --git a/crates/ra_syntax/src/syntax_error.rs b/crates/syntax/src/syntax_error.rs similarity index 100% rename from crates/ra_syntax/src/syntax_error.rs rename to crates/syntax/src/syntax_error.rs diff --git a/crates/ra_syntax/src/syntax_node.rs b/crates/syntax/src/syntax_node.rs similarity index 100% rename from crates/ra_syntax/src/syntax_node.rs rename to crates/syntax/src/syntax_node.rs diff --git a/crates/ra_syntax/src/tests.rs b/crates/syntax/src/tests.rs similarity index 98% rename from crates/ra_syntax/src/tests.rs rename to crates/syntax/src/tests.rs index 00b957f434..ddc7183694 100644 --- a/crates/ra_syntax/src/tests.rs +++ b/crates/syntax/src/tests.rs @@ -126,7 +126,7 @@ fn self_hosting_parsing() { let files = walkdir::WalkDir::new(dir) .into_iter() .filter_entry(|entry| { - // Get all files which are not in the crates/ra_syntax/test_data folder + // Get all files which are not in the crates/syntax/test_data folder !entry.path().components().any(|component| component.as_os_str() == "test_data") }) .map(|e| e.unwrap()) @@ -162,7 +162,7 @@ fn self_hosting_parsing() { } fn test_data_dir() -> PathBuf { - project_dir().join("crates/ra_syntax/test_data") + project_dir().join("crates/syntax/test_data") } fn assert_errors_are_present(errors: &[SyntaxError], path: &Path) { diff --git a/crates/ra_syntax/src/validation.rs b/crates/syntax/src/validation.rs similarity index 100% rename from crates/ra_syntax/src/validation.rs rename to crates/syntax/src/validation.rs diff --git a/crates/ra_syntax/src/validation/block.rs b/crates/syntax/src/validation/block.rs similarity index 100% rename from crates/ra_syntax/src/validation/block.rs rename to crates/syntax/src/validation/block.rs diff --git a/crates/ra_syntax/test_data/accidentally_quadratic b/crates/syntax/test_data/accidentally_quadratic similarity index 100% rename from crates/ra_syntax/test_data/accidentally_quadratic rename to crates/syntax/test_data/accidentally_quadratic diff --git a/crates/ra_syntax/test_data/lexer/err/0001_unclosed_char_at_eof.rs b/crates/syntax/test_data/lexer/err/0001_unclosed_char_at_eof.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0001_unclosed_char_at_eof.rs rename to crates/syntax/test_data/lexer/err/0001_unclosed_char_at_eof.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0001_unclosed_char_at_eof.txt b/crates/syntax/test_data/lexer/err/0001_unclosed_char_at_eof.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0001_unclosed_char_at_eof.txt rename to crates/syntax/test_data/lexer/err/0001_unclosed_char_at_eof.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0002_unclosed_char_with_ferris.rs b/crates/syntax/test_data/lexer/err/0002_unclosed_char_with_ferris.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0002_unclosed_char_with_ferris.rs rename to crates/syntax/test_data/lexer/err/0002_unclosed_char_with_ferris.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0002_unclosed_char_with_ferris.txt b/crates/syntax/test_data/lexer/err/0002_unclosed_char_with_ferris.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0002_unclosed_char_with_ferris.txt rename to crates/syntax/test_data/lexer/err/0002_unclosed_char_with_ferris.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0003_unclosed_char_with_ascii_escape.rs b/crates/syntax/test_data/lexer/err/0003_unclosed_char_with_ascii_escape.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0003_unclosed_char_with_ascii_escape.rs rename to crates/syntax/test_data/lexer/err/0003_unclosed_char_with_ascii_escape.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0003_unclosed_char_with_ascii_escape.txt b/crates/syntax/test_data/lexer/err/0003_unclosed_char_with_ascii_escape.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0003_unclosed_char_with_ascii_escape.txt rename to crates/syntax/test_data/lexer/err/0003_unclosed_char_with_ascii_escape.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0004_unclosed_char_with_unicode_escape.rs b/crates/syntax/test_data/lexer/err/0004_unclosed_char_with_unicode_escape.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0004_unclosed_char_with_unicode_escape.rs rename to crates/syntax/test_data/lexer/err/0004_unclosed_char_with_unicode_escape.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0004_unclosed_char_with_unicode_escape.txt b/crates/syntax/test_data/lexer/err/0004_unclosed_char_with_unicode_escape.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0004_unclosed_char_with_unicode_escape.txt rename to crates/syntax/test_data/lexer/err/0004_unclosed_char_with_unicode_escape.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0005_unclosed_char_with_space.rs b/crates/syntax/test_data/lexer/err/0005_unclosed_char_with_space.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0005_unclosed_char_with_space.rs rename to crates/syntax/test_data/lexer/err/0005_unclosed_char_with_space.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0005_unclosed_char_with_space.txt b/crates/syntax/test_data/lexer/err/0005_unclosed_char_with_space.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0005_unclosed_char_with_space.txt rename to crates/syntax/test_data/lexer/err/0005_unclosed_char_with_space.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0006_unclosed_char_with_slash.rs b/crates/syntax/test_data/lexer/err/0006_unclosed_char_with_slash.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0006_unclosed_char_with_slash.rs rename to crates/syntax/test_data/lexer/err/0006_unclosed_char_with_slash.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0006_unclosed_char_with_slash.txt b/crates/syntax/test_data/lexer/err/0006_unclosed_char_with_slash.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0006_unclosed_char_with_slash.txt rename to crates/syntax/test_data/lexer/err/0006_unclosed_char_with_slash.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0007_unclosed_char_with_slash_n.rs b/crates/syntax/test_data/lexer/err/0007_unclosed_char_with_slash_n.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0007_unclosed_char_with_slash_n.rs rename to crates/syntax/test_data/lexer/err/0007_unclosed_char_with_slash_n.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0007_unclosed_char_with_slash_n.txt b/crates/syntax/test_data/lexer/err/0007_unclosed_char_with_slash_n.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0007_unclosed_char_with_slash_n.txt rename to crates/syntax/test_data/lexer/err/0007_unclosed_char_with_slash_n.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0008_unclosed_char_with_slash_single_quote.rs b/crates/syntax/test_data/lexer/err/0008_unclosed_char_with_slash_single_quote.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0008_unclosed_char_with_slash_single_quote.rs rename to crates/syntax/test_data/lexer/err/0008_unclosed_char_with_slash_single_quote.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0008_unclosed_char_with_slash_single_quote.txt b/crates/syntax/test_data/lexer/err/0008_unclosed_char_with_slash_single_quote.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0008_unclosed_char_with_slash_single_quote.txt rename to crates/syntax/test_data/lexer/err/0008_unclosed_char_with_slash_single_quote.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0009_unclosed_byte_at_eof.rs b/crates/syntax/test_data/lexer/err/0009_unclosed_byte_at_eof.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0009_unclosed_byte_at_eof.rs rename to crates/syntax/test_data/lexer/err/0009_unclosed_byte_at_eof.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0009_unclosed_byte_at_eof.txt b/crates/syntax/test_data/lexer/err/0009_unclosed_byte_at_eof.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0009_unclosed_byte_at_eof.txt rename to crates/syntax/test_data/lexer/err/0009_unclosed_byte_at_eof.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0010_unclosed_byte_with_ferris.rs b/crates/syntax/test_data/lexer/err/0010_unclosed_byte_with_ferris.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0010_unclosed_byte_with_ferris.rs rename to crates/syntax/test_data/lexer/err/0010_unclosed_byte_with_ferris.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0010_unclosed_byte_with_ferris.txt b/crates/syntax/test_data/lexer/err/0010_unclosed_byte_with_ferris.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0010_unclosed_byte_with_ferris.txt rename to crates/syntax/test_data/lexer/err/0010_unclosed_byte_with_ferris.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0011_unclosed_byte_with_ascii_escape.rs b/crates/syntax/test_data/lexer/err/0011_unclosed_byte_with_ascii_escape.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0011_unclosed_byte_with_ascii_escape.rs rename to crates/syntax/test_data/lexer/err/0011_unclosed_byte_with_ascii_escape.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0011_unclosed_byte_with_ascii_escape.txt b/crates/syntax/test_data/lexer/err/0011_unclosed_byte_with_ascii_escape.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0011_unclosed_byte_with_ascii_escape.txt rename to crates/syntax/test_data/lexer/err/0011_unclosed_byte_with_ascii_escape.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0012_unclosed_byte_with_unicode_escape.rs b/crates/syntax/test_data/lexer/err/0012_unclosed_byte_with_unicode_escape.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0012_unclosed_byte_with_unicode_escape.rs rename to crates/syntax/test_data/lexer/err/0012_unclosed_byte_with_unicode_escape.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0012_unclosed_byte_with_unicode_escape.txt b/crates/syntax/test_data/lexer/err/0012_unclosed_byte_with_unicode_escape.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0012_unclosed_byte_with_unicode_escape.txt rename to crates/syntax/test_data/lexer/err/0012_unclosed_byte_with_unicode_escape.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0013_unclosed_byte_with_space.rs b/crates/syntax/test_data/lexer/err/0013_unclosed_byte_with_space.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0013_unclosed_byte_with_space.rs rename to crates/syntax/test_data/lexer/err/0013_unclosed_byte_with_space.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0013_unclosed_byte_with_space.txt b/crates/syntax/test_data/lexer/err/0013_unclosed_byte_with_space.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0013_unclosed_byte_with_space.txt rename to crates/syntax/test_data/lexer/err/0013_unclosed_byte_with_space.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0014_unclosed_byte_with_slash.rs b/crates/syntax/test_data/lexer/err/0014_unclosed_byte_with_slash.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0014_unclosed_byte_with_slash.rs rename to crates/syntax/test_data/lexer/err/0014_unclosed_byte_with_slash.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0014_unclosed_byte_with_slash.txt b/crates/syntax/test_data/lexer/err/0014_unclosed_byte_with_slash.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0014_unclosed_byte_with_slash.txt rename to crates/syntax/test_data/lexer/err/0014_unclosed_byte_with_slash.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0015_unclosed_byte_with_slash_n.rs b/crates/syntax/test_data/lexer/err/0015_unclosed_byte_with_slash_n.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0015_unclosed_byte_with_slash_n.rs rename to crates/syntax/test_data/lexer/err/0015_unclosed_byte_with_slash_n.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0015_unclosed_byte_with_slash_n.txt b/crates/syntax/test_data/lexer/err/0015_unclosed_byte_with_slash_n.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0015_unclosed_byte_with_slash_n.txt rename to crates/syntax/test_data/lexer/err/0015_unclosed_byte_with_slash_n.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0016_unclosed_byte_with_slash_single_quote.rs b/crates/syntax/test_data/lexer/err/0016_unclosed_byte_with_slash_single_quote.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0016_unclosed_byte_with_slash_single_quote.rs rename to crates/syntax/test_data/lexer/err/0016_unclosed_byte_with_slash_single_quote.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0016_unclosed_byte_with_slash_single_quote.txt b/crates/syntax/test_data/lexer/err/0016_unclosed_byte_with_slash_single_quote.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0016_unclosed_byte_with_slash_single_quote.txt rename to crates/syntax/test_data/lexer/err/0016_unclosed_byte_with_slash_single_quote.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0017_unclosed_string_at_eof.rs b/crates/syntax/test_data/lexer/err/0017_unclosed_string_at_eof.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0017_unclosed_string_at_eof.rs rename to crates/syntax/test_data/lexer/err/0017_unclosed_string_at_eof.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0017_unclosed_string_at_eof.txt b/crates/syntax/test_data/lexer/err/0017_unclosed_string_at_eof.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0017_unclosed_string_at_eof.txt rename to crates/syntax/test_data/lexer/err/0017_unclosed_string_at_eof.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0018_unclosed_string_with_ferris.rs b/crates/syntax/test_data/lexer/err/0018_unclosed_string_with_ferris.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0018_unclosed_string_with_ferris.rs rename to crates/syntax/test_data/lexer/err/0018_unclosed_string_with_ferris.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0018_unclosed_string_with_ferris.txt b/crates/syntax/test_data/lexer/err/0018_unclosed_string_with_ferris.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0018_unclosed_string_with_ferris.txt rename to crates/syntax/test_data/lexer/err/0018_unclosed_string_with_ferris.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0019_unclosed_string_with_ascii_escape.rs b/crates/syntax/test_data/lexer/err/0019_unclosed_string_with_ascii_escape.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0019_unclosed_string_with_ascii_escape.rs rename to crates/syntax/test_data/lexer/err/0019_unclosed_string_with_ascii_escape.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0019_unclosed_string_with_ascii_escape.txt b/crates/syntax/test_data/lexer/err/0019_unclosed_string_with_ascii_escape.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0019_unclosed_string_with_ascii_escape.txt rename to crates/syntax/test_data/lexer/err/0019_unclosed_string_with_ascii_escape.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0020_unclosed_string_with_unicode_escape.rs b/crates/syntax/test_data/lexer/err/0020_unclosed_string_with_unicode_escape.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0020_unclosed_string_with_unicode_escape.rs rename to crates/syntax/test_data/lexer/err/0020_unclosed_string_with_unicode_escape.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0020_unclosed_string_with_unicode_escape.txt b/crates/syntax/test_data/lexer/err/0020_unclosed_string_with_unicode_escape.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0020_unclosed_string_with_unicode_escape.txt rename to crates/syntax/test_data/lexer/err/0020_unclosed_string_with_unicode_escape.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0021_unclosed_string_with_space.rs b/crates/syntax/test_data/lexer/err/0021_unclosed_string_with_space.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0021_unclosed_string_with_space.rs rename to crates/syntax/test_data/lexer/err/0021_unclosed_string_with_space.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0021_unclosed_string_with_space.txt b/crates/syntax/test_data/lexer/err/0021_unclosed_string_with_space.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0021_unclosed_string_with_space.txt rename to crates/syntax/test_data/lexer/err/0021_unclosed_string_with_space.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0022_unclosed_string_with_slash.rs b/crates/syntax/test_data/lexer/err/0022_unclosed_string_with_slash.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0022_unclosed_string_with_slash.rs rename to crates/syntax/test_data/lexer/err/0022_unclosed_string_with_slash.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0022_unclosed_string_with_slash.txt b/crates/syntax/test_data/lexer/err/0022_unclosed_string_with_slash.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0022_unclosed_string_with_slash.txt rename to crates/syntax/test_data/lexer/err/0022_unclosed_string_with_slash.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0023_unclosed_string_with_slash_n.rs b/crates/syntax/test_data/lexer/err/0023_unclosed_string_with_slash_n.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0023_unclosed_string_with_slash_n.rs rename to crates/syntax/test_data/lexer/err/0023_unclosed_string_with_slash_n.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0023_unclosed_string_with_slash_n.txt b/crates/syntax/test_data/lexer/err/0023_unclosed_string_with_slash_n.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0023_unclosed_string_with_slash_n.txt rename to crates/syntax/test_data/lexer/err/0023_unclosed_string_with_slash_n.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0024_unclosed_string_with_slash_double_quote.rs b/crates/syntax/test_data/lexer/err/0024_unclosed_string_with_slash_double_quote.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0024_unclosed_string_with_slash_double_quote.rs rename to crates/syntax/test_data/lexer/err/0024_unclosed_string_with_slash_double_quote.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0024_unclosed_string_with_slash_double_quote.txt b/crates/syntax/test_data/lexer/err/0024_unclosed_string_with_slash_double_quote.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0024_unclosed_string_with_slash_double_quote.txt rename to crates/syntax/test_data/lexer/err/0024_unclosed_string_with_slash_double_quote.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0025_unclosed_byte_string_at_eof.rs b/crates/syntax/test_data/lexer/err/0025_unclosed_byte_string_at_eof.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0025_unclosed_byte_string_at_eof.rs rename to crates/syntax/test_data/lexer/err/0025_unclosed_byte_string_at_eof.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0025_unclosed_byte_string_at_eof.txt b/crates/syntax/test_data/lexer/err/0025_unclosed_byte_string_at_eof.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0025_unclosed_byte_string_at_eof.txt rename to crates/syntax/test_data/lexer/err/0025_unclosed_byte_string_at_eof.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0026_unclosed_byte_string_with_ferris.rs b/crates/syntax/test_data/lexer/err/0026_unclosed_byte_string_with_ferris.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0026_unclosed_byte_string_with_ferris.rs rename to crates/syntax/test_data/lexer/err/0026_unclosed_byte_string_with_ferris.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0026_unclosed_byte_string_with_ferris.txt b/crates/syntax/test_data/lexer/err/0026_unclosed_byte_string_with_ferris.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0026_unclosed_byte_string_with_ferris.txt rename to crates/syntax/test_data/lexer/err/0026_unclosed_byte_string_with_ferris.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0027_unclosed_byte_string_with_ascii_escape.rs b/crates/syntax/test_data/lexer/err/0027_unclosed_byte_string_with_ascii_escape.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0027_unclosed_byte_string_with_ascii_escape.rs rename to crates/syntax/test_data/lexer/err/0027_unclosed_byte_string_with_ascii_escape.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0027_unclosed_byte_string_with_ascii_escape.txt b/crates/syntax/test_data/lexer/err/0027_unclosed_byte_string_with_ascii_escape.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0027_unclosed_byte_string_with_ascii_escape.txt rename to crates/syntax/test_data/lexer/err/0027_unclosed_byte_string_with_ascii_escape.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0028_unclosed_byte_string_with_unicode_escape.rs b/crates/syntax/test_data/lexer/err/0028_unclosed_byte_string_with_unicode_escape.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0028_unclosed_byte_string_with_unicode_escape.rs rename to crates/syntax/test_data/lexer/err/0028_unclosed_byte_string_with_unicode_escape.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0028_unclosed_byte_string_with_unicode_escape.txt b/crates/syntax/test_data/lexer/err/0028_unclosed_byte_string_with_unicode_escape.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0028_unclosed_byte_string_with_unicode_escape.txt rename to crates/syntax/test_data/lexer/err/0028_unclosed_byte_string_with_unicode_escape.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0029_unclosed_byte_string_with_space.rs b/crates/syntax/test_data/lexer/err/0029_unclosed_byte_string_with_space.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0029_unclosed_byte_string_with_space.rs rename to crates/syntax/test_data/lexer/err/0029_unclosed_byte_string_with_space.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0029_unclosed_byte_string_with_space.txt b/crates/syntax/test_data/lexer/err/0029_unclosed_byte_string_with_space.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0029_unclosed_byte_string_with_space.txt rename to crates/syntax/test_data/lexer/err/0029_unclosed_byte_string_with_space.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0030_unclosed_byte_string_with_slash.rs b/crates/syntax/test_data/lexer/err/0030_unclosed_byte_string_with_slash.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0030_unclosed_byte_string_with_slash.rs rename to crates/syntax/test_data/lexer/err/0030_unclosed_byte_string_with_slash.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0030_unclosed_byte_string_with_slash.txt b/crates/syntax/test_data/lexer/err/0030_unclosed_byte_string_with_slash.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0030_unclosed_byte_string_with_slash.txt rename to crates/syntax/test_data/lexer/err/0030_unclosed_byte_string_with_slash.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0031_unclosed_byte_string_with_slash_n.rs b/crates/syntax/test_data/lexer/err/0031_unclosed_byte_string_with_slash_n.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0031_unclosed_byte_string_with_slash_n.rs rename to crates/syntax/test_data/lexer/err/0031_unclosed_byte_string_with_slash_n.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0031_unclosed_byte_string_with_slash_n.txt b/crates/syntax/test_data/lexer/err/0031_unclosed_byte_string_with_slash_n.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0031_unclosed_byte_string_with_slash_n.txt rename to crates/syntax/test_data/lexer/err/0031_unclosed_byte_string_with_slash_n.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0032_unclosed_byte_string_with_slash_double_quote.rs b/crates/syntax/test_data/lexer/err/0032_unclosed_byte_string_with_slash_double_quote.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0032_unclosed_byte_string_with_slash_double_quote.rs rename to crates/syntax/test_data/lexer/err/0032_unclosed_byte_string_with_slash_double_quote.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0032_unclosed_byte_string_with_slash_double_quote.txt b/crates/syntax/test_data/lexer/err/0032_unclosed_byte_string_with_slash_double_quote.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0032_unclosed_byte_string_with_slash_double_quote.txt rename to crates/syntax/test_data/lexer/err/0032_unclosed_byte_string_with_slash_double_quote.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0033_unclosed_raw_string_at_eof.rs b/crates/syntax/test_data/lexer/err/0033_unclosed_raw_string_at_eof.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0033_unclosed_raw_string_at_eof.rs rename to crates/syntax/test_data/lexer/err/0033_unclosed_raw_string_at_eof.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0033_unclosed_raw_string_at_eof.txt b/crates/syntax/test_data/lexer/err/0033_unclosed_raw_string_at_eof.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0033_unclosed_raw_string_at_eof.txt rename to crates/syntax/test_data/lexer/err/0033_unclosed_raw_string_at_eof.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0034_unclosed_raw_string_with_ferris.rs b/crates/syntax/test_data/lexer/err/0034_unclosed_raw_string_with_ferris.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0034_unclosed_raw_string_with_ferris.rs rename to crates/syntax/test_data/lexer/err/0034_unclosed_raw_string_with_ferris.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0034_unclosed_raw_string_with_ferris.txt b/crates/syntax/test_data/lexer/err/0034_unclosed_raw_string_with_ferris.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0034_unclosed_raw_string_with_ferris.txt rename to crates/syntax/test_data/lexer/err/0034_unclosed_raw_string_with_ferris.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0035_unclosed_raw_string_with_ascii_escape.rs b/crates/syntax/test_data/lexer/err/0035_unclosed_raw_string_with_ascii_escape.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0035_unclosed_raw_string_with_ascii_escape.rs rename to crates/syntax/test_data/lexer/err/0035_unclosed_raw_string_with_ascii_escape.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0035_unclosed_raw_string_with_ascii_escape.txt b/crates/syntax/test_data/lexer/err/0035_unclosed_raw_string_with_ascii_escape.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0035_unclosed_raw_string_with_ascii_escape.txt rename to crates/syntax/test_data/lexer/err/0035_unclosed_raw_string_with_ascii_escape.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0036_unclosed_raw_string_with_unicode_escape.rs b/crates/syntax/test_data/lexer/err/0036_unclosed_raw_string_with_unicode_escape.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0036_unclosed_raw_string_with_unicode_escape.rs rename to crates/syntax/test_data/lexer/err/0036_unclosed_raw_string_with_unicode_escape.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0036_unclosed_raw_string_with_unicode_escape.txt b/crates/syntax/test_data/lexer/err/0036_unclosed_raw_string_with_unicode_escape.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0036_unclosed_raw_string_with_unicode_escape.txt rename to crates/syntax/test_data/lexer/err/0036_unclosed_raw_string_with_unicode_escape.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0037_unclosed_raw_string_with_space.rs b/crates/syntax/test_data/lexer/err/0037_unclosed_raw_string_with_space.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0037_unclosed_raw_string_with_space.rs rename to crates/syntax/test_data/lexer/err/0037_unclosed_raw_string_with_space.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0037_unclosed_raw_string_with_space.txt b/crates/syntax/test_data/lexer/err/0037_unclosed_raw_string_with_space.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0037_unclosed_raw_string_with_space.txt rename to crates/syntax/test_data/lexer/err/0037_unclosed_raw_string_with_space.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0038_unclosed_raw_string_with_slash.rs b/crates/syntax/test_data/lexer/err/0038_unclosed_raw_string_with_slash.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0038_unclosed_raw_string_with_slash.rs rename to crates/syntax/test_data/lexer/err/0038_unclosed_raw_string_with_slash.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0038_unclosed_raw_string_with_slash.txt b/crates/syntax/test_data/lexer/err/0038_unclosed_raw_string_with_slash.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0038_unclosed_raw_string_with_slash.txt rename to crates/syntax/test_data/lexer/err/0038_unclosed_raw_string_with_slash.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0039_unclosed_raw_string_with_slash_n.rs b/crates/syntax/test_data/lexer/err/0039_unclosed_raw_string_with_slash_n.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0039_unclosed_raw_string_with_slash_n.rs rename to crates/syntax/test_data/lexer/err/0039_unclosed_raw_string_with_slash_n.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0039_unclosed_raw_string_with_slash_n.txt b/crates/syntax/test_data/lexer/err/0039_unclosed_raw_string_with_slash_n.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0039_unclosed_raw_string_with_slash_n.txt rename to crates/syntax/test_data/lexer/err/0039_unclosed_raw_string_with_slash_n.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0040_unclosed_raw_byte_string_at_eof.rs b/crates/syntax/test_data/lexer/err/0040_unclosed_raw_byte_string_at_eof.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0040_unclosed_raw_byte_string_at_eof.rs rename to crates/syntax/test_data/lexer/err/0040_unclosed_raw_byte_string_at_eof.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0040_unclosed_raw_byte_string_at_eof.txt b/crates/syntax/test_data/lexer/err/0040_unclosed_raw_byte_string_at_eof.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0040_unclosed_raw_byte_string_at_eof.txt rename to crates/syntax/test_data/lexer/err/0040_unclosed_raw_byte_string_at_eof.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0041_unclosed_raw_byte_string_with_ferris.rs b/crates/syntax/test_data/lexer/err/0041_unclosed_raw_byte_string_with_ferris.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0041_unclosed_raw_byte_string_with_ferris.rs rename to crates/syntax/test_data/lexer/err/0041_unclosed_raw_byte_string_with_ferris.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0041_unclosed_raw_byte_string_with_ferris.txt b/crates/syntax/test_data/lexer/err/0041_unclosed_raw_byte_string_with_ferris.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0041_unclosed_raw_byte_string_with_ferris.txt rename to crates/syntax/test_data/lexer/err/0041_unclosed_raw_byte_string_with_ferris.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0042_unclosed_raw_byte_string_with_ascii_escape.rs b/crates/syntax/test_data/lexer/err/0042_unclosed_raw_byte_string_with_ascii_escape.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0042_unclosed_raw_byte_string_with_ascii_escape.rs rename to crates/syntax/test_data/lexer/err/0042_unclosed_raw_byte_string_with_ascii_escape.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0042_unclosed_raw_byte_string_with_ascii_escape.txt b/crates/syntax/test_data/lexer/err/0042_unclosed_raw_byte_string_with_ascii_escape.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0042_unclosed_raw_byte_string_with_ascii_escape.txt rename to crates/syntax/test_data/lexer/err/0042_unclosed_raw_byte_string_with_ascii_escape.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0043_unclosed_raw_byte_string_with_unicode_escape.rs b/crates/syntax/test_data/lexer/err/0043_unclosed_raw_byte_string_with_unicode_escape.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0043_unclosed_raw_byte_string_with_unicode_escape.rs rename to crates/syntax/test_data/lexer/err/0043_unclosed_raw_byte_string_with_unicode_escape.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0043_unclosed_raw_byte_string_with_unicode_escape.txt b/crates/syntax/test_data/lexer/err/0043_unclosed_raw_byte_string_with_unicode_escape.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0043_unclosed_raw_byte_string_with_unicode_escape.txt rename to crates/syntax/test_data/lexer/err/0043_unclosed_raw_byte_string_with_unicode_escape.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0044_unclosed_raw_byte_string_with_space.rs b/crates/syntax/test_data/lexer/err/0044_unclosed_raw_byte_string_with_space.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0044_unclosed_raw_byte_string_with_space.rs rename to crates/syntax/test_data/lexer/err/0044_unclosed_raw_byte_string_with_space.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0044_unclosed_raw_byte_string_with_space.txt b/crates/syntax/test_data/lexer/err/0044_unclosed_raw_byte_string_with_space.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0044_unclosed_raw_byte_string_with_space.txt rename to crates/syntax/test_data/lexer/err/0044_unclosed_raw_byte_string_with_space.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0045_unclosed_raw_byte_string_with_slash.rs b/crates/syntax/test_data/lexer/err/0045_unclosed_raw_byte_string_with_slash.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0045_unclosed_raw_byte_string_with_slash.rs rename to crates/syntax/test_data/lexer/err/0045_unclosed_raw_byte_string_with_slash.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0045_unclosed_raw_byte_string_with_slash.txt b/crates/syntax/test_data/lexer/err/0045_unclosed_raw_byte_string_with_slash.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0045_unclosed_raw_byte_string_with_slash.txt rename to crates/syntax/test_data/lexer/err/0045_unclosed_raw_byte_string_with_slash.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0046_unclosed_raw_byte_string_with_slash_n.rs b/crates/syntax/test_data/lexer/err/0046_unclosed_raw_byte_string_with_slash_n.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0046_unclosed_raw_byte_string_with_slash_n.rs rename to crates/syntax/test_data/lexer/err/0046_unclosed_raw_byte_string_with_slash_n.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0046_unclosed_raw_byte_string_with_slash_n.txt b/crates/syntax/test_data/lexer/err/0046_unclosed_raw_byte_string_with_slash_n.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0046_unclosed_raw_byte_string_with_slash_n.txt rename to crates/syntax/test_data/lexer/err/0046_unclosed_raw_byte_string_with_slash_n.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0047_unstarted_raw_string_at_eof.rs b/crates/syntax/test_data/lexer/err/0047_unstarted_raw_string_at_eof.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0047_unstarted_raw_string_at_eof.rs rename to crates/syntax/test_data/lexer/err/0047_unstarted_raw_string_at_eof.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0047_unstarted_raw_string_at_eof.txt b/crates/syntax/test_data/lexer/err/0047_unstarted_raw_string_at_eof.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0047_unstarted_raw_string_at_eof.txt rename to crates/syntax/test_data/lexer/err/0047_unstarted_raw_string_at_eof.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0048_unstarted_raw_byte_string_at_eof.rs b/crates/syntax/test_data/lexer/err/0048_unstarted_raw_byte_string_at_eof.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0048_unstarted_raw_byte_string_at_eof.rs rename to crates/syntax/test_data/lexer/err/0048_unstarted_raw_byte_string_at_eof.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0048_unstarted_raw_byte_string_at_eof.txt b/crates/syntax/test_data/lexer/err/0048_unstarted_raw_byte_string_at_eof.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0048_unstarted_raw_byte_string_at_eof.txt rename to crates/syntax/test_data/lexer/err/0048_unstarted_raw_byte_string_at_eof.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0049_unstarted_raw_string_with_ascii.rs b/crates/syntax/test_data/lexer/err/0049_unstarted_raw_string_with_ascii.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0049_unstarted_raw_string_with_ascii.rs rename to crates/syntax/test_data/lexer/err/0049_unstarted_raw_string_with_ascii.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0049_unstarted_raw_string_with_ascii.txt b/crates/syntax/test_data/lexer/err/0049_unstarted_raw_string_with_ascii.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0049_unstarted_raw_string_with_ascii.txt rename to crates/syntax/test_data/lexer/err/0049_unstarted_raw_string_with_ascii.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0050_unstarted_raw_byte_string_with_ascii.rs b/crates/syntax/test_data/lexer/err/0050_unstarted_raw_byte_string_with_ascii.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0050_unstarted_raw_byte_string_with_ascii.rs rename to crates/syntax/test_data/lexer/err/0050_unstarted_raw_byte_string_with_ascii.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0050_unstarted_raw_byte_string_with_ascii.txt b/crates/syntax/test_data/lexer/err/0050_unstarted_raw_byte_string_with_ascii.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0050_unstarted_raw_byte_string_with_ascii.txt rename to crates/syntax/test_data/lexer/err/0050_unstarted_raw_byte_string_with_ascii.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0051_unclosed_block_comment_at_eof.rs b/crates/syntax/test_data/lexer/err/0051_unclosed_block_comment_at_eof.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0051_unclosed_block_comment_at_eof.rs rename to crates/syntax/test_data/lexer/err/0051_unclosed_block_comment_at_eof.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0051_unclosed_block_comment_at_eof.txt b/crates/syntax/test_data/lexer/err/0051_unclosed_block_comment_at_eof.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0051_unclosed_block_comment_at_eof.txt rename to crates/syntax/test_data/lexer/err/0051_unclosed_block_comment_at_eof.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0052_unclosed_block_comment_with_content.rs b/crates/syntax/test_data/lexer/err/0052_unclosed_block_comment_with_content.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0052_unclosed_block_comment_with_content.rs rename to crates/syntax/test_data/lexer/err/0052_unclosed_block_comment_with_content.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0052_unclosed_block_comment_with_content.txt b/crates/syntax/test_data/lexer/err/0052_unclosed_block_comment_with_content.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0052_unclosed_block_comment_with_content.txt rename to crates/syntax/test_data/lexer/err/0052_unclosed_block_comment_with_content.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0053_unclosed_nested_block_comment_entirely.rs b/crates/syntax/test_data/lexer/err/0053_unclosed_nested_block_comment_entirely.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0053_unclosed_nested_block_comment_entirely.rs rename to crates/syntax/test_data/lexer/err/0053_unclosed_nested_block_comment_entirely.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0053_unclosed_nested_block_comment_entirely.txt b/crates/syntax/test_data/lexer/err/0053_unclosed_nested_block_comment_entirely.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0053_unclosed_nested_block_comment_entirely.txt rename to crates/syntax/test_data/lexer/err/0053_unclosed_nested_block_comment_entirely.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0054_unclosed_nested_block_comment_partially.rs b/crates/syntax/test_data/lexer/err/0054_unclosed_nested_block_comment_partially.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0054_unclosed_nested_block_comment_partially.rs rename to crates/syntax/test_data/lexer/err/0054_unclosed_nested_block_comment_partially.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0054_unclosed_nested_block_comment_partially.txt b/crates/syntax/test_data/lexer/err/0054_unclosed_nested_block_comment_partially.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0054_unclosed_nested_block_comment_partially.txt rename to crates/syntax/test_data/lexer/err/0054_unclosed_nested_block_comment_partially.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0055_empty_int.rs b/crates/syntax/test_data/lexer/err/0055_empty_int.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0055_empty_int.rs rename to crates/syntax/test_data/lexer/err/0055_empty_int.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0055_empty_int.txt b/crates/syntax/test_data/lexer/err/0055_empty_int.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0055_empty_int.txt rename to crates/syntax/test_data/lexer/err/0055_empty_int.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0056_empty_exponent.rs b/crates/syntax/test_data/lexer/err/0056_empty_exponent.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0056_empty_exponent.rs rename to crates/syntax/test_data/lexer/err/0056_empty_exponent.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0056_empty_exponent.txt b/crates/syntax/test_data/lexer/err/0056_empty_exponent.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0056_empty_exponent.txt rename to crates/syntax/test_data/lexer/err/0056_empty_exponent.txt diff --git a/crates/ra_syntax/test_data/lexer/err/0057_lifetime_strarts_with_a_number.rs b/crates/syntax/test_data/lexer/err/0057_lifetime_strarts_with_a_number.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0057_lifetime_strarts_with_a_number.rs rename to crates/syntax/test_data/lexer/err/0057_lifetime_strarts_with_a_number.rs diff --git a/crates/ra_syntax/test_data/lexer/err/0057_lifetime_strarts_with_a_number.txt b/crates/syntax/test_data/lexer/err/0057_lifetime_strarts_with_a_number.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/err/0057_lifetime_strarts_with_a_number.txt rename to crates/syntax/test_data/lexer/err/0057_lifetime_strarts_with_a_number.txt diff --git a/crates/ra_syntax/test_data/lexer/ok/0001_hello.rs b/crates/syntax/test_data/lexer/ok/0001_hello.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/ok/0001_hello.rs rename to crates/syntax/test_data/lexer/ok/0001_hello.rs diff --git a/crates/ra_syntax/test_data/lexer/ok/0001_hello.txt b/crates/syntax/test_data/lexer/ok/0001_hello.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/ok/0001_hello.txt rename to crates/syntax/test_data/lexer/ok/0001_hello.txt diff --git a/crates/ra_syntax/test_data/lexer/ok/0002_whitespace.rs b/crates/syntax/test_data/lexer/ok/0002_whitespace.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/ok/0002_whitespace.rs rename to crates/syntax/test_data/lexer/ok/0002_whitespace.rs diff --git a/crates/ra_syntax/test_data/lexer/ok/0002_whitespace.txt b/crates/syntax/test_data/lexer/ok/0002_whitespace.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/ok/0002_whitespace.txt rename to crates/syntax/test_data/lexer/ok/0002_whitespace.txt diff --git a/crates/ra_syntax/test_data/lexer/ok/0003_ident.rs b/crates/syntax/test_data/lexer/ok/0003_ident.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/ok/0003_ident.rs rename to crates/syntax/test_data/lexer/ok/0003_ident.rs diff --git a/crates/ra_syntax/test_data/lexer/ok/0003_ident.txt b/crates/syntax/test_data/lexer/ok/0003_ident.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/ok/0003_ident.txt rename to crates/syntax/test_data/lexer/ok/0003_ident.txt diff --git a/crates/ra_syntax/test_data/lexer/ok/0004_numbers.rs b/crates/syntax/test_data/lexer/ok/0004_numbers.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/ok/0004_numbers.rs rename to crates/syntax/test_data/lexer/ok/0004_numbers.rs diff --git a/crates/ra_syntax/test_data/lexer/ok/0004_numbers.txt b/crates/syntax/test_data/lexer/ok/0004_numbers.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/ok/0004_numbers.txt rename to crates/syntax/test_data/lexer/ok/0004_numbers.txt diff --git a/crates/ra_syntax/test_data/lexer/ok/0005_symbols.rs b/crates/syntax/test_data/lexer/ok/0005_symbols.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/ok/0005_symbols.rs rename to crates/syntax/test_data/lexer/ok/0005_symbols.rs diff --git a/crates/ra_syntax/test_data/lexer/ok/0005_symbols.txt b/crates/syntax/test_data/lexer/ok/0005_symbols.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/ok/0005_symbols.txt rename to crates/syntax/test_data/lexer/ok/0005_symbols.txt diff --git a/crates/ra_syntax/test_data/lexer/ok/0006_chars.rs b/crates/syntax/test_data/lexer/ok/0006_chars.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/ok/0006_chars.rs rename to crates/syntax/test_data/lexer/ok/0006_chars.rs diff --git a/crates/ra_syntax/test_data/lexer/ok/0006_chars.txt b/crates/syntax/test_data/lexer/ok/0006_chars.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/ok/0006_chars.txt rename to crates/syntax/test_data/lexer/ok/0006_chars.txt diff --git a/crates/ra_syntax/test_data/lexer/ok/0007_lifetimes.rs b/crates/syntax/test_data/lexer/ok/0007_lifetimes.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/ok/0007_lifetimes.rs rename to crates/syntax/test_data/lexer/ok/0007_lifetimes.rs diff --git a/crates/ra_syntax/test_data/lexer/ok/0007_lifetimes.txt b/crates/syntax/test_data/lexer/ok/0007_lifetimes.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/ok/0007_lifetimes.txt rename to crates/syntax/test_data/lexer/ok/0007_lifetimes.txt diff --git a/crates/ra_syntax/test_data/lexer/ok/0008_byte_strings.rs b/crates/syntax/test_data/lexer/ok/0008_byte_strings.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/ok/0008_byte_strings.rs rename to crates/syntax/test_data/lexer/ok/0008_byte_strings.rs diff --git a/crates/ra_syntax/test_data/lexer/ok/0008_byte_strings.txt b/crates/syntax/test_data/lexer/ok/0008_byte_strings.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/ok/0008_byte_strings.txt rename to crates/syntax/test_data/lexer/ok/0008_byte_strings.txt diff --git a/crates/ra_syntax/test_data/lexer/ok/0009_strings.rs b/crates/syntax/test_data/lexer/ok/0009_strings.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/ok/0009_strings.rs rename to crates/syntax/test_data/lexer/ok/0009_strings.rs diff --git a/crates/ra_syntax/test_data/lexer/ok/0009_strings.txt b/crates/syntax/test_data/lexer/ok/0009_strings.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/ok/0009_strings.txt rename to crates/syntax/test_data/lexer/ok/0009_strings.txt diff --git a/crates/ra_syntax/test_data/lexer/ok/0010_single_line_comments.rs b/crates/syntax/test_data/lexer/ok/0010_single_line_comments.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/ok/0010_single_line_comments.rs rename to crates/syntax/test_data/lexer/ok/0010_single_line_comments.rs diff --git a/crates/ra_syntax/test_data/lexer/ok/0010_single_line_comments.txt b/crates/syntax/test_data/lexer/ok/0010_single_line_comments.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/ok/0010_single_line_comments.txt rename to crates/syntax/test_data/lexer/ok/0010_single_line_comments.txt diff --git a/crates/ra_syntax/test_data/lexer/ok/0011_keywords.rs b/crates/syntax/test_data/lexer/ok/0011_keywords.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/ok/0011_keywords.rs rename to crates/syntax/test_data/lexer/ok/0011_keywords.rs diff --git a/crates/ra_syntax/test_data/lexer/ok/0011_keywords.txt b/crates/syntax/test_data/lexer/ok/0011_keywords.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/ok/0011_keywords.txt rename to crates/syntax/test_data/lexer/ok/0011_keywords.txt diff --git a/crates/ra_syntax/test_data/lexer/ok/0012_block_comment.rs b/crates/syntax/test_data/lexer/ok/0012_block_comment.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/ok/0012_block_comment.rs rename to crates/syntax/test_data/lexer/ok/0012_block_comment.rs diff --git a/crates/ra_syntax/test_data/lexer/ok/0012_block_comment.txt b/crates/syntax/test_data/lexer/ok/0012_block_comment.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/ok/0012_block_comment.txt rename to crates/syntax/test_data/lexer/ok/0012_block_comment.txt diff --git a/crates/ra_syntax/test_data/lexer/ok/0013_raw_strings.rs b/crates/syntax/test_data/lexer/ok/0013_raw_strings.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/ok/0013_raw_strings.rs rename to crates/syntax/test_data/lexer/ok/0013_raw_strings.rs diff --git a/crates/ra_syntax/test_data/lexer/ok/0013_raw_strings.txt b/crates/syntax/test_data/lexer/ok/0013_raw_strings.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/ok/0013_raw_strings.txt rename to crates/syntax/test_data/lexer/ok/0013_raw_strings.txt diff --git a/crates/ra_syntax/test_data/lexer/ok/0014_raw_ident.rs b/crates/syntax/test_data/lexer/ok/0014_raw_ident.rs similarity index 100% rename from crates/ra_syntax/test_data/lexer/ok/0014_raw_ident.rs rename to crates/syntax/test_data/lexer/ok/0014_raw_ident.rs diff --git a/crates/ra_syntax/test_data/lexer/ok/0014_raw_ident.txt b/crates/syntax/test_data/lexer/ok/0014_raw_ident.txt similarity index 100% rename from crates/ra_syntax/test_data/lexer/ok/0014_raw_ident.txt rename to crates/syntax/test_data/lexer/ok/0014_raw_ident.txt diff --git a/crates/ra_syntax/test_data/parser/err/0000_struct_field_missing_comma.rast b/crates/syntax/test_data/parser/err/0000_struct_field_missing_comma.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0000_struct_field_missing_comma.rast rename to crates/syntax/test_data/parser/err/0000_struct_field_missing_comma.rast diff --git a/crates/ra_syntax/test_data/parser/err/0000_struct_field_missing_comma.rs b/crates/syntax/test_data/parser/err/0000_struct_field_missing_comma.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0000_struct_field_missing_comma.rs rename to crates/syntax/test_data/parser/err/0000_struct_field_missing_comma.rs diff --git a/crates/ra_syntax/test_data/parser/err/0001_item_recovery_in_file.rast b/crates/syntax/test_data/parser/err/0001_item_recovery_in_file.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0001_item_recovery_in_file.rast rename to crates/syntax/test_data/parser/err/0001_item_recovery_in_file.rast diff --git a/crates/ra_syntax/test_data/parser/err/0001_item_recovery_in_file.rs b/crates/syntax/test_data/parser/err/0001_item_recovery_in_file.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0001_item_recovery_in_file.rs rename to crates/syntax/test_data/parser/err/0001_item_recovery_in_file.rs diff --git a/crates/ra_syntax/test_data/parser/err/0002_duplicate_shebang.rast b/crates/syntax/test_data/parser/err/0002_duplicate_shebang.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0002_duplicate_shebang.rast rename to crates/syntax/test_data/parser/err/0002_duplicate_shebang.rast diff --git a/crates/ra_syntax/test_data/parser/err/0002_duplicate_shebang.rs b/crates/syntax/test_data/parser/err/0002_duplicate_shebang.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0002_duplicate_shebang.rs rename to crates/syntax/test_data/parser/err/0002_duplicate_shebang.rs diff --git a/crates/ra_syntax/test_data/parser/err/0003_C++_semicolon.rast b/crates/syntax/test_data/parser/err/0003_C++_semicolon.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0003_C++_semicolon.rast rename to crates/syntax/test_data/parser/err/0003_C++_semicolon.rast diff --git a/crates/ra_syntax/test_data/parser/err/0003_C++_semicolon.rs b/crates/syntax/test_data/parser/err/0003_C++_semicolon.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0003_C++_semicolon.rs rename to crates/syntax/test_data/parser/err/0003_C++_semicolon.rs diff --git a/crates/ra_syntax/test_data/parser/err/0004_use_path_bad_segment.rast b/crates/syntax/test_data/parser/err/0004_use_path_bad_segment.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0004_use_path_bad_segment.rast rename to crates/syntax/test_data/parser/err/0004_use_path_bad_segment.rast diff --git a/crates/ra_syntax/test_data/parser/err/0004_use_path_bad_segment.rs b/crates/syntax/test_data/parser/err/0004_use_path_bad_segment.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0004_use_path_bad_segment.rs rename to crates/syntax/test_data/parser/err/0004_use_path_bad_segment.rs diff --git a/crates/ra_syntax/test_data/parser/err/0005_attribute_recover.rast b/crates/syntax/test_data/parser/err/0005_attribute_recover.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0005_attribute_recover.rast rename to crates/syntax/test_data/parser/err/0005_attribute_recover.rast diff --git a/crates/ra_syntax/test_data/parser/err/0005_attribute_recover.rs b/crates/syntax/test_data/parser/err/0005_attribute_recover.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0005_attribute_recover.rs rename to crates/syntax/test_data/parser/err/0005_attribute_recover.rs diff --git a/crates/ra_syntax/test_data/parser/err/0006_named_field_recovery.rast b/crates/syntax/test_data/parser/err/0006_named_field_recovery.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0006_named_field_recovery.rast rename to crates/syntax/test_data/parser/err/0006_named_field_recovery.rast diff --git a/crates/ra_syntax/test_data/parser/err/0006_named_field_recovery.rs b/crates/syntax/test_data/parser/err/0006_named_field_recovery.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0006_named_field_recovery.rs rename to crates/syntax/test_data/parser/err/0006_named_field_recovery.rs diff --git a/crates/ra_syntax/test_data/parser/err/0007_stray_curly_in_file.rast b/crates/syntax/test_data/parser/err/0007_stray_curly_in_file.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0007_stray_curly_in_file.rast rename to crates/syntax/test_data/parser/err/0007_stray_curly_in_file.rast diff --git a/crates/ra_syntax/test_data/parser/err/0007_stray_curly_in_file.rs b/crates/syntax/test_data/parser/err/0007_stray_curly_in_file.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0007_stray_curly_in_file.rs rename to crates/syntax/test_data/parser/err/0007_stray_curly_in_file.rs diff --git a/crates/ra_syntax/test_data/parser/err/0008_item_block_recovery.rast b/crates/syntax/test_data/parser/err/0008_item_block_recovery.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0008_item_block_recovery.rast rename to crates/syntax/test_data/parser/err/0008_item_block_recovery.rast diff --git a/crates/ra_syntax/test_data/parser/err/0008_item_block_recovery.rs b/crates/syntax/test_data/parser/err/0008_item_block_recovery.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0008_item_block_recovery.rs rename to crates/syntax/test_data/parser/err/0008_item_block_recovery.rs diff --git a/crates/ra_syntax/test_data/parser/err/0009_broken_struct_type_parameter.rast b/crates/syntax/test_data/parser/err/0009_broken_struct_type_parameter.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0009_broken_struct_type_parameter.rast rename to crates/syntax/test_data/parser/err/0009_broken_struct_type_parameter.rast diff --git a/crates/ra_syntax/test_data/parser/err/0009_broken_struct_type_parameter.rs b/crates/syntax/test_data/parser/err/0009_broken_struct_type_parameter.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0009_broken_struct_type_parameter.rs rename to crates/syntax/test_data/parser/err/0009_broken_struct_type_parameter.rs diff --git a/crates/ra_syntax/test_data/parser/err/0010_unsafe_lambda_block.rast b/crates/syntax/test_data/parser/err/0010_unsafe_lambda_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0010_unsafe_lambda_block.rast rename to crates/syntax/test_data/parser/err/0010_unsafe_lambda_block.rast diff --git a/crates/ra_syntax/test_data/parser/err/0010_unsafe_lambda_block.rs b/crates/syntax/test_data/parser/err/0010_unsafe_lambda_block.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0010_unsafe_lambda_block.rs rename to crates/syntax/test_data/parser/err/0010_unsafe_lambda_block.rs diff --git a/crates/ra_syntax/test_data/parser/err/0011_extern_struct.rast b/crates/syntax/test_data/parser/err/0011_extern_struct.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0011_extern_struct.rast rename to crates/syntax/test_data/parser/err/0011_extern_struct.rast diff --git a/crates/ra_syntax/test_data/parser/err/0011_extern_struct.rs b/crates/syntax/test_data/parser/err/0011_extern_struct.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0011_extern_struct.rs rename to crates/syntax/test_data/parser/err/0011_extern_struct.rs diff --git a/crates/ra_syntax/test_data/parser/err/0012_broken_lambda.rast b/crates/syntax/test_data/parser/err/0012_broken_lambda.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0012_broken_lambda.rast rename to crates/syntax/test_data/parser/err/0012_broken_lambda.rast diff --git a/crates/ra_syntax/test_data/parser/err/0013_invalid_type.rast b/crates/syntax/test_data/parser/err/0013_invalid_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0013_invalid_type.rast rename to crates/syntax/test_data/parser/err/0013_invalid_type.rast diff --git a/crates/ra_syntax/test_data/parser/err/0013_invalid_type.rs b/crates/syntax/test_data/parser/err/0013_invalid_type.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0013_invalid_type.rs rename to crates/syntax/test_data/parser/err/0013_invalid_type.rs diff --git a/crates/ra_syntax/test_data/parser/err/0014_where_no_bounds.rast b/crates/syntax/test_data/parser/err/0014_where_no_bounds.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0014_where_no_bounds.rast rename to crates/syntax/test_data/parser/err/0014_where_no_bounds.rast diff --git a/crates/ra_syntax/test_data/parser/err/0014_where_no_bounds.rs b/crates/syntax/test_data/parser/err/0014_where_no_bounds.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0014_where_no_bounds.rs rename to crates/syntax/test_data/parser/err/0014_where_no_bounds.rs diff --git a/crates/ra_syntax/test_data/parser/err/0015_curly_in_params.rast b/crates/syntax/test_data/parser/err/0015_curly_in_params.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0015_curly_in_params.rast rename to crates/syntax/test_data/parser/err/0015_curly_in_params.rast diff --git a/crates/ra_syntax/test_data/parser/err/0015_curly_in_params.rs b/crates/syntax/test_data/parser/err/0015_curly_in_params.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0015_curly_in_params.rs rename to crates/syntax/test_data/parser/err/0015_curly_in_params.rs diff --git a/crates/ra_syntax/test_data/parser/err/0016_missing_semi.rast b/crates/syntax/test_data/parser/err/0016_missing_semi.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0016_missing_semi.rast rename to crates/syntax/test_data/parser/err/0016_missing_semi.rast diff --git a/crates/ra_syntax/test_data/parser/err/0016_missing_semi.rs b/crates/syntax/test_data/parser/err/0016_missing_semi.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0016_missing_semi.rs rename to crates/syntax/test_data/parser/err/0016_missing_semi.rs diff --git a/crates/ra_syntax/test_data/parser/err/0017_incomplete_binexpr.rast b/crates/syntax/test_data/parser/err/0017_incomplete_binexpr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0017_incomplete_binexpr.rast rename to crates/syntax/test_data/parser/err/0017_incomplete_binexpr.rast diff --git a/crates/ra_syntax/test_data/parser/err/0017_incomplete_binexpr.rs b/crates/syntax/test_data/parser/err/0017_incomplete_binexpr.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0017_incomplete_binexpr.rs rename to crates/syntax/test_data/parser/err/0017_incomplete_binexpr.rs diff --git a/crates/ra_syntax/test_data/parser/err/0018_incomplete_fn.rast b/crates/syntax/test_data/parser/err/0018_incomplete_fn.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0018_incomplete_fn.rast rename to crates/syntax/test_data/parser/err/0018_incomplete_fn.rast diff --git a/crates/ra_syntax/test_data/parser/err/0018_incomplete_fn.rs b/crates/syntax/test_data/parser/err/0018_incomplete_fn.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0018_incomplete_fn.rs rename to crates/syntax/test_data/parser/err/0018_incomplete_fn.rs diff --git a/crates/ra_syntax/test_data/parser/err/0019_let_recover.rast b/crates/syntax/test_data/parser/err/0019_let_recover.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0019_let_recover.rast rename to crates/syntax/test_data/parser/err/0019_let_recover.rast diff --git a/crates/ra_syntax/test_data/parser/err/0019_let_recover.rs b/crates/syntax/test_data/parser/err/0019_let_recover.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0019_let_recover.rs rename to crates/syntax/test_data/parser/err/0019_let_recover.rs diff --git a/crates/ra_syntax/test_data/parser/err/0020_fn_recover.rast b/crates/syntax/test_data/parser/err/0020_fn_recover.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0020_fn_recover.rast rename to crates/syntax/test_data/parser/err/0020_fn_recover.rast diff --git a/crates/ra_syntax/test_data/parser/err/0020_fn_recover.rs b/crates/syntax/test_data/parser/err/0020_fn_recover.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0020_fn_recover.rs rename to crates/syntax/test_data/parser/err/0020_fn_recover.rs diff --git a/crates/ra_syntax/test_data/parser/err/0021_incomplete_param.rast b/crates/syntax/test_data/parser/err/0021_incomplete_param.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0021_incomplete_param.rast rename to crates/syntax/test_data/parser/err/0021_incomplete_param.rast diff --git a/crates/ra_syntax/test_data/parser/err/0021_incomplete_param.rs b/crates/syntax/test_data/parser/err/0021_incomplete_param.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0021_incomplete_param.rs rename to crates/syntax/test_data/parser/err/0021_incomplete_param.rs diff --git a/crates/ra_syntax/test_data/parser/err/0022_bad_exprs.rast b/crates/syntax/test_data/parser/err/0022_bad_exprs.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0022_bad_exprs.rast rename to crates/syntax/test_data/parser/err/0022_bad_exprs.rast diff --git a/crates/ra_syntax/test_data/parser/err/0022_bad_exprs.rs b/crates/syntax/test_data/parser/err/0022_bad_exprs.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0022_bad_exprs.rs rename to crates/syntax/test_data/parser/err/0022_bad_exprs.rs diff --git a/crates/ra_syntax/test_data/parser/err/0023_mismatched_paren.rast b/crates/syntax/test_data/parser/err/0023_mismatched_paren.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0023_mismatched_paren.rast rename to crates/syntax/test_data/parser/err/0023_mismatched_paren.rast diff --git a/crates/ra_syntax/test_data/parser/err/0023_mismatched_paren.rs b/crates/syntax/test_data/parser/err/0023_mismatched_paren.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0023_mismatched_paren.rs rename to crates/syntax/test_data/parser/err/0023_mismatched_paren.rs diff --git a/crates/ra_syntax/test_data/parser/err/0024_many_type_parens.rast b/crates/syntax/test_data/parser/err/0024_many_type_parens.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0024_many_type_parens.rast rename to crates/syntax/test_data/parser/err/0024_many_type_parens.rast diff --git a/crates/ra_syntax/test_data/parser/err/0024_many_type_parens.rs b/crates/syntax/test_data/parser/err/0024_many_type_parens.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0024_many_type_parens.rs rename to crates/syntax/test_data/parser/err/0024_many_type_parens.rs diff --git a/crates/ra_syntax/test_data/parser/err/0025_nope.rast b/crates/syntax/test_data/parser/err/0025_nope.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0025_nope.rast rename to crates/syntax/test_data/parser/err/0025_nope.rast diff --git a/crates/ra_syntax/test_data/parser/err/0025_nope.rs b/crates/syntax/test_data/parser/err/0025_nope.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0025_nope.rs rename to crates/syntax/test_data/parser/err/0025_nope.rs diff --git a/crates/ra_syntax/test_data/parser/err/0026_imp_recovery.rast b/crates/syntax/test_data/parser/err/0026_imp_recovery.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0026_imp_recovery.rast rename to crates/syntax/test_data/parser/err/0026_imp_recovery.rast diff --git a/crates/ra_syntax/test_data/parser/err/0026_imp_recovery.rs b/crates/syntax/test_data/parser/err/0026_imp_recovery.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0026_imp_recovery.rs rename to crates/syntax/test_data/parser/err/0026_imp_recovery.rs diff --git a/crates/ra_syntax/test_data/parser/err/0027_incomplere_where_for.rast b/crates/syntax/test_data/parser/err/0027_incomplere_where_for.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0027_incomplere_where_for.rast rename to crates/syntax/test_data/parser/err/0027_incomplere_where_for.rast diff --git a/crates/ra_syntax/test_data/parser/err/0027_incomplere_where_for.rs b/crates/syntax/test_data/parser/err/0027_incomplere_where_for.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0027_incomplere_where_for.rs rename to crates/syntax/test_data/parser/err/0027_incomplere_where_for.rs diff --git a/crates/ra_syntax/test_data/parser/err/0029_field_completion.rast b/crates/syntax/test_data/parser/err/0029_field_completion.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0029_field_completion.rast rename to crates/syntax/test_data/parser/err/0029_field_completion.rast diff --git a/crates/ra_syntax/test_data/parser/err/0029_field_completion.rs b/crates/syntax/test_data/parser/err/0029_field_completion.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0029_field_completion.rs rename to crates/syntax/test_data/parser/err/0029_field_completion.rs diff --git a/crates/ra_syntax/test_data/parser/err/0031_block_inner_attrs.rast b/crates/syntax/test_data/parser/err/0031_block_inner_attrs.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0031_block_inner_attrs.rast rename to crates/syntax/test_data/parser/err/0031_block_inner_attrs.rast diff --git a/crates/ra_syntax/test_data/parser/err/0031_block_inner_attrs.rs b/crates/syntax/test_data/parser/err/0031_block_inner_attrs.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0031_block_inner_attrs.rs rename to crates/syntax/test_data/parser/err/0031_block_inner_attrs.rs diff --git a/crates/ra_syntax/test_data/parser/err/0032_match_arms_inner_attrs.rast b/crates/syntax/test_data/parser/err/0032_match_arms_inner_attrs.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0032_match_arms_inner_attrs.rast rename to crates/syntax/test_data/parser/err/0032_match_arms_inner_attrs.rast diff --git a/crates/ra_syntax/test_data/parser/err/0032_match_arms_inner_attrs.rs b/crates/syntax/test_data/parser/err/0032_match_arms_inner_attrs.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0032_match_arms_inner_attrs.rs rename to crates/syntax/test_data/parser/err/0032_match_arms_inner_attrs.rs diff --git a/crates/ra_syntax/test_data/parser/err/0033_match_arms_outer_attrs.rast b/crates/syntax/test_data/parser/err/0033_match_arms_outer_attrs.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0033_match_arms_outer_attrs.rast rename to crates/syntax/test_data/parser/err/0033_match_arms_outer_attrs.rast diff --git a/crates/ra_syntax/test_data/parser/err/0033_match_arms_outer_attrs.rs b/crates/syntax/test_data/parser/err/0033_match_arms_outer_attrs.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0033_match_arms_outer_attrs.rs rename to crates/syntax/test_data/parser/err/0033_match_arms_outer_attrs.rs diff --git a/crates/ra_syntax/test_data/parser/err/0034_bad_box_pattern.rast b/crates/syntax/test_data/parser/err/0034_bad_box_pattern.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0034_bad_box_pattern.rast rename to crates/syntax/test_data/parser/err/0034_bad_box_pattern.rast diff --git a/crates/ra_syntax/test_data/parser/err/0034_bad_box_pattern.rs b/crates/syntax/test_data/parser/err/0034_bad_box_pattern.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0034_bad_box_pattern.rs rename to crates/syntax/test_data/parser/err/0034_bad_box_pattern.rs diff --git a/crates/ra_syntax/test_data/parser/err/0035_use_recover.rast b/crates/syntax/test_data/parser/err/0035_use_recover.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0035_use_recover.rast rename to crates/syntax/test_data/parser/err/0035_use_recover.rast diff --git a/crates/ra_syntax/test_data/parser/err/0035_use_recover.rs b/crates/syntax/test_data/parser/err/0035_use_recover.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0035_use_recover.rs rename to crates/syntax/test_data/parser/err/0035_use_recover.rs diff --git a/crates/ra_syntax/test_data/parser/err/0036_partial_use.rast b/crates/syntax/test_data/parser/err/0036_partial_use.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0036_partial_use.rast rename to crates/syntax/test_data/parser/err/0036_partial_use.rast diff --git a/crates/ra_syntax/test_data/parser/err/0036_partial_use.rs b/crates/syntax/test_data/parser/err/0036_partial_use.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0036_partial_use.rs rename to crates/syntax/test_data/parser/err/0036_partial_use.rs diff --git a/crates/ra_syntax/test_data/parser/err/0037_visibility_in_traits.rast b/crates/syntax/test_data/parser/err/0037_visibility_in_traits.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0037_visibility_in_traits.rast rename to crates/syntax/test_data/parser/err/0037_visibility_in_traits.rast diff --git a/crates/ra_syntax/test_data/parser/err/0037_visibility_in_traits.rs b/crates/syntax/test_data/parser/err/0037_visibility_in_traits.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0037_visibility_in_traits.rs rename to crates/syntax/test_data/parser/err/0037_visibility_in_traits.rs diff --git a/crates/ra_syntax/test_data/parser/err/0038_endless_inclusive_range.rast b/crates/syntax/test_data/parser/err/0038_endless_inclusive_range.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0038_endless_inclusive_range.rast rename to crates/syntax/test_data/parser/err/0038_endless_inclusive_range.rast diff --git a/crates/ra_syntax/test_data/parser/err/0038_endless_inclusive_range.rs b/crates/syntax/test_data/parser/err/0038_endless_inclusive_range.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0038_endless_inclusive_range.rs rename to crates/syntax/test_data/parser/err/0038_endless_inclusive_range.rs diff --git a/crates/ra_syntax/test_data/parser/err/0039_lambda_recovery.rast b/crates/syntax/test_data/parser/err/0039_lambda_recovery.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0039_lambda_recovery.rast rename to crates/syntax/test_data/parser/err/0039_lambda_recovery.rast diff --git a/crates/ra_syntax/test_data/parser/err/0039_lambda_recovery.rs b/crates/syntax/test_data/parser/err/0039_lambda_recovery.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0039_lambda_recovery.rs rename to crates/syntax/test_data/parser/err/0039_lambda_recovery.rs diff --git a/crates/ra_syntax/test_data/parser/err/0040_illegal_crate_kw_location.rast b/crates/syntax/test_data/parser/err/0040_illegal_crate_kw_location.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0040_illegal_crate_kw_location.rast rename to crates/syntax/test_data/parser/err/0040_illegal_crate_kw_location.rast diff --git a/crates/ra_syntax/test_data/parser/err/0040_illegal_crate_kw_location.rs b/crates/syntax/test_data/parser/err/0040_illegal_crate_kw_location.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0040_illegal_crate_kw_location.rs rename to crates/syntax/test_data/parser/err/0040_illegal_crate_kw_location.rs diff --git a/crates/ra_syntax/test_data/parser/err/0041_illegal_super_keyword_location.rast b/crates/syntax/test_data/parser/err/0041_illegal_super_keyword_location.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0041_illegal_super_keyword_location.rast rename to crates/syntax/test_data/parser/err/0041_illegal_super_keyword_location.rast diff --git a/crates/ra_syntax/test_data/parser/err/0041_illegal_super_keyword_location.rs b/crates/syntax/test_data/parser/err/0041_illegal_super_keyword_location.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0041_illegal_super_keyword_location.rs rename to crates/syntax/test_data/parser/err/0041_illegal_super_keyword_location.rs diff --git a/crates/ra_syntax/test_data/parser/err/0042_illegal_self_keyword_location.rast b/crates/syntax/test_data/parser/err/0042_illegal_self_keyword_location.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0042_illegal_self_keyword_location.rast rename to crates/syntax/test_data/parser/err/0042_illegal_self_keyword_location.rast diff --git a/crates/ra_syntax/test_data/parser/err/0042_illegal_self_keyword_location.rs b/crates/syntax/test_data/parser/err/0042_illegal_self_keyword_location.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0042_illegal_self_keyword_location.rs rename to crates/syntax/test_data/parser/err/0042_illegal_self_keyword_location.rs diff --git a/crates/ra_syntax/test_data/parser/err/0043_weird_blocks.rast b/crates/syntax/test_data/parser/err/0043_weird_blocks.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0043_weird_blocks.rast rename to crates/syntax/test_data/parser/err/0043_weird_blocks.rast diff --git a/crates/ra_syntax/test_data/parser/err/0043_weird_blocks.rs b/crates/syntax/test_data/parser/err/0043_weird_blocks.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0043_weird_blocks.rs rename to crates/syntax/test_data/parser/err/0043_weird_blocks.rs diff --git a/crates/ra_syntax/test_data/parser/err/0044_unexpected_for_type.rast b/crates/syntax/test_data/parser/err/0044_unexpected_for_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0044_unexpected_for_type.rast rename to crates/syntax/test_data/parser/err/0044_unexpected_for_type.rast diff --git a/crates/ra_syntax/test_data/parser/err/0044_unexpected_for_type.rs b/crates/syntax/test_data/parser/err/0044_unexpected_for_type.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0044_unexpected_for_type.rs rename to crates/syntax/test_data/parser/err/0044_unexpected_for_type.rs diff --git a/crates/ra_syntax/test_data/parser/err/0045_item_modifiers.rast b/crates/syntax/test_data/parser/err/0045_item_modifiers.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0045_item_modifiers.rast rename to crates/syntax/test_data/parser/err/0045_item_modifiers.rast diff --git a/crates/ra_syntax/test_data/parser/err/0045_item_modifiers.rs b/crates/syntax/test_data/parser/err/0045_item_modifiers.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/err/0045_item_modifiers.rs rename to crates/syntax/test_data/parser/err/0045_item_modifiers.rs diff --git a/crates/ra_syntax/test_data/parser/fragments/expr/err/0000_truncated_add.rast b/crates/syntax/test_data/parser/fragments/expr/err/0000_truncated_add.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/fragments/expr/err/0000_truncated_add.rast rename to crates/syntax/test_data/parser/fragments/expr/err/0000_truncated_add.rast diff --git a/crates/ra_syntax/test_data/parser/fragments/expr/err/0000_truncated_add.rs b/crates/syntax/test_data/parser/fragments/expr/err/0000_truncated_add.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/fragments/expr/err/0000_truncated_add.rs rename to crates/syntax/test_data/parser/fragments/expr/err/0000_truncated_add.rs diff --git a/crates/ra_syntax/test_data/parser/fragments/expr/ok/0000_add.rast b/crates/syntax/test_data/parser/fragments/expr/ok/0000_add.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/fragments/expr/ok/0000_add.rast rename to crates/syntax/test_data/parser/fragments/expr/ok/0000_add.rast diff --git a/crates/ra_syntax/test_data/parser/fragments/expr/ok/0000_add.rs b/crates/syntax/test_data/parser/fragments/expr/ok/0000_add.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/fragments/expr/ok/0000_add.rs rename to crates/syntax/test_data/parser/fragments/expr/ok/0000_add.rs diff --git a/crates/ra_syntax/test_data/parser/fragments/item/err/0000_extra_keyword.rast b/crates/syntax/test_data/parser/fragments/item/err/0000_extra_keyword.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/fragments/item/err/0000_extra_keyword.rast rename to crates/syntax/test_data/parser/fragments/item/err/0000_extra_keyword.rast diff --git a/crates/ra_syntax/test_data/parser/fragments/item/err/0000_extra_keyword.rs b/crates/syntax/test_data/parser/fragments/item/err/0000_extra_keyword.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/fragments/item/err/0000_extra_keyword.rs rename to crates/syntax/test_data/parser/fragments/item/err/0000_extra_keyword.rs diff --git a/crates/ra_syntax/test_data/parser/fragments/item/ok/0000_fn.rast b/crates/syntax/test_data/parser/fragments/item/ok/0000_fn.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/fragments/item/ok/0000_fn.rast rename to crates/syntax/test_data/parser/fragments/item/ok/0000_fn.rast diff --git a/crates/ra_syntax/test_data/parser/fragments/item/ok/0000_fn.rs b/crates/syntax/test_data/parser/fragments/item/ok/0000_fn.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/fragments/item/ok/0000_fn.rs rename to crates/syntax/test_data/parser/fragments/item/ok/0000_fn.rs diff --git a/crates/ra_syntax/test_data/parser/fragments/path/err/0000_reserved_word.rast b/crates/syntax/test_data/parser/fragments/path/err/0000_reserved_word.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/fragments/path/err/0000_reserved_word.rast rename to crates/syntax/test_data/parser/fragments/path/err/0000_reserved_word.rast diff --git a/crates/ra_syntax/test_data/parser/fragments/path/err/0000_reserved_word.rs b/crates/syntax/test_data/parser/fragments/path/err/0000_reserved_word.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/fragments/path/err/0000_reserved_word.rs rename to crates/syntax/test_data/parser/fragments/path/err/0000_reserved_word.rs diff --git a/crates/ra_syntax/test_data/parser/fragments/path/err/0001_expression.rast b/crates/syntax/test_data/parser/fragments/path/err/0001_expression.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/fragments/path/err/0001_expression.rast rename to crates/syntax/test_data/parser/fragments/path/err/0001_expression.rast diff --git a/crates/ra_syntax/test_data/parser/fragments/path/err/0001_expression.rs b/crates/syntax/test_data/parser/fragments/path/err/0001_expression.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/fragments/path/err/0001_expression.rs rename to crates/syntax/test_data/parser/fragments/path/err/0001_expression.rs diff --git a/crates/ra_syntax/test_data/parser/fragments/path/ok/0000_single_ident.rast b/crates/syntax/test_data/parser/fragments/path/ok/0000_single_ident.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/fragments/path/ok/0000_single_ident.rast rename to crates/syntax/test_data/parser/fragments/path/ok/0000_single_ident.rast diff --git a/crates/ra_syntax/test_data/parser/fragments/path/ok/0000_single_ident.rs b/crates/syntax/test_data/parser/fragments/path/ok/0000_single_ident.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/fragments/path/ok/0000_single_ident.rs rename to crates/syntax/test_data/parser/fragments/path/ok/0000_single_ident.rs diff --git a/crates/ra_syntax/test_data/parser/fragments/path/ok/0001_multipart.rast b/crates/syntax/test_data/parser/fragments/path/ok/0001_multipart.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/fragments/path/ok/0001_multipart.rast rename to crates/syntax/test_data/parser/fragments/path/ok/0001_multipart.rast diff --git a/crates/ra_syntax/test_data/parser/fragments/path/ok/0001_multipart.rs b/crates/syntax/test_data/parser/fragments/path/ok/0001_multipart.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/fragments/path/ok/0001_multipart.rs rename to crates/syntax/test_data/parser/fragments/path/ok/0001_multipart.rs diff --git a/crates/ra_syntax/test_data/parser/fragments/pattern/err/0000_reserved_word.rast b/crates/syntax/test_data/parser/fragments/pattern/err/0000_reserved_word.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/fragments/pattern/err/0000_reserved_word.rast rename to crates/syntax/test_data/parser/fragments/pattern/err/0000_reserved_word.rast diff --git a/crates/ra_syntax/test_data/parser/fragments/pattern/err/0000_reserved_word.rs b/crates/syntax/test_data/parser/fragments/pattern/err/0000_reserved_word.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/fragments/pattern/err/0000_reserved_word.rs rename to crates/syntax/test_data/parser/fragments/pattern/err/0000_reserved_word.rs diff --git a/crates/ra_syntax/test_data/parser/fragments/pattern/err/0001_missing_paren.rast b/crates/syntax/test_data/parser/fragments/pattern/err/0001_missing_paren.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/fragments/pattern/err/0001_missing_paren.rast rename to crates/syntax/test_data/parser/fragments/pattern/err/0001_missing_paren.rast diff --git a/crates/ra_syntax/test_data/parser/fragments/pattern/err/0001_missing_paren.rs b/crates/syntax/test_data/parser/fragments/pattern/err/0001_missing_paren.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/fragments/pattern/err/0001_missing_paren.rs rename to crates/syntax/test_data/parser/fragments/pattern/err/0001_missing_paren.rs diff --git a/crates/ra_syntax/test_data/parser/fragments/pattern/ok/0000_enum.rast b/crates/syntax/test_data/parser/fragments/pattern/ok/0000_enum.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/fragments/pattern/ok/0000_enum.rast rename to crates/syntax/test_data/parser/fragments/pattern/ok/0000_enum.rast diff --git a/crates/ra_syntax/test_data/parser/fragments/pattern/ok/0000_enum.rs b/crates/syntax/test_data/parser/fragments/pattern/ok/0000_enum.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/fragments/pattern/ok/0000_enum.rs rename to crates/syntax/test_data/parser/fragments/pattern/ok/0000_enum.rs diff --git a/crates/ra_syntax/test_data/parser/fragments/type/err/0000_missing_close.rast b/crates/syntax/test_data/parser/fragments/type/err/0000_missing_close.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/fragments/type/err/0000_missing_close.rast rename to crates/syntax/test_data/parser/fragments/type/err/0000_missing_close.rast diff --git a/crates/ra_syntax/test_data/parser/fragments/type/err/0000_missing_close.rs b/crates/syntax/test_data/parser/fragments/type/err/0000_missing_close.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/fragments/type/err/0000_missing_close.rs rename to crates/syntax/test_data/parser/fragments/type/err/0000_missing_close.rs diff --git a/crates/ra_syntax/test_data/parser/fragments/type/ok/0000_result.rast b/crates/syntax/test_data/parser/fragments/type/ok/0000_result.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/fragments/type/ok/0000_result.rast rename to crates/syntax/test_data/parser/fragments/type/ok/0000_result.rast diff --git a/crates/ra_syntax/test_data/parser/fragments/type/ok/0000_result.rs b/crates/syntax/test_data/parser/fragments/type/ok/0000_result.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/fragments/type/ok/0000_result.rs rename to crates/syntax/test_data/parser/fragments/type/ok/0000_result.rs diff --git a/crates/ra_syntax/test_data/parser/fuzz-failures/0000.rs b/crates/syntax/test_data/parser/fuzz-failures/0000.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/fuzz-failures/0000.rs rename to crates/syntax/test_data/parser/fuzz-failures/0000.rs diff --git a/crates/ra_syntax/test_data/parser/fuzz-failures/0001.rs b/crates/syntax/test_data/parser/fuzz-failures/0001.rs similarity index 99% rename from crates/ra_syntax/test_data/parser/fuzz-failures/0001.rs rename to crates/syntax/test_data/parser/fuzz-failures/0001.rs index 099cc5f84a..f1148058ef 100644 --- a/crates/ra_syntax/test_data/parser/fuzz-failures/0001.rs +++ b/crates/syntax/test_data/parser/fuzz-failures/0001.rs @@ -1,4 +1,4 @@ -use ra_syntax::{ +use syntax::{ File, TextRange, SyntaxNodeRef, TextUnit, SyntaxKind::*, algo::{find_leaf_at_offset, LeafAtOffset, find_covering_node, ancestors, Direction, siblings}, diff --git a/crates/ra_syntax/test_data/parser/fuzz-failures/0002.rs b/crates/syntax/test_data/parser/fuzz-failures/0002.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/fuzz-failures/0002.rs rename to crates/syntax/test_data/parser/fuzz-failures/0002.rs diff --git a/crates/ra_syntax/test_data/parser/fuzz-failures/0003.rs b/crates/syntax/test_data/parser/fuzz-failures/0003.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/fuzz-failures/0003.rs rename to crates/syntax/test_data/parser/fuzz-failures/0003.rs diff --git a/crates/ra_syntax/test_data/parser/fuzz-failures/0004.rs b/crates/syntax/test_data/parser/fuzz-failures/0004.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/fuzz-failures/0004.rs rename to crates/syntax/test_data/parser/fuzz-failures/0004.rs diff --git a/crates/ra_syntax/test_data/parser/inline/err/0001_array_type_missing_semi.rast b/crates/syntax/test_data/parser/inline/err/0001_array_type_missing_semi.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0001_array_type_missing_semi.rast rename to crates/syntax/test_data/parser/inline/err/0001_array_type_missing_semi.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0001_array_type_missing_semi.rs b/crates/syntax/test_data/parser/inline/err/0001_array_type_missing_semi.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0001_array_type_missing_semi.rs rename to crates/syntax/test_data/parser/inline/err/0001_array_type_missing_semi.rs diff --git a/crates/ra_syntax/test_data/parser/inline/err/0002_misplaced_label_err.rast b/crates/syntax/test_data/parser/inline/err/0002_misplaced_label_err.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0002_misplaced_label_err.rast rename to crates/syntax/test_data/parser/inline/err/0002_misplaced_label_err.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0002_misplaced_label_err.rs b/crates/syntax/test_data/parser/inline/err/0002_misplaced_label_err.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0002_misplaced_label_err.rs rename to crates/syntax/test_data/parser/inline/err/0002_misplaced_label_err.rs diff --git a/crates/ra_syntax/test_data/parser/inline/err/0003_pointer_type_no_mutability.rast b/crates/syntax/test_data/parser/inline/err/0003_pointer_type_no_mutability.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0003_pointer_type_no_mutability.rast rename to crates/syntax/test_data/parser/inline/err/0003_pointer_type_no_mutability.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0003_pointer_type_no_mutability.rs b/crates/syntax/test_data/parser/inline/err/0003_pointer_type_no_mutability.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0003_pointer_type_no_mutability.rs rename to crates/syntax/test_data/parser/inline/err/0003_pointer_type_no_mutability.rs diff --git a/crates/ra_syntax/test_data/parser/inline/err/0004_impl_type.rast b/crates/syntax/test_data/parser/inline/err/0004_impl_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0004_impl_type.rast rename to crates/syntax/test_data/parser/inline/err/0004_impl_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0004_impl_type.rs b/crates/syntax/test_data/parser/inline/err/0004_impl_type.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0004_impl_type.rs rename to crates/syntax/test_data/parser/inline/err/0004_impl_type.rs diff --git a/crates/ra_syntax/test_data/parser/inline/err/0005_fn_pointer_type_missing_fn.rast b/crates/syntax/test_data/parser/inline/err/0005_fn_pointer_type_missing_fn.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0005_fn_pointer_type_missing_fn.rast rename to crates/syntax/test_data/parser/inline/err/0005_fn_pointer_type_missing_fn.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0005_fn_pointer_type_missing_fn.rs b/crates/syntax/test_data/parser/inline/err/0005_fn_pointer_type_missing_fn.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0005_fn_pointer_type_missing_fn.rs rename to crates/syntax/test_data/parser/inline/err/0005_fn_pointer_type_missing_fn.rs diff --git a/crates/ra_syntax/test_data/parser/inline/err/0006_unsafe_block_in_mod.rast b/crates/syntax/test_data/parser/inline/err/0006_unsafe_block_in_mod.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0006_unsafe_block_in_mod.rast rename to crates/syntax/test_data/parser/inline/err/0006_unsafe_block_in_mod.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0006_unsafe_block_in_mod.rs b/crates/syntax/test_data/parser/inline/err/0006_unsafe_block_in_mod.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0006_unsafe_block_in_mod.rs rename to crates/syntax/test_data/parser/inline/err/0006_unsafe_block_in_mod.rs diff --git a/crates/ra_syntax/test_data/parser/inline/err/0007_async_without_semicolon.rast b/crates/syntax/test_data/parser/inline/err/0007_async_without_semicolon.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0007_async_without_semicolon.rast rename to crates/syntax/test_data/parser/inline/err/0007_async_without_semicolon.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0007_async_without_semicolon.rs b/crates/syntax/test_data/parser/inline/err/0007_async_without_semicolon.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0007_async_without_semicolon.rs rename to crates/syntax/test_data/parser/inline/err/0007_async_without_semicolon.rs diff --git a/crates/ra_syntax/test_data/parser/inline/err/0008_pub_expr.rast b/crates/syntax/test_data/parser/inline/err/0008_pub_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0008_pub_expr.rast rename to crates/syntax/test_data/parser/inline/err/0008_pub_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0008_pub_expr.rs b/crates/syntax/test_data/parser/inline/err/0008_pub_expr.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0008_pub_expr.rs rename to crates/syntax/test_data/parser/inline/err/0008_pub_expr.rs diff --git a/crates/ra_syntax/test_data/parser/inline/err/0009_attr_on_expr_not_allowed.rast b/crates/syntax/test_data/parser/inline/err/0009_attr_on_expr_not_allowed.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0009_attr_on_expr_not_allowed.rast rename to crates/syntax/test_data/parser/inline/err/0009_attr_on_expr_not_allowed.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0009_attr_on_expr_not_allowed.rs b/crates/syntax/test_data/parser/inline/err/0009_attr_on_expr_not_allowed.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0009_attr_on_expr_not_allowed.rs rename to crates/syntax/test_data/parser/inline/err/0009_attr_on_expr_not_allowed.rs diff --git a/crates/ra_syntax/test_data/parser/inline/err/0010_bad_tuple_index_expr.rast b/crates/syntax/test_data/parser/inline/err/0010_bad_tuple_index_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0010_bad_tuple_index_expr.rast rename to crates/syntax/test_data/parser/inline/err/0010_bad_tuple_index_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0010_bad_tuple_index_expr.rs b/crates/syntax/test_data/parser/inline/err/0010_bad_tuple_index_expr.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0010_bad_tuple_index_expr.rs rename to crates/syntax/test_data/parser/inline/err/0010_bad_tuple_index_expr.rs diff --git a/crates/ra_syntax/test_data/parser/inline/err/0013_static_underscore.rast b/crates/syntax/test_data/parser/inline/err/0013_static_underscore.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0013_static_underscore.rast rename to crates/syntax/test_data/parser/inline/err/0013_static_underscore.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0013_static_underscore.rs b/crates/syntax/test_data/parser/inline/err/0013_static_underscore.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0013_static_underscore.rs rename to crates/syntax/test_data/parser/inline/err/0013_static_underscore.rs diff --git a/crates/ra_syntax/test_data/parser/inline/err/0014_record_literal_before_ellipsis_recovery.rast b/crates/syntax/test_data/parser/inline/err/0014_record_literal_before_ellipsis_recovery.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0014_record_literal_before_ellipsis_recovery.rast rename to crates/syntax/test_data/parser/inline/err/0014_record_literal_before_ellipsis_recovery.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0014_record_literal_before_ellipsis_recovery.rs b/crates/syntax/test_data/parser/inline/err/0014_record_literal_before_ellipsis_recovery.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0014_record_literal_before_ellipsis_recovery.rs rename to crates/syntax/test_data/parser/inline/err/0014_record_literal_before_ellipsis_recovery.rs diff --git a/crates/ra_syntax/test_data/parser/inline/err/0015_empty_segment.rast b/crates/syntax/test_data/parser/inline/err/0015_empty_segment.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0015_empty_segment.rast rename to crates/syntax/test_data/parser/inline/err/0015_empty_segment.rast diff --git a/crates/ra_syntax/test_data/parser/inline/err/0015_empty_segment.rs b/crates/syntax/test_data/parser/inline/err/0015_empty_segment.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/err/0015_empty_segment.rs rename to crates/syntax/test_data/parser/inline/err/0015_empty_segment.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0001_trait_item_list.rast b/crates/syntax/test_data/parser/inline/ok/0001_trait_item_list.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0001_trait_item_list.rast rename to crates/syntax/test_data/parser/inline/ok/0001_trait_item_list.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0001_trait_item_list.rs b/crates/syntax/test_data/parser/inline/ok/0001_trait_item_list.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0001_trait_item_list.rs rename to crates/syntax/test_data/parser/inline/ok/0001_trait_item_list.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0002_use_tree_list.rast b/crates/syntax/test_data/parser/inline/ok/0002_use_tree_list.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0002_use_tree_list.rast rename to crates/syntax/test_data/parser/inline/ok/0002_use_tree_list.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0002_use_tree_list.rs b/crates/syntax/test_data/parser/inline/ok/0002_use_tree_list.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0002_use_tree_list.rs rename to crates/syntax/test_data/parser/inline/ok/0002_use_tree_list.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0003_where_pred_for.rast b/crates/syntax/test_data/parser/inline/ok/0003_where_pred_for.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0003_where_pred_for.rast rename to crates/syntax/test_data/parser/inline/ok/0003_where_pred_for.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0003_where_pred_for.rs b/crates/syntax/test_data/parser/inline/ok/0003_where_pred_for.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0003_where_pred_for.rs rename to crates/syntax/test_data/parser/inline/ok/0003_where_pred_for.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0004_value_parameters_no_patterns.rast b/crates/syntax/test_data/parser/inline/ok/0004_value_parameters_no_patterns.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0004_value_parameters_no_patterns.rast rename to crates/syntax/test_data/parser/inline/ok/0004_value_parameters_no_patterns.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0004_value_parameters_no_patterns.rs b/crates/syntax/test_data/parser/inline/ok/0004_value_parameters_no_patterns.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0004_value_parameters_no_patterns.rs rename to crates/syntax/test_data/parser/inline/ok/0004_value_parameters_no_patterns.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0005_function_type_params.rast b/crates/syntax/test_data/parser/inline/ok/0005_function_type_params.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0005_function_type_params.rast rename to crates/syntax/test_data/parser/inline/ok/0005_function_type_params.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0005_function_type_params.rs b/crates/syntax/test_data/parser/inline/ok/0005_function_type_params.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0005_function_type_params.rs rename to crates/syntax/test_data/parser/inline/ok/0005_function_type_params.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0006_self_param.rast b/crates/syntax/test_data/parser/inline/ok/0006_self_param.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0006_self_param.rast rename to crates/syntax/test_data/parser/inline/ok/0006_self_param.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0006_self_param.rs b/crates/syntax/test_data/parser/inline/ok/0006_self_param.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0006_self_param.rs rename to crates/syntax/test_data/parser/inline/ok/0006_self_param.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0007_type_param_bounds.rast b/crates/syntax/test_data/parser/inline/ok/0007_type_param_bounds.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0007_type_param_bounds.rast rename to crates/syntax/test_data/parser/inline/ok/0007_type_param_bounds.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0007_type_param_bounds.rs b/crates/syntax/test_data/parser/inline/ok/0007_type_param_bounds.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0007_type_param_bounds.rs rename to crates/syntax/test_data/parser/inline/ok/0007_type_param_bounds.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0008_path_part.rast b/crates/syntax/test_data/parser/inline/ok/0008_path_part.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0008_path_part.rast rename to crates/syntax/test_data/parser/inline/ok/0008_path_part.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0008_path_part.rs b/crates/syntax/test_data/parser/inline/ok/0008_path_part.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0008_path_part.rs rename to crates/syntax/test_data/parser/inline/ok/0008_path_part.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0009_loop_expr.rast b/crates/syntax/test_data/parser/inline/ok/0009_loop_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0009_loop_expr.rast rename to crates/syntax/test_data/parser/inline/ok/0009_loop_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0009_loop_expr.rs b/crates/syntax/test_data/parser/inline/ok/0009_loop_expr.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0009_loop_expr.rs rename to crates/syntax/test_data/parser/inline/ok/0009_loop_expr.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0010_extern_block.rast b/crates/syntax/test_data/parser/inline/ok/0010_extern_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0010_extern_block.rast rename to crates/syntax/test_data/parser/inline/ok/0010_extern_block.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0010_extern_block.rs b/crates/syntax/test_data/parser/inline/ok/0010_extern_block.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0010_extern_block.rs rename to crates/syntax/test_data/parser/inline/ok/0010_extern_block.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0011_field_expr.rast b/crates/syntax/test_data/parser/inline/ok/0011_field_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0011_field_expr.rast rename to crates/syntax/test_data/parser/inline/ok/0011_field_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0011_field_expr.rs b/crates/syntax/test_data/parser/inline/ok/0011_field_expr.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0011_field_expr.rs rename to crates/syntax/test_data/parser/inline/ok/0011_field_expr.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0012_type_item_where_clause.rast b/crates/syntax/test_data/parser/inline/ok/0012_type_item_where_clause.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0012_type_item_where_clause.rast rename to crates/syntax/test_data/parser/inline/ok/0012_type_item_where_clause.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0012_type_item_where_clause.rs b/crates/syntax/test_data/parser/inline/ok/0012_type_item_where_clause.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0012_type_item_where_clause.rs rename to crates/syntax/test_data/parser/inline/ok/0012_type_item_where_clause.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0013_pointer_type_mut.rast b/crates/syntax/test_data/parser/inline/ok/0013_pointer_type_mut.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0013_pointer_type_mut.rast rename to crates/syntax/test_data/parser/inline/ok/0013_pointer_type_mut.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0013_pointer_type_mut.rs b/crates/syntax/test_data/parser/inline/ok/0013_pointer_type_mut.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0013_pointer_type_mut.rs rename to crates/syntax/test_data/parser/inline/ok/0013_pointer_type_mut.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0014_never_type.rast b/crates/syntax/test_data/parser/inline/ok/0014_never_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0014_never_type.rast rename to crates/syntax/test_data/parser/inline/ok/0014_never_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0014_never_type.rs b/crates/syntax/test_data/parser/inline/ok/0014_never_type.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0014_never_type.rs rename to crates/syntax/test_data/parser/inline/ok/0014_never_type.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0015_continue_expr.rast b/crates/syntax/test_data/parser/inline/ok/0015_continue_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0015_continue_expr.rast rename to crates/syntax/test_data/parser/inline/ok/0015_continue_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0015_continue_expr.rs b/crates/syntax/test_data/parser/inline/ok/0015_continue_expr.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0015_continue_expr.rs rename to crates/syntax/test_data/parser/inline/ok/0015_continue_expr.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0017_array_type.rast b/crates/syntax/test_data/parser/inline/ok/0017_array_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0017_array_type.rast rename to crates/syntax/test_data/parser/inline/ok/0017_array_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0017_array_type.rs b/crates/syntax/test_data/parser/inline/ok/0017_array_type.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0017_array_type.rs rename to crates/syntax/test_data/parser/inline/ok/0017_array_type.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0018_arb_self_types.rast b/crates/syntax/test_data/parser/inline/ok/0018_arb_self_types.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0018_arb_self_types.rast rename to crates/syntax/test_data/parser/inline/ok/0018_arb_self_types.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0018_arb_self_types.rs b/crates/syntax/test_data/parser/inline/ok/0018_arb_self_types.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0018_arb_self_types.rs rename to crates/syntax/test_data/parser/inline/ok/0018_arb_self_types.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0019_unary_expr.rast b/crates/syntax/test_data/parser/inline/ok/0019_unary_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0019_unary_expr.rast rename to crates/syntax/test_data/parser/inline/ok/0019_unary_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0019_unary_expr.rs b/crates/syntax/test_data/parser/inline/ok/0019_unary_expr.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0019_unary_expr.rs rename to crates/syntax/test_data/parser/inline/ok/0019_unary_expr.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0020_use_star.rast b/crates/syntax/test_data/parser/inline/ok/0020_use_star.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0020_use_star.rast rename to crates/syntax/test_data/parser/inline/ok/0020_use_star.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0020_use_star.rs b/crates/syntax/test_data/parser/inline/ok/0020_use_star.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0020_use_star.rs rename to crates/syntax/test_data/parser/inline/ok/0020_use_star.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0021_impl_item_list.rast b/crates/syntax/test_data/parser/inline/ok/0021_impl_item_list.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0021_impl_item_list.rast rename to crates/syntax/test_data/parser/inline/ok/0021_impl_item_list.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0021_impl_item_list.rs b/crates/syntax/test_data/parser/inline/ok/0021_impl_item_list.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0021_impl_item_list.rs rename to crates/syntax/test_data/parser/inline/ok/0021_impl_item_list.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0022_crate_visibility.rast b/crates/syntax/test_data/parser/inline/ok/0022_crate_visibility.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0022_crate_visibility.rast rename to crates/syntax/test_data/parser/inline/ok/0022_crate_visibility.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0022_crate_visibility.rs b/crates/syntax/test_data/parser/inline/ok/0022_crate_visibility.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0022_crate_visibility.rs rename to crates/syntax/test_data/parser/inline/ok/0022_crate_visibility.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0023_placeholder_type.rast b/crates/syntax/test_data/parser/inline/ok/0023_placeholder_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0023_placeholder_type.rast rename to crates/syntax/test_data/parser/inline/ok/0023_placeholder_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0023_placeholder_type.rs b/crates/syntax/test_data/parser/inline/ok/0023_placeholder_type.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0023_placeholder_type.rs rename to crates/syntax/test_data/parser/inline/ok/0023_placeholder_type.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0024_slice_pat.rast b/crates/syntax/test_data/parser/inline/ok/0024_slice_pat.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0024_slice_pat.rast rename to crates/syntax/test_data/parser/inline/ok/0024_slice_pat.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0024_slice_pat.rs b/crates/syntax/test_data/parser/inline/ok/0024_slice_pat.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0024_slice_pat.rs rename to crates/syntax/test_data/parser/inline/ok/0024_slice_pat.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0025_slice_type.rast b/crates/syntax/test_data/parser/inline/ok/0025_slice_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0025_slice_type.rast rename to crates/syntax/test_data/parser/inline/ok/0025_slice_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0025_slice_type.rs b/crates/syntax/test_data/parser/inline/ok/0025_slice_type.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0025_slice_type.rs rename to crates/syntax/test_data/parser/inline/ok/0025_slice_type.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0026_tuple_pat_fields.rast b/crates/syntax/test_data/parser/inline/ok/0026_tuple_pat_fields.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0026_tuple_pat_fields.rast rename to crates/syntax/test_data/parser/inline/ok/0026_tuple_pat_fields.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0026_tuple_pat_fields.rs b/crates/syntax/test_data/parser/inline/ok/0026_tuple_pat_fields.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0026_tuple_pat_fields.rs rename to crates/syntax/test_data/parser/inline/ok/0026_tuple_pat_fields.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0027_ref_pat.rast b/crates/syntax/test_data/parser/inline/ok/0027_ref_pat.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0027_ref_pat.rast rename to crates/syntax/test_data/parser/inline/ok/0027_ref_pat.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0027_ref_pat.rs b/crates/syntax/test_data/parser/inline/ok/0027_ref_pat.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0027_ref_pat.rs rename to crates/syntax/test_data/parser/inline/ok/0027_ref_pat.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0028_impl_trait_type.rast b/crates/syntax/test_data/parser/inline/ok/0028_impl_trait_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0028_impl_trait_type.rast rename to crates/syntax/test_data/parser/inline/ok/0028_impl_trait_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0028_impl_trait_type.rs b/crates/syntax/test_data/parser/inline/ok/0028_impl_trait_type.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0028_impl_trait_type.rs rename to crates/syntax/test_data/parser/inline/ok/0028_impl_trait_type.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0029_cast_expr.rast b/crates/syntax/test_data/parser/inline/ok/0029_cast_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0029_cast_expr.rast rename to crates/syntax/test_data/parser/inline/ok/0029_cast_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0029_cast_expr.rs b/crates/syntax/test_data/parser/inline/ok/0029_cast_expr.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0029_cast_expr.rs rename to crates/syntax/test_data/parser/inline/ok/0029_cast_expr.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0030_cond.rast b/crates/syntax/test_data/parser/inline/ok/0030_cond.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0030_cond.rast rename to crates/syntax/test_data/parser/inline/ok/0030_cond.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0030_cond.rs b/crates/syntax/test_data/parser/inline/ok/0030_cond.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0030_cond.rs rename to crates/syntax/test_data/parser/inline/ok/0030_cond.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0031_while_expr.rast b/crates/syntax/test_data/parser/inline/ok/0031_while_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0031_while_expr.rast rename to crates/syntax/test_data/parser/inline/ok/0031_while_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0031_while_expr.rs b/crates/syntax/test_data/parser/inline/ok/0031_while_expr.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0031_while_expr.rs rename to crates/syntax/test_data/parser/inline/ok/0031_while_expr.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0032_fn_pointer_type.rast b/crates/syntax/test_data/parser/inline/ok/0032_fn_pointer_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0032_fn_pointer_type.rast rename to crates/syntax/test_data/parser/inline/ok/0032_fn_pointer_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0032_fn_pointer_type.rs b/crates/syntax/test_data/parser/inline/ok/0032_fn_pointer_type.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0032_fn_pointer_type.rs rename to crates/syntax/test_data/parser/inline/ok/0032_fn_pointer_type.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0033_reference_type;.rast b/crates/syntax/test_data/parser/inline/ok/0033_reference_type;.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0033_reference_type;.rast rename to crates/syntax/test_data/parser/inline/ok/0033_reference_type;.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0033_reference_type;.rs b/crates/syntax/test_data/parser/inline/ok/0033_reference_type;.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0033_reference_type;.rs rename to crates/syntax/test_data/parser/inline/ok/0033_reference_type;.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0034_break_expr.rast b/crates/syntax/test_data/parser/inline/ok/0034_break_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0034_break_expr.rast rename to crates/syntax/test_data/parser/inline/ok/0034_break_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0034_break_expr.rs b/crates/syntax/test_data/parser/inline/ok/0034_break_expr.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0034_break_expr.rs rename to crates/syntax/test_data/parser/inline/ok/0034_break_expr.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0037_qual_paths.rast b/crates/syntax/test_data/parser/inline/ok/0037_qual_paths.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0037_qual_paths.rast rename to crates/syntax/test_data/parser/inline/ok/0037_qual_paths.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0037_qual_paths.rs b/crates/syntax/test_data/parser/inline/ok/0037_qual_paths.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0037_qual_paths.rs rename to crates/syntax/test_data/parser/inline/ok/0037_qual_paths.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0038_full_range_expr.rast b/crates/syntax/test_data/parser/inline/ok/0038_full_range_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0038_full_range_expr.rast rename to crates/syntax/test_data/parser/inline/ok/0038_full_range_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0038_full_range_expr.rs b/crates/syntax/test_data/parser/inline/ok/0038_full_range_expr.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0038_full_range_expr.rs rename to crates/syntax/test_data/parser/inline/ok/0038_full_range_expr.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0039_type_arg.rast b/crates/syntax/test_data/parser/inline/ok/0039_type_arg.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0039_type_arg.rast rename to crates/syntax/test_data/parser/inline/ok/0039_type_arg.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0039_type_arg.rs b/crates/syntax/test_data/parser/inline/ok/0039_type_arg.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0039_type_arg.rs rename to crates/syntax/test_data/parser/inline/ok/0039_type_arg.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0040_crate_keyword_vis.rast b/crates/syntax/test_data/parser/inline/ok/0040_crate_keyword_vis.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0040_crate_keyword_vis.rast rename to crates/syntax/test_data/parser/inline/ok/0040_crate_keyword_vis.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0040_crate_keyword_vis.rs b/crates/syntax/test_data/parser/inline/ok/0040_crate_keyword_vis.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0040_crate_keyword_vis.rs rename to crates/syntax/test_data/parser/inline/ok/0040_crate_keyword_vis.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0041_trait_item.rast b/crates/syntax/test_data/parser/inline/ok/0041_trait_item.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0041_trait_item.rast rename to crates/syntax/test_data/parser/inline/ok/0041_trait_item.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0041_trait_item.rs b/crates/syntax/test_data/parser/inline/ok/0041_trait_item.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0041_trait_item.rs rename to crates/syntax/test_data/parser/inline/ok/0041_trait_item.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0042_call_expr.rast b/crates/syntax/test_data/parser/inline/ok/0042_call_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0042_call_expr.rast rename to crates/syntax/test_data/parser/inline/ok/0042_call_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0042_call_expr.rs b/crates/syntax/test_data/parser/inline/ok/0042_call_expr.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0042_call_expr.rs rename to crates/syntax/test_data/parser/inline/ok/0042_call_expr.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0043_use_alias.rast b/crates/syntax/test_data/parser/inline/ok/0043_use_alias.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0043_use_alias.rast rename to crates/syntax/test_data/parser/inline/ok/0043_use_alias.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0043_use_alias.rs b/crates/syntax/test_data/parser/inline/ok/0043_use_alias.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0043_use_alias.rs rename to crates/syntax/test_data/parser/inline/ok/0043_use_alias.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0044_block_items.rast b/crates/syntax/test_data/parser/inline/ok/0044_block_items.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0044_block_items.rast rename to crates/syntax/test_data/parser/inline/ok/0044_block_items.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0044_block_items.rs b/crates/syntax/test_data/parser/inline/ok/0044_block_items.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0044_block_items.rs rename to crates/syntax/test_data/parser/inline/ok/0044_block_items.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0045_param_list_opt_patterns.rast b/crates/syntax/test_data/parser/inline/ok/0045_param_list_opt_patterns.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0045_param_list_opt_patterns.rast rename to crates/syntax/test_data/parser/inline/ok/0045_param_list_opt_patterns.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0045_param_list_opt_patterns.rs b/crates/syntax/test_data/parser/inline/ok/0045_param_list_opt_patterns.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0045_param_list_opt_patterns.rs rename to crates/syntax/test_data/parser/inline/ok/0045_param_list_opt_patterns.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0046_singleton_tuple_type.rast b/crates/syntax/test_data/parser/inline/ok/0046_singleton_tuple_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0046_singleton_tuple_type.rast rename to crates/syntax/test_data/parser/inline/ok/0046_singleton_tuple_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0046_singleton_tuple_type.rs b/crates/syntax/test_data/parser/inline/ok/0046_singleton_tuple_type.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0046_singleton_tuple_type.rs rename to crates/syntax/test_data/parser/inline/ok/0046_singleton_tuple_type.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0048_path_type_with_bounds.rast b/crates/syntax/test_data/parser/inline/ok/0048_path_type_with_bounds.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0048_path_type_with_bounds.rast rename to crates/syntax/test_data/parser/inline/ok/0048_path_type_with_bounds.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0048_path_type_with_bounds.rs b/crates/syntax/test_data/parser/inline/ok/0048_path_type_with_bounds.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0048_path_type_with_bounds.rs rename to crates/syntax/test_data/parser/inline/ok/0048_path_type_with_bounds.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0050_fn_decl.rast b/crates/syntax/test_data/parser/inline/ok/0050_fn_decl.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0050_fn_decl.rast rename to crates/syntax/test_data/parser/inline/ok/0050_fn_decl.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0050_fn_decl.rs b/crates/syntax/test_data/parser/inline/ok/0050_fn_decl.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0050_fn_decl.rs rename to crates/syntax/test_data/parser/inline/ok/0050_fn_decl.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0051_unit_type.rast b/crates/syntax/test_data/parser/inline/ok/0051_unit_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0051_unit_type.rast rename to crates/syntax/test_data/parser/inline/ok/0051_unit_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0051_unit_type.rs b/crates/syntax/test_data/parser/inline/ok/0051_unit_type.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0051_unit_type.rs rename to crates/syntax/test_data/parser/inline/ok/0051_unit_type.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0052_path_type.rast b/crates/syntax/test_data/parser/inline/ok/0052_path_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0052_path_type.rast rename to crates/syntax/test_data/parser/inline/ok/0052_path_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0052_path_type.rs b/crates/syntax/test_data/parser/inline/ok/0052_path_type.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0052_path_type.rs rename to crates/syntax/test_data/parser/inline/ok/0052_path_type.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0053_path_expr.rast b/crates/syntax/test_data/parser/inline/ok/0053_path_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0053_path_expr.rast rename to crates/syntax/test_data/parser/inline/ok/0053_path_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0053_path_expr.rs b/crates/syntax/test_data/parser/inline/ok/0053_path_expr.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0053_path_expr.rs rename to crates/syntax/test_data/parser/inline/ok/0053_path_expr.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0054_record_field_attrs.rast b/crates/syntax/test_data/parser/inline/ok/0054_record_field_attrs.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0054_record_field_attrs.rast rename to crates/syntax/test_data/parser/inline/ok/0054_record_field_attrs.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0054_record_field_attrs.rs b/crates/syntax/test_data/parser/inline/ok/0054_record_field_attrs.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0054_record_field_attrs.rs rename to crates/syntax/test_data/parser/inline/ok/0054_record_field_attrs.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0055_literal_pattern.rast b/crates/syntax/test_data/parser/inline/ok/0055_literal_pattern.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0055_literal_pattern.rast rename to crates/syntax/test_data/parser/inline/ok/0055_literal_pattern.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0055_literal_pattern.rs b/crates/syntax/test_data/parser/inline/ok/0055_literal_pattern.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0055_literal_pattern.rs rename to crates/syntax/test_data/parser/inline/ok/0055_literal_pattern.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0056_where_clause.rast b/crates/syntax/test_data/parser/inline/ok/0056_where_clause.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0056_where_clause.rast rename to crates/syntax/test_data/parser/inline/ok/0056_where_clause.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0056_where_clause.rs b/crates/syntax/test_data/parser/inline/ok/0056_where_clause.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0056_where_clause.rs rename to crates/syntax/test_data/parser/inline/ok/0056_where_clause.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0058_range_pat.rast b/crates/syntax/test_data/parser/inline/ok/0058_range_pat.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0058_range_pat.rast rename to crates/syntax/test_data/parser/inline/ok/0058_range_pat.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0058_range_pat.rs b/crates/syntax/test_data/parser/inline/ok/0058_range_pat.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0058_range_pat.rs rename to crates/syntax/test_data/parser/inline/ok/0058_range_pat.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0059_match_arms_commas.rast b/crates/syntax/test_data/parser/inline/ok/0059_match_arms_commas.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0059_match_arms_commas.rast rename to crates/syntax/test_data/parser/inline/ok/0059_match_arms_commas.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0059_match_arms_commas.rs b/crates/syntax/test_data/parser/inline/ok/0059_match_arms_commas.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0059_match_arms_commas.rs rename to crates/syntax/test_data/parser/inline/ok/0059_match_arms_commas.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0060_extern_crate.rast b/crates/syntax/test_data/parser/inline/ok/0060_extern_crate.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0060_extern_crate.rast rename to crates/syntax/test_data/parser/inline/ok/0060_extern_crate.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0060_extern_crate.rs b/crates/syntax/test_data/parser/inline/ok/0060_extern_crate.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0060_extern_crate.rs rename to crates/syntax/test_data/parser/inline/ok/0060_extern_crate.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0061_record_lit.rast b/crates/syntax/test_data/parser/inline/ok/0061_record_lit.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0061_record_lit.rast rename to crates/syntax/test_data/parser/inline/ok/0061_record_lit.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0061_record_lit.rs b/crates/syntax/test_data/parser/inline/ok/0061_record_lit.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0061_record_lit.rs rename to crates/syntax/test_data/parser/inline/ok/0061_record_lit.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0062_mod_contents.rast b/crates/syntax/test_data/parser/inline/ok/0062_mod_contents.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0062_mod_contents.rast rename to crates/syntax/test_data/parser/inline/ok/0062_mod_contents.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0062_mod_contents.rs b/crates/syntax/test_data/parser/inline/ok/0062_mod_contents.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0062_mod_contents.rs rename to crates/syntax/test_data/parser/inline/ok/0062_mod_contents.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0063_impl_def_neg.rast b/crates/syntax/test_data/parser/inline/ok/0063_impl_def_neg.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0063_impl_def_neg.rast rename to crates/syntax/test_data/parser/inline/ok/0063_impl_def_neg.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0063_impl_def_neg.rs b/crates/syntax/test_data/parser/inline/ok/0063_impl_def_neg.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0063_impl_def_neg.rs rename to crates/syntax/test_data/parser/inline/ok/0063_impl_def_neg.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0064_if_expr.rast b/crates/syntax/test_data/parser/inline/ok/0064_if_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0064_if_expr.rast rename to crates/syntax/test_data/parser/inline/ok/0064_if_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0064_if_expr.rs b/crates/syntax/test_data/parser/inline/ok/0064_if_expr.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0064_if_expr.rs rename to crates/syntax/test_data/parser/inline/ok/0064_if_expr.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0065_dyn_trait_type.rast b/crates/syntax/test_data/parser/inline/ok/0065_dyn_trait_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0065_dyn_trait_type.rast rename to crates/syntax/test_data/parser/inline/ok/0065_dyn_trait_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0065_dyn_trait_type.rs b/crates/syntax/test_data/parser/inline/ok/0065_dyn_trait_type.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0065_dyn_trait_type.rs rename to crates/syntax/test_data/parser/inline/ok/0065_dyn_trait_type.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0066_match_arm.rast b/crates/syntax/test_data/parser/inline/ok/0066_match_arm.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0066_match_arm.rast rename to crates/syntax/test_data/parser/inline/ok/0066_match_arm.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0066_match_arm.rs b/crates/syntax/test_data/parser/inline/ok/0066_match_arm.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0066_match_arm.rs rename to crates/syntax/test_data/parser/inline/ok/0066_match_arm.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0067_crate_path.rast b/crates/syntax/test_data/parser/inline/ok/0067_crate_path.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0067_crate_path.rast rename to crates/syntax/test_data/parser/inline/ok/0067_crate_path.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0067_crate_path.rs b/crates/syntax/test_data/parser/inline/ok/0067_crate_path.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0067_crate_path.rs rename to crates/syntax/test_data/parser/inline/ok/0067_crate_path.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0068_union_items.rast b/crates/syntax/test_data/parser/inline/ok/0068_union_items.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0068_union_items.rast rename to crates/syntax/test_data/parser/inline/ok/0068_union_items.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0068_union_items.rs b/crates/syntax/test_data/parser/inline/ok/0068_union_items.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0068_union_items.rs rename to crates/syntax/test_data/parser/inline/ok/0068_union_items.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0069_use_tree_list_after_path.rast b/crates/syntax/test_data/parser/inline/ok/0069_use_tree_list_after_path.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0069_use_tree_list_after_path.rast rename to crates/syntax/test_data/parser/inline/ok/0069_use_tree_list_after_path.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0069_use_tree_list_after_path.rs b/crates/syntax/test_data/parser/inline/ok/0069_use_tree_list_after_path.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0069_use_tree_list_after_path.rs rename to crates/syntax/test_data/parser/inline/ok/0069_use_tree_list_after_path.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0070_stmt_bin_expr_ambiguity.rast b/crates/syntax/test_data/parser/inline/ok/0070_stmt_bin_expr_ambiguity.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0070_stmt_bin_expr_ambiguity.rast rename to crates/syntax/test_data/parser/inline/ok/0070_stmt_bin_expr_ambiguity.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0070_stmt_bin_expr_ambiguity.rs b/crates/syntax/test_data/parser/inline/ok/0070_stmt_bin_expr_ambiguity.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0070_stmt_bin_expr_ambiguity.rs rename to crates/syntax/test_data/parser/inline/ok/0070_stmt_bin_expr_ambiguity.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0071_match_expr.rast b/crates/syntax/test_data/parser/inline/ok/0071_match_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0071_match_expr.rast rename to crates/syntax/test_data/parser/inline/ok/0071_match_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0071_match_expr.rs b/crates/syntax/test_data/parser/inline/ok/0071_match_expr.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0071_match_expr.rs rename to crates/syntax/test_data/parser/inline/ok/0071_match_expr.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0072_return_expr.rast b/crates/syntax/test_data/parser/inline/ok/0072_return_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0072_return_expr.rast rename to crates/syntax/test_data/parser/inline/ok/0072_return_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0072_return_expr.rs b/crates/syntax/test_data/parser/inline/ok/0072_return_expr.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0072_return_expr.rs rename to crates/syntax/test_data/parser/inline/ok/0072_return_expr.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0073_type_item_type_params.rast b/crates/syntax/test_data/parser/inline/ok/0073_type_item_type_params.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0073_type_item_type_params.rast rename to crates/syntax/test_data/parser/inline/ok/0073_type_item_type_params.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0073_type_item_type_params.rs b/crates/syntax/test_data/parser/inline/ok/0073_type_item_type_params.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0073_type_item_type_params.rs rename to crates/syntax/test_data/parser/inline/ok/0073_type_item_type_params.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0074_stmt_postfix_expr_ambiguity.rast b/crates/syntax/test_data/parser/inline/ok/0074_stmt_postfix_expr_ambiguity.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0074_stmt_postfix_expr_ambiguity.rast rename to crates/syntax/test_data/parser/inline/ok/0074_stmt_postfix_expr_ambiguity.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0074_stmt_postfix_expr_ambiguity.rs b/crates/syntax/test_data/parser/inline/ok/0074_stmt_postfix_expr_ambiguity.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0074_stmt_postfix_expr_ambiguity.rs rename to crates/syntax/test_data/parser/inline/ok/0074_stmt_postfix_expr_ambiguity.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0075_block.rast b/crates/syntax/test_data/parser/inline/ok/0075_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0075_block.rast rename to crates/syntax/test_data/parser/inline/ok/0075_block.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0075_block.rs b/crates/syntax/test_data/parser/inline/ok/0075_block.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0075_block.rs rename to crates/syntax/test_data/parser/inline/ok/0075_block.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0076_function_where_clause.rast b/crates/syntax/test_data/parser/inline/ok/0076_function_where_clause.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0076_function_where_clause.rast rename to crates/syntax/test_data/parser/inline/ok/0076_function_where_clause.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0076_function_where_clause.rs b/crates/syntax/test_data/parser/inline/ok/0076_function_where_clause.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0076_function_where_clause.rs rename to crates/syntax/test_data/parser/inline/ok/0076_function_where_clause.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0077_try_expr.rast b/crates/syntax/test_data/parser/inline/ok/0077_try_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0077_try_expr.rast rename to crates/syntax/test_data/parser/inline/ok/0077_try_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0077_try_expr.rs b/crates/syntax/test_data/parser/inline/ok/0077_try_expr.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0077_try_expr.rs rename to crates/syntax/test_data/parser/inline/ok/0077_try_expr.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0078_type_item.rast b/crates/syntax/test_data/parser/inline/ok/0078_type_item.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0078_type_item.rast rename to crates/syntax/test_data/parser/inline/ok/0078_type_item.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0078_type_item.rs b/crates/syntax/test_data/parser/inline/ok/0078_type_item.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0078_type_item.rs rename to crates/syntax/test_data/parser/inline/ok/0078_type_item.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0079_impl_def.rast b/crates/syntax/test_data/parser/inline/ok/0079_impl_def.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0079_impl_def.rast rename to crates/syntax/test_data/parser/inline/ok/0079_impl_def.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0079_impl_def.rs b/crates/syntax/test_data/parser/inline/ok/0079_impl_def.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0079_impl_def.rs rename to crates/syntax/test_data/parser/inline/ok/0079_impl_def.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0080_postfix_range.rast b/crates/syntax/test_data/parser/inline/ok/0080_postfix_range.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0080_postfix_range.rast rename to crates/syntax/test_data/parser/inline/ok/0080_postfix_range.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0080_postfix_range.rs b/crates/syntax/test_data/parser/inline/ok/0080_postfix_range.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0080_postfix_range.rs rename to crates/syntax/test_data/parser/inline/ok/0080_postfix_range.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.rast b/crates/syntax/test_data/parser/inline/ok/0081_for_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.rast rename to crates/syntax/test_data/parser/inline/ok/0081_for_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.rs b/crates/syntax/test_data/parser/inline/ok/0081_for_type.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.rs rename to crates/syntax/test_data/parser/inline/ok/0081_for_type.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0082_ref_expr.rast b/crates/syntax/test_data/parser/inline/ok/0082_ref_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0082_ref_expr.rast rename to crates/syntax/test_data/parser/inline/ok/0082_ref_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0082_ref_expr.rs b/crates/syntax/test_data/parser/inline/ok/0082_ref_expr.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0082_ref_expr.rs rename to crates/syntax/test_data/parser/inline/ok/0082_ref_expr.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0083_struct_items.rast b/crates/syntax/test_data/parser/inline/ok/0083_struct_items.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0083_struct_items.rast rename to crates/syntax/test_data/parser/inline/ok/0083_struct_items.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0083_struct_items.rs b/crates/syntax/test_data/parser/inline/ok/0083_struct_items.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0083_struct_items.rs rename to crates/syntax/test_data/parser/inline/ok/0083_struct_items.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0084_paren_type.rast b/crates/syntax/test_data/parser/inline/ok/0084_paren_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0084_paren_type.rast rename to crates/syntax/test_data/parser/inline/ok/0084_paren_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0084_paren_type.rs b/crates/syntax/test_data/parser/inline/ok/0084_paren_type.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0084_paren_type.rs rename to crates/syntax/test_data/parser/inline/ok/0084_paren_type.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0085_expr_literals.rast b/crates/syntax/test_data/parser/inline/ok/0085_expr_literals.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0085_expr_literals.rast rename to crates/syntax/test_data/parser/inline/ok/0085_expr_literals.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0085_expr_literals.rs b/crates/syntax/test_data/parser/inline/ok/0085_expr_literals.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0085_expr_literals.rs rename to crates/syntax/test_data/parser/inline/ok/0085_expr_literals.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0086_function_ret_type.rast b/crates/syntax/test_data/parser/inline/ok/0086_function_ret_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0086_function_ret_type.rast rename to crates/syntax/test_data/parser/inline/ok/0086_function_ret_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0086_function_ret_type.rs b/crates/syntax/test_data/parser/inline/ok/0086_function_ret_type.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0086_function_ret_type.rs rename to crates/syntax/test_data/parser/inline/ok/0086_function_ret_type.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0088_break_ambiguity.rast b/crates/syntax/test_data/parser/inline/ok/0088_break_ambiguity.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0088_break_ambiguity.rast rename to crates/syntax/test_data/parser/inline/ok/0088_break_ambiguity.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0088_break_ambiguity.rs b/crates/syntax/test_data/parser/inline/ok/0088_break_ambiguity.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0088_break_ambiguity.rs rename to crates/syntax/test_data/parser/inline/ok/0088_break_ambiguity.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0090_type_param_default.rast b/crates/syntax/test_data/parser/inline/ok/0090_type_param_default.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0090_type_param_default.rast rename to crates/syntax/test_data/parser/inline/ok/0090_type_param_default.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0090_type_param_default.rs b/crates/syntax/test_data/parser/inline/ok/0090_type_param_default.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0090_type_param_default.rs rename to crates/syntax/test_data/parser/inline/ok/0090_type_param_default.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0092_fn_pointer_type_with_ret.rast b/crates/syntax/test_data/parser/inline/ok/0092_fn_pointer_type_with_ret.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0092_fn_pointer_type_with_ret.rast rename to crates/syntax/test_data/parser/inline/ok/0092_fn_pointer_type_with_ret.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0092_fn_pointer_type_with_ret.rs b/crates/syntax/test_data/parser/inline/ok/0092_fn_pointer_type_with_ret.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0092_fn_pointer_type_with_ret.rs rename to crates/syntax/test_data/parser/inline/ok/0092_fn_pointer_type_with_ret.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0093_index_expr.rast b/crates/syntax/test_data/parser/inline/ok/0093_index_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0093_index_expr.rast rename to crates/syntax/test_data/parser/inline/ok/0093_index_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0093_index_expr.rs b/crates/syntax/test_data/parser/inline/ok/0093_index_expr.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0093_index_expr.rs rename to crates/syntax/test_data/parser/inline/ok/0093_index_expr.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0095_placeholder_pat.rast b/crates/syntax/test_data/parser/inline/ok/0095_placeholder_pat.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0095_placeholder_pat.rast rename to crates/syntax/test_data/parser/inline/ok/0095_placeholder_pat.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0095_placeholder_pat.rs b/crates/syntax/test_data/parser/inline/ok/0095_placeholder_pat.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0095_placeholder_pat.rs rename to crates/syntax/test_data/parser/inline/ok/0095_placeholder_pat.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0096_no_semi_after_block.rast b/crates/syntax/test_data/parser/inline/ok/0096_no_semi_after_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0096_no_semi_after_block.rast rename to crates/syntax/test_data/parser/inline/ok/0096_no_semi_after_block.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0096_no_semi_after_block.rs b/crates/syntax/test_data/parser/inline/ok/0096_no_semi_after_block.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0096_no_semi_after_block.rs rename to crates/syntax/test_data/parser/inline/ok/0096_no_semi_after_block.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0099_param_list.rast b/crates/syntax/test_data/parser/inline/ok/0099_param_list.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0099_param_list.rast rename to crates/syntax/test_data/parser/inline/ok/0099_param_list.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0099_param_list.rs b/crates/syntax/test_data/parser/inline/ok/0099_param_list.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0099_param_list.rs rename to crates/syntax/test_data/parser/inline/ok/0099_param_list.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0100_for_expr.rast b/crates/syntax/test_data/parser/inline/ok/0100_for_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0100_for_expr.rast rename to crates/syntax/test_data/parser/inline/ok/0100_for_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0100_for_expr.rs b/crates/syntax/test_data/parser/inline/ok/0100_for_expr.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0100_for_expr.rs rename to crates/syntax/test_data/parser/inline/ok/0100_for_expr.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0102_record_field_pat_list.rast b/crates/syntax/test_data/parser/inline/ok/0102_record_field_pat_list.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0102_record_field_pat_list.rast rename to crates/syntax/test_data/parser/inline/ok/0102_record_field_pat_list.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0102_record_field_pat_list.rs b/crates/syntax/test_data/parser/inline/ok/0102_record_field_pat_list.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0102_record_field_pat_list.rs rename to crates/syntax/test_data/parser/inline/ok/0102_record_field_pat_list.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0103_array_expr.rast b/crates/syntax/test_data/parser/inline/ok/0103_array_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0103_array_expr.rast rename to crates/syntax/test_data/parser/inline/ok/0103_array_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0103_array_expr.rs b/crates/syntax/test_data/parser/inline/ok/0103_array_expr.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0103_array_expr.rs rename to crates/syntax/test_data/parser/inline/ok/0103_array_expr.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0104_path_fn_trait_args.rast b/crates/syntax/test_data/parser/inline/ok/0104_path_fn_trait_args.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0104_path_fn_trait_args.rast rename to crates/syntax/test_data/parser/inline/ok/0104_path_fn_trait_args.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0104_path_fn_trait_args.rs b/crates/syntax/test_data/parser/inline/ok/0104_path_fn_trait_args.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0104_path_fn_trait_args.rs rename to crates/syntax/test_data/parser/inline/ok/0104_path_fn_trait_args.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0106_lambda_expr.rast b/crates/syntax/test_data/parser/inline/ok/0106_lambda_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0106_lambda_expr.rast rename to crates/syntax/test_data/parser/inline/ok/0106_lambda_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0106_lambda_expr.rs b/crates/syntax/test_data/parser/inline/ok/0106_lambda_expr.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0106_lambda_expr.rs rename to crates/syntax/test_data/parser/inline/ok/0106_lambda_expr.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0107_method_call_expr.rast b/crates/syntax/test_data/parser/inline/ok/0107_method_call_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0107_method_call_expr.rast rename to crates/syntax/test_data/parser/inline/ok/0107_method_call_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0107_method_call_expr.rs b/crates/syntax/test_data/parser/inline/ok/0107_method_call_expr.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0107_method_call_expr.rs rename to crates/syntax/test_data/parser/inline/ok/0107_method_call_expr.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0108_tuple_expr.rast b/crates/syntax/test_data/parser/inline/ok/0108_tuple_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0108_tuple_expr.rast rename to crates/syntax/test_data/parser/inline/ok/0108_tuple_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0108_tuple_expr.rs b/crates/syntax/test_data/parser/inline/ok/0108_tuple_expr.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0108_tuple_expr.rs rename to crates/syntax/test_data/parser/inline/ok/0108_tuple_expr.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0109_label.rast b/crates/syntax/test_data/parser/inline/ok/0109_label.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0109_label.rast rename to crates/syntax/test_data/parser/inline/ok/0109_label.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0109_label.rs b/crates/syntax/test_data/parser/inline/ok/0109_label.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0109_label.rs rename to crates/syntax/test_data/parser/inline/ok/0109_label.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0110_use_path.rast b/crates/syntax/test_data/parser/inline/ok/0110_use_path.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0110_use_path.rast rename to crates/syntax/test_data/parser/inline/ok/0110_use_path.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0110_use_path.rs b/crates/syntax/test_data/parser/inline/ok/0110_use_path.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0110_use_path.rs rename to crates/syntax/test_data/parser/inline/ok/0110_use_path.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0111_tuple_pat.rast b/crates/syntax/test_data/parser/inline/ok/0111_tuple_pat.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0111_tuple_pat.rast rename to crates/syntax/test_data/parser/inline/ok/0111_tuple_pat.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0111_tuple_pat.rs b/crates/syntax/test_data/parser/inline/ok/0111_tuple_pat.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0111_tuple_pat.rs rename to crates/syntax/test_data/parser/inline/ok/0111_tuple_pat.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0112_bind_pat.rast b/crates/syntax/test_data/parser/inline/ok/0112_bind_pat.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0112_bind_pat.rast rename to crates/syntax/test_data/parser/inline/ok/0112_bind_pat.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0112_bind_pat.rs b/crates/syntax/test_data/parser/inline/ok/0112_bind_pat.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0112_bind_pat.rs rename to crates/syntax/test_data/parser/inline/ok/0112_bind_pat.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0113_nocontentexpr.rast b/crates/syntax/test_data/parser/inline/ok/0113_nocontentexpr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0113_nocontentexpr.rast rename to crates/syntax/test_data/parser/inline/ok/0113_nocontentexpr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0113_nocontentexpr.rs b/crates/syntax/test_data/parser/inline/ok/0113_nocontentexpr.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0113_nocontentexpr.rs rename to crates/syntax/test_data/parser/inline/ok/0113_nocontentexpr.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0114_tuple_struct_where.rast b/crates/syntax/test_data/parser/inline/ok/0114_tuple_struct_where.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0114_tuple_struct_where.rast rename to crates/syntax/test_data/parser/inline/ok/0114_tuple_struct_where.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0114_tuple_struct_where.rs b/crates/syntax/test_data/parser/inline/ok/0114_tuple_struct_where.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0114_tuple_struct_where.rs rename to crates/syntax/test_data/parser/inline/ok/0114_tuple_struct_where.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0115_tuple_field_attrs.rast b/crates/syntax/test_data/parser/inline/ok/0115_tuple_field_attrs.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0115_tuple_field_attrs.rast rename to crates/syntax/test_data/parser/inline/ok/0115_tuple_field_attrs.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0115_tuple_field_attrs.rs b/crates/syntax/test_data/parser/inline/ok/0115_tuple_field_attrs.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0115_tuple_field_attrs.rs rename to crates/syntax/test_data/parser/inline/ok/0115_tuple_field_attrs.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0117_macro_call_type.rast b/crates/syntax/test_data/parser/inline/ok/0117_macro_call_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0117_macro_call_type.rast rename to crates/syntax/test_data/parser/inline/ok/0117_macro_call_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0117_macro_call_type.rs b/crates/syntax/test_data/parser/inline/ok/0117_macro_call_type.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0117_macro_call_type.rs rename to crates/syntax/test_data/parser/inline/ok/0117_macro_call_type.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.rast b/crates/syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.rast rename to crates/syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.rs b/crates/syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.rs rename to crates/syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0118_match_guard.rast b/crates/syntax/test_data/parser/inline/ok/0118_match_guard.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0118_match_guard.rast rename to crates/syntax/test_data/parser/inline/ok/0118_match_guard.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0118_match_guard.rs b/crates/syntax/test_data/parser/inline/ok/0118_match_guard.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0118_match_guard.rs rename to crates/syntax/test_data/parser/inline/ok/0118_match_guard.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0120_match_arms_inner_attribute.rast b/crates/syntax/test_data/parser/inline/ok/0120_match_arms_inner_attribute.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0120_match_arms_inner_attribute.rast rename to crates/syntax/test_data/parser/inline/ok/0120_match_arms_inner_attribute.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0120_match_arms_inner_attribute.rs b/crates/syntax/test_data/parser/inline/ok/0120_match_arms_inner_attribute.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0120_match_arms_inner_attribute.rs rename to crates/syntax/test_data/parser/inline/ok/0120_match_arms_inner_attribute.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0121_match_arms_outer_attributes.rast b/crates/syntax/test_data/parser/inline/ok/0121_match_arms_outer_attributes.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0121_match_arms_outer_attributes.rast rename to crates/syntax/test_data/parser/inline/ok/0121_match_arms_outer_attributes.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0121_match_arms_outer_attributes.rs b/crates/syntax/test_data/parser/inline/ok/0121_match_arms_outer_attributes.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0121_match_arms_outer_attributes.rs rename to crates/syntax/test_data/parser/inline/ok/0121_match_arms_outer_attributes.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0122_generic_lifetime_type_attribute.rast b/crates/syntax/test_data/parser/inline/ok/0122_generic_lifetime_type_attribute.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0122_generic_lifetime_type_attribute.rast rename to crates/syntax/test_data/parser/inline/ok/0122_generic_lifetime_type_attribute.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0122_generic_lifetime_type_attribute.rs b/crates/syntax/test_data/parser/inline/ok/0122_generic_lifetime_type_attribute.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0122_generic_lifetime_type_attribute.rs rename to crates/syntax/test_data/parser/inline/ok/0122_generic_lifetime_type_attribute.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0123_param_list_vararg.rast b/crates/syntax/test_data/parser/inline/ok/0123_param_list_vararg.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0123_param_list_vararg.rast rename to crates/syntax/test_data/parser/inline/ok/0123_param_list_vararg.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0123_param_list_vararg.rs b/crates/syntax/test_data/parser/inline/ok/0123_param_list_vararg.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0123_param_list_vararg.rs rename to crates/syntax/test_data/parser/inline/ok/0123_param_list_vararg.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0125_crate_keyword_path.rast b/crates/syntax/test_data/parser/inline/ok/0125_crate_keyword_path.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0125_crate_keyword_path.rast rename to crates/syntax/test_data/parser/inline/ok/0125_crate_keyword_path.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0125_crate_keyword_path.rs b/crates/syntax/test_data/parser/inline/ok/0125_crate_keyword_path.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0125_crate_keyword_path.rs rename to crates/syntax/test_data/parser/inline/ok/0125_crate_keyword_path.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0125_record_literal_field_with_attr.rast b/crates/syntax/test_data/parser/inline/ok/0125_record_literal_field_with_attr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0125_record_literal_field_with_attr.rast rename to crates/syntax/test_data/parser/inline/ok/0125_record_literal_field_with_attr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0125_record_literal_field_with_attr.rs b/crates/syntax/test_data/parser/inline/ok/0125_record_literal_field_with_attr.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0125_record_literal_field_with_attr.rs rename to crates/syntax/test_data/parser/inline/ok/0125_record_literal_field_with_attr.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0126_attr_on_expr_stmt.rast b/crates/syntax/test_data/parser/inline/ok/0126_attr_on_expr_stmt.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0126_attr_on_expr_stmt.rast rename to crates/syntax/test_data/parser/inline/ok/0126_attr_on_expr_stmt.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0126_attr_on_expr_stmt.rs b/crates/syntax/test_data/parser/inline/ok/0126_attr_on_expr_stmt.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0126_attr_on_expr_stmt.rs rename to crates/syntax/test_data/parser/inline/ok/0126_attr_on_expr_stmt.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0127_attr_on_last_expr_in_block.rast b/crates/syntax/test_data/parser/inline/ok/0127_attr_on_last_expr_in_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0127_attr_on_last_expr_in_block.rast rename to crates/syntax/test_data/parser/inline/ok/0127_attr_on_last_expr_in_block.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0127_attr_on_last_expr_in_block.rs b/crates/syntax/test_data/parser/inline/ok/0127_attr_on_last_expr_in_block.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0127_attr_on_last_expr_in_block.rs rename to crates/syntax/test_data/parser/inline/ok/0127_attr_on_last_expr_in_block.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0129_marco_pat.rast b/crates/syntax/test_data/parser/inline/ok/0129_marco_pat.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0129_marco_pat.rast rename to crates/syntax/test_data/parser/inline/ok/0129_marco_pat.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0129_marco_pat.rs b/crates/syntax/test_data/parser/inline/ok/0129_marco_pat.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0129_marco_pat.rs rename to crates/syntax/test_data/parser/inline/ok/0129_marco_pat.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0130_let_stmt.rast b/crates/syntax/test_data/parser/inline/ok/0130_let_stmt.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0130_let_stmt.rast rename to crates/syntax/test_data/parser/inline/ok/0130_let_stmt.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0130_let_stmt.rs b/crates/syntax/test_data/parser/inline/ok/0130_let_stmt.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0130_let_stmt.rs rename to crates/syntax/test_data/parser/inline/ok/0130_let_stmt.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0130_try_block_expr.rast b/crates/syntax/test_data/parser/inline/ok/0130_try_block_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0130_try_block_expr.rast rename to crates/syntax/test_data/parser/inline/ok/0130_try_block_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0130_try_block_expr.rs b/crates/syntax/test_data/parser/inline/ok/0130_try_block_expr.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0130_try_block_expr.rs rename to crates/syntax/test_data/parser/inline/ok/0130_try_block_expr.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0131_existential_type.rast b/crates/syntax/test_data/parser/inline/ok/0131_existential_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0131_existential_type.rast rename to crates/syntax/test_data/parser/inline/ok/0131_existential_type.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0131_existential_type.rs b/crates/syntax/test_data/parser/inline/ok/0131_existential_type.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0131_existential_type.rs rename to crates/syntax/test_data/parser/inline/ok/0131_existential_type.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0132_box_expr.rast b/crates/syntax/test_data/parser/inline/ok/0132_box_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0132_box_expr.rast rename to crates/syntax/test_data/parser/inline/ok/0132_box_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0132_box_expr.rs b/crates/syntax/test_data/parser/inline/ok/0132_box_expr.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0132_box_expr.rs rename to crates/syntax/test_data/parser/inline/ok/0132_box_expr.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0134_nocontentexpr_after_item.rast b/crates/syntax/test_data/parser/inline/ok/0134_nocontentexpr_after_item.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0134_nocontentexpr_after_item.rast rename to crates/syntax/test_data/parser/inline/ok/0134_nocontentexpr_after_item.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0134_nocontentexpr_after_item.rs b/crates/syntax/test_data/parser/inline/ok/0134_nocontentexpr_after_item.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0134_nocontentexpr_after_item.rs rename to crates/syntax/test_data/parser/inline/ok/0134_nocontentexpr_after_item.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0137_await_expr.rast b/crates/syntax/test_data/parser/inline/ok/0137_await_expr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0137_await_expr.rast rename to crates/syntax/test_data/parser/inline/ok/0137_await_expr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0137_await_expr.rs b/crates/syntax/test_data/parser/inline/ok/0137_await_expr.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0137_await_expr.rs rename to crates/syntax/test_data/parser/inline/ok/0137_await_expr.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0138_associated_type_bounds.rast b/crates/syntax/test_data/parser/inline/ok/0138_associated_type_bounds.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0138_associated_type_bounds.rast rename to crates/syntax/test_data/parser/inline/ok/0138_associated_type_bounds.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0138_associated_type_bounds.rs b/crates/syntax/test_data/parser/inline/ok/0138_associated_type_bounds.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0138_associated_type_bounds.rs rename to crates/syntax/test_data/parser/inline/ok/0138_associated_type_bounds.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0138_expression_after_block.rast b/crates/syntax/test_data/parser/inline/ok/0138_expression_after_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0138_expression_after_block.rast rename to crates/syntax/test_data/parser/inline/ok/0138_expression_after_block.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0138_expression_after_block.rs b/crates/syntax/test_data/parser/inline/ok/0138_expression_after_block.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0138_expression_after_block.rs rename to crates/syntax/test_data/parser/inline/ok/0138_expression_after_block.rs diff --git a/crates/ra_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 similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0138_self_param_outer_attr.rast rename to crates/syntax/test_data/parser/inline/ok/0138_self_param_outer_attr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0138_self_param_outer_attr.rs b/crates/syntax/test_data/parser/inline/ok/0138_self_param_outer_attr.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0138_self_param_outer_attr.rs rename to crates/syntax/test_data/parser/inline/ok/0138_self_param_outer_attr.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0139_param_outer_arg.rast b/crates/syntax/test_data/parser/inline/ok/0139_param_outer_arg.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0139_param_outer_arg.rast rename to crates/syntax/test_data/parser/inline/ok/0139_param_outer_arg.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0139_param_outer_arg.rs b/crates/syntax/test_data/parser/inline/ok/0139_param_outer_arg.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0139_param_outer_arg.rs rename to crates/syntax/test_data/parser/inline/ok/0139_param_outer_arg.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0142_for_range_from.rast b/crates/syntax/test_data/parser/inline/ok/0142_for_range_from.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0142_for_range_from.rast rename to crates/syntax/test_data/parser/inline/ok/0142_for_range_from.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0142_for_range_from.rs b/crates/syntax/test_data/parser/inline/ok/0142_for_range_from.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0142_for_range_from.rs rename to crates/syntax/test_data/parser/inline/ok/0142_for_range_from.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0143_box_pat.rast b/crates/syntax/test_data/parser/inline/ok/0143_box_pat.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0143_box_pat.rast rename to crates/syntax/test_data/parser/inline/ok/0143_box_pat.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0143_box_pat.rs b/crates/syntax/test_data/parser/inline/ok/0143_box_pat.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0143_box_pat.rs rename to crates/syntax/test_data/parser/inline/ok/0143_box_pat.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0144_dot_dot_pat.rast b/crates/syntax/test_data/parser/inline/ok/0144_dot_dot_pat.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0144_dot_dot_pat.rast rename to crates/syntax/test_data/parser/inline/ok/0144_dot_dot_pat.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0144_dot_dot_pat.rs b/crates/syntax/test_data/parser/inline/ok/0144_dot_dot_pat.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0144_dot_dot_pat.rs rename to crates/syntax/test_data/parser/inline/ok/0144_dot_dot_pat.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0145_record_field_pat.rast b/crates/syntax/test_data/parser/inline/ok/0145_record_field_pat.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0145_record_field_pat.rast rename to crates/syntax/test_data/parser/inline/ok/0145_record_field_pat.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0145_record_field_pat.rs b/crates/syntax/test_data/parser/inline/ok/0145_record_field_pat.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0145_record_field_pat.rs rename to crates/syntax/test_data/parser/inline/ok/0145_record_field_pat.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0146_as_precedence.rast b/crates/syntax/test_data/parser/inline/ok/0146_as_precedence.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0146_as_precedence.rast rename to crates/syntax/test_data/parser/inline/ok/0146_as_precedence.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0146_as_precedence.rs b/crates/syntax/test_data/parser/inline/ok/0146_as_precedence.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0146_as_precedence.rs rename to crates/syntax/test_data/parser/inline/ok/0146_as_precedence.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0147_const_param.rast b/crates/syntax/test_data/parser/inline/ok/0147_const_param.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0147_const_param.rast rename to crates/syntax/test_data/parser/inline/ok/0147_const_param.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0147_const_param.rs b/crates/syntax/test_data/parser/inline/ok/0147_const_param.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0147_const_param.rs rename to crates/syntax/test_data/parser/inline/ok/0147_const_param.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0147_macro_def.rast b/crates/syntax/test_data/parser/inline/ok/0147_macro_def.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0147_macro_def.rast rename to crates/syntax/test_data/parser/inline/ok/0147_macro_def.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0147_macro_def.rs b/crates/syntax/test_data/parser/inline/ok/0147_macro_def.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0147_macro_def.rs rename to crates/syntax/test_data/parser/inline/ok/0147_macro_def.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0148_pub_macro_def.rast b/crates/syntax/test_data/parser/inline/ok/0148_pub_macro_def.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0148_pub_macro_def.rast rename to crates/syntax/test_data/parser/inline/ok/0148_pub_macro_def.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0148_pub_macro_def.rs b/crates/syntax/test_data/parser/inline/ok/0148_pub_macro_def.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0148_pub_macro_def.rs rename to crates/syntax/test_data/parser/inline/ok/0148_pub_macro_def.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0150_array_attrs.rast b/crates/syntax/test_data/parser/inline/ok/0150_array_attrs.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0150_array_attrs.rast rename to crates/syntax/test_data/parser/inline/ok/0150_array_attrs.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0150_array_attrs.rs b/crates/syntax/test_data/parser/inline/ok/0150_array_attrs.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0150_array_attrs.rs rename to crates/syntax/test_data/parser/inline/ok/0150_array_attrs.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0150_impl_type_params.rast b/crates/syntax/test_data/parser/inline/ok/0150_impl_type_params.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0150_impl_type_params.rast rename to crates/syntax/test_data/parser/inline/ok/0150_impl_type_params.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0150_impl_type_params.rs b/crates/syntax/test_data/parser/inline/ok/0150_impl_type_params.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0150_impl_type_params.rs rename to crates/syntax/test_data/parser/inline/ok/0150_impl_type_params.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0151_fn.rast b/crates/syntax/test_data/parser/inline/ok/0151_fn.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0151_fn.rast rename to crates/syntax/test_data/parser/inline/ok/0151_fn.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0151_fn.rs b/crates/syntax/test_data/parser/inline/ok/0151_fn.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0151_fn.rs rename to crates/syntax/test_data/parser/inline/ok/0151_fn.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0151_trait_alias.rast b/crates/syntax/test_data/parser/inline/ok/0151_trait_alias.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0151_trait_alias.rast rename to crates/syntax/test_data/parser/inline/ok/0151_trait_alias.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0151_trait_alias.rs b/crates/syntax/test_data/parser/inline/ok/0151_trait_alias.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0151_trait_alias.rs rename to crates/syntax/test_data/parser/inline/ok/0151_trait_alias.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0152_arg_with_attr.rast b/crates/syntax/test_data/parser/inline/ok/0152_arg_with_attr.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0152_arg_with_attr.rast rename to crates/syntax/test_data/parser/inline/ok/0152_arg_with_attr.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0152_arg_with_attr.rs b/crates/syntax/test_data/parser/inline/ok/0152_arg_with_attr.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0152_arg_with_attr.rs rename to crates/syntax/test_data/parser/inline/ok/0152_arg_with_attr.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0152_impl.rast b/crates/syntax/test_data/parser/inline/ok/0152_impl.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0152_impl.rast rename to crates/syntax/test_data/parser/inline/ok/0152_impl.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0152_impl.rs b/crates/syntax/test_data/parser/inline/ok/0152_impl.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0152_impl.rs rename to crates/syntax/test_data/parser/inline/ok/0152_impl.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0153_trait.rast b/crates/syntax/test_data/parser/inline/ok/0153_trait.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0153_trait.rast rename to crates/syntax/test_data/parser/inline/ok/0153_trait.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0153_trait.rs b/crates/syntax/test_data/parser/inline/ok/0153_trait.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0153_trait.rs rename to crates/syntax/test_data/parser/inline/ok/0153_trait.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0154_fn_pointer_param_ident_path.rast b/crates/syntax/test_data/parser/inline/ok/0154_fn_pointer_param_ident_path.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0154_fn_pointer_param_ident_path.rast rename to crates/syntax/test_data/parser/inline/ok/0154_fn_pointer_param_ident_path.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0154_fn_pointer_param_ident_path.rs b/crates/syntax/test_data/parser/inline/ok/0154_fn_pointer_param_ident_path.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0154_fn_pointer_param_ident_path.rs rename to crates/syntax/test_data/parser/inline/ok/0154_fn_pointer_param_ident_path.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0155_closure_params.rast b/crates/syntax/test_data/parser/inline/ok/0155_closure_params.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0155_closure_params.rast rename to crates/syntax/test_data/parser/inline/ok/0155_closure_params.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0155_closure_params.rs b/crates/syntax/test_data/parser/inline/ok/0155_closure_params.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0155_closure_params.rs rename to crates/syntax/test_data/parser/inline/ok/0155_closure_params.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0156_fn_def_param.rast b/crates/syntax/test_data/parser/inline/ok/0156_fn_def_param.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0156_fn_def_param.rast rename to crates/syntax/test_data/parser/inline/ok/0156_fn_def_param.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0156_fn_def_param.rs b/crates/syntax/test_data/parser/inline/ok/0156_fn_def_param.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0156_fn_def_param.rs rename to crates/syntax/test_data/parser/inline/ok/0156_fn_def_param.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0156_or_pattern.rast b/crates/syntax/test_data/parser/inline/ok/0156_or_pattern.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0156_or_pattern.rast rename to crates/syntax/test_data/parser/inline/ok/0156_or_pattern.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0156_or_pattern.rs b/crates/syntax/test_data/parser/inline/ok/0156_or_pattern.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0156_or_pattern.rs rename to crates/syntax/test_data/parser/inline/ok/0156_or_pattern.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0157_fn_pointer_unnamed_arg.rast b/crates/syntax/test_data/parser/inline/ok/0157_fn_pointer_unnamed_arg.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0157_fn_pointer_unnamed_arg.rast rename to crates/syntax/test_data/parser/inline/ok/0157_fn_pointer_unnamed_arg.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0157_fn_pointer_unnamed_arg.rs b/crates/syntax/test_data/parser/inline/ok/0157_fn_pointer_unnamed_arg.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0157_fn_pointer_unnamed_arg.rs rename to crates/syntax/test_data/parser/inline/ok/0157_fn_pointer_unnamed_arg.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0157_variant_discriminant.rast b/crates/syntax/test_data/parser/inline/ok/0157_variant_discriminant.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0157_variant_discriminant.rast rename to crates/syntax/test_data/parser/inline/ok/0157_variant_discriminant.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0157_variant_discriminant.rs b/crates/syntax/test_data/parser/inline/ok/0157_variant_discriminant.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0157_variant_discriminant.rs rename to crates/syntax/test_data/parser/inline/ok/0157_variant_discriminant.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0158_binop_resets_statementness.rast b/crates/syntax/test_data/parser/inline/ok/0158_binop_resets_statementness.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0158_binop_resets_statementness.rast rename to crates/syntax/test_data/parser/inline/ok/0158_binop_resets_statementness.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0158_binop_resets_statementness.rs b/crates/syntax/test_data/parser/inline/ok/0158_binop_resets_statementness.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0158_binop_resets_statementness.rs rename to crates/syntax/test_data/parser/inline/ok/0158_binop_resets_statementness.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0158_lambda_ret_block.rast b/crates/syntax/test_data/parser/inline/ok/0158_lambda_ret_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0158_lambda_ret_block.rast rename to crates/syntax/test_data/parser/inline/ok/0158_lambda_ret_block.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0158_lambda_ret_block.rs b/crates/syntax/test_data/parser/inline/ok/0158_lambda_ret_block.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0158_lambda_ret_block.rs rename to crates/syntax/test_data/parser/inline/ok/0158_lambda_ret_block.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0159_try_macro_fallback.rast b/crates/syntax/test_data/parser/inline/ok/0159_try_macro_fallback.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0159_try_macro_fallback.rast rename to crates/syntax/test_data/parser/inline/ok/0159_try_macro_fallback.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0159_try_macro_fallback.rs b/crates/syntax/test_data/parser/inline/ok/0159_try_macro_fallback.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0159_try_macro_fallback.rs rename to crates/syntax/test_data/parser/inline/ok/0159_try_macro_fallback.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0160_try_macro_rules.rast b/crates/syntax/test_data/parser/inline/ok/0160_try_macro_rules.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0160_try_macro_rules.rast rename to crates/syntax/test_data/parser/inline/ok/0160_try_macro_rules.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0160_try_macro_rules.rs b/crates/syntax/test_data/parser/inline/ok/0160_try_macro_rules.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0160_try_macro_rules.rs rename to crates/syntax/test_data/parser/inline/ok/0160_try_macro_rules.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0161_labeled_block.rast b/crates/syntax/test_data/parser/inline/ok/0161_labeled_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0161_labeled_block.rast rename to crates/syntax/test_data/parser/inline/ok/0161_labeled_block.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0161_labeled_block.rs b/crates/syntax/test_data/parser/inline/ok/0161_labeled_block.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0161_labeled_block.rs rename to crates/syntax/test_data/parser/inline/ok/0161_labeled_block.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0162_unsafe_block.rast b/crates/syntax/test_data/parser/inline/ok/0162_unsafe_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0162_unsafe_block.rast rename to crates/syntax/test_data/parser/inline/ok/0162_unsafe_block.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0162_unsafe_block.rs b/crates/syntax/test_data/parser/inline/ok/0162_unsafe_block.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0162_unsafe_block.rs rename to crates/syntax/test_data/parser/inline/ok/0162_unsafe_block.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_item.rast b/crates/syntax/test_data/parser/inline/ok/0163_default_unsafe_item.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_item.rast rename to crates/syntax/test_data/parser/inline/ok/0163_default_unsafe_item.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_item.rs b/crates/syntax/test_data/parser/inline/ok/0163_default_unsafe_item.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0163_default_unsafe_item.rs rename to crates/syntax/test_data/parser/inline/ok/0163_default_unsafe_item.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0164_default_item.rast b/crates/syntax/test_data/parser/inline/ok/0164_default_item.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0164_default_item.rast rename to crates/syntax/test_data/parser/inline/ok/0164_default_item.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0164_default_item.rs b/crates/syntax/test_data/parser/inline/ok/0164_default_item.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0164_default_item.rs rename to crates/syntax/test_data/parser/inline/ok/0164_default_item.rs diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0164_type_path_in_pattern.rast b/crates/syntax/test_data/parser/inline/ok/0164_type_path_in_pattern.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0164_type_path_in_pattern.rast rename to crates/syntax/test_data/parser/inline/ok/0164_type_path_in_pattern.rast diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0164_type_path_in_pattern.rs b/crates/syntax/test_data/parser/inline/ok/0164_type_path_in_pattern.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/inline/ok/0164_type_path_in_pattern.rs rename to crates/syntax/test_data/parser/inline/ok/0164_type_path_in_pattern.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0000_empty.rast b/crates/syntax/test_data/parser/ok/0000_empty.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0000_empty.rast rename to crates/syntax/test_data/parser/ok/0000_empty.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0000_empty.rs b/crates/syntax/test_data/parser/ok/0000_empty.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0000_empty.rs rename to crates/syntax/test_data/parser/ok/0000_empty.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0001_struct_item.rast b/crates/syntax/test_data/parser/ok/0001_struct_item.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0001_struct_item.rast rename to crates/syntax/test_data/parser/ok/0001_struct_item.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0001_struct_item.rs b/crates/syntax/test_data/parser/ok/0001_struct_item.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0001_struct_item.rs rename to crates/syntax/test_data/parser/ok/0001_struct_item.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0002_struct_item_field.rast b/crates/syntax/test_data/parser/ok/0002_struct_item_field.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0002_struct_item_field.rast rename to crates/syntax/test_data/parser/ok/0002_struct_item_field.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0002_struct_item_field.rs b/crates/syntax/test_data/parser/ok/0002_struct_item_field.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0002_struct_item_field.rs rename to crates/syntax/test_data/parser/ok/0002_struct_item_field.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0004_file_shebang.rast b/crates/syntax/test_data/parser/ok/0004_file_shebang.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0004_file_shebang.rast rename to crates/syntax/test_data/parser/ok/0004_file_shebang.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0004_file_shebang.rs b/crates/syntax/test_data/parser/ok/0004_file_shebang.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0004_file_shebang.rs rename to crates/syntax/test_data/parser/ok/0004_file_shebang.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0005_fn_item.rast b/crates/syntax/test_data/parser/ok/0005_fn_item.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0005_fn_item.rast rename to crates/syntax/test_data/parser/ok/0005_fn_item.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0005_fn_item.rs b/crates/syntax/test_data/parser/ok/0005_fn_item.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0005_fn_item.rs rename to crates/syntax/test_data/parser/ok/0005_fn_item.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0006_inner_attributes.rast b/crates/syntax/test_data/parser/ok/0006_inner_attributes.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0006_inner_attributes.rast rename to crates/syntax/test_data/parser/ok/0006_inner_attributes.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0006_inner_attributes.rs b/crates/syntax/test_data/parser/ok/0006_inner_attributes.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0006_inner_attributes.rs rename to crates/syntax/test_data/parser/ok/0006_inner_attributes.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0007_extern_crate.rast b/crates/syntax/test_data/parser/ok/0007_extern_crate.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0007_extern_crate.rast rename to crates/syntax/test_data/parser/ok/0007_extern_crate.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0007_extern_crate.rs b/crates/syntax/test_data/parser/ok/0007_extern_crate.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0007_extern_crate.rs rename to crates/syntax/test_data/parser/ok/0007_extern_crate.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0008_mod_item.rast b/crates/syntax/test_data/parser/ok/0008_mod_item.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0008_mod_item.rast rename to crates/syntax/test_data/parser/ok/0008_mod_item.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0008_mod_item.rs b/crates/syntax/test_data/parser/ok/0008_mod_item.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0008_mod_item.rs rename to crates/syntax/test_data/parser/ok/0008_mod_item.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0009_use_item.rast b/crates/syntax/test_data/parser/ok/0009_use_item.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0009_use_item.rast rename to crates/syntax/test_data/parser/ok/0009_use_item.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0009_use_item.rs b/crates/syntax/test_data/parser/ok/0009_use_item.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0009_use_item.rs rename to crates/syntax/test_data/parser/ok/0009_use_item.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0010_use_path_segments.rast b/crates/syntax/test_data/parser/ok/0010_use_path_segments.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0010_use_path_segments.rast rename to crates/syntax/test_data/parser/ok/0010_use_path_segments.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0010_use_path_segments.rs b/crates/syntax/test_data/parser/ok/0010_use_path_segments.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0010_use_path_segments.rs rename to crates/syntax/test_data/parser/ok/0010_use_path_segments.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0011_outer_attribute.rast b/crates/syntax/test_data/parser/ok/0011_outer_attribute.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0011_outer_attribute.rast rename to crates/syntax/test_data/parser/ok/0011_outer_attribute.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0011_outer_attribute.rs b/crates/syntax/test_data/parser/ok/0011_outer_attribute.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0011_outer_attribute.rs rename to crates/syntax/test_data/parser/ok/0011_outer_attribute.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0012_visibility.rast b/crates/syntax/test_data/parser/ok/0012_visibility.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0012_visibility.rast rename to crates/syntax/test_data/parser/ok/0012_visibility.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0012_visibility.rs b/crates/syntax/test_data/parser/ok/0012_visibility.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0012_visibility.rs rename to crates/syntax/test_data/parser/ok/0012_visibility.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0013_use_path_self_super.rast b/crates/syntax/test_data/parser/ok/0013_use_path_self_super.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0013_use_path_self_super.rast rename to crates/syntax/test_data/parser/ok/0013_use_path_self_super.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0013_use_path_self_super.rs b/crates/syntax/test_data/parser/ok/0013_use_path_self_super.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0013_use_path_self_super.rs rename to crates/syntax/test_data/parser/ok/0013_use_path_self_super.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0014_use_tree.rast b/crates/syntax/test_data/parser/ok/0014_use_tree.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0014_use_tree.rast rename to crates/syntax/test_data/parser/ok/0014_use_tree.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0014_use_tree.rs b/crates/syntax/test_data/parser/ok/0014_use_tree.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0014_use_tree.rs rename to crates/syntax/test_data/parser/ok/0014_use_tree.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0015_use_tree.rast b/crates/syntax/test_data/parser/ok/0015_use_tree.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0015_use_tree.rast rename to crates/syntax/test_data/parser/ok/0015_use_tree.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0015_use_tree.rs b/crates/syntax/test_data/parser/ok/0015_use_tree.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0015_use_tree.rs rename to crates/syntax/test_data/parser/ok/0015_use_tree.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0016_struct_flavors.rast b/crates/syntax/test_data/parser/ok/0016_struct_flavors.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0016_struct_flavors.rast rename to crates/syntax/test_data/parser/ok/0016_struct_flavors.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0016_struct_flavors.rs b/crates/syntax/test_data/parser/ok/0016_struct_flavors.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0016_struct_flavors.rs rename to crates/syntax/test_data/parser/ok/0016_struct_flavors.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0017_attr_trailing_comma.rast b/crates/syntax/test_data/parser/ok/0017_attr_trailing_comma.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0017_attr_trailing_comma.rast rename to crates/syntax/test_data/parser/ok/0017_attr_trailing_comma.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0017_attr_trailing_comma.rs b/crates/syntax/test_data/parser/ok/0017_attr_trailing_comma.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0017_attr_trailing_comma.rs rename to crates/syntax/test_data/parser/ok/0017_attr_trailing_comma.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0018_struct_type_params.rast b/crates/syntax/test_data/parser/ok/0018_struct_type_params.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0018_struct_type_params.rast rename to crates/syntax/test_data/parser/ok/0018_struct_type_params.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0018_struct_type_params.rs b/crates/syntax/test_data/parser/ok/0018_struct_type_params.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0018_struct_type_params.rs rename to crates/syntax/test_data/parser/ok/0018_struct_type_params.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0019_enums.rast b/crates/syntax/test_data/parser/ok/0019_enums.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0019_enums.rast rename to crates/syntax/test_data/parser/ok/0019_enums.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0019_enums.rs b/crates/syntax/test_data/parser/ok/0019_enums.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0019_enums.rs rename to crates/syntax/test_data/parser/ok/0019_enums.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0020_type_param_bounds.rast b/crates/syntax/test_data/parser/ok/0020_type_param_bounds.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0020_type_param_bounds.rast rename to crates/syntax/test_data/parser/ok/0020_type_param_bounds.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0020_type_param_bounds.rs b/crates/syntax/test_data/parser/ok/0020_type_param_bounds.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0020_type_param_bounds.rs rename to crates/syntax/test_data/parser/ok/0020_type_param_bounds.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0022_empty_extern_block.rast b/crates/syntax/test_data/parser/ok/0022_empty_extern_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0022_empty_extern_block.rast rename to crates/syntax/test_data/parser/ok/0022_empty_extern_block.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0022_empty_extern_block.rs b/crates/syntax/test_data/parser/ok/0022_empty_extern_block.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0022_empty_extern_block.rs rename to crates/syntax/test_data/parser/ok/0022_empty_extern_block.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0023_static_items.rast b/crates/syntax/test_data/parser/ok/0023_static_items.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0023_static_items.rast rename to crates/syntax/test_data/parser/ok/0023_static_items.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0023_static_items.rs b/crates/syntax/test_data/parser/ok/0023_static_items.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0023_static_items.rs rename to crates/syntax/test_data/parser/ok/0023_static_items.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0024_const_item.rast b/crates/syntax/test_data/parser/ok/0024_const_item.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0024_const_item.rast rename to crates/syntax/test_data/parser/ok/0024_const_item.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0024_const_item.rs b/crates/syntax/test_data/parser/ok/0024_const_item.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0024_const_item.rs rename to crates/syntax/test_data/parser/ok/0024_const_item.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0025_extern_fn_in_block.rast b/crates/syntax/test_data/parser/ok/0025_extern_fn_in_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0025_extern_fn_in_block.rast rename to crates/syntax/test_data/parser/ok/0025_extern_fn_in_block.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0025_extern_fn_in_block.rs b/crates/syntax/test_data/parser/ok/0025_extern_fn_in_block.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0025_extern_fn_in_block.rs rename to crates/syntax/test_data/parser/ok/0025_extern_fn_in_block.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0026_const_fn_in_block.rast b/crates/syntax/test_data/parser/ok/0026_const_fn_in_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0026_const_fn_in_block.rast rename to crates/syntax/test_data/parser/ok/0026_const_fn_in_block.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0026_const_fn_in_block.rs b/crates/syntax/test_data/parser/ok/0026_const_fn_in_block.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0026_const_fn_in_block.rs rename to crates/syntax/test_data/parser/ok/0026_const_fn_in_block.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0027_unsafe_fn_in_block.rast b/crates/syntax/test_data/parser/ok/0027_unsafe_fn_in_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0027_unsafe_fn_in_block.rast rename to crates/syntax/test_data/parser/ok/0027_unsafe_fn_in_block.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0027_unsafe_fn_in_block.rs b/crates/syntax/test_data/parser/ok/0027_unsafe_fn_in_block.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0027_unsafe_fn_in_block.rs rename to crates/syntax/test_data/parser/ok/0027_unsafe_fn_in_block.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0028_operator_binding_power.rast b/crates/syntax/test_data/parser/ok/0028_operator_binding_power.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0028_operator_binding_power.rast rename to crates/syntax/test_data/parser/ok/0028_operator_binding_power.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0028_operator_binding_power.rs b/crates/syntax/test_data/parser/ok/0028_operator_binding_power.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0028_operator_binding_power.rs rename to crates/syntax/test_data/parser/ok/0028_operator_binding_power.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0029_range_forms.rast b/crates/syntax/test_data/parser/ok/0029_range_forms.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0029_range_forms.rast rename to crates/syntax/test_data/parser/ok/0029_range_forms.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0029_range_forms.rs b/crates/syntax/test_data/parser/ok/0029_range_forms.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0029_range_forms.rs rename to crates/syntax/test_data/parser/ok/0029_range_forms.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0030_string_suffixes.rast b/crates/syntax/test_data/parser/ok/0030_string_suffixes.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0030_string_suffixes.rast rename to crates/syntax/test_data/parser/ok/0030_string_suffixes.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0030_string_suffixes.rs b/crates/syntax/test_data/parser/ok/0030_string_suffixes.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0030_string_suffixes.rs rename to crates/syntax/test_data/parser/ok/0030_string_suffixes.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0030_traits.rast b/crates/syntax/test_data/parser/ok/0030_traits.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0030_traits.rast rename to crates/syntax/test_data/parser/ok/0030_traits.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0030_traits.rs b/crates/syntax/test_data/parser/ok/0030_traits.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0030_traits.rs rename to crates/syntax/test_data/parser/ok/0030_traits.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0031_extern.rast b/crates/syntax/test_data/parser/ok/0031_extern.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0031_extern.rast rename to crates/syntax/test_data/parser/ok/0031_extern.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0031_extern.rs b/crates/syntax/test_data/parser/ok/0031_extern.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0031_extern.rs rename to crates/syntax/test_data/parser/ok/0031_extern.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0032_where_for.rast b/crates/syntax/test_data/parser/ok/0032_where_for.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0032_where_for.rast rename to crates/syntax/test_data/parser/ok/0032_where_for.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0032_where_for.rs b/crates/syntax/test_data/parser/ok/0032_where_for.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0032_where_for.rs rename to crates/syntax/test_data/parser/ok/0032_where_for.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0033_label_break.rast b/crates/syntax/test_data/parser/ok/0033_label_break.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0033_label_break.rast rename to crates/syntax/test_data/parser/ok/0033_label_break.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0033_label_break.rs b/crates/syntax/test_data/parser/ok/0033_label_break.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0033_label_break.rs rename to crates/syntax/test_data/parser/ok/0033_label_break.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0034_crate_path_in_call.rast b/crates/syntax/test_data/parser/ok/0034_crate_path_in_call.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0034_crate_path_in_call.rast rename to crates/syntax/test_data/parser/ok/0034_crate_path_in_call.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0034_crate_path_in_call.rs b/crates/syntax/test_data/parser/ok/0034_crate_path_in_call.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0034_crate_path_in_call.rs rename to crates/syntax/test_data/parser/ok/0034_crate_path_in_call.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0035_weird_exprs.rast b/crates/syntax/test_data/parser/ok/0035_weird_exprs.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0035_weird_exprs.rast rename to crates/syntax/test_data/parser/ok/0035_weird_exprs.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0035_weird_exprs.rs b/crates/syntax/test_data/parser/ok/0035_weird_exprs.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0035_weird_exprs.rs rename to crates/syntax/test_data/parser/ok/0035_weird_exprs.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0036_fully_qualified.rast b/crates/syntax/test_data/parser/ok/0036_fully_qualified.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0036_fully_qualified.rast rename to crates/syntax/test_data/parser/ok/0036_fully_qualified.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0036_fully_qualified.rs b/crates/syntax/test_data/parser/ok/0036_fully_qualified.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0036_fully_qualified.rs rename to crates/syntax/test_data/parser/ok/0036_fully_qualified.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0037_mod.rast b/crates/syntax/test_data/parser/ok/0037_mod.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0037_mod.rast rename to crates/syntax/test_data/parser/ok/0037_mod.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0037_mod.rs b/crates/syntax/test_data/parser/ok/0037_mod.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0037_mod.rs rename to crates/syntax/test_data/parser/ok/0037_mod.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0038_where_pred_type.rast b/crates/syntax/test_data/parser/ok/0038_where_pred_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0038_where_pred_type.rast rename to crates/syntax/test_data/parser/ok/0038_where_pred_type.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0038_where_pred_type.rs b/crates/syntax/test_data/parser/ok/0038_where_pred_type.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0038_where_pred_type.rs rename to crates/syntax/test_data/parser/ok/0038_where_pred_type.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0039_raw_fn_item.rast b/crates/syntax/test_data/parser/ok/0039_raw_fn_item.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0039_raw_fn_item.rast rename to crates/syntax/test_data/parser/ok/0039_raw_fn_item.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0039_raw_fn_item.rs b/crates/syntax/test_data/parser/ok/0039_raw_fn_item.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0039_raw_fn_item.rs rename to crates/syntax/test_data/parser/ok/0039_raw_fn_item.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0040_raw_struct_item_field.rast b/crates/syntax/test_data/parser/ok/0040_raw_struct_item_field.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0040_raw_struct_item_field.rast rename to crates/syntax/test_data/parser/ok/0040_raw_struct_item_field.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0040_raw_struct_item_field.rs b/crates/syntax/test_data/parser/ok/0040_raw_struct_item_field.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0040_raw_struct_item_field.rs rename to crates/syntax/test_data/parser/ok/0040_raw_struct_item_field.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0041_raw_keywords.rast b/crates/syntax/test_data/parser/ok/0041_raw_keywords.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0041_raw_keywords.rast rename to crates/syntax/test_data/parser/ok/0041_raw_keywords.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0041_raw_keywords.rs b/crates/syntax/test_data/parser/ok/0041_raw_keywords.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0041_raw_keywords.rs rename to crates/syntax/test_data/parser/ok/0041_raw_keywords.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0042_ufcs_call_list.rast b/crates/syntax/test_data/parser/ok/0042_ufcs_call_list.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0042_ufcs_call_list.rast rename to crates/syntax/test_data/parser/ok/0042_ufcs_call_list.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0042_ufcs_call_list.rs b/crates/syntax/test_data/parser/ok/0042_ufcs_call_list.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0042_ufcs_call_list.rs rename to crates/syntax/test_data/parser/ok/0042_ufcs_call_list.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0043_complex_assignment.rast b/crates/syntax/test_data/parser/ok/0043_complex_assignment.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0043_complex_assignment.rast rename to crates/syntax/test_data/parser/ok/0043_complex_assignment.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0043_complex_assignment.rs b/crates/syntax/test_data/parser/ok/0043_complex_assignment.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0043_complex_assignment.rs rename to crates/syntax/test_data/parser/ok/0043_complex_assignment.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0044_let_attrs.rast b/crates/syntax/test_data/parser/ok/0044_let_attrs.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0044_let_attrs.rast rename to crates/syntax/test_data/parser/ok/0044_let_attrs.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0044_let_attrs.rs b/crates/syntax/test_data/parser/ok/0044_let_attrs.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0044_let_attrs.rs rename to crates/syntax/test_data/parser/ok/0044_let_attrs.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0045_block_inner_attrs.rast b/crates/syntax/test_data/parser/ok/0045_block_inner_attrs.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0045_block_inner_attrs.rast rename to crates/syntax/test_data/parser/ok/0045_block_inner_attrs.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0045_block_inner_attrs.rs b/crates/syntax/test_data/parser/ok/0045_block_inner_attrs.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0045_block_inner_attrs.rs rename to crates/syntax/test_data/parser/ok/0045_block_inner_attrs.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0046_extern_inner_attributes.rast b/crates/syntax/test_data/parser/ok/0046_extern_inner_attributes.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0046_extern_inner_attributes.rast rename to crates/syntax/test_data/parser/ok/0046_extern_inner_attributes.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0046_extern_inner_attributes.rs b/crates/syntax/test_data/parser/ok/0046_extern_inner_attributes.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0046_extern_inner_attributes.rs rename to crates/syntax/test_data/parser/ok/0046_extern_inner_attributes.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0047_minus_in_inner_pattern.rast b/crates/syntax/test_data/parser/ok/0047_minus_in_inner_pattern.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0047_minus_in_inner_pattern.rast rename to crates/syntax/test_data/parser/ok/0047_minus_in_inner_pattern.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0047_minus_in_inner_pattern.rs b/crates/syntax/test_data/parser/ok/0047_minus_in_inner_pattern.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0047_minus_in_inner_pattern.rs rename to crates/syntax/test_data/parser/ok/0047_minus_in_inner_pattern.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0048_compound_assignment.rast b/crates/syntax/test_data/parser/ok/0048_compound_assignment.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0048_compound_assignment.rast rename to crates/syntax/test_data/parser/ok/0048_compound_assignment.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0048_compound_assignment.rs b/crates/syntax/test_data/parser/ok/0048_compound_assignment.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0048_compound_assignment.rs rename to crates/syntax/test_data/parser/ok/0048_compound_assignment.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0049_async_block.rast b/crates/syntax/test_data/parser/ok/0049_async_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0049_async_block.rast rename to crates/syntax/test_data/parser/ok/0049_async_block.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0049_async_block.rs b/crates/syntax/test_data/parser/ok/0049_async_block.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0049_async_block.rs rename to crates/syntax/test_data/parser/ok/0049_async_block.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0050_async_block_as_argument.rast b/crates/syntax/test_data/parser/ok/0050_async_block_as_argument.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0050_async_block_as_argument.rast rename to crates/syntax/test_data/parser/ok/0050_async_block_as_argument.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0050_async_block_as_argument.rs b/crates/syntax/test_data/parser/ok/0050_async_block_as_argument.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0050_async_block_as_argument.rs rename to crates/syntax/test_data/parser/ok/0050_async_block_as_argument.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0051_parameter_attrs.rast b/crates/syntax/test_data/parser/ok/0051_parameter_attrs.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0051_parameter_attrs.rast rename to crates/syntax/test_data/parser/ok/0051_parameter_attrs.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0051_parameter_attrs.rs b/crates/syntax/test_data/parser/ok/0051_parameter_attrs.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0051_parameter_attrs.rs rename to crates/syntax/test_data/parser/ok/0051_parameter_attrs.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0052_for_range_block.rast b/crates/syntax/test_data/parser/ok/0052_for_range_block.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0052_for_range_block.rast rename to crates/syntax/test_data/parser/ok/0052_for_range_block.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0052_for_range_block.rs b/crates/syntax/test_data/parser/ok/0052_for_range_block.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0052_for_range_block.rs rename to crates/syntax/test_data/parser/ok/0052_for_range_block.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0053_outer_attribute_on_macro_rules.rast b/crates/syntax/test_data/parser/ok/0053_outer_attribute_on_macro_rules.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0053_outer_attribute_on_macro_rules.rast rename to crates/syntax/test_data/parser/ok/0053_outer_attribute_on_macro_rules.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0053_outer_attribute_on_macro_rules.rs b/crates/syntax/test_data/parser/ok/0053_outer_attribute_on_macro_rules.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0053_outer_attribute_on_macro_rules.rs rename to crates/syntax/test_data/parser/ok/0053_outer_attribute_on_macro_rules.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0054_qual_path_in_type_arg.rast b/crates/syntax/test_data/parser/ok/0054_qual_path_in_type_arg.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0054_qual_path_in_type_arg.rast rename to crates/syntax/test_data/parser/ok/0054_qual_path_in_type_arg.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0054_qual_path_in_type_arg.rs b/crates/syntax/test_data/parser/ok/0054_qual_path_in_type_arg.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0054_qual_path_in_type_arg.rs rename to crates/syntax/test_data/parser/ok/0054_qual_path_in_type_arg.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0055_dot_dot_dot.rast b/crates/syntax/test_data/parser/ok/0055_dot_dot_dot.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0055_dot_dot_dot.rast rename to crates/syntax/test_data/parser/ok/0055_dot_dot_dot.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0055_dot_dot_dot.rs b/crates/syntax/test_data/parser/ok/0055_dot_dot_dot.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0055_dot_dot_dot.rs rename to crates/syntax/test_data/parser/ok/0055_dot_dot_dot.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0056_neq_in_type.rast b/crates/syntax/test_data/parser/ok/0056_neq_in_type.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0056_neq_in_type.rast rename to crates/syntax/test_data/parser/ok/0056_neq_in_type.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0056_neq_in_type.rs b/crates/syntax/test_data/parser/ok/0056_neq_in_type.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0056_neq_in_type.rs rename to crates/syntax/test_data/parser/ok/0056_neq_in_type.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0057_loop_in_call.rast b/crates/syntax/test_data/parser/ok/0057_loop_in_call.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0057_loop_in_call.rast rename to crates/syntax/test_data/parser/ok/0057_loop_in_call.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0057_loop_in_call.rs b/crates/syntax/test_data/parser/ok/0057_loop_in_call.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0057_loop_in_call.rs rename to crates/syntax/test_data/parser/ok/0057_loop_in_call.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0058_unary_expr_precedence.rast b/crates/syntax/test_data/parser/ok/0058_unary_expr_precedence.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0058_unary_expr_precedence.rast rename to crates/syntax/test_data/parser/ok/0058_unary_expr_precedence.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0058_unary_expr_precedence.rs b/crates/syntax/test_data/parser/ok/0058_unary_expr_precedence.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0058_unary_expr_precedence.rs rename to crates/syntax/test_data/parser/ok/0058_unary_expr_precedence.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0059_loops_in_parens.rast b/crates/syntax/test_data/parser/ok/0059_loops_in_parens.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0059_loops_in_parens.rast rename to crates/syntax/test_data/parser/ok/0059_loops_in_parens.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0059_loops_in_parens.rs b/crates/syntax/test_data/parser/ok/0059_loops_in_parens.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0059_loops_in_parens.rs rename to crates/syntax/test_data/parser/ok/0059_loops_in_parens.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0060_as_range.rast b/crates/syntax/test_data/parser/ok/0060_as_range.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0060_as_range.rast rename to crates/syntax/test_data/parser/ok/0060_as_range.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0060_as_range.rs b/crates/syntax/test_data/parser/ok/0060_as_range.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0060_as_range.rs rename to crates/syntax/test_data/parser/ok/0060_as_range.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0061_match_full_range.rast b/crates/syntax/test_data/parser/ok/0061_match_full_range.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0061_match_full_range.rast rename to crates/syntax/test_data/parser/ok/0061_match_full_range.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0061_match_full_range.rs b/crates/syntax/test_data/parser/ok/0061_match_full_range.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0061_match_full_range.rs rename to crates/syntax/test_data/parser/ok/0061_match_full_range.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0062_macro_2.0.rast b/crates/syntax/test_data/parser/ok/0062_macro_2.0.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0062_macro_2.0.rast rename to crates/syntax/test_data/parser/ok/0062_macro_2.0.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0062_macro_2.0.rs b/crates/syntax/test_data/parser/ok/0062_macro_2.0.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0062_macro_2.0.rs rename to crates/syntax/test_data/parser/ok/0062_macro_2.0.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0063_trait_fn_patterns.rast b/crates/syntax/test_data/parser/ok/0063_trait_fn_patterns.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0063_trait_fn_patterns.rast rename to crates/syntax/test_data/parser/ok/0063_trait_fn_patterns.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0063_trait_fn_patterns.rs b/crates/syntax/test_data/parser/ok/0063_trait_fn_patterns.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0063_trait_fn_patterns.rs rename to crates/syntax/test_data/parser/ok/0063_trait_fn_patterns.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0063_variadic_fun.rast b/crates/syntax/test_data/parser/ok/0063_variadic_fun.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0063_variadic_fun.rast rename to crates/syntax/test_data/parser/ok/0063_variadic_fun.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0063_variadic_fun.rs b/crates/syntax/test_data/parser/ok/0063_variadic_fun.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0063_variadic_fun.rs rename to crates/syntax/test_data/parser/ok/0063_variadic_fun.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0064_impl_fn_params.rast b/crates/syntax/test_data/parser/ok/0064_impl_fn_params.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0064_impl_fn_params.rast rename to crates/syntax/test_data/parser/ok/0064_impl_fn_params.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0064_impl_fn_params.rs b/crates/syntax/test_data/parser/ok/0064_impl_fn_params.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0064_impl_fn_params.rs rename to crates/syntax/test_data/parser/ok/0064_impl_fn_params.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0065_comment_newline.rast b/crates/syntax/test_data/parser/ok/0065_comment_newline.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0065_comment_newline.rast rename to crates/syntax/test_data/parser/ok/0065_comment_newline.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0065_comment_newline.rs b/crates/syntax/test_data/parser/ok/0065_comment_newline.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0065_comment_newline.rs rename to crates/syntax/test_data/parser/ok/0065_comment_newline.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0065_plus_after_fn_trait_bound.rast b/crates/syntax/test_data/parser/ok/0065_plus_after_fn_trait_bound.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0065_plus_after_fn_trait_bound.rast rename to crates/syntax/test_data/parser/ok/0065_plus_after_fn_trait_bound.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0065_plus_after_fn_trait_bound.rs b/crates/syntax/test_data/parser/ok/0065_plus_after_fn_trait_bound.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0065_plus_after_fn_trait_bound.rs rename to crates/syntax/test_data/parser/ok/0065_plus_after_fn_trait_bound.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0066_default_modifier.rast b/crates/syntax/test_data/parser/ok/0066_default_modifier.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0066_default_modifier.rast rename to crates/syntax/test_data/parser/ok/0066_default_modifier.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0066_default_modifier.rs b/crates/syntax/test_data/parser/ok/0066_default_modifier.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0066_default_modifier.rs rename to crates/syntax/test_data/parser/ok/0066_default_modifier.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0067_where_for_pred.rast b/crates/syntax/test_data/parser/ok/0067_where_for_pred.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0067_where_for_pred.rast rename to crates/syntax/test_data/parser/ok/0067_where_for_pred.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0067_where_for_pred.rs b/crates/syntax/test_data/parser/ok/0067_where_for_pred.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0067_where_for_pred.rs rename to crates/syntax/test_data/parser/ok/0067_where_for_pred.rs diff --git a/crates/ra_syntax/test_data/parser/ok/0068_item_modifiers.rast b/crates/syntax/test_data/parser/ok/0068_item_modifiers.rast similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0068_item_modifiers.rast rename to crates/syntax/test_data/parser/ok/0068_item_modifiers.rast diff --git a/crates/ra_syntax/test_data/parser/ok/0068_item_modifiers.rs b/crates/syntax/test_data/parser/ok/0068_item_modifiers.rs similarity index 100% rename from crates/ra_syntax/test_data/parser/ok/0068_item_modifiers.rs rename to crates/syntax/test_data/parser/ok/0068_item_modifiers.rs diff --git a/crates/ra_syntax/test_data/reparse/fuzz-failures/0000.rs b/crates/syntax/test_data/reparse/fuzz-failures/0000.rs similarity index 100% rename from crates/ra_syntax/test_data/reparse/fuzz-failures/0000.rs rename to crates/syntax/test_data/reparse/fuzz-failures/0000.rs diff --git a/crates/ra_syntax/test_data/reparse/fuzz-failures/0001.rs b/crates/syntax/test_data/reparse/fuzz-failures/0001.rs similarity index 100% rename from crates/ra_syntax/test_data/reparse/fuzz-failures/0001.rs rename to crates/syntax/test_data/reparse/fuzz-failures/0001.rs diff --git a/crates/ra_syntax/test_data/reparse/fuzz-failures/0002.rs b/crates/syntax/test_data/reparse/fuzz-failures/0002.rs similarity index 100% rename from crates/ra_syntax/test_data/reparse/fuzz-failures/0002.rs rename to crates/syntax/test_data/reparse/fuzz-failures/0002.rs diff --git a/crates/ra_syntax/test_data/reparse/fuzz-failures/0003.rs b/crates/syntax/test_data/reparse/fuzz-failures/0003.rs similarity index 100% rename from crates/ra_syntax/test_data/reparse/fuzz-failures/0003.rs rename to crates/syntax/test_data/reparse/fuzz-failures/0003.rs diff --git a/crates/ra_syntax/test_data/reparse/fuzz-failures/0004.rs b/crates/syntax/test_data/reparse/fuzz-failures/0004.rs similarity index 100% rename from crates/ra_syntax/test_data/reparse/fuzz-failures/0004.rs rename to crates/syntax/test_data/reparse/fuzz-failures/0004.rs diff --git a/crates/ra_syntax/test_data/reparse/fuzz-failures/0005.rs b/crates/syntax/test_data/reparse/fuzz-failures/0005.rs similarity index 100% rename from crates/ra_syntax/test_data/reparse/fuzz-failures/0005.rs rename to crates/syntax/test_data/reparse/fuzz-failures/0005.rs diff --git a/docs/dev/README.md b/docs/dev/README.md index 33829c5937..4aab6e2b86 100644 --- a/docs/dev/README.md +++ b/docs/dev/README.md @@ -92,7 +92,7 @@ This is primarily useful for performance optimizations, or for bug minimization. ## Parser Tests -Tests for the parser (`parser`) live in the `ra_syntax` crate (see `test_data` directory). +Tests for the parser (`parser`) live in the `syntax` crate (see `test_data` directory). There are two kinds of tests: * Manually written test cases in `parser/ok` and `parser/err` diff --git a/docs/dev/style.md b/docs/dev/style.md index 1c68f57023..3bbab6da90 100644 --- a/docs/dev/style.md +++ b/docs/dev/style.md @@ -97,13 +97,13 @@ Qualify items from `hir` and `ast`. ```rust // Good -use ra_syntax::ast; +use syntax::ast; fn frobnicate(func: hir::Function, strukt: ast::StructDef) {} // Not as good use hir::Function; -use ra_syntax::ast::StructDef; +use syntax::ast::StructDef; fn frobnicate(func: Function, strukt: StructDef) {} ``` diff --git a/xtask/src/codegen.rs b/xtask/src/codegen.rs index 08e7a10b75..2acd598d1e 100644 --- a/xtask/src/codegen.rs +++ b/xtask/src/codegen.rs @@ -25,12 +25,12 @@ pub use self::{ }; const GRAMMAR_DIR: &str = "crates/parser/src/grammar"; -const OK_INLINE_TESTS_DIR: &str = "crates/ra_syntax/test_data/parser/inline/ok"; -const ERR_INLINE_TESTS_DIR: &str = "crates/ra_syntax/test_data/parser/inline/err"; +const OK_INLINE_TESTS_DIR: &str = "crates/syntax/test_data/parser/inline/ok"; +const ERR_INLINE_TESTS_DIR: &str = "crates/syntax/test_data/parser/inline/err"; const SYNTAX_KINDS: &str = "crates/parser/src/syntax_kind/generated.rs"; -const AST_NODES: &str = "crates/ra_syntax/src/ast/generated/nodes.rs"; -const AST_TOKENS: &str = "crates/ra_syntax/src/ast/generated/tokens.rs"; +const AST_NODES: &str = "crates/syntax/src/ast/generated/nodes.rs"; +const AST_TOKENS: &str = "crates/syntax/src/ast/generated/tokens.rs"; const ASSISTS_DIR: &str = "crates/ra_assists/src/handlers"; const ASSISTS_TESTS: &str = "crates/ra_assists/src/tests/generated.rs"; diff --git a/xtask/src/codegen/gen_syntax.rs b/xtask/src/codegen/gen_syntax.rs index cafad8070d..dd1f4d6a2c 100644 --- a/xtask/src/codegen/gen_syntax.rs +++ b/xtask/src/codegen/gen_syntax.rs @@ -1,7 +1,7 @@ //! This module generates AST datatype used by rust-analyzer. //! //! Specifically, it generates the `SyntaxKind` enum and a number of newtype -//! wrappers around `SyntaxNode` which implement `ra_syntax::AstNode`. +//! wrappers around `SyntaxNode` which implement `syntax::AstNode`. use std::{ collections::{BTreeSet, HashSet}, diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs index 2fdb08f2e1..904a9ee715 100644 --- a/xtask/src/lib.rs +++ b/xtask/src/lib.rs @@ -103,7 +103,7 @@ pub fn run_clippy() -> Result<()> { } pub fn run_fuzzer() -> Result<()> { - let _d = pushd("./crates/ra_syntax"); + let _d = pushd("./crates/syntax"); let _e = pushenv("RUSTUP_TOOLCHAIN", "nightly"); if run!("cargo fuzz --help").is_err() { run!("cargo install cargo-fuzz")?; diff --git a/xtask/tests/tidy.rs b/xtask/tests/tidy.rs index f1a7e8288e..8c608284a4 100644 --- a/xtask/tests/tidy.rs +++ b/xtask/tests/tidy.rs @@ -199,7 +199,7 @@ impl TidyDocs { "parser", "profile", "ra_project_model", - "ra_syntax", + "syntax", "tt", "ra_hir_ty", ]; From 0635458a6bf883b5abcae024afb17a11688fef92 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 12 Aug 2020 18:49:43 +0200 Subject: [PATCH 075/119] **Merge Imports** assist handles self --- .../ra_assists/src/handlers/merge_imports.rs | 27 +++++++++++++++++++ crates/syntax/src/ast/edit.rs | 11 +++++--- crates/syntax/src/ast/make.rs | 3 +++ 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/crates/ra_assists/src/handlers/merge_imports.rs b/crates/ra_assists/src/handlers/merge_imports.rs index 9c5c6eda72..47d4654046 100644 --- a/crates/ra_assists/src/handlers/merge_imports.rs +++ b/crates/ra_assists/src/handlers/merge_imports.rs @@ -164,6 +164,33 @@ use std::fmt::{Display, Debug}; ); } + #[test] + fn merge_self1() { + check_assist( + merge_imports, + r" +use std::fmt<|>; +use std::fmt::Display; +", + r" +use std::fmt::{self, Display}; +", + ); + } + + #[test] + fn merge_self2() { + check_assist( + merge_imports, + r" +use std::{fmt, <|>fmt::Display}; +", + r" +use std::{fmt::{Display, self}}; +", + ); + } + #[test] fn test_merge_nested() { check_assist( diff --git a/crates/syntax/src/ast/edit.rs b/crates/syntax/src/ast/edit.rs index 5ed123f91f..2667d9af4c 100644 --- a/crates/syntax/src/ast/edit.rs +++ b/crates/syntax/src/ast/edit.rs @@ -313,10 +313,15 @@ impl ast::UseTree { #[must_use] pub fn split_prefix(&self, prefix: &ast::Path) -> ast::UseTree { - let suffix = match split_path_prefix(&prefix) { - Some(it) => it, - None => return self.clone(), + let suffix = if self.path().as_ref() == Some(prefix) && self.use_tree_list().is_none() { + make::path_unqualified(make::path_segment_self()) + } else { + match split_path_prefix(&prefix) { + Some(it) => it, + None => return self.clone(), + } }; + let use_tree = make::use_tree( suffix, self.use_tree_list(), diff --git a/crates/syntax/src/ast/make.rs b/crates/syntax/src/ast/make.rs index 254a37fe3e..3009faed71 100644 --- a/crates/syntax/src/ast/make.rs +++ b/crates/syntax/src/ast/make.rs @@ -24,6 +24,9 @@ pub fn ty(text: &str) -> ast::Type { pub fn path_segment(name_ref: ast::NameRef) -> ast::PathSegment { ast_from_text(&format!("use {};", name_ref)) } +pub fn path_segment_self() -> ast::PathSegment { + ast_from_text("use self;") +} pub fn path_unqualified(segment: ast::PathSegment) -> ast::Path { path_from_text(&format!("use {}", segment)) } From 0de795fc4c121033890c21ffd41ef9274dc3c74e Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Thu, 13 Aug 2020 00:43:01 +0300 Subject: [PATCH 076/119] Consider only IdentPats for param name hints --- crates/ra_ide/src/inlay_hints.rs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs index 46ddc528e5..81fe274adf 100644 --- a/crates/ra_ide/src/inlay_hints.rs +++ b/crates/ra_ide/src/inlay_hints.rs @@ -156,15 +156,15 @@ fn get_param_name_hints( .params(sema.db) .into_iter() .zip(args) - .filter_map(|((param, _ty), arg)| match param? { - Either::Left(self_param) => Some((self_param.to_string(), arg)), - Either::Right(pat) => { - let param_name = match pat { + .filter_map(|((param, _ty), arg)| { + let param_name = match param? { + Either::Left(self_param) => self_param.to_string(), + Either::Right(pat) => match pat { ast::Pat::IdentPat(it) => it.name()?.to_string(), - it => it.to_string(), - }; - Some((param_name, arg)) - } + _ => return None, + }, + }; + Some((param_name, arg)) }) .filter(|(param_name, arg)| should_show_param_name_hint(sema, &callable, ¶m_name, &arg)) .map(|(param_name, arg)| InlayHint { @@ -707,6 +707,8 @@ fn different_order(param: &Param) {} fn different_order_mut(param: &mut Param) {} fn has_underscore(_param: bool) {} fn enum_matches_param_name(completion_kind: CompletionKind) {} +fn param_destructuring_omitted_1((a, b): (u32, u32)) {} +fn param_destructuring_omitted_2(TestVarContainer { test_var: _ }: TestVarContainer) {} fn twiddle(twiddle: bool) {} fn doo(_doo: bool) {} @@ -746,6 +748,10 @@ fn main() { let b: f64 = 4.0; let _: f64 = a.div_euclid(b); let _: f64 = a.abs_sub(b); + + let range: (u32, u32) = (3, 5); + param_destructuring_omitted_1(range); + param_destructuring_omitted_2(container); }"#, ); } From 349e6c62ada1fa45a8b80edb877b5e7c9d0c306d Mon Sep 17 00:00:00 2001 From: Pavan Kumar Sunkara Date: Thu, 13 Aug 2020 02:57:26 +0200 Subject: [PATCH 077/119] Rename ra_proc_macro_srv -> proc_macro_srv --- Cargo.lock | 6 +++--- crates/{ra_proc_macro_srv => proc_macro_srv}/Cargo.toml | 9 ++++----- crates/{ra_proc_macro_srv => proc_macro_srv}/src/cli.rs | 0 .../{ra_proc_macro_srv => proc_macro_srv}/src/dylib.rs | 0 crates/{ra_proc_macro_srv => proc_macro_srv}/src/lib.rs | 0 .../src/proc_macro/bridge/buffer.rs | 0 .../src/proc_macro/bridge/client.rs | 0 .../src/proc_macro/bridge/closure.rs | 0 .../src/proc_macro/bridge/handle.rs | 0 .../src/proc_macro/bridge/mod.rs | 0 .../src/proc_macro/bridge/rpc.rs | 0 .../src/proc_macro/bridge/scoped_cell.rs | 0 .../src/proc_macro/bridge/server.rs | 0 .../src/proc_macro/diagnostic.rs | 0 .../src/proc_macro/mod.rs | 0 .../src/rustc_server.rs | 0 .../src/tests/fixtures/test_serialize_proc_macro.txt | 0 .../src/tests/mod.rs | 0 .../src/tests/utils.rs | 0 crates/rust-analyzer/Cargo.toml | 2 +- crates/rust-analyzer/src/bin/main.rs | 2 +- crates/rust-analyzer/src/reload.rs | 2 +- 22 files changed, 10 insertions(+), 11 deletions(-) rename crates/{ra_proc_macro_srv => proc_macro_srv}/Cargo.toml (88%) rename crates/{ra_proc_macro_srv => proc_macro_srv}/src/cli.rs (100%) rename crates/{ra_proc_macro_srv => proc_macro_srv}/src/dylib.rs (100%) rename crates/{ra_proc_macro_srv => proc_macro_srv}/src/lib.rs (100%) rename crates/{ra_proc_macro_srv => proc_macro_srv}/src/proc_macro/bridge/buffer.rs (100%) rename crates/{ra_proc_macro_srv => proc_macro_srv}/src/proc_macro/bridge/client.rs (100%) rename crates/{ra_proc_macro_srv => proc_macro_srv}/src/proc_macro/bridge/closure.rs (100%) rename crates/{ra_proc_macro_srv => proc_macro_srv}/src/proc_macro/bridge/handle.rs (100%) rename crates/{ra_proc_macro_srv => proc_macro_srv}/src/proc_macro/bridge/mod.rs (100%) rename crates/{ra_proc_macro_srv => proc_macro_srv}/src/proc_macro/bridge/rpc.rs (100%) rename crates/{ra_proc_macro_srv => proc_macro_srv}/src/proc_macro/bridge/scoped_cell.rs (100%) rename crates/{ra_proc_macro_srv => proc_macro_srv}/src/proc_macro/bridge/server.rs (100%) rename crates/{ra_proc_macro_srv => proc_macro_srv}/src/proc_macro/diagnostic.rs (100%) rename crates/{ra_proc_macro_srv => proc_macro_srv}/src/proc_macro/mod.rs (100%) rename crates/{ra_proc_macro_srv => proc_macro_srv}/src/rustc_server.rs (100%) rename crates/{ra_proc_macro_srv => proc_macro_srv}/src/tests/fixtures/test_serialize_proc_macro.txt (100%) rename crates/{ra_proc_macro_srv => proc_macro_srv}/src/tests/mod.rs (100%) rename crates/{ra_proc_macro_srv => proc_macro_srv}/src/tests/utils.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index c95ef002d3..efc17c4301 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1133,8 +1133,8 @@ dependencies = [ ] [[package]] -name = "ra_proc_macro_srv" -version = "0.1.0" +name = "proc_macro_srv" +version = "0.0.0" dependencies = [ "cargo_metadata", "difference", @@ -1280,7 +1280,7 @@ dependencies = [ "ra_ide", "ra_ide_db", "ra_mbe", - "ra_proc_macro_srv", + "proc_macro_srv", "ra_project_model", "ra_ssr", "rayon", diff --git a/crates/ra_proc_macro_srv/Cargo.toml b/crates/proc_macro_srv/Cargo.toml similarity index 88% rename from crates/ra_proc_macro_srv/Cargo.toml rename to crates/proc_macro_srv/Cargo.toml index 1c25e72296..775af890eb 100644 --- a/crates/ra_proc_macro_srv/Cargo.toml +++ b/crates/proc_macro_srv/Cargo.toml @@ -1,10 +1,9 @@ [package] -edition = "2018" -name = "ra_proc_macro_srv" -version = "0.1.0" -authors = ["rust-analyzer developers"] -publish = false +name = "proc_macro_srv" +version = "0.0.0" license = "MIT OR Apache-2.0" +authors = ["rust-analyzer developers"] +edition = "2018" [lib] doctest = false diff --git a/crates/ra_proc_macro_srv/src/cli.rs b/crates/proc_macro_srv/src/cli.rs similarity index 100% rename from crates/ra_proc_macro_srv/src/cli.rs rename to crates/proc_macro_srv/src/cli.rs diff --git a/crates/ra_proc_macro_srv/src/dylib.rs b/crates/proc_macro_srv/src/dylib.rs similarity index 100% rename from crates/ra_proc_macro_srv/src/dylib.rs rename to crates/proc_macro_srv/src/dylib.rs diff --git a/crates/ra_proc_macro_srv/src/lib.rs b/crates/proc_macro_srv/src/lib.rs similarity index 100% rename from crates/ra_proc_macro_srv/src/lib.rs rename to crates/proc_macro_srv/src/lib.rs diff --git a/crates/ra_proc_macro_srv/src/proc_macro/bridge/buffer.rs b/crates/proc_macro_srv/src/proc_macro/bridge/buffer.rs similarity index 100% rename from crates/ra_proc_macro_srv/src/proc_macro/bridge/buffer.rs rename to crates/proc_macro_srv/src/proc_macro/bridge/buffer.rs diff --git a/crates/ra_proc_macro_srv/src/proc_macro/bridge/client.rs b/crates/proc_macro_srv/src/proc_macro/bridge/client.rs similarity index 100% rename from crates/ra_proc_macro_srv/src/proc_macro/bridge/client.rs rename to crates/proc_macro_srv/src/proc_macro/bridge/client.rs diff --git a/crates/ra_proc_macro_srv/src/proc_macro/bridge/closure.rs b/crates/proc_macro_srv/src/proc_macro/bridge/closure.rs similarity index 100% rename from crates/ra_proc_macro_srv/src/proc_macro/bridge/closure.rs rename to crates/proc_macro_srv/src/proc_macro/bridge/closure.rs diff --git a/crates/ra_proc_macro_srv/src/proc_macro/bridge/handle.rs b/crates/proc_macro_srv/src/proc_macro/bridge/handle.rs similarity index 100% rename from crates/ra_proc_macro_srv/src/proc_macro/bridge/handle.rs rename to crates/proc_macro_srv/src/proc_macro/bridge/handle.rs diff --git a/crates/ra_proc_macro_srv/src/proc_macro/bridge/mod.rs b/crates/proc_macro_srv/src/proc_macro/bridge/mod.rs similarity index 100% rename from crates/ra_proc_macro_srv/src/proc_macro/bridge/mod.rs rename to crates/proc_macro_srv/src/proc_macro/bridge/mod.rs diff --git a/crates/ra_proc_macro_srv/src/proc_macro/bridge/rpc.rs b/crates/proc_macro_srv/src/proc_macro/bridge/rpc.rs similarity index 100% rename from crates/ra_proc_macro_srv/src/proc_macro/bridge/rpc.rs rename to crates/proc_macro_srv/src/proc_macro/bridge/rpc.rs diff --git a/crates/ra_proc_macro_srv/src/proc_macro/bridge/scoped_cell.rs b/crates/proc_macro_srv/src/proc_macro/bridge/scoped_cell.rs similarity index 100% rename from crates/ra_proc_macro_srv/src/proc_macro/bridge/scoped_cell.rs rename to crates/proc_macro_srv/src/proc_macro/bridge/scoped_cell.rs diff --git a/crates/ra_proc_macro_srv/src/proc_macro/bridge/server.rs b/crates/proc_macro_srv/src/proc_macro/bridge/server.rs similarity index 100% rename from crates/ra_proc_macro_srv/src/proc_macro/bridge/server.rs rename to crates/proc_macro_srv/src/proc_macro/bridge/server.rs diff --git a/crates/ra_proc_macro_srv/src/proc_macro/diagnostic.rs b/crates/proc_macro_srv/src/proc_macro/diagnostic.rs similarity index 100% rename from crates/ra_proc_macro_srv/src/proc_macro/diagnostic.rs rename to crates/proc_macro_srv/src/proc_macro/diagnostic.rs diff --git a/crates/ra_proc_macro_srv/src/proc_macro/mod.rs b/crates/proc_macro_srv/src/proc_macro/mod.rs similarity index 100% rename from crates/ra_proc_macro_srv/src/proc_macro/mod.rs rename to crates/proc_macro_srv/src/proc_macro/mod.rs diff --git a/crates/ra_proc_macro_srv/src/rustc_server.rs b/crates/proc_macro_srv/src/rustc_server.rs similarity index 100% rename from crates/ra_proc_macro_srv/src/rustc_server.rs rename to crates/proc_macro_srv/src/rustc_server.rs diff --git a/crates/ra_proc_macro_srv/src/tests/fixtures/test_serialize_proc_macro.txt b/crates/proc_macro_srv/src/tests/fixtures/test_serialize_proc_macro.txt similarity index 100% rename from crates/ra_proc_macro_srv/src/tests/fixtures/test_serialize_proc_macro.txt rename to crates/proc_macro_srv/src/tests/fixtures/test_serialize_proc_macro.txt diff --git a/crates/ra_proc_macro_srv/src/tests/mod.rs b/crates/proc_macro_srv/src/tests/mod.rs similarity index 100% rename from crates/ra_proc_macro_srv/src/tests/mod.rs rename to crates/proc_macro_srv/src/tests/mod.rs diff --git a/crates/ra_proc_macro_srv/src/tests/utils.rs b/crates/proc_macro_srv/src/tests/utils.rs similarity index 100% rename from crates/ra_proc_macro_srv/src/tests/utils.rs rename to crates/proc_macro_srv/src/tests/utils.rs diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index 86c786e25c..7713ed7eab 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml @@ -52,7 +52,7 @@ ra_ssr = { path = "../ra_ssr" } hir = { path = "../ra_hir", package = "ra_hir" } hir_def = { path = "../ra_hir_def", package = "ra_hir_def" } hir_ty = { path = "../ra_hir_ty", package = "ra_hir_ty" } -ra_proc_macro_srv = { path = "../ra_proc_macro_srv" } +proc_macro_srv = { path = "../proc_macro_srv" } [target.'cfg(windows)'.dependencies] winapi = "0.3.8" diff --git a/crates/rust-analyzer/src/bin/main.rs b/crates/rust-analyzer/src/bin/main.rs index 9622d71c06..f177f8709a 100644 --- a/crates/rust-analyzer/src/bin/main.rs +++ b/crates/rust-analyzer/src/bin/main.rs @@ -30,7 +30,7 @@ fn try_main() -> Result<()> { let args = args::Args::parse()?; match args.command { args::Command::RunServer => run_server()?, - args::Command::ProcMacro => ra_proc_macro_srv::cli::run()?, + args::Command::ProcMacro => proc_macro_srv::cli::run()?, args::Command::Parse { no_dump } => cli::parse(no_dump)?, args::Command::Symbols => cli::symbols()?, diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs index f74f2c02c8..611c9a89f5 100644 --- a/crates/rust-analyzer/src/reload.rs +++ b/crates/rust-analyzer/src/reload.rs @@ -176,7 +176,7 @@ impl GlobalState { Ok(it) => it, Err(err) => { log::error!( - "Failed to run ra_proc_macro_srv from path {}, error: {:?}", + "Failed to run proc_macro_srv from path {}, error: {:?}", path.display(), err ); From e30be7ad15272746e761a29cb1829defecd231cc Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 10:35:11 +0200 Subject: [PATCH 078/119] Disabe macros TypeSCript builder It hangs for some reason, and we are moving TS extension anyways... --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f46fb8fecc..ea194a9442 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -115,7 +115,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, windows-latest, macos-latest] + os: [ubuntu-latest, windows-latest] runs-on: ${{ matrix.os }} From 0e6b94de78bb5b356d6fd14a6db91ceb8d76856d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 10:04:37 +0200 Subject: [PATCH 079/119] Minor --- Cargo.lock | 36 ++++++++++++++++---------------- crates/proc_macro_srv/Cargo.toml | 8 ++++--- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index efc17c4301..614548ccac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -901,6 +901,23 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "proc_macro_srv" +version = "0.0.0" +dependencies = [ + "cargo_metadata", + "difference", + "goblin", + "libloading", + "memmap", + "ra_mbe", + "ra_proc_macro", + "serde_derive", + "test_utils", + "toolchain", + "tt", +] + [[package]] name = "profile" version = "0.0.0" @@ -1132,23 +1149,6 @@ dependencies = [ "tt", ] -[[package]] -name = "proc_macro_srv" -version = "0.0.0" -dependencies = [ - "cargo_metadata", - "difference", - "goblin", - "libloading", - "memmap", - "ra_mbe", - "ra_proc_macro", - "serde_derive", - "test_utils", - "toolchain", - "tt", -] - [[package]] name = "ra_project_model" version = "0.1.0" @@ -1271,6 +1271,7 @@ dependencies = [ "oorandom", "parking_lot", "pico-args", + "proc_macro_srv", "profile", "ra_cfg", "ra_db", @@ -1280,7 +1281,6 @@ dependencies = [ "ra_ide", "ra_ide_db", "ra_mbe", - "proc_macro_srv", "ra_project_model", "ra_ssr", "rayon", diff --git a/crates/proc_macro_srv/Cargo.toml b/crates/proc_macro_srv/Cargo.toml index 775af890eb..f7d481cbab 100644 --- a/crates/proc_macro_srv/Cargo.toml +++ b/crates/proc_macro_srv/Cargo.toml @@ -9,12 +9,13 @@ edition = "2018" doctest = false [dependencies] -tt = { path = "../tt" } -ra_mbe = { path = "../ra_mbe" } -ra_proc_macro = { path = "../ra_proc_macro" } goblin = "0.2.1" libloading = "0.6.0" memmap = "0.7" + +tt = { path = "../tt" } +ra_mbe = { path = "../ra_mbe" } +ra_proc_macro = { path = "../ra_proc_macro" } test_utils = { path = "../test_utils" } [dev-dependencies] @@ -22,4 +23,5 @@ cargo_metadata = "0.11.1" difference = "2.0.0" # used as proc macro test target serde_derive = "1.0.106" + toolchain = { path = "../toolchain" } From d42ba6397668fe28bd9cd92db829755905469a69 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 10:04:55 +0200 Subject: [PATCH 080/119] :arrow_up: crates --- Cargo.lock | 55 +++++++++++++++++++----------------------------------- 1 file changed, 19 insertions(+), 36 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 614548ccac..6bace7bd23 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15,15 +15,6 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" -[[package]] -name = "aho-corasick" -version = "0.7.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043164d8ba5c4c3035fec9bbee8647c0261d788f3474306f93bb65901cae0e86" -dependencies = [ - "memchr", -] - [[package]] name = "ansi_term" version = "0.12.1" @@ -289,9 +280,9 @@ checksum = "9bda8e21c04aca2ae33ffc2fd8c23134f3cac46db123ba97bd9d3f3b8a4a85e1" [[package]] name = "either" -version = "1.5.3" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" +checksum = "cd56b59865bce947ac5958779cfa508f6c3b9497cc762b7e24a12d11ccde2c4f" [[package]] name = "ena" @@ -551,9 +542,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "lazycell" -version = "1.2.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" @@ -644,12 +635,6 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" -[[package]] -name = "memchr" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" - [[package]] name = "memmap" version = "0.7.0" @@ -1219,10 +1204,7 @@ version = "1.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6" dependencies = [ - "aho-corasick", - "memchr", "regex-syntax", - "thread_local", ] [[package]] @@ -1414,18 +1396,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.114" +version = "1.0.115" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5317f7588f0a5078ee60ef675ef96735a1442132dc645eb1d12c018620ed8cd3" +checksum = "e54c9a88f2da7238af84b5101443f0c0d0a3bbdc455e34a5c9497b1903ed55d5" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.114" +version = "1.0.115" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0be94b04690fbaed37cddffc5c134bf537c8e3329d53e982fe04c374978f8e" +checksum = "609feed1d0a73cc36a0182a840a9b37b4a82f0b1150369f0536a9e3f2a31dc48" dependencies = [ "proc-macro2", "quote", @@ -1471,9 +1453,9 @@ checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" [[package]] name = "smallvec" -version = "1.4.1" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3757cb9d89161a2f24e1cf78efa0c1fcff485d18e3f55e0aa3480824ddaa0f3f" +checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252" [[package]] name = "smol_str" @@ -1614,9 +1596,9 @@ dependencies = [ [[package]] name = "tracing" -version = "0.1.18" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0aae59226cf195d8e74d4b34beae1859257efb4e5fed3f147d2dc2c7d372178" +checksum = "6d79ca061b032d6ce30c660fded31189ca0b9922bf483cd70759f13a2d86786c" dependencies = [ "cfg-if", "tracing-attributes", @@ -1625,9 +1607,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0693bf8d6f2bf22c690fc61a9d21ac69efdbb894a17ed596b9af0f01e64b84b" +checksum = "1fe233f4227389ab7df5b32649239da7ebe0b281824b4e84b342d04d3fd8c25e" dependencies = [ "proc-macro2", "quote", @@ -1636,9 +1618,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d593f98af59ebc017c0648f0117525db358745a8894a8d684e185ba3f45954f9" +checksum = "db63662723c316b43ca36d833707cc93dff82a02ba3d7e354f342682cc8b3545" dependencies = [ "lazy_static", ] @@ -1666,9 +1648,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7b33f8b2ef2ab0c3778c12646d9c42a24f7772bee4cdafc72199644a9f58fdc" +checksum = "abd165311cc4d7a555ad11cc77a37756df836182db0d81aac908c8184c584f40" dependencies = [ "ansi_term", "chrono", @@ -1679,6 +1661,7 @@ dependencies = [ "serde_json", "sharded-slab", "smallvec", + "thread_local", "tracing-core", "tracing-log", "tracing-serde", From 2f45cfc415626cfae5cba89c88a25fb3225486f7 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 10:08:11 +0200 Subject: [PATCH 081/119] Rename ra_mbe -> mbe --- Cargo.lock | 36 +++++++++---------- crates/{ra_mbe => mbe}/Cargo.toml | 15 ++++---- crates/{ra_mbe => mbe}/src/lib.rs | 0 crates/{ra_mbe => mbe}/src/mbe_expander.rs | 0 .../src/mbe_expander/matcher.rs | 0 .../src/mbe_expander/transcriber.rs | 0 crates/{ra_mbe => mbe}/src/parser.rs | 0 crates/{ra_mbe => mbe}/src/subtree_source.rs | 0 crates/{ra_mbe => mbe}/src/syntax_bridge.rs | 0 crates/{ra_mbe => mbe}/src/tests.rs | 0 crates/{ra_mbe => mbe}/src/tt_iter.rs | 0 crates/proc_macro_srv/Cargo.toml | 2 +- crates/proc_macro_srv/src/rustc_server.rs | 2 +- crates/ra_cfg/Cargo.toml | 2 +- crates/ra_cfg/src/cfg_expr.rs | 2 +- crates/ra_hir_def/Cargo.toml | 2 +- crates/ra_hir_expand/Cargo.toml | 2 +- crates/rust-analyzer/Cargo.toml | 2 +- xtask/tests/tidy.rs | 2 +- 19 files changed, 34 insertions(+), 33 deletions(-) rename crates/{ra_mbe => mbe}/Cargo.toml (90%) rename crates/{ra_mbe => mbe}/src/lib.rs (100%) rename crates/{ra_mbe => mbe}/src/mbe_expander.rs (100%) rename crates/{ra_mbe => mbe}/src/mbe_expander/matcher.rs (100%) rename crates/{ra_mbe => mbe}/src/mbe_expander/transcriber.rs (100%) rename crates/{ra_mbe => mbe}/src/parser.rs (100%) rename crates/{ra_mbe => mbe}/src/subtree_source.rs (100%) rename crates/{ra_mbe => mbe}/src/syntax_bridge.rs (100%) rename crates/{ra_mbe => mbe}/src/tests.rs (100%) rename crates/{ra_mbe => mbe}/src/tt_iter.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 6bace7bd23..a63cd58f27 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -635,6 +635,19 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" +[[package]] +name = "mbe" +version = "0.0.0" +dependencies = [ + "log", + "parser", + "rustc-hash", + "smallvec", + "syntax", + "test_utils", + "tt", +] + [[package]] name = "memmap" version = "0.7.0" @@ -894,8 +907,8 @@ dependencies = [ "difference", "goblin", "libloading", + "mbe", "memmap", - "ra_mbe", "ra_proc_macro", "serde_derive", "test_utils", @@ -946,7 +959,7 @@ dependencies = [ name = "ra_cfg" version = "0.1.0" dependencies = [ - "ra_mbe", + "mbe", "rustc-hash", "syntax", "tt", @@ -1006,12 +1019,12 @@ dependencies = [ "indexmap", "itertools", "log", + "mbe", "once_cell", "profile", "ra_cfg", "ra_db", "ra_hir_expand", - "ra_mbe", "rustc-hash", "smallvec", "stdx", @@ -1027,10 +1040,10 @@ dependencies = [ "arena", "either", "log", + "mbe", "parser", "profile", "ra_db", - "ra_mbe", "rustc-hash", "syntax", "test_utils", @@ -1109,19 +1122,6 @@ dependencies = [ "text_edit", ] -[[package]] -name = "ra_mbe" -version = "0.1.0" -dependencies = [ - "log", - "parser", - "rustc-hash", - "smallvec", - "syntax", - "test_utils", - "tt", -] - [[package]] name = "ra_proc_macro" version = "0.1.0" @@ -1249,6 +1249,7 @@ dependencies = [ "log", "lsp-server", "lsp-types", + "mbe", "mimalloc", "oorandom", "parking_lot", @@ -1262,7 +1263,6 @@ dependencies = [ "ra_hir_ty", "ra_ide", "ra_ide_db", - "ra_mbe", "ra_project_model", "ra_ssr", "rayon", diff --git a/crates/ra_mbe/Cargo.toml b/crates/mbe/Cargo.toml similarity index 90% rename from crates/ra_mbe/Cargo.toml rename to crates/mbe/Cargo.toml index 4a4be65ebc..1aba8b7c48 100644 --- a/crates/ra_mbe/Cargo.toml +++ b/crates/mbe/Cargo.toml @@ -1,20 +1,21 @@ [package] -edition = "2018" -name = "ra_mbe" -version = "0.1.0" -authors = ["rust-analyzer developers"] +name = "mbe" +version = "0.0.0" license = "MIT OR Apache-2.0" +authors = ["rust-analyzer developers"] +edition = "2018" [lib] doctest = false [dependencies] -syntax = { path = "../syntax" } -parser = { path = "../parser" } -tt = { path = "../tt" } rustc-hash = "1.1.0" smallvec = "1.2.0" log = "0.4.8" +syntax = { path = "../syntax" } +parser = { path = "../parser" } +tt = { path = "../tt" } + [dev-dependencies] test_utils = { path = "../test_utils" } diff --git a/crates/ra_mbe/src/lib.rs b/crates/mbe/src/lib.rs similarity index 100% rename from crates/ra_mbe/src/lib.rs rename to crates/mbe/src/lib.rs diff --git a/crates/ra_mbe/src/mbe_expander.rs b/crates/mbe/src/mbe_expander.rs similarity index 100% rename from crates/ra_mbe/src/mbe_expander.rs rename to crates/mbe/src/mbe_expander.rs diff --git a/crates/ra_mbe/src/mbe_expander/matcher.rs b/crates/mbe/src/mbe_expander/matcher.rs similarity index 100% rename from crates/ra_mbe/src/mbe_expander/matcher.rs rename to crates/mbe/src/mbe_expander/matcher.rs diff --git a/crates/ra_mbe/src/mbe_expander/transcriber.rs b/crates/mbe/src/mbe_expander/transcriber.rs similarity index 100% rename from crates/ra_mbe/src/mbe_expander/transcriber.rs rename to crates/mbe/src/mbe_expander/transcriber.rs diff --git a/crates/ra_mbe/src/parser.rs b/crates/mbe/src/parser.rs similarity index 100% rename from crates/ra_mbe/src/parser.rs rename to crates/mbe/src/parser.rs diff --git a/crates/ra_mbe/src/subtree_source.rs b/crates/mbe/src/subtree_source.rs similarity index 100% rename from crates/ra_mbe/src/subtree_source.rs rename to crates/mbe/src/subtree_source.rs diff --git a/crates/ra_mbe/src/syntax_bridge.rs b/crates/mbe/src/syntax_bridge.rs similarity index 100% rename from crates/ra_mbe/src/syntax_bridge.rs rename to crates/mbe/src/syntax_bridge.rs diff --git a/crates/ra_mbe/src/tests.rs b/crates/mbe/src/tests.rs similarity index 100% rename from crates/ra_mbe/src/tests.rs rename to crates/mbe/src/tests.rs diff --git a/crates/ra_mbe/src/tt_iter.rs b/crates/mbe/src/tt_iter.rs similarity index 100% rename from crates/ra_mbe/src/tt_iter.rs rename to crates/mbe/src/tt_iter.rs diff --git a/crates/proc_macro_srv/Cargo.toml b/crates/proc_macro_srv/Cargo.toml index f7d481cbab..0954ffb66f 100644 --- a/crates/proc_macro_srv/Cargo.toml +++ b/crates/proc_macro_srv/Cargo.toml @@ -14,7 +14,7 @@ libloading = "0.6.0" memmap = "0.7" tt = { path = "../tt" } -ra_mbe = { path = "../ra_mbe" } +mbe = { path = "../mbe" } ra_proc_macro = { path = "../ra_proc_macro" } test_utils = { path = "../test_utils" } diff --git a/crates/proc_macro_srv/src/rustc_server.rs b/crates/proc_macro_srv/src/rustc_server.rs index d534d1337f..7d1695c86a 100644 --- a/crates/proc_macro_srv/src/rustc_server.rs +++ b/crates/proc_macro_srv/src/rustc_server.rs @@ -182,7 +182,7 @@ pub mod token_stream { fn from_str(src: &str) -> Result { let (subtree, _token_map) = - ra_mbe::parse_to_token_tree(src).ok_or("Failed to parse from mbe")?; + mbe::parse_to_token_tree(src).ok_or("Failed to parse from mbe")?; let tt: tt::TokenTree = subtree.into(); Ok(tt.into()) diff --git a/crates/ra_cfg/Cargo.toml b/crates/ra_cfg/Cargo.toml index cb0d2b9d73..e77c7bd720 100644 --- a/crates/ra_cfg/Cargo.toml +++ b/crates/ra_cfg/Cargo.toml @@ -15,4 +15,4 @@ syntax = { path = "../syntax" } tt = { path = "../tt" } [dev-dependencies] -mbe = { path = "../ra_mbe", package = "ra_mbe" } +mbe = { path = "../mbe" } diff --git a/crates/ra_cfg/src/cfg_expr.rs b/crates/ra_cfg/src/cfg_expr.rs index 940091465c..fc93730d99 100644 --- a/crates/ra_cfg/src/cfg_expr.rs +++ b/crates/ra_cfg/src/cfg_expr.rs @@ -4,7 +4,7 @@ use std::slice::Iter as SliceIter; -use syntax::SmolStr; +use tt::SmolStr; #[derive(Debug, Clone, PartialEq, Eq)] pub enum CfgExpr { diff --git a/crates/ra_hir_def/Cargo.toml b/crates/ra_hir_def/Cargo.toml index 38129782fe..ba7916c305 100644 --- a/crates/ra_hir_def/Cargo.toml +++ b/crates/ra_hir_def/Cargo.toml @@ -28,7 +28,7 @@ syntax = { path = "../syntax" } profile = { path = "../profile" } hir_expand = { path = "../ra_hir_expand", package = "ra_hir_expand" } test_utils = { path = "../test_utils" } -mbe = { path = "../ra_mbe", package = "ra_mbe" } +mbe = { path = "../mbe" } ra_cfg = { path = "../ra_cfg" } tt = { path = "../tt" } diff --git a/crates/ra_hir_expand/Cargo.toml b/crates/ra_hir_expand/Cargo.toml index 153a70bdf5..cbb0ac29b8 100644 --- a/crates/ra_hir_expand/Cargo.toml +++ b/crates/ra_hir_expand/Cargo.toml @@ -19,5 +19,5 @@ syntax = { path = "../syntax" } parser = { path = "../parser" } profile = { path = "../profile" } tt = { path = "../tt" } -mbe = { path = "../ra_mbe", package = "ra_mbe" } +mbe = { path = "../mbe" } test_utils = { path = "../test_utils"} diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index 7713ed7eab..156f8d538e 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml @@ -60,5 +60,5 @@ winapi = "0.3.8" [dev-dependencies] expect = { path = "../expect" } test_utils = { path = "../test_utils" } -mbe = { path = "../ra_mbe", package = "ra_mbe" } +mbe = { path = "../mbe" } tt = { path = "../tt" } diff --git a/xtask/tests/tidy.rs b/xtask/tests/tidy.rs index 8c608284a4..0188aaa2ec 100644 --- a/xtask/tests/tidy.rs +++ b/xtask/tests/tidy.rs @@ -195,7 +195,7 @@ impl TidyDocs { "ra_hir", "ra_hir_expand", "ra_ide", - "ra_mbe", + "mbe", "parser", "profile", "ra_project_model", From 3615758f8ebf5d2cdd5d82f10daa596acfc1a64f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 10:15:45 +0200 Subject: [PATCH 082/119] Minimize deps --- crates/ra_cfg/Cargo.toml | 2 +- crates/ra_cfg/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/ra_cfg/Cargo.toml b/crates/ra_cfg/Cargo.toml index e77c7bd720..661e539043 100644 --- a/crates/ra_cfg/Cargo.toml +++ b/crates/ra_cfg/Cargo.toml @@ -11,8 +11,8 @@ doctest = false [dependencies] rustc-hash = "1.1.0" -syntax = { path = "../syntax" } tt = { path = "../tt" } [dev-dependencies] mbe = { path = "../mbe" } +syntax = { path = "../syntax" } diff --git a/crates/ra_cfg/src/lib.rs b/crates/ra_cfg/src/lib.rs index 7e025143bd..6fb37bf9f1 100644 --- a/crates/ra_cfg/src/lib.rs +++ b/crates/ra_cfg/src/lib.rs @@ -3,7 +3,7 @@ mod cfg_expr; use rustc_hash::FxHashSet; -use syntax::SmolStr; +use tt::SmolStr; pub use cfg_expr::CfgExpr; From 5734cc85868bf5fe2e4e023b40913b2063a78e31 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 10:17:59 +0200 Subject: [PATCH 083/119] Simplify --- crates/ra_cfg/src/cfg_expr.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/crates/ra_cfg/src/cfg_expr.rs b/crates/ra_cfg/src/cfg_expr.rs index fc93730d99..336fe25bc9 100644 --- a/crates/ra_cfg/src/cfg_expr.rs +++ b/crates/ra_cfg/src/cfg_expr.rs @@ -86,17 +86,15 @@ fn next_cfg_expr(it: &mut SliceIter) -> Option { mod tests { use super::*; - use mbe::{ast_to_token_tree, TokenMap}; + use mbe::ast_to_token_tree; use syntax::ast::{self, AstNode}; - fn get_token_tree_generated(input: &str) -> (tt::Subtree, TokenMap) { - let source_file = ast::SourceFile::parse(input).ok().unwrap(); - let tt = source_file.syntax().descendants().find_map(ast::TokenTree::cast).unwrap(); - ast_to_token_tree(&tt).unwrap() - } - fn assert_parse_result(input: &str, expected: CfgExpr) { - let (tt, _) = get_token_tree_generated(input); + let (tt, _) = { + let source_file = ast::SourceFile::parse(input).ok().unwrap(); + let tt = source_file.syntax().descendants().find_map(ast::TokenTree::cast).unwrap(); + ast_to_token_tree(&tt).unwrap() + }; let cfg = CfgExpr::parse(&tt); assert_eq!(cfg, expected); } From 68c223872562a8d746d4f1045d508887a0cbca5e Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 10:19:09 +0200 Subject: [PATCH 084/119] Rename ra_cfg -> cfg --- Cargo.lock | 30 +++++++++---------- crates/{ra_cfg => cfg}/Cargo.toml | 8 ++--- crates/{ra_cfg => cfg}/src/cfg_expr.rs | 0 crates/{ra_cfg => cfg}/src/lib.rs | 2 +- crates/ra_db/Cargo.toml | 2 +- crates/ra_db/src/fixture.rs | 2 +- crates/ra_db/src/input.rs | 2 +- crates/ra_hir_def/Cargo.toml | 2 +- crates/ra_hir_def/src/adt.rs | 2 +- crates/ra_hir_def/src/attr.rs | 2 +- crates/ra_hir_def/src/body.rs | 2 +- crates/ra_hir_def/src/nameres/collector.rs | 2 +- crates/ra_ide/Cargo.toml | 2 +- crates/ra_ide/src/lib.rs | 2 +- crates/ra_ide/src/mock_analysis.rs | 2 +- crates/ra_ide/src/parent_module.rs | 2 +- crates/ra_ide/src/runnables.rs | 2 +- crates/ra_project_model/Cargo.toml | 2 +- crates/ra_project_model/src/cfg_flag.rs | 2 +- crates/ra_project_model/src/lib.rs | 2 +- crates/rust-analyzer/Cargo.toml | 2 +- crates/rust-analyzer/src/cargo_target_spec.rs | 4 +-- 22 files changed, 39 insertions(+), 39 deletions(-) rename crates/{ra_cfg => cfg}/Cargo.toml (88%) rename crates/{ra_cfg => cfg}/src/cfg_expr.rs (100%) rename crates/{ra_cfg => cfg}/src/lib.rs (95%) diff --git a/Cargo.lock b/Cargo.lock index a63cd58f27..18c979b39e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -112,6 +112,16 @@ version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9a06fb2e53271d7c279ec1efea6ab691c35a2ae67ec0d91d7acec0caf13b518" +[[package]] +name = "cfg" +version = "0.0.0" +dependencies = [ + "mbe", + "rustc-hash", + "syntax", + "tt", +] + [[package]] name = "cfg-if" version = "0.1.10" @@ -955,22 +965,12 @@ dependencies = [ "text_edit", ] -[[package]] -name = "ra_cfg" -version = "0.1.0" -dependencies = [ - "mbe", - "rustc-hash", - "syntax", - "tt", -] - [[package]] name = "ra_db" version = "0.1.0" dependencies = [ + "cfg", "profile", - "ra_cfg", "rustc-hash", "salsa", "stdx", @@ -1012,6 +1012,7 @@ version = "0.1.0" dependencies = [ "anymap", "arena", + "cfg", "drop_bomb", "either", "expect", @@ -1022,7 +1023,6 @@ dependencies = [ "mbe", "once_cell", "profile", - "ra_cfg", "ra_db", "ra_hir_expand", "rustc-hash", @@ -1082,6 +1082,7 @@ dependencies = [ name = "ra_ide" version = "0.1.0" dependencies = [ + "cfg", "either", "expect", "indexmap", @@ -1090,7 +1091,6 @@ dependencies = [ "oorandom", "profile", "ra_assists", - "ra_cfg", "ra_db", "ra_fmt", "ra_hir", @@ -1141,9 +1141,9 @@ dependencies = [ "anyhow", "arena", "cargo_metadata", + "cfg", "log", "paths", - "ra_cfg", "ra_db", "ra_proc_macro", "rustc-hash", @@ -1240,6 +1240,7 @@ name = "rust-analyzer" version = "0.1.0" dependencies = [ "anyhow", + "cfg", "crossbeam-channel", "env_logger", "expect", @@ -1256,7 +1257,6 @@ dependencies = [ "pico-args", "proc_macro_srv", "profile", - "ra_cfg", "ra_db", "ra_hir", "ra_hir_def", diff --git a/crates/ra_cfg/Cargo.toml b/crates/cfg/Cargo.toml similarity index 88% rename from crates/ra_cfg/Cargo.toml rename to crates/cfg/Cargo.toml index 661e539043..d2ea551d18 100644 --- a/crates/ra_cfg/Cargo.toml +++ b/crates/cfg/Cargo.toml @@ -1,9 +1,9 @@ [package] -edition = "2018" -name = "ra_cfg" -version = "0.1.0" -authors = ["rust-analyzer developers"] +name = "cfg" +version = "0.0.0" license = "MIT OR Apache-2.0" +authors = ["rust-analyzer developers"] +edition = "2018" [lib] doctest = false diff --git a/crates/ra_cfg/src/cfg_expr.rs b/crates/cfg/src/cfg_expr.rs similarity index 100% rename from crates/ra_cfg/src/cfg_expr.rs rename to crates/cfg/src/cfg_expr.rs diff --git a/crates/ra_cfg/src/lib.rs b/crates/cfg/src/lib.rs similarity index 95% rename from crates/ra_cfg/src/lib.rs rename to crates/cfg/src/lib.rs index 6fb37bf9f1..a9d50e698a 100644 --- a/crates/ra_cfg/src/lib.rs +++ b/crates/cfg/src/lib.rs @@ -1,4 +1,4 @@ -//! ra_cfg defines conditional compiling options, `cfg` attibute parser and evaluator +//! cfg defines conditional compiling options, `cfg` attibute parser and evaluator mod cfg_expr; diff --git a/crates/ra_db/Cargo.toml b/crates/ra_db/Cargo.toml index 156ea1ee4b..ad432f096a 100644 --- a/crates/ra_db/Cargo.toml +++ b/crates/ra_db/Cargo.toml @@ -13,7 +13,7 @@ salsa = "0.15.2" rustc-hash = "1.1.0" syntax = { path = "../syntax" } -ra_cfg = { path = "../ra_cfg" } +cfg = { path = "../cfg" } profile = { path = "../profile" } tt = { path = "../tt" } test_utils = { path = "../test_utils" } diff --git a/crates/ra_db/src/fixture.rs b/crates/ra_db/src/fixture.rs index 2aafb99654..5ff8ead0e5 100644 --- a/crates/ra_db/src/fixture.rs +++ b/crates/ra_db/src/fixture.rs @@ -59,7 +59,7 @@ //! ``` use std::{str::FromStr, sync::Arc}; -use ra_cfg::CfgOptions; +use cfg::CfgOptions; use rustc_hash::FxHashMap; use test_utils::{extract_range_or_offset, Fixture, RangeOrOffset, CURSOR_MARKER}; use vfs::{file_set::FileSet, VfsPath}; diff --git a/crates/ra_db/src/input.rs b/crates/ra_db/src/input.rs index 12a8634997..f3d65cdf02 100644 --- a/crates/ra_db/src/input.rs +++ b/crates/ra_db/src/input.rs @@ -8,7 +8,7 @@ use std::{fmt, iter::FromIterator, ops, str::FromStr, sync::Arc}; -use ra_cfg::CfgOptions; +use cfg::CfgOptions; use rustc_hash::{FxHashMap, FxHashSet}; use syntax::SmolStr; use tt::TokenExpander; diff --git a/crates/ra_hir_def/Cargo.toml b/crates/ra_hir_def/Cargo.toml index ba7916c305..e7d3c4d5be 100644 --- a/crates/ra_hir_def/Cargo.toml +++ b/crates/ra_hir_def/Cargo.toml @@ -29,7 +29,7 @@ profile = { path = "../profile" } hir_expand = { path = "../ra_hir_expand", package = "ra_hir_expand" } test_utils = { path = "../test_utils" } mbe = { path = "../mbe" } -ra_cfg = { path = "../ra_cfg" } +cfg = { path = "../cfg" } tt = { path = "../tt" } [dev-dependencies] diff --git a/crates/ra_hir_def/src/adt.rs b/crates/ra_hir_def/src/adt.rs index c83219d771..d69ff2fc79 100644 --- a/crates/ra_hir_def/src/adt.rs +++ b/crates/ra_hir_def/src/adt.rs @@ -23,7 +23,7 @@ use crate::{ EnumId, HasModule, LocalEnumVariantId, LocalFieldId, Lookup, ModuleId, StructId, UnionId, VariantId, }; -use ra_cfg::CfgOptions; +use cfg::CfgOptions; /// Note that we use `StructData` for unions as well! #[derive(Debug, Clone, PartialEq, Eq)] diff --git a/crates/ra_hir_def/src/attr.rs b/crates/ra_hir_def/src/attr.rs index 36dc8b8166..1e5b06ca02 100644 --- a/crates/ra_hir_def/src/attr.rs +++ b/crates/ra_hir_def/src/attr.rs @@ -5,7 +5,7 @@ use std::{ops, sync::Arc}; use either::Either; use hir_expand::{hygiene::Hygiene, AstId, InFile}; use mbe::ast_to_token_tree; -use ra_cfg::{CfgExpr, CfgOptions}; +use cfg::{CfgExpr, CfgOptions}; use syntax::{ ast::{self, AstNode, AttrsOwner}, SmolStr, diff --git a/crates/ra_hir_def/src/body.rs b/crates/ra_hir_def/src/body.rs index 7c33966a71..3568513d1e 100644 --- a/crates/ra_hir_def/src/body.rs +++ b/crates/ra_hir_def/src/body.rs @@ -9,7 +9,7 @@ use arena::{map::ArenaMap, Arena}; use drop_bomb::DropBomb; use either::Either; use hir_expand::{ast_id_map::AstIdMap, hygiene::Hygiene, AstId, HirFileId, InFile, MacroDefId}; -use ra_cfg::CfgOptions; +use cfg::CfgOptions; use ra_db::CrateId; use rustc_hash::FxHashMap; use syntax::{ast, AstNode, AstPtr}; diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index f7270ec91c..fa2dadfc5b 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs @@ -11,7 +11,7 @@ use hir_expand::{ proc_macro::ProcMacroExpander, HirFileId, MacroCallId, MacroDefId, MacroDefKind, }; -use ra_cfg::CfgOptions; +use cfg::CfgOptions; use ra_db::{CrateId, FileId, ProcMacroId}; use rustc_hash::FxHashMap; use syntax::ast; diff --git a/crates/ra_ide/Cargo.toml b/crates/ra_ide/Cargo.toml index 8e0fa59178..c60e555455 100644 --- a/crates/ra_ide/Cargo.toml +++ b/crates/ra_ide/Cargo.toml @@ -25,7 +25,7 @@ syntax = { path = "../syntax" } text_edit = { path = "../text_edit" } ra_db = { path = "../ra_db" } ra_ide_db = { path = "../ra_ide_db" } -ra_cfg = { path = "../ra_cfg" } +cfg = { path = "../cfg" } ra_fmt = { path = "../ra_fmt" } profile = { path = "../profile" } test_utils = { path = "../test_utils" } diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs index 20967ba990..1fdf17800d 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ra_ide/src/lib.rs @@ -47,7 +47,7 @@ mod typing; use std::sync::Arc; -use ra_cfg::CfgOptions; +use cfg::CfgOptions; use ra_db::{ salsa::{self, ParallelDatabase}, CheckCanceled, Env, FileLoader, FileSet, SourceDatabase, VfsPath, diff --git a/crates/ra_ide/src/mock_analysis.rs b/crates/ra_ide/src/mock_analysis.rs index c7e0f4b58f..a4691f0284 100644 --- a/crates/ra_ide/src/mock_analysis.rs +++ b/crates/ra_ide/src/mock_analysis.rs @@ -1,7 +1,7 @@ //! FIXME: write short doc here use std::sync::Arc; -use ra_cfg::CfgOptions; +use cfg::CfgOptions; use ra_db::{CrateName, FileSet, SourceRoot, VfsPath}; use test_utils::{ extract_annotations, extract_range_or_offset, Fixture, RangeOrOffset, CURSOR_MARKER, diff --git a/crates/ra_ide/src/parent_module.rs b/crates/ra_ide/src/parent_module.rs index 69af0c86ad..b78388e6b1 100644 --- a/crates/ra_ide/src/parent_module.rs +++ b/crates/ra_ide/src/parent_module.rs @@ -63,7 +63,7 @@ pub(crate) fn crate_for(db: &RootDatabase, file_id: FileId) -> Vec { #[cfg(test)] mod tests { - use ra_cfg::CfgOptions; + use cfg::CfgOptions; use ra_db::Env; use test_utils::mark; diff --git a/crates/ra_ide/src/runnables.rs b/crates/ra_ide/src/runnables.rs index 54cb3b3094..7d8a210b7f 100644 --- a/crates/ra_ide/src/runnables.rs +++ b/crates/ra_ide/src/runnables.rs @@ -2,7 +2,7 @@ use std::fmt; use hir::{AsAssocItem, Attrs, HirFileId, InFile, Semantics}; use itertools::Itertools; -use ra_cfg::CfgExpr; +use cfg::CfgExpr; use ra_ide_db::RootDatabase; use syntax::{ ast::{self, AstNode, AttrsOwner, DocCommentsOwner, ModuleItemOwner, NameOwner}, diff --git a/crates/ra_project_model/Cargo.toml b/crates/ra_project_model/Cargo.toml index 171fe86264..52f2d57b3b 100644 --- a/crates/ra_project_model/Cargo.toml +++ b/crates/ra_project_model/Cargo.toml @@ -15,7 +15,7 @@ rustc-hash = "1.1.0" cargo_metadata = "0.11.1" arena = { path = "../arena" } -ra_cfg = { path = "../ra_cfg" } +cfg = { path = "../cfg" } ra_db = { path = "../ra_db" } toolchain = { path = "../toolchain" } ra_proc_macro = { path = "../ra_proc_macro" } diff --git a/crates/ra_project_model/src/cfg_flag.rs b/crates/ra_project_model/src/cfg_flag.rs index bd50056c68..e92962cf67 100644 --- a/crates/ra_project_model/src/cfg_flag.rs +++ b/crates/ra_project_model/src/cfg_flag.rs @@ -3,7 +3,7 @@ //! rustc main.rs --cfg foo --cfg 'feature="bar"' use std::str::FromStr; -use ra_cfg::CfgOptions; +use cfg::CfgOptions; use stdx::split_once; #[derive(Clone, Eq, PartialEq, Debug)] diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs index 46f44910c0..47e7d24203 100644 --- a/crates/ra_project_model/src/lib.rs +++ b/crates/ra_project_model/src/lib.rs @@ -13,7 +13,7 @@ use std::{ use anyhow::{bail, Context, Result}; use paths::{AbsPath, AbsPathBuf}; -use ra_cfg::CfgOptions; +use cfg::CfgOptions; use ra_db::{CrateGraph, CrateId, CrateName, Edition, Env, FileId}; use rustc_hash::{FxHashMap, FxHashSet}; diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index 156f8d538e..440b1cd134 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml @@ -42,7 +42,7 @@ syntax = { path = "../syntax" } text_edit = { path = "../text_edit" } vfs = { path = "../vfs" } vfs-notify = { path = "../vfs-notify" } -ra_cfg = { path = "../ra_cfg" } +cfg = { path = "../cfg" } toolchain = { path = "../toolchain" } # This should only be used in CLI diff --git a/crates/rust-analyzer/src/cargo_target_spec.rs b/crates/rust-analyzer/src/cargo_target_spec.rs index 7929368c0c..87ddd25bf2 100644 --- a/crates/rust-analyzer/src/cargo_target_spec.rs +++ b/crates/rust-analyzer/src/cargo_target_spec.rs @@ -1,6 +1,6 @@ //! See `CargoTargetSpec` -use ra_cfg::CfgExpr; +use cfg::CfgExpr; use ra_ide::{FileId, RunnableKind, TestId}; use ra_project_model::{self, TargetKind}; use vfs::AbsPathBuf; @@ -178,7 +178,7 @@ mod tests { use super::*; use mbe::ast_to_token_tree; - use ra_cfg::CfgExpr; + use cfg::CfgExpr; use syntax::{ ast::{self, AstNode}, SmolStr, From 7d9480c6eb43b3ef1bd75ad26e99c14cca5cb366 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 10:32:19 +0200 Subject: [PATCH 085/119] fmt --- crates/ra_hir_def/src/attr.rs | 2 +- crates/ra_hir_def/src/body.rs | 2 +- crates/ra_hir_def/src/nameres/collector.rs | 2 +- crates/ra_ide/src/runnables.rs | 2 +- crates/ra_project_model/src/lib.rs | 2 +- crates/rust-analyzer/src/cargo_target_spec.rs | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/ra_hir_def/src/attr.rs b/crates/ra_hir_def/src/attr.rs index 1e5b06ca02..dea552a605 100644 --- a/crates/ra_hir_def/src/attr.rs +++ b/crates/ra_hir_def/src/attr.rs @@ -2,10 +2,10 @@ use std::{ops, sync::Arc}; +use cfg::{CfgExpr, CfgOptions}; use either::Either; use hir_expand::{hygiene::Hygiene, AstId, InFile}; use mbe::ast_to_token_tree; -use cfg::{CfgExpr, CfgOptions}; use syntax::{ ast::{self, AstNode, AttrsOwner}, SmolStr, diff --git a/crates/ra_hir_def/src/body.rs b/crates/ra_hir_def/src/body.rs index 3568513d1e..fe659386a3 100644 --- a/crates/ra_hir_def/src/body.rs +++ b/crates/ra_hir_def/src/body.rs @@ -6,10 +6,10 @@ pub mod scope; use std::{mem, ops::Index, sync::Arc}; use arena::{map::ArenaMap, Arena}; +use cfg::CfgOptions; use drop_bomb::DropBomb; use either::Either; use hir_expand::{ast_id_map::AstIdMap, hygiene::Hygiene, AstId, HirFileId, InFile, MacroDefId}; -use cfg::CfgOptions; use ra_db::CrateId; use rustc_hash::FxHashMap; use syntax::{ast, AstNode, AstPtr}; diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index fa2dadfc5b..6a58919360 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs @@ -3,6 +3,7 @@ //! `DefCollector::collect` contains the fixed-point iteration loop which //! resolves imports and expands macros. +use cfg::CfgOptions; use hir_expand::{ ast_id_map::FileAstId, builtin_derive::find_builtin_derive, @@ -11,7 +12,6 @@ use hir_expand::{ proc_macro::ProcMacroExpander, HirFileId, MacroCallId, MacroDefId, MacroDefKind, }; -use cfg::CfgOptions; use ra_db::{CrateId, FileId, ProcMacroId}; use rustc_hash::FxHashMap; use syntax::ast; diff --git a/crates/ra_ide/src/runnables.rs b/crates/ra_ide/src/runnables.rs index 7d8a210b7f..fb40762cfb 100644 --- a/crates/ra_ide/src/runnables.rs +++ b/crates/ra_ide/src/runnables.rs @@ -1,8 +1,8 @@ use std::fmt; +use cfg::CfgExpr; use hir::{AsAssocItem, Attrs, HirFileId, InFile, Semantics}; use itertools::Itertools; -use cfg::CfgExpr; use ra_ide_db::RootDatabase; use syntax::{ ast::{self, AstNode, AttrsOwner, DocCommentsOwner, ModuleItemOwner, NameOwner}, diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs index 47e7d24203..ee42198f35 100644 --- a/crates/ra_project_model/src/lib.rs +++ b/crates/ra_project_model/src/lib.rs @@ -12,8 +12,8 @@ use std::{ }; use anyhow::{bail, Context, Result}; -use paths::{AbsPath, AbsPathBuf}; use cfg::CfgOptions; +use paths::{AbsPath, AbsPathBuf}; use ra_db::{CrateGraph, CrateId, CrateName, Edition, Env, FileId}; use rustc_hash::{FxHashMap, FxHashSet}; diff --git a/crates/rust-analyzer/src/cargo_target_spec.rs b/crates/rust-analyzer/src/cargo_target_spec.rs index 87ddd25bf2..9c7a9cce61 100644 --- a/crates/rust-analyzer/src/cargo_target_spec.rs +++ b/crates/rust-analyzer/src/cargo_target_spec.rs @@ -177,8 +177,8 @@ fn required_features(cfg_expr: &CfgExpr, features: &mut Vec) { mod tests { use super::*; - use mbe::ast_to_token_tree; use cfg::CfgExpr; + use mbe::ast_to_token_tree; use syntax::{ ast::{self, AstNode}, SmolStr, From 982b29925275403697b52dd88bd79868ea8b67d9 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 10:53:34 +0200 Subject: [PATCH 086/119] Temporary disable MacOS builder GH Actions is not feeling great today :-( --- .github/workflows/ci.yaml | 2 +- bors.toml | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ea194a9442..2deb009cef 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -25,7 +25,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, windows-latest, macos-latest] + os: [ubuntu-latest, windows-latest] #, macos-latest] steps: - name: Checkout repository diff --git a/bors.toml b/bors.toml index 13ce236df5..4c980a24d3 100644 --- a/bors.toml +++ b/bors.toml @@ -1,9 +1,8 @@ status = [ "Rust (ubuntu-latest)", "Rust (windows-latest)", - "Rust (macos-latest)", + # "Rust (macos-latest)", "TypeScript (ubuntu-latest)", "TypeScript (windows-latest)", - "TypeScript (macos-latest)", ] delete_merged_branches = true From 26b98b07aa0e4430bc872b28eadbc822cfee7b6e Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 10:32:03 +0200 Subject: [PATCH 087/119] Cleanup **Move Guard** assist --- crates/ra_assists/src/handlers/move_guard.rs | 222 +++++++++---------- crates/ra_assists/src/tests/generated.rs | 4 +- crates/syntax/src/ast/edit.rs | 3 + 3 files changed, 112 insertions(+), 117 deletions(-) diff --git a/crates/ra_assists/src/handlers/move_guard.rs b/crates/ra_assists/src/handlers/move_guard.rs index c62ebc3061..452115fe67 100644 --- a/crates/ra_assists/src/handlers/move_guard.rs +++ b/crates/ra_assists/src/handlers/move_guard.rs @@ -1,5 +1,5 @@ use syntax::{ - ast::{AstNode, IfExpr, MatchArm}, + ast::{edit::AstNodeEdit, make, AstNode, IfExpr, MatchArm}, SyntaxKind::WHITESPACE, }; @@ -25,7 +25,9 @@ use crate::{AssistContext, AssistId, AssistKind, Assists}; // // fn handle(action: Action) { // match action { -// Action::Move { distance } => if distance > 10 { foo() }, +// Action::Move { distance } => if distance > 10 { +// foo() +// }, // _ => (), // } // } @@ -35,9 +37,13 @@ pub(crate) fn move_guard_to_arm_body(acc: &mut Assists, ctx: &AssistContext) -> let guard = match_arm.guard()?; let space_before_guard = guard.syntax().prev_sibling_or_token(); - let guard_conditions = guard.expr()?; + let guard_condition = guard.expr()?; let arm_expr = match_arm.expr()?; - let buf = format!("if {} {{ {} }}", guard_conditions.syntax().text(), arm_expr.syntax().text()); + let if_expr = make::expr_if( + make::condition(guard_condition, None), + make::block_expr(None, Some(arm_expr.clone())), + ) + .indent(arm_expr.indent_level()); let target = guard.syntax().text_range(); acc.add( @@ -53,7 +59,7 @@ pub(crate) fn move_guard_to_arm_body(acc: &mut Assists, ctx: &AssistContext) -> }; edit.delete(guard.syntax().text_range()); - edit.replace_node_and_indent(arm_expr.syntax(), buf); + edit.replace_ast(arm_expr, if_expr); }, ) } @@ -134,16 +140,14 @@ mod tests { check_assist_target( move_guard_to_arm_body, r#" - fn f() { - let t = 'a'; - let chars = "abcd"; - match t { - '\r' <|>if chars.clone().next() == Some('\n') => false, - _ => true - } - } - "#, - r#"if chars.clone().next() == Some('\n')"#, +fn main() { + match 92 { + x <|>if x > 10 => false, + _ => true + } +} +"#, + r#"if x > 10"#, ); } @@ -152,25 +156,23 @@ mod tests { check_assist( move_guard_to_arm_body, r#" - fn f() { - let t = 'a'; - let chars = "abcd"; - match t { - '\r' <|>if chars.clone().next() == Some('\n') => false, - _ => true - } - } - "#, +fn main() { + match 92 { + x <|>if x > 10 => false, + _ => true + } +} +"#, r#" - fn f() { - let t = 'a'; - let chars = "abcd"; - match t { - '\r' => if chars.clone().next() == Some('\n') { false }, - _ => true - } - } - "#, +fn main() { + match 92 { + x => if x > 10 { + false + }, + _ => true + } +} +"#, ); } @@ -179,21 +181,23 @@ mod tests { check_assist( move_guard_to_arm_body, r#" - fn f() { - match x { - <|>y @ 4 | y @ 5 if y > 5 => true, - _ => false - } - } - "#, +fn main() { + match 92 { + <|>x @ 4 | x @ 5 if x > 5 => true, + _ => false + } +} +"#, r#" - fn f() { - match x { - y @ 4 | y @ 5 => if y > 5 { true }, - _ => false - } - } - "#, +fn main() { + match 92 { + x @ 4 | x @ 5 => if x > 5 { + true + }, + _ => false + } +} +"#, ); } @@ -202,25 +206,21 @@ mod tests { check_assist( move_arm_cond_to_match_guard, r#" - fn f() { - let t = 'a'; - let chars = "abcd"; - match t { - '\r' => if chars.clone().next() == Some('\n') { <|>false }, - _ => true - } - } - "#, +fn main() { + match 92 { + x => if x > 10 { <|>false }, + _ => true + } +} +"#, r#" - fn f() { - let t = 'a'; - let chars = "abcd"; - match t { - '\r' if chars.clone().next() == Some('\n') => false, - _ => true - } - } - "#, +fn main() { + match 92 { + x if x > 10 => false, + _ => true + } +} +"#, ); } @@ -229,15 +229,13 @@ mod tests { check_assist_not_applicable( move_arm_cond_to_match_guard, r#" - fn f() { - let t = 'a'; - let chars = "abcd"; - match t { - '\r' => if let Some(_) = chars.clone().next() { <|>false }, - _ => true - } - } - "#, +fn main() { + match 92 { + x => if let 62 = x { <|>false }, + _ => true + } +} +"#, ); } @@ -246,25 +244,21 @@ mod tests { check_assist( move_arm_cond_to_match_guard, r#" - fn f() { - let t = 'a'; - let chars = "abcd"; - match t { - '\r' => if chars.clone().next().is_some() { <|> }, - _ => true - } - } - "#, +fn main() { + match 92 { + x => if x > 10 { <|> }, + _ => true + } +} +"#, r#" - fn f() { - let t = 'a'; - let chars = "abcd"; - match t { - '\r' if chars.clone().next().is_some() => { }, - _ => true - } - } - "#, +fn main() { + match 92 { + x if x > 10 => { }, + _ => true + } +} +"#, ); } @@ -273,31 +267,27 @@ mod tests { check_assist( move_arm_cond_to_match_guard, r#" - fn f() { - let mut t = 'a'; - let chars = "abcd"; - match t { - '\r' => if chars.clone().next().is_some() { - t = 'e';<|> - false - }, - _ => true - } - } - "#, +fn main() { + match 92 { + x => if x > 10 { + 92;<|> + false + }, + _ => true + } +} +"#, r#" - fn f() { - let mut t = 'a'; - let chars = "abcd"; - match t { - '\r' if chars.clone().next().is_some() => { - t = 'e'; - false - }, - _ => true - } - } - "#, +fn main() { + match 92 { + x if x > 10 => { + 92; + false + }, + _ => true + } +} +"#, ); } } diff --git a/crates/ra_assists/src/tests/generated.rs b/crates/ra_assists/src/tests/generated.rs index 97978e7a2e..d16e6fb0a6 100644 --- a/crates/ra_assists/src/tests/generated.rs +++ b/crates/ra_assists/src/tests/generated.rs @@ -690,7 +690,9 @@ enum Action { Move { distance: u32 }, Stop } fn handle(action: Action) { match action { - Action::Move { distance } => if distance > 10 { foo() }, + Action::Move { distance } => if distance > 10 { + foo() + }, _ => (), } } diff --git a/crates/syntax/src/ast/edit.rs b/crates/syntax/src/ast/edit.rs index 2667d9af4c..190746e09e 100644 --- a/crates/syntax/src/ast/edit.rs +++ b/crates/syntax/src/ast/edit.rs @@ -601,6 +601,9 @@ pub trait AstNodeEdit: AstNode + Clone + Sized { } rewriter.rewrite_ast(self) } + fn indent_level(&self) -> IndentLevel { + IndentLevel::from_node(self.syntax()) + } #[must_use] fn indent(&self, level: IndentLevel) -> Self { Self::cast(level.increase_indent(self.syntax().clone())).unwrap() From b0f03db51dc84aac56c807ecf4da8151c01e3c04 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 11:32:45 +0200 Subject: [PATCH 088/119] Remove deprecated function --- crates/ra_assists/src/assist_context.rs | 17 +---- .../handlers/change_return_type_to_result.rs | 73 ++++++++++--------- crates/ra_fmt/src/lib.rs | 5 -- crates/syntax/src/ast/make.rs | 7 ++ 4 files changed, 48 insertions(+), 54 deletions(-) diff --git a/crates/ra_assists/src/assist_context.rs b/crates/ra_assists/src/assist_context.rs index 217f692a4e..368d48a712 100644 --- a/crates/ra_assists/src/assist_context.rs +++ b/crates/ra_assists/src/assist_context.rs @@ -5,14 +5,13 @@ use std::mem; use algo::find_covering_element; use hir::Semantics; use ra_db::{FileId, FileRange}; -use ra_fmt::{leading_indent, reindent}; use ra_ide_db::{ source_change::{SourceChange, SourceFileEdit}, RootDatabase, }; use syntax::{ algo::{self, find_node_at_offset, SyntaxRewriter}, - AstNode, SourceFile, SyntaxElement, SyntaxKind, SyntaxNode, SyntaxToken, TextRange, TextSize, + AstNode, SourceFile, SyntaxElement, SyntaxKind, SyntaxToken, TextRange, TextSize, TokenAtOffset, }; use text_edit::{TextEdit, TextEditBuilder}; @@ -269,20 +268,6 @@ impl AssistBuilder { pub(crate) fn replace_ast(&mut self, old: N, new: N) { algo::diff(old.syntax(), new.syntax()).into_text_edit(&mut self.edit) } - /// Replaces specified `node` of text with a given string, reindenting the - /// string to maintain `node`'s existing indent. - // FIXME: remove in favor of syntax::edit::IndentLevel::increase_indent - pub(crate) fn replace_node_and_indent( - &mut self, - node: &SyntaxNode, - replace_with: impl Into, - ) { - let mut replace_with = replace_with.into(); - if let Some(indent) = leading_indent(node) { - replace_with = reindent(&replace_with, &indent) - } - self.replace(node.text_range(), replace_with) - } pub(crate) fn rewrite(&mut self, rewriter: SyntaxRewriter) { let node = rewriter.rewrite_root().unwrap(); let new = rewriter.rewrite(&node); diff --git a/crates/ra_assists/src/handlers/change_return_type_to_result.rs b/crates/ra_assists/src/handlers/change_return_type_to_result.rs index d5a68a24c9..be480943c5 100644 --- a/crates/ra_assists/src/handlers/change_return_type_to_result.rs +++ b/crates/ra_assists/src/handlers/change_return_type_to_result.rs @@ -1,10 +1,12 @@ +use std::iter; + use syntax::{ - ast::{self, BlockExpr, Expr, LoopBodyOwner}, + ast::{self, make, BlockExpr, Expr, LoopBodyOwner}, AstNode, SyntaxNode, }; +use test_utils::mark; use crate::{AssistContext, AssistId, AssistKind, Assists}; -use test_utils::mark; // Assist: change_return_type_to_result // @@ -44,7 +46,13 @@ pub(crate) fn change_return_type_to_result(acc: &mut Assists, ctx: &AssistContex tail_return_expr_collector.collect_tail_exprs(block_expr); for ret_expr_arg in tail_return_expr_collector.exprs_to_wrap { - builder.replace_node_and_indent(&ret_expr_arg, format!("Ok({})", ret_expr_arg)); + let ok_wrapped = make::expr_call( + make::expr_path(make::path_unqualified(make::path_segment(make::name_ref( + "Ok", + )))), + make::arg_list(iter::once(ret_expr_arg.clone())), + ); + builder.replace_ast(ret_expr_arg, ok_wrapped); } match ctx.config.snippet_cap { @@ -60,7 +68,7 @@ pub(crate) fn change_return_type_to_result(acc: &mut Assists, ctx: &AssistContex } struct TailReturnCollector { - exprs_to_wrap: Vec, + exprs_to_wrap: Vec, } impl TailReturnCollector { @@ -86,7 +94,8 @@ impl TailReturnCollector { if let Some(last_exprs) = get_tail_expr_from_block(&expr) { for last_expr in last_exprs { let last_expr = match last_expr { - NodeType::Node(expr) | NodeType::Leaf(expr) => expr, + NodeType::Node(expr) => expr, + NodeType::Leaf(expr) => expr.syntax().clone(), }; if let Some(last_expr) = Expr::cast(last_expr.clone()) { @@ -113,12 +122,12 @@ impl TailReturnCollector { } Expr::ReturnExpr(ret_expr) => { if let Some(ret_expr_arg) = &ret_expr.expr() { - self.exprs_to_wrap.push(ret_expr_arg.syntax().clone()); + self.exprs_to_wrap.push(ret_expr_arg.clone()); } } Expr::BreakExpr(break_expr) if collect_break => { if let Some(break_expr_arg) = &break_expr.expr() { - self.exprs_to_wrap.push(break_expr_arg.syntax().clone()); + self.exprs_to_wrap.push(break_expr_arg.clone()); } } Expr::IfExpr(if_expr) => { @@ -166,14 +175,11 @@ impl TailReturnCollector { NodeType::Leaf(expr) => { self.exprs_to_wrap.push(expr.clone()); } - NodeType::Node(expr) => match &Expr::cast(expr.clone()) { - Some(last_expr) => { - self.fetch_tail_exprs(last_expr); + NodeType::Node(expr) => { + if let Some(last_expr) = Expr::cast(expr.clone()) { + self.fetch_tail_exprs(&last_expr); } - None => { - self.exprs_to_wrap.push(expr.clone()); - } - }, + } } } } @@ -182,7 +188,7 @@ impl TailReturnCollector { #[derive(Debug)] enum NodeType { - Leaf(SyntaxNode), + Leaf(ast::Expr), Node(SyntaxNode), } @@ -233,25 +239,26 @@ fn get_tail_expr_from_block(expr: &Expr) -> Option> { Some(arms) } - Expr::BreakExpr(expr) => expr.expr().map(|e| vec![NodeType::Leaf(e.syntax().clone())]), + Expr::BreakExpr(expr) => expr.expr().map(|e| vec![NodeType::Leaf(e)]), Expr::ReturnExpr(ret_expr) => Some(vec![NodeType::Node(ret_expr.syntax().clone())]), - Expr::CallExpr(call_expr) => Some(vec![NodeType::Leaf(call_expr.syntax().clone())]), - Expr::Literal(lit_expr) => Some(vec![NodeType::Leaf(lit_expr.syntax().clone())]), - Expr::TupleExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), - Expr::ArrayExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), - Expr::ParenExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), - Expr::PathExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), - Expr::RecordExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), - Expr::IndexExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), - Expr::MethodCallExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), - Expr::AwaitExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), - Expr::CastExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), - Expr::RefExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), - Expr::PrefixExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), - Expr::RangeExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), - Expr::BinExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), - Expr::MacroCall(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), - Expr::BoxExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), + + Expr::CallExpr(_) + | Expr::Literal(_) + | Expr::TupleExpr(_) + | Expr::ArrayExpr(_) + | Expr::ParenExpr(_) + | Expr::PathExpr(_) + | Expr::RecordExpr(_) + | Expr::IndexExpr(_) + | Expr::MethodCallExpr(_) + | Expr::AwaitExpr(_) + | Expr::CastExpr(_) + | Expr::RefExpr(_) + | Expr::PrefixExpr(_) + | Expr::RangeExpr(_) + | Expr::BinExpr(_) + | Expr::MacroCall(_) + | Expr::BoxExpr(_) => Some(vec![NodeType::Leaf(expr.clone())]), _ => None, } } diff --git a/crates/ra_fmt/src/lib.rs b/crates/ra_fmt/src/lib.rs index d0bf0593f7..397a3c3ae0 100644 --- a/crates/ra_fmt/src/lib.rs +++ b/crates/ra_fmt/src/lib.rs @@ -10,11 +10,6 @@ use syntax::{ SyntaxNode, SyntaxToken, T, }; -pub fn reindent(text: &str, indent: &str) -> String { - let indent = format!("\n{}", indent); - text.lines().intersperse(&indent).collect() -} - /// If the node is on the beginning of the line, calculate indent. pub fn leading_indent(node: &SyntaxNode) -> Option { for token in prev_tokens(node.first_token()?) { diff --git a/crates/syntax/src/ast/make.rs b/crates/syntax/src/ast/make.rs index 3009faed71..d20c085aa0 100644 --- a/crates/syntax/src/ast/make.rs +++ b/crates/syntax/src/ast/make.rs @@ -134,6 +134,9 @@ pub fn expr_prefix(op: SyntaxKind, expr: ast::Expr) -> ast::Expr { let token = token(op); expr_from_text(&format!("{}{}", token, expr)) } +pub fn expr_call(f: ast::Expr, arg_list: ast::ArgList) -> ast::Expr { + expr_from_text(&format!("{}{}", f, arg_list)) +} fn expr_from_text(text: &str) -> ast::Expr { ast_from_text(&format!("const C: () = {};", text)) } @@ -151,6 +154,10 @@ pub fn condition(expr: ast::Expr, pattern: Option) -> ast::Condition { } } +pub fn arg_list(args: impl IntoIterator) -> ast::ArgList { + ast_from_text(&format!("fn main() {{ ()({}) }}", args.into_iter().format(", "))) +} + pub fn ident_pat(name: ast::Name) -> ast::IdentPat { return from_text(name.text()); From f0a9128761e8dd42f0dd40610a1d8734a52f3d9c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 11:41:20 +0200 Subject: [PATCH 089/119] Minor --- .../src/handlers/replace_if_let_with_match.rs | 6 ++- .../ra_assists/src/handlers/unwrap_block.rs | 3 +- crates/ra_assists/src/utils.rs | 38 ++++++++++++++++++ crates/ra_fmt/src/lib.rs | 40 +------------------ crates/ra_ide/src/join_lines.rs | 3 +- 5 files changed, 46 insertions(+), 44 deletions(-) diff --git a/crates/ra_assists/src/handlers/replace_if_let_with_match.rs b/crates/ra_assists/src/handlers/replace_if_let_with_match.rs index 2442f049b6..79097621e6 100644 --- a/crates/ra_assists/src/handlers/replace_if_let_with_match.rs +++ b/crates/ra_assists/src/handlers/replace_if_let_with_match.rs @@ -1,4 +1,3 @@ -use ra_fmt::unwrap_trivial_block; use syntax::{ ast::{ self, @@ -8,7 +7,10 @@ use syntax::{ AstNode, }; -use crate::{utils::TryEnum, AssistContext, AssistId, AssistKind, Assists}; +use crate::{ + utils::{unwrap_trivial_block, TryEnum}, + AssistContext, AssistId, AssistKind, Assists, +}; // Assist: replace_if_let_with_match // diff --git a/crates/ra_assists/src/handlers/unwrap_block.rs b/crates/ra_assists/src/handlers/unwrap_block.rs index 2879090b86..3851aeb3e7 100644 --- a/crates/ra_assists/src/handlers/unwrap_block.rs +++ b/crates/ra_assists/src/handlers/unwrap_block.rs @@ -1,4 +1,3 @@ -use ra_fmt::unwrap_trivial_block; use syntax::{ ast::{ self, @@ -7,7 +6,7 @@ use syntax::{ AstNode, TextRange, T, }; -use crate::{AssistContext, AssistId, AssistKind, Assists}; +use crate::{utils::unwrap_trivial_block, AssistContext, AssistId, AssistKind, Assists}; // Assist: unwrap_block // diff --git a/crates/ra_assists/src/utils.rs b/crates/ra_assists/src/utils.rs index 6d85661c46..a20453dd87 100644 --- a/crates/ra_assists/src/utils.rs +++ b/crates/ra_assists/src/utils.rs @@ -4,6 +4,7 @@ pub(crate) mod insert_use; use std::{iter, ops}; use hir::{Adt, Crate, Enum, ScopeDef, Semantics, Trait, Type}; +use itertools::Itertools; use ra_ide_db::RootDatabase; use rustc_hash::FxHashSet; use syntax::{ @@ -17,6 +18,43 @@ use crate::assist_config::SnippetCap; pub(crate) use insert_use::{find_insert_use_container, insert_use_statement}; +pub(crate) fn unwrap_trivial_block(block: ast::BlockExpr) -> ast::Expr { + extract_trivial_expression(&block) + .filter(|expr| !expr.syntax().text().contains_char('\n')) + .unwrap_or_else(|| block.into()) +} + +pub fn extract_trivial_expression(block: &ast::BlockExpr) -> Option { + let has_anything_else = |thing: &SyntaxNode| -> bool { + let mut non_trivial_children = + block.syntax().children_with_tokens().filter(|it| match it.kind() { + WHITESPACE | T!['{'] | T!['}'] => false, + _ => it.as_node() != Some(thing), + }); + non_trivial_children.next().is_some() + }; + + if let Some(expr) = block.expr() { + if has_anything_else(expr.syntax()) { + return None; + } + return Some(expr); + } + // Unwrap `{ continue; }` + let (stmt,) = block.statements().next_tuple()?; + if let ast::Stmt::ExprStmt(expr_stmt) = stmt { + if has_anything_else(expr_stmt.syntax()) { + return None; + } + let expr = expr_stmt.expr()?; + match expr.syntax().kind() { + CONTINUE_EXPR | BREAK_EXPR | RETURN_EXPR => return Some(expr), + _ => (), + } + } + None +} + #[derive(Clone, Copy, Debug)] pub(crate) enum Cursor<'a> { Replace(&'a SyntaxNode), diff --git a/crates/ra_fmt/src/lib.rs b/crates/ra_fmt/src/lib.rs index 397a3c3ae0..d0004654b3 100644 --- a/crates/ra_fmt/src/lib.rs +++ b/crates/ra_fmt/src/lib.rs @@ -2,9 +2,8 @@ use std::iter::successors; -use itertools::Itertools; use syntax::{ - ast::{self, AstNode, AstToken}, + ast::{self, AstToken}, SmolStr, SyntaxKind, SyntaxKind::*, SyntaxNode, SyntaxToken, T, @@ -30,43 +29,6 @@ fn prev_tokens(token: SyntaxToken) -> impl Iterator { successors(token.prev_token(), |token| token.prev_token()) } -pub fn unwrap_trivial_block(block: ast::BlockExpr) -> ast::Expr { - extract_trivial_expression(&block) - .filter(|expr| !expr.syntax().text().contains_char('\n')) - .unwrap_or_else(|| block.into()) -} - -pub fn extract_trivial_expression(block: &ast::BlockExpr) -> Option { - let has_anything_else = |thing: &SyntaxNode| -> bool { - let mut non_trivial_children = - block.syntax().children_with_tokens().filter(|it| match it.kind() { - WHITESPACE | T!['{'] | T!['}'] => false, - _ => it.as_node() != Some(thing), - }); - non_trivial_children.next().is_some() - }; - - if let Some(expr) = block.expr() { - if has_anything_else(expr.syntax()) { - return None; - } - return Some(expr); - } - // Unwrap `{ continue; }` - let (stmt,) = block.statements().next_tuple()?; - if let ast::Stmt::ExprStmt(expr_stmt) = stmt { - if has_anything_else(expr_stmt.syntax()) { - return None; - } - let expr = expr_stmt.expr()?; - match expr.syntax().kind() { - CONTINUE_EXPR | BREAK_EXPR | RETURN_EXPR => return Some(expr), - _ => (), - } - } - None -} - pub fn compute_ws(left: SyntaxKind, right: SyntaxKind) -> &'static str { match left { T!['('] | T!['['] => return "", diff --git a/crates/ra_ide/src/join_lines.rs b/crates/ra_ide/src/join_lines.rs index 35cec87f67..574ce219d9 100644 --- a/crates/ra_ide/src/join_lines.rs +++ b/crates/ra_ide/src/join_lines.rs @@ -1,5 +1,6 @@ use itertools::Itertools; -use ra_fmt::{compute_ws, extract_trivial_expression}; +use ra_assists::utils::extract_trivial_expression; +use ra_fmt::compute_ws; use syntax::{ algo::{find_covering_element, non_trivia_sibling}, ast::{self, AstNode, AstToken}, From 80c241b39a02a949c745676e22b28db95186feda Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 11:44:39 +0200 Subject: [PATCH 090/119] Minor --- crates/ra_fmt/src/lib.rs | 27 +-------------------------- crates/ra_ide/src/join_lines.rs | 26 ++++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/crates/ra_fmt/src/lib.rs b/crates/ra_fmt/src/lib.rs index d0004654b3..b92477f9e7 100644 --- a/crates/ra_fmt/src/lib.rs +++ b/crates/ra_fmt/src/lib.rs @@ -4,9 +4,7 @@ use std::iter::successors; use syntax::{ ast::{self, AstToken}, - SmolStr, SyntaxKind, - SyntaxKind::*, - SyntaxNode, SyntaxToken, T, + SmolStr, SyntaxNode, SyntaxToken, }; /// If the node is on the beginning of the line, calculate indent. @@ -28,26 +26,3 @@ pub fn leading_indent(node: &SyntaxNode) -> Option { fn prev_tokens(token: SyntaxToken) -> impl Iterator { successors(token.prev_token(), |token| token.prev_token()) } - -pub fn compute_ws(left: SyntaxKind, right: SyntaxKind) -> &'static str { - match left { - T!['('] | T!['['] => return "", - T!['{'] => { - if let USE_TREE = right { - return ""; - } - } - _ => (), - } - match right { - T![')'] | T![']'] => return "", - T!['}'] => { - if let USE_TREE = left { - return ""; - } - } - T![.] => return "", - _ => (), - } - " " -} diff --git a/crates/ra_ide/src/join_lines.rs b/crates/ra_ide/src/join_lines.rs index 574ce219d9..f5c3107015 100644 --- a/crates/ra_ide/src/join_lines.rs +++ b/crates/ra_ide/src/join_lines.rs @@ -1,11 +1,10 @@ use itertools::Itertools; use ra_assists::utils::extract_trivial_expression; -use ra_fmt::compute_ws; use syntax::{ algo::{find_covering_element, non_trivia_sibling}, ast::{self, AstNode, AstToken}, Direction, NodeOrToken, SourceFile, - SyntaxKind::{self, WHITESPACE}, + SyntaxKind::{self, USE_TREE, WHITESPACE}, SyntaxNode, SyntaxToken, TextRange, TextSize, T, }; use text_edit::{TextEdit, TextEditBuilder}; @@ -169,6 +168,29 @@ fn is_trailing_comma(left: SyntaxKind, right: SyntaxKind) -> bool { matches!((left, right), (T![,], T![')']) | (T![,], T![']'])) } +fn compute_ws(left: SyntaxKind, right: SyntaxKind) -> &'static str { + match left { + T!['('] | T!['['] => return "", + T!['{'] => { + if let USE_TREE = right { + return ""; + } + } + _ => (), + } + match right { + T![')'] | T![']'] => return "", + T!['}'] => { + if let USE_TREE = left { + return ""; + } + } + T![.] => return "", + _ => (), + } + " " +} + #[cfg(test)] mod tests { use syntax::SourceFile; From 479235ff0b25dbac977d28475b9203e3207b117b Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 11:47:31 +0200 Subject: [PATCH 091/119] Minor --- .../src/handlers/extract_struct_from_enum_variant.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs b/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs index 6e9f2d0fc7..b4e19b3dc7 100644 --- a/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs +++ b/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs @@ -6,7 +6,7 @@ use rustc_hash::FxHashSet; use syntax::{ algo::find_node_at_offset, ast::{self, ArgListOwner, AstNode, NameOwner, VisibilityOwner}, - SourceFile, SyntaxNode, TextRange, TextSize, + SourceFile, TextRange, TextSize, }; use crate::{ @@ -72,7 +72,7 @@ pub(crate) fn extract_struct_from_enum_variant( } extract_struct_def( builder, - enum_ast.syntax(), + &enum_ast, &variant_name, &field_list.to_string(), start_offset, @@ -112,9 +112,10 @@ fn insert_import( Some(()) } +// FIXME: this should use strongly-typed `make`, rather than string manipulation1 fn extract_struct_def( builder: &mut AssistBuilder, - enum_ast: &SyntaxNode, + enum_: &ast::Enum, variant_name: &str, variant_list: &str, start_offset: TextSize, @@ -126,7 +127,7 @@ fn extract_struct_def( } else { "".to_string() }; - let indent = if let Some(indent) = leading_indent(enum_ast) { + let indent = if let Some(indent) = leading_indent(enum_.syntax()) { indent.to_string() } else { "".to_string() From c81f6230da98fd3e3fa91c0896d65922a1ed4a24 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 11:56:11 +0200 Subject: [PATCH 092/119] Remove ra_fmt crate --- Cargo.lock | 10 ------- crates/ra_assists/Cargo.toml | 1 - .../extract_struct_from_enum_variant.rs | 11 ++------ crates/ra_assists/src/utils/insert_use.rs | 27 ++++++++++++++++-- crates/ra_fmt/Cargo.toml | 15 ---------- crates/ra_fmt/src/lib.rs | 28 ------------------- crates/ra_ide/Cargo.toml | 1 - crates/ra_ide/src/typing.rs | 5 ++-- 8 files changed, 29 insertions(+), 69 deletions(-) delete mode 100644 crates/ra_fmt/Cargo.toml delete mode 100644 crates/ra_fmt/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 18c979b39e..5f7b85b059 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -955,7 +955,6 @@ dependencies = [ "itertools", "profile", "ra_db", - "ra_fmt", "ra_hir", "ra_ide_db", "rustc-hash", @@ -980,14 +979,6 @@ dependencies = [ "vfs", ] -[[package]] -name = "ra_fmt" -version = "0.1.0" -dependencies = [ - "itertools", - "syntax", -] - [[package]] name = "ra_hir" version = "0.1.0" @@ -1092,7 +1083,6 @@ dependencies = [ "profile", "ra_assists", "ra_db", - "ra_fmt", "ra_hir", "ra_ide_db", "ra_ssr", diff --git a/crates/ra_assists/Cargo.toml b/crates/ra_assists/Cargo.toml index abc290463a..83e44c1243 100644 --- a/crates/ra_assists/Cargo.toml +++ b/crates/ra_assists/Cargo.toml @@ -17,7 +17,6 @@ stdx = { path = "../stdx" } syntax = { path = "../syntax" } text_edit = { path = "../text_edit" } -ra_fmt = { path = "../ra_fmt" } profile = { path = "../profile" } ra_db = { path = "../ra_db" } ra_ide_db = { path = "../ra_ide_db" } diff --git a/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs b/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs index b4e19b3dc7..497f887cd1 100644 --- a/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs +++ b/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs @@ -1,11 +1,10 @@ use hir::{EnumVariant, Module, ModuleDef, Name}; use ra_db::FileId; -use ra_fmt::leading_indent; use ra_ide_db::{defs::Definition, search::Reference, RootDatabase}; use rustc_hash::FxHashSet; use syntax::{ algo::find_node_at_offset, - ast::{self, ArgListOwner, AstNode, NameOwner, VisibilityOwner}, + ast::{self, edit::IndentLevel, ArgListOwner, AstNode, NameOwner, VisibilityOwner}, SourceFile, TextRange, TextSize, }; @@ -112,7 +111,7 @@ fn insert_import( Some(()) } -// FIXME: this should use strongly-typed `make`, rather than string manipulation1 +// FIXME: this should use strongly-typed `make`, rather than string manipulation. fn extract_struct_def( builder: &mut AssistBuilder, enum_: &ast::Enum, @@ -127,11 +126,7 @@ fn extract_struct_def( } else { "".to_string() }; - let indent = if let Some(indent) = leading_indent(enum_.syntax()) { - indent.to_string() - } else { - "".to_string() - }; + let indent = IndentLevel::from_node(enum_.syntax()); let struct_def = format!( r#"{}struct {}{}; diff --git a/crates/ra_assists/src/utils/insert_use.rs b/crates/ra_assists/src/utils/insert_use.rs index f89c288da4..50a62ee829 100644 --- a/crates/ra_assists/src/utils/insert_use.rs +++ b/crates/ra_assists/src/utils/insert_use.rs @@ -2,13 +2,15 @@ // FIXME: rewrite according to the plan, outlined in // https://github.com/rust-analyzer/rust-analyzer/issues/3301#issuecomment-592931553 +use std::iter::successors; + use either::Either; use hir::{self, ModPath}; use syntax::{ ast::{self, NameOwner, VisibilityOwner}, - AstNode, Direction, SmolStr, + AstNode, AstToken, Direction, SmolStr, SyntaxKind::{PATH, PATH_SEGMENT}, - SyntaxNode, T, + SyntaxNode, SyntaxToken, T, }; use text_edit::TextEditBuilder; @@ -442,7 +444,7 @@ fn make_assist_add_new_use( edit: &mut TextEditBuilder, ) { if let Some(anchor) = anchor { - let indent = ra_fmt::leading_indent(anchor); + let indent = leading_indent(anchor); let mut buf = String::new(); if after { buf.push_str("\n"); @@ -524,3 +526,22 @@ fn make_assist_add_nested_import( edit.insert(end, "}".to_string()); } } + +/// If the node is on the beginning of the line, calculate indent. +fn leading_indent(node: &SyntaxNode) -> Option { + for token in prev_tokens(node.first_token()?) { + if let Some(ws) = ast::Whitespace::cast(token.clone()) { + let ws_text = ws.text(); + if let Some(pos) = ws_text.rfind('\n') { + return Some(ws_text[pos + 1..].into()); + } + } + if token.text().contains('\n') { + break; + } + } + return None; + fn prev_tokens(token: SyntaxToken) -> impl Iterator { + successors(token.prev_token(), |token| token.prev_token()) + } +} diff --git a/crates/ra_fmt/Cargo.toml b/crates/ra_fmt/Cargo.toml deleted file mode 100644 index d42ca62be2..0000000000 --- a/crates/ra_fmt/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[package] -edition = "2018" -name = "ra_fmt" -version = "0.1.0" -authors = ["rust-analyzer developers"] -publish = false -license = "MIT OR Apache-2.0" - -[lib] -doctest = false - -[dependencies] -itertools = "0.9.0" - -syntax = { path = "../syntax" } diff --git a/crates/ra_fmt/src/lib.rs b/crates/ra_fmt/src/lib.rs deleted file mode 100644 index b92477f9e7..0000000000 --- a/crates/ra_fmt/src/lib.rs +++ /dev/null @@ -1,28 +0,0 @@ -//! This crate provides some utilities for indenting rust code. - -use std::iter::successors; - -use syntax::{ - ast::{self, AstToken}, - SmolStr, SyntaxNode, SyntaxToken, -}; - -/// If the node is on the beginning of the line, calculate indent. -pub fn leading_indent(node: &SyntaxNode) -> Option { - for token in prev_tokens(node.first_token()?) { - if let Some(ws) = ast::Whitespace::cast(token.clone()) { - let ws_text = ws.text(); - if let Some(pos) = ws_text.rfind('\n') { - return Some(ws_text[pos + 1..].into()); - } - } - if token.text().contains('\n') { - break; - } - } - None -} - -fn prev_tokens(token: SyntaxToken) -> impl Iterator { - successors(token.prev_token(), |token| token.prev_token()) -} diff --git a/crates/ra_ide/Cargo.toml b/crates/ra_ide/Cargo.toml index c60e555455..938398a41a 100644 --- a/crates/ra_ide/Cargo.toml +++ b/crates/ra_ide/Cargo.toml @@ -26,7 +26,6 @@ text_edit = { path = "../text_edit" } ra_db = { path = "../ra_db" } ra_ide_db = { path = "../ra_ide_db" } cfg = { path = "../cfg" } -ra_fmt = { path = "../ra_fmt" } profile = { path = "../profile" } test_utils = { path = "../test_utils" } ra_assists = { path = "../ra_assists" } diff --git a/crates/ra_ide/src/typing.rs b/crates/ra_ide/src/typing.rs index c408b1d521..7897c57b77 100644 --- a/crates/ra_ide/src/typing.rs +++ b/crates/ra_ide/src/typing.rs @@ -16,11 +16,10 @@ mod on_enter; use ra_db::{FilePosition, SourceDatabase}; -use ra_fmt::leading_indent; use ra_ide_db::{source_change::SourceFileEdit, RootDatabase}; use syntax::{ algo::find_node_at_offset, - ast::{self, AstToken}, + ast::{self, edit::IndentLevel, AstToken}, AstNode, SourceFile, SyntaxKind::{FIELD_EXPR, METHOD_CALL_EXPR}, TextRange, TextSize, @@ -104,7 +103,7 @@ fn on_dot_typed(file: &SourceFile, offset: TextSize) -> Option { if !matches!(parent.kind(), FIELD_EXPR | METHOD_CALL_EXPR) { return None; } - let prev_indent = leading_indent(&parent)?; + let prev_indent = IndentLevel::from_node(&parent); let target_indent = format!(" {}", prev_indent); let target_indent_len = TextSize::of(&target_indent); if current_indent_len == target_indent_len { From eac24d52e672c0a9c118e8969bf1b839c3e7f1f3 Mon Sep 17 00:00:00 2001 From: Pavan Kumar Sunkara Date: Thu, 13 Aug 2020 12:05:30 +0200 Subject: [PATCH 093/119] Rename ra_project_model -> project_model --- Cargo.lock | 40 +++++++++---------- .../Cargo.toml | 17 ++++---- .../src/cargo_workspace.rs | 0 .../src/cfg_flag.rs | 0 .../src/lib.rs | 0 .../src/project_json.rs | 0 .../src/sysroot.rs | 0 crates/rust-analyzer/Cargo.toml | 2 +- crates/rust-analyzer/src/bin/main.rs | 2 +- crates/rust-analyzer/src/cargo_target_spec.rs | 2 +- crates/rust-analyzer/src/cli/load_cargo.rs | 2 +- crates/rust-analyzer/src/config.rs | 2 +- crates/rust-analyzer/src/global_state.rs | 2 +- crates/rust-analyzer/src/handlers.rs | 2 +- crates/rust-analyzer/src/main_loop.rs | 2 +- crates/rust-analyzer/src/reload.rs | 6 +-- .../tests/heavy_tests/support.rs | 2 +- xtask/tests/tidy.rs | 2 +- 18 files changed, 40 insertions(+), 43 deletions(-) rename crates/{ra_project_model => project_model}/Cargo.toml (91%) rename crates/{ra_project_model => project_model}/src/cargo_workspace.rs (100%) rename crates/{ra_project_model => project_model}/src/cfg_flag.rs (100%) rename crates/{ra_project_model => project_model}/src/lib.rs (100%) rename crates/{ra_project_model => project_model}/src/project_json.rs (100%) rename crates/{ra_project_model => project_model}/src/sysroot.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 18c979b39e..f72d9e022d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -938,6 +938,25 @@ dependencies = [ "perf-event", ] +[[package]] +name = "project_model" +version = "0.0.0" +dependencies = [ + "anyhow", + "arena", + "cargo_metadata", + "cfg", + "log", + "paths", + "ra_db", + "ra_proc_macro", + "rustc-hash", + "serde", + "serde_json", + "stdx", + "toolchain", +] + [[package]] name = "quote" version = "1.0.7" @@ -1134,25 +1153,6 @@ dependencies = [ "tt", ] -[[package]] -name = "ra_project_model" -version = "0.1.0" -dependencies = [ - "anyhow", - "arena", - "cargo_metadata", - "cfg", - "log", - "paths", - "ra_db", - "ra_proc_macro", - "rustc-hash", - "serde", - "serde_json", - "stdx", - "toolchain", -] - [[package]] name = "ra_ssr" version = "0.1.0" @@ -1257,13 +1257,13 @@ dependencies = [ "pico-args", "proc_macro_srv", "profile", + "project_model", "ra_db", "ra_hir", "ra_hir_def", "ra_hir_ty", "ra_ide", "ra_ide_db", - "ra_project_model", "ra_ssr", "rayon", "rustc-hash", diff --git a/crates/ra_project_model/Cargo.toml b/crates/project_model/Cargo.toml similarity index 91% rename from crates/ra_project_model/Cargo.toml rename to crates/project_model/Cargo.toml index 52f2d57b3b..8d8d093879 100644 --- a/crates/ra_project_model/Cargo.toml +++ b/crates/project_model/Cargo.toml @@ -1,9 +1,9 @@ [package] -edition = "2018" -name = "ra_project_model" -version = "0.1.0" -authors = ["rust-analyzer developers"] +name = "project_model" +version = "0.0.0" license = "MIT OR Apache-2.0" +authors = ["rust-analyzer developers"] +edition = "2018" [lib] doctest = false @@ -11,8 +11,10 @@ doctest = false [dependencies] log = "0.4.8" rustc-hash = "1.1.0" - cargo_metadata = "0.11.1" +serde = { version = "1.0.106", features = ["derive"] } +serde_json = "1.0.48" +anyhow = "1.0.26" arena = { path = "../arena" } cfg = { path = "../cfg" } @@ -21,8 +23,3 @@ toolchain = { path = "../toolchain" } ra_proc_macro = { path = "../ra_proc_macro" } paths = { path = "../paths" } stdx = { path = "../stdx" } - -serde = { version = "1.0.106", features = ["derive"] } -serde_json = "1.0.48" - -anyhow = "1.0.26" diff --git a/crates/ra_project_model/src/cargo_workspace.rs b/crates/project_model/src/cargo_workspace.rs similarity index 100% rename from crates/ra_project_model/src/cargo_workspace.rs rename to crates/project_model/src/cargo_workspace.rs diff --git a/crates/ra_project_model/src/cfg_flag.rs b/crates/project_model/src/cfg_flag.rs similarity index 100% rename from crates/ra_project_model/src/cfg_flag.rs rename to crates/project_model/src/cfg_flag.rs diff --git a/crates/ra_project_model/src/lib.rs b/crates/project_model/src/lib.rs similarity index 100% rename from crates/ra_project_model/src/lib.rs rename to crates/project_model/src/lib.rs diff --git a/crates/ra_project_model/src/project_json.rs b/crates/project_model/src/project_json.rs similarity index 100% rename from crates/ra_project_model/src/project_json.rs rename to crates/project_model/src/project_json.rs diff --git a/crates/ra_project_model/src/sysroot.rs b/crates/project_model/src/sysroot.rs similarity index 100% rename from crates/ra_project_model/src/sysroot.rs rename to crates/project_model/src/sysroot.rs diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index 440b1cd134..c6102bf272 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml @@ -37,7 +37,7 @@ lsp-server = "0.3.3" flycheck = { path = "../flycheck" } ra_ide = { path = "../ra_ide" } profile = { path = "../profile" } -ra_project_model = { path = "../ra_project_model" } +project_model = { path = "../project_model" } syntax = { path = "../syntax" } text_edit = { path = "../text_edit" } vfs = { path = "../vfs" } diff --git a/crates/rust-analyzer/src/bin/main.rs b/crates/rust-analyzer/src/bin/main.rs index f177f8709a..bade31ca24 100644 --- a/crates/rust-analyzer/src/bin/main.rs +++ b/crates/rust-analyzer/src/bin/main.rs @@ -6,7 +6,7 @@ mod args; use std::{convert::TryFrom, process}; use lsp_server::Connection; -use ra_project_model::ProjectManifest; +use project_model::ProjectManifest; use rust_analyzer::{ cli, config::{Config, LinkedProject}, diff --git a/crates/rust-analyzer/src/cargo_target_spec.rs b/crates/rust-analyzer/src/cargo_target_spec.rs index 9c7a9cce61..5ba30dbad6 100644 --- a/crates/rust-analyzer/src/cargo_target_spec.rs +++ b/crates/rust-analyzer/src/cargo_target_spec.rs @@ -1,8 +1,8 @@ //! See `CargoTargetSpec` use cfg::CfgExpr; +use project_model::{self, TargetKind}; use ra_ide::{FileId, RunnableKind, TestId}; -use ra_project_model::{self, TargetKind}; use vfs::AbsPathBuf; use crate::{global_state::GlobalStateSnapshot, Result}; diff --git a/crates/rust-analyzer/src/cli/load_cargo.rs b/crates/rust-analyzer/src/cli/load_cargo.rs index a43bf2244d..f6cb144c67 100644 --- a/crates/rust-analyzer/src/cli/load_cargo.rs +++ b/crates/rust-analyzer/src/cli/load_cargo.rs @@ -4,9 +4,9 @@ use std::{path::Path, sync::Arc}; use anyhow::Result; use crossbeam_channel::{unbounded, Receiver}; +use project_model::{CargoConfig, ProcMacroClient, ProjectManifest, ProjectWorkspace}; use ra_db::CrateGraph; use ra_ide::{AnalysisChange, AnalysisHost}; -use ra_project_model::{CargoConfig, ProcMacroClient, ProjectManifest, ProjectWorkspace}; use vfs::{loader::Handle, AbsPath, AbsPathBuf}; use crate::reload::{ProjectFolders, SourceRootConfig}; diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index 70b4512d0b..bfc84147c3 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs @@ -11,8 +11,8 @@ use std::{ffi::OsString, path::PathBuf}; use flycheck::FlycheckConfig; use lsp_types::ClientCapabilities; +use project_model::{CargoConfig, ProjectJson, ProjectJsonData, ProjectManifest}; use ra_ide::{AssistConfig, CompletionConfig, HoverConfig, InlayHintsConfig}; -use ra_project_model::{CargoConfig, ProjectJson, ProjectJsonData, ProjectManifest}; use serde::Deserialize; use vfs::AbsPathBuf; diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs index 8c115c8a67..2e8b708d0f 100644 --- a/crates/rust-analyzer/src/global_state.rs +++ b/crates/rust-analyzer/src/global_state.rs @@ -9,9 +9,9 @@ use crossbeam_channel::{unbounded, Receiver, Sender}; use flycheck::FlycheckHandle; use lsp_types::{SemanticTokens, Url}; use parking_lot::{Mutex, RwLock}; +use project_model::{CargoWorkspace, ProcMacroClient, ProjectWorkspace, Target}; use ra_db::{CrateId, VfsPath}; use ra_ide::{Analysis, AnalysisChange, AnalysisHost, FileId}; -use ra_project_model::{CargoWorkspace, ProcMacroClient, ProjectWorkspace, Target}; use rustc_hash::FxHashMap; use crate::{ diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index 86e7833f2f..4b5ca7eecf 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs @@ -18,11 +18,11 @@ use lsp_types::{ SemanticTokensRangeResult, SemanticTokensResult, SymbolInformation, SymbolTag, TextDocumentIdentifier, Url, WorkspaceEdit, }; +use project_model::TargetKind; use ra_ide::{ FileId, FilePosition, FileRange, HoverAction, HoverGotoTypeData, NavigationTarget, Query, RangeInfo, Runnable, RunnableKind, SearchScope, TextEdit, }; -use ra_project_model::TargetKind; use serde::{Deserialize, Serialize}; use serde_json::to_value; use stdx::{format_to, split_once}; diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index 32962b0885..9a779cb14e 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs @@ -21,7 +21,7 @@ use crate::{ lsp_utils::{apply_document_changes, is_canceled, notification_is, Progress}, Result, }; -use ra_project_model::ProjectWorkspace; +use project_model::ProjectWorkspace; use vfs::ChangeKind; pub fn main_loop(config: Config, connection: Connection) -> Result<()> { diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs index 611c9a89f5..640417dc65 100644 --- a/crates/rust-analyzer/src/reload.rs +++ b/crates/rust-analyzer/src/reload.rs @@ -2,9 +2,9 @@ use std::{mem, sync::Arc}; use flycheck::FlycheckHandle; +use project_model::{ProcMacroClient, ProjectWorkspace}; use ra_db::{CrateGraph, SourceRoot, VfsPath}; use ra_ide::AnalysisChange; -use ra_project_model::{ProcMacroClient, ProjectWorkspace}; use vfs::{file_set::FileSetConfig, AbsPath, AbsPathBuf, ChangeKind}; use crate::{ @@ -98,14 +98,14 @@ impl GlobalState { .iter() .map(|project| match project { LinkedProject::ProjectManifest(manifest) => { - ra_project_model::ProjectWorkspace::load( + project_model::ProjectWorkspace::load( manifest.clone(), &cargo_config, with_sysroot, ) } LinkedProject::InlineJsonProject(it) => { - Ok(ra_project_model::ProjectWorkspace::Json { project: it.clone() }) + Ok(project_model::ProjectWorkspace::Json { project: it.clone() }) } }) .collect::>(); diff --git a/crates/rust-analyzer/tests/heavy_tests/support.rs b/crates/rust-analyzer/tests/heavy_tests/support.rs index 15866fbb16..5bafeba797 100644 --- a/crates/rust-analyzer/tests/heavy_tests/support.rs +++ b/crates/rust-analyzer/tests/heavy_tests/support.rs @@ -12,7 +12,7 @@ use lsp_types::{ notification::Exit, request::Shutdown, TextDocumentIdentifier, Url, WorkDoneProgress, }; use lsp_types::{ProgressParams, ProgressParamsValue}; -use ra_project_model::ProjectManifest; +use project_model::ProjectManifest; use rust_analyzer::{ config::{ClientCapsConfig, Config, FilesConfig, FilesWatcher, LinkedProject}, main_loop, diff --git a/xtask/tests/tidy.rs b/xtask/tests/tidy.rs index 0188aaa2ec..2e68e71db2 100644 --- a/xtask/tests/tidy.rs +++ b/xtask/tests/tidy.rs @@ -198,7 +198,7 @@ impl TidyDocs { "mbe", "parser", "profile", - "ra_project_model", + "project_model", "syntax", "tt", "ra_hir_ty", From 3100de842b3cc33c9ad364f10c7f740ac760f564 Mon Sep 17 00:00:00 2001 From: David Lattimore Date: Wed, 5 Aug 2020 19:48:52 +1000 Subject: [PATCH 094/119] Structured search replace now handles UFCS calls to trait methods --- crates/ra_ssr/src/matching.rs | 67 ++++++++++++++++++++++++++++------ crates/ra_ssr/src/resolving.rs | 33 +++++++++++++++-- crates/ra_ssr/src/tests.rs | 29 +++++++++++++++ 3 files changed, 114 insertions(+), 15 deletions(-) diff --git a/crates/ra_ssr/src/matching.rs b/crates/ra_ssr/src/matching.rs index 125bf38951..6e0b923528 100644 --- a/crates/ra_ssr/src/matching.rs +++ b/crates/ra_ssr/src/matching.rs @@ -3,7 +3,7 @@ use crate::{ parsing::{Constraint, NodeKind, Placeholder}, - resolving::{ResolvedPattern, ResolvedRule}, + resolving::{ResolvedPattern, ResolvedRule, UfcsCallInfo}, SsrMatches, }; use hir::Semantics; @@ -190,11 +190,12 @@ impl<'db, 'sema> Matcher<'db, 'sema> { return Ok(()); } // We allow a UFCS call to match a method call, provided they resolve to the same function. - if let Some(pattern_function) = self.rule.pattern.ufcs_function_calls.get(pattern) { - if let (Some(pattern), Some(code)) = - (ast::CallExpr::cast(pattern.clone()), ast::MethodCallExpr::cast(code.clone())) - { - return self.attempt_match_ufcs(phase, &pattern, &code, *pattern_function); + if let Some(pattern_ufcs) = self.rule.pattern.ufcs_function_calls.get(pattern) { + if let Some(code) = ast::MethodCallExpr::cast(code.clone()) { + return self.attempt_match_ufcs_to_method_call(phase, pattern_ufcs, &code); + } + if let Some(code) = ast::CallExpr::cast(code.clone()) { + return self.attempt_match_ufcs_to_ufcs(phase, pattern_ufcs, &code); } } if pattern.kind() != code.kind() { @@ -521,23 +522,28 @@ impl<'db, 'sema> Matcher<'db, 'sema> { Ok(()) } - fn attempt_match_ufcs( + fn attempt_match_ufcs_to_method_call( &self, phase: &mut Phase, - pattern: &ast::CallExpr, + pattern_ufcs: &UfcsCallInfo, code: &ast::MethodCallExpr, - pattern_function: hir::Function, ) -> Result<(), MatchFailed> { use ast::ArgListOwner; let code_resolved_function = self .sema .resolve_method_call(code) .ok_or_else(|| match_error!("Failed to resolve method call"))?; - if pattern_function != code_resolved_function { + if pattern_ufcs.function != code_resolved_function { fail_match!("Method call resolved to a different function"); } + if code_resolved_function.has_self_param(self.sema.db) { + if let (Some(pattern_type), Some(expr)) = (&pattern_ufcs.qualifier_type, &code.expr()) { + self.check_expr_type(pattern_type, expr)?; + } + } // Check arguments. - let mut pattern_args = pattern + let mut pattern_args = pattern_ufcs + .call_expr .arg_list() .ok_or_else(|| match_error!("Pattern function call has no args"))? .args(); @@ -552,6 +558,45 @@ impl<'db, 'sema> Matcher<'db, 'sema> { } } + fn attempt_match_ufcs_to_ufcs( + &self, + phase: &mut Phase, + pattern_ufcs: &UfcsCallInfo, + code: &ast::CallExpr, + ) -> Result<(), MatchFailed> { + use ast::ArgListOwner; + // Check that the first argument is the expected type. + if let (Some(pattern_type), Some(expr)) = ( + &pattern_ufcs.qualifier_type, + &code.arg_list().and_then(|code_args| code_args.args().next()), + ) { + self.check_expr_type(pattern_type, expr)?; + } + self.attempt_match_node_children(phase, pattern_ufcs.call_expr.syntax(), code.syntax()) + } + + fn check_expr_type( + &self, + pattern_type: &hir::Type, + expr: &ast::Expr, + ) -> Result<(), MatchFailed> { + use hir::HirDisplay; + let code_type = self.sema.type_of_expr(&expr).ok_or_else(|| { + match_error!("Failed to get receiver type for `{}`", expr.syntax().text()) + })?; + if !code_type + .autoderef(self.sema.db) + .any(|deref_code_type| *pattern_type == deref_code_type) + { + fail_match!( + "Pattern type `{}` didn't match code type `{}`", + pattern_type.display(self.sema.db), + code_type.display(self.sema.db) + ); + } + Ok(()) + } + fn get_placeholder(&self, element: &SyntaxElement) -> Option<&Placeholder> { only_ident(element.clone()).and_then(|ident| self.rule.get_placeholder(&ident)) } diff --git a/crates/ra_ssr/src/resolving.rs b/crates/ra_ssr/src/resolving.rs index 7e7585c8bb..bfc20705b4 100644 --- a/crates/ra_ssr/src/resolving.rs +++ b/crates/ra_ssr/src/resolving.rs @@ -25,7 +25,7 @@ pub(crate) struct ResolvedPattern { pub(crate) node: SyntaxNode, // Paths in `node` that we've resolved. pub(crate) resolved_paths: FxHashMap, - pub(crate) ufcs_function_calls: FxHashMap, + pub(crate) ufcs_function_calls: FxHashMap, pub(crate) contains_self: bool, } @@ -35,6 +35,12 @@ pub(crate) struct ResolvedPath { pub(crate) depth: u32, } +pub(crate) struct UfcsCallInfo { + pub(crate) call_expr: ast::CallExpr, + pub(crate) function: hir::Function, + pub(crate) qualifier_type: Option, +} + impl ResolvedRule { pub(crate) fn new( rule: parsing::ParsedRule, @@ -70,6 +76,7 @@ struct Resolver<'a, 'db> { impl Resolver<'_, '_> { fn resolve_pattern_tree(&self, pattern: SyntaxNode) -> Result { + use syntax::ast::AstNode; use syntax::{SyntaxElement, T}; let mut resolved_paths = FxHashMap::default(); self.resolve(pattern.clone(), 0, &mut resolved_paths)?; @@ -77,11 +84,15 @@ impl Resolver<'_, '_> { .iter() .filter_map(|(path_node, resolved)| { if let Some(grandparent) = path_node.parent().and_then(|parent| parent.parent()) { - if grandparent.kind() == SyntaxKind::CALL_EXPR { + if let Some(call_expr) = ast::CallExpr::cast(grandparent.clone()) { if let hir::PathResolution::AssocItem(hir::AssocItem::Function(function)) = - &resolved.resolution + resolved.resolution { - return Some((grandparent, *function)); + let qualifier_type = self.resolution_scope.qualifier_type(path_node); + return Some(( + grandparent, + UfcsCallInfo { call_expr, function, qualifier_type }, + )); } } } @@ -226,6 +237,20 @@ impl<'db> ResolutionScope<'db> { None } } + + fn qualifier_type(&self, path: &SyntaxNode) -> Option { + use syntax::ast::AstNode; + if let Some(path) = ast::Path::cast(path.clone()) { + if let Some(qualifier) = path.qualifier() { + if let Some(resolved_qualifier) = self.resolve_path(&qualifier) { + if let hir::PathResolution::Def(hir::ModuleDef::Adt(adt)) = resolved_qualifier { + return Some(adt.ty(self.scope.db)); + } + } + } + } + None + } } fn is_self(path: &ast::Path) -> bool { diff --git a/crates/ra_ssr/src/tests.rs b/crates/ra_ssr/src/tests.rs index 7d4d470c0e..4bc09c1e47 100644 --- a/crates/ra_ssr/src/tests.rs +++ b/crates/ra_ssr/src/tests.rs @@ -1143,3 +1143,32 @@ fn replace_self() { "#]], ); } + +#[test] +fn match_trait_method_call() { + // `Bar::foo` and `Bar2::foo` resolve to the same function. Make sure we only match if the type + // matches what's in the pattern. Also checks that we handle autoderef. + let code = r#" + pub struct Bar {} + pub struct Bar2 {} + pub trait Foo { + fn foo(&self, _: i32) {} + } + impl Foo for Bar {} + impl Foo for Bar2 {} + fn main() { + let v1 = Bar {}; + let v2 = Bar2 {}; + let v1_ref = &v1; + let v2_ref = &v2; + v1.foo(1); + v2.foo(2); + Bar::foo(&v1, 3); + Bar2::foo(&v2, 4); + v1_ref.foo(5); + v2_ref.foo(6); + } + "#; + assert_matches("Bar::foo($a, $b)", code, &["v1.foo(1)", "Bar::foo(&v1, 3)", "v1_ref.foo(5)"]); + assert_matches("Bar2::foo($a, $b)", code, &["v2.foo(2)", "Bar2::foo(&v2, 4)", "v2_ref.foo(6)"]); +} From 2119dc23e80d77f1abc789e3d99c34d429e17905 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 12:07:28 +0200 Subject: [PATCH 095/119] Rename ra_proc_macro -> proc_macro_api --- Cargo.lock | 28 +++++++++---------- .../Cargo.toml | 5 ++-- .../src/lib.rs | 0 .../src/msg.rs | 0 .../src/process.rs | 0 .../src/rpc.rs | 2 +- crates/proc_macro_srv/Cargo.toml | 2 +- crates/proc_macro_srv/src/cli.rs | 2 +- crates/proc_macro_srv/src/dylib.rs | 2 +- crates/proc_macro_srv/src/lib.rs | 4 +-- crates/proc_macro_srv/src/tests/utils.rs | 2 +- crates/project_model/Cargo.toml | 2 +- crates/project_model/src/lib.rs | 2 +- 13 files changed, 26 insertions(+), 25 deletions(-) rename crates/{ra_proc_macro => proc_macro_api}/Cargo.toml (92%) rename crates/{ra_proc_macro => proc_macro_api}/src/lib.rs (100%) rename crates/{ra_proc_macro => proc_macro_api}/src/msg.rs (100%) rename crates/{ra_proc_macro => proc_macro_api}/src/process.rs (100%) rename crates/{ra_proc_macro => proc_macro_api}/src/rpc.rs (99%) diff --git a/Cargo.lock b/Cargo.lock index 89d0a60ec3..9878dd88fe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -909,6 +909,18 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "proc_macro_api" +version = "0.1.0" +dependencies = [ + "crossbeam-channel", + "jod-thread", + "log", + "serde", + "serde_json", + "tt", +] + [[package]] name = "proc_macro_srv" version = "0.0.0" @@ -919,7 +931,7 @@ dependencies = [ "libloading", "mbe", "memmap", - "ra_proc_macro", + "proc_macro_api", "serde_derive", "test_utils", "toolchain", @@ -948,8 +960,8 @@ dependencies = [ "cfg", "log", "paths", + "proc_macro_api", "ra_db", - "ra_proc_macro", "rustc-hash", "serde", "serde_json", @@ -1131,18 +1143,6 @@ dependencies = [ "text_edit", ] -[[package]] -name = "ra_proc_macro" -version = "0.1.0" -dependencies = [ - "crossbeam-channel", - "jod-thread", - "log", - "serde", - "serde_json", - "tt", -] - [[package]] name = "ra_ssr" version = "0.1.0" diff --git a/crates/ra_proc_macro/Cargo.toml b/crates/proc_macro_api/Cargo.toml similarity index 92% rename from crates/ra_proc_macro/Cargo.toml rename to crates/proc_macro_api/Cargo.toml index d2d1bc228d..c1abb56277 100644 --- a/crates/ra_proc_macro/Cargo.toml +++ b/crates/proc_macro_api/Cargo.toml @@ -1,6 +1,6 @@ [package] edition = "2018" -name = "ra_proc_macro" +name = "proc_macro_api" version = "0.1.0" authors = ["rust-analyzer developers"] publish = false @@ -10,9 +10,10 @@ license = "MIT OR Apache-2.0" doctest = false [dependencies] -tt = { path = "../tt" } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" log = "0.4.8" crossbeam-channel = "0.4.0" jod-thread = "0.1.1" + +tt = { path = "../tt" } diff --git a/crates/ra_proc_macro/src/lib.rs b/crates/proc_macro_api/src/lib.rs similarity index 100% rename from crates/ra_proc_macro/src/lib.rs rename to crates/proc_macro_api/src/lib.rs diff --git a/crates/ra_proc_macro/src/msg.rs b/crates/proc_macro_api/src/msg.rs similarity index 100% rename from crates/ra_proc_macro/src/msg.rs rename to crates/proc_macro_api/src/msg.rs diff --git a/crates/ra_proc_macro/src/process.rs b/crates/proc_macro_api/src/process.rs similarity index 100% rename from crates/ra_proc_macro/src/process.rs rename to crates/proc_macro_api/src/process.rs diff --git a/crates/ra_proc_macro/src/rpc.rs b/crates/proc_macro_api/src/rpc.rs similarity index 99% rename from crates/ra_proc_macro/src/rpc.rs rename to crates/proc_macro_api/src/rpc.rs index 5e5d78d067..47624163ee 100644 --- a/crates/ra_proc_macro/src/rpc.rs +++ b/crates/proc_macro_api/src/rpc.rs @@ -1,4 +1,4 @@ -//! Data struture serialization related stuff for RPC +//! Data structure serialization related stuff for RPC //! //! Defines all necessary rpc serialization data structures, //! which includes `tt` related data and some task messages. diff --git a/crates/proc_macro_srv/Cargo.toml b/crates/proc_macro_srv/Cargo.toml index 0954ffb66f..7171f08084 100644 --- a/crates/proc_macro_srv/Cargo.toml +++ b/crates/proc_macro_srv/Cargo.toml @@ -15,7 +15,7 @@ memmap = "0.7" tt = { path = "../tt" } mbe = { path = "../mbe" } -ra_proc_macro = { path = "../ra_proc_macro" } +proc_macro_api = { path = "../proc_macro_api" } test_utils = { path = "../test_utils" } [dev-dependencies] diff --git a/crates/proc_macro_srv/src/cli.rs b/crates/proc_macro_srv/src/cli.rs index 1437794c9e..d428b95675 100644 --- a/crates/proc_macro_srv/src/cli.rs +++ b/crates/proc_macro_srv/src/cli.rs @@ -1,7 +1,7 @@ //! Driver for proc macro server use crate::ProcMacroSrv; -use ra_proc_macro::msg::{self, Message}; +use proc_macro_api::msg::{self, Message}; use std::io; pub fn run() -> io::Result<()> { diff --git a/crates/proc_macro_srv/src/dylib.rs b/crates/proc_macro_srv/src/dylib.rs index 9b6cc91ef9..f8f705da8c 100644 --- a/crates/proc_macro_srv/src/dylib.rs +++ b/crates/proc_macro_srv/src/dylib.rs @@ -7,7 +7,7 @@ use std::path::{Path, PathBuf}; use goblin::{mach::Mach, Object}; use libloading::Library; use memmap::Mmap; -use ra_proc_macro::ProcMacroKind; +use proc_macro_api::ProcMacroKind; use std::io; const NEW_REGISTRAR_SYMBOL: &str = "_rustc_proc_macro_decls_"; diff --git a/crates/proc_macro_srv/src/lib.rs b/crates/proc_macro_srv/src/lib.rs index 1fc2eef82e..7e4e4ad505 100644 --- a/crates/proc_macro_srv/src/lib.rs +++ b/crates/proc_macro_srv/src/lib.rs @@ -8,7 +8,7 @@ //! * We use `tt` for proc-macro `TokenStream` server, it is easier to manipulate and interact with //! RA than `proc-macro2` token stream. //! * By **copying** the whole rustc `lib_proc_macro` code, we are able to build this with `stable` -//! rustc rather than `unstable`. (Although in gerenal ABI compatibility is still an issue) +//! rustc rather than `unstable`. (Although in general ABI compatibility is still an issue)… #[allow(dead_code)] #[doc(hidden)] @@ -20,7 +20,7 @@ mod rustc_server; mod dylib; use proc_macro::bridge::client::TokenStream; -use ra_proc_macro::{ExpansionResult, ExpansionTask, ListMacrosResult, ListMacrosTask}; +use proc_macro_api::{ExpansionResult, ExpansionTask, ListMacrosResult, ListMacrosTask}; use std::{ collections::{hash_map::Entry, HashMap}, fs, diff --git a/crates/proc_macro_srv/src/tests/utils.rs b/crates/proc_macro_srv/src/tests/utils.rs index 1b6a0b6fb7..5828512d6e 100644 --- a/crates/proc_macro_srv/src/tests/utils.rs +++ b/crates/proc_macro_srv/src/tests/utils.rs @@ -2,7 +2,7 @@ use crate::dylib; use crate::ProcMacroSrv; -use ra_proc_macro::ListMacrosTask; +use proc_macro_api::ListMacrosTask; use std::str::FromStr; use test_utils::assert_eq_text; diff --git a/crates/project_model/Cargo.toml b/crates/project_model/Cargo.toml index 8d8d093879..1c84c7d209 100644 --- a/crates/project_model/Cargo.toml +++ b/crates/project_model/Cargo.toml @@ -20,6 +20,6 @@ arena = { path = "../arena" } cfg = { path = "../cfg" } ra_db = { path = "../ra_db" } toolchain = { path = "../toolchain" } -ra_proc_macro = { path = "../ra_proc_macro" } +proc_macro_api = { path = "../proc_macro_api" } paths = { path = "../paths" } stdx = { path = "../stdx" } diff --git a/crates/project_model/src/lib.rs b/crates/project_model/src/lib.rs index ee42198f35..234f908c9b 100644 --- a/crates/project_model/src/lib.rs +++ b/crates/project_model/src/lib.rs @@ -25,7 +25,7 @@ pub use crate::{ sysroot::Sysroot, }; -pub use ra_proc_macro::ProcMacroClient; +pub use proc_macro_api::ProcMacroClient; #[derive(Debug, Clone, Eq, PartialEq)] pub enum ProjectWorkspace { From ed20a857f485a471369cd99b843af19a4d875ad0 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 16:25:38 +0200 Subject: [PATCH 096/119] Rename ra_db -> base_db --- Cargo.lock | 50 +++++++++---------- crates/{ra_db => base_db}/Cargo.toml | 8 +-- crates/{ra_db => base_db}/src/cancellation.rs | 0 crates/{ra_db => base_db}/src/fixture.rs | 0 crates/{ra_db => base_db}/src/input.rs | 0 crates/{ra_db => base_db}/src/lib.rs | 2 +- crates/project_model/Cargo.toml | 2 +- crates/project_model/src/cargo_workspace.rs | 2 +- crates/project_model/src/lib.rs | 2 +- crates/project_model/src/project_json.rs | 2 +- crates/ra_assists/Cargo.toml | 2 +- crates/ra_assists/src/assist_context.rs | 2 +- .../extract_struct_from_enum_variant.rs | 2 +- .../ra_assists/src/handlers/fix_visibility.rs | 2 +- .../src/handlers/generate_function.rs | 2 +- crates/ra_assists/src/lib.rs | 2 +- crates/ra_assists/src/tests.rs | 2 +- crates/ra_hir/Cargo.toml | 2 +- crates/ra_hir/src/code_model.rs | 2 +- crates/ra_hir/src/from_id.rs | 2 +- crates/ra_hir/src/semantics.rs | 2 +- crates/ra_hir/src/semantics/source_to_def.rs | 2 +- crates/ra_hir/src/source_analyzer.rs | 2 +- crates/ra_hir_def/Cargo.toml | 2 +- crates/ra_hir_def/src/body.rs | 4 +- crates/ra_hir_def/src/body/scope.rs | 2 +- crates/ra_hir_def/src/db.rs | 2 +- crates/ra_hir_def/src/find_path.rs | 2 +- crates/ra_hir_def/src/generics.rs | 2 +- crates/ra_hir_def/src/import_map.rs | 4 +- crates/ra_hir_def/src/item_scope.rs | 2 +- crates/ra_hir_def/src/item_tree/tests.rs | 2 +- crates/ra_hir_def/src/lib.rs | 2 +- crates/ra_hir_def/src/nameres.rs | 2 +- crates/ra_hir_def/src/nameres/collector.rs | 4 +- .../ra_hir_def/src/nameres/mod_resolution.rs | 2 +- .../ra_hir_def/src/nameres/path_resolution.rs | 2 +- crates/ra_hir_def/src/nameres/tests.rs | 2 +- .../src/nameres/tests/incremental.rs | 2 +- crates/ra_hir_def/src/path.rs | 2 +- crates/ra_hir_def/src/resolver.rs | 2 +- crates/ra_hir_def/src/test_db.rs | 6 +-- crates/ra_hir_expand/Cargo.toml | 2 +- crates/ra_hir_expand/src/builtin_derive.rs | 2 +- crates/ra_hir_expand/src/builtin_macro.rs | 4 +- crates/ra_hir_expand/src/db.rs | 2 +- crates/ra_hir_expand/src/eager.rs | 2 +- crates/ra_hir_expand/src/hygiene.rs | 2 +- crates/ra_hir_expand/src/lib.rs | 2 +- crates/ra_hir_expand/src/name.rs | 2 +- crates/ra_hir_expand/src/proc_macro.rs | 2 +- crates/ra_hir_expand/src/test_db.rs | 6 +-- crates/ra_hir_ty/Cargo.toml | 2 +- crates/ra_hir_ty/src/autoderef.rs | 2 +- crates/ra_hir_ty/src/db.rs | 2 +- crates/ra_hir_ty/src/diagnostics.rs | 2 +- crates/ra_hir_ty/src/lib.rs | 2 +- crates/ra_hir_ty/src/lower.rs | 2 +- crates/ra_hir_ty/src/method_resolution.rs | 2 +- crates/ra_hir_ty/src/test_db.rs | 6 +-- crates/ra_hir_ty/src/tests.rs | 2 +- crates/ra_hir_ty/src/traits.rs | 2 +- crates/ra_hir_ty/src/traits/chalk.rs | 2 +- crates/ra_hir_ty/src/traits/chalk/interner.rs | 2 +- crates/ra_hir_ty/src/traits/chalk/mapping.rs | 2 +- crates/ra_ide/Cargo.toml | 2 +- crates/ra_ide/src/call_hierarchy.rs | 2 +- .../src/completion/completion_context.rs | 2 +- crates/ra_ide/src/diagnostics.rs | 2 +- .../src/diagnostics/diagnostics_with_fix.rs | 2 +- .../ra_ide/src/display/navigation_target.rs | 2 +- crates/ra_ide/src/goto_definition.rs | 2 +- crates/ra_ide/src/goto_implementation.rs | 2 +- crates/ra_ide/src/goto_type_definition.rs | 2 +- crates/ra_ide/src/hover.rs | 4 +- crates/ra_ide/src/lib.rs | 10 ++-- crates/ra_ide/src/mock_analysis.rs | 2 +- crates/ra_ide/src/parent_module.rs | 4 +- crates/ra_ide/src/references/rename.rs | 2 +- crates/ra_ide/src/ssr.rs | 2 +- crates/ra_ide/src/status.rs | 8 +-- crates/ra_ide/src/syntax_highlighting/html.rs | 2 +- crates/ra_ide/src/syntax_tree.rs | 2 +- crates/ra_ide/src/typing.rs | 2 +- crates/ra_ide/src/typing/on_enter.rs | 2 +- crates/ra_ide_db/Cargo.toml | 2 +- crates/ra_ide_db/src/change.rs | 18 +++---- crates/ra_ide_db/src/lib.rs | 14 +++--- crates/ra_ide_db/src/search.rs | 2 +- crates/ra_ide_db/src/source_change.rs | 2 +- crates/ra_ide_db/src/symbol_index.rs | 6 +-- crates/ra_ssr/Cargo.toml | 2 +- crates/ra_ssr/src/lib.rs | 8 +-- crates/ra_ssr/src/matching.rs | 2 +- crates/ra_ssr/src/resolving.rs | 2 +- crates/ra_ssr/src/search.rs | 4 +- crates/ra_ssr/src/tests.rs | 6 +-- crates/rust-analyzer/Cargo.toml | 2 +- .../rust-analyzer/src/cli/analysis_bench.rs | 2 +- .../rust-analyzer/src/cli/analysis_stats.rs | 8 +-- crates/rust-analyzer/src/cli/diagnostics.rs | 2 +- crates/rust-analyzer/src/cli/load_cargo.rs | 2 +- crates/rust-analyzer/src/cli/ssr.rs | 4 +- crates/rust-analyzer/src/from_proto.rs | 2 +- crates/rust-analyzer/src/global_state.rs | 2 +- crates/rust-analyzer/src/lsp_utils.rs | 2 +- crates/rust-analyzer/src/main_loop.rs | 2 +- crates/rust-analyzer/src/reload.rs | 2 +- crates/rust-analyzer/src/to_proto.rs | 2 +- docs/dev/architecture.md | 6 +-- docs/dev/guide.md | 4 +- 111 files changed, 183 insertions(+), 183 deletions(-) rename crates/{ra_db => base_db}/Cargo.toml (91%) rename crates/{ra_db => base_db}/src/cancellation.rs (100%) rename crates/{ra_db => base_db}/src/fixture.rs (100%) rename crates/{ra_db => base_db}/src/input.rs (100%) rename crates/{ra_db => base_db}/src/lib.rs (98%) diff --git a/Cargo.lock b/Cargo.lock index 9878dd88fe..a99dd6e04a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -83,6 +83,21 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" +[[package]] +name = "base_db" +version = "0.0.0" +dependencies = [ + "cfg", + "profile", + "rustc-hash", + "salsa", + "stdx", + "syntax", + "test_utils", + "tt", + "vfs", +] + [[package]] name = "bitflags" version = "1.2.1" @@ -956,12 +971,12 @@ version = "0.0.0" dependencies = [ "anyhow", "arena", + "base_db", "cargo_metadata", "cfg", "log", "paths", "proc_macro_api", - "ra_db", "rustc-hash", "serde", "serde_json", @@ -982,10 +997,10 @@ dependencies = [ name = "ra_assists" version = "0.1.0" dependencies = [ + "base_db", "either", "itertools", "profile", - "ra_db", "ra_hir", "ra_ide_db", "rustc-hash", @@ -995,31 +1010,16 @@ dependencies = [ "text_edit", ] -[[package]] -name = "ra_db" -version = "0.1.0" -dependencies = [ - "cfg", - "profile", - "rustc-hash", - "salsa", - "stdx", - "syntax", - "test_utils", - "tt", - "vfs", -] - [[package]] name = "ra_hir" version = "0.1.0" dependencies = [ "arrayvec", + "base_db", "either", "itertools", "log", "profile", - "ra_db", "ra_hir_def", "ra_hir_expand", "ra_hir_ty", @@ -1034,6 +1034,7 @@ version = "0.1.0" dependencies = [ "anymap", "arena", + "base_db", "cfg", "drop_bomb", "either", @@ -1045,7 +1046,6 @@ dependencies = [ "mbe", "once_cell", "profile", - "ra_db", "ra_hir_expand", "rustc-hash", "smallvec", @@ -1060,12 +1060,12 @@ name = "ra_hir_expand" version = "0.1.0" dependencies = [ "arena", + "base_db", "either", "log", "mbe", "parser", "profile", - "ra_db", "rustc-hash", "syntax", "test_utils", @@ -1078,6 +1078,7 @@ version = "0.1.0" dependencies = [ "arena", "arrayvec", + "base_db", "chalk-ir", "chalk-recursive", "chalk-solve", @@ -1086,7 +1087,6 @@ dependencies = [ "itertools", "log", "profile", - "ra_db", "ra_hir_def", "ra_hir_expand", "rustc-hash", @@ -1104,6 +1104,7 @@ dependencies = [ name = "ra_ide" version = "0.1.0" dependencies = [ + "base_db", "cfg", "either", "expect", @@ -1113,7 +1114,6 @@ dependencies = [ "oorandom", "profile", "ra_assists", - "ra_db", "ra_hir", "ra_ide_db", "ra_ssr", @@ -1128,12 +1128,12 @@ dependencies = [ name = "ra_ide_db" version = "0.1.0" dependencies = [ + "base_db", "either", "fst", "log", "once_cell", "profile", - "ra_db", "ra_hir", "rayon", "rustc-hash", @@ -1147,8 +1147,8 @@ dependencies = [ name = "ra_ssr" version = "0.1.0" dependencies = [ + "base_db", "expect", - "ra_db", "ra_hir", "ra_ide_db", "rustc-hash", @@ -1230,6 +1230,7 @@ name = "rust-analyzer" version = "0.1.0" dependencies = [ "anyhow", + "base_db", "cfg", "crossbeam-channel", "env_logger", @@ -1248,7 +1249,6 @@ dependencies = [ "proc_macro_srv", "profile", "project_model", - "ra_db", "ra_hir", "ra_hir_def", "ra_hir_ty", diff --git a/crates/ra_db/Cargo.toml b/crates/base_db/Cargo.toml similarity index 91% rename from crates/ra_db/Cargo.toml rename to crates/base_db/Cargo.toml index ad432f096a..7347d7528c 100644 --- a/crates/ra_db/Cargo.toml +++ b/crates/base_db/Cargo.toml @@ -1,9 +1,9 @@ [package] -edition = "2018" -name = "ra_db" -version = "0.1.0" -authors = ["rust-analyzer developers"] +name = "base_db" +version = "0.0.0" license = "MIT OR Apache-2.0" +authors = ["rust-analyzer developers"] +edition = "2018" [lib] doctest = false diff --git a/crates/ra_db/src/cancellation.rs b/crates/base_db/src/cancellation.rs similarity index 100% rename from crates/ra_db/src/cancellation.rs rename to crates/base_db/src/cancellation.rs diff --git a/crates/ra_db/src/fixture.rs b/crates/base_db/src/fixture.rs similarity index 100% rename from crates/ra_db/src/fixture.rs rename to crates/base_db/src/fixture.rs diff --git a/crates/ra_db/src/input.rs b/crates/base_db/src/input.rs similarity index 100% rename from crates/ra_db/src/input.rs rename to crates/base_db/src/input.rs diff --git a/crates/ra_db/src/lib.rs b/crates/base_db/src/lib.rs similarity index 98% rename from crates/ra_db/src/lib.rs rename to crates/base_db/src/lib.rs index 73ac243d66..811057251d 100644 --- a/crates/ra_db/src/lib.rs +++ b/crates/base_db/src/lib.rs @@ -1,4 +1,4 @@ -//! ra_db defines basic database traits. The concrete DB is defined by ra_ide. +//! base_db defines basic database traits. The concrete DB is defined by ra_ide. mod cancellation; mod input; pub mod fixture; diff --git a/crates/project_model/Cargo.toml b/crates/project_model/Cargo.toml index 1c84c7d209..386f72f419 100644 --- a/crates/project_model/Cargo.toml +++ b/crates/project_model/Cargo.toml @@ -18,7 +18,7 @@ anyhow = "1.0.26" arena = { path = "../arena" } cfg = { path = "../cfg" } -ra_db = { path = "../ra_db" } +base_db = { path = "../base_db" } toolchain = { path = "../toolchain" } proc_macro_api = { path = "../proc_macro_api" } paths = { path = "../paths" } diff --git a/crates/project_model/src/cargo_workspace.rs b/crates/project_model/src/cargo_workspace.rs index abf8dca964..e5c2d2b256 100644 --- a/crates/project_model/src/cargo_workspace.rs +++ b/crates/project_model/src/cargo_workspace.rs @@ -9,9 +9,9 @@ use std::{ use anyhow::{Context, Result}; use arena::{Arena, Idx}; +use base_db::Edition; use cargo_metadata::{BuildScript, CargoOpt, Message, MetadataCommand, PackageId}; use paths::{AbsPath, AbsPathBuf}; -use ra_db::Edition; use rustc_hash::FxHashMap; use crate::cfg_flag::CfgFlag; diff --git a/crates/project_model/src/lib.rs b/crates/project_model/src/lib.rs index 234f908c9b..1f5a94d7f9 100644 --- a/crates/project_model/src/lib.rs +++ b/crates/project_model/src/lib.rs @@ -12,9 +12,9 @@ use std::{ }; use anyhow::{bail, Context, Result}; +use base_db::{CrateGraph, CrateId, CrateName, Edition, Env, FileId}; use cfg::CfgOptions; use paths::{AbsPath, AbsPathBuf}; -use ra_db::{CrateGraph, CrateId, CrateName, Edition, Env, FileId}; use rustc_hash::{FxHashMap, FxHashSet}; use crate::cfg_flag::CfgFlag; diff --git a/crates/project_model/src/project_json.rs b/crates/project_model/src/project_json.rs index e3f3163f6a..060ea5b7dc 100644 --- a/crates/project_model/src/project_json.rs +++ b/crates/project_model/src/project_json.rs @@ -2,8 +2,8 @@ use std::path::PathBuf; +use base_db::{CrateId, CrateName, Dependency, Edition}; use paths::{AbsPath, AbsPathBuf}; -use ra_db::{CrateId, CrateName, Dependency, Edition}; use rustc_hash::FxHashMap; use serde::{de, Deserialize}; diff --git a/crates/ra_assists/Cargo.toml b/crates/ra_assists/Cargo.toml index 83e44c1243..ebac09be62 100644 --- a/crates/ra_assists/Cargo.toml +++ b/crates/ra_assists/Cargo.toml @@ -18,7 +18,7 @@ stdx = { path = "../stdx" } syntax = { path = "../syntax" } text_edit = { path = "../text_edit" } profile = { path = "../profile" } -ra_db = { path = "../ra_db" } +base_db = { path = "../base_db" } ra_ide_db = { path = "../ra_ide_db" } hir = { path = "../ra_hir", package = "ra_hir" } test_utils = { path = "../test_utils" } diff --git a/crates/ra_assists/src/assist_context.rs b/crates/ra_assists/src/assist_context.rs index 368d48a712..2fdce037fb 100644 --- a/crates/ra_assists/src/assist_context.rs +++ b/crates/ra_assists/src/assist_context.rs @@ -3,8 +3,8 @@ use std::mem; use algo::find_covering_element; +use base_db::{FileId, FileRange}; use hir::Semantics; -use ra_db::{FileId, FileRange}; use ra_ide_db::{ source_change::{SourceChange, SourceFileEdit}, RootDatabase, diff --git a/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs b/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs index 497f887cd1..52fbc540eb 100644 --- a/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs +++ b/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs @@ -1,5 +1,5 @@ +use base_db::FileId; use hir::{EnumVariant, Module, ModuleDef, Name}; -use ra_db::FileId; use ra_ide_db::{defs::Definition, search::Reference, RootDatabase}; use rustc_hash::FxHashSet; use syntax::{ diff --git a/crates/ra_assists/src/handlers/fix_visibility.rs b/crates/ra_assists/src/handlers/fix_visibility.rs index b6cc1a3204..7cd76ea065 100644 --- a/crates/ra_assists/src/handlers/fix_visibility.rs +++ b/crates/ra_assists/src/handlers/fix_visibility.rs @@ -1,5 +1,5 @@ +use base_db::FileId; use hir::{db::HirDatabase, HasSource, HasVisibility, PathResolution}; -use ra_db::FileId; use syntax::{ast, AstNode, TextRange, TextSize}; use crate::{utils::vis_offset, AssistContext, AssistId, AssistKind, Assists}; diff --git a/crates/ra_assists/src/handlers/generate_function.rs b/crates/ra_assists/src/handlers/generate_function.rs index b5df441019..b38d640581 100644 --- a/crates/ra_assists/src/handlers/generate_function.rs +++ b/crates/ra_assists/src/handlers/generate_function.rs @@ -1,5 +1,5 @@ +use base_db::FileId; use hir::HirDisplay; -use ra_db::FileId; use rustc_hash::{FxHashMap, FxHashSet}; use syntax::{ ast::{ diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs index e2ef561fee..5d062b88b8 100644 --- a/crates/ra_assists/src/lib.rs +++ b/crates/ra_assists/src/lib.rs @@ -17,8 +17,8 @@ mod tests; pub mod utils; pub mod ast_transform; +use base_db::FileRange; use hir::Semantics; -use ra_db::FileRange; use ra_ide_db::{source_change::SourceChange, RootDatabase}; use syntax::TextRange; diff --git a/crates/ra_assists/src/tests.rs b/crates/ra_assists/src/tests.rs index 1ae7aaa09b..75d9736882 100644 --- a/crates/ra_assists/src/tests.rs +++ b/crates/ra_assists/src/tests.rs @@ -1,7 +1,7 @@ mod generated; +use base_db::{fixture::WithFixture, FileId, FileRange, SourceDatabaseExt}; use hir::Semantics; -use ra_db::{fixture::WithFixture, FileId, FileRange, SourceDatabaseExt}; use ra_ide_db::RootDatabase; use syntax::TextRange; use test_utils::{assert_eq_text, extract_offset, extract_range}; diff --git a/crates/ra_hir/Cargo.toml b/crates/ra_hir/Cargo.toml index ee5622a7d9..5ccdb74fd6 100644 --- a/crates/ra_hir/Cargo.toml +++ b/crates/ra_hir/Cargo.toml @@ -18,7 +18,7 @@ itertools = "0.9.0" stdx = { path = "../stdx" } syntax = { path = "../syntax" } -ra_db = { path = "../ra_db" } +base_db = { path = "../base_db" } profile = { path = "../profile" } hir_expand = { path = "../ra_hir_expand", package = "ra_hir_expand" } hir_def = { path = "../ra_hir_def", package = "ra_hir_def" } diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 98724c1462..d4d6b1759c 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs @@ -2,6 +2,7 @@ use std::{iter, sync::Arc}; use arrayvec::ArrayVec; +use base_db::{CrateId, Edition, FileId}; use either::Either; use hir_def::{ adt::ReprKind, @@ -30,7 +31,6 @@ use hir_ty::{ method_resolution, ApplicationTy, CallableDefId, Canonical, FnSig, GenericPredicate, InEnvironment, Substs, TraitEnvironment, Ty, TyDefId, TypeCtor, }; -use ra_db::{CrateId, Edition, FileId}; use rustc_hash::FxHashSet; use stdx::impl_from; use syntax::{ diff --git a/crates/ra_hir/src/from_id.rs b/crates/ra_hir/src/from_id.rs index 679ae81215..a53ac1e080 100644 --- a/crates/ra_hir/src/from_id.rs +++ b/crates/ra_hir/src/from_id.rs @@ -29,7 +29,7 @@ macro_rules! from_id { } from_id![ - (ra_db::CrateId, crate::Crate), + (base_db::CrateId, crate::Crate), (hir_def::ModuleId, crate::Module), (hir_def::StructId, crate::Struct), (hir_def::UnionId, crate::Union), diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs index 2e0ef44085..1467d825d9 100644 --- a/crates/ra_hir/src/semantics.rs +++ b/crates/ra_hir/src/semantics.rs @@ -4,6 +4,7 @@ mod source_to_def; use std::{cell::RefCell, fmt, iter::successors}; +use base_db::{FileId, FileRange}; use hir_def::{ resolver::{self, HasResolver, Resolver}, AsMacroCall, FunctionId, TraitId, VariantId, @@ -11,7 +12,6 @@ use hir_def::{ use hir_expand::{hygiene::Hygiene, name::AsName, ExpansionInfo}; use hir_ty::associated_type_shorthand_candidates; use itertools::Itertools; -use ra_db::{FileId, FileRange}; use rustc_hash::{FxHashMap, FxHashSet}; use syntax::{ algo::{find_node_at_offset, skip_trivia_token}, diff --git a/crates/ra_hir/src/semantics/source_to_def.rs b/crates/ra_hir/src/semantics/source_to_def.rs index ab2fd0957f..5918b9541b 100644 --- a/crates/ra_hir/src/semantics/source_to_def.rs +++ b/crates/ra_hir/src/semantics/source_to_def.rs @@ -1,5 +1,6 @@ //! Maps *syntax* of various definitions to their semantic ids. +use base_db::FileId; use hir_def::{ child_by_source::ChildBySource, dyn_map::DynMap, @@ -9,7 +10,6 @@ use hir_def::{ ModuleId, StaticId, StructId, TraitId, TypeAliasId, TypeParamId, UnionId, VariantId, }; use hir_expand::{name::AsName, AstId, MacroDefKind}; -use ra_db::FileId; use rustc_hash::FxHashMap; use stdx::impl_from; use syntax::{ diff --git a/crates/ra_hir/src/source_analyzer.rs b/crates/ra_hir/src/source_analyzer.rs index 6b2de3a06f..8750584f94 100644 --- a/crates/ra_hir/src/source_analyzer.rs +++ b/crates/ra_hir/src/source_analyzer.rs @@ -31,7 +31,7 @@ use crate::{ MacroDef, ModPath, ModuleDef, Path, PathKind, Static, Struct, Trait, Type, TypeAlias, TypeParam, }; -use ra_db::CrateId; +use base_db::CrateId; /// `SourceAnalyzer` is a convenience wrapper which exposes HIR API in terms of /// original source files. It should not be used inside the HIR itself. diff --git a/crates/ra_hir_def/Cargo.toml b/crates/ra_hir_def/Cargo.toml index e7d3c4d5be..2b187bc4a0 100644 --- a/crates/ra_hir_def/Cargo.toml +++ b/crates/ra_hir_def/Cargo.toml @@ -23,7 +23,7 @@ smallvec = "1.4.0" stdx = { path = "../stdx" } arena = { path = "../arena" } -ra_db = { path = "../ra_db" } +base_db = { path = "../base_db" } syntax = { path = "../syntax" } profile = { path = "../profile" } hir_expand = { path = "../ra_hir_expand", package = "ra_hir_expand" } diff --git a/crates/ra_hir_def/src/body.rs b/crates/ra_hir_def/src/body.rs index fe659386a3..9a9a605ddb 100644 --- a/crates/ra_hir_def/src/body.rs +++ b/crates/ra_hir_def/src/body.rs @@ -6,11 +6,11 @@ pub mod scope; use std::{mem, ops::Index, sync::Arc}; use arena::{map::ArenaMap, Arena}; +use base_db::CrateId; use cfg::CfgOptions; use drop_bomb::DropBomb; use either::Either; use hir_expand::{ast_id_map::AstIdMap, hygiene::Hygiene, AstId, HirFileId, InFile, MacroDefId}; -use ra_db::CrateId; use rustc_hash::FxHashMap; use syntax::{ast, AstNode, AstPtr}; use test_utils::mark; @@ -320,7 +320,7 @@ impl BodySourceMap { #[cfg(test)] mod tests { - use ra_db::{fixture::WithFixture, SourceDatabase}; + use base_db::{fixture::WithFixture, SourceDatabase}; use test_utils::mark; use crate::ModuleDefId; diff --git a/crates/ra_hir_def/src/body/scope.rs b/crates/ra_hir_def/src/body/scope.rs index 079f14c298..9142bc05b8 100644 --- a/crates/ra_hir_def/src/body/scope.rs +++ b/crates/ra_hir_def/src/body/scope.rs @@ -169,8 +169,8 @@ fn compute_expr_scopes(expr: ExprId, body: &Body, scopes: &mut ExprScopes, scope #[cfg(test)] mod tests { + use base_db::{fixture::WithFixture, FileId, SourceDatabase}; use hir_expand::{name::AsName, InFile}; - use ra_db::{fixture::WithFixture, FileId, SourceDatabase}; use syntax::{algo::find_node_at_offset, ast, AstNode}; use test_utils::{assert_eq_text, extract_offset, mark}; diff --git a/crates/ra_hir_def/src/db.rs b/crates/ra_hir_def/src/db.rs index a925548b58..6d694de115 100644 --- a/crates/ra_hir_def/src/db.rs +++ b/crates/ra_hir_def/src/db.rs @@ -1,8 +1,8 @@ //! Defines database & queries for name resolution. use std::sync::Arc; +use base_db::{salsa, CrateId, SourceDatabase, Upcast}; use hir_expand::{db::AstDatabase, HirFileId}; -use ra_db::{salsa, CrateId, SourceDatabase, Upcast}; use syntax::SmolStr; use crate::{ diff --git a/crates/ra_hir_def/src/find_path.rs b/crates/ra_hir_def/src/find_path.rs index 5099f417d3..ac2c54ac53 100644 --- a/crates/ra_hir_def/src/find_path.rs +++ b/crates/ra_hir_def/src/find_path.rs @@ -292,8 +292,8 @@ fn find_local_import_locations( #[cfg(test)] mod tests { + use base_db::fixture::WithFixture; use hir_expand::hygiene::Hygiene; - use ra_db::fixture::WithFixture; use syntax::ast::AstNode; use test_utils::mark; diff --git a/crates/ra_hir_def/src/generics.rs b/crates/ra_hir_def/src/generics.rs index 4476f03162..835fe3fbdc 100644 --- a/crates/ra_hir_def/src/generics.rs +++ b/crates/ra_hir_def/src/generics.rs @@ -5,12 +5,12 @@ use std::sync::Arc; use arena::{map::ArenaMap, Arena}; +use base_db::FileId; use either::Either; use hir_expand::{ name::{name, AsName, Name}, InFile, }; -use ra_db::FileId; use syntax::ast::{self, GenericParamsOwner, NameOwner, TypeBoundsOwner}; use crate::{ diff --git a/crates/ra_hir_def/src/import_map.rs b/crates/ra_hir_def/src/import_map.rs index 431ff30abd..d32a0bdaf2 100644 --- a/crates/ra_hir_def/src/import_map.rs +++ b/crates/ra_hir_def/src/import_map.rs @@ -2,9 +2,9 @@ use std::{cmp::Ordering, fmt, hash::BuildHasherDefault, sync::Arc}; +use base_db::CrateId; use fst::{self, Streamer}; use indexmap::{map::Entry, IndexMap}; -use ra_db::CrateId; use rustc_hash::{FxHashMap, FxHasher}; use smallvec::SmallVec; use syntax::SmolStr; @@ -327,8 +327,8 @@ pub fn search_dependencies<'a>( #[cfg(test)] mod tests { + use base_db::{fixture::WithFixture, SourceDatabase, Upcast}; use expect::{expect, Expect}; - use ra_db::{fixture::WithFixture, SourceDatabase, Upcast}; use crate::{test_db::TestDB, AssocContainerId, Lookup}; diff --git a/crates/ra_hir_def/src/item_scope.rs b/crates/ra_hir_def/src/item_scope.rs index 8fee4b15e5..f1e9dfd5b1 100644 --- a/crates/ra_hir_def/src/item_scope.rs +++ b/crates/ra_hir_def/src/item_scope.rs @@ -3,9 +3,9 @@ use std::collections::hash_map::Entry; +use base_db::CrateId; use hir_expand::name::Name; use once_cell::sync::Lazy; -use ra_db::CrateId; use rustc_hash::{FxHashMap, FxHashSet}; use test_utils::mark; diff --git a/crates/ra_hir_def/src/item_tree/tests.rs b/crates/ra_hir_def/src/item_tree/tests.rs index 6c843e339a..2f62eddcba 100644 --- a/crates/ra_hir_def/src/item_tree/tests.rs +++ b/crates/ra_hir_def/src/item_tree/tests.rs @@ -1,6 +1,6 @@ +use base_db::fixture::WithFixture; use expect::{expect, Expect}; use hir_expand::{db::AstDatabase, HirFileId, InFile}; -use ra_db::fixture::WithFixture; use rustc_hash::FxHashSet; use std::sync::Arc; use stdx::format_to; diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs index 806ac731f5..f24a1dd77c 100644 --- a/crates/ra_hir_def/src/lib.rs +++ b/crates/ra_hir_def/src/lib.rs @@ -53,11 +53,11 @@ mod test_db; use std::hash::{Hash, Hasher}; use arena::Idx; +use base_db::{impl_intern_key, salsa, CrateId}; use hir_expand::{ ast_id_map::FileAstId, eager::expand_eager_macro, hygiene::Hygiene, AstId, HirFileId, InFile, MacroCallId, MacroCallKind, MacroDefId, MacroDefKind, }; -use ra_db::{impl_intern_key, salsa, CrateId}; use syntax::ast; use crate::builtin_type::BuiltinType; diff --git a/crates/ra_hir_def/src/nameres.rs b/crates/ra_hir_def/src/nameres.rs index d26c837cc8..bf302172d0 100644 --- a/crates/ra_hir_def/src/nameres.rs +++ b/crates/ra_hir_def/src/nameres.rs @@ -57,8 +57,8 @@ mod tests; use std::sync::Arc; use arena::Arena; +use base_db::{CrateId, Edition, FileId}; use hir_expand::{diagnostics::DiagnosticSink, name::Name, InFile}; -use ra_db::{CrateId, Edition, FileId}; use rustc_hash::FxHashMap; use stdx::format_to; use syntax::ast; diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index 6a58919360..3e99c87737 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs @@ -3,6 +3,7 @@ //! `DefCollector::collect` contains the fixed-point iteration loop which //! resolves imports and expands macros. +use base_db::{CrateId, FileId, ProcMacroId}; use cfg::CfgOptions; use hir_expand::{ ast_id_map::FileAstId, @@ -12,7 +13,6 @@ use hir_expand::{ proc_macro::ProcMacroExpander, HirFileId, MacroCallId, MacroDefId, MacroDefKind, }; -use ra_db::{CrateId, FileId, ProcMacroId}; use rustc_hash::FxHashMap; use syntax::ast; use test_utils::mark; @@ -1209,7 +1209,7 @@ fn is_macro_rules(path: &ModPath) -> bool { mod tests { use crate::{db::DefDatabase, test_db::TestDB}; use arena::Arena; - use ra_db::{fixture::WithFixture, SourceDatabase}; + use base_db::{fixture::WithFixture, SourceDatabase}; use super::*; diff --git a/crates/ra_hir_def/src/nameres/mod_resolution.rs b/crates/ra_hir_def/src/nameres/mod_resolution.rs index 316245d6ba..e8389b4846 100644 --- a/crates/ra_hir_def/src/nameres/mod_resolution.rs +++ b/crates/ra_hir_def/src/nameres/mod_resolution.rs @@ -1,6 +1,6 @@ //! This module resolves `mod foo;` declaration to file. +use base_db::FileId; use hir_expand::name::Name; -use ra_db::FileId; use syntax::SmolStr; use crate::{db::DefDatabase, HirFileId}; diff --git a/crates/ra_hir_def/src/nameres/path_resolution.rs b/crates/ra_hir_def/src/nameres/path_resolution.rs index dbfa7fccb4..88e10574ef 100644 --- a/crates/ra_hir_def/src/nameres/path_resolution.rs +++ b/crates/ra_hir_def/src/nameres/path_resolution.rs @@ -12,8 +12,8 @@ use std::iter::successors; +use base_db::Edition; use hir_expand::name::Name; -use ra_db::Edition; use test_utils::mark; use crate::{ diff --git a/crates/ra_hir_def/src/nameres/tests.rs b/crates/ra_hir_def/src/nameres/tests.rs index 839b1de578..b105d56b24 100644 --- a/crates/ra_hir_def/src/nameres/tests.rs +++ b/crates/ra_hir_def/src/nameres/tests.rs @@ -6,8 +6,8 @@ mod primitives; use std::sync::Arc; +use base_db::{fixture::WithFixture, SourceDatabase}; use expect::{expect, Expect}; -use ra_db::{fixture::WithFixture, SourceDatabase}; use test_utils::mark; use crate::{db::DefDatabase, nameres::*, test_db::TestDB}; diff --git a/crates/ra_hir_def/src/nameres/tests/incremental.rs b/crates/ra_hir_def/src/nameres/tests/incremental.rs index 0c288a1085..cfbc62cc43 100644 --- a/crates/ra_hir_def/src/nameres/tests/incremental.rs +++ b/crates/ra_hir_def/src/nameres/tests/incremental.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use ra_db::SourceDatabaseExt; +use base_db::SourceDatabaseExt; use super::*; diff --git a/crates/ra_hir_def/src/path.rs b/crates/ra_hir_def/src/path.rs index 88be07c8a7..74d26f08b3 100644 --- a/crates/ra_hir_def/src/path.rs +++ b/crates/ra_hir_def/src/path.rs @@ -8,11 +8,11 @@ use std::{ }; use crate::body::LowerCtx; +use base_db::CrateId; use hir_expand::{ hygiene::Hygiene, name::{AsName, Name}, }; -use ra_db::CrateId; use syntax::ast; use crate::{ diff --git a/crates/ra_hir_def/src/resolver.rs b/crates/ra_hir_def/src/resolver.rs index 0bf51eb7b8..f8cc5e075e 100644 --- a/crates/ra_hir_def/src/resolver.rs +++ b/crates/ra_hir_def/src/resolver.rs @@ -1,11 +1,11 @@ //! Name resolution façade. use std::sync::Arc; +use base_db::CrateId; use hir_expand::{ name::{name, Name}, MacroDefId, }; -use ra_db::CrateId; use rustc_hash::FxHashSet; use crate::{ diff --git a/crates/ra_hir_def/src/test_db.rs b/crates/ra_hir_def/src/test_db.rs index 339f819b8b..42a762936d 100644 --- a/crates/ra_hir_def/src/test_db.rs +++ b/crates/ra_hir_def/src/test_db.rs @@ -5,15 +5,15 @@ use std::{ sync::{Arc, Mutex}, }; +use base_db::{salsa, CrateId, FileId, FileLoader, FileLoaderDelegate, Upcast}; use hir_expand::db::AstDatabase; -use ra_db::{salsa, CrateId, FileId, FileLoader, FileLoaderDelegate, Upcast}; use rustc_hash::FxHashSet; use crate::db::DefDatabase; #[salsa::database( - ra_db::SourceDatabaseExtStorage, - ra_db::SourceDatabaseStorage, + base_db::SourceDatabaseExtStorage, + base_db::SourceDatabaseStorage, hir_expand::db::AstDatabaseStorage, crate::db::InternDatabaseStorage, crate::db::DefDatabaseStorage diff --git a/crates/ra_hir_expand/Cargo.toml b/crates/ra_hir_expand/Cargo.toml index cbb0ac29b8..41acf37122 100644 --- a/crates/ra_hir_expand/Cargo.toml +++ b/crates/ra_hir_expand/Cargo.toml @@ -14,7 +14,7 @@ either = "1.5.3" rustc-hash = "1.0.0" arena = { path = "../arena" } -ra_db = { path = "../ra_db" } +base_db = { path = "../base_db" } syntax = { path = "../syntax" } parser = { path = "../parser" } profile = { path = "../profile" } diff --git a/crates/ra_hir_expand/src/builtin_derive.rs b/crates/ra_hir_expand/src/builtin_derive.rs index 2d2f8bcb84..988a60d56a 100644 --- a/crates/ra_hir_expand/src/builtin_derive.rs +++ b/crates/ra_hir_expand/src/builtin_derive.rs @@ -253,8 +253,8 @@ fn partial_ord_expand( #[cfg(test)] mod tests { + use base_db::{fixture::WithFixture, CrateId, SourceDatabase}; use name::{known, Name}; - use ra_db::{fixture::WithFixture, CrateId, SourceDatabase}; use crate::{test_db::TestDB, AstId, MacroCallId, MacroCallKind, MacroCallLoc}; diff --git a/crates/ra_hir_expand/src/builtin_macro.rs b/crates/ra_hir_expand/src/builtin_macro.rs index ae4c843820..86918b6269 100644 --- a/crates/ra_hir_expand/src/builtin_macro.rs +++ b/crates/ra_hir_expand/src/builtin_macro.rs @@ -4,10 +4,10 @@ use crate::{ MacroDefId, MacroDefKind, TextSize, }; +use base_db::FileId; use either::Either; use mbe::parse_to_token_tree; use parser::FragmentKind; -use ra_db::FileId; use syntax::ast::{self, AstToken, HasStringValue}; macro_rules! register_builtin { @@ -426,7 +426,7 @@ mod tests { name::AsName, test_db::TestDB, AstNode, EagerCallLoc, MacroCallId, MacroCallKind, MacroCallLoc, }; - use ra_db::{fixture::WithFixture, SourceDatabase}; + use base_db::{fixture::WithFixture, SourceDatabase}; use std::sync::Arc; use syntax::ast::NameOwner; diff --git a/crates/ra_hir_expand/src/db.rs b/crates/ra_hir_expand/src/db.rs index c275f6b017..dcc038bcd8 100644 --- a/crates/ra_hir_expand/src/db.rs +++ b/crates/ra_hir_expand/src/db.rs @@ -2,9 +2,9 @@ use std::sync::Arc; +use base_db::{salsa, SourceDatabase}; use mbe::{ExpandResult, MacroRules}; use parser::FragmentKind; -use ra_db::{salsa, SourceDatabase}; use syntax::{algo::diff, AstNode, GreenNode, Parse, SyntaxKind::*, SyntaxNode}; use crate::{ diff --git a/crates/ra_hir_expand/src/eager.rs b/crates/ra_hir_expand/src/eager.rs index bd3409f973..10c45646f0 100644 --- a/crates/ra_hir_expand/src/eager.rs +++ b/crates/ra_hir_expand/src/eager.rs @@ -25,8 +25,8 @@ use crate::{ EagerCallLoc, EagerMacroId, InFile, MacroCallId, MacroCallKind, MacroDefId, MacroDefKind, }; +use base_db::CrateId; use parser::FragmentKind; -use ra_db::CrateId; use std::sync::Arc; use syntax::{algo::SyntaxRewriter, SyntaxNode}; diff --git a/crates/ra_hir_expand/src/hygiene.rs b/crates/ra_hir_expand/src/hygiene.rs index 23b5eac270..845e9cbc19 100644 --- a/crates/ra_hir_expand/src/hygiene.rs +++ b/crates/ra_hir_expand/src/hygiene.rs @@ -2,8 +2,8 @@ //! //! Specifically, `ast` + `Hygiene` allows you to create a `Name`. Note that, at //! this moment, this is horribly incomplete and handles only `$crate`. +use base_db::CrateId; use either::Either; -use ra_db::CrateId; use syntax::ast; use crate::{ diff --git a/crates/ra_hir_expand/src/lib.rs b/crates/ra_hir_expand/src/lib.rs index af0cc445f7..7425b561ac 100644 --- a/crates/ra_hir_expand/src/lib.rs +++ b/crates/ra_hir_expand/src/lib.rs @@ -18,7 +18,7 @@ pub mod eager; use std::hash::Hash; use std::sync::Arc; -use ra_db::{impl_intern_key, salsa, CrateId, FileId}; +use base_db::{impl_intern_key, salsa, CrateId, FileId}; use syntax::{ algo, ast::{self, AstNode}, diff --git a/crates/ra_hir_expand/src/name.rs b/crates/ra_hir_expand/src/name.rs index 4dcaff0885..49841c7a12 100644 --- a/crates/ra_hir_expand/src/name.rs +++ b/crates/ra_hir_expand/src/name.rs @@ -115,7 +115,7 @@ impl AsName for ast::FieldKind { } } -impl AsName for ra_db::Dependency { +impl AsName for base_db::Dependency { fn as_name(&self) -> Name { Name::new_text(SmolStr::new(&*self.name)) } diff --git a/crates/ra_hir_expand/src/proc_macro.rs b/crates/ra_hir_expand/src/proc_macro.rs index 2c0ec41d24..80255ea327 100644 --- a/crates/ra_hir_expand/src/proc_macro.rs +++ b/crates/ra_hir_expand/src/proc_macro.rs @@ -1,7 +1,7 @@ //! Proc Macro Expander stub use crate::{db::AstDatabase, LazyMacroId}; -use ra_db::{CrateId, ProcMacroId}; +use base_db::{CrateId, ProcMacroId}; use tt::buffer::{Cursor, TokenBuffer}; #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] diff --git a/crates/ra_hir_expand/src/test_db.rs b/crates/ra_hir_expand/src/test_db.rs index 332fa556fa..86a5d867e6 100644 --- a/crates/ra_hir_expand/src/test_db.rs +++ b/crates/ra_hir_expand/src/test_db.rs @@ -5,12 +5,12 @@ use std::{ sync::{Arc, Mutex}, }; -use ra_db::{salsa, CrateId, FileId, FileLoader, FileLoaderDelegate}; +use base_db::{salsa, CrateId, FileId, FileLoader, FileLoaderDelegate}; use rustc_hash::FxHashSet; #[salsa::database( - ra_db::SourceDatabaseExtStorage, - ra_db::SourceDatabaseStorage, + base_db::SourceDatabaseExtStorage, + base_db::SourceDatabaseStorage, crate::db::AstDatabaseStorage )] #[derive(Default)] diff --git a/crates/ra_hir_ty/Cargo.toml b/crates/ra_hir_ty/Cargo.toml index 6156e4a854..720d171aca 100644 --- a/crates/ra_hir_ty/Cargo.toml +++ b/crates/ra_hir_ty/Cargo.toml @@ -21,7 +21,7 @@ stdx = { path = "../stdx" } hir_def = { path = "../ra_hir_def", package = "ra_hir_def" } hir_expand = { path = "../ra_hir_expand", package = "ra_hir_expand" } arena = { path = "../arena" } -ra_db = { path = "../ra_db" } +base_db = { path = "../base_db" } profile = { path = "../profile" } syntax = { path = "../syntax" } test_utils = { path = "../test_utils" } diff --git a/crates/ra_hir_ty/src/autoderef.rs b/crates/ra_hir_ty/src/autoderef.rs index c727012c69..ece68183e7 100644 --- a/crates/ra_hir_ty/src/autoderef.rs +++ b/crates/ra_hir_ty/src/autoderef.rs @@ -5,10 +5,10 @@ use std::iter::successors; +use base_db::CrateId; use hir_def::lang_item::LangItemTarget; use hir_expand::name::name; use log::{info, warn}; -use ra_db::CrateId; use crate::{ db::HirDatabase, diff --git a/crates/ra_hir_ty/src/db.rs b/crates/ra_hir_ty/src/db.rs index 7a28673b16..25cf9eb7f1 100644 --- a/crates/ra_hir_ty/src/db.rs +++ b/crates/ra_hir_ty/src/db.rs @@ -3,11 +3,11 @@ use std::sync::Arc; use arena::map::ArenaMap; +use base_db::{impl_intern_key, salsa, CrateId, Upcast}; use hir_def::{ db::DefDatabase, expr::ExprId, DefWithBodyId, FunctionId, GenericDefId, ImplId, LocalFieldId, TypeParamId, VariantId, }; -use ra_db::{impl_intern_key, salsa, CrateId, Upcast}; use crate::{ method_resolution::{InherentImpls, TraitImpls}, diff --git a/crates/ra_hir_ty/src/diagnostics.rs b/crates/ra_hir_ty/src/diagnostics.rs index bf35d2d0ee..ae0cf8d09b 100644 --- a/crates/ra_hir_ty/src/diagnostics.rs +++ b/crates/ra_hir_ty/src/diagnostics.rs @@ -208,12 +208,12 @@ impl Diagnostic for MismatchedArgCount { #[cfg(test)] mod tests { + use base_db::{fixture::WithFixture, FileId, SourceDatabase, SourceDatabaseExt}; use hir_def::{db::DefDatabase, AssocItemId, ModuleDefId}; use hir_expand::{ db::AstDatabase, diagnostics::{Diagnostic, DiagnosticSinkBuilder}, }; - use ra_db::{fixture::WithFixture, FileId, SourceDatabase, SourceDatabaseExt}; use rustc_hash::FxHashMap; use syntax::{TextRange, TextSize}; diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs index 7698cb0d4b..1e748476ac 100644 --- a/crates/ra_hir_ty/src/lib.rs +++ b/crates/ra_hir_ty/src/lib.rs @@ -26,6 +26,7 @@ mod test_db; use std::{iter, mem, ops::Deref, sync::Arc}; +use base_db::{salsa, CrateId}; use hir_def::{ expr::ExprId, type_ref::{Mutability, Rawness}, @@ -33,7 +34,6 @@ use hir_def::{ TypeParamId, }; use itertools::Itertools; -use ra_db::{salsa, CrateId}; use crate::{ db::HirDatabase, diff --git a/crates/ra_hir_ty/src/lower.rs b/crates/ra_hir_ty/src/lower.rs index 7b805fe7ae..cd574e983f 100644 --- a/crates/ra_hir_ty/src/lower.rs +++ b/crates/ra_hir_ty/src/lower.rs @@ -8,6 +8,7 @@ use std::{iter, sync::Arc}; use arena::map::ArenaMap; +use base_db::CrateId; use hir_def::{ adt::StructKind, builtin_type::BuiltinType, @@ -20,7 +21,6 @@ use hir_def::{ UnionId, VariantId, }; use hir_expand::name::Name; -use ra_db::CrateId; use smallvec::SmallVec; use stdx::impl_from; use test_utils::mark; diff --git a/crates/ra_hir_ty/src/method_resolution.rs b/crates/ra_hir_ty/src/method_resolution.rs index 3b3bee6a70..ec59145c70 100644 --- a/crates/ra_hir_ty/src/method_resolution.rs +++ b/crates/ra_hir_ty/src/method_resolution.rs @@ -5,6 +5,7 @@ use std::{iter, sync::Arc}; use arrayvec::ArrayVec; +use base_db::CrateId; use hir_def::{ builtin_type::{IntBitness, Signedness}, lang_item::LangItemTarget, @@ -12,7 +13,6 @@ use hir_def::{ AssocContainerId, AssocItemId, FunctionId, HasModule, ImplId, Lookup, TraitId, }; use hir_expand::name::Name; -use ra_db::CrateId; use rustc_hash::{FxHashMap, FxHashSet}; use super::Substs; diff --git a/crates/ra_hir_ty/src/test_db.rs b/crates/ra_hir_ty/src/test_db.rs index 0e2a69eec2..15b8435e92 100644 --- a/crates/ra_hir_ty/src/test_db.rs +++ b/crates/ra_hir_ty/src/test_db.rs @@ -5,16 +5,16 @@ use std::{ sync::{Arc, Mutex}, }; +use base_db::{salsa, CrateId, FileId, FileLoader, FileLoaderDelegate, SourceDatabase, Upcast}; use hir_def::{db::DefDatabase, ModuleId}; use hir_expand::db::AstDatabase; -use ra_db::{salsa, CrateId, FileId, FileLoader, FileLoaderDelegate, SourceDatabase, Upcast}; use rustc_hash::{FxHashMap, FxHashSet}; use syntax::TextRange; use test_utils::extract_annotations; #[salsa::database( - ra_db::SourceDatabaseExtStorage, - ra_db::SourceDatabaseStorage, + base_db::SourceDatabaseExtStorage, + base_db::SourceDatabaseStorage, hir_expand::db::AstDatabaseStorage, hir_def::db::InternDatabaseStorage, hir_def::db::DefDatabaseStorage, diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/ra_hir_ty/src/tests.rs index 5f6f8869ae..f6b172c3af 100644 --- a/crates/ra_hir_ty/src/tests.rs +++ b/crates/ra_hir_ty/src/tests.rs @@ -10,6 +10,7 @@ mod display_source_code; use std::sync::Arc; +use base_db::{fixture::WithFixture, FileRange, SourceDatabase, SourceDatabaseExt}; use expect::Expect; use hir_def::{ body::{BodySourceMap, SyntheticSyntax}, @@ -21,7 +22,6 @@ use hir_def::{ AssocItemId, DefWithBodyId, LocalModuleId, Lookup, ModuleDefId, }; use hir_expand::{db::AstDatabase, InFile}; -use ra_db::{fixture::WithFixture, FileRange, SourceDatabase, SourceDatabaseExt}; use stdx::format_to; use syntax::{ algo, diff --git a/crates/ra_hir_ty/src/traits.rs b/crates/ra_hir_ty/src/traits.rs index 2576a9dfc3..2553237170 100644 --- a/crates/ra_hir_ty/src/traits.rs +++ b/crates/ra_hir_ty/src/traits.rs @@ -1,10 +1,10 @@ //! Trait solving using Chalk. use std::sync::Arc; +use base_db::CrateId; use chalk_ir::cast::Cast; use chalk_solve::Solver; use hir_def::{lang_item::LangItemTarget, TraitId}; -use ra_db::CrateId; use crate::{db::HirDatabase, DebruijnIndex, Substs}; diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/ra_hir_ty/src/traits/chalk.rs index 3b6af5c9a8..b336534179 100644 --- a/crates/ra_hir_ty/src/traits/chalk.rs +++ b/crates/ra_hir_ty/src/traits/chalk.rs @@ -6,11 +6,11 @@ use log::debug; use chalk_ir::{fold::shift::Shift, CanonicalVarKinds, GenericArg, TypeName}; use chalk_solve::rust_ir::{self, OpaqueTyDatumBound, WellKnownTrait}; +use base_db::{salsa::InternKey, CrateId}; use hir_def::{ lang_item::{lang_attr, LangItemTarget}, AssocContainerId, AssocItemId, HasModule, Lookup, TypeAliasId, }; -use ra_db::{salsa::InternKey, CrateId}; use super::ChalkContext; use crate::{ diff --git a/crates/ra_hir_ty/src/traits/chalk/interner.rs b/crates/ra_hir_ty/src/traits/chalk/interner.rs index 8d4c51a8ff..fc0f9c2019 100644 --- a/crates/ra_hir_ty/src/traits/chalk/interner.rs +++ b/crates/ra_hir_ty/src/traits/chalk/interner.rs @@ -2,9 +2,9 @@ //! representation of the various objects Chalk deals with (types, goals etc.). use super::tls; +use base_db::salsa::InternId; use chalk_ir::{GenericArg, Goal, GoalData}; use hir_def::TypeAliasId; -use ra_db::salsa::InternId; use std::{fmt, sync::Arc}; #[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)] diff --git a/crates/ra_hir_ty/src/traits/chalk/mapping.rs b/crates/ra_hir_ty/src/traits/chalk/mapping.rs index b3e92993d2..fe62f3fa7c 100644 --- a/crates/ra_hir_ty/src/traits/chalk/mapping.rs +++ b/crates/ra_hir_ty/src/traits/chalk/mapping.rs @@ -9,8 +9,8 @@ use chalk_ir::{ }; use chalk_solve::rust_ir; +use base_db::salsa::InternKey; use hir_def::{type_ref::Mutability, AssocContainerId, GenericDefId, Lookup, TypeAliasId}; -use ra_db::salsa::InternKey; use crate::{ db::HirDatabase, diff --git a/crates/ra_ide/Cargo.toml b/crates/ra_ide/Cargo.toml index 938398a41a..1af51f3ae8 100644 --- a/crates/ra_ide/Cargo.toml +++ b/crates/ra_ide/Cargo.toml @@ -23,7 +23,7 @@ stdx = { path = "../stdx" } syntax = { path = "../syntax" } text_edit = { path = "../text_edit" } -ra_db = { path = "../ra_db" } +base_db = { path = "../base_db" } ra_ide_db = { path = "../ra_ide_db" } cfg = { path = "../cfg" } profile = { path = "../profile" } diff --git a/crates/ra_ide/src/call_hierarchy.rs b/crates/ra_ide/src/call_hierarchy.rs index 116e6bf83e..3578b8d3ce 100644 --- a/crates/ra_ide/src/call_hierarchy.rs +++ b/crates/ra_ide/src/call_hierarchy.rs @@ -137,7 +137,7 @@ impl CallLocations { #[cfg(test)] mod tests { - use ra_db::FilePosition; + use base_db::FilePosition; use crate::mock_analysis::analysis_and_position; diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs index b5efb6cd67..0e0a201d09 100644 --- a/crates/ra_ide/src/completion/completion_context.rs +++ b/crates/ra_ide/src/completion/completion_context.rs @@ -1,7 +1,7 @@ //! FIXME: write short doc here +use base_db::SourceDatabase; use hir::{Semantics, SemanticsScope, Type}; -use ra_db::SourceDatabase; use ra_ide_db::RootDatabase; use syntax::{ algo::{find_covering_element, find_node_at_offset}, diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs index 18def6115d..4e59e3a480 100644 --- a/crates/ra_ide/src/diagnostics.rs +++ b/crates/ra_ide/src/diagnostics.rs @@ -6,9 +6,9 @@ use std::cell::RefCell; +use base_db::SourceDatabase; use hir::{diagnostics::DiagnosticSinkBuilder, Semantics}; use itertools::Itertools; -use ra_db::SourceDatabase; use ra_ide_db::RootDatabase; use syntax::{ ast::{self, AstNode}, diff --git a/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs b/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs index efcd631b31..7e126d7a6a 100644 --- a/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs +++ b/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs @@ -2,12 +2,12 @@ //! The same module also has all curret custom fixes for the diagnostics implemented. use crate::Fix; use ast::{edit::IndentLevel, make}; +use base_db::FileId; use hir::{ db::AstDatabase, diagnostics::{Diagnostic, MissingFields, MissingOkInTailExpr, NoSuchField, UnresolvedModule}, HasSource, HirDisplay, Semantics, VariantDef, }; -use ra_db::FileId; use ra_ide_db::{ source_change::{FileSystemEdit, SourceFileEdit}, RootDatabase, diff --git a/crates/ra_ide/src/display/navigation_target.rs b/crates/ra_ide/src/display/navigation_target.rs index 683088a748..09ec3f65e6 100644 --- a/crates/ra_ide/src/display/navigation_target.rs +++ b/crates/ra_ide/src/display/navigation_target.rs @@ -1,8 +1,8 @@ //! FIXME: write short doc here +use base_db::{FileId, SourceDatabase}; use either::Either; use hir::{original_range, AssocItem, FieldSource, HasSource, InFile, ModuleSource}; -use ra_db::{FileId, SourceDatabase}; use ra_ide_db::{defs::Definition, RootDatabase}; use syntax::{ ast::{self, DocCommentsOwner, NameOwner}, diff --git a/crates/ra_ide/src/goto_definition.rs b/crates/ra_ide/src/goto_definition.rs index 77f374ea2a..b93d116bf8 100644 --- a/crates/ra_ide/src/goto_definition.rs +++ b/crates/ra_ide/src/goto_definition.rs @@ -100,7 +100,7 @@ pub(crate) fn reference_definition( #[cfg(test)] mod tests { - use ra_db::FileRange; + use base_db::FileRange; use syntax::{TextRange, TextSize}; use crate::mock_analysis::MockAnalysis; diff --git a/crates/ra_ide/src/goto_implementation.rs b/crates/ra_ide/src/goto_implementation.rs index 91a8c1dd17..6dc2ccfd05 100644 --- a/crates/ra_ide/src/goto_implementation.rs +++ b/crates/ra_ide/src/goto_implementation.rs @@ -74,7 +74,7 @@ fn impls_for_trait( #[cfg(test)] mod tests { - use ra_db::FileRange; + use base_db::FileRange; use crate::mock_analysis::MockAnalysis; diff --git a/crates/ra_ide/src/goto_type_definition.rs b/crates/ra_ide/src/goto_type_definition.rs index 3ec2ee59de..8017ca58cb 100644 --- a/crates/ra_ide/src/goto_type_definition.rs +++ b/crates/ra_ide/src/goto_type_definition.rs @@ -54,7 +54,7 @@ fn pick_best(tokens: TokenAtOffset) -> Option { #[cfg(test)] mod tests { - use ra_db::FileRange; + use base_db::FileRange; use crate::mock_analysis::MockAnalysis; diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs index 37e68ff7a5..a74087f87a 100644 --- a/crates/ra_ide/src/hover.rs +++ b/crates/ra_ide/src/hover.rs @@ -1,9 +1,9 @@ +use base_db::SourceDatabase; use hir::{ Adt, AsAssocItem, AssocItemContainer, Documentation, FieldSource, HasSource, HirDisplay, Module, ModuleDef, ModuleSource, Semantics, }; use itertools::Itertools; -use ra_db::SourceDatabase; use ra_ide_db::{ defs::{classify_name, classify_name_ref, Definition}, RootDatabase, @@ -352,8 +352,8 @@ fn pick_best(tokens: TokenAtOffset) -> Option { #[cfg(test)] mod tests { + use base_db::FileLoader; use expect::{expect, Expect}; - use ra_db::FileLoader; use crate::mock_analysis::analysis_and_position; diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs index 1fdf17800d..789fbdaf23 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ra_ide/src/lib.rs @@ -47,11 +47,11 @@ mod typing; use std::sync::Arc; -use cfg::CfgOptions; -use ra_db::{ +use base_db::{ salsa::{self, ParallelDatabase}, CheckCanceled, Env, FileLoader, FileSet, SourceDatabase, VfsPath, }; +use cfg::CfgOptions; use ra_ide_db::{ symbol_index::{self, FileSymbol}, LineIndexDatabase, @@ -81,12 +81,12 @@ pub use crate::{ }, }; -pub use hir::{Documentation, Semantics}; -pub use ra_assists::{Assist, AssistConfig, AssistId, AssistKind, ResolvedAssist}; -pub use ra_db::{ +pub use base_db::{ Canceled, CrateGraph, CrateId, Edition, FileId, FilePosition, FileRange, SourceRoot, SourceRootId, }; +pub use hir::{Documentation, Semantics}; +pub use ra_assists::{Assist, AssistConfig, AssistId, AssistKind, ResolvedAssist}; pub use ra_ide_db::{ change::AnalysisChange, line_index::{LineCol, LineIndex}, diff --git a/crates/ra_ide/src/mock_analysis.rs b/crates/ra_ide/src/mock_analysis.rs index a4691f0284..363e6d27e5 100644 --- a/crates/ra_ide/src/mock_analysis.rs +++ b/crates/ra_ide/src/mock_analysis.rs @@ -1,8 +1,8 @@ //! FIXME: write short doc here use std::sync::Arc; +use base_db::{CrateName, FileSet, SourceRoot, VfsPath}; use cfg::CfgOptions; -use ra_db::{CrateName, FileSet, SourceRoot, VfsPath}; use test_utils::{ extract_annotations, extract_range_or_offset, Fixture, RangeOrOffset, CURSOR_MARKER, }; diff --git a/crates/ra_ide/src/parent_module.rs b/crates/ra_ide/src/parent_module.rs index b78388e6b1..8439e1d5d3 100644 --- a/crates/ra_ide/src/parent_module.rs +++ b/crates/ra_ide/src/parent_module.rs @@ -1,5 +1,5 @@ +use base_db::{CrateId, FileId, FilePosition}; use hir::Semantics; -use ra_db::{CrateId, FileId, FilePosition}; use ra_ide_db::RootDatabase; use syntax::{ algo::find_node_at_offset, @@ -63,8 +63,8 @@ pub(crate) fn crate_for(db: &RootDatabase, file_id: FileId) -> Vec { #[cfg(test)] mod tests { + use base_db::Env; use cfg::CfgOptions; - use ra_db::Env; use test_utils::mark; use crate::{ diff --git a/crates/ra_ide/src/references/rename.rs b/crates/ra_ide/src/references/rename.rs index a075618e74..5697b9d879 100644 --- a/crates/ra_ide/src/references/rename.rs +++ b/crates/ra_ide/src/references/rename.rs @@ -1,7 +1,7 @@ //! FIXME: write short doc here +use base_db::SourceDatabaseExt; use hir::{Module, ModuleDef, ModuleSource, Semantics}; -use ra_db::SourceDatabaseExt; use ra_ide_db::{ defs::{classify_name, classify_name_ref, Definition, NameClass, NameRefClass}, RootDatabase, diff --git a/crates/ra_ide/src/ssr.rs b/crates/ra_ide/src/ssr.rs index 8be862fd6e..97b82b70e5 100644 --- a/crates/ra_ide/src/ssr.rs +++ b/crates/ra_ide/src/ssr.rs @@ -1,4 +1,4 @@ -use ra_db::{FilePosition, FileRange}; +use base_db::{FilePosition, FileRange}; use ra_ide_db::RootDatabase; use crate::SourceFileEdit; diff --git a/crates/ra_ide/src/status.rs b/crates/ra_ide/src/status.rs index 797ead1ada..869c74accc 100644 --- a/crates/ra_ide/src/status.rs +++ b/crates/ra_ide/src/status.rs @@ -1,11 +1,11 @@ use std::{fmt, iter::FromIterator, sync::Arc}; -use hir::MacroFile; -use profile::{memory_usage, Bytes}; -use ra_db::{ +use base_db::{ salsa::debug::{DebugQueryTable, TableEntry}, FileTextQuery, SourceRootId, }; +use hir::MacroFile; +use profile::{memory_usage, Bytes}; use ra_ide_db::{ symbol_index::{LibrarySymbolsQuery, SymbolIndex}, RootDatabase, @@ -16,7 +16,7 @@ use syntax::{ast, Parse, SyntaxNode}; use crate::FileId; fn syntax_tree_stats(db: &RootDatabase) -> SyntaxTreeStats { - ra_db::ParseQuery.in_db(db).entries::() + base_db::ParseQuery.in_db(db).entries::() } fn macro_syntax_tree_stats(db: &RootDatabase) -> SyntaxTreeStats { hir::db::ParseMacroQuery.in_db(db).entries::() diff --git a/crates/ra_ide/src/syntax_highlighting/html.rs b/crates/ra_ide/src/syntax_highlighting/html.rs index 418122648a..249368ff81 100644 --- a/crates/ra_ide/src/syntax_highlighting/html.rs +++ b/crates/ra_ide/src/syntax_highlighting/html.rs @@ -1,7 +1,7 @@ //! Renders a bit of code as HTML. +use base_db::SourceDatabase; use oorandom::Rand32; -use ra_db::SourceDatabase; use syntax::{AstNode, TextRange, TextSize}; use crate::{syntax_highlighting::highlight, FileId, RootDatabase}; diff --git a/crates/ra_ide/src/syntax_tree.rs b/crates/ra_ide/src/syntax_tree.rs index d05ff22149..17daf06b66 100644 --- a/crates/ra_ide/src/syntax_tree.rs +++ b/crates/ra_ide/src/syntax_tree.rs @@ -1,4 +1,4 @@ -use ra_db::{FileId, SourceDatabase}; +use base_db::{FileId, SourceDatabase}; use ra_ide_db::RootDatabase; use syntax::{ algo, AstNode, NodeOrToken, SourceFile, diff --git a/crates/ra_ide/src/typing.rs b/crates/ra_ide/src/typing.rs index 7897c57b77..75f2a6b605 100644 --- a/crates/ra_ide/src/typing.rs +++ b/crates/ra_ide/src/typing.rs @@ -15,7 +15,7 @@ mod on_enter; -use ra_db::{FilePosition, SourceDatabase}; +use base_db::{FilePosition, SourceDatabase}; use ra_ide_db::{source_change::SourceFileEdit, RootDatabase}; use syntax::{ algo::find_node_at_offset, diff --git a/crates/ra_ide/src/typing/on_enter.rs b/crates/ra_ide/src/typing/on_enter.rs index 9cd153f94a..1939306590 100644 --- a/crates/ra_ide/src/typing/on_enter.rs +++ b/crates/ra_ide/src/typing/on_enter.rs @@ -1,7 +1,7 @@ //! Handles the `Enter` key press. At the momently, this only continues //! comments, but should handle indent some time in the future as well. -use ra_db::{FilePosition, SourceDatabase}; +use base_db::{FilePosition, SourceDatabase}; use ra_ide_db::RootDatabase; use syntax::{ ast::{self, AstToken}, diff --git a/crates/ra_ide_db/Cargo.toml b/crates/ra_ide_db/Cargo.toml index 9ed13a13db..0cda7090d3 100644 --- a/crates/ra_ide_db/Cargo.toml +++ b/crates/ra_ide_db/Cargo.toml @@ -23,7 +23,7 @@ stdx = { path = "../stdx" } syntax = { path = "../syntax" } text_edit = { path = "../text_edit" } -ra_db = { path = "../ra_db" } +base_db = { path = "../base_db" } profile = { path = "../profile" } test_utils = { path = "../test_utils" } diff --git a/crates/ra_ide_db/src/change.rs b/crates/ra_ide_db/src/change.rs index 7a4e04ca9b..8b4fd7ab84 100644 --- a/crates/ra_ide_db/src/change.rs +++ b/crates/ra_ide_db/src/change.rs @@ -3,11 +3,11 @@ use std::{fmt, sync::Arc, time}; -use profile::{memory_usage, Bytes}; -use ra_db::{ +use base_db::{ salsa::{Database, Durability, SweepStrategy}, CrateGraph, FileId, SourceDatabase, SourceDatabaseExt, SourceRoot, SourceRootId, }; +use profile::{memory_usage, Bytes}; use rustc_hash::FxHashSet; use crate::{symbol_index::SymbolsDatabase, RootDatabase}; @@ -146,7 +146,7 @@ impl RootDatabase { let sweep = SweepStrategy::default().discard_values().sweep_all_revisions(); - ra_db::ParseQuery.in_db(self).sweep(sweep); + base_db::ParseQuery.in_db(self).sweep(sweep); hir::db::ParseMacroQuery.in_db(self).sweep(sweep); // Macros do take significant space, but less then the syntax trees @@ -201,14 +201,14 @@ impl RootDatabase { } sweep_each_query![ // SourceDatabase - ra_db::ParseQuery - ra_db::CrateGraphQuery + base_db::ParseQuery + base_db::CrateGraphQuery // SourceDatabaseExt - ra_db::FileTextQuery - ra_db::FileSourceRootQuery - ra_db::SourceRootQuery - ra_db::SourceRootCratesQuery + base_db::FileTextQuery + base_db::FileSourceRootQuery + base_db::SourceRootQuery + base_db::SourceRootCratesQuery // AstDatabase hir::db::AstIdMapQuery diff --git a/crates/ra_ide_db/src/lib.rs b/crates/ra_ide_db/src/lib.rs index 6900cac73e..fd474cd0f4 100644 --- a/crates/ra_ide_db/src/lib.rs +++ b/crates/ra_ide_db/src/lib.rs @@ -13,19 +13,19 @@ mod wasm_shims; use std::{fmt, sync::Arc}; -use hir::db::{AstDatabase, DefDatabase, HirDatabase}; -use ra_db::{ +use base_db::{ salsa::{self, Durability}, Canceled, CheckCanceled, CrateId, FileId, FileLoader, FileLoaderDelegate, SourceDatabase, Upcast, }; +use hir::db::{AstDatabase, DefDatabase, HirDatabase}; use rustc_hash::FxHashSet; use crate::{line_index::LineIndex, symbol_index::SymbolsDatabase}; #[salsa::database( - ra_db::SourceDatabaseStorage, - ra_db::SourceDatabaseExtStorage, + base_db::SourceDatabaseStorage, + base_db::SourceDatabaseExtStorage, LineIndexDatabaseStorage, symbol_index::SymbolsDatabaseStorage, hir::db::InternDatabaseStorage, @@ -111,8 +111,8 @@ impl RootDatabase { } pub fn update_lru_capacity(&mut self, lru_capacity: Option) { - let lru_capacity = lru_capacity.unwrap_or(ra_db::DEFAULT_LRU_CAP); - ra_db::ParseQuery.in_db_mut(self).set_lru_capacity(lru_capacity); + let lru_capacity = lru_capacity.unwrap_or(base_db::DEFAULT_LRU_CAP); + base_db::ParseQuery.in_db_mut(self).set_lru_capacity(lru_capacity); hir::db::ParseMacroQuery.in_db_mut(self).set_lru_capacity(lru_capacity); hir::db::MacroExpandQuery.in_db_mut(self).set_lru_capacity(lru_capacity); } @@ -129,7 +129,7 @@ impl salsa::ParallelDatabase for RootDatabase { } #[salsa::query_group(LineIndexDatabaseStorage)] -pub trait LineIndexDatabase: ra_db::SourceDatabase + CheckCanceled { +pub trait LineIndexDatabase: base_db::SourceDatabase + CheckCanceled { fn line_index(&self, file_id: FileId) -> Arc; } diff --git a/crates/ra_ide_db/src/search.rs b/crates/ra_ide_db/src/search.rs index 7827cc71cf..b9360bf129 100644 --- a/crates/ra_ide_db/src/search.rs +++ b/crates/ra_ide_db/src/search.rs @@ -6,9 +6,9 @@ use std::{convert::TryInto, mem}; +use base_db::{FileId, FileRange, SourceDatabaseExt}; use hir::{DefWithBody, HasSource, Module, ModuleSource, Semantics, Visibility}; use once_cell::unsync::Lazy; -use ra_db::{FileId, FileRange, SourceDatabaseExt}; use rustc_hash::FxHashMap; use syntax::{ast, match_ast, AstNode, TextRange, TextSize}; diff --git a/crates/ra_ide_db/src/source_change.rs b/crates/ra_ide_db/src/source_change.rs index ae21132dd7..f1590ec663 100644 --- a/crates/ra_ide_db/src/source_change.rs +++ b/crates/ra_ide_db/src/source_change.rs @@ -3,7 +3,7 @@ //! //! It can be viewed as a dual for `AnalysisChange`. -use ra_db::FileId; +use base_db::FileId; use text_edit::TextEdit; #[derive(Default, Debug, Clone)] diff --git a/crates/ra_ide_db/src/symbol_index.rs b/crates/ra_ide_db/src/symbol_index.rs index 896092b467..654df898e9 100644 --- a/crates/ra_ide_db/src/symbol_index.rs +++ b/crates/ra_ide_db/src/symbol_index.rs @@ -28,12 +28,12 @@ use std::{ sync::Arc, }; -use fst::{self, Streamer}; -use hir::db::DefDatabase; -use ra_db::{ +use base_db::{ salsa::{self, ParallelDatabase}, CrateId, FileId, SourceDatabaseExt, SourceRootId, }; +use fst::{self, Streamer}; +use hir::db::DefDatabase; use rayon::prelude::*; use rustc_hash::{FxHashMap, FxHashSet}; use syntax::{ diff --git a/crates/ra_ssr/Cargo.toml b/crates/ra_ssr/Cargo.toml index 958baa2df7..f290939cfb 100644 --- a/crates/ra_ssr/Cargo.toml +++ b/crates/ra_ssr/Cargo.toml @@ -13,7 +13,7 @@ doctest = false [dependencies] text_edit = { path = "../text_edit" } syntax = { path = "../syntax" } -ra_db = { path = "../ra_db" } +base_db = { path = "../base_db" } ra_ide_db = { path = "../ra_ide_db" } hir = { path = "../ra_hir", package = "ra_hir" } rustc-hash = "1.1.0" diff --git a/crates/ra_ssr/src/lib.rs b/crates/ra_ssr/src/lib.rs index fb53212a3a..6725582e49 100644 --- a/crates/ra_ssr/src/lib.rs +++ b/crates/ra_ssr/src/lib.rs @@ -18,8 +18,8 @@ use crate::errors::bail; pub use crate::errors::SsrError; pub use crate::matching::Match; use crate::matching::MatchFailureReason; +use base_db::{FileId, FilePosition, FileRange}; use hir::Semantics; -use ra_db::{FileId, FilePosition, FileRange}; use ra_ide_db::source_change::SourceFileEdit; use resolving::ResolvedRule; use rustc_hash::FxHashMap; @@ -71,7 +71,7 @@ impl<'db> MatchFinder<'db> { /// Constructs an instance using the start of the first file in `db` as the lookup context. pub fn at_first_file(db: &'db ra_ide_db::RootDatabase) -> Result, SsrError> { - use ra_db::SourceDatabaseExt; + use base_db::SourceDatabaseExt; use ra_ide_db::symbol_index::SymbolsDatabase; if let Some(first_file_id) = db .local_roots() @@ -105,7 +105,7 @@ impl<'db> MatchFinder<'db> { /// Finds matches for all added rules and returns edits for all found matches. pub fn edits(&self) -> Vec { - use ra_db::SourceDatabaseExt; + use base_db::SourceDatabaseExt; let mut matches_by_file = FxHashMap::default(); for m in self.matches().matches { matches_by_file @@ -150,7 +150,7 @@ impl<'db> MatchFinder<'db> { /// them, while recording reasons why they don't match. This API is useful for command /// line-based debugging where providing a range is difficult. pub fn debug_where_text_equal(&self, file_id: FileId, snippet: &str) -> Vec { - use ra_db::SourceDatabaseExt; + use base_db::SourceDatabaseExt; let file = self.sema.parse(file_id); let mut res = Vec::new(); let file_text = self.sema.db.file_text(file_id); diff --git a/crates/ra_ssr/src/matching.rs b/crates/ra_ssr/src/matching.rs index 6e0b923528..e81a87c471 100644 --- a/crates/ra_ssr/src/matching.rs +++ b/crates/ra_ssr/src/matching.rs @@ -6,8 +6,8 @@ use crate::{ resolving::{ResolvedPattern, ResolvedRule, UfcsCallInfo}, SsrMatches, }; +use base_db::FileRange; use hir::Semantics; -use ra_db::FileRange; use rustc_hash::FxHashMap; use std::{cell::Cell, iter::Peekable}; use syntax::ast::{AstNode, AstToken}; diff --git a/crates/ra_ssr/src/resolving.rs b/crates/ra_ssr/src/resolving.rs index bfc20705b4..dac09bae80 100644 --- a/crates/ra_ssr/src/resolving.rs +++ b/crates/ra_ssr/src/resolving.rs @@ -2,8 +2,8 @@ use crate::errors::error; use crate::{parsing, SsrError}; +use base_db::FilePosition; use parsing::Placeholder; -use ra_db::FilePosition; use rustc_hash::FxHashMap; use syntax::{ast, SmolStr, SyntaxKind, SyntaxNode, SyntaxToken}; use test_utils::mark; diff --git a/crates/ra_ssr/src/search.rs b/crates/ra_ssr/src/search.rs index e44e149599..434953fb48 100644 --- a/crates/ra_ssr/src/search.rs +++ b/crates/ra_ssr/src/search.rs @@ -5,7 +5,7 @@ use crate::{ resolving::{ResolvedPath, ResolvedPattern, ResolvedRule}, Match, MatchFinder, }; -use ra_db::{FileId, FileRange}; +use base_db::{FileId, FileRange}; use ra_ide_db::{ defs::Definition, search::{Reference, SearchScope}, @@ -145,7 +145,7 @@ impl<'db> MatchFinder<'db> { fn search_files_do(&self, mut callback: impl FnMut(FileId)) { if self.restrict_ranges.is_empty() { // Unrestricted search. - use ra_db::SourceDatabaseExt; + use base_db::SourceDatabaseExt; use ra_ide_db::symbol_index::SymbolsDatabase; for &root in self.sema.db.local_roots().iter() { let sr = self.sema.db.source_root(root); diff --git a/crates/ra_ssr/src/tests.rs b/crates/ra_ssr/src/tests.rs index 4bc09c1e47..54c3da9db3 100644 --- a/crates/ra_ssr/src/tests.rs +++ b/crates/ra_ssr/src/tests.rs @@ -1,6 +1,6 @@ use crate::{MatchFinder, SsrRule}; +use base_db::{salsa::Durability, FileId, FilePosition, FileRange, SourceDatabaseExt}; use expect::{expect, Expect}; -use ra_db::{salsa::Durability, FileId, FilePosition, FileRange, SourceDatabaseExt}; use rustc_hash::FxHashSet; use std::sync::Arc; use test_utils::{mark, RangeOrOffset}; @@ -62,7 +62,7 @@ fn parser_undefined_placeholder_in_replacement() { /// `code` may optionally contain a cursor marker `<|>`. If it doesn't, then the position will be /// the start of the file. If there's a second cursor marker, then we'll return a single range. pub(crate) fn single_file(code: &str) -> (ra_ide_db::RootDatabase, FilePosition, Vec) { - use ra_db::fixture::WithFixture; + use base_db::fixture::WithFixture; use ra_ide_db::symbol_index::SymbolsDatabase; let (mut db, file_id, range_or_offset) = if code.contains(test_utils::CURSOR_MARKER) { ra_ide_db::RootDatabase::with_range_or_offset(code) @@ -83,7 +83,7 @@ pub(crate) fn single_file(code: &str) -> (ra_ide_db::RootDatabase, FilePosition, } } let mut local_roots = FxHashSet::default(); - local_roots.insert(ra_db::fixture::WORKSPACE); + local_roots.insert(base_db::fixture::WORKSPACE); db.set_local_roots_with_durability(Arc::new(local_roots), Durability::HIGH); (db, position, selections) } diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index c6102bf272..210d9e9c88 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml @@ -46,7 +46,7 @@ cfg = { path = "../cfg" } toolchain = { path = "../toolchain" } # This should only be used in CLI -ra_db = { path = "../ra_db" } +base_db = { path = "../base_db" } ra_ide_db = { path = "../ra_ide_db" } ra_ssr = { path = "../ra_ssr" } hir = { path = "../ra_hir", package = "ra_hir" } diff --git a/crates/rust-analyzer/src/cli/analysis_bench.rs b/crates/rust-analyzer/src/cli/analysis_bench.rs index bc5f77e1a9..b20a1675e6 100644 --- a/crates/rust-analyzer/src/cli/analysis_bench.rs +++ b/crates/rust-analyzer/src/cli/analysis_bench.rs @@ -3,7 +3,7 @@ use std::{env, path::PathBuf, str::FromStr, sync::Arc, time::Instant}; use anyhow::{bail, format_err, Result}; -use ra_db::{ +use base_db::{ salsa::{Database, Durability}, FileId, }; diff --git a/crates/rust-analyzer/src/cli/analysis_stats.rs b/crates/rust-analyzer/src/cli/analysis_stats.rs index cfc1b22440..fb2b2b0001 100644 --- a/crates/rust-analyzer/src/cli/analysis_stats.rs +++ b/crates/rust-analyzer/src/cli/analysis_stats.rs @@ -6,6 +6,10 @@ use std::{ time::{SystemTime, UNIX_EPOCH}, }; +use base_db::{ + salsa::{self, ParallelDatabase}, + SourceDatabaseExt, +}; use hir::{ db::{AstDatabase, DefDatabase, HirDatabase}, original_range, AssocItem, Crate, HasSource, HirDisplay, ModuleDef, @@ -14,10 +18,6 @@ use hir_def::FunctionId; use hir_ty::{Ty, TypeWalk}; use itertools::Itertools; use oorandom::Rand32; -use ra_db::{ - salsa::{self, ParallelDatabase}, - SourceDatabaseExt, -}; use rayon::prelude::*; use rustc_hash::FxHashSet; use stdx::format_to; diff --git a/crates/rust-analyzer/src/cli/diagnostics.rs b/crates/rust-analyzer/src/cli/diagnostics.rs index f17fc5dfe9..56403cabe4 100644 --- a/crates/rust-analyzer/src/cli/diagnostics.rs +++ b/crates/rust-analyzer/src/cli/diagnostics.rs @@ -6,8 +6,8 @@ use std::path::Path; use anyhow::anyhow; use rustc_hash::FxHashSet; +use base_db::SourceDatabaseExt; use hir::Crate; -use ra_db::SourceDatabaseExt; use ra_ide::Severity; use crate::cli::{load_cargo::load_cargo, Result}; diff --git a/crates/rust-analyzer/src/cli/load_cargo.rs b/crates/rust-analyzer/src/cli/load_cargo.rs index f6cb144c67..5427348032 100644 --- a/crates/rust-analyzer/src/cli/load_cargo.rs +++ b/crates/rust-analyzer/src/cli/load_cargo.rs @@ -3,9 +3,9 @@ use std::{path::Path, sync::Arc}; use anyhow::Result; +use base_db::CrateGraph; use crossbeam_channel::{unbounded, Receiver}; use project_model::{CargoConfig, ProcMacroClient, ProjectManifest, ProjectWorkspace}; -use ra_db::CrateGraph; use ra_ide::{AnalysisChange, AnalysisHost}; use vfs::{loader::Handle, AbsPath, AbsPathBuf}; diff --git a/crates/rust-analyzer/src/cli/ssr.rs b/crates/rust-analyzer/src/cli/ssr.rs index 194bec008d..08788fb415 100644 --- a/crates/rust-analyzer/src/cli/ssr.rs +++ b/crates/rust-analyzer/src/cli/ssr.rs @@ -4,7 +4,7 @@ use crate::cli::{load_cargo::load_cargo, Result}; use ra_ssr::{MatchFinder, SsrPattern, SsrRule}; pub fn apply_ssr_rules(rules: Vec) -> Result<()> { - use ra_db::SourceDatabaseExt; + use base_db::SourceDatabaseExt; let (host, vfs) = load_cargo(&std::env::current_dir()?, true, true)?; let db = host.raw_database(); let mut match_finder = MatchFinder::at_first_file(db)?; @@ -26,7 +26,7 @@ pub fn apply_ssr_rules(rules: Vec) -> Result<()> { /// `debug_snippet`. This is intended for debugging and probably isn't in it's current form useful /// for much else. pub fn search_for_patterns(patterns: Vec, debug_snippet: Option) -> Result<()> { - use ra_db::SourceDatabaseExt; + use base_db::SourceDatabaseExt; use ra_ide_db::symbol_index::SymbolsDatabase; let (host, _vfs) = load_cargo(&std::env::current_dir()?, true, true)?; let db = host.raw_database(); diff --git a/crates/rust-analyzer/src/from_proto.rs b/crates/rust-analyzer/src/from_proto.rs index ad88ffdd72..945a353dd5 100644 --- a/crates/rust-analyzer/src/from_proto.rs +++ b/crates/rust-analyzer/src/from_proto.rs @@ -1,7 +1,7 @@ //! Conversion lsp_types types to rust-analyzer specific ones. use std::convert::TryFrom; -use ra_db::{FileId, FilePosition, FileRange}; +use base_db::{FileId, FilePosition, FileRange}; use ra_ide::{AssistKind, LineCol, LineIndex}; use syntax::{TextRange, TextSize}; use vfs::AbsPathBuf; diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs index 2e8b708d0f..f04a0a59fd 100644 --- a/crates/rust-analyzer/src/global_state.rs +++ b/crates/rust-analyzer/src/global_state.rs @@ -5,12 +5,12 @@ use std::{sync::Arc, time::Instant}; +use base_db::{CrateId, VfsPath}; use crossbeam_channel::{unbounded, Receiver, Sender}; use flycheck::FlycheckHandle; use lsp_types::{SemanticTokens, Url}; use parking_lot::{Mutex, RwLock}; use project_model::{CargoWorkspace, ProcMacroClient, ProjectWorkspace, Target}; -use ra_db::{CrateId, VfsPath}; use ra_ide::{Analysis, AnalysisChange, AnalysisHost, FileId}; use rustc_hash::FxHashMap; diff --git a/crates/rust-analyzer/src/lsp_utils.rs b/crates/rust-analyzer/src/lsp_utils.rs index 0bc3ff115d..17d1550cdd 100644 --- a/crates/rust-analyzer/src/lsp_utils.rs +++ b/crates/rust-analyzer/src/lsp_utils.rs @@ -1,8 +1,8 @@ //! Utilities for LSP-related boilerplate code. use std::{error::Error, ops::Range}; +use base_db::Canceled; use lsp_server::Notification; -use ra_db::Canceled; use ra_ide::LineIndex; use crate::{from_proto, global_state::GlobalState}; diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index 9a779cb14e..5726820f91 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs @@ -5,10 +5,10 @@ use std::{ time::{Duration, Instant}, }; +use base_db::VfsPath; use crossbeam_channel::{select, Receiver}; use lsp_server::{Connection, Notification, Request, Response}; use lsp_types::notification::Notification as _; -use ra_db::VfsPath; use ra_ide::{Canceled, FileId}; use crate::{ diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs index 640417dc65..fd133e3124 100644 --- a/crates/rust-analyzer/src/reload.rs +++ b/crates/rust-analyzer/src/reload.rs @@ -1,9 +1,9 @@ //! Project loading & configuration updates use std::{mem, sync::Arc}; +use base_db::{CrateGraph, SourceRoot, VfsPath}; use flycheck::FlycheckHandle; use project_model::{ProcMacroClient, ProjectWorkspace}; -use ra_db::{CrateGraph, SourceRoot, VfsPath}; use ra_ide::AnalysisChange; use vfs::{file_set::FileSetConfig, AbsPath, AbsPathBuf, ChangeKind}; diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index 278819a5c3..93a4b1f27d 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs @@ -4,8 +4,8 @@ use std::{ sync::atomic::{AtomicU32, Ordering}, }; +use base_db::{FileId, FileRange}; use itertools::Itertools; -use ra_db::{FileId, FileRange}; use ra_ide::{ Assist, AssistKind, CallInfo, CompletionItem, CompletionItemKind, Documentation, FileSystemEdit, Fold, FoldKind, Highlight, HighlightModifier, HighlightTag, HighlightedRange, diff --git a/docs/dev/architecture.md b/docs/dev/architecture.md index 21373729c7..746d41f83c 100644 --- a/docs/dev/architecture.md +++ b/docs/dev/architecture.md @@ -92,14 +92,14 @@ in particular: it shows off various methods of working with syntax tree. See [#93](https://github.com/rust-analyzer/rust-analyzer/pull/93) for an example PR which fixes a bug in the grammar. -### `crates/ra_db` +### `crates/base_db` We use the [salsa](https://github.com/salsa-rs/salsa) crate for incremental and on-demand computation. Roughly, you can think of salsa as a key-value store, but -it also can compute derived values using specified functions. The `ra_db` crate +it also can compute derived values using specified functions. The `base_db` crate provides basic infrastructure for interacting with salsa. Crucially, it defines most of the "input" queries: facts supplied by the client of the -analyzer. Reading the docs of the `ra_db::input` module should be useful: +analyzer. Reading the docs of the `base_db::input` module should be useful: everything else is strictly derived from those inputs. ### `crates/ra_hir*` crates diff --git a/docs/dev/guide.md b/docs/dev/guide.md index c3252f1f68..d14143226b 100644 --- a/docs/dev/guide.md +++ b/docs/dev/guide.md @@ -259,7 +259,7 @@ Salsa input queries are defined in [`FilesDatabase`] (which is a part of `RootDatabase`). They closely mirror the familiar `AnalysisChange` structure: indeed, what `apply_change` does is it sets the values of input queries. -[`FilesDatabase`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_db/src/input.rs#L150-L174 +[`FilesDatabase`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/base_db/src/input.rs#L150-L174 ## From text to semantic model @@ -392,7 +392,7 @@ integers which can "intern" a location and return an integer ID back. The salsa database we use includes a couple of [interners]. How to "garbage collect" unused locations is an open question. -[`LocationInterner`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_db/src/loc2id.rs#L65-L71 +[`LocationInterner`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/base_db/src/loc2id.rs#L65-L71 [interners]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/db.rs#L22-L23 For example, we use `LocationInterner` to assign IDs to definitions of functions, From b7aa4898e0841ab8199643f89a0caa967b698ca8 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 16:26:29 +0200 Subject: [PATCH 097/119] Rename ra_hir_expand -> hir_expand --- Cargo.lock | 40 +++++++++---------- .../{ra_hir_expand => hir_expand}/Cargo.toml | 8 ++-- .../src/ast_id_map.rs | 0 .../src/builtin_derive.rs | 0 .../src/builtin_macro.rs | 0 .../{ra_hir_expand => hir_expand}/src/db.rs | 0 .../src/diagnostics.rs | 0 .../src/eager.rs | 0 .../src/hygiene.rs | 0 .../{ra_hir_expand => hir_expand}/src/lib.rs | 2 +- .../{ra_hir_expand => hir_expand}/src/name.rs | 0 .../src/proc_macro.rs | 0 .../src/quote.rs | 0 .../src/test_db.rs | 0 crates/ra_hir/Cargo.toml | 2 +- crates/ra_hir/src/code_model.rs | 2 +- crates/ra_hir_def/Cargo.toml | 3 +- crates/ra_hir_ty/Cargo.toml | 2 +- xtask/tests/tidy.rs | 2 +- 19 files changed, 30 insertions(+), 31 deletions(-) rename crates/{ra_hir_expand => hir_expand}/Cargo.toml (91%) rename crates/{ra_hir_expand => hir_expand}/src/ast_id_map.rs (100%) rename crates/{ra_hir_expand => hir_expand}/src/builtin_derive.rs (100%) rename crates/{ra_hir_expand => hir_expand}/src/builtin_macro.rs (100%) rename crates/{ra_hir_expand => hir_expand}/src/db.rs (100%) rename crates/{ra_hir_expand => hir_expand}/src/diagnostics.rs (100%) rename crates/{ra_hir_expand => hir_expand}/src/eager.rs (100%) rename crates/{ra_hir_expand => hir_expand}/src/hygiene.rs (100%) rename crates/{ra_hir_expand => hir_expand}/src/lib.rs (99%) rename crates/{ra_hir_expand => hir_expand}/src/name.rs (100%) rename crates/{ra_hir_expand => hir_expand}/src/proc_macro.rs (100%) rename crates/{ra_hir_expand => hir_expand}/src/quote.rs (100%) rename crates/{ra_hir_expand => hir_expand}/src/test_db.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index a99dd6e04a..768c3293d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -463,6 +463,23 @@ dependencies = [ "libc", ] +[[package]] +name = "hir_expand" +version = "0.0.0" +dependencies = [ + "arena", + "base_db", + "either", + "log", + "mbe", + "parser", + "profile", + "rustc-hash", + "syntax", + "test_utils", + "tt", +] + [[package]] name = "home" version = "0.5.3" @@ -1017,11 +1034,11 @@ dependencies = [ "arrayvec", "base_db", "either", + "hir_expand", "itertools", "log", "profile", "ra_hir_def", - "ra_hir_expand", "ra_hir_ty", "rustc-hash", "stdx", @@ -1040,13 +1057,13 @@ dependencies = [ "either", "expect", "fst", + "hir_expand", "indexmap", "itertools", "log", "mbe", "once_cell", "profile", - "ra_hir_expand", "rustc-hash", "smallvec", "stdx", @@ -1055,23 +1072,6 @@ dependencies = [ "tt", ] -[[package]] -name = "ra_hir_expand" -version = "0.1.0" -dependencies = [ - "arena", - "base_db", - "either", - "log", - "mbe", - "parser", - "profile", - "rustc-hash", - "syntax", - "test_utils", - "tt", -] - [[package]] name = "ra_hir_ty" version = "0.1.0" @@ -1084,11 +1084,11 @@ dependencies = [ "chalk-solve", "ena", "expect", + "hir_expand", "itertools", "log", "profile", "ra_hir_def", - "ra_hir_expand", "rustc-hash", "scoped-tls", "smallvec", diff --git a/crates/ra_hir_expand/Cargo.toml b/crates/hir_expand/Cargo.toml similarity index 91% rename from crates/ra_hir_expand/Cargo.toml rename to crates/hir_expand/Cargo.toml index 41acf37122..1c46992915 100644 --- a/crates/ra_hir_expand/Cargo.toml +++ b/crates/hir_expand/Cargo.toml @@ -1,9 +1,9 @@ [package] -edition = "2018" -name = "ra_hir_expand" -version = "0.1.0" -authors = ["rust-analyzer developers"] +name = "hir_expand" +version = "0.0.0" license = "MIT OR Apache-2.0" +authors = ["rust-analyzer developers"] +edition = "2018" [lib] doctest = false diff --git a/crates/ra_hir_expand/src/ast_id_map.rs b/crates/hir_expand/src/ast_id_map.rs similarity index 100% rename from crates/ra_hir_expand/src/ast_id_map.rs rename to crates/hir_expand/src/ast_id_map.rs diff --git a/crates/ra_hir_expand/src/builtin_derive.rs b/crates/hir_expand/src/builtin_derive.rs similarity index 100% rename from crates/ra_hir_expand/src/builtin_derive.rs rename to crates/hir_expand/src/builtin_derive.rs diff --git a/crates/ra_hir_expand/src/builtin_macro.rs b/crates/hir_expand/src/builtin_macro.rs similarity index 100% rename from crates/ra_hir_expand/src/builtin_macro.rs rename to crates/hir_expand/src/builtin_macro.rs diff --git a/crates/ra_hir_expand/src/db.rs b/crates/hir_expand/src/db.rs similarity index 100% rename from crates/ra_hir_expand/src/db.rs rename to crates/hir_expand/src/db.rs diff --git a/crates/ra_hir_expand/src/diagnostics.rs b/crates/hir_expand/src/diagnostics.rs similarity index 100% rename from crates/ra_hir_expand/src/diagnostics.rs rename to crates/hir_expand/src/diagnostics.rs diff --git a/crates/ra_hir_expand/src/eager.rs b/crates/hir_expand/src/eager.rs similarity index 100% rename from crates/ra_hir_expand/src/eager.rs rename to crates/hir_expand/src/eager.rs diff --git a/crates/ra_hir_expand/src/hygiene.rs b/crates/hir_expand/src/hygiene.rs similarity index 100% rename from crates/ra_hir_expand/src/hygiene.rs rename to crates/hir_expand/src/hygiene.rs diff --git a/crates/ra_hir_expand/src/lib.rs b/crates/hir_expand/src/lib.rs similarity index 99% rename from crates/ra_hir_expand/src/lib.rs rename to crates/hir_expand/src/lib.rs index 7425b561ac..2be15e8413 100644 --- a/crates/ra_hir_expand/src/lib.rs +++ b/crates/hir_expand/src/lib.rs @@ -1,4 +1,4 @@ -//! `ra_hir_expand` deals with macro expansion. +//! `hir_expand` deals with macro expansion. //! //! Specifically, it implements a concept of `MacroFile` -- a file whose syntax //! tree originates not from the text of some `FileId`, but from some macro diff --git a/crates/ra_hir_expand/src/name.rs b/crates/hir_expand/src/name.rs similarity index 100% rename from crates/ra_hir_expand/src/name.rs rename to crates/hir_expand/src/name.rs diff --git a/crates/ra_hir_expand/src/proc_macro.rs b/crates/hir_expand/src/proc_macro.rs similarity index 100% rename from crates/ra_hir_expand/src/proc_macro.rs rename to crates/hir_expand/src/proc_macro.rs diff --git a/crates/ra_hir_expand/src/quote.rs b/crates/hir_expand/src/quote.rs similarity index 100% rename from crates/ra_hir_expand/src/quote.rs rename to crates/hir_expand/src/quote.rs diff --git a/crates/ra_hir_expand/src/test_db.rs b/crates/hir_expand/src/test_db.rs similarity index 100% rename from crates/ra_hir_expand/src/test_db.rs rename to crates/hir_expand/src/test_db.rs diff --git a/crates/ra_hir/Cargo.toml b/crates/ra_hir/Cargo.toml index 5ccdb74fd6..0ec1589c19 100644 --- a/crates/ra_hir/Cargo.toml +++ b/crates/ra_hir/Cargo.toml @@ -20,6 +20,6 @@ stdx = { path = "../stdx" } syntax = { path = "../syntax" } base_db = { path = "../base_db" } profile = { path = "../profile" } -hir_expand = { path = "../ra_hir_expand", package = "ra_hir_expand" } +hir_expand = { path = "../hir_expand" } hir_def = { path = "../ra_hir_def", package = "ra_hir_def" } hir_ty = { path = "../ra_hir_ty", package = "ra_hir_ty" } diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index d4d6b1759c..8ffb9e99b0 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs @@ -815,7 +815,7 @@ pub struct MacroDef { impl MacroDef { /// FIXME: right now, this just returns the root module of the crate that /// defines this macro. The reasons for this is that macros are expanded - /// early, in `ra_hir_expand`, where modules simply do not exist yet. + /// early, in `hir_expand`, where modules simply do not exist yet. pub fn module(self, db: &dyn HirDatabase) -> Option { let krate = self.id.krate?; let module_id = db.crate_def_map(krate).root; diff --git a/crates/ra_hir_def/Cargo.toml b/crates/ra_hir_def/Cargo.toml index 2b187bc4a0..f93a213dfb 100644 --- a/crates/ra_hir_def/Cargo.toml +++ b/crates/ra_hir_def/Cargo.toml @@ -21,12 +21,11 @@ indexmap = "1.4.0" smallvec = "1.4.0" stdx = { path = "../stdx" } - arena = { path = "../arena" } base_db = { path = "../base_db" } syntax = { path = "../syntax" } profile = { path = "../profile" } -hir_expand = { path = "../ra_hir_expand", package = "ra_hir_expand" } +hir_expand = { path = "../hir_expand" } test_utils = { path = "../test_utils" } mbe = { path = "../mbe" } cfg = { path = "../cfg" } diff --git a/crates/ra_hir_ty/Cargo.toml b/crates/ra_hir_ty/Cargo.toml index 720d171aca..75f04f9dd0 100644 --- a/crates/ra_hir_ty/Cargo.toml +++ b/crates/ra_hir_ty/Cargo.toml @@ -19,7 +19,7 @@ rustc-hash = "1.1.0" stdx = { path = "../stdx" } hir_def = { path = "../ra_hir_def", package = "ra_hir_def" } -hir_expand = { path = "../ra_hir_expand", package = "ra_hir_expand" } +hir_expand = { path = "../hir_expand" } arena = { path = "../arena" } base_db = { path = "../base_db" } profile = { path = "../profile" } diff --git a/xtask/tests/tidy.rs b/xtask/tests/tidy.rs index 2e68e71db2..dc367d1e03 100644 --- a/xtask/tests/tidy.rs +++ b/xtask/tests/tidy.rs @@ -193,7 +193,7 @@ impl TidyDocs { let poorly_documented = [ "ra_hir", - "ra_hir_expand", + "hir_expand", "ra_ide", "mbe", "parser", From b28c54a2c239acd73f2eea80fda9ee3960d2c046 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 16:28:27 +0200 Subject: [PATCH 098/119] Rename ra_hir_def -> hir_def --- Cargo.lock | 60 +++++++++---------- crates/{ra_hir_def => hir_def}/Cargo.toml | 8 +-- crates/{ra_hir_def => hir_def}/src/adt.rs | 0 crates/{ra_hir_def => hir_def}/src/attr.rs | 0 crates/{ra_hir_def => hir_def}/src/body.rs | 0 .../{ra_hir_def => hir_def}/src/body/lower.rs | 0 .../{ra_hir_def => hir_def}/src/body/scope.rs | 0 .../src/builtin_type.rs | 0 .../src/child_by_source.rs | 0 crates/{ra_hir_def => hir_def}/src/data.rs | 0 crates/{ra_hir_def => hir_def}/src/db.rs | 0 .../src/diagnostics.rs | 0 crates/{ra_hir_def => hir_def}/src/docs.rs | 0 crates/{ra_hir_def => hir_def}/src/dyn_map.rs | 0 crates/{ra_hir_def => hir_def}/src/expr.rs | 0 .../{ra_hir_def => hir_def}/src/find_path.rs | 0 .../{ra_hir_def => hir_def}/src/generics.rs | 0 .../{ra_hir_def => hir_def}/src/import_map.rs | 0 .../{ra_hir_def => hir_def}/src/item_scope.rs | 0 .../{ra_hir_def => hir_def}/src/item_tree.rs | 0 .../src/item_tree/lower.rs | 0 .../src/item_tree/tests.rs | 8 +-- crates/{ra_hir_def => hir_def}/src/keys.rs | 0 .../{ra_hir_def => hir_def}/src/lang_item.rs | 0 crates/{ra_hir_def => hir_def}/src/lib.rs | 0 crates/{ra_hir_def => hir_def}/src/nameres.rs | 0 .../src/nameres/collector.rs | 0 .../src/nameres/mod_resolution.rs | 0 .../src/nameres/path_resolution.rs | 0 .../src/nameres/tests.rs | 0 .../src/nameres/tests/globs.rs | 0 .../src/nameres/tests/incremental.rs | 0 .../src/nameres/tests/macros.rs | 0 .../src/nameres/tests/mod_resolution.rs | 0 .../src/nameres/tests/primitives.rs | 0 crates/{ra_hir_def => hir_def}/src/path.rs | 0 .../{ra_hir_def => hir_def}/src/path/lower.rs | 0 .../src/path/lower/lower_use.rs | 0 crates/{ra_hir_def => hir_def}/src/per_ns.rs | 0 .../{ra_hir_def => hir_def}/src/resolver.rs | 0 crates/{ra_hir_def => hir_def}/src/src.rs | 0 crates/{ra_hir_def => hir_def}/src/test_db.rs | 0 crates/{ra_hir_def => hir_def}/src/trace.rs | 0 .../{ra_hir_def => hir_def}/src/type_ref.rs | 0 .../{ra_hir_def => hir_def}/src/visibility.rs | 0 crates/ra_hir/Cargo.toml | 2 +- crates/ra_hir_ty/Cargo.toml | 2 +- crates/ra_hir_ty/src/tests/simple.rs | 4 +- crates/rust-analyzer/Cargo.toml | 2 +- .../rust-analyzer/src/diagnostics/to_proto.rs | 12 ++-- .../test_data/macro_compiler_error.txt | 4 +- 51 files changed, 51 insertions(+), 51 deletions(-) rename crates/{ra_hir_def => hir_def}/Cargo.toml (95%) rename crates/{ra_hir_def => hir_def}/src/adt.rs (100%) rename crates/{ra_hir_def => hir_def}/src/attr.rs (100%) rename crates/{ra_hir_def => hir_def}/src/body.rs (100%) rename crates/{ra_hir_def => hir_def}/src/body/lower.rs (100%) rename crates/{ra_hir_def => hir_def}/src/body/scope.rs (100%) rename crates/{ra_hir_def => hir_def}/src/builtin_type.rs (100%) rename crates/{ra_hir_def => hir_def}/src/child_by_source.rs (100%) rename crates/{ra_hir_def => hir_def}/src/data.rs (100%) rename crates/{ra_hir_def => hir_def}/src/db.rs (100%) rename crates/{ra_hir_def => hir_def}/src/diagnostics.rs (100%) rename crates/{ra_hir_def => hir_def}/src/docs.rs (100%) rename crates/{ra_hir_def => hir_def}/src/dyn_map.rs (100%) rename crates/{ra_hir_def => hir_def}/src/expr.rs (100%) rename crates/{ra_hir_def => hir_def}/src/find_path.rs (100%) rename crates/{ra_hir_def => hir_def}/src/generics.rs (100%) rename crates/{ra_hir_def => hir_def}/src/import_map.rs (100%) rename crates/{ra_hir_def => hir_def}/src/item_scope.rs (100%) rename crates/{ra_hir_def => hir_def}/src/item_tree.rs (100%) rename crates/{ra_hir_def => hir_def}/src/item_tree/lower.rs (100%) rename crates/{ra_hir_def => hir_def}/src/item_tree/tests.rs (97%) rename crates/{ra_hir_def => hir_def}/src/keys.rs (100%) rename crates/{ra_hir_def => hir_def}/src/lang_item.rs (100%) rename crates/{ra_hir_def => hir_def}/src/lib.rs (100%) rename crates/{ra_hir_def => hir_def}/src/nameres.rs (100%) rename crates/{ra_hir_def => hir_def}/src/nameres/collector.rs (100%) rename crates/{ra_hir_def => hir_def}/src/nameres/mod_resolution.rs (100%) rename crates/{ra_hir_def => hir_def}/src/nameres/path_resolution.rs (100%) rename crates/{ra_hir_def => hir_def}/src/nameres/tests.rs (100%) rename crates/{ra_hir_def => hir_def}/src/nameres/tests/globs.rs (100%) rename crates/{ra_hir_def => hir_def}/src/nameres/tests/incremental.rs (100%) rename crates/{ra_hir_def => hir_def}/src/nameres/tests/macros.rs (100%) rename crates/{ra_hir_def => hir_def}/src/nameres/tests/mod_resolution.rs (100%) rename crates/{ra_hir_def => hir_def}/src/nameres/tests/primitives.rs (100%) rename crates/{ra_hir_def => hir_def}/src/path.rs (100%) rename crates/{ra_hir_def => hir_def}/src/path/lower.rs (100%) rename crates/{ra_hir_def => hir_def}/src/path/lower/lower_use.rs (100%) rename crates/{ra_hir_def => hir_def}/src/per_ns.rs (100%) rename crates/{ra_hir_def => hir_def}/src/resolver.rs (100%) rename crates/{ra_hir_def => hir_def}/src/src.rs (100%) rename crates/{ra_hir_def => hir_def}/src/test_db.rs (100%) rename crates/{ra_hir_def => hir_def}/src/trace.rs (100%) rename crates/{ra_hir_def => hir_def}/src/type_ref.rs (100%) rename crates/{ra_hir_def => hir_def}/src/visibility.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 768c3293d5..702bd5191d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -463,6 +463,33 @@ dependencies = [ "libc", ] +[[package]] +name = "hir_def" +version = "0.0.0" +dependencies = [ + "anymap", + "arena", + "base_db", + "cfg", + "drop_bomb", + "either", + "expect", + "fst", + "hir_expand", + "indexmap", + "itertools", + "log", + "mbe", + "once_cell", + "profile", + "rustc-hash", + "smallvec", + "stdx", + "syntax", + "test_utils", + "tt", +] + [[package]] name = "hir_expand" version = "0.0.0" @@ -1034,44 +1061,17 @@ dependencies = [ "arrayvec", "base_db", "either", + "hir_def", "hir_expand", "itertools", "log", "profile", - "ra_hir_def", "ra_hir_ty", "rustc-hash", "stdx", "syntax", ] -[[package]] -name = "ra_hir_def" -version = "0.1.0" -dependencies = [ - "anymap", - "arena", - "base_db", - "cfg", - "drop_bomb", - "either", - "expect", - "fst", - "hir_expand", - "indexmap", - "itertools", - "log", - "mbe", - "once_cell", - "profile", - "rustc-hash", - "smallvec", - "stdx", - "syntax", - "test_utils", - "tt", -] - [[package]] name = "ra_hir_ty" version = "0.1.0" @@ -1084,11 +1084,11 @@ dependencies = [ "chalk-solve", "ena", "expect", + "hir_def", "hir_expand", "itertools", "log", "profile", - "ra_hir_def", "rustc-hash", "scoped-tls", "smallvec", @@ -1236,6 +1236,7 @@ dependencies = [ "env_logger", "expect", "flycheck", + "hir_def", "itertools", "jod-thread", "log", @@ -1250,7 +1251,6 @@ dependencies = [ "profile", "project_model", "ra_hir", - "ra_hir_def", "ra_hir_ty", "ra_ide", "ra_ide_db", diff --git a/crates/ra_hir_def/Cargo.toml b/crates/hir_def/Cargo.toml similarity index 95% rename from crates/ra_hir_def/Cargo.toml rename to crates/hir_def/Cargo.toml index f93a213dfb..403bc2aff3 100644 --- a/crates/ra_hir_def/Cargo.toml +++ b/crates/hir_def/Cargo.toml @@ -1,9 +1,9 @@ [package] -edition = "2018" -name = "ra_hir_def" -version = "0.1.0" -authors = ["rust-analyzer developers"] +name = "hir_def" +version = "0.0.0" license = "MIT OR Apache-2.0" +authors = ["rust-analyzer developers"] +edition = "2018" [lib] doctest = false diff --git a/crates/ra_hir_def/src/adt.rs b/crates/hir_def/src/adt.rs similarity index 100% rename from crates/ra_hir_def/src/adt.rs rename to crates/hir_def/src/adt.rs diff --git a/crates/ra_hir_def/src/attr.rs b/crates/hir_def/src/attr.rs similarity index 100% rename from crates/ra_hir_def/src/attr.rs rename to crates/hir_def/src/attr.rs diff --git a/crates/ra_hir_def/src/body.rs b/crates/hir_def/src/body.rs similarity index 100% rename from crates/ra_hir_def/src/body.rs rename to crates/hir_def/src/body.rs diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/hir_def/src/body/lower.rs similarity index 100% rename from crates/ra_hir_def/src/body/lower.rs rename to crates/hir_def/src/body/lower.rs diff --git a/crates/ra_hir_def/src/body/scope.rs b/crates/hir_def/src/body/scope.rs similarity index 100% rename from crates/ra_hir_def/src/body/scope.rs rename to crates/hir_def/src/body/scope.rs diff --git a/crates/ra_hir_def/src/builtin_type.rs b/crates/hir_def/src/builtin_type.rs similarity index 100% rename from crates/ra_hir_def/src/builtin_type.rs rename to crates/hir_def/src/builtin_type.rs diff --git a/crates/ra_hir_def/src/child_by_source.rs b/crates/hir_def/src/child_by_source.rs similarity index 100% rename from crates/ra_hir_def/src/child_by_source.rs rename to crates/hir_def/src/child_by_source.rs diff --git a/crates/ra_hir_def/src/data.rs b/crates/hir_def/src/data.rs similarity index 100% rename from crates/ra_hir_def/src/data.rs rename to crates/hir_def/src/data.rs diff --git a/crates/ra_hir_def/src/db.rs b/crates/hir_def/src/db.rs similarity index 100% rename from crates/ra_hir_def/src/db.rs rename to crates/hir_def/src/db.rs diff --git a/crates/ra_hir_def/src/diagnostics.rs b/crates/hir_def/src/diagnostics.rs similarity index 100% rename from crates/ra_hir_def/src/diagnostics.rs rename to crates/hir_def/src/diagnostics.rs diff --git a/crates/ra_hir_def/src/docs.rs b/crates/hir_def/src/docs.rs similarity index 100% rename from crates/ra_hir_def/src/docs.rs rename to crates/hir_def/src/docs.rs diff --git a/crates/ra_hir_def/src/dyn_map.rs b/crates/hir_def/src/dyn_map.rs similarity index 100% rename from crates/ra_hir_def/src/dyn_map.rs rename to crates/hir_def/src/dyn_map.rs diff --git a/crates/ra_hir_def/src/expr.rs b/crates/hir_def/src/expr.rs similarity index 100% rename from crates/ra_hir_def/src/expr.rs rename to crates/hir_def/src/expr.rs diff --git a/crates/ra_hir_def/src/find_path.rs b/crates/hir_def/src/find_path.rs similarity index 100% rename from crates/ra_hir_def/src/find_path.rs rename to crates/hir_def/src/find_path.rs diff --git a/crates/ra_hir_def/src/generics.rs b/crates/hir_def/src/generics.rs similarity index 100% rename from crates/ra_hir_def/src/generics.rs rename to crates/hir_def/src/generics.rs diff --git a/crates/ra_hir_def/src/import_map.rs b/crates/hir_def/src/import_map.rs similarity index 100% rename from crates/ra_hir_def/src/import_map.rs rename to crates/hir_def/src/import_map.rs diff --git a/crates/ra_hir_def/src/item_scope.rs b/crates/hir_def/src/item_scope.rs similarity index 100% rename from crates/ra_hir_def/src/item_scope.rs rename to crates/hir_def/src/item_scope.rs diff --git a/crates/ra_hir_def/src/item_tree.rs b/crates/hir_def/src/item_tree.rs similarity index 100% rename from crates/ra_hir_def/src/item_tree.rs rename to crates/hir_def/src/item_tree.rs diff --git a/crates/ra_hir_def/src/item_tree/lower.rs b/crates/hir_def/src/item_tree/lower.rs similarity index 100% rename from crates/ra_hir_def/src/item_tree/lower.rs rename to crates/hir_def/src/item_tree/lower.rs diff --git a/crates/ra_hir_def/src/item_tree/tests.rs b/crates/hir_def/src/item_tree/tests.rs similarity index 97% rename from crates/ra_hir_def/src/item_tree/tests.rs rename to crates/hir_def/src/item_tree/tests.rs index 2f62eddcba..9c5bf72bd5 100644 --- a/crates/ra_hir_def/src/item_tree/tests.rs +++ b/crates/hir_def/src/item_tree/tests.rs @@ -246,13 +246,13 @@ fn smoke() { #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct0"))] }, input: None }]) }] Struct { name: Name(Text("Struct0")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(1), fields: Unit, ast_id: FileAstId::(3), kind: Unit } #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct1"))] }, input: None }]) }] - Struct { name: Name(Text("Struct1")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(2), fields: Tuple(IdRange::(0..1)), ast_id: FileAstId::(4), kind: Tuple } + Struct { name: Name(Text("Struct1")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(2), fields: Tuple(IdRange::(0..1)), ast_id: FileAstId::(4), kind: Tuple } #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct2"))] }, input: None }]) }] - Struct { name: Name(Text("Struct2")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(3), fields: Record(IdRange::(1..2)), ast_id: FileAstId::(5), kind: Record } + Struct { name: Name(Text("Struct2")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(3), fields: Record(IdRange::(1..2)), ast_id: FileAstId::(5), kind: Record } #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("en"))] }, input: None }]) }] - Enum { name: Name(Text("En")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), variants: IdRange::(0..1), ast_id: FileAstId::(6) } + Enum { name: Name(Text("En")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), variants: IdRange::(0..1), ast_id: FileAstId::(6) } #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("un"))] }, input: None }]) }] - Union { name: Name(Text("Un")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), fields: Record(IdRange::(3..4)), ast_id: FileAstId::(7) } + Union { name: Name(Text("Un")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), fields: Record(IdRange::(3..4)), ast_id: FileAstId::(7) } "##]], ); } diff --git a/crates/ra_hir_def/src/keys.rs b/crates/hir_def/src/keys.rs similarity index 100% rename from crates/ra_hir_def/src/keys.rs rename to crates/hir_def/src/keys.rs diff --git a/crates/ra_hir_def/src/lang_item.rs b/crates/hir_def/src/lang_item.rs similarity index 100% rename from crates/ra_hir_def/src/lang_item.rs rename to crates/hir_def/src/lang_item.rs diff --git a/crates/ra_hir_def/src/lib.rs b/crates/hir_def/src/lib.rs similarity index 100% rename from crates/ra_hir_def/src/lib.rs rename to crates/hir_def/src/lib.rs diff --git a/crates/ra_hir_def/src/nameres.rs b/crates/hir_def/src/nameres.rs similarity index 100% rename from crates/ra_hir_def/src/nameres.rs rename to crates/hir_def/src/nameres.rs diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs similarity index 100% rename from crates/ra_hir_def/src/nameres/collector.rs rename to crates/hir_def/src/nameres/collector.rs diff --git a/crates/ra_hir_def/src/nameres/mod_resolution.rs b/crates/hir_def/src/nameres/mod_resolution.rs similarity index 100% rename from crates/ra_hir_def/src/nameres/mod_resolution.rs rename to crates/hir_def/src/nameres/mod_resolution.rs diff --git a/crates/ra_hir_def/src/nameres/path_resolution.rs b/crates/hir_def/src/nameres/path_resolution.rs similarity index 100% rename from crates/ra_hir_def/src/nameres/path_resolution.rs rename to crates/hir_def/src/nameres/path_resolution.rs diff --git a/crates/ra_hir_def/src/nameres/tests.rs b/crates/hir_def/src/nameres/tests.rs similarity index 100% rename from crates/ra_hir_def/src/nameres/tests.rs rename to crates/hir_def/src/nameres/tests.rs diff --git a/crates/ra_hir_def/src/nameres/tests/globs.rs b/crates/hir_def/src/nameres/tests/globs.rs similarity index 100% rename from crates/ra_hir_def/src/nameres/tests/globs.rs rename to crates/hir_def/src/nameres/tests/globs.rs diff --git a/crates/ra_hir_def/src/nameres/tests/incremental.rs b/crates/hir_def/src/nameres/tests/incremental.rs similarity index 100% rename from crates/ra_hir_def/src/nameres/tests/incremental.rs rename to crates/hir_def/src/nameres/tests/incremental.rs diff --git a/crates/ra_hir_def/src/nameres/tests/macros.rs b/crates/hir_def/src/nameres/tests/macros.rs similarity index 100% rename from crates/ra_hir_def/src/nameres/tests/macros.rs rename to crates/hir_def/src/nameres/tests/macros.rs diff --git a/crates/ra_hir_def/src/nameres/tests/mod_resolution.rs b/crates/hir_def/src/nameres/tests/mod_resolution.rs similarity index 100% rename from crates/ra_hir_def/src/nameres/tests/mod_resolution.rs rename to crates/hir_def/src/nameres/tests/mod_resolution.rs diff --git a/crates/ra_hir_def/src/nameres/tests/primitives.rs b/crates/hir_def/src/nameres/tests/primitives.rs similarity index 100% rename from crates/ra_hir_def/src/nameres/tests/primitives.rs rename to crates/hir_def/src/nameres/tests/primitives.rs diff --git a/crates/ra_hir_def/src/path.rs b/crates/hir_def/src/path.rs similarity index 100% rename from crates/ra_hir_def/src/path.rs rename to crates/hir_def/src/path.rs diff --git a/crates/ra_hir_def/src/path/lower.rs b/crates/hir_def/src/path/lower.rs similarity index 100% rename from crates/ra_hir_def/src/path/lower.rs rename to crates/hir_def/src/path/lower.rs diff --git a/crates/ra_hir_def/src/path/lower/lower_use.rs b/crates/hir_def/src/path/lower/lower_use.rs similarity index 100% rename from crates/ra_hir_def/src/path/lower/lower_use.rs rename to crates/hir_def/src/path/lower/lower_use.rs diff --git a/crates/ra_hir_def/src/per_ns.rs b/crates/hir_def/src/per_ns.rs similarity index 100% rename from crates/ra_hir_def/src/per_ns.rs rename to crates/hir_def/src/per_ns.rs diff --git a/crates/ra_hir_def/src/resolver.rs b/crates/hir_def/src/resolver.rs similarity index 100% rename from crates/ra_hir_def/src/resolver.rs rename to crates/hir_def/src/resolver.rs diff --git a/crates/ra_hir_def/src/src.rs b/crates/hir_def/src/src.rs similarity index 100% rename from crates/ra_hir_def/src/src.rs rename to crates/hir_def/src/src.rs diff --git a/crates/ra_hir_def/src/test_db.rs b/crates/hir_def/src/test_db.rs similarity index 100% rename from crates/ra_hir_def/src/test_db.rs rename to crates/hir_def/src/test_db.rs diff --git a/crates/ra_hir_def/src/trace.rs b/crates/hir_def/src/trace.rs similarity index 100% rename from crates/ra_hir_def/src/trace.rs rename to crates/hir_def/src/trace.rs diff --git a/crates/ra_hir_def/src/type_ref.rs b/crates/hir_def/src/type_ref.rs similarity index 100% rename from crates/ra_hir_def/src/type_ref.rs rename to crates/hir_def/src/type_ref.rs diff --git a/crates/ra_hir_def/src/visibility.rs b/crates/hir_def/src/visibility.rs similarity index 100% rename from crates/ra_hir_def/src/visibility.rs rename to crates/hir_def/src/visibility.rs diff --git a/crates/ra_hir/Cargo.toml b/crates/ra_hir/Cargo.toml index 0ec1589c19..edca5dc6f8 100644 --- a/crates/ra_hir/Cargo.toml +++ b/crates/ra_hir/Cargo.toml @@ -21,5 +21,5 @@ syntax = { path = "../syntax" } base_db = { path = "../base_db" } profile = { path = "../profile" } hir_expand = { path = "../hir_expand" } -hir_def = { path = "../ra_hir_def", package = "ra_hir_def" } +hir_def = { path = "../hir_def" } hir_ty = { path = "../ra_hir_ty", package = "ra_hir_ty" } diff --git a/crates/ra_hir_ty/Cargo.toml b/crates/ra_hir_ty/Cargo.toml index 75f04f9dd0..d430b08ca7 100644 --- a/crates/ra_hir_ty/Cargo.toml +++ b/crates/ra_hir_ty/Cargo.toml @@ -18,7 +18,7 @@ rustc-hash = "1.1.0" stdx = { path = "../stdx" } -hir_def = { path = "../ra_hir_def", package = "ra_hir_def" } +hir_def = { path = "../hir_def" } hir_expand = { path = "../hir_expand" } arena = { path = "../arena" } base_db = { path = "../base_db" } diff --git a/crates/ra_hir_ty/src/tests/simple.rs b/crates/ra_hir_ty/src/tests/simple.rs index 5a7cf9455b..59eb59d5fa 100644 --- a/crates/ra_hir_ty/src/tests/simple.rs +++ b/crates/ra_hir_ty/src/tests/simple.rs @@ -1776,8 +1776,8 @@ fn main() { ); } -// This test is actually testing the shadowing behavior within ra_hir_def. It -// lives here because the testing infrastructure in ra_hir_def isn't currently +// This test is actually testing the shadowing behavior within hir_def. It +// lives here because the testing infrastructure in hir_def isn't currently // capable of asserting the necessary conditions. #[test] fn should_be_shadowing_imports() { diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index 210d9e9c88..0dee719de5 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml @@ -50,7 +50,7 @@ base_db = { path = "../base_db" } ra_ide_db = { path = "../ra_ide_db" } ra_ssr = { path = "../ra_ssr" } hir = { path = "../ra_hir", package = "ra_hir" } -hir_def = { path = "../ra_hir_def", package = "ra_hir_def" } +hir_def = { path = "../hir_def" } hir_ty = { path = "../ra_hir_ty", package = "ra_hir_ty" } proc_macro_srv = { path = "../proc_macro_srv" } diff --git a/crates/rust-analyzer/src/diagnostics/to_proto.rs b/crates/rust-analyzer/src/diagnostics/to_proto.rs index 97f3313521..6d54081560 100644 --- a/crates/rust-analyzer/src/diagnostics/to_proto.rs +++ b/crates/rust-analyzer/src/diagnostics/to_proto.rs @@ -1116,7 +1116,7 @@ mod tests { fn macro_compiler_error() { check( r##"{ - "rendered": "error: Please register your known path in the path module\n --> crates/ra_hir_def/src/path.rs:265:9\n |\n265 | compile_error!(\"Please register your known path in the path module\")\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n | \n ::: crates/ra_hir_def/src/data.rs:80:16\n |\n80 | let path = path![std::future::Future];\n | -------------------------- in this macro invocation\n\n", + "rendered": "error: Please register your known path in the path module\n --> crates/hir_def/src/path.rs:265:9\n |\n265 | compile_error!(\"Please register your known path in the path module\")\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n | \n ::: crates/hir_def/src/data.rs:80:16\n |\n80 | let path = path![std::future::Future];\n | -------------------------- in this macro invocation\n\n", "children": [], "code": null, "level": "error", @@ -1134,7 +1134,7 @@ mod tests { "column_end": 2, "column_start": 1, "expansion": null, - "file_name": "crates/ra_hir_def/src/path.rs", + "file_name": "crates/hir_def/src/path.rs", "is_primary": false, "label": null, "line_end": 267, @@ -1227,7 +1227,7 @@ mod tests { "column_end": 2, "column_start": 1, "expansion": null, - "file_name": "crates/ra_hir_def/src/path.rs", + "file_name": "crates/hir_def/src/path.rs", "is_primary": false, "label": null, "line_end": 277, @@ -1284,7 +1284,7 @@ mod tests { "column_end": 42, "column_start": 16, "expansion": null, - "file_name": "crates/ra_hir_def/src/data.rs", + "file_name": "crates/hir_def/src/data.rs", "is_primary": false, "label": null, "line_end": 80, @@ -1300,7 +1300,7 @@ mod tests { ] } }, - "file_name": "crates/ra_hir_def/src/path.rs", + "file_name": "crates/hir_def/src/path.rs", "is_primary": false, "label": null, "line_end": 272, @@ -1316,7 +1316,7 @@ mod tests { ] } }, - "file_name": "crates/ra_hir_def/src/path.rs", + "file_name": "crates/hir_def/src/path.rs", "is_primary": true, "label": null, "line_end": 265, diff --git a/crates/rust-analyzer/test_data/macro_compiler_error.txt b/crates/rust-analyzer/test_data/macro_compiler_error.txt index f695db73ce..89dae7d5a6 100644 --- a/crates/rust-analyzer/test_data/macro_compiler_error.txt +++ b/crates/rust-analyzer/test_data/macro_compiler_error.txt @@ -1,6 +1,6 @@ [ MappedRustDiagnostic { - url: "file:///test/crates/ra_hir_def/src/data.rs", + url: "file:///test/crates/hir_def/src/data.rs", diagnostic: Diagnostic { range: Range { start: Position { @@ -24,7 +24,7 @@ [ DiagnosticRelatedInformation { location: Location { - uri: "file:///test/crates/ra_hir_def/src/path.rs", + uri: "file:///test/crates/hir_def/src/path.rs", range: Range { start: Position { line: 264, From 50f8c1ebf23f634b68529603a917e3feeda457fa Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 16:31:04 +0200 Subject: [PATCH 099/119] Somewhat fix pre-cache --- xtask/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs index 904a9ee715..807ef587ce 100644 --- a/xtask/src/lib.rs +++ b/xtask/src/lib.rs @@ -139,7 +139,7 @@ pub fn run_pre_cache() -> Result<()> { } fs2::remove_file("./target/.rustc_info.json")?; - let to_delete = ["ra_", "heavy_test", "xtask"]; + let to_delete = ["hir", "heavy_test", "xtask", "ide", "rust-analyzer"]; for &dir in ["./target/debug/deps", "target/debug/.fingerprint"].iter() { for entry in Path::new(dir).read_dir()? { let entry = entry?; From 6a77ec7bbe6ddbf663dce9529d11d1bb56c5489a Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 16:35:29 +0200 Subject: [PATCH 100/119] Rename ra_hir_ty -> hir_ty --- Cargo.lock | 60 +++++++++---------- crates/{ra_hir_ty => hir_ty}/Cargo.toml | 23 ++++--- crates/{ra_hir_ty => hir_ty}/src/autoderef.rs | 0 crates/{ra_hir_ty => hir_ty}/src/db.rs | 0 .../{ra_hir_ty => hir_ty}/src/diagnostics.rs | 0 .../src/diagnostics/expr.rs | 0 .../src/diagnostics/match_check.rs | 0 .../src/diagnostics/unsafe_check.rs | 0 crates/{ra_hir_ty => hir_ty}/src/display.rs | 0 crates/{ra_hir_ty => hir_ty}/src/infer.rs | 0 .../{ra_hir_ty => hir_ty}/src/infer/coerce.rs | 0 .../{ra_hir_ty => hir_ty}/src/infer/expr.rs | 0 crates/{ra_hir_ty => hir_ty}/src/infer/pat.rs | 0 .../{ra_hir_ty => hir_ty}/src/infer/path.rs | 0 .../{ra_hir_ty => hir_ty}/src/infer/unify.rs | 0 crates/{ra_hir_ty => hir_ty}/src/lib.rs | 0 crates/{ra_hir_ty => hir_ty}/src/lower.rs | 0 .../src/method_resolution.rs | 0 crates/{ra_hir_ty => hir_ty}/src/op.rs | 0 crates/{ra_hir_ty => hir_ty}/src/primitive.rs | 0 crates/{ra_hir_ty => hir_ty}/src/test_db.rs | 0 crates/{ra_hir_ty => hir_ty}/src/tests.rs | 2 +- .../src/tests/coercion.rs | 0 .../src/tests/display_source_code.rs | 0 .../{ra_hir_ty => hir_ty}/src/tests/macros.rs | 0 .../src/tests/method_resolution.rs | 0 .../src/tests/never_type.rs | 0 .../src/tests/patterns.rs | 0 .../src/tests/regression.rs | 0 .../{ra_hir_ty => hir_ty}/src/tests/simple.rs | 0 .../{ra_hir_ty => hir_ty}/src/tests/traits.rs | 0 crates/{ra_hir_ty => hir_ty}/src/traits.rs | 0 .../{ra_hir_ty => hir_ty}/src/traits/chalk.rs | 0 .../src/traits/chalk/interner.rs | 0 .../src/traits/chalk/mapping.rs | 0 .../src/traits/chalk/tls.rs | 0 crates/{ra_hir_ty => hir_ty}/src/utils.rs | 0 crates/ra_hir/Cargo.toml | 2 +- crates/rust-analyzer/Cargo.toml | 2 +- xtask/tests/tidy.rs | 2 +- 40 files changed, 44 insertions(+), 47 deletions(-) rename crates/{ra_hir_ty => hir_ty}/Cargo.toml (95%) rename crates/{ra_hir_ty => hir_ty}/src/autoderef.rs (100%) rename crates/{ra_hir_ty => hir_ty}/src/db.rs (100%) rename crates/{ra_hir_ty => hir_ty}/src/diagnostics.rs (100%) rename crates/{ra_hir_ty => hir_ty}/src/diagnostics/expr.rs (100%) rename crates/{ra_hir_ty => hir_ty}/src/diagnostics/match_check.rs (100%) rename crates/{ra_hir_ty => hir_ty}/src/diagnostics/unsafe_check.rs (100%) rename crates/{ra_hir_ty => hir_ty}/src/display.rs (100%) rename crates/{ra_hir_ty => hir_ty}/src/infer.rs (100%) rename crates/{ra_hir_ty => hir_ty}/src/infer/coerce.rs (100%) rename crates/{ra_hir_ty => hir_ty}/src/infer/expr.rs (100%) rename crates/{ra_hir_ty => hir_ty}/src/infer/pat.rs (100%) rename crates/{ra_hir_ty => hir_ty}/src/infer/path.rs (100%) rename crates/{ra_hir_ty => hir_ty}/src/infer/unify.rs (100%) rename crates/{ra_hir_ty => hir_ty}/src/lib.rs (100%) rename crates/{ra_hir_ty => hir_ty}/src/lower.rs (100%) rename crates/{ra_hir_ty => hir_ty}/src/method_resolution.rs (100%) rename crates/{ra_hir_ty => hir_ty}/src/op.rs (100%) rename crates/{ra_hir_ty => hir_ty}/src/primitive.rs (100%) rename crates/{ra_hir_ty => hir_ty}/src/test_db.rs (100%) rename crates/{ra_hir_ty => hir_ty}/src/tests.rs (99%) rename crates/{ra_hir_ty => hir_ty}/src/tests/coercion.rs (100%) rename crates/{ra_hir_ty => hir_ty}/src/tests/display_source_code.rs (100%) rename crates/{ra_hir_ty => hir_ty}/src/tests/macros.rs (100%) rename crates/{ra_hir_ty => hir_ty}/src/tests/method_resolution.rs (100%) rename crates/{ra_hir_ty => hir_ty}/src/tests/never_type.rs (100%) rename crates/{ra_hir_ty => hir_ty}/src/tests/patterns.rs (100%) rename crates/{ra_hir_ty => hir_ty}/src/tests/regression.rs (100%) rename crates/{ra_hir_ty => hir_ty}/src/tests/simple.rs (100%) rename crates/{ra_hir_ty => hir_ty}/src/tests/traits.rs (100%) rename crates/{ra_hir_ty => hir_ty}/src/traits.rs (100%) rename crates/{ra_hir_ty => hir_ty}/src/traits/chalk.rs (100%) rename crates/{ra_hir_ty => hir_ty}/src/traits/chalk/interner.rs (100%) rename crates/{ra_hir_ty => hir_ty}/src/traits/chalk/mapping.rs (100%) rename crates/{ra_hir_ty => hir_ty}/src/traits/chalk/tls.rs (100%) rename crates/{ra_hir_ty => hir_ty}/src/utils.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 702bd5191d..6ecea36470 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -507,6 +507,34 @@ dependencies = [ "tt", ] +[[package]] +name = "hir_ty" +version = "0.0.0" +dependencies = [ + "arena", + "arrayvec", + "base_db", + "chalk-ir", + "chalk-recursive", + "chalk-solve", + "ena", + "expect", + "hir_def", + "hir_expand", + "itertools", + "log", + "profile", + "rustc-hash", + "scoped-tls", + "smallvec", + "stdx", + "syntax", + "test_utils", + "tracing", + "tracing-subscriber", + "tracing-tree", +] + [[package]] name = "home" version = "0.5.3" @@ -1063,41 +1091,13 @@ dependencies = [ "either", "hir_def", "hir_expand", - "itertools", - "log", - "profile", - "ra_hir_ty", - "rustc-hash", - "stdx", - "syntax", -] - -[[package]] -name = "ra_hir_ty" -version = "0.1.0" -dependencies = [ - "arena", - "arrayvec", - "base_db", - "chalk-ir", - "chalk-recursive", - "chalk-solve", - "ena", - "expect", - "hir_def", - "hir_expand", + "hir_ty", "itertools", "log", "profile", "rustc-hash", - "scoped-tls", - "smallvec", "stdx", "syntax", - "test_utils", - "tracing", - "tracing-subscriber", - "tracing-tree", ] [[package]] @@ -1237,6 +1237,7 @@ dependencies = [ "expect", "flycheck", "hir_def", + "hir_ty", "itertools", "jod-thread", "log", @@ -1251,7 +1252,6 @@ dependencies = [ "profile", "project_model", "ra_hir", - "ra_hir_ty", "ra_ide", "ra_ide_db", "ra_ssr", diff --git a/crates/ra_hir_ty/Cargo.toml b/crates/hir_ty/Cargo.toml similarity index 95% rename from crates/ra_hir_ty/Cargo.toml rename to crates/hir_ty/Cargo.toml index d430b08ca7..83b5013a90 100644 --- a/crates/ra_hir_ty/Cargo.toml +++ b/crates/hir_ty/Cargo.toml @@ -1,9 +1,9 @@ [package] -edition = "2018" -name = "ra_hir_ty" -version = "0.1.0" -authors = ["rust-analyzer developers"] +name = "hir_ty" +version = "0.0.0" license = "MIT OR Apache-2.0" +authors = ["rust-analyzer developers"] +edition = "2018" [lib] doctest = false @@ -15,9 +15,12 @@ smallvec = "1.2.0" ena = "0.14.0" log = "0.4.8" rustc-hash = "1.1.0" +scoped-tls = "1" +chalk-solve = { version = "0.21.0" } +chalk-ir = { version = "0.21.0" } +chalk-recursive = { version = "0.21.0" } stdx = { path = "../stdx" } - hir_def = { path = "../hir_def" } hir_expand = { path = "../hir_expand" } arena = { path = "../arena" } @@ -26,15 +29,9 @@ profile = { path = "../profile" } syntax = { path = "../syntax" } test_utils = { path = "../test_utils" } -scoped-tls = "1" - -chalk-solve = { version = "0.21.0" } -chalk-ir = { version = "0.21.0" } -chalk-recursive = { version = "0.21.0" } - [dev-dependencies] -expect = { path = "../expect" } - tracing = "0.1" tracing-subscriber = { version = "0.2", default-features = false, features = ["env-filter", "registry"] } tracing-tree = { version = "0.1.4" } + +expect = { path = "../expect" } diff --git a/crates/ra_hir_ty/src/autoderef.rs b/crates/hir_ty/src/autoderef.rs similarity index 100% rename from crates/ra_hir_ty/src/autoderef.rs rename to crates/hir_ty/src/autoderef.rs diff --git a/crates/ra_hir_ty/src/db.rs b/crates/hir_ty/src/db.rs similarity index 100% rename from crates/ra_hir_ty/src/db.rs rename to crates/hir_ty/src/db.rs diff --git a/crates/ra_hir_ty/src/diagnostics.rs b/crates/hir_ty/src/diagnostics.rs similarity index 100% rename from crates/ra_hir_ty/src/diagnostics.rs rename to crates/hir_ty/src/diagnostics.rs diff --git a/crates/ra_hir_ty/src/diagnostics/expr.rs b/crates/hir_ty/src/diagnostics/expr.rs similarity index 100% rename from crates/ra_hir_ty/src/diagnostics/expr.rs rename to crates/hir_ty/src/diagnostics/expr.rs diff --git a/crates/ra_hir_ty/src/diagnostics/match_check.rs b/crates/hir_ty/src/diagnostics/match_check.rs similarity index 100% rename from crates/ra_hir_ty/src/diagnostics/match_check.rs rename to crates/hir_ty/src/diagnostics/match_check.rs diff --git a/crates/ra_hir_ty/src/diagnostics/unsafe_check.rs b/crates/hir_ty/src/diagnostics/unsafe_check.rs similarity index 100% rename from crates/ra_hir_ty/src/diagnostics/unsafe_check.rs rename to crates/hir_ty/src/diagnostics/unsafe_check.rs diff --git a/crates/ra_hir_ty/src/display.rs b/crates/hir_ty/src/display.rs similarity index 100% rename from crates/ra_hir_ty/src/display.rs rename to crates/hir_ty/src/display.rs diff --git a/crates/ra_hir_ty/src/infer.rs b/crates/hir_ty/src/infer.rs similarity index 100% rename from crates/ra_hir_ty/src/infer.rs rename to crates/hir_ty/src/infer.rs diff --git a/crates/ra_hir_ty/src/infer/coerce.rs b/crates/hir_ty/src/infer/coerce.rs similarity index 100% rename from crates/ra_hir_ty/src/infer/coerce.rs rename to crates/hir_ty/src/infer/coerce.rs diff --git a/crates/ra_hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs similarity index 100% rename from crates/ra_hir_ty/src/infer/expr.rs rename to crates/hir_ty/src/infer/expr.rs diff --git a/crates/ra_hir_ty/src/infer/pat.rs b/crates/hir_ty/src/infer/pat.rs similarity index 100% rename from crates/ra_hir_ty/src/infer/pat.rs rename to crates/hir_ty/src/infer/pat.rs diff --git a/crates/ra_hir_ty/src/infer/path.rs b/crates/hir_ty/src/infer/path.rs similarity index 100% rename from crates/ra_hir_ty/src/infer/path.rs rename to crates/hir_ty/src/infer/path.rs diff --git a/crates/ra_hir_ty/src/infer/unify.rs b/crates/hir_ty/src/infer/unify.rs similarity index 100% rename from crates/ra_hir_ty/src/infer/unify.rs rename to crates/hir_ty/src/infer/unify.rs diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs similarity index 100% rename from crates/ra_hir_ty/src/lib.rs rename to crates/hir_ty/src/lib.rs diff --git a/crates/ra_hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs similarity index 100% rename from crates/ra_hir_ty/src/lower.rs rename to crates/hir_ty/src/lower.rs diff --git a/crates/ra_hir_ty/src/method_resolution.rs b/crates/hir_ty/src/method_resolution.rs similarity index 100% rename from crates/ra_hir_ty/src/method_resolution.rs rename to crates/hir_ty/src/method_resolution.rs diff --git a/crates/ra_hir_ty/src/op.rs b/crates/hir_ty/src/op.rs similarity index 100% rename from crates/ra_hir_ty/src/op.rs rename to crates/hir_ty/src/op.rs diff --git a/crates/ra_hir_ty/src/primitive.rs b/crates/hir_ty/src/primitive.rs similarity index 100% rename from crates/ra_hir_ty/src/primitive.rs rename to crates/hir_ty/src/primitive.rs diff --git a/crates/ra_hir_ty/src/test_db.rs b/crates/hir_ty/src/test_db.rs similarity index 100% rename from crates/ra_hir_ty/src/test_db.rs rename to crates/hir_ty/src/test_db.rs diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/hir_ty/src/tests.rs similarity index 99% rename from crates/ra_hir_ty/src/tests.rs rename to crates/hir_ty/src/tests.rs index f6b172c3af..c953925ecb 100644 --- a/crates/ra_hir_ty/src/tests.rs +++ b/crates/hir_ty/src/tests.rs @@ -35,7 +35,7 @@ use crate::{ // These tests compare the inference results for all expressions in a file // against snapshots of the expected results using expect. Use -// `env UPDATE_EXPECT=1 cargo test -p ra_hir_ty` to update the snapshots. +// `env UPDATE_EXPECT=1 cargo test -p hir_ty` to update the snapshots. fn setup_tracing() -> tracing::subscriber::DefaultGuard { use tracing_subscriber::{layer::SubscriberExt, EnvFilter, Registry}; diff --git a/crates/ra_hir_ty/src/tests/coercion.rs b/crates/hir_ty/src/tests/coercion.rs similarity index 100% rename from crates/ra_hir_ty/src/tests/coercion.rs rename to crates/hir_ty/src/tests/coercion.rs diff --git a/crates/ra_hir_ty/src/tests/display_source_code.rs b/crates/hir_ty/src/tests/display_source_code.rs similarity index 100% rename from crates/ra_hir_ty/src/tests/display_source_code.rs rename to crates/hir_ty/src/tests/display_source_code.rs diff --git a/crates/ra_hir_ty/src/tests/macros.rs b/crates/hir_ty/src/tests/macros.rs similarity index 100% rename from crates/ra_hir_ty/src/tests/macros.rs rename to crates/hir_ty/src/tests/macros.rs diff --git a/crates/ra_hir_ty/src/tests/method_resolution.rs b/crates/hir_ty/src/tests/method_resolution.rs similarity index 100% rename from crates/ra_hir_ty/src/tests/method_resolution.rs rename to crates/hir_ty/src/tests/method_resolution.rs diff --git a/crates/ra_hir_ty/src/tests/never_type.rs b/crates/hir_ty/src/tests/never_type.rs similarity index 100% rename from crates/ra_hir_ty/src/tests/never_type.rs rename to crates/hir_ty/src/tests/never_type.rs diff --git a/crates/ra_hir_ty/src/tests/patterns.rs b/crates/hir_ty/src/tests/patterns.rs similarity index 100% rename from crates/ra_hir_ty/src/tests/patterns.rs rename to crates/hir_ty/src/tests/patterns.rs diff --git a/crates/ra_hir_ty/src/tests/regression.rs b/crates/hir_ty/src/tests/regression.rs similarity index 100% rename from crates/ra_hir_ty/src/tests/regression.rs rename to crates/hir_ty/src/tests/regression.rs diff --git a/crates/ra_hir_ty/src/tests/simple.rs b/crates/hir_ty/src/tests/simple.rs similarity index 100% rename from crates/ra_hir_ty/src/tests/simple.rs rename to crates/hir_ty/src/tests/simple.rs diff --git a/crates/ra_hir_ty/src/tests/traits.rs b/crates/hir_ty/src/tests/traits.rs similarity index 100% rename from crates/ra_hir_ty/src/tests/traits.rs rename to crates/hir_ty/src/tests/traits.rs diff --git a/crates/ra_hir_ty/src/traits.rs b/crates/hir_ty/src/traits.rs similarity index 100% rename from crates/ra_hir_ty/src/traits.rs rename to crates/hir_ty/src/traits.rs diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/hir_ty/src/traits/chalk.rs similarity index 100% rename from crates/ra_hir_ty/src/traits/chalk.rs rename to crates/hir_ty/src/traits/chalk.rs diff --git a/crates/ra_hir_ty/src/traits/chalk/interner.rs b/crates/hir_ty/src/traits/chalk/interner.rs similarity index 100% rename from crates/ra_hir_ty/src/traits/chalk/interner.rs rename to crates/hir_ty/src/traits/chalk/interner.rs diff --git a/crates/ra_hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs similarity index 100% rename from crates/ra_hir_ty/src/traits/chalk/mapping.rs rename to crates/hir_ty/src/traits/chalk/mapping.rs diff --git a/crates/ra_hir_ty/src/traits/chalk/tls.rs b/crates/hir_ty/src/traits/chalk/tls.rs similarity index 100% rename from crates/ra_hir_ty/src/traits/chalk/tls.rs rename to crates/hir_ty/src/traits/chalk/tls.rs diff --git a/crates/ra_hir_ty/src/utils.rs b/crates/hir_ty/src/utils.rs similarity index 100% rename from crates/ra_hir_ty/src/utils.rs rename to crates/hir_ty/src/utils.rs diff --git a/crates/ra_hir/Cargo.toml b/crates/ra_hir/Cargo.toml index edca5dc6f8..61cc099ac7 100644 --- a/crates/ra_hir/Cargo.toml +++ b/crates/ra_hir/Cargo.toml @@ -22,4 +22,4 @@ base_db = { path = "../base_db" } profile = { path = "../profile" } hir_expand = { path = "../hir_expand" } hir_def = { path = "../hir_def" } -hir_ty = { path = "../ra_hir_ty", package = "ra_hir_ty" } +hir_ty = { path = "../hir_ty" } diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index 0dee719de5..e17fe47dae 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml @@ -51,7 +51,7 @@ ra_ide_db = { path = "../ra_ide_db" } ra_ssr = { path = "../ra_ssr" } hir = { path = "../ra_hir", package = "ra_hir" } hir_def = { path = "../hir_def" } -hir_ty = { path = "../ra_hir_ty", package = "ra_hir_ty" } +hir_ty = { path = "../hir_ty" } proc_macro_srv = { path = "../proc_macro_srv" } [target.'cfg(windows)'.dependencies] diff --git a/xtask/tests/tidy.rs b/xtask/tests/tidy.rs index dc367d1e03..5a5bd4a3ee 100644 --- a/xtask/tests/tidy.rs +++ b/xtask/tests/tidy.rs @@ -201,7 +201,7 @@ impl TidyDocs { "project_model", "syntax", "tt", - "ra_hir_ty", + "hir_ty", ]; let mut has_fixmes = From ae71a631fd657368e8593feb5e025d23147afe60 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 16:36:55 +0200 Subject: [PATCH 101/119] Rename ra_hir -> hir --- Cargo.lock | 46 +++++++++---------- crates/{ra_hir => hir}/Cargo.toml | 9 ++-- crates/{ra_hir => hir}/src/code_model.rs | 0 crates/{ra_hir => hir}/src/db.rs | 0 crates/{ra_hir => hir}/src/diagnostics.rs | 0 crates/{ra_hir => hir}/src/from_id.rs | 0 crates/{ra_hir => hir}/src/has_source.rs | 0 crates/{ra_hir => hir}/src/lib.rs | 4 +- crates/{ra_hir => hir}/src/semantics.rs | 0 .../src/semantics/source_to_def.rs | 0 crates/{ra_hir => hir}/src/source_analyzer.rs | 0 crates/ra_assists/Cargo.toml | 2 +- crates/ra_ide/Cargo.toml | 2 +- crates/ra_ide/src/lib.rs | 2 +- crates/ra_ide_db/Cargo.toml | 2 +- crates/ra_ssr/Cargo.toml | 2 +- crates/rust-analyzer/Cargo.toml | 2 +- docs/dev/README.md | 6 +-- docs/dev/architecture.md | 6 +-- docs/dev/guide.md | 38 +++++++-------- xtask/tests/tidy.rs | 2 +- 21 files changed, 61 insertions(+), 62 deletions(-) rename crates/{ra_hir => hir}/Cargo.toml (92%) rename crates/{ra_hir => hir}/src/code_model.rs (100%) rename crates/{ra_hir => hir}/src/db.rs (100%) rename crates/{ra_hir => hir}/src/diagnostics.rs (100%) rename crates/{ra_hir => hir}/src/from_id.rs (100%) rename crates/{ra_hir => hir}/src/has_source.rs (100%) rename crates/{ra_hir => hir}/src/lib.rs (92%) rename crates/{ra_hir => hir}/src/semantics.rs (100%) rename crates/{ra_hir => hir}/src/semantics/source_to_def.rs (100%) rename crates/{ra_hir => hir}/src/source_analyzer.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 6ecea36470..ae71ea9fdb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -463,6 +463,24 @@ dependencies = [ "libc", ] +[[package]] +name = "hir" +version = "0.0.0" +dependencies = [ + "arrayvec", + "base_db", + "either", + "hir_def", + "hir_expand", + "hir_ty", + "itertools", + "log", + "profile", + "rustc-hash", + "stdx", + "syntax", +] + [[package]] name = "hir_def" version = "0.0.0" @@ -1071,9 +1089,9 @@ version = "0.1.0" dependencies = [ "base_db", "either", + "hir", "itertools", "profile", - "ra_hir", "ra_ide_db", "rustc-hash", "stdx", @@ -1082,24 +1100,6 @@ dependencies = [ "text_edit", ] -[[package]] -name = "ra_hir" -version = "0.1.0" -dependencies = [ - "arrayvec", - "base_db", - "either", - "hir_def", - "hir_expand", - "hir_ty", - "itertools", - "log", - "profile", - "rustc-hash", - "stdx", - "syntax", -] - [[package]] name = "ra_ide" version = "0.1.0" @@ -1108,13 +1108,13 @@ dependencies = [ "cfg", "either", "expect", + "hir", "indexmap", "itertools", "log", "oorandom", "profile", "ra_assists", - "ra_hir", "ra_ide_db", "ra_ssr", "rustc-hash", @@ -1131,10 +1131,10 @@ dependencies = [ "base_db", "either", "fst", + "hir", "log", "once_cell", "profile", - "ra_hir", "rayon", "rustc-hash", "stdx", @@ -1149,7 +1149,7 @@ version = "0.1.0" dependencies = [ "base_db", "expect", - "ra_hir", + "hir", "ra_ide_db", "rustc-hash", "syntax", @@ -1236,6 +1236,7 @@ dependencies = [ "env_logger", "expect", "flycheck", + "hir", "hir_def", "hir_ty", "itertools", @@ -1251,7 +1252,6 @@ dependencies = [ "proc_macro_srv", "profile", "project_model", - "ra_hir", "ra_ide", "ra_ide_db", "ra_ssr", diff --git a/crates/ra_hir/Cargo.toml b/crates/hir/Cargo.toml similarity index 92% rename from crates/ra_hir/Cargo.toml rename to crates/hir/Cargo.toml index 61cc099ac7..dbb2986b60 100644 --- a/crates/ra_hir/Cargo.toml +++ b/crates/hir/Cargo.toml @@ -1,9 +1,9 @@ [package] -edition = "2018" -name = "ra_hir" -version = "0.1.0" -authors = ["rust-analyzer developers"] +name = "hir" +version = "0.0.0" license = "MIT OR Apache-2.0" +authors = ["rust-analyzer developers"] +edition = "2018" [lib] doctest = false @@ -13,7 +13,6 @@ log = "0.4.8" rustc-hash = "1.1.0" either = "1.5.3" arrayvec = "0.5.1" - itertools = "0.9.0" stdx = { path = "../stdx" } diff --git a/crates/ra_hir/src/code_model.rs b/crates/hir/src/code_model.rs similarity index 100% rename from crates/ra_hir/src/code_model.rs rename to crates/hir/src/code_model.rs diff --git a/crates/ra_hir/src/db.rs b/crates/hir/src/db.rs similarity index 100% rename from crates/ra_hir/src/db.rs rename to crates/hir/src/db.rs diff --git a/crates/ra_hir/src/diagnostics.rs b/crates/hir/src/diagnostics.rs similarity index 100% rename from crates/ra_hir/src/diagnostics.rs rename to crates/hir/src/diagnostics.rs diff --git a/crates/ra_hir/src/from_id.rs b/crates/hir/src/from_id.rs similarity index 100% rename from crates/ra_hir/src/from_id.rs rename to crates/hir/src/from_id.rs diff --git a/crates/ra_hir/src/has_source.rs b/crates/hir/src/has_source.rs similarity index 100% rename from crates/ra_hir/src/has_source.rs rename to crates/hir/src/has_source.rs diff --git a/crates/ra_hir/src/lib.rs b/crates/hir/src/lib.rs similarity index 92% rename from crates/ra_hir/src/lib.rs rename to crates/hir/src/lib.rs index 34b02c5365..24a0f6b4b1 100644 --- a/crates/ra_hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -9,11 +9,11 @@ //! It is written in "OO" style. Each type is self contained (as in, it knows it's //! parents and full context). It should be "clean code". //! -//! `ra_hir_*` crates are the implementation of the compiler logic. +//! `hir_*` crates are the implementation of the compiler logic. //! They are written in "ECS" style, with relatively little abstractions. //! Many types are not self-contained, and explicitly use local indexes, arenas, etc. //! -//! `ra_hir` is what insulates the "we don't know how to actually write an incremental compiler" +//! `hir` is what insulates the "we don't know how to actually write an incremental compiler" //! from the ide with completions, hovers, etc. It is a (soft, internal) boundary: //! https://www.tedinski.com/2018/02/06/system-boundaries.html. diff --git a/crates/ra_hir/src/semantics.rs b/crates/hir/src/semantics.rs similarity index 100% rename from crates/ra_hir/src/semantics.rs rename to crates/hir/src/semantics.rs diff --git a/crates/ra_hir/src/semantics/source_to_def.rs b/crates/hir/src/semantics/source_to_def.rs similarity index 100% rename from crates/ra_hir/src/semantics/source_to_def.rs rename to crates/hir/src/semantics/source_to_def.rs diff --git a/crates/ra_hir/src/source_analyzer.rs b/crates/hir/src/source_analyzer.rs similarity index 100% rename from crates/ra_hir/src/source_analyzer.rs rename to crates/hir/src/source_analyzer.rs diff --git a/crates/ra_assists/Cargo.toml b/crates/ra_assists/Cargo.toml index ebac09be62..cacc063da2 100644 --- a/crates/ra_assists/Cargo.toml +++ b/crates/ra_assists/Cargo.toml @@ -20,5 +20,5 @@ text_edit = { path = "../text_edit" } profile = { path = "../profile" } base_db = { path = "../base_db" } ra_ide_db = { path = "../ra_ide_db" } -hir = { path = "../ra_hir", package = "ra_hir" } +hir = { path = "../hir" } test_utils = { path = "../test_utils" } diff --git a/crates/ra_ide/Cargo.toml b/crates/ra_ide/Cargo.toml index 1af51f3ae8..a701cdf1d5 100644 --- a/crates/ra_ide/Cargo.toml +++ b/crates/ra_ide/Cargo.toml @@ -33,7 +33,7 @@ ra_ssr = { path = "../ra_ssr" } # ra_ide should depend only on the top-level `hir` package. if you need # something from some `hir_xxx` subpackage, reexport the API via `hir`. -hir = { path = "../ra_hir", package = "ra_hir" } +hir = { path = "../hir" } [dev-dependencies] expect = { path = "../expect" } diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs index 789fbdaf23..0d14c823ae 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ra_ide/src/lib.rs @@ -3,7 +3,7 @@ //! Strings, suitable for displaying to the human. //! //! What powers this API are the `RootDatabase` struct, which defines a `salsa` -//! database, and the `ra_hir` crate, where majority of the analysis happens. +//! database, and the `hir` crate, where majority of the analysis happens. //! However, IDE specific bits of the analysis (most notably completion) happen //! in this crate. diff --git a/crates/ra_ide_db/Cargo.toml b/crates/ra_ide_db/Cargo.toml index 0cda7090d3..eda257a3a8 100644 --- a/crates/ra_ide_db/Cargo.toml +++ b/crates/ra_ide_db/Cargo.toml @@ -29,4 +29,4 @@ test_utils = { path = "../test_utils" } # ra_ide should depend only on the top-level `hir` package. if you need # something from some `hir_xxx` subpackage, reexport the API via `hir`. -hir = { path = "../ra_hir", package = "ra_hir" } +hir = { path = "../hir" } diff --git a/crates/ra_ssr/Cargo.toml b/crates/ra_ssr/Cargo.toml index f290939cfb..bed4bbdf19 100644 --- a/crates/ra_ssr/Cargo.toml +++ b/crates/ra_ssr/Cargo.toml @@ -15,7 +15,7 @@ text_edit = { path = "../text_edit" } syntax = { path = "../syntax" } base_db = { path = "../base_db" } ra_ide_db = { path = "../ra_ide_db" } -hir = { path = "../ra_hir", package = "ra_hir" } +hir = { path = "../hir" } rustc-hash = "1.1.0" test_utils = { path = "../test_utils" } diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index e17fe47dae..c0257e9c89 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml @@ -49,7 +49,7 @@ toolchain = { path = "../toolchain" } base_db = { path = "../base_db" } ra_ide_db = { path = "../ra_ide_db" } ra_ssr = { path = "../ra_ssr" } -hir = { path = "../ra_hir", package = "ra_hir" } +hir = { path = "../hir" } hir_def = { path = "../hir_def" } hir_ty = { path = "../hir_ty" } proc_macro_srv = { path = "../proc_macro_srv" } diff --git a/docs/dev/README.md b/docs/dev/README.md index 4aab6e2b86..04bebbfca5 100644 --- a/docs/dev/README.md +++ b/docs/dev/README.md @@ -148,14 +148,14 @@ Internal representations are lowered to LSP in the `rust-analyzer` crate (the on ## IDE/Compiler split -There's a semi-hard split between "compiler" and "IDE", at the `ra_hir` crate. +There's a semi-hard split between "compiler" and "IDE", at the `hir` crate. Compiler derives new facts about source code. It explicitly acknowledges that not all info is available (i.e. you can't look at types during name resolution). IDE assumes that all information is available at all times. -IDE should use only types from `ra_hir`, and should not depend on the underling compiler types. -`ra_hir` is a facade. +IDE should use only types from `hir`, and should not depend on the underling compiler types. +`hir` is a facade. ## IDE API diff --git a/docs/dev/architecture.md b/docs/dev/architecture.md index 746d41f83c..0ffe61026a 100644 --- a/docs/dev/architecture.md +++ b/docs/dev/architecture.md @@ -102,7 +102,7 @@ defines most of the "input" queries: facts supplied by the client of the analyzer. Reading the docs of the `base_db::input` module should be useful: everything else is strictly derived from those inputs. -### `crates/ra_hir*` crates +### `crates/hir*` crates HIR provides high-level "object oriented" access to Rust code. @@ -113,10 +113,10 @@ is responsible for guessing a HIR for a particular source position. Underneath, HIR works on top of salsa, using a `HirDatabase` trait. -`ra_hir_xxx` crates have a strong ECS flavor, in that they work with raw ids and +`hir_xxx` crates have a strong ECS flavor, in that they work with raw ids and directly query the database. -The top-level `ra_hir` façade crate wraps ids into a more OO-flavored API. +The top-level `hir` façade crate wraps ids into a more OO-flavored API. ### `crates/ra_ide` diff --git a/docs/dev/guide.md b/docs/dev/guide.md index d14143226b..29d84bf3f6 100644 --- a/docs/dev/guide.md +++ b/docs/dev/guide.md @@ -275,7 +275,7 @@ several times, with different sets of `cfg`s enabled. The IDE-specific task of mapping source code position into a semantic model is inherently imprecise for this reason, and is handled by the [`source_binder`]. -[`source_binder`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/source_binder.rs +[`source_binder`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/hir/src/source_binder.rs The semantic interface is declared in the [`code_model_api`] module. Each entity is identified by an integer ID and has a bunch of methods which take a salsa database @@ -283,8 +283,8 @@ as an argument and returns other entities (which are also IDs). Internally, thes methods invoke various queries on the database to build the model on demand. Here's [the list of queries]. -[`code_model_api`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/code_model_api.rs -[the list of queries]: https://github.com/rust-analyzer/rust-analyzer/blob/7e84440e25e19529e4ff8a66e521d1b06349c6ec/crates/ra_hir/src/db.rs#L20-L106 +[`code_model_api`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/hir/src/code_model_api.rs +[the list of queries]: https://github.com/rust-analyzer/rust-analyzer/blob/7e84440e25e19529e4ff8a66e521d1b06349c6ec/crates/hir/src/db.rs#L20-L106 The first step of building the model is parsing the source code. @@ -341,7 +341,7 @@ The algorithm for building a tree of modules is to start with a crate root declarations and recursively process child modules. This is handled by the [`module_tree_query`], with two slight variations. -[`module_tree_query`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/module_tree.rs#L116-L123 +[`module_tree_query`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/hir/src/module_tree.rs#L116-L123 First, rust-analyzer builds a module tree for all crates in a source root simultaneously. The main reason for this is historical (`module_tree` predates @@ -364,7 +364,7 @@ the same, we don't have to re-execute [`module_tree_query`]. In fact, we only need to re-execute it when we add/remove new files or when we change mod declarations. -[`submodules_query`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/module_tree.rs#L41 +[`submodules_query`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/hir/src/module_tree.rs#L41 We store the resulting modules in a `Vec`-based indexed arena. The indices in the arena becomes module IDs. And this brings us to the next topic: @@ -393,7 +393,7 @@ database we use includes a couple of [interners]. How to "garbage collect" unused locations is an open question. [`LocationInterner`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/base_db/src/loc2id.rs#L65-L71 -[interners]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/db.rs#L22-L23 +[interners]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/hir/src/db.rs#L22-L23 For example, we use `LocationInterner` to assign IDs to definitions of functions, structs, enums, etc. The location, [`DefLoc`] contains two bits of information: @@ -407,7 +407,7 @@ using offsets, text ranges or syntax trees as keys and values for queries. What we do instead is we store "index" of the item among all of the items of a file (so, a positional based ID, but localized to a single file). -[`DefLoc`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/ids.rs#L127-L139 +[`DefLoc`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/hir/src/ids.rs#L127-L139 One thing we've glossed over for the time being is support for macros. We have only proof of concept handling of macros at the moment, but they are extremely @@ -440,7 +440,7 @@ terms of `HirFileId`! This does not recur infinitely though: any chain of `HirFileId`s bottoms out in `HirFileId::FileId`, that is, some source file actually written by the user. -[`HirFileId`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/ids.rs#L18-L125 +[`HirFileId`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/hir/src/ids.rs#L18-L125 Now that we understand how to identify a definition, in a source or in a macro-generated file, we can discuss name resolution a bit. @@ -454,14 +454,14 @@ each module into a position-independent representation which does not change if we modify bodies of the items. After that we [loop] resolving all imports until we've reached a fixed point. -[lower]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/nameres/lower.rs#L113-L117 -[loop]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/nameres.rs#L186-L196 +[lower]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/hir/src/nameres/lower.rs#L113-L117 +[loop]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/hir/src/nameres.rs#L186-L196 And, given all our preparation with IDs and a position-independent representation, it is satisfying to [test] that typing inside function body does not invalidate name resolution results. -[test]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/nameres/tests.rs#L376 +[test]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/hir/src/nameres/tests.rs#L376 An interesting fact about name resolution is that it "erases" all of the intermediate paths from the imports: in the end, we know which items are defined @@ -496,10 +496,10 @@ there's an intermediate [projection query] which returns only the first position-independent part of the lowering. The result of this query is stable. Naturally, name resolution [uses] this stable projection query. -[imports]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/nameres/lower.rs#L52-L59 -[`SourceMap`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/nameres/lower.rs#L52-L59 -[projection query]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/nameres/lower.rs#L97-L103 -[uses]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/query_definitions.rs#L49 +[imports]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/hir/src/nameres/lower.rs#L52-L59 +[`SourceMap`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/hir/src/nameres/lower.rs#L52-L59 +[projection query]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/hir/src/nameres/lower.rs#L97-L103 +[uses]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/hir/src/query_definitions.rs#L49 ## Type inference @@ -521,10 +521,10 @@ construct a mapping from `ExprId`s to types. [@flodiebold]: https://github.com/flodiebold [#327]: https://github.com/rust-analyzer/rust-analyzer/pull/327 -[lower the AST]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/expr.rs -[positional ID]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/expr.rs#L13-L15 -[a source map]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/expr.rs#L41-L44 -[type inference]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_hir/src/ty.rs#L1208-L1223 +[lower the AST]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/hir/src/expr.rs +[positional ID]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/hir/src/expr.rs#L13-L15 +[a source map]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/hir/src/expr.rs#L41-L44 +[type inference]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/hir/src/ty.rs#L1208-L1223 ## Tying it all together: completion diff --git a/xtask/tests/tidy.rs b/xtask/tests/tidy.rs index 5a5bd4a3ee..97a11a01ee 100644 --- a/xtask/tests/tidy.rs +++ b/xtask/tests/tidy.rs @@ -192,7 +192,7 @@ impl TidyDocs { } let poorly_documented = [ - "ra_hir", + "hir", "hir_expand", "ra_ide", "mbe", From bb5c189b7dae1ea63ccd5d7a0c2e097d7c676f77 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 16:39:16 +0200 Subject: [PATCH 102/119] Rename ra_ide_db -> ide_db --- Cargo.lock | 46 +++++++++---------- crates/{ra_ide_db => ide_db}/Cargo.toml | 10 ++-- crates/{ra_ide_db => ide_db}/src/change.rs | 0 crates/{ra_ide_db => ide_db}/src/defs.rs | 0 .../src/imports_locator.rs | 0 crates/{ra_ide_db => ide_db}/src/lib.rs | 0 .../{ra_ide_db => ide_db}/src/line_index.rs | 0 crates/{ra_ide_db => ide_db}/src/search.rs | 0 .../src/source_change.rs | 0 .../{ra_ide_db => ide_db}/src/symbol_index.rs | 0 .../{ra_ide_db => ide_db}/src/wasm_shims.rs | 0 crates/ra_assists/Cargo.toml | 2 +- crates/ra_assists/src/assist_context.rs | 2 +- .../ra_assists/src/handlers/add_turbo_fish.rs | 2 +- crates/ra_assists/src/handlers/auto_import.rs | 2 +- .../src/handlers/expand_glob_import.rs | 2 +- .../extract_struct_from_enum_variant.rs | 2 +- .../src/handlers/fill_match_arms.rs | 2 +- .../handlers/generate_from_impl_for_enum.rs | 2 +- .../src/handlers/inline_local_variable.rs | 2 +- .../ra_assists/src/handlers/reorder_fields.rs | 2 +- crates/ra_assists/src/lib.rs | 2 +- crates/ra_assists/src/tests.rs | 2 +- crates/ra_assists/src/utils.rs | 2 +- crates/ra_ide/Cargo.toml | 2 +- crates/ra_ide/src/call_hierarchy.rs | 2 +- crates/ra_ide/src/call_info.rs | 2 +- crates/ra_ide/src/completion.rs | 2 +- .../src/completion/completion_context.rs | 2 +- crates/ra_ide/src/diagnostics.rs | 2 +- .../src/diagnostics/diagnostics_with_fix.rs | 2 +- .../ra_ide/src/display/navigation_target.rs | 2 +- crates/ra_ide/src/expand_macro.rs | 2 +- crates/ra_ide/src/extend_selection.rs | 2 +- crates/ra_ide/src/goto_definition.rs | 2 +- crates/ra_ide/src/goto_implementation.rs | 2 +- crates/ra_ide/src/goto_type_definition.rs | 2 +- crates/ra_ide/src/hover.rs | 4 +- crates/ra_ide/src/inlay_hints.rs | 2 +- crates/ra_ide/src/lib.rs | 6 +-- crates/ra_ide/src/parent_module.rs | 2 +- crates/ra_ide/src/references.rs | 4 +- crates/ra_ide/src/references/rename.rs | 2 +- crates/ra_ide/src/runnables.rs | 2 +- crates/ra_ide/src/ssr.rs | 2 +- crates/ra_ide/src/status.rs | 4 +- crates/ra_ide/src/syntax_highlighting.rs | 2 +- crates/ra_ide/src/syntax_tree.rs | 2 +- crates/ra_ide/src/typing.rs | 2 +- crates/ra_ide/src/typing/on_enter.rs | 2 +- crates/ra_ssr/Cargo.toml | 2 +- crates/ra_ssr/src/lib.rs | 10 ++-- crates/ra_ssr/src/matching.rs | 8 ++-- crates/ra_ssr/src/nester.rs | 10 ++-- crates/ra_ssr/src/resolving.rs | 2 +- crates/ra_ssr/src/search.rs | 4 +- crates/ra_ssr/src/tests.rs | 8 ++-- crates/rust-analyzer/Cargo.toml | 2 +- crates/rust-analyzer/src/cli/ssr.rs | 2 +- 59 files changed, 93 insertions(+), 99 deletions(-) rename crates/{ra_ide_db => ide_db}/Cargo.toml (94%) rename crates/{ra_ide_db => ide_db}/src/change.rs (100%) rename crates/{ra_ide_db => ide_db}/src/defs.rs (100%) rename crates/{ra_ide_db => ide_db}/src/imports_locator.rs (100%) rename crates/{ra_ide_db => ide_db}/src/lib.rs (100%) rename crates/{ra_ide_db => ide_db}/src/line_index.rs (100%) rename crates/{ra_ide_db => ide_db}/src/search.rs (100%) rename crates/{ra_ide_db => ide_db}/src/source_change.rs (100%) rename crates/{ra_ide_db => ide_db}/src/symbol_index.rs (100%) rename crates/{ra_ide_db => ide_db}/src/wasm_shims.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index ae71ea9fdb..8704e43860 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -562,6 +562,25 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "ide_db" +version = "0.0.0" +dependencies = [ + "base_db", + "either", + "fst", + "hir", + "log", + "once_cell", + "profile", + "rayon", + "rustc-hash", + "stdx", + "syntax", + "test_utils", + "text_edit", +] + [[package]] name = "idna" version = "0.2.0" @@ -1090,9 +1109,9 @@ dependencies = [ "base_db", "either", "hir", + "ide_db", "itertools", "profile", - "ra_ide_db", "rustc-hash", "stdx", "syntax", @@ -1109,13 +1128,13 @@ dependencies = [ "either", "expect", "hir", + "ide_db", "indexmap", "itertools", "log", "oorandom", "profile", "ra_assists", - "ra_ide_db", "ra_ssr", "rustc-hash", "stdx", @@ -1124,25 +1143,6 @@ dependencies = [ "text_edit", ] -[[package]] -name = "ra_ide_db" -version = "0.1.0" -dependencies = [ - "base_db", - "either", - "fst", - "hir", - "log", - "once_cell", - "profile", - "rayon", - "rustc-hash", - "stdx", - "syntax", - "test_utils", - "text_edit", -] - [[package]] name = "ra_ssr" version = "0.1.0" @@ -1150,7 +1150,7 @@ dependencies = [ "base_db", "expect", "hir", - "ra_ide_db", + "ide_db", "rustc-hash", "syntax", "test_utils", @@ -1239,6 +1239,7 @@ dependencies = [ "hir", "hir_def", "hir_ty", + "ide_db", "itertools", "jod-thread", "log", @@ -1253,7 +1254,6 @@ dependencies = [ "profile", "project_model", "ra_ide", - "ra_ide_db", "ra_ssr", "rayon", "rustc-hash", diff --git a/crates/ra_ide_db/Cargo.toml b/crates/ide_db/Cargo.toml similarity index 94% rename from crates/ra_ide_db/Cargo.toml rename to crates/ide_db/Cargo.toml index eda257a3a8..885212162f 100644 --- a/crates/ra_ide_db/Cargo.toml +++ b/crates/ide_db/Cargo.toml @@ -1,9 +1,9 @@ [package] -edition = "2018" -name = "ra_ide_db" -version = "0.1.0" -authors = ["rust-analyzer developers"] +name = "ide_db" +version = "0.0.0" license = "MIT OR Apache-2.0" +authors = ["rust-analyzer developers"] +edition = "2018" [lib] doctest = false @@ -20,13 +20,11 @@ once_cell = "1.3.1" either = "1.5.3" stdx = { path = "../stdx" } - syntax = { path = "../syntax" } text_edit = { path = "../text_edit" } base_db = { path = "../base_db" } profile = { path = "../profile" } test_utils = { path = "../test_utils" } - # ra_ide should depend only on the top-level `hir` package. if you need # something from some `hir_xxx` subpackage, reexport the API via `hir`. hir = { path = "../hir" } diff --git a/crates/ra_ide_db/src/change.rs b/crates/ide_db/src/change.rs similarity index 100% rename from crates/ra_ide_db/src/change.rs rename to crates/ide_db/src/change.rs diff --git a/crates/ra_ide_db/src/defs.rs b/crates/ide_db/src/defs.rs similarity index 100% rename from crates/ra_ide_db/src/defs.rs rename to crates/ide_db/src/defs.rs diff --git a/crates/ra_ide_db/src/imports_locator.rs b/crates/ide_db/src/imports_locator.rs similarity index 100% rename from crates/ra_ide_db/src/imports_locator.rs rename to crates/ide_db/src/imports_locator.rs diff --git a/crates/ra_ide_db/src/lib.rs b/crates/ide_db/src/lib.rs similarity index 100% rename from crates/ra_ide_db/src/lib.rs rename to crates/ide_db/src/lib.rs diff --git a/crates/ra_ide_db/src/line_index.rs b/crates/ide_db/src/line_index.rs similarity index 100% rename from crates/ra_ide_db/src/line_index.rs rename to crates/ide_db/src/line_index.rs diff --git a/crates/ra_ide_db/src/search.rs b/crates/ide_db/src/search.rs similarity index 100% rename from crates/ra_ide_db/src/search.rs rename to crates/ide_db/src/search.rs diff --git a/crates/ra_ide_db/src/source_change.rs b/crates/ide_db/src/source_change.rs similarity index 100% rename from crates/ra_ide_db/src/source_change.rs rename to crates/ide_db/src/source_change.rs diff --git a/crates/ra_ide_db/src/symbol_index.rs b/crates/ide_db/src/symbol_index.rs similarity index 100% rename from crates/ra_ide_db/src/symbol_index.rs rename to crates/ide_db/src/symbol_index.rs diff --git a/crates/ra_ide_db/src/wasm_shims.rs b/crates/ide_db/src/wasm_shims.rs similarity index 100% rename from crates/ra_ide_db/src/wasm_shims.rs rename to crates/ide_db/src/wasm_shims.rs diff --git a/crates/ra_assists/Cargo.toml b/crates/ra_assists/Cargo.toml index cacc063da2..19e7591f71 100644 --- a/crates/ra_assists/Cargo.toml +++ b/crates/ra_assists/Cargo.toml @@ -19,6 +19,6 @@ syntax = { path = "../syntax" } text_edit = { path = "../text_edit" } profile = { path = "../profile" } base_db = { path = "../base_db" } -ra_ide_db = { path = "../ra_ide_db" } +ide_db = { path = "../ide_db" } hir = { path = "../hir" } test_utils = { path = "../test_utils" } diff --git a/crates/ra_assists/src/assist_context.rs b/crates/ra_assists/src/assist_context.rs index 2fdce037fb..79574b9ac8 100644 --- a/crates/ra_assists/src/assist_context.rs +++ b/crates/ra_assists/src/assist_context.rs @@ -5,7 +5,7 @@ use std::mem; use algo::find_covering_element; use base_db::{FileId, FileRange}; use hir::Semantics; -use ra_ide_db::{ +use ide_db::{ source_change::{SourceChange, SourceFileEdit}, RootDatabase, }; diff --git a/crates/ra_assists/src/handlers/add_turbo_fish.rs b/crates/ra_assists/src/handlers/add_turbo_fish.rs index 8c7ffae3dd..f4f997d8e1 100644 --- a/crates/ra_assists/src/handlers/add_turbo_fish.rs +++ b/crates/ra_assists/src/handlers/add_turbo_fish.rs @@ -1,4 +1,4 @@ -use ra_ide_db::defs::{classify_name_ref, Definition, NameRefClass}; +use ide_db::defs::{classify_name_ref, Definition, NameRefClass}; use syntax::{ast, AstNode, SyntaxKind, T}; use test_utils::mark; diff --git a/crates/ra_assists/src/handlers/auto_import.rs b/crates/ra_assists/src/handlers/auto_import.rs index e19b197d9e..cce789972e 100644 --- a/crates/ra_assists/src/handlers/auto_import.rs +++ b/crates/ra_assists/src/handlers/auto_import.rs @@ -5,7 +5,7 @@ use hir::{ AsAssocItem, AssocItemContainer, ModPath, Module, ModuleDef, PathResolution, Semantics, Trait, Type, }; -use ra_ide_db::{imports_locator, RootDatabase}; +use ide_db::{imports_locator, RootDatabase}; use rustc_hash::FxHashSet; use syntax::{ ast::{self, AstNode}, diff --git a/crates/ra_assists/src/handlers/expand_glob_import.rs b/crates/ra_assists/src/handlers/expand_glob_import.rs index cf34ffaf7f..f690ec343b 100644 --- a/crates/ra_assists/src/handlers/expand_glob_import.rs +++ b/crates/ra_assists/src/handlers/expand_glob_import.rs @@ -1,5 +1,5 @@ use hir::{AssocItem, MacroDef, ModuleDef, Name, PathResolution, ScopeDef, SemanticsScope}; -use ra_ide_db::{ +use ide_db::{ defs::{classify_name_ref, Definition, NameRefClass}, RootDatabase, }; diff --git a/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs b/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs index 52fbc540eb..4bcdae7ba0 100644 --- a/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs +++ b/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs @@ -1,6 +1,6 @@ use base_db::FileId; use hir::{EnumVariant, Module, ModuleDef, Name}; -use ra_ide_db::{defs::Definition, search::Reference, RootDatabase}; +use ide_db::{defs::Definition, search::Reference, RootDatabase}; use rustc_hash::FxHashSet; use syntax::{ algo::find_node_at_offset, diff --git a/crates/ra_assists/src/handlers/fill_match_arms.rs b/crates/ra_assists/src/handlers/fill_match_arms.rs index 8f66606372..3d9bdb2bf7 100644 --- a/crates/ra_assists/src/handlers/fill_match_arms.rs +++ b/crates/ra_assists/src/handlers/fill_match_arms.rs @@ -1,8 +1,8 @@ use std::iter; use hir::{Adt, HasSource, ModuleDef, Semantics}; +use ide_db::RootDatabase; use itertools::Itertools; -use ra_ide_db::RootDatabase; use syntax::ast::{self, make, AstNode, MatchArm, NameOwner, Pat}; use test_utils::mark; diff --git a/crates/ra_assists/src/handlers/generate_from_impl_for_enum.rs b/crates/ra_assists/src/handlers/generate_from_impl_for_enum.rs index 302b6b67d4..7f04b95725 100644 --- a/crates/ra_assists/src/handlers/generate_from_impl_for_enum.rs +++ b/crates/ra_assists/src/handlers/generate_from_impl_for_enum.rs @@ -1,4 +1,4 @@ -use ra_ide_db::RootDatabase; +use ide_db::RootDatabase; use syntax::ast::{self, AstNode, NameOwner}; use test_utils::mark; diff --git a/crates/ra_assists/src/handlers/inline_local_variable.rs b/crates/ra_assists/src/handlers/inline_local_variable.rs index 5315923206..2b52b333b8 100644 --- a/crates/ra_assists/src/handlers/inline_local_variable.rs +++ b/crates/ra_assists/src/handlers/inline_local_variable.rs @@ -1,4 +1,4 @@ -use ra_ide_db::defs::Definition; +use ide_db::defs::Definition; use syntax::{ ast::{self, AstNode, AstToken}, TextRange, diff --git a/crates/ra_assists/src/handlers/reorder_fields.rs b/crates/ra_assists/src/handlers/reorder_fields.rs index 013720dfcb..527f457a79 100644 --- a/crates/ra_assists/src/handlers/reorder_fields.rs +++ b/crates/ra_assists/src/handlers/reorder_fields.rs @@ -2,7 +2,7 @@ use itertools::Itertools; use rustc_hash::FxHashMap; use hir::{Adt, ModuleDef, PathResolution, Semantics, Struct}; -use ra_ide_db::RootDatabase; +use ide_db::RootDatabase; use syntax::{algo, ast, match_ast, AstNode, SyntaxKind, SyntaxKind::*, SyntaxNode}; use crate::{AssistContext, AssistId, AssistKind, Assists}; diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs index 5d062b88b8..f0cf35caf4 100644 --- a/crates/ra_assists/src/lib.rs +++ b/crates/ra_assists/src/lib.rs @@ -19,7 +19,7 @@ pub mod ast_transform; use base_db::FileRange; use hir::Semantics; -use ra_ide_db::{source_change::SourceChange, RootDatabase}; +use ide_db::{source_change::SourceChange, RootDatabase}; use syntax::TextRange; pub(crate) use crate::assist_context::{AssistContext, Assists}; diff --git a/crates/ra_assists/src/tests.rs b/crates/ra_assists/src/tests.rs index 75d9736882..ba1fb543b8 100644 --- a/crates/ra_assists/src/tests.rs +++ b/crates/ra_assists/src/tests.rs @@ -2,7 +2,7 @@ mod generated; use base_db::{fixture::WithFixture, FileId, FileRange, SourceDatabaseExt}; use hir::Semantics; -use ra_ide_db::RootDatabase; +use ide_db::RootDatabase; use syntax::TextRange; use test_utils::{assert_eq_text, extract_offset, extract_range}; diff --git a/crates/ra_assists/src/utils.rs b/crates/ra_assists/src/utils.rs index a20453dd87..84ccacafe3 100644 --- a/crates/ra_assists/src/utils.rs +++ b/crates/ra_assists/src/utils.rs @@ -4,8 +4,8 @@ pub(crate) mod insert_use; use std::{iter, ops}; use hir::{Adt, Crate, Enum, ScopeDef, Semantics, Trait, Type}; +use ide_db::RootDatabase; use itertools::Itertools; -use ra_ide_db::RootDatabase; use rustc_hash::FxHashSet; use syntax::{ ast::{self, make, NameOwner}, diff --git a/crates/ra_ide/Cargo.toml b/crates/ra_ide/Cargo.toml index a701cdf1d5..e25aad6cfb 100644 --- a/crates/ra_ide/Cargo.toml +++ b/crates/ra_ide/Cargo.toml @@ -24,7 +24,7 @@ stdx = { path = "../stdx" } syntax = { path = "../syntax" } text_edit = { path = "../text_edit" } base_db = { path = "../base_db" } -ra_ide_db = { path = "../ra_ide_db" } +ide_db = { path = "../ide_db" } cfg = { path = "../cfg" } profile = { path = "../profile" } test_utils = { path = "../test_utils" } diff --git a/crates/ra_ide/src/call_hierarchy.rs b/crates/ra_ide/src/call_hierarchy.rs index 3578b8d3ce..58e26b94ca 100644 --- a/crates/ra_ide/src/call_hierarchy.rs +++ b/crates/ra_ide/src/call_hierarchy.rs @@ -3,7 +3,7 @@ use indexmap::IndexMap; use hir::Semantics; -use ra_ide_db::RootDatabase; +use ide_db::RootDatabase; use syntax::{ast, match_ast, AstNode, TextRange}; use crate::{ diff --git a/crates/ra_ide/src/call_info.rs b/crates/ra_ide/src/call_info.rs index 703cbc6b43..86abd2d8ce 100644 --- a/crates/ra_ide/src/call_info.rs +++ b/crates/ra_ide/src/call_info.rs @@ -1,7 +1,7 @@ //! FIXME: write short doc here use either::Either; use hir::{Docs, HirDisplay, Semantics, Type}; -use ra_ide_db::RootDatabase; +use ide_db::RootDatabase; use stdx::format_to; use syntax::{ ast::{self, ArgListOwner}, diff --git a/crates/ra_ide/src/completion.rs b/crates/ra_ide/src/completion.rs index 68ac05e4ca..7fb4d687e1 100644 --- a/crates/ra_ide/src/completion.rs +++ b/crates/ra_ide/src/completion.rs @@ -19,7 +19,7 @@ mod complete_postfix; mod complete_macro_in_item_position; mod complete_trait_impl; -use ra_ide_db::RootDatabase; +use ide_db::RootDatabase; use crate::{ completion::{ diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs index 0e0a201d09..047ecd9d77 100644 --- a/crates/ra_ide/src/completion/completion_context.rs +++ b/crates/ra_ide/src/completion/completion_context.rs @@ -2,7 +2,7 @@ use base_db::SourceDatabase; use hir::{Semantics, SemanticsScope, Type}; -use ra_ide_db::RootDatabase; +use ide_db::RootDatabase; use syntax::{ algo::{find_covering_element, find_node_at_offset}, ast, match_ast, AstNode, NodeOrToken, diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs index 4e59e3a480..a3ec98178a 100644 --- a/crates/ra_ide/src/diagnostics.rs +++ b/crates/ra_ide/src/diagnostics.rs @@ -8,8 +8,8 @@ use std::cell::RefCell; use base_db::SourceDatabase; use hir::{diagnostics::DiagnosticSinkBuilder, Semantics}; +use ide_db::RootDatabase; use itertools::Itertools; -use ra_ide_db::RootDatabase; use syntax::{ ast::{self, AstNode}, SyntaxNode, TextRange, T, diff --git a/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs b/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs index 7e126d7a6a..85b46c9958 100644 --- a/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs +++ b/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs @@ -8,7 +8,7 @@ use hir::{ diagnostics::{Diagnostic, MissingFields, MissingOkInTailExpr, NoSuchField, UnresolvedModule}, HasSource, HirDisplay, Semantics, VariantDef, }; -use ra_ide_db::{ +use ide_db::{ source_change::{FileSystemEdit, SourceFileEdit}, RootDatabase, }; diff --git a/crates/ra_ide/src/display/navigation_target.rs b/crates/ra_ide/src/display/navigation_target.rs index 09ec3f65e6..e771061772 100644 --- a/crates/ra_ide/src/display/navigation_target.rs +++ b/crates/ra_ide/src/display/navigation_target.rs @@ -3,7 +3,7 @@ use base_db::{FileId, SourceDatabase}; use either::Either; use hir::{original_range, AssocItem, FieldSource, HasSource, InFile, ModuleSource}; -use ra_ide_db::{defs::Definition, RootDatabase}; +use ide_db::{defs::Definition, RootDatabase}; use syntax::{ ast::{self, DocCommentsOwner, NameOwner}, match_ast, AstNode, SmolStr, diff --git a/crates/ra_ide/src/expand_macro.rs b/crates/ra_ide/src/expand_macro.rs index c25e068d60..31455709d7 100644 --- a/crates/ra_ide/src/expand_macro.rs +++ b/crates/ra_ide/src/expand_macro.rs @@ -1,5 +1,5 @@ use hir::Semantics; -use ra_ide_db::RootDatabase; +use ide_db::RootDatabase; use syntax::{ algo::{find_node_at_offset, SyntaxRewriter}, ast, AstNode, NodeOrToken, SyntaxKind, diff --git a/crates/ra_ide/src/extend_selection.rs b/crates/ra_ide/src/extend_selection.rs index f30df2bff4..34563a0267 100644 --- a/crates/ra_ide/src/extend_selection.rs +++ b/crates/ra_ide/src/extend_selection.rs @@ -1,7 +1,7 @@ use std::iter::successors; use hir::Semantics; -use ra_ide_db::RootDatabase; +use ide_db::RootDatabase; use syntax::{ algo::{self, find_covering_element, skip_trivia_token}, ast::{self, AstNode, AstToken}, diff --git a/crates/ra_ide/src/goto_definition.rs b/crates/ra_ide/src/goto_definition.rs index b93d116bf8..15e9b7fad8 100644 --- a/crates/ra_ide/src/goto_definition.rs +++ b/crates/ra_ide/src/goto_definition.rs @@ -1,5 +1,5 @@ use hir::Semantics; -use ra_ide_db::{ +use ide_db::{ defs::{classify_name, classify_name_ref}, symbol_index, RootDatabase, }; diff --git a/crates/ra_ide/src/goto_implementation.rs b/crates/ra_ide/src/goto_implementation.rs index 6dc2ccfd05..f503f4ec5f 100644 --- a/crates/ra_ide/src/goto_implementation.rs +++ b/crates/ra_ide/src/goto_implementation.rs @@ -1,5 +1,5 @@ use hir::{Crate, ImplDef, Semantics}; -use ra_ide_db::RootDatabase; +use ide_db::RootDatabase; use syntax::{algo::find_node_at_offset, ast, AstNode}; use crate::{display::ToNav, FilePosition, NavigationTarget, RangeInfo}; diff --git a/crates/ra_ide/src/goto_type_definition.rs b/crates/ra_ide/src/goto_type_definition.rs index 8017ca58cb..4a151b1506 100644 --- a/crates/ra_ide/src/goto_type_definition.rs +++ b/crates/ra_ide/src/goto_type_definition.rs @@ -1,4 +1,4 @@ -use ra_ide_db::RootDatabase; +use ide_db::RootDatabase; use syntax::{ast, match_ast, AstNode, SyntaxKind::*, SyntaxToken, TokenAtOffset, T}; use crate::{display::ToNav, FilePosition, NavigationTarget, RangeInfo}; diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs index a74087f87a..331aa4db0c 100644 --- a/crates/ra_ide/src/hover.rs +++ b/crates/ra_ide/src/hover.rs @@ -3,11 +3,11 @@ use hir::{ Adt, AsAssocItem, AssocItemContainer, Documentation, FieldSource, HasSource, HirDisplay, Module, ModuleDef, ModuleSource, Semantics, }; -use itertools::Itertools; -use ra_ide_db::{ +use ide_db::{ defs::{classify_name, classify_name_ref, Definition}, RootDatabase, }; +use itertools::Itertools; use stdx::format_to; use syntax::{ast, match_ast, AstNode, SyntaxKind::*, SyntaxToken, TokenAtOffset, T}; use test_utils::mark; diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs index 81fe274adf..002adf9159 100644 --- a/crates/ra_ide/src/inlay_hints.rs +++ b/crates/ra_ide/src/inlay_hints.rs @@ -1,5 +1,5 @@ use hir::{Adt, Callable, HirDisplay, Semantics, Type}; -use ra_ide_db::RootDatabase; +use ide_db::RootDatabase; use stdx::to_lower_snake_case; use syntax::{ ast::{self, ArgListOwner, AstNode}, diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs index 0d14c823ae..66a234fff7 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ra_ide/src/lib.rs @@ -52,7 +52,7 @@ use base_db::{ CheckCanceled, Env, FileLoader, FileSet, SourceDatabase, VfsPath, }; use cfg::CfgOptions; -use ra_ide_db::{ +use ide_db::{ symbol_index::{self, FileSymbol}, LineIndexDatabase, }; @@ -86,8 +86,7 @@ pub use base_db::{ SourceRootId, }; pub use hir::{Documentation, Semantics}; -pub use ra_assists::{Assist, AssistConfig, AssistId, AssistKind, ResolvedAssist}; -pub use ra_ide_db::{ +pub use ide_db::{ change::AnalysisChange, line_index::{LineCol, LineIndex}, search::SearchScope, @@ -95,6 +94,7 @@ pub use ra_ide_db::{ symbol_index::Query, RootDatabase, }; +pub use ra_assists::{Assist, AssistConfig, AssistId, AssistKind, ResolvedAssist}; pub use ra_ssr::SsrError; pub use text_edit::{Indel, TextEdit}; diff --git a/crates/ra_ide/src/parent_module.rs b/crates/ra_ide/src/parent_module.rs index 8439e1d5d3..59ed2967cf 100644 --- a/crates/ra_ide/src/parent_module.rs +++ b/crates/ra_ide/src/parent_module.rs @@ -1,6 +1,6 @@ use base_db::{CrateId, FileId, FilePosition}; use hir::Semantics; -use ra_ide_db::RootDatabase; +use ide_db::RootDatabase; use syntax::{ algo::find_node_at_offset, ast::{self, AstNode}, diff --git a/crates/ra_ide/src/references.rs b/crates/ra_ide/src/references.rs index e89dca869c..0a76ec6b43 100644 --- a/crates/ra_ide/src/references.rs +++ b/crates/ra_ide/src/references.rs @@ -12,7 +12,7 @@ mod rename; use hir::Semantics; -use ra_ide_db::{ +use ide_db::{ defs::{classify_name, classify_name_ref, Definition}, search::SearchScope, RootDatabase, @@ -27,7 +27,7 @@ use crate::{display::TryToNav, FilePosition, FileRange, NavigationTarget, RangeI pub(crate) use self::rename::rename; -pub use ra_ide_db::search::{Reference, ReferenceAccess, ReferenceKind}; +pub use ide_db::search::{Reference, ReferenceAccess, ReferenceKind}; #[derive(Debug, Clone)] pub struct ReferenceSearchResult { diff --git a/crates/ra_ide/src/references/rename.rs b/crates/ra_ide/src/references/rename.rs index 5697b9d879..d73dc9cd00 100644 --- a/crates/ra_ide/src/references/rename.rs +++ b/crates/ra_ide/src/references/rename.rs @@ -2,7 +2,7 @@ use base_db::SourceDatabaseExt; use hir::{Module, ModuleDef, ModuleSource, Semantics}; -use ra_ide_db::{ +use ide_db::{ defs::{classify_name, classify_name_ref, Definition, NameClass, NameRefClass}, RootDatabase, }; diff --git a/crates/ra_ide/src/runnables.rs b/crates/ra_ide/src/runnables.rs index fb40762cfb..c3e07c8dec 100644 --- a/crates/ra_ide/src/runnables.rs +++ b/crates/ra_ide/src/runnables.rs @@ -2,8 +2,8 @@ use std::fmt; use cfg::CfgExpr; use hir::{AsAssocItem, Attrs, HirFileId, InFile, Semantics}; +use ide_db::RootDatabase; use itertools::Itertools; -use ra_ide_db::RootDatabase; use syntax::{ ast::{self, AstNode, AttrsOwner, DocCommentsOwner, ModuleItemOwner, NameOwner}, match_ast, SyntaxNode, diff --git a/crates/ra_ide/src/ssr.rs b/crates/ra_ide/src/ssr.rs index 97b82b70e5..a8a7041923 100644 --- a/crates/ra_ide/src/ssr.rs +++ b/crates/ra_ide/src/ssr.rs @@ -1,5 +1,5 @@ use base_db::{FilePosition, FileRange}; -use ra_ide_db::RootDatabase; +use ide_db::RootDatabase; use crate::SourceFileEdit; use ra_ssr::{MatchFinder, SsrError, SsrRule}; diff --git a/crates/ra_ide/src/status.rs b/crates/ra_ide/src/status.rs index 869c74accc..c237081818 100644 --- a/crates/ra_ide/src/status.rs +++ b/crates/ra_ide/src/status.rs @@ -5,11 +5,11 @@ use base_db::{ FileTextQuery, SourceRootId, }; use hir::MacroFile; -use profile::{memory_usage, Bytes}; -use ra_ide_db::{ +use ide_db::{ symbol_index::{LibrarySymbolsQuery, SymbolIndex}, RootDatabase, }; +use profile::{memory_usage, Bytes}; use rustc_hash::FxHashMap; use syntax::{ast, Parse, SyntaxNode}; diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index 4b41ceb1dc..5d7c7e8d02 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -5,7 +5,7 @@ mod injection; mod tests; use hir::{Name, Semantics, VariantDef}; -use ra_ide_db::{ +use ide_db::{ defs::{classify_name, classify_name_ref, Definition, NameClass, NameRefClass}, RootDatabase, }; diff --git a/crates/ra_ide/src/syntax_tree.rs b/crates/ra_ide/src/syntax_tree.rs index 17daf06b66..f800449596 100644 --- a/crates/ra_ide/src/syntax_tree.rs +++ b/crates/ra_ide/src/syntax_tree.rs @@ -1,5 +1,5 @@ use base_db::{FileId, SourceDatabase}; -use ra_ide_db::RootDatabase; +use ide_db::RootDatabase; use syntax::{ algo, AstNode, NodeOrToken, SourceFile, SyntaxKind::{RAW_STRING, STRING}, diff --git a/crates/ra_ide/src/typing.rs b/crates/ra_ide/src/typing.rs index 75f2a6b605..899ce5f265 100644 --- a/crates/ra_ide/src/typing.rs +++ b/crates/ra_ide/src/typing.rs @@ -16,7 +16,7 @@ mod on_enter; use base_db::{FilePosition, SourceDatabase}; -use ra_ide_db::{source_change::SourceFileEdit, RootDatabase}; +use ide_db::{source_change::SourceFileEdit, RootDatabase}; use syntax::{ algo::find_node_at_offset, ast::{self, edit::IndentLevel, AstToken}, diff --git a/crates/ra_ide/src/typing/on_enter.rs b/crates/ra_ide/src/typing/on_enter.rs index 1939306590..f7d46146c5 100644 --- a/crates/ra_ide/src/typing/on_enter.rs +++ b/crates/ra_ide/src/typing/on_enter.rs @@ -2,7 +2,7 @@ //! comments, but should handle indent some time in the future as well. use base_db::{FilePosition, SourceDatabase}; -use ra_ide_db::RootDatabase; +use ide_db::RootDatabase; use syntax::{ ast::{self, AstToken}, AstNode, SmolStr, SourceFile, diff --git a/crates/ra_ssr/Cargo.toml b/crates/ra_ssr/Cargo.toml index bed4bbdf19..4d22a8a982 100644 --- a/crates/ra_ssr/Cargo.toml +++ b/crates/ra_ssr/Cargo.toml @@ -14,7 +14,7 @@ doctest = false text_edit = { path = "../text_edit" } syntax = { path = "../syntax" } base_db = { path = "../base_db" } -ra_ide_db = { path = "../ra_ide_db" } +ide_db = { path = "../ide_db" } hir = { path = "../hir" } rustc-hash = "1.1.0" test_utils = { path = "../test_utils" } diff --git a/crates/ra_ssr/src/lib.rs b/crates/ra_ssr/src/lib.rs index 6725582e49..b4e35107ed 100644 --- a/crates/ra_ssr/src/lib.rs +++ b/crates/ra_ssr/src/lib.rs @@ -20,7 +20,7 @@ pub use crate::matching::Match; use crate::matching::MatchFailureReason; use base_db::{FileId, FilePosition, FileRange}; use hir::Semantics; -use ra_ide_db::source_change::SourceFileEdit; +use ide_db::source_change::SourceFileEdit; use resolving::ResolvedRule; use rustc_hash::FxHashMap; use syntax::{ast, AstNode, SyntaxNode, TextRange}; @@ -49,7 +49,7 @@ pub struct SsrMatches { /// Searches a crate for pattern matches and possibly replaces them with something else. pub struct MatchFinder<'db> { /// Our source of information about the user's code. - sema: Semantics<'db, ra_ide_db::RootDatabase>, + sema: Semantics<'db, ide_db::RootDatabase>, rules: Vec, resolution_scope: resolving::ResolutionScope<'db>, restrict_ranges: Vec, @@ -59,7 +59,7 @@ impl<'db> MatchFinder<'db> { /// Constructs a new instance where names will be looked up as if they appeared at /// `lookup_context`. pub fn in_context( - db: &'db ra_ide_db::RootDatabase, + db: &'db ide_db::RootDatabase, lookup_context: FilePosition, mut restrict_ranges: Vec, ) -> MatchFinder<'db> { @@ -70,9 +70,9 @@ impl<'db> MatchFinder<'db> { } /// Constructs an instance using the start of the first file in `db` as the lookup context. - pub fn at_first_file(db: &'db ra_ide_db::RootDatabase) -> Result, SsrError> { + pub fn at_first_file(db: &'db ide_db::RootDatabase) -> Result, SsrError> { use base_db::SourceDatabaseExt; - use ra_ide_db::symbol_index::SymbolsDatabase; + use ide_db::symbol_index::SymbolsDatabase; if let Some(first_file_id) = db .local_roots() .iter() diff --git a/crates/ra_ssr/src/matching.rs b/crates/ra_ssr/src/matching.rs index e81a87c471..ffc7202ae5 100644 --- a/crates/ra_ssr/src/matching.rs +++ b/crates/ra_ssr/src/matching.rs @@ -92,7 +92,7 @@ pub(crate) fn get_match( rule: &ResolvedRule, code: &SyntaxNode, restrict_range: &Option, - sema: &Semantics, + sema: &Semantics, ) -> Result { record_match_fails_reasons_scope(debug_active, || { Matcher::try_match(rule, code, restrict_range, sema) @@ -101,7 +101,7 @@ pub(crate) fn get_match( /// Checks if our search pattern matches a particular node of the AST. struct Matcher<'db, 'sema> { - sema: &'sema Semantics<'db, ra_ide_db::RootDatabase>, + sema: &'sema Semantics<'db, ide_db::RootDatabase>, /// If any placeholders come from anywhere outside of this range, then the match will be /// rejected. restrict_range: Option, @@ -123,7 +123,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> { rule: &ResolvedRule, code: &SyntaxNode, restrict_range: &Option, - sema: &'sema Semantics<'db, ra_ide_db::RootDatabase>, + sema: &'sema Semantics<'db, ide_db::RootDatabase>, ) -> Result { let match_state = Matcher { sema, restrict_range: restrict_range.clone(), rule }; // First pass at matching, where we check that node types and idents match. @@ -606,7 +606,7 @@ impl Match { fn render_template_paths( &mut self, template: &ResolvedPattern, - sema: &Semantics, + sema: &Semantics, ) -> Result<(), MatchFailed> { let module = sema .scope(&self.matched_node) diff --git a/crates/ra_ssr/src/nester.rs b/crates/ra_ssr/src/nester.rs index 8be570d3cf..6ac355dfc2 100644 --- a/crates/ra_ssr/src/nester.rs +++ b/crates/ra_ssr/src/nester.rs @@ -13,7 +13,7 @@ use syntax::SyntaxNode; pub(crate) fn nest_and_remove_collisions( mut matches: Vec, - sema: &hir::Semantics, + sema: &hir::Semantics, ) -> SsrMatches { // We sort the matches by depth then by rule index. Sorting by depth means that by the time we // see a match, any parent matches or conflicting matches will have already been seen. Sorting @@ -36,7 +36,7 @@ impl MatchCollector { /// Attempts to add `m` to matches. If it conflicts with an existing match, it is discarded. If /// it is entirely within the a placeholder of an existing match, then it is added as a child /// match of the existing match. - fn add_match(&mut self, m: Match, sema: &hir::Semantics) { + fn add_match(&mut self, m: Match, sema: &hir::Semantics) { let matched_node = m.matched_node.clone(); if let Some(existing) = self.matches_by_node.get_mut(&matched_node) { try_add_sub_match(m, existing, sema); @@ -53,11 +53,7 @@ impl MatchCollector { } /// Attempts to add `m` as a sub-match of `existing`. -fn try_add_sub_match( - m: Match, - existing: &mut Match, - sema: &hir::Semantics, -) { +fn try_add_sub_match(m: Match, existing: &mut Match, sema: &hir::Semantics) { for p in existing.placeholder_values.values_mut() { // Note, no need to check if p.range.file is equal to m.range.file, since we // already know we're within `existing`. diff --git a/crates/ra_ssr/src/resolving.rs b/crates/ra_ssr/src/resolving.rs index dac09bae80..020fd79941 100644 --- a/crates/ra_ssr/src/resolving.rs +++ b/crates/ra_ssr/src/resolving.rs @@ -187,7 +187,7 @@ impl Resolver<'_, '_> { impl<'db> ResolutionScope<'db> { pub(crate) fn new( - sema: &hir::Semantics<'db, ra_ide_db::RootDatabase>, + sema: &hir::Semantics<'db, ide_db::RootDatabase>, resolve_context: FilePosition, ) -> ResolutionScope<'db> { use syntax::ast::AstNode; diff --git a/crates/ra_ssr/src/search.rs b/crates/ra_ssr/src/search.rs index 434953fb48..8509cfa4de 100644 --- a/crates/ra_ssr/src/search.rs +++ b/crates/ra_ssr/src/search.rs @@ -6,7 +6,7 @@ use crate::{ Match, MatchFinder, }; use base_db::{FileId, FileRange}; -use ra_ide_db::{ +use ide_db::{ defs::Definition, search::{Reference, SearchScope}, }; @@ -146,7 +146,7 @@ impl<'db> MatchFinder<'db> { if self.restrict_ranges.is_empty() { // Unrestricted search. use base_db::SourceDatabaseExt; - use ra_ide_db::symbol_index::SymbolsDatabase; + use ide_db::symbol_index::SymbolsDatabase; for &root in self.sema.db.local_roots().iter() { let sr = self.sema.db.source_root(root); for file_id in sr.iter() { diff --git a/crates/ra_ssr/src/tests.rs b/crates/ra_ssr/src/tests.rs index 54c3da9db3..0d0a000906 100644 --- a/crates/ra_ssr/src/tests.rs +++ b/crates/ra_ssr/src/tests.rs @@ -61,13 +61,13 @@ fn parser_undefined_placeholder_in_replacement() { /// `code` may optionally contain a cursor marker `<|>`. If it doesn't, then the position will be /// the start of the file. If there's a second cursor marker, then we'll return a single range. -pub(crate) fn single_file(code: &str) -> (ra_ide_db::RootDatabase, FilePosition, Vec) { +pub(crate) fn single_file(code: &str) -> (ide_db::RootDatabase, FilePosition, Vec) { use base_db::fixture::WithFixture; - use ra_ide_db::symbol_index::SymbolsDatabase; + use ide_db::symbol_index::SymbolsDatabase; let (mut db, file_id, range_or_offset) = if code.contains(test_utils::CURSOR_MARKER) { - ra_ide_db::RootDatabase::with_range_or_offset(code) + ide_db::RootDatabase::with_range_or_offset(code) } else { - let (db, file_id) = ra_ide_db::RootDatabase::with_single_file(code); + let (db, file_id) = ide_db::RootDatabase::with_single_file(code); (db, file_id, RangeOrOffset::Offset(0.into())) }; let selections; diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index c0257e9c89..da8c09c09a 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml @@ -47,7 +47,7 @@ toolchain = { path = "../toolchain" } # This should only be used in CLI base_db = { path = "../base_db" } -ra_ide_db = { path = "../ra_ide_db" } +ide_db = { path = "../ide_db" } ra_ssr = { path = "../ra_ssr" } hir = { path = "../hir" } hir_def = { path = "../hir_def" } diff --git a/crates/rust-analyzer/src/cli/ssr.rs b/crates/rust-analyzer/src/cli/ssr.rs index 08788fb415..1357a93e16 100644 --- a/crates/rust-analyzer/src/cli/ssr.rs +++ b/crates/rust-analyzer/src/cli/ssr.rs @@ -27,7 +27,7 @@ pub fn apply_ssr_rules(rules: Vec) -> Result<()> { /// for much else. pub fn search_for_patterns(patterns: Vec, debug_snippet: Option) -> Result<()> { use base_db::SourceDatabaseExt; - use ra_ide_db::symbol_index::SymbolsDatabase; + use ide_db::symbol_index::SymbolsDatabase; let (host, _vfs) = load_cargo(&std::env::current_dir()?, true, true)?; let db = host.raw_database(); let mut match_finder = MatchFinder::at_first_file(db)?; From ae3abd6e575940eb1221acf26c09e96352f052fa Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 16:45:10 +0200 Subject: [PATCH 103/119] Rename ra_ssr -> ssr --- Cargo.lock | 32 +++++------ crates/ra_ide/Cargo.toml | 2 +- crates/ra_ide/src/lib.rs | 18 ++++--- crates/ra_ide/src/ssr.rs | 72 ------------------------- crates/rust-analyzer/Cargo.toml | 2 +- crates/rust-analyzer/src/bin/args.rs | 2 +- crates/rust-analyzer/src/cli.rs | 12 +++-- crates/rust-analyzer/src/cli/ssr.rs | 2 +- crates/{ra_ssr => ssr}/Cargo.toml | 11 ++-- crates/{ra_ssr => ssr}/src/errors.rs | 0 crates/{ra_ssr => ssr}/src/lib.rs | 52 ++++++++++++++++++ crates/{ra_ssr => ssr}/src/matching.rs | 0 crates/{ra_ssr => ssr}/src/nester.rs | 0 crates/{ra_ssr => ssr}/src/parsing.rs | 0 crates/{ra_ssr => ssr}/src/replacing.rs | 0 crates/{ra_ssr => ssr}/src/resolving.rs | 0 crates/{ra_ssr => ssr}/src/search.rs | 0 crates/{ra_ssr => ssr}/src/tests.rs | 0 18 files changed, 95 insertions(+), 110 deletions(-) delete mode 100644 crates/ra_ide/src/ssr.rs rename crates/{ra_ssr => ssr}/Cargo.toml (97%) rename crates/{ra_ssr => ssr}/src/errors.rs (100%) rename crates/{ra_ssr => ssr}/src/lib.rs (82%) rename crates/{ra_ssr => ssr}/src/matching.rs (100%) rename crates/{ra_ssr => ssr}/src/nester.rs (100%) rename crates/{ra_ssr => ssr}/src/parsing.rs (100%) rename crates/{ra_ssr => ssr}/src/replacing.rs (100%) rename crates/{ra_ssr => ssr}/src/resolving.rs (100%) rename crates/{ra_ssr => ssr}/src/search.rs (100%) rename crates/{ra_ssr => ssr}/src/tests.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 8704e43860..4d8b748392 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1135,28 +1135,14 @@ dependencies = [ "oorandom", "profile", "ra_assists", - "ra_ssr", "rustc-hash", + "ssr", "stdx", "syntax", "test_utils", "text_edit", ] -[[package]] -name = "ra_ssr" -version = "0.1.0" -dependencies = [ - "base_db", - "expect", - "hir", - "ide_db", - "rustc-hash", - "syntax", - "test_utils", - "text_edit", -] - [[package]] name = "rayon" version = "1.3.1" @@ -1254,11 +1240,11 @@ dependencies = [ "profile", "project_model", "ra_ide", - "ra_ssr", "rayon", "rustc-hash", "serde", "serde_json", + "ssr", "stdx", "syntax", "test_utils", @@ -1456,6 +1442,20 @@ dependencies = [ "serde", ] +[[package]] +name = "ssr" +version = "0.1.0" +dependencies = [ + "base_db", + "expect", + "hir", + "ide_db", + "rustc-hash", + "syntax", + "test_utils", + "text_edit", +] + [[package]] name = "stdx" version = "0.1.0" diff --git a/crates/ra_ide/Cargo.toml b/crates/ra_ide/Cargo.toml index e25aad6cfb..8519e9ccae 100644 --- a/crates/ra_ide/Cargo.toml +++ b/crates/ra_ide/Cargo.toml @@ -29,7 +29,7 @@ cfg = { path = "../cfg" } profile = { path = "../profile" } test_utils = { path = "../test_utils" } ra_assists = { path = "../ra_assists" } -ra_ssr = { path = "../ra_ssr" } +ssr = { path = "../ssr" } # ra_ide should depend only on the top-level `hir` package. if you need # something from some `hir_xxx` subpackage, reexport the API via `hir`. diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs index 66a234fff7..bbc9e4b8af 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ra_ide/src/lib.rs @@ -39,7 +39,6 @@ mod matching_brace; mod parent_module; mod references; mod runnables; -mod ssr; mod status; mod syntax_highlighting; mod syntax_tree; @@ -95,7 +94,7 @@ pub use ide_db::{ RootDatabase, }; pub use ra_assists::{Assist, AssistConfig, AssistId, AssistKind, ResolvedAssist}; -pub use ra_ssr::SsrError; +pub use ssr::SsrError; pub use text_edit::{Indel, TextEdit}; pub type Cancelable = Result; @@ -515,20 +514,23 @@ impl Analysis { &self, query: &str, parse_only: bool, - position: FilePosition, + resolve_context: FilePosition, selections: Vec, ) -> Cancelable> { self.with_db(|db| { - let edits = ssr::parse_search_replace(query, parse_only, db, position, selections)?; + let rule: ssr::SsrRule = query.parse()?; + let mut match_finder = ssr::MatchFinder::in_context(db, resolve_context, selections); + match_finder.add_rule(rule)?; + let edits = if parse_only { Vec::new() } else { match_finder.edits() }; Ok(SourceChange::from(edits)) }) } /// Performs an operation on that may be Canceled. - fn with_db T + std::panic::UnwindSafe, T>( - &self, - f: F, - ) -> Cancelable { + fn with_db(&self, f: F) -> Cancelable + where + F: FnOnce(&RootDatabase) -> T + std::panic::UnwindSafe, + { self.db.catch_canceled(f) } } diff --git a/crates/ra_ide/src/ssr.rs b/crates/ra_ide/src/ssr.rs deleted file mode 100644 index a8a7041923..0000000000 --- a/crates/ra_ide/src/ssr.rs +++ /dev/null @@ -1,72 +0,0 @@ -use base_db::{FilePosition, FileRange}; -use ide_db::RootDatabase; - -use crate::SourceFileEdit; -use ra_ssr::{MatchFinder, SsrError, SsrRule}; - -// Feature: Structural Search and Replace -// -// Search and replace with named wildcards that will match any expression, type, path, pattern or item. -// The syntax for a structural search replace command is ` ==>> `. -// A `$` placeholder in the search pattern will match any AST node and `$` will reference it in the replacement. -// Within a macro call, a placeholder will match up until whatever token follows the placeholder. -// -// All paths in both the search pattern and the replacement template must resolve in the context -// in which this command is invoked. Paths in the search pattern will then match the code if they -// resolve to the same item, even if they're written differently. For example if we invoke the -// command in the module `foo` with a pattern of `Bar`, then code in the parent module that refers -// to `foo::Bar` will match. -// -// Paths in the replacement template will be rendered appropriately for the context in which the -// replacement occurs. For example if our replacement template is `foo::Bar` and we match some -// code in the `foo` module, we'll insert just `Bar`. -// -// Inherent method calls should generally be written in UFCS form. e.g. `foo::Bar::baz($s, $a)` will -// match `$s.baz($a)`, provided the method call `baz` resolves to the method `foo::Bar::baz`. -// -// The scope of the search / replace will be restricted to the current selection if any, otherwise -// it will apply to the whole workspace. -// -// Placeholders may be given constraints by writing them as `${::...}`. -// -// Supported constraints: -// -// |=== -// | Constraint | Restricts placeholder -// -// | kind(literal) | Is a literal (e.g. `42` or `"forty two"`) -// | not(a) | Negates the constraint `a` -// |=== -// -// Available via the command `rust-analyzer.ssr`. -// -// ```rust -// // Using structural search replace command [foo($a, $b) ==>> ($a).foo($b)] -// -// // BEFORE -// String::from(foo(y + 5, z)) -// -// // AFTER -// String::from((y + 5).foo(z)) -// ``` -// -// |=== -// | Editor | Action Name -// -// | VS Code | **Rust Analyzer: Structural Search Replace** -// |=== -pub fn parse_search_replace( - rule: &str, - parse_only: bool, - db: &RootDatabase, - resolve_context: FilePosition, - selections: Vec, -) -> Result, SsrError> { - let rule: SsrRule = rule.parse()?; - let mut match_finder = MatchFinder::in_context(db, resolve_context, selections); - match_finder.add_rule(rule)?; - if parse_only { - return Ok(Vec::new()); - } - Ok(match_finder.edits()) -} diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index da8c09c09a..749cf648c6 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml @@ -48,7 +48,7 @@ toolchain = { path = "../toolchain" } # This should only be used in CLI base_db = { path = "../base_db" } ide_db = { path = "../ide_db" } -ra_ssr = { path = "../ra_ssr" } +ssr = { path = "../ssr" } hir = { path = "../hir" } hir_def = { path = "../hir_def" } hir_ty = { path = "../hir_ty" } diff --git a/crates/rust-analyzer/src/bin/args.rs b/crates/rust-analyzer/src/bin/args.rs index d3081e88bd..0bc92431a9 100644 --- a/crates/rust-analyzer/src/bin/args.rs +++ b/crates/rust-analyzer/src/bin/args.rs @@ -7,8 +7,8 @@ use std::{env, fmt::Write, path::PathBuf}; use anyhow::{bail, Result}; use pico_args::Arguments; -use ra_ssr::{SsrPattern, SsrRule}; use rust_analyzer::cli::{AnalysisStatsCmd, BenchCmd, BenchWhat, Position, Verbosity}; +use ssr::{SsrPattern, SsrRule}; use vfs::AbsPathBuf; pub(crate) struct Args { diff --git a/crates/rust-analyzer/src/cli.rs b/crates/rust-analyzer/src/cli.rs index 420abaccb9..b237a94d11 100644 --- a/crates/rust-analyzer/src/cli.rs +++ b/crates/rust-analyzer/src/cli.rs @@ -13,11 +13,13 @@ use anyhow::Result; use ra_ide::Analysis; use syntax::{AstNode, SourceFile}; -pub use analysis_bench::{BenchCmd, BenchWhat, Position}; -pub use analysis_stats::AnalysisStatsCmd; -pub use diagnostics::diagnostics; -pub use load_cargo::load_cargo; -pub use ssr::{apply_ssr_rules, search_for_patterns}; +pub use self::{ + analysis_bench::{BenchCmd, BenchWhat, Position}, + analysis_stats::AnalysisStatsCmd, + diagnostics::diagnostics, + load_cargo::load_cargo, + ssr::{apply_ssr_rules, search_for_patterns}, +}; #[derive(Clone, Copy)] pub enum Verbosity { diff --git a/crates/rust-analyzer/src/cli/ssr.rs b/crates/rust-analyzer/src/cli/ssr.rs index 1357a93e16..c11e109437 100644 --- a/crates/rust-analyzer/src/cli/ssr.rs +++ b/crates/rust-analyzer/src/cli/ssr.rs @@ -1,7 +1,7 @@ //! Applies structured search replace rules from the command line. use crate::cli::{load_cargo::load_cargo, Result}; -use ra_ssr::{MatchFinder, SsrPattern, SsrRule}; +use ssr::{MatchFinder, SsrPattern, SsrRule}; pub fn apply_ssr_rules(rules: Vec) -> Result<()> { use base_db::SourceDatabaseExt; diff --git a/crates/ra_ssr/Cargo.toml b/crates/ssr/Cargo.toml similarity index 97% rename from crates/ra_ssr/Cargo.toml rename to crates/ssr/Cargo.toml index 4d22a8a982..cd05eeecc8 100644 --- a/crates/ra_ssr/Cargo.toml +++ b/crates/ssr/Cargo.toml @@ -1,22 +1,23 @@ [package] -edition = "2018" -name = "ra_ssr" +name = "ssr" version = "0.1.0" -authors = ["rust-analyzer developers"] -license = "MIT OR Apache-2.0" description = "Structural search and replace of Rust code" +license = "MIT OR Apache-2.0" repository = "https://github.com/rust-analyzer/rust-analyzer" +authors = ["rust-analyzer developers"] +edition = "2018" [lib] doctest = false [dependencies] +rustc-hash = "1.1.0" + text_edit = { path = "../text_edit" } syntax = { path = "../syntax" } base_db = { path = "../base_db" } ide_db = { path = "../ide_db" } hir = { path = "../hir" } -rustc-hash = "1.1.0" test_utils = { path = "../test_utils" } [dev-dependencies] diff --git a/crates/ra_ssr/src/errors.rs b/crates/ssr/src/errors.rs similarity index 100% rename from crates/ra_ssr/src/errors.rs rename to crates/ssr/src/errors.rs diff --git a/crates/ra_ssr/src/lib.rs b/crates/ssr/src/lib.rs similarity index 82% rename from crates/ra_ssr/src/lib.rs rename to crates/ssr/src/lib.rs index b4e35107ed..292bd5b9a7 100644 --- a/crates/ra_ssr/src/lib.rs +++ b/crates/ssr/src/lib.rs @@ -3,6 +3,58 @@ //! Allows searching the AST for code that matches one or more patterns and then replacing that code //! based on a template. +// Feature: Structural Search and Replace +// +// Search and replace with named wildcards that will match any expression, type, path, pattern or item. +// The syntax for a structural search replace command is ` ==>> `. +// A `$` placeholder in the search pattern will match any AST node and `$` will reference it in the replacement. +// Within a macro call, a placeholder will match up until whatever token follows the placeholder. +// +// All paths in both the search pattern and the replacement template must resolve in the context +// in which this command is invoked. Paths in the search pattern will then match the code if they +// resolve to the same item, even if they're written differently. For example if we invoke the +// command in the module `foo` with a pattern of `Bar`, then code in the parent module that refers +// to `foo::Bar` will match. +// +// Paths in the replacement template will be rendered appropriately for the context in which the +// replacement occurs. For example if our replacement template is `foo::Bar` and we match some +// code in the `foo` module, we'll insert just `Bar`. +// +// Inherent method calls should generally be written in UFCS form. e.g. `foo::Bar::baz($s, $a)` will +// match `$s.baz($a)`, provided the method call `baz` resolves to the method `foo::Bar::baz`. +// +// The scope of the search / replace will be restricted to the current selection if any, otherwise +// it will apply to the whole workspace. +// +// Placeholders may be given constraints by writing them as `${::...}`. +// +// Supported constraints: +// +// |=== +// | Constraint | Restricts placeholder +// +// | kind(literal) | Is a literal (e.g. `42` or `"forty two"`) +// | not(a) | Negates the constraint `a` +// |=== +// +// Available via the command `rust-analyzer.ssr`. +// +// ```rust +// // Using structural search replace command [foo($a, $b) ==>> ($a).foo($b)] +// +// // BEFORE +// String::from(foo(y + 5, z)) +// +// // AFTER +// String::from((y + 5).foo(z)) +// ``` +// +// |=== +// | Editor | Action Name +// +// | VS Code | **Rust Analyzer: Structural Search Replace** +// |=== + mod matching; mod nester; mod parsing; diff --git a/crates/ra_ssr/src/matching.rs b/crates/ssr/src/matching.rs similarity index 100% rename from crates/ra_ssr/src/matching.rs rename to crates/ssr/src/matching.rs diff --git a/crates/ra_ssr/src/nester.rs b/crates/ssr/src/nester.rs similarity index 100% rename from crates/ra_ssr/src/nester.rs rename to crates/ssr/src/nester.rs diff --git a/crates/ra_ssr/src/parsing.rs b/crates/ssr/src/parsing.rs similarity index 100% rename from crates/ra_ssr/src/parsing.rs rename to crates/ssr/src/parsing.rs diff --git a/crates/ra_ssr/src/replacing.rs b/crates/ssr/src/replacing.rs similarity index 100% rename from crates/ra_ssr/src/replacing.rs rename to crates/ssr/src/replacing.rs diff --git a/crates/ra_ssr/src/resolving.rs b/crates/ssr/src/resolving.rs similarity index 100% rename from crates/ra_ssr/src/resolving.rs rename to crates/ssr/src/resolving.rs diff --git a/crates/ra_ssr/src/search.rs b/crates/ssr/src/search.rs similarity index 100% rename from crates/ra_ssr/src/search.rs rename to crates/ssr/src/search.rs diff --git a/crates/ra_ssr/src/tests.rs b/crates/ssr/src/tests.rs similarity index 100% rename from crates/ra_ssr/src/tests.rs rename to crates/ssr/src/tests.rs From fc34403018079ea053f26d0a31b7517053c7dd8c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 17:33:38 +0200 Subject: [PATCH 104/119] Rename ra_assists -> assists --- Cargo.lock | 36 +++++++++---------- crates/{ra_assists => assists}/Cargo.toml | 9 +++-- .../src/assist_config.rs | 0 .../src/assist_context.rs | 0 .../src/ast_transform.rs | 0 .../src/handlers/add_custom_impl.rs | 0 .../src/handlers/add_explicit_type.rs | 0 .../src/handlers/add_missing_impl_members.rs | 0 .../src/handlers/add_turbo_fish.rs | 0 .../src/handlers/apply_demorgan.rs | 0 .../src/handlers/auto_import.rs | 0 .../handlers/change_return_type_to_result.rs | 0 .../src/handlers/change_visibility.rs | 0 .../src/handlers/early_return.rs | 0 .../src/handlers/expand_glob_import.rs | 0 .../extract_struct_from_enum_variant.rs | 0 .../src/handlers/extract_variable.rs | 0 .../src/handlers/fill_match_arms.rs | 0 .../src/handlers/fix_visibility.rs | 0 .../src/handlers/flip_binexpr.rs | 0 .../src/handlers/flip_comma.rs | 0 .../src/handlers/flip_trait_bound.rs | 0 .../src/handlers/generate_derive.rs | 0 .../handlers/generate_from_impl_for_enum.rs | 0 .../src/handlers/generate_function.rs | 0 .../src/handlers/generate_impl.rs | 0 .../src/handlers/generate_new.rs | 0 .../src/handlers/inline_local_variable.rs | 0 .../src/handlers/introduce_named_lifetime.rs | 0 .../src/handlers/invert_if.rs | 0 .../src/handlers/merge_imports.rs | 0 .../src/handlers/merge_match_arms.rs | 0 .../src/handlers/move_bounds.rs | 0 .../src/handlers/move_guard.rs | 0 .../src/handlers/raw_string.rs | 0 .../src/handlers/remove_dbg.rs | 0 .../src/handlers/remove_mut.rs | 0 .../src/handlers/reorder_fields.rs | 0 .../src/handlers/replace_if_let_with_match.rs | 0 .../src/handlers/replace_let_with_if_let.rs | 0 .../replace_qualified_name_with_use.rs | 0 .../src/handlers/replace_unwrap_with_match.rs | 0 .../src/handlers/split_import.rs | 0 .../src/handlers/unwrap_block.rs | 0 crates/{ra_assists => assists}/src/lib.rs | 2 +- crates/{ra_assists => assists}/src/tests.rs | 0 .../src/tests/generated.rs | 0 crates/{ra_assists => assists}/src/utils.rs | 0 .../src/utils/insert_use.rs | 0 crates/ide_db/src/imports_locator.rs | 4 +-- crates/ra_ide/Cargo.toml | 2 +- .../ra_ide/src/completion/complete_postfix.rs | 2 +- .../src/completion/complete_trait_impl.rs | 2 +- crates/ra_ide/src/join_lines.rs | 2 +- crates/ra_ide/src/lib.rs | 4 +-- docs/dev/architecture.md | 2 +- xtask/src/codegen.rs | 4 +-- 57 files changed, 34 insertions(+), 35 deletions(-) rename crates/{ra_assists => assists}/Cargo.toml (92%) rename crates/{ra_assists => assists}/src/assist_config.rs (100%) rename crates/{ra_assists => assists}/src/assist_context.rs (100%) rename crates/{ra_assists => assists}/src/ast_transform.rs (100%) rename crates/{ra_assists => assists}/src/handlers/add_custom_impl.rs (100%) rename crates/{ra_assists => assists}/src/handlers/add_explicit_type.rs (100%) rename crates/{ra_assists => assists}/src/handlers/add_missing_impl_members.rs (100%) rename crates/{ra_assists => assists}/src/handlers/add_turbo_fish.rs (100%) rename crates/{ra_assists => assists}/src/handlers/apply_demorgan.rs (100%) rename crates/{ra_assists => assists}/src/handlers/auto_import.rs (100%) rename crates/{ra_assists => assists}/src/handlers/change_return_type_to_result.rs (100%) rename crates/{ra_assists => assists}/src/handlers/change_visibility.rs (100%) rename crates/{ra_assists => assists}/src/handlers/early_return.rs (100%) rename crates/{ra_assists => assists}/src/handlers/expand_glob_import.rs (100%) rename crates/{ra_assists => assists}/src/handlers/extract_struct_from_enum_variant.rs (100%) rename crates/{ra_assists => assists}/src/handlers/extract_variable.rs (100%) rename crates/{ra_assists => assists}/src/handlers/fill_match_arms.rs (100%) rename crates/{ra_assists => assists}/src/handlers/fix_visibility.rs (100%) rename crates/{ra_assists => assists}/src/handlers/flip_binexpr.rs (100%) rename crates/{ra_assists => assists}/src/handlers/flip_comma.rs (100%) rename crates/{ra_assists => assists}/src/handlers/flip_trait_bound.rs (100%) rename crates/{ra_assists => assists}/src/handlers/generate_derive.rs (100%) rename crates/{ra_assists => assists}/src/handlers/generate_from_impl_for_enum.rs (100%) rename crates/{ra_assists => assists}/src/handlers/generate_function.rs (100%) rename crates/{ra_assists => assists}/src/handlers/generate_impl.rs (100%) rename crates/{ra_assists => assists}/src/handlers/generate_new.rs (100%) rename crates/{ra_assists => assists}/src/handlers/inline_local_variable.rs (100%) rename crates/{ra_assists => assists}/src/handlers/introduce_named_lifetime.rs (100%) rename crates/{ra_assists => assists}/src/handlers/invert_if.rs (100%) rename crates/{ra_assists => assists}/src/handlers/merge_imports.rs (100%) rename crates/{ra_assists => assists}/src/handlers/merge_match_arms.rs (100%) rename crates/{ra_assists => assists}/src/handlers/move_bounds.rs (100%) rename crates/{ra_assists => assists}/src/handlers/move_guard.rs (100%) rename crates/{ra_assists => assists}/src/handlers/raw_string.rs (100%) rename crates/{ra_assists => assists}/src/handlers/remove_dbg.rs (100%) rename crates/{ra_assists => assists}/src/handlers/remove_mut.rs (100%) rename crates/{ra_assists => assists}/src/handlers/reorder_fields.rs (100%) rename crates/{ra_assists => assists}/src/handlers/replace_if_let_with_match.rs (100%) rename crates/{ra_assists => assists}/src/handlers/replace_let_with_if_let.rs (100%) rename crates/{ra_assists => assists}/src/handlers/replace_qualified_name_with_use.rs (100%) rename crates/{ra_assists => assists}/src/handlers/replace_unwrap_with_match.rs (100%) rename crates/{ra_assists => assists}/src/handlers/split_import.rs (100%) rename crates/{ra_assists => assists}/src/handlers/unwrap_block.rs (100%) rename crates/{ra_assists => assists}/src/lib.rs (98%) rename crates/{ra_assists => assists}/src/tests.rs (100%) rename crates/{ra_assists => assists}/src/tests/generated.rs (100%) rename crates/{ra_assists => assists}/src/utils.rs (100%) rename crates/{ra_assists => assists}/src/utils/insert_use.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 4d8b748392..621be08320 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -46,6 +46,23 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" +[[package]] +name = "assists" +version = "0.0.0" +dependencies = [ + "base_db", + "either", + "hir", + "ide_db", + "itertools", + "profile", + "rustc-hash", + "stdx", + "syntax", + "test_utils", + "text_edit", +] + [[package]] name = "atty" version = "0.2.14" @@ -1102,27 +1119,11 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "ra_assists" -version = "0.1.0" -dependencies = [ - "base_db", - "either", - "hir", - "ide_db", - "itertools", - "profile", - "rustc-hash", - "stdx", - "syntax", - "test_utils", - "text_edit", -] - [[package]] name = "ra_ide" version = "0.1.0" dependencies = [ + "assists", "base_db", "cfg", "either", @@ -1134,7 +1135,6 @@ dependencies = [ "log", "oorandom", "profile", - "ra_assists", "rustc-hash", "ssr", "stdx", diff --git a/crates/ra_assists/Cargo.toml b/crates/assists/Cargo.toml similarity index 92% rename from crates/ra_assists/Cargo.toml rename to crates/assists/Cargo.toml index 19e7591f71..a560a35c7e 100644 --- a/crates/ra_assists/Cargo.toml +++ b/crates/assists/Cargo.toml @@ -1,9 +1,9 @@ [package] -edition = "2018" -name = "ra_assists" -version = "0.1.0" -authors = ["rust-analyzer developers"] +name = "assists" +version = "0.0.0" license = "MIT OR Apache-2.0" +authors = ["rust-analyzer developers"] +edition = "2018" [lib] doctest = false @@ -14,7 +14,6 @@ itertools = "0.9.0" either = "1.5.3" stdx = { path = "../stdx" } - syntax = { path = "../syntax" } text_edit = { path = "../text_edit" } profile = { path = "../profile" } diff --git a/crates/ra_assists/src/assist_config.rs b/crates/assists/src/assist_config.rs similarity index 100% rename from crates/ra_assists/src/assist_config.rs rename to crates/assists/src/assist_config.rs diff --git a/crates/ra_assists/src/assist_context.rs b/crates/assists/src/assist_context.rs similarity index 100% rename from crates/ra_assists/src/assist_context.rs rename to crates/assists/src/assist_context.rs diff --git a/crates/ra_assists/src/ast_transform.rs b/crates/assists/src/ast_transform.rs similarity index 100% rename from crates/ra_assists/src/ast_transform.rs rename to crates/assists/src/ast_transform.rs diff --git a/crates/ra_assists/src/handlers/add_custom_impl.rs b/crates/assists/src/handlers/add_custom_impl.rs similarity index 100% rename from crates/ra_assists/src/handlers/add_custom_impl.rs rename to crates/assists/src/handlers/add_custom_impl.rs diff --git a/crates/ra_assists/src/handlers/add_explicit_type.rs b/crates/assists/src/handlers/add_explicit_type.rs similarity index 100% rename from crates/ra_assists/src/handlers/add_explicit_type.rs rename to crates/assists/src/handlers/add_explicit_type.rs diff --git a/crates/ra_assists/src/handlers/add_missing_impl_members.rs b/crates/assists/src/handlers/add_missing_impl_members.rs similarity index 100% rename from crates/ra_assists/src/handlers/add_missing_impl_members.rs rename to crates/assists/src/handlers/add_missing_impl_members.rs diff --git a/crates/ra_assists/src/handlers/add_turbo_fish.rs b/crates/assists/src/handlers/add_turbo_fish.rs similarity index 100% rename from crates/ra_assists/src/handlers/add_turbo_fish.rs rename to crates/assists/src/handlers/add_turbo_fish.rs diff --git a/crates/ra_assists/src/handlers/apply_demorgan.rs b/crates/assists/src/handlers/apply_demorgan.rs similarity index 100% rename from crates/ra_assists/src/handlers/apply_demorgan.rs rename to crates/assists/src/handlers/apply_demorgan.rs diff --git a/crates/ra_assists/src/handlers/auto_import.rs b/crates/assists/src/handlers/auto_import.rs similarity index 100% rename from crates/ra_assists/src/handlers/auto_import.rs rename to crates/assists/src/handlers/auto_import.rs diff --git a/crates/ra_assists/src/handlers/change_return_type_to_result.rs b/crates/assists/src/handlers/change_return_type_to_result.rs similarity index 100% rename from crates/ra_assists/src/handlers/change_return_type_to_result.rs rename to crates/assists/src/handlers/change_return_type_to_result.rs diff --git a/crates/ra_assists/src/handlers/change_visibility.rs b/crates/assists/src/handlers/change_visibility.rs similarity index 100% rename from crates/ra_assists/src/handlers/change_visibility.rs rename to crates/assists/src/handlers/change_visibility.rs diff --git a/crates/ra_assists/src/handlers/early_return.rs b/crates/assists/src/handlers/early_return.rs similarity index 100% rename from crates/ra_assists/src/handlers/early_return.rs rename to crates/assists/src/handlers/early_return.rs diff --git a/crates/ra_assists/src/handlers/expand_glob_import.rs b/crates/assists/src/handlers/expand_glob_import.rs similarity index 100% rename from crates/ra_assists/src/handlers/expand_glob_import.rs rename to crates/assists/src/handlers/expand_glob_import.rs diff --git a/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs b/crates/assists/src/handlers/extract_struct_from_enum_variant.rs similarity index 100% rename from crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs rename to crates/assists/src/handlers/extract_struct_from_enum_variant.rs diff --git a/crates/ra_assists/src/handlers/extract_variable.rs b/crates/assists/src/handlers/extract_variable.rs similarity index 100% rename from crates/ra_assists/src/handlers/extract_variable.rs rename to crates/assists/src/handlers/extract_variable.rs diff --git a/crates/ra_assists/src/handlers/fill_match_arms.rs b/crates/assists/src/handlers/fill_match_arms.rs similarity index 100% rename from crates/ra_assists/src/handlers/fill_match_arms.rs rename to crates/assists/src/handlers/fill_match_arms.rs diff --git a/crates/ra_assists/src/handlers/fix_visibility.rs b/crates/assists/src/handlers/fix_visibility.rs similarity index 100% rename from crates/ra_assists/src/handlers/fix_visibility.rs rename to crates/assists/src/handlers/fix_visibility.rs diff --git a/crates/ra_assists/src/handlers/flip_binexpr.rs b/crates/assists/src/handlers/flip_binexpr.rs similarity index 100% rename from crates/ra_assists/src/handlers/flip_binexpr.rs rename to crates/assists/src/handlers/flip_binexpr.rs diff --git a/crates/ra_assists/src/handlers/flip_comma.rs b/crates/assists/src/handlers/flip_comma.rs similarity index 100% rename from crates/ra_assists/src/handlers/flip_comma.rs rename to crates/assists/src/handlers/flip_comma.rs diff --git a/crates/ra_assists/src/handlers/flip_trait_bound.rs b/crates/assists/src/handlers/flip_trait_bound.rs similarity index 100% rename from crates/ra_assists/src/handlers/flip_trait_bound.rs rename to crates/assists/src/handlers/flip_trait_bound.rs diff --git a/crates/ra_assists/src/handlers/generate_derive.rs b/crates/assists/src/handlers/generate_derive.rs similarity index 100% rename from crates/ra_assists/src/handlers/generate_derive.rs rename to crates/assists/src/handlers/generate_derive.rs diff --git a/crates/ra_assists/src/handlers/generate_from_impl_for_enum.rs b/crates/assists/src/handlers/generate_from_impl_for_enum.rs similarity index 100% rename from crates/ra_assists/src/handlers/generate_from_impl_for_enum.rs rename to crates/assists/src/handlers/generate_from_impl_for_enum.rs diff --git a/crates/ra_assists/src/handlers/generate_function.rs b/crates/assists/src/handlers/generate_function.rs similarity index 100% rename from crates/ra_assists/src/handlers/generate_function.rs rename to crates/assists/src/handlers/generate_function.rs diff --git a/crates/ra_assists/src/handlers/generate_impl.rs b/crates/assists/src/handlers/generate_impl.rs similarity index 100% rename from crates/ra_assists/src/handlers/generate_impl.rs rename to crates/assists/src/handlers/generate_impl.rs diff --git a/crates/ra_assists/src/handlers/generate_new.rs b/crates/assists/src/handlers/generate_new.rs similarity index 100% rename from crates/ra_assists/src/handlers/generate_new.rs rename to crates/assists/src/handlers/generate_new.rs diff --git a/crates/ra_assists/src/handlers/inline_local_variable.rs b/crates/assists/src/handlers/inline_local_variable.rs similarity index 100% rename from crates/ra_assists/src/handlers/inline_local_variable.rs rename to crates/assists/src/handlers/inline_local_variable.rs diff --git a/crates/ra_assists/src/handlers/introduce_named_lifetime.rs b/crates/assists/src/handlers/introduce_named_lifetime.rs similarity index 100% rename from crates/ra_assists/src/handlers/introduce_named_lifetime.rs rename to crates/assists/src/handlers/introduce_named_lifetime.rs diff --git a/crates/ra_assists/src/handlers/invert_if.rs b/crates/assists/src/handlers/invert_if.rs similarity index 100% rename from crates/ra_assists/src/handlers/invert_if.rs rename to crates/assists/src/handlers/invert_if.rs diff --git a/crates/ra_assists/src/handlers/merge_imports.rs b/crates/assists/src/handlers/merge_imports.rs similarity index 100% rename from crates/ra_assists/src/handlers/merge_imports.rs rename to crates/assists/src/handlers/merge_imports.rs diff --git a/crates/ra_assists/src/handlers/merge_match_arms.rs b/crates/assists/src/handlers/merge_match_arms.rs similarity index 100% rename from crates/ra_assists/src/handlers/merge_match_arms.rs rename to crates/assists/src/handlers/merge_match_arms.rs diff --git a/crates/ra_assists/src/handlers/move_bounds.rs b/crates/assists/src/handlers/move_bounds.rs similarity index 100% rename from crates/ra_assists/src/handlers/move_bounds.rs rename to crates/assists/src/handlers/move_bounds.rs diff --git a/crates/ra_assists/src/handlers/move_guard.rs b/crates/assists/src/handlers/move_guard.rs similarity index 100% rename from crates/ra_assists/src/handlers/move_guard.rs rename to crates/assists/src/handlers/move_guard.rs diff --git a/crates/ra_assists/src/handlers/raw_string.rs b/crates/assists/src/handlers/raw_string.rs similarity index 100% rename from crates/ra_assists/src/handlers/raw_string.rs rename to crates/assists/src/handlers/raw_string.rs diff --git a/crates/ra_assists/src/handlers/remove_dbg.rs b/crates/assists/src/handlers/remove_dbg.rs similarity index 100% rename from crates/ra_assists/src/handlers/remove_dbg.rs rename to crates/assists/src/handlers/remove_dbg.rs diff --git a/crates/ra_assists/src/handlers/remove_mut.rs b/crates/assists/src/handlers/remove_mut.rs similarity index 100% rename from crates/ra_assists/src/handlers/remove_mut.rs rename to crates/assists/src/handlers/remove_mut.rs diff --git a/crates/ra_assists/src/handlers/reorder_fields.rs b/crates/assists/src/handlers/reorder_fields.rs similarity index 100% rename from crates/ra_assists/src/handlers/reorder_fields.rs rename to crates/assists/src/handlers/reorder_fields.rs diff --git a/crates/ra_assists/src/handlers/replace_if_let_with_match.rs b/crates/assists/src/handlers/replace_if_let_with_match.rs similarity index 100% rename from crates/ra_assists/src/handlers/replace_if_let_with_match.rs rename to crates/assists/src/handlers/replace_if_let_with_match.rs diff --git a/crates/ra_assists/src/handlers/replace_let_with_if_let.rs b/crates/assists/src/handlers/replace_let_with_if_let.rs similarity index 100% rename from crates/ra_assists/src/handlers/replace_let_with_if_let.rs rename to crates/assists/src/handlers/replace_let_with_if_let.rs diff --git a/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs b/crates/assists/src/handlers/replace_qualified_name_with_use.rs similarity index 100% rename from crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs rename to crates/assists/src/handlers/replace_qualified_name_with_use.rs diff --git a/crates/ra_assists/src/handlers/replace_unwrap_with_match.rs b/crates/assists/src/handlers/replace_unwrap_with_match.rs similarity index 100% rename from crates/ra_assists/src/handlers/replace_unwrap_with_match.rs rename to crates/assists/src/handlers/replace_unwrap_with_match.rs diff --git a/crates/ra_assists/src/handlers/split_import.rs b/crates/assists/src/handlers/split_import.rs similarity index 100% rename from crates/ra_assists/src/handlers/split_import.rs rename to crates/assists/src/handlers/split_import.rs diff --git a/crates/ra_assists/src/handlers/unwrap_block.rs b/crates/assists/src/handlers/unwrap_block.rs similarity index 100% rename from crates/ra_assists/src/handlers/unwrap_block.rs rename to crates/assists/src/handlers/unwrap_block.rs diff --git a/crates/ra_assists/src/lib.rs b/crates/assists/src/lib.rs similarity index 98% rename from crates/ra_assists/src/lib.rs rename to crates/assists/src/lib.rs index f0cf35caf4..ae90d68a35 100644 --- a/crates/ra_assists/src/lib.rs +++ b/crates/assists/src/lib.rs @@ -1,4 +1,4 @@ -//! `ra_assists` crate provides a bunch of code assists, also known as code +//! `assists` crate provides a bunch of code assists, also known as code //! actions (in LSP) or intentions (in IntelliJ). //! //! An assist is a micro-refactoring, which is automatically activated in diff --git a/crates/ra_assists/src/tests.rs b/crates/assists/src/tests.rs similarity index 100% rename from crates/ra_assists/src/tests.rs rename to crates/assists/src/tests.rs diff --git a/crates/ra_assists/src/tests/generated.rs b/crates/assists/src/tests/generated.rs similarity index 100% rename from crates/ra_assists/src/tests/generated.rs rename to crates/assists/src/tests/generated.rs diff --git a/crates/ra_assists/src/utils.rs b/crates/assists/src/utils.rs similarity index 100% rename from crates/ra_assists/src/utils.rs rename to crates/assists/src/utils.rs diff --git a/crates/ra_assists/src/utils/insert_use.rs b/crates/assists/src/utils/insert_use.rs similarity index 100% rename from crates/ra_assists/src/utils/insert_use.rs rename to crates/assists/src/utils/insert_use.rs diff --git a/crates/ide_db/src/imports_locator.rs b/crates/ide_db/src/imports_locator.rs index 1d0c202915..ed67e35531 100644 --- a/crates/ide_db/src/imports_locator.rs +++ b/crates/ide_db/src/imports_locator.rs @@ -1,5 +1,5 @@ -//! This module contains an import search funcionality that is provided to the ra_assists module. -//! Later, this should be moved away to a separate crate that is accessible from the ra_assists module. +//! This module contains an import search funcionality that is provided to the assists module. +//! Later, this should be moved away to a separate crate that is accessible from the assists module. use hir::{Crate, MacroDef, ModuleDef, Semantics}; use syntax::{ast, AstNode, SyntaxKind::NAME}; diff --git a/crates/ra_ide/Cargo.toml b/crates/ra_ide/Cargo.toml index 8519e9ccae..2eb86755f0 100644 --- a/crates/ra_ide/Cargo.toml +++ b/crates/ra_ide/Cargo.toml @@ -28,7 +28,7 @@ ide_db = { path = "../ide_db" } cfg = { path = "../cfg" } profile = { path = "../profile" } test_utils = { path = "../test_utils" } -ra_assists = { path = "../ra_assists" } +assists = { path = "../assists" } ssr = { path = "../ssr" } # ra_ide should depend only on the top-level `hir` package. if you need diff --git a/crates/ra_ide/src/completion/complete_postfix.rs b/crates/ra_ide/src/completion/complete_postfix.rs index 05e15d4647..d50b13c52c 100644 --- a/crates/ra_ide/src/completion/complete_postfix.rs +++ b/crates/ra_ide/src/completion/complete_postfix.rs @@ -1,5 +1,5 @@ //! FIXME: write short doc here -use ra_assists::utils::TryEnum; +use assists::utils::TryEnum; use syntax::{ ast::{self, AstNode}, TextRange, TextSize, diff --git a/crates/ra_ide/src/completion/complete_trait_impl.rs b/crates/ra_ide/src/completion/complete_trait_impl.rs index d7edd92cf0..478e312623 100644 --- a/crates/ra_ide/src/completion/complete_trait_impl.rs +++ b/crates/ra_ide/src/completion/complete_trait_impl.rs @@ -31,8 +31,8 @@ //! } //! ``` +use assists::utils::get_missing_assoc_items; use hir::{self, Docs, HasSource}; -use ra_assists::utils::get_missing_assoc_items; use syntax::{ ast::{self, edit, Impl}, AstNode, SyntaxKind, SyntaxNode, TextRange, T, diff --git a/crates/ra_ide/src/join_lines.rs b/crates/ra_ide/src/join_lines.rs index f5c3107015..e37702acdf 100644 --- a/crates/ra_ide/src/join_lines.rs +++ b/crates/ra_ide/src/join_lines.rs @@ -1,5 +1,5 @@ +use assists::utils::extract_trivial_expression; use itertools::Itertools; -use ra_assists::utils::extract_trivial_expression; use syntax::{ algo::{find_covering_element, non_trivia_sibling}, ast::{self, AstNode, AstToken}, diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs index bbc9e4b8af..4321a6b743 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ra_ide/src/lib.rs @@ -80,6 +80,7 @@ pub use crate::{ }, }; +pub use assists::{Assist, AssistConfig, AssistId, AssistKind, ResolvedAssist}; pub use base_db::{ Canceled, CrateGraph, CrateId, Edition, FileId, FilePosition, FileRange, SourceRoot, SourceRootId, @@ -93,7 +94,6 @@ pub use ide_db::{ symbol_index::Query, RootDatabase, }; -pub use ra_assists::{Assist, AssistConfig, AssistId, AssistKind, ResolvedAssist}; pub use ssr::SsrError; pub use text_edit::{Indel, TextEdit}; @@ -478,7 +478,7 @@ impl Analysis { config: &AssistConfig, frange: FileRange, ) -> Cancelable> { - self.with_db(|db| ra_assists::Assist::resolved(db, config, frange)) + self.with_db(|db| assists::Assist::resolved(db, config, frange)) } /// Computes unresolved assists (aka code actions aka intentions) for the given diff --git a/docs/dev/architecture.md b/docs/dev/architecture.md index 0ffe61026a..917f05c812 100644 --- a/docs/dev/architecture.md +++ b/docs/dev/architecture.md @@ -56,7 +56,7 @@ In particular, `cargo xtask codegen` generates: 2. [`ast/generated`](https://github.com/rust-analyzer/rust-analyzer/blob/a0be39296d2925972cacd9fbf8b5fb258fad6947/crates/ra_syntax/src/ast/generated.rs) -- AST data structure. -3. [`doc_tests/generated`](https://github.com/rust-analyzer/rust-analyzer/blob/a0be39296d2925972cacd9fbf8b5fb258fad6947/crates/ra_assists/src/doc_tests/generated.rs), +3. [`doc_tests/generated`](https://github.com/rust-analyzer/rust-analyzer/blob/a0be39296d2925972cacd9fbf8b5fb258fad6947/crates/assists/src/doc_tests/generated.rs), [`test_data/parser/inline`](https://github.com/rust-analyzer/rust-analyzer/tree/a0be39296d2925972cacd9fbf8b5fb258fad6947/crates/ra_syntax/test_data/parser/inline) -- tests for assists and the parser. diff --git a/xtask/src/codegen.rs b/xtask/src/codegen.rs index 2acd598d1e..78a84f68d0 100644 --- a/xtask/src/codegen.rs +++ b/xtask/src/codegen.rs @@ -32,8 +32,8 @@ const SYNTAX_KINDS: &str = "crates/parser/src/syntax_kind/generated.rs"; const AST_NODES: &str = "crates/syntax/src/ast/generated/nodes.rs"; const AST_TOKENS: &str = "crates/syntax/src/ast/generated/tokens.rs"; -const ASSISTS_DIR: &str = "crates/ra_assists/src/handlers"; -const ASSISTS_TESTS: &str = "crates/ra_assists/src/tests/generated.rs"; +const ASSISTS_DIR: &str = "crates/assists/src/handlers"; +const ASSISTS_TESTS: &str = "crates/assists/src/tests/generated.rs"; #[derive(Debug, PartialEq, Eq, Clone, Copy)] pub enum Mode { From 1b0c7701cc97cd7bef8bb9729011d4cf291a60c5 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 17:42:52 +0200 Subject: [PATCH 105/119] Rename ra_ide -> ide --- Cargo.lock | 70 +++++++++---------- README.md | 2 +- crates/base_db/src/lib.rs | 2 +- crates/expect/Cargo.toml | 5 +- crates/flycheck/Cargo.toml | 7 +- crates/{ra_ide => ide}/Cargo.toml | 14 ++-- crates/{ra_ide => ide}/src/call_hierarchy.rs | 0 crates/{ra_ide => ide}/src/call_info.rs | 0 crates/{ra_ide => ide}/src/completion.rs | 0 .../src/completion/complete_attribute.rs | 0 .../src/completion/complete_dot.rs | 0 .../src/completion/complete_fn_param.rs | 0 .../src/completion/complete_keyword.rs | 0 .../complete_macro_in_item_position.rs | 0 .../src/completion/complete_pattern.rs | 0 .../src/completion/complete_postfix.rs | 0 .../src/completion/complete_qualified_path.rs | 0 .../src/completion/complete_record.rs | 0 .../src/completion/complete_snippet.rs | 0 .../src/completion/complete_trait_impl.rs | 0 .../completion/complete_unqualified_path.rs | 0 .../src/completion/completion_config.rs | 0 .../src/completion/completion_context.rs | 0 .../src/completion/completion_item.rs | 0 .../src/completion/patterns.rs | 0 .../src/completion/presentation.rs | 0 .../src/completion/test_utils.rs | 0 crates/{ra_ide => ide}/src/diagnostics.rs | 0 .../src/diagnostics/diagnostics_with_fix.rs | 0 crates/{ra_ide => ide}/src/display.rs | 0 .../src/display/navigation_target.rs | 0 .../src/display/short_label.rs | 0 crates/{ra_ide => ide}/src/expand_macro.rs | 0 .../{ra_ide => ide}/src/extend_selection.rs | 0 crates/{ra_ide => ide}/src/file_structure.rs | 0 crates/{ra_ide => ide}/src/folding_ranges.rs | 0 crates/{ra_ide => ide}/src/goto_definition.rs | 0 .../src/goto_implementation.rs | 0 .../src/goto_type_definition.rs | 0 crates/{ra_ide => ide}/src/hover.rs | 0 crates/{ra_ide => ide}/src/inlay_hints.rs | 0 crates/{ra_ide => ide}/src/join_lines.rs | 0 crates/{ra_ide => ide}/src/lib.rs | 2 +- crates/{ra_ide => ide}/src/markup.rs | 0 crates/{ra_ide => ide}/src/matching_brace.rs | 0 crates/{ra_ide => ide}/src/mock_analysis.rs | 0 crates/{ra_ide => ide}/src/parent_module.rs | 0 crates/{ra_ide => ide}/src/prime_caches.rs | 0 crates/{ra_ide => ide}/src/references.rs | 0 .../{ra_ide => ide}/src/references/rename.rs | 0 crates/{ra_ide => ide}/src/runnables.rs | 0 crates/{ra_ide => ide}/src/status.rs | 0 .../src/syntax_highlighting.rs | 0 .../src/syntax_highlighting/html.rs | 0 .../src/syntax_highlighting/injection.rs | 0 .../src/syntax_highlighting/tags.rs | 0 .../src/syntax_highlighting/tests.rs | 14 ++-- crates/{ra_ide => ide}/src/syntax_tree.rs | 0 crates/{ra_ide => ide}/src/typing.rs | 0 crates/{ra_ide => ide}/src/typing/on_enter.rs | 0 .../test_data/highlight_doctest.html | 0 .../test_data/highlight_extern_crate.html | 0 .../test_data/highlight_injection.html | 0 .../test_data/highlight_strings.html | 0 .../test_data/highlight_unsafe.html | 0 .../test_data/highlighting.html | 0 .../test_data/rainbow_highlighting.html | 0 crates/ide_db/Cargo.toml | 2 +- crates/ide_db/src/defs.rs | 2 +- crates/paths/Cargo.toml | 4 +- crates/proc_macro_api/Cargo.toml | 7 +- crates/rust-analyzer/Cargo.toml | 11 ++- crates/rust-analyzer/src/cargo_target_spec.rs | 2 +- crates/rust-analyzer/src/cli.rs | 2 +- .../rust-analyzer/src/cli/analysis_bench.rs | 2 +- crates/rust-analyzer/src/cli/diagnostics.rs | 2 +- crates/rust-analyzer/src/cli/load_cargo.rs | 2 +- crates/rust-analyzer/src/config.rs | 2 +- crates/rust-analyzer/src/diagnostics.rs | 2 +- crates/rust-analyzer/src/from_proto.rs | 2 +- crates/rust-analyzer/src/global_state.rs | 2 +- crates/rust-analyzer/src/handlers.rs | 12 ++-- crates/rust-analyzer/src/lib.rs | 4 +- crates/rust-analyzer/src/lsp_utils.rs | 2 +- crates/rust-analyzer/src/main_loop.rs | 2 +- crates/rust-analyzer/src/reload.rs | 2 +- crates/rust-analyzer/src/to_proto.rs | 6 +- crates/ssr/Cargo.toml | 2 +- crates/stdx/Cargo.toml | 4 +- crates/test_utils/Cargo.toml | 7 +- crates/vfs-notify/Cargo.toml | 4 +- crates/vfs/Cargo.toml | 4 +- docs/dev/README.md | 4 +- docs/dev/architecture.md | 8 +-- docs/dev/guide.md | 24 +++---- xtask/tests/tidy.rs | 2 +- 96 files changed, 122 insertions(+), 125 deletions(-) rename crates/{ra_ide => ide}/Cargo.toml (84%) rename crates/{ra_ide => ide}/src/call_hierarchy.rs (100%) rename crates/{ra_ide => ide}/src/call_info.rs (100%) rename crates/{ra_ide => ide}/src/completion.rs (100%) rename crates/{ra_ide => ide}/src/completion/complete_attribute.rs (100%) rename crates/{ra_ide => ide}/src/completion/complete_dot.rs (100%) rename crates/{ra_ide => ide}/src/completion/complete_fn_param.rs (100%) rename crates/{ra_ide => ide}/src/completion/complete_keyword.rs (100%) rename crates/{ra_ide => ide}/src/completion/complete_macro_in_item_position.rs (100%) rename crates/{ra_ide => ide}/src/completion/complete_pattern.rs (100%) rename crates/{ra_ide => ide}/src/completion/complete_postfix.rs (100%) rename crates/{ra_ide => ide}/src/completion/complete_qualified_path.rs (100%) rename crates/{ra_ide => ide}/src/completion/complete_record.rs (100%) rename crates/{ra_ide => ide}/src/completion/complete_snippet.rs (100%) rename crates/{ra_ide => ide}/src/completion/complete_trait_impl.rs (100%) rename crates/{ra_ide => ide}/src/completion/complete_unqualified_path.rs (100%) rename crates/{ra_ide => ide}/src/completion/completion_config.rs (100%) rename crates/{ra_ide => ide}/src/completion/completion_context.rs (100%) rename crates/{ra_ide => ide}/src/completion/completion_item.rs (100%) rename crates/{ra_ide => ide}/src/completion/patterns.rs (100%) rename crates/{ra_ide => ide}/src/completion/presentation.rs (100%) rename crates/{ra_ide => ide}/src/completion/test_utils.rs (100%) rename crates/{ra_ide => ide}/src/diagnostics.rs (100%) rename crates/{ra_ide => ide}/src/diagnostics/diagnostics_with_fix.rs (100%) rename crates/{ra_ide => ide}/src/display.rs (100%) rename crates/{ra_ide => ide}/src/display/navigation_target.rs (100%) rename crates/{ra_ide => ide}/src/display/short_label.rs (100%) rename crates/{ra_ide => ide}/src/expand_macro.rs (100%) rename crates/{ra_ide => ide}/src/extend_selection.rs (100%) rename crates/{ra_ide => ide}/src/file_structure.rs (100%) rename crates/{ra_ide => ide}/src/folding_ranges.rs (100%) rename crates/{ra_ide => ide}/src/goto_definition.rs (100%) rename crates/{ra_ide => ide}/src/goto_implementation.rs (100%) rename crates/{ra_ide => ide}/src/goto_type_definition.rs (100%) rename crates/{ra_ide => ide}/src/hover.rs (100%) rename crates/{ra_ide => ide}/src/inlay_hints.rs (100%) rename crates/{ra_ide => ide}/src/join_lines.rs (100%) rename crates/{ra_ide => ide}/src/lib.rs (99%) rename crates/{ra_ide => ide}/src/markup.rs (100%) rename crates/{ra_ide => ide}/src/matching_brace.rs (100%) rename crates/{ra_ide => ide}/src/mock_analysis.rs (100%) rename crates/{ra_ide => ide}/src/parent_module.rs (100%) rename crates/{ra_ide => ide}/src/prime_caches.rs (100%) rename crates/{ra_ide => ide}/src/references.rs (100%) rename crates/{ra_ide => ide}/src/references/rename.rs (100%) rename crates/{ra_ide => ide}/src/runnables.rs (100%) rename crates/{ra_ide => ide}/src/status.rs (100%) rename crates/{ra_ide => ide}/src/syntax_highlighting.rs (100%) rename crates/{ra_ide => ide}/src/syntax_highlighting/html.rs (100%) rename crates/{ra_ide => ide}/src/syntax_highlighting/injection.rs (100%) rename crates/{ra_ide => ide}/src/syntax_highlighting/tags.rs (100%) rename crates/{ra_ide => ide}/src/syntax_highlighting/tests.rs (94%) rename crates/{ra_ide => ide}/src/syntax_tree.rs (100%) rename crates/{ra_ide => ide}/src/typing.rs (100%) rename crates/{ra_ide => ide}/src/typing/on_enter.rs (100%) rename crates/{ra_ide => ide}/test_data/highlight_doctest.html (100%) rename crates/{ra_ide => ide}/test_data/highlight_extern_crate.html (100%) rename crates/{ra_ide => ide}/test_data/highlight_injection.html (100%) rename crates/{ra_ide => ide}/test_data/highlight_strings.html (100%) rename crates/{ra_ide => ide}/test_data/highlight_unsafe.html (100%) rename crates/{ra_ide => ide}/test_data/highlighting.html (100%) rename crates/{ra_ide => ide}/test_data/rainbow_highlighting.html (100%) diff --git a/Cargo.lock b/Cargo.lock index 621be08320..2386c8f3a5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -346,7 +346,7 @@ dependencies = [ [[package]] name = "expect" -version = "0.1.0" +version = "0.0.0" dependencies = [ "difference", "once_cell", @@ -385,7 +385,7 @@ dependencies = [ [[package]] name = "flycheck" -version = "0.1.0" +version = "0.0.0" dependencies = [ "cargo_metadata", "crossbeam-channel", @@ -579,6 +579,30 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "ide" +version = "0.0.0" +dependencies = [ + "assists", + "base_db", + "cfg", + "either", + "expect", + "hir", + "ide_db", + "indexmap", + "itertools", + "log", + "oorandom", + "profile", + "rustc-hash", + "ssr", + "stdx", + "syntax", + "test_utils", + "text_edit", +] + [[package]] name = "ide_db" version = "0.0.0" @@ -992,7 +1016,7 @@ dependencies = [ [[package]] name = "paths" -version = "0.1.0" +version = "0.0.0" [[package]] name = "percent-encoding" @@ -1052,7 +1076,7 @@ dependencies = [ [[package]] name = "proc_macro_api" -version = "0.1.0" +version = "0.0.0" dependencies = [ "crossbeam-channel", "jod-thread", @@ -1119,30 +1143,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "ra_ide" -version = "0.1.0" -dependencies = [ - "assists", - "base_db", - "cfg", - "either", - "expect", - "hir", - "ide_db", - "indexmap", - "itertools", - "log", - "oorandom", - "profile", - "rustc-hash", - "ssr", - "stdx", - "syntax", - "test_utils", - "text_edit", -] - [[package]] name = "rayon" version = "1.3.1" @@ -1213,7 +1213,7 @@ dependencies = [ [[package]] name = "rust-analyzer" -version = "0.1.0" +version = "0.0.0" dependencies = [ "anyhow", "base_db", @@ -1225,6 +1225,7 @@ dependencies = [ "hir", "hir_def", "hir_ty", + "ide", "ide_db", "itertools", "jod-thread", @@ -1239,7 +1240,6 @@ dependencies = [ "proc_macro_srv", "profile", "project_model", - "ra_ide", "rayon", "rustc-hash", "serde", @@ -1444,7 +1444,7 @@ dependencies = [ [[package]] name = "ssr" -version = "0.1.0" +version = "0.0.0" dependencies = [ "base_db", "expect", @@ -1458,7 +1458,7 @@ dependencies = [ [[package]] name = "stdx" -version = "0.1.0" +version = "0.0.0" [[package]] name = "syn" @@ -1515,7 +1515,7 @@ dependencies = [ [[package]] name = "test_utils" -version = "0.1.0" +version = "0.0.0" dependencies = [ "difference", "rustc-hash", @@ -1729,7 +1729,7 @@ dependencies = [ [[package]] name = "vfs" -version = "0.1.0" +version = "0.0.0" dependencies = [ "fst", "paths", @@ -1738,7 +1738,7 @@ dependencies = [ [[package]] name = "vfs-notify" -version = "0.1.0" +version = "0.0.0" dependencies = [ "crossbeam-channel", "jod-thread", diff --git a/README.md b/README.md index 16c980400c..264e4da707 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frls-2.2E0 * Website: https://rust-analyzer.github.io/ * Metrics: https://rust-analyzer.github.io/metrics/ -* API docs: https://rust-analyzer.github.io/rust-analyzer/ra_ide/ +* API docs: https://rust-analyzer.github.io/rust-analyzer/ide/ ## License diff --git a/crates/base_db/src/lib.rs b/crates/base_db/src/lib.rs index 811057251d..ee34158506 100644 --- a/crates/base_db/src/lib.rs +++ b/crates/base_db/src/lib.rs @@ -1,4 +1,4 @@ -//! base_db defines basic database traits. The concrete DB is defined by ra_ide. +//! base_db defines basic database traits. The concrete DB is defined by ide. mod cancellation; mod input; pub mod fixture; diff --git a/crates/expect/Cargo.toml b/crates/expect/Cargo.toml index 77775630dc..b54d3a60e3 100644 --- a/crates/expect/Cargo.toml +++ b/crates/expect/Cargo.toml @@ -1,9 +1,9 @@ [package] name = "expect" -version = "0.1.0" +version = "0.0.0" +license = "MIT OR Apache-2.0" authors = ["rust-analyzer developers"] edition = "2018" -license = "MIT OR Apache-2.0" [lib] doctest = false @@ -11,4 +11,5 @@ doctest = false [dependencies] once_cell = "1" difference = "2" + stdx = { path = "../stdx" } diff --git a/crates/flycheck/Cargo.toml b/crates/flycheck/Cargo.toml index acc72bc59c..262a66e4e3 100644 --- a/crates/flycheck/Cargo.toml +++ b/crates/flycheck/Cargo.toml @@ -1,9 +1,9 @@ [package] -edition = "2018" name = "flycheck" -version = "0.1.0" -authors = ["rust-analyzer developers"] +version = "0.0.0" license = "MIT OR Apache-2.0" +authors = ["rust-analyzer developers"] +edition = "2018" [lib] doctest = false @@ -14,4 +14,5 @@ log = "0.4.8" cargo_metadata = "0.11.1" serde_json = "1.0.48" jod-thread = "0.1.1" + toolchain = { path = "../toolchain" } diff --git a/crates/ra_ide/Cargo.toml b/crates/ide/Cargo.toml similarity index 84% rename from crates/ra_ide/Cargo.toml rename to crates/ide/Cargo.toml index 2eb86755f0..e4b970c73b 100644 --- a/crates/ra_ide/Cargo.toml +++ b/crates/ide/Cargo.toml @@ -1,16 +1,13 @@ [package] -edition = "2018" -name = "ra_ide" -version = "0.1.0" -authors = ["rust-analyzer developers"] +name = "ide" +version = "0.0.0" license = "MIT OR Apache-2.0" +authors = ["rust-analyzer developers"] +edition = "2018" [lib] doctest = false -[features] -wasm = [] - [dependencies] either = "1.5.3" indexmap = "1.3.2" @@ -20,7 +17,6 @@ rustc-hash = "1.1.0" oorandom = "11.1.2" stdx = { path = "../stdx" } - syntax = { path = "../syntax" } text_edit = { path = "../text_edit" } base_db = { path = "../base_db" } @@ -31,7 +27,7 @@ test_utils = { path = "../test_utils" } assists = { path = "../assists" } ssr = { path = "../ssr" } -# ra_ide should depend only on the top-level `hir` package. if you need +# ide should depend only on the top-level `hir` package. if you need # something from some `hir_xxx` subpackage, reexport the API via `hir`. hir = { path = "../hir" } diff --git a/crates/ra_ide/src/call_hierarchy.rs b/crates/ide/src/call_hierarchy.rs similarity index 100% rename from crates/ra_ide/src/call_hierarchy.rs rename to crates/ide/src/call_hierarchy.rs diff --git a/crates/ra_ide/src/call_info.rs b/crates/ide/src/call_info.rs similarity index 100% rename from crates/ra_ide/src/call_info.rs rename to crates/ide/src/call_info.rs diff --git a/crates/ra_ide/src/completion.rs b/crates/ide/src/completion.rs similarity index 100% rename from crates/ra_ide/src/completion.rs rename to crates/ide/src/completion.rs diff --git a/crates/ra_ide/src/completion/complete_attribute.rs b/crates/ide/src/completion/complete_attribute.rs similarity index 100% rename from crates/ra_ide/src/completion/complete_attribute.rs rename to crates/ide/src/completion/complete_attribute.rs diff --git a/crates/ra_ide/src/completion/complete_dot.rs b/crates/ide/src/completion/complete_dot.rs similarity index 100% rename from crates/ra_ide/src/completion/complete_dot.rs rename to crates/ide/src/completion/complete_dot.rs diff --git a/crates/ra_ide/src/completion/complete_fn_param.rs b/crates/ide/src/completion/complete_fn_param.rs similarity index 100% rename from crates/ra_ide/src/completion/complete_fn_param.rs rename to crates/ide/src/completion/complete_fn_param.rs diff --git a/crates/ra_ide/src/completion/complete_keyword.rs b/crates/ide/src/completion/complete_keyword.rs similarity index 100% rename from crates/ra_ide/src/completion/complete_keyword.rs rename to crates/ide/src/completion/complete_keyword.rs diff --git a/crates/ra_ide/src/completion/complete_macro_in_item_position.rs b/crates/ide/src/completion/complete_macro_in_item_position.rs similarity index 100% rename from crates/ra_ide/src/completion/complete_macro_in_item_position.rs rename to crates/ide/src/completion/complete_macro_in_item_position.rs diff --git a/crates/ra_ide/src/completion/complete_pattern.rs b/crates/ide/src/completion/complete_pattern.rs similarity index 100% rename from crates/ra_ide/src/completion/complete_pattern.rs rename to crates/ide/src/completion/complete_pattern.rs diff --git a/crates/ra_ide/src/completion/complete_postfix.rs b/crates/ide/src/completion/complete_postfix.rs similarity index 100% rename from crates/ra_ide/src/completion/complete_postfix.rs rename to crates/ide/src/completion/complete_postfix.rs diff --git a/crates/ra_ide/src/completion/complete_qualified_path.rs b/crates/ide/src/completion/complete_qualified_path.rs similarity index 100% rename from crates/ra_ide/src/completion/complete_qualified_path.rs rename to crates/ide/src/completion/complete_qualified_path.rs diff --git a/crates/ra_ide/src/completion/complete_record.rs b/crates/ide/src/completion/complete_record.rs similarity index 100% rename from crates/ra_ide/src/completion/complete_record.rs rename to crates/ide/src/completion/complete_record.rs diff --git a/crates/ra_ide/src/completion/complete_snippet.rs b/crates/ide/src/completion/complete_snippet.rs similarity index 100% rename from crates/ra_ide/src/completion/complete_snippet.rs rename to crates/ide/src/completion/complete_snippet.rs diff --git a/crates/ra_ide/src/completion/complete_trait_impl.rs b/crates/ide/src/completion/complete_trait_impl.rs similarity index 100% rename from crates/ra_ide/src/completion/complete_trait_impl.rs rename to crates/ide/src/completion/complete_trait_impl.rs diff --git a/crates/ra_ide/src/completion/complete_unqualified_path.rs b/crates/ide/src/completion/complete_unqualified_path.rs similarity index 100% rename from crates/ra_ide/src/completion/complete_unqualified_path.rs rename to crates/ide/src/completion/complete_unqualified_path.rs diff --git a/crates/ra_ide/src/completion/completion_config.rs b/crates/ide/src/completion/completion_config.rs similarity index 100% rename from crates/ra_ide/src/completion/completion_config.rs rename to crates/ide/src/completion/completion_config.rs diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ide/src/completion/completion_context.rs similarity index 100% rename from crates/ra_ide/src/completion/completion_context.rs rename to crates/ide/src/completion/completion_context.rs diff --git a/crates/ra_ide/src/completion/completion_item.rs b/crates/ide/src/completion/completion_item.rs similarity index 100% rename from crates/ra_ide/src/completion/completion_item.rs rename to crates/ide/src/completion/completion_item.rs diff --git a/crates/ra_ide/src/completion/patterns.rs b/crates/ide/src/completion/patterns.rs similarity index 100% rename from crates/ra_ide/src/completion/patterns.rs rename to crates/ide/src/completion/patterns.rs diff --git a/crates/ra_ide/src/completion/presentation.rs b/crates/ide/src/completion/presentation.rs similarity index 100% rename from crates/ra_ide/src/completion/presentation.rs rename to crates/ide/src/completion/presentation.rs diff --git a/crates/ra_ide/src/completion/test_utils.rs b/crates/ide/src/completion/test_utils.rs similarity index 100% rename from crates/ra_ide/src/completion/test_utils.rs rename to crates/ide/src/completion/test_utils.rs diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ide/src/diagnostics.rs similarity index 100% rename from crates/ra_ide/src/diagnostics.rs rename to crates/ide/src/diagnostics.rs diff --git a/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs b/crates/ide/src/diagnostics/diagnostics_with_fix.rs similarity index 100% rename from crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs rename to crates/ide/src/diagnostics/diagnostics_with_fix.rs diff --git a/crates/ra_ide/src/display.rs b/crates/ide/src/display.rs similarity index 100% rename from crates/ra_ide/src/display.rs rename to crates/ide/src/display.rs diff --git a/crates/ra_ide/src/display/navigation_target.rs b/crates/ide/src/display/navigation_target.rs similarity index 100% rename from crates/ra_ide/src/display/navigation_target.rs rename to crates/ide/src/display/navigation_target.rs diff --git a/crates/ra_ide/src/display/short_label.rs b/crates/ide/src/display/short_label.rs similarity index 100% rename from crates/ra_ide/src/display/short_label.rs rename to crates/ide/src/display/short_label.rs diff --git a/crates/ra_ide/src/expand_macro.rs b/crates/ide/src/expand_macro.rs similarity index 100% rename from crates/ra_ide/src/expand_macro.rs rename to crates/ide/src/expand_macro.rs diff --git a/crates/ra_ide/src/extend_selection.rs b/crates/ide/src/extend_selection.rs similarity index 100% rename from crates/ra_ide/src/extend_selection.rs rename to crates/ide/src/extend_selection.rs diff --git a/crates/ra_ide/src/file_structure.rs b/crates/ide/src/file_structure.rs similarity index 100% rename from crates/ra_ide/src/file_structure.rs rename to crates/ide/src/file_structure.rs diff --git a/crates/ra_ide/src/folding_ranges.rs b/crates/ide/src/folding_ranges.rs similarity index 100% rename from crates/ra_ide/src/folding_ranges.rs rename to crates/ide/src/folding_ranges.rs diff --git a/crates/ra_ide/src/goto_definition.rs b/crates/ide/src/goto_definition.rs similarity index 100% rename from crates/ra_ide/src/goto_definition.rs rename to crates/ide/src/goto_definition.rs diff --git a/crates/ra_ide/src/goto_implementation.rs b/crates/ide/src/goto_implementation.rs similarity index 100% rename from crates/ra_ide/src/goto_implementation.rs rename to crates/ide/src/goto_implementation.rs diff --git a/crates/ra_ide/src/goto_type_definition.rs b/crates/ide/src/goto_type_definition.rs similarity index 100% rename from crates/ra_ide/src/goto_type_definition.rs rename to crates/ide/src/goto_type_definition.rs diff --git a/crates/ra_ide/src/hover.rs b/crates/ide/src/hover.rs similarity index 100% rename from crates/ra_ide/src/hover.rs rename to crates/ide/src/hover.rs diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ide/src/inlay_hints.rs similarity index 100% rename from crates/ra_ide/src/inlay_hints.rs rename to crates/ide/src/inlay_hints.rs diff --git a/crates/ra_ide/src/join_lines.rs b/crates/ide/src/join_lines.rs similarity index 100% rename from crates/ra_ide/src/join_lines.rs rename to crates/ide/src/join_lines.rs diff --git a/crates/ra_ide/src/lib.rs b/crates/ide/src/lib.rs similarity index 99% rename from crates/ra_ide/src/lib.rs rename to crates/ide/src/lib.rs index 4321a6b743..eb63895297 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ide/src/lib.rs @@ -1,4 +1,4 @@ -//! ra_ide crate provides "ide-centric" APIs for the rust-analyzer. That is, +//! ide crate provides "ide-centric" APIs for the rust-analyzer. That is, //! it generally operates with files and text ranges, and returns results as //! Strings, suitable for displaying to the human. //! diff --git a/crates/ra_ide/src/markup.rs b/crates/ide/src/markup.rs similarity index 100% rename from crates/ra_ide/src/markup.rs rename to crates/ide/src/markup.rs diff --git a/crates/ra_ide/src/matching_brace.rs b/crates/ide/src/matching_brace.rs similarity index 100% rename from crates/ra_ide/src/matching_brace.rs rename to crates/ide/src/matching_brace.rs diff --git a/crates/ra_ide/src/mock_analysis.rs b/crates/ide/src/mock_analysis.rs similarity index 100% rename from crates/ra_ide/src/mock_analysis.rs rename to crates/ide/src/mock_analysis.rs diff --git a/crates/ra_ide/src/parent_module.rs b/crates/ide/src/parent_module.rs similarity index 100% rename from crates/ra_ide/src/parent_module.rs rename to crates/ide/src/parent_module.rs diff --git a/crates/ra_ide/src/prime_caches.rs b/crates/ide/src/prime_caches.rs similarity index 100% rename from crates/ra_ide/src/prime_caches.rs rename to crates/ide/src/prime_caches.rs diff --git a/crates/ra_ide/src/references.rs b/crates/ide/src/references.rs similarity index 100% rename from crates/ra_ide/src/references.rs rename to crates/ide/src/references.rs diff --git a/crates/ra_ide/src/references/rename.rs b/crates/ide/src/references/rename.rs similarity index 100% rename from crates/ra_ide/src/references/rename.rs rename to crates/ide/src/references/rename.rs diff --git a/crates/ra_ide/src/runnables.rs b/crates/ide/src/runnables.rs similarity index 100% rename from crates/ra_ide/src/runnables.rs rename to crates/ide/src/runnables.rs diff --git a/crates/ra_ide/src/status.rs b/crates/ide/src/status.rs similarity index 100% rename from crates/ra_ide/src/status.rs rename to crates/ide/src/status.rs diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ide/src/syntax_highlighting.rs similarity index 100% rename from crates/ra_ide/src/syntax_highlighting.rs rename to crates/ide/src/syntax_highlighting.rs diff --git a/crates/ra_ide/src/syntax_highlighting/html.rs b/crates/ide/src/syntax_highlighting/html.rs similarity index 100% rename from crates/ra_ide/src/syntax_highlighting/html.rs rename to crates/ide/src/syntax_highlighting/html.rs diff --git a/crates/ra_ide/src/syntax_highlighting/injection.rs b/crates/ide/src/syntax_highlighting/injection.rs similarity index 100% rename from crates/ra_ide/src/syntax_highlighting/injection.rs rename to crates/ide/src/syntax_highlighting/injection.rs diff --git a/crates/ra_ide/src/syntax_highlighting/tags.rs b/crates/ide/src/syntax_highlighting/tags.rs similarity index 100% rename from crates/ra_ide/src/syntax_highlighting/tags.rs rename to crates/ide/src/syntax_highlighting/tags.rs diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ide/src/syntax_highlighting/tests.rs similarity index 94% rename from crates/ra_ide/src/syntax_highlighting/tests.rs rename to crates/ide/src/syntax_highlighting/tests.rs index 594f61e85b..94f37d773f 100644 --- a/crates/ra_ide/src/syntax_highlighting/tests.rs +++ b/crates/ide/src/syntax_highlighting/tests.rs @@ -105,7 +105,7 @@ impl Option { } "# .trim(), - expect_file!["crates/ra_ide/test_data/highlighting.html"], + expect_file!["crates/ide/test_data/highlighting.html"], false, ); } @@ -128,7 +128,7 @@ fn bar() { } "# .trim(), - expect_file!["crates/ra_ide/test_data/rainbow_highlighting.html"], + expect_file!["crates/ide/test_data/rainbow_highlighting.html"], true, ); } @@ -181,7 +181,7 @@ fn main() { ); }"## .trim(), - expect_file!["crates/ra_ide/test_data/highlight_injection.html"], + expect_file!["crates/ide/test_data/highlight_injection.html"], false, ); } @@ -264,7 +264,7 @@ fn main() { println!("{ничоси}", ничоси = 92); }"# .trim(), - expect_file!["crates/ra_ide/test_data/highlight_strings.html"], + expect_file!["crates/ide/test_data/highlight_strings.html"], false, ); } @@ -337,7 +337,7 @@ fn main() { } "# .trim(), - expect_file!["crates/ra_ide/test_data/highlight_unsafe.html"], + expect_file!["crates/ide/test_data/highlight_unsafe.html"], false, ); } @@ -413,7 +413,7 @@ macro_rules! noop { } "# .trim(), - expect_file!["crates/ra_ide/test_data/highlight_doctest.html"], + expect_file!["crates/ide/test_data/highlight_doctest.html"], false, ); } @@ -430,7 +430,7 @@ fn test_extern_crate() { //- /alloc/lib.rs pub struct A "#, - expect_file!["crates/ra_ide/test_data/highlight_extern_crate.html"], + expect_file!["crates/ide/test_data/highlight_extern_crate.html"], false, ); } diff --git a/crates/ra_ide/src/syntax_tree.rs b/crates/ide/src/syntax_tree.rs similarity index 100% rename from crates/ra_ide/src/syntax_tree.rs rename to crates/ide/src/syntax_tree.rs diff --git a/crates/ra_ide/src/typing.rs b/crates/ide/src/typing.rs similarity index 100% rename from crates/ra_ide/src/typing.rs rename to crates/ide/src/typing.rs diff --git a/crates/ra_ide/src/typing/on_enter.rs b/crates/ide/src/typing/on_enter.rs similarity index 100% rename from crates/ra_ide/src/typing/on_enter.rs rename to crates/ide/src/typing/on_enter.rs diff --git a/crates/ra_ide/test_data/highlight_doctest.html b/crates/ide/test_data/highlight_doctest.html similarity index 100% rename from crates/ra_ide/test_data/highlight_doctest.html rename to crates/ide/test_data/highlight_doctest.html diff --git a/crates/ra_ide/test_data/highlight_extern_crate.html b/crates/ide/test_data/highlight_extern_crate.html similarity index 100% rename from crates/ra_ide/test_data/highlight_extern_crate.html rename to crates/ide/test_data/highlight_extern_crate.html diff --git a/crates/ra_ide/test_data/highlight_injection.html b/crates/ide/test_data/highlight_injection.html similarity index 100% rename from crates/ra_ide/test_data/highlight_injection.html rename to crates/ide/test_data/highlight_injection.html diff --git a/crates/ra_ide/test_data/highlight_strings.html b/crates/ide/test_data/highlight_strings.html similarity index 100% rename from crates/ra_ide/test_data/highlight_strings.html rename to crates/ide/test_data/highlight_strings.html diff --git a/crates/ra_ide/test_data/highlight_unsafe.html b/crates/ide/test_data/highlight_unsafe.html similarity index 100% rename from crates/ra_ide/test_data/highlight_unsafe.html rename to crates/ide/test_data/highlight_unsafe.html diff --git a/crates/ra_ide/test_data/highlighting.html b/crates/ide/test_data/highlighting.html similarity index 100% rename from crates/ra_ide/test_data/highlighting.html rename to crates/ide/test_data/highlighting.html diff --git a/crates/ra_ide/test_data/rainbow_highlighting.html b/crates/ide/test_data/rainbow_highlighting.html similarity index 100% rename from crates/ra_ide/test_data/rainbow_highlighting.html rename to crates/ide/test_data/rainbow_highlighting.html diff --git a/crates/ide_db/Cargo.toml b/crates/ide_db/Cargo.toml index 885212162f..692fb64153 100644 --- a/crates/ide_db/Cargo.toml +++ b/crates/ide_db/Cargo.toml @@ -25,6 +25,6 @@ text_edit = { path = "../text_edit" } base_db = { path = "../base_db" } profile = { path = "../profile" } test_utils = { path = "../test_utils" } -# ra_ide should depend only on the top-level `hir` package. if you need +# ide should depend only on the top-level `hir` package. if you need # something from some `hir_xxx` subpackage, reexport the API via `hir`. hir = { path = "../hir" } diff --git a/crates/ide_db/src/defs.rs b/crates/ide_db/src/defs.rs index 7b5d6ac491..0d0affc273 100644 --- a/crates/ide_db/src/defs.rs +++ b/crates/ide_db/src/defs.rs @@ -243,7 +243,7 @@ impl NameRefClass { } // Note: we don't have unit-tests for this rather important function. -// It is primarily exercised via goto definition tests in `ra_ide`. +// It is primarily exercised via goto definition tests in `ide`. pub fn classify_name_ref( sema: &Semantics, name_ref: &ast::NameRef, diff --git a/crates/paths/Cargo.toml b/crates/paths/Cargo.toml index cbe2c26e20..5ac18d63b3 100644 --- a/crates/paths/Cargo.toml +++ b/crates/paths/Cargo.toml @@ -1,9 +1,9 @@ [package] name = "paths" -version = "0.1.0" +version = "0.0.0" +license = "MIT OR Apache-2.0" authors = ["rust-analyzer developers"] edition = "2018" -license = "MIT OR Apache-2.0" [lib] doctest = false diff --git a/crates/proc_macro_api/Cargo.toml b/crates/proc_macro_api/Cargo.toml index c1abb56277..a3a4c11033 100644 --- a/crates/proc_macro_api/Cargo.toml +++ b/crates/proc_macro_api/Cargo.toml @@ -1,10 +1,9 @@ [package] -edition = "2018" name = "proc_macro_api" -version = "0.1.0" -authors = ["rust-analyzer developers"] -publish = false +version = "0.0.0" license = "MIT OR Apache-2.0" +authors = ["rust-analyzer developers"] +edition = "2018" [lib] doctest = false diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index 749cf648c6..c7c1eda0fd 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml @@ -1,10 +1,10 @@ [package] -edition = "2018" name = "rust-analyzer" -version = "0.1.0" +version = "0.0.0" +license = "MIT OR Apache-2.0" authors = ["rust-analyzer developers"] autobins = false -license = "MIT OR Apache-2.0" +edition = "2018" [lib] doctest = false @@ -30,12 +30,11 @@ serde_json = "1.0.48" threadpool = "1.7.1" rayon = "1.3.1" mimalloc = { version = "0.1.19", default-features = false, optional = true } +lsp-server = "0.3.3" stdx = { path = "../stdx" } - -lsp-server = "0.3.3" flycheck = { path = "../flycheck" } -ra_ide = { path = "../ra_ide" } +ide = { path = "../ide" } profile = { path = "../profile" } project_model = { path = "../project_model" } syntax = { path = "../syntax" } diff --git a/crates/rust-analyzer/src/cargo_target_spec.rs b/crates/rust-analyzer/src/cargo_target_spec.rs index 5ba30dbad6..3041915e18 100644 --- a/crates/rust-analyzer/src/cargo_target_spec.rs +++ b/crates/rust-analyzer/src/cargo_target_spec.rs @@ -1,8 +1,8 @@ //! See `CargoTargetSpec` use cfg::CfgExpr; +use ide::{FileId, RunnableKind, TestId}; use project_model::{self, TargetKind}; -use ra_ide::{FileId, RunnableKind, TestId}; use vfs::AbsPathBuf; use crate::{global_state::GlobalStateSnapshot, Result}; diff --git a/crates/rust-analyzer/src/cli.rs b/crates/rust-analyzer/src/cli.rs index b237a94d11..6966ee576f 100644 --- a/crates/rust-analyzer/src/cli.rs +++ b/crates/rust-analyzer/src/cli.rs @@ -10,7 +10,7 @@ mod ssr; use std::io::Read; use anyhow::Result; -use ra_ide::Analysis; +use ide::Analysis; use syntax::{AstNode, SourceFile}; pub use self::{ diff --git a/crates/rust-analyzer/src/cli/analysis_bench.rs b/crates/rust-analyzer/src/cli/analysis_bench.rs index b20a1675e6..0f614f9e0c 100644 --- a/crates/rust-analyzer/src/cli/analysis_bench.rs +++ b/crates/rust-analyzer/src/cli/analysis_bench.rs @@ -7,7 +7,7 @@ use base_db::{ salsa::{Database, Durability}, FileId, }; -use ra_ide::{Analysis, AnalysisChange, AnalysisHost, CompletionConfig, FilePosition, LineCol}; +use ide::{Analysis, AnalysisChange, AnalysisHost, CompletionConfig, FilePosition, LineCol}; use vfs::AbsPathBuf; use crate::{ diff --git a/crates/rust-analyzer/src/cli/diagnostics.rs b/crates/rust-analyzer/src/cli/diagnostics.rs index 56403cabe4..3371c4fd30 100644 --- a/crates/rust-analyzer/src/cli/diagnostics.rs +++ b/crates/rust-analyzer/src/cli/diagnostics.rs @@ -8,7 +8,7 @@ use rustc_hash::FxHashSet; use base_db::SourceDatabaseExt; use hir::Crate; -use ra_ide::Severity; +use ide::Severity; use crate::cli::{load_cargo::load_cargo, Result}; diff --git a/crates/rust-analyzer/src/cli/load_cargo.rs b/crates/rust-analyzer/src/cli/load_cargo.rs index 5427348032..c47cf6ef3e 100644 --- a/crates/rust-analyzer/src/cli/load_cargo.rs +++ b/crates/rust-analyzer/src/cli/load_cargo.rs @@ -5,8 +5,8 @@ use std::{path::Path, sync::Arc}; use anyhow::Result; use base_db::CrateGraph; use crossbeam_channel::{unbounded, Receiver}; +use ide::{AnalysisChange, AnalysisHost}; use project_model::{CargoConfig, ProcMacroClient, ProjectManifest, ProjectWorkspace}; -use ra_ide::{AnalysisChange, AnalysisHost}; use vfs::{loader::Handle, AbsPath, AbsPathBuf}; use crate::reload::{ProjectFolders, SourceRootConfig}; diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index bfc84147c3..33fb5e9c22 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs @@ -10,9 +10,9 @@ use std::{ffi::OsString, path::PathBuf}; use flycheck::FlycheckConfig; +use ide::{AssistConfig, CompletionConfig, HoverConfig, InlayHintsConfig}; use lsp_types::ClientCapabilities; use project_model::{CargoConfig, ProjectJson, ProjectJsonData, ProjectManifest}; -use ra_ide::{AssistConfig, CompletionConfig, HoverConfig, InlayHintsConfig}; use serde::Deserialize; use vfs::AbsPathBuf; diff --git a/crates/rust-analyzer/src/diagnostics.rs b/crates/rust-analyzer/src/diagnostics.rs index d24c55cee6..108df3eb04 100644 --- a/crates/rust-analyzer/src/diagnostics.rs +++ b/crates/rust-analyzer/src/diagnostics.rs @@ -3,7 +3,7 @@ pub(crate) mod to_proto; use std::{mem, sync::Arc}; -use ra_ide::FileId; +use ide::FileId; use rustc_hash::{FxHashMap, FxHashSet}; use crate::lsp_ext; diff --git a/crates/rust-analyzer/src/from_proto.rs b/crates/rust-analyzer/src/from_proto.rs index 945a353dd5..5b9f52993d 100644 --- a/crates/rust-analyzer/src/from_proto.rs +++ b/crates/rust-analyzer/src/from_proto.rs @@ -2,7 +2,7 @@ use std::convert::TryFrom; use base_db::{FileId, FilePosition, FileRange}; -use ra_ide::{AssistKind, LineCol, LineIndex}; +use ide::{AssistKind, LineCol, LineIndex}; use syntax::{TextRange, TextSize}; use vfs::AbsPathBuf; diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs index f04a0a59fd..212f98a300 100644 --- a/crates/rust-analyzer/src/global_state.rs +++ b/crates/rust-analyzer/src/global_state.rs @@ -8,10 +8,10 @@ use std::{sync::Arc, time::Instant}; use base_db::{CrateId, VfsPath}; use crossbeam_channel::{unbounded, Receiver, Sender}; use flycheck::FlycheckHandle; +use ide::{Analysis, AnalysisChange, AnalysisHost, FileId}; use lsp_types::{SemanticTokens, Url}; use parking_lot::{Mutex, RwLock}; use project_model::{CargoWorkspace, ProcMacroClient, ProjectWorkspace, Target}; -use ra_ide::{Analysis, AnalysisChange, AnalysisHost, FileId}; use rustc_hash::FxHashMap; use crate::{ diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index 4b5ca7eecf..74f73655a4 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs @@ -1,12 +1,16 @@ //! This module is responsible for implementing handlers for Language Server //! Protocol. The majority of requests are fulfilled by calling into the -//! `ra_ide` crate. +//! `ide` crate. use std::{ io::Write as _, process::{self, Stdio}, }; +use ide::{ + FileId, FilePosition, FileRange, HoverAction, HoverGotoTypeData, NavigationTarget, Query, + RangeInfo, Runnable, RunnableKind, SearchScope, TextEdit, +}; use lsp_server::ErrorCode; use lsp_types::{ CallHierarchyIncomingCall, CallHierarchyIncomingCallsParams, CallHierarchyItem, @@ -19,10 +23,6 @@ use lsp_types::{ TextDocumentIdentifier, Url, WorkspaceEdit, }; use project_model::TargetKind; -use ra_ide::{ - FileId, FilePosition, FileRange, HoverAction, HoverGotoTypeData, NavigationTarget, Query, - RangeInfo, Runnable, RunnableKind, SearchScope, TextEdit, -}; use serde::{Deserialize, Serialize}; use serde_json::to_value; use stdx::{format_to, split_once}; @@ -212,7 +212,7 @@ pub(crate) fn handle_on_type_formatting( let line_index = snap.analysis.file_line_index(position.file_id)?; let line_endings = snap.file_line_endings(position.file_id); - // in `ra_ide`, the `on_type` invariant is that + // in `ide`, the `on_type` invariant is that // `text.char_at(position) == typed_char`. position.offset -= TextSize::of('.'); let char_typed = params.ch.chars().next().unwrap_or('\0'); diff --git a/crates/rust-analyzer/src/lib.rs b/crates/rust-analyzer/src/lib.rs index 8d2e76cc24..87f72b4974 100644 --- a/crates/rust-analyzer/src/lib.rs +++ b/crates/rust-analyzer/src/lib.rs @@ -1,6 +1,6 @@ //! Implementation of the LSP for rust-analyzer. //! -//! This crate takes Rust-specific analysis results from ra_ide and translates +//! This crate takes Rust-specific analysis results from ide and translates //! into LSP types. //! //! It also is the root of all state. `world` module defines the bulk of the @@ -41,7 +41,7 @@ use serde::de::DeserializeOwned; pub type Result> = std::result::Result; pub use crate::{caps::server_capabilities, main_loop::main_loop}; -use ra_ide::AnalysisHost; +use ide::AnalysisHost; use std::fmt; use vfs::Vfs; diff --git a/crates/rust-analyzer/src/lsp_utils.rs b/crates/rust-analyzer/src/lsp_utils.rs index 17d1550cdd..85c6615714 100644 --- a/crates/rust-analyzer/src/lsp_utils.rs +++ b/crates/rust-analyzer/src/lsp_utils.rs @@ -2,8 +2,8 @@ use std::{error::Error, ops::Range}; use base_db::Canceled; +use ide::LineIndex; use lsp_server::Notification; -use ra_ide::LineIndex; use crate::{from_proto, global_state::GlobalState}; diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index 5726820f91..66e04653a3 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs @@ -7,9 +7,9 @@ use std::{ use base_db::VfsPath; use crossbeam_channel::{select, Receiver}; +use ide::{Canceled, FileId}; use lsp_server::{Connection, Notification, Request, Response}; use lsp_types::notification::Notification as _; -use ra_ide::{Canceled, FileId}; use crate::{ config::Config, diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs index fd133e3124..a2cfb4e0d5 100644 --- a/crates/rust-analyzer/src/reload.rs +++ b/crates/rust-analyzer/src/reload.rs @@ -3,8 +3,8 @@ use std::{mem, sync::Arc}; use base_db::{CrateGraph, SourceRoot, VfsPath}; use flycheck::FlycheckHandle; +use ide::AnalysisChange; use project_model::{ProcMacroClient, ProjectWorkspace}; -use ra_ide::AnalysisChange; use vfs::{file_set::FileSetConfig, AbsPath, AbsPathBuf, ChangeKind}; use crate::{ diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index 93a4b1f27d..8a2cfa2aee 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs @@ -5,13 +5,13 @@ use std::{ }; use base_db::{FileId, FileRange}; -use itertools::Itertools; -use ra_ide::{ +use ide::{ Assist, AssistKind, CallInfo, CompletionItem, CompletionItemKind, Documentation, FileSystemEdit, Fold, FoldKind, Highlight, HighlightModifier, HighlightTag, HighlightedRange, Indel, InlayHint, InlayKind, InsertTextFormat, LineIndex, Markup, NavigationTarget, ReferenceAccess, ResolvedAssist, Runnable, Severity, SourceChange, SourceFileEdit, TextEdit, }; +use itertools::Itertools; use syntax::{SyntaxKind, TextRange, TextSize}; use crate::{ @@ -761,7 +761,7 @@ pub(crate) fn markup_content(markup: Markup) -> lsp_types::MarkupContent { #[cfg(test)] mod tests { - use ra_ide::Analysis; + use ide::Analysis; use super::*; diff --git a/crates/ssr/Cargo.toml b/crates/ssr/Cargo.toml index cd05eeecc8..56c1f77618 100644 --- a/crates/ssr/Cargo.toml +++ b/crates/ssr/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ssr" -version = "0.1.0" +version = "0.0.0" description = "Structural search and replace of Rust code" license = "MIT OR Apache-2.0" repository = "https://github.com/rust-analyzer/rust-analyzer" diff --git a/crates/stdx/Cargo.toml b/crates/stdx/Cargo.toml index 4c0b858617..b186b46f29 100644 --- a/crates/stdx/Cargo.toml +++ b/crates/stdx/Cargo.toml @@ -1,9 +1,9 @@ [package] name = "stdx" -version = "0.1.0" +version = "0.0.0" +license = "MIT OR Apache-2.0" authors = ["rust-analyzer developers"] edition = "2018" -license = "MIT OR Apache-2.0" [lib] doctest = false diff --git a/crates/test_utils/Cargo.toml b/crates/test_utils/Cargo.toml index e719f4f7c1..45e5fb97f7 100644 --- a/crates/test_utils/Cargo.toml +++ b/crates/test_utils/Cargo.toml @@ -1,9 +1,9 @@ [package] -edition = "2018" name = "test_utils" -version = "0.1.0" -authors = ["rust-analyzer developers"] +version = "0.0.0" license = "MIT OR Apache-2.0" +authors = ["rust-analyzer developers"] +edition = "2018" [lib] doctest = false @@ -14,4 +14,5 @@ difference = "2.0.0" text-size = "1.0.0" serde_json = "1.0.48" rustc-hash = "1.1.0" + stdx = { path = "../stdx" } diff --git a/crates/vfs-notify/Cargo.toml b/crates/vfs-notify/Cargo.toml index fce7bae3ad..c1e53f4b15 100644 --- a/crates/vfs-notify/Cargo.toml +++ b/crates/vfs-notify/Cargo.toml @@ -1,9 +1,9 @@ [package] name = "vfs-notify" -version = "0.1.0" +version = "0.0.0" +license = "MIT OR Apache-2.0" authors = ["rust-analyzer developers"] edition = "2018" -license = "MIT OR Apache-2.0" [lib] doctest = false diff --git a/crates/vfs/Cargo.toml b/crates/vfs/Cargo.toml index b74cdb7ffa..9ae8f19b6f 100644 --- a/crates/vfs/Cargo.toml +++ b/crates/vfs/Cargo.toml @@ -1,9 +1,9 @@ [package] name = "vfs" -version = "0.1.0" +version = "0.0.0" +license = "MIT OR Apache-2.0" authors = ["rust-analyzer developers"] edition = "2018" -license = "MIT OR Apache-2.0" [lib] doctest = false diff --git a/docs/dev/README.md b/docs/dev/README.md index 04bebbfca5..ad18217f17 100644 --- a/docs/dev/README.md +++ b/docs/dev/README.md @@ -14,7 +14,7 @@ To learn more about how rust-analyzer works, see We also publish rustdoc docs to pages: -https://rust-analyzer.github.io/rust-analyzer/ra_ide/ +https://rust-analyzer.github.io/rust-analyzer/ide/ Various organizational and process issues are discussed in this document. @@ -159,7 +159,7 @@ IDE should use only types from `hir`, and should not depend on the underling com ## IDE API -The main IDE crate (`ra_ide`) uses "Plain Old Data" for the API. +The main IDE crate (`ide`) uses "Plain Old Data" for the API. Rather than talking in definitions and references, it talks in Strings and textual offsets. In general, API is centered around UI concerns -- the result of the call is what the user sees in the editor, and not what the compiler sees underneath. The results are 100% Rust specific though. diff --git a/docs/dev/architecture.md b/docs/dev/architecture.md index 917f05c812..6f1377f2f0 100644 --- a/docs/dev/architecture.md +++ b/docs/dev/architecture.md @@ -118,7 +118,7 @@ directly query the database. The top-level `hir` façade crate wraps ids into a more OO-flavored API. -### `crates/ra_ide` +### `crates/ide` A stateful library for analyzing many Rust files as they change. `AnalysisHost` is a mutable entity (clojure's atom) which holds the current state, incorporates @@ -136,11 +136,11 @@ offsets and strings as output. This works on top of rich code model powered by ### `crates/rust-analyzer` -An LSP implementation which wraps `ra_ide` into a language server protocol. +An LSP implementation which wraps `ide` into a language server protocol. ### `ra_vfs` -Although `hir` and `ra_ide` don't do any IO, we need to be able to read +Although `hir` and `ide` don't do any IO, we need to be able to read files from disk at the end of the day. This is what `ra_vfs` does. It also manages overlays: "dirty" files in the editor, whose "true" contents is different from data on disk. This is more or less the single really @@ -161,7 +161,7 @@ disk. For this reason, we try to avoid writing too many tests on this boundary: in a statically typed language, it's hard to make an error in the protocol itself if messages are themselves typed. -The middle, and most important, boundary is `ra_ide`. Unlike +The middle, and most important, boundary is `ide`. Unlike `rust-analyzer`, which exposes API, `ide` uses Rust API and is intended to use by various tools. Typical test creates an `AnalysisHost`, calls some `Analysis` functions and compares the results against expectation. diff --git a/docs/dev/guide.md b/docs/dev/guide.md index 29d84bf3f6..b5a5d7c935 100644 --- a/docs/dev/guide.md +++ b/docs/dev/guide.md @@ -40,8 +40,8 @@ terms of files and offsets, and **not** in terms of Rust concepts like structs, traits, etc. The "typed" API with Rust specific types is slightly lower in the stack, we'll talk about it later. -[`AnalysisHost`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_ide_api/src/lib.rs#L265-L284 -[`Analysis`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_ide_api/src/lib.rs#L291-L478 +[`AnalysisHost`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ide_api/src/lib.rs#L265-L284 +[`Analysis`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ide_api/src/lib.rs#L291-L478 The reason for this separation of `Analysis` and `AnalysisHost` is that we want to apply changes "uniquely", but we might also want to fork an `Analysis` and send it to @@ -69,7 +69,7 @@ the `AnalysisHost::apply_change` method, which accepts a single argument, a "transaction", so it suffices to study its methods to understand all of the input data. -[`AnalysisChange`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_ide_api/src/lib.rs#L119-L167 +[`AnalysisChange`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ide_api/src/lib.rs#L119-L167 The `(add|change|remove)_file` methods control the set of the input files, where each file has an integer id (`FileId`, picked by the client), text (`String`) @@ -253,7 +253,7 @@ All analyzer information is stored in a salsa database. `Analysis` and `AnalysisHost` types are newtype wrappers for [`RootDatabase`] -- a salsa database. -[`RootDatabase`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_ide_api/src/db.rs#L88-L134 +[`RootDatabase`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ide_api/src/db.rs#L88-L134 Salsa input queries are defined in [`FilesDatabase`] (which is a part of `RootDatabase`). They closely mirror the familiar `AnalysisChange` structure: @@ -565,11 +565,11 @@ the type to completion. [schedule it on the threadpool]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_lsp_server/src/main_loop.rs#L428 [catch]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_lsp_server/src/main_loop.rs#L436-L442 [the handler]: https://salsa.zulipchat.com/#narrow/stream/181542-rfcs.2Fsalsa-query-group/topic/design.20next.20steps -[ask analysis for completion]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_ide_api/src/lib.rs#L439-L444 -[completion implementation]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_ide_api/src/completion.rs#L46-L62 -[`CompletionContext`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_ide_api/src/completion/completion_context.rs#L14-L37 -["IntelliJ Trick"]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_ide_api/src/completion/completion_context.rs#L72-L75 -[find an ancestor `fn` node]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_ide_api/src/completion/completion_context.rs#L116-L120 -[semantic model]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_ide_api/src/completion/completion_context.rs#L123 -[series of independent completion routines]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_ide_api/src/completion.rs#L52-L59 -[`complete_dot`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ra_ide_api/src/completion/complete_dot.rs#L6-L22 +[ask analysis for completion]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ide_api/src/lib.rs#L439-L444 +[completion implementation]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ide_api/src/completion.rs#L46-L62 +[`CompletionContext`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ide_api/src/completion/completion_context.rs#L14-L37 +["IntelliJ Trick"]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ide_api/src/completion/completion_context.rs#L72-L75 +[find an ancestor `fn` node]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ide_api/src/completion/completion_context.rs#L116-L120 +[semantic model]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ide_api/src/completion/completion_context.rs#L123 +[series of independent completion routines]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ide_api/src/completion.rs#L52-L59 +[`complete_dot`]: https://github.com/rust-analyzer/rust-analyzer/blob/guide-2019-01/crates/ide_api/src/completion/complete_dot.rs#L6-L22 diff --git a/xtask/tests/tidy.rs b/xtask/tests/tidy.rs index 97a11a01ee..76895aeca0 100644 --- a/xtask/tests/tidy.rs +++ b/xtask/tests/tidy.rs @@ -194,7 +194,7 @@ impl TidyDocs { let poorly_documented = [ "hir", "hir_expand", - "ra_ide", + "ide", "mbe", "parser", "profile", From 6bc2633c90cedad057c5201d1ab7f67b57247004 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 17:58:35 +0200 Subject: [PATCH 106/119] Align parser names with grammar --- crates/parser/src/grammar.rs | 16 ++--- crates/parser/src/grammar/attributes.rs | 10 +-- crates/parser/src/grammar/expressions.rs | 14 ++-- crates/parser/src/grammar/expressions/atom.rs | 20 +++--- crates/parser/src/grammar/items.rs | 54 +++++++------- crates/parser/src/grammar/items/adt.rs | 34 ++++----- crates/parser/src/grammar/items/consts.rs | 4 +- crates/parser/src/grammar/items/traits.rs | 38 +++------- crates/parser/src/grammar/items/use_item.rs | 4 +- crates/parser/src/grammar/params.rs | 12 ++-- crates/parser/src/grammar/paths.rs | 6 +- crates/parser/src/grammar/patterns.rs | 20 +++--- crates/parser/src/grammar/type_args.rs | 6 +- crates/parser/src/grammar/type_params.rs | 12 ++-- crates/parser/src/grammar/types.rs | 20 +++--- .../inline/ok/0001_trait_item_list.rast | 71 ------------------- .../parser/inline/ok/0001_trait_item_list.rs | 6 -- 17 files changed, 124 insertions(+), 223 deletions(-) delete mode 100644 crates/syntax/test_data/parser/inline/ok/0001_trait_item_list.rast delete mode 100644 crates/syntax/test_data/parser/inline/ok/0001_trait_item_list.rs diff --git a/crates/parser/src/grammar.rs b/crates/parser/src/grammar.rs index 9dbd2ebc44..562e92252b 100644 --- a/crates/parser/src/grammar.rs +++ b/crates/parser/src/grammar.rs @@ -142,19 +142,19 @@ pub(crate) fn reparser( ) -> Option { let res = match node { BLOCK_EXPR => expressions::block_expr, - RECORD_FIELD_LIST => items::record_field_def_list, - RECORD_EXPR_FIELD_LIST => items::record_field_list, - VARIANT_LIST => items::enum_variant_list, + RECORD_FIELD_LIST => items::record_field_list, + RECORD_EXPR_FIELD_LIST => items::record_expr_field_list, + VARIANT_LIST => items::variant_list, MATCH_ARM_LIST => items::match_arm_list, USE_TREE_LIST => items::use_tree_list, EXTERN_ITEM_LIST => items::extern_item_list, TOKEN_TREE if first_child? == T!['{'] => items::token_tree, ASSOC_ITEM_LIST => match parent? { - IMPL => items::impl_item_list, - TRAIT => items::trait_item_list, + IMPL => items::assoc_item_list, + TRAIT => items::assoc_item_list, _ => return None, }, - ITEM_LIST => items::mod_item_list, + ITEM_LIST => items::item_list, _ => return None, }; Some(res) @@ -217,7 +217,7 @@ fn opt_visibility(p: &mut Parser) -> bool { true } -fn opt_alias(p: &mut Parser) { +fn opt_rename(p: &mut Parser) { if p.at(T![as]) { let m = p.start(); p.bump(T![as]); @@ -239,7 +239,7 @@ fn abi(p: &mut Parser) { abi.complete(p, ABI); } -fn opt_fn_ret_type(p: &mut Parser) -> bool { +fn opt_ret_type(p: &mut Parser) -> bool { if p.at(T![->]) { let m = p.start(); p.bump(T![->]); diff --git a/crates/parser/src/grammar/attributes.rs b/crates/parser/src/grammar/attributes.rs index f3158ade30..dab0f62c3c 100644 --- a/crates/parser/src/grammar/attributes.rs +++ b/crates/parser/src/grammar/attributes.rs @@ -2,19 +2,19 @@ use super::*; -pub(super) fn inner_attributes(p: &mut Parser) { +pub(super) fn inner_attrs(p: &mut Parser) { while p.at(T![#]) && p.nth(1) == T![!] { - attribute(p, true) + attr(p, true) } } -pub(super) fn outer_attributes(p: &mut Parser) { +pub(super) fn outer_attrs(p: &mut Parser) { while p.at(T![#]) { - attribute(p, false) + attr(p, false) } } -fn attribute(p: &mut Parser, inner: bool) { +fn attr(p: &mut Parser, inner: bool) { let attr = p.start(); assert!(p.at(T![#])); p.bump(T![#]); diff --git a/crates/parser/src/grammar/expressions.rs b/crates/parser/src/grammar/expressions.rs index 3291e3f146..e72929f8cc 100644 --- a/crates/parser/src/grammar/expressions.rs +++ b/crates/parser/src/grammar/expressions.rs @@ -22,7 +22,7 @@ pub(super) fn expr(p: &mut Parser) -> (Option, BlockLike) { pub(super) fn expr_with_attrs(p: &mut Parser) -> bool { let m = p.start(); let has_attrs = p.at(T![#]); - attributes::outer_attributes(p); + attributes::outer_attrs(p); let (cm, _block_like) = expr(p); let success = cm.is_some(); @@ -64,7 +64,7 @@ pub(super) fn stmt(p: &mut Parser, with_semi: StmtWithSemi) { // #[D] return (); // } let has_attrs = p.at(T![#]); - attributes::outer_attributes(p); + attributes::outer_attrs(p); if p.at(T![let]) { let_stmt(p, m, with_semi); @@ -175,7 +175,7 @@ pub(super) fn stmt(p: &mut Parser, with_semi: StmtWithSemi) { pub(super) fn expr_block_contents(p: &mut Parser) { // This is checked by a validator - attributes::inner_attributes(p); + attributes::inner_attrs(p); while !p.at(EOF) && !p.at(T!['}']) { // test nocontentexpr @@ -489,7 +489,7 @@ fn method_call_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { let m = lhs.precede(p); p.bump_any(); name_ref(p); - type_args::opt_type_arg_list(p, true); + type_args::opt_generic_arg_list(p, true); if p.at(T!['(']) { arg_list(p); } @@ -585,7 +585,7 @@ fn path_expr(p: &mut Parser, r: Restrictions) -> (CompletedMarker, BlockLike) { paths::expr_path(p); match p.current() { T!['{'] if !r.forbid_structs => { - record_field_list(p); + record_expr_field_list(p); (m.complete(p, RECORD_EXPR), BlockLike::NotBlock) } T![!] if !p.at(T![!=]) => { @@ -603,7 +603,7 @@ fn path_expr(p: &mut Parser, r: Restrictions) -> (CompletedMarker, BlockLike) { // S { x, y: 32, ..Default::default() }; // TupleStruct { 0: 1 }; // } -pub(crate) fn record_field_list(p: &mut Parser) { +pub(crate) fn record_expr_field_list(p: &mut Parser) { assert!(p.at(T!['{'])); let m = p.start(); p.bump(T!['{']); @@ -613,7 +613,7 @@ pub(crate) fn record_field_list(p: &mut Parser) { // fn main() { // S { #[cfg(test)] field: 1 } // } - attributes::outer_attributes(p); + attributes::outer_attrs(p); match p.current() { IDENT | INT_NUMBER => { diff --git a/crates/parser/src/grammar/expressions/atom.rs b/crates/parser/src/grammar/expressions/atom.rs index 0b01d3bc64..ba6dd2fbcc 100644 --- a/crates/parser/src/grammar/expressions/atom.rs +++ b/crates/parser/src/grammar/expressions/atom.rs @@ -75,9 +75,9 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar T!['('] => tuple_expr(p), T!['['] => array_expr(p), L_DOLLAR => meta_var_expr(p), - T![|] => lambda_expr(p), - T![move] if la == T![|] => lambda_expr(p), - T![async] if la == T![|] || (la == T![move] && p.nth(2) == T![|]) => lambda_expr(p), + T![|] => closure_expr(p), + T![move] if la == T![|] => closure_expr(p), + T![async] if la == T![|] || (la == T![move] && p.nth(2) == T![|]) => closure_expr(p), T![if] => if_expr(p), T![loop] => loop_expr(p, None), @@ -228,7 +228,7 @@ fn array_expr(p: &mut Parser) -> CompletedMarker { // move || {}; // async move || {}; // } -fn lambda_expr(p: &mut Parser) -> CompletedMarker { +fn closure_expr(p: &mut Parser) -> CompletedMarker { assert!( p.at(T![|]) || (p.at(T![move]) && p.nth(1) == T![|]) @@ -239,7 +239,7 @@ fn lambda_expr(p: &mut Parser) -> CompletedMarker { p.eat(T![async]); p.eat(T![move]); params::param_list_closure(p); - if opt_fn_ret_type(p) { + if opt_ret_type(p) { // test lambda_ret_block // fn main() { || -> i32 { 92 }(); } block_expr(p); @@ -265,7 +265,7 @@ fn if_expr(p: &mut Parser) -> CompletedMarker { assert!(p.at(T![if])); let m = p.start(); p.bump(T![if]); - cond(p); + condition(p); block_expr(p); if p.at(T![else]) { p.bump(T![else]); @@ -314,7 +314,7 @@ fn while_expr(p: &mut Parser, m: Option) -> CompletedMarker { assert!(p.at(T![while])); let m = m.unwrap_or_else(|| p.start()); p.bump(T![while]); - cond(p); + condition(p); block_expr(p); m.complete(p, WHILE_EXPR) } @@ -342,7 +342,7 @@ fn for_expr(p: &mut Parser, m: Option) -> CompletedMarker { // while let Some(_) | Some(_) = None {} // while let | Some(_) = None {} // } -fn cond(p: &mut Parser) { +fn condition(p: &mut Parser) { let m = p.start(); if p.eat(T![let]) { patterns::pattern_top(p); @@ -386,7 +386,7 @@ pub(crate) fn match_arm_list(p: &mut Parser) { // _ => (), // } // } - attributes::inner_attributes(p); + attributes::inner_attrs(p); while !p.at(EOF) && !p.at(T!['}']) { if p.at(T!['{']) { @@ -437,7 +437,7 @@ fn match_arm(p: &mut Parser) -> BlockLike { // _ => (), // } // } - attributes::outer_attributes(p); + attributes::outer_attrs(p); patterns::pattern_top_r(p, TokenSet::EMPTY); if p.at(T![if]) { diff --git a/crates/parser/src/grammar/items.rs b/crates/parser/src/grammar/items.rs index d091b0fbb2..b2f7cc21f6 100644 --- a/crates/parser/src/grammar/items.rs +++ b/crates/parser/src/grammar/items.rs @@ -6,9 +6,9 @@ mod traits; mod use_item; pub(crate) use self::{ - adt::{enum_variant_list, record_field_def_list}, - expressions::{match_arm_list, record_field_list}, - traits::{impl_item_list, trait_item_list}, + adt::{record_field_list, variant_list}, + expressions::{match_arm_list, record_expr_field_list}, + traits::assoc_item_list, use_item::use_tree_list, }; use super::*; @@ -20,7 +20,7 @@ use super::*; // super::baz! {} // struct S; pub(super) fn mod_contents(p: &mut Parser, stop_on_r_curly: bool) { - attributes::inner_attributes(p); + attributes::inner_attrs(p); while !(stop_on_r_curly && p.at(T!['}']) || p.at(EOF)) { item_or_macro(p, stop_on_r_curly) } @@ -33,7 +33,7 @@ pub(super) const ITEM_RECOVERY_SET: TokenSet = token_set![ pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool) { let m = p.start(); - attributes::outer_attributes(p); + attributes::outer_attrs(p); let m = match maybe_item(p, m) { Ok(()) => { if p.at(T![;]) { @@ -144,30 +144,30 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker) -> Result<(), Marker> { // test fn // fn foo() {} T![fn] => { - fn_def(p); + fn_(p); m.complete(p, FN); } // test trait // trait T {} T![trait] => { - traits::trait_def(p); + traits::trait_(p); m.complete(p, TRAIT); } T![const] => { - consts::const_def(p, m); + consts::konst(p, m); } // test impl // impl T for S {} T![impl] => { - traits::impl_def(p); + traits::impl_(p); m.complete(p, IMPL); } T![type] => { - type_def(p, m); + type_alias(p, m); } _ => { if !has_visibility && !has_mods { @@ -190,9 +190,9 @@ fn items_without_modifiers(p: &mut Parser, m: Marker) -> Result<(), Marker> { match p.current() { // test extern_crate // extern crate foo; - T![extern] if la == T![crate] => extern_crate_item(p, m), + T![extern] if la == T![crate] => extern_crate(p, m), T![type] => { - type_def(p, m); + type_alias(p, m); } T![mod] => mod_item(p, m), T![struct] => { @@ -205,7 +205,7 @@ fn items_without_modifiers(p: &mut Parser, m: Marker) -> Result<(), Marker> { // a: i32, // b: f32, // } - adt::struct_def(p, m); + adt::strukt(p, m); } // test pub_macro_def // pub macro m($:ident) {} @@ -219,12 +219,12 @@ fn items_without_modifiers(p: &mut Parser, m: Marker) -> Result<(), Marker> { // a: i32, // b: f32, // } - adt::union_def(p, m); + adt::union(p, m); } - T![enum] => adt::enum_def(p, m), - T![use] => use_item::use_item(p, m), - T![const] if (la == IDENT || la == T![_] || la == T![mut]) => consts::const_def(p, m), - T![static] => consts::static_def(p, m), + T![enum] => adt::enum_(p, m), + T![use] => use_item::use_(p, m), + T![const] if (la == IDENT || la == T![_] || la == T![mut]) => consts::konst(p, m), + T![static] => consts::static_(p, m), // test extern_block // extern {} T![extern] @@ -239,7 +239,7 @@ fn items_without_modifiers(p: &mut Parser, m: Marker) -> Result<(), Marker> { Ok(()) } -fn extern_crate_item(p: &mut Parser, m: Marker) { +fn extern_crate(p: &mut Parser, m: Marker) { assert!(p.at(T![extern])); p.bump(T![extern]); assert!(p.at(T![crate])); @@ -251,7 +251,7 @@ fn extern_crate_item(p: &mut Parser, m: Marker) { name_ref(p); } - opt_alias(p); + opt_rename(p); p.expect(T![;]); m.complete(p, EXTERN_CRATE); } @@ -265,14 +265,14 @@ pub(crate) fn extern_item_list(p: &mut Parser) { m.complete(p, EXTERN_ITEM_LIST); } -fn fn_def(p: &mut Parser) { +fn fn_(p: &mut Parser) { assert!(p.at(T![fn])); p.bump(T![fn]); name_r(p, ITEM_RECOVERY_SET); // test function_type_params // fn foo(){} - type_params::opt_type_param_list(p); + type_params::opt_generic_param_list(p); if p.at(T!['(']) { params::param_list_fn_def(p); @@ -282,7 +282,7 @@ fn fn_def(p: &mut Parser) { // test function_ret_type // fn foo() {} // fn bar() -> () {} - opt_fn_ret_type(p); + opt_ret_type(p); // test function_where_clause // fn foo() where T: Copy {} @@ -299,7 +299,7 @@ fn fn_def(p: &mut Parser) { // test type_item // type Foo = Bar; -fn type_def(p: &mut Parser, m: Marker) { +fn type_alias(p: &mut Parser, m: Marker) { assert!(p.at(T![type])); p.bump(T![type]); @@ -307,7 +307,7 @@ fn type_def(p: &mut Parser, m: Marker) { // test type_item_type_params // type Result = (); - type_params::opt_type_param_list(p); + type_params::opt_generic_param_list(p); if p.at(T![:]) { type_params::bounds(p); @@ -329,14 +329,14 @@ pub(crate) fn mod_item(p: &mut Parser, m: Marker) { name(p); if p.at(T!['{']) { - mod_item_list(p); + item_list(p); } else if !p.eat(T![;]) { p.error("expected `;` or `{`"); } m.complete(p, MODULE); } -pub(crate) fn mod_item_list(p: &mut Parser) { +pub(crate) fn item_list(p: &mut Parser) { assert!(p.at(T!['{'])); let m = p.start(); p.bump(T!['{']); diff --git a/crates/parser/src/grammar/items/adt.rs b/crates/parser/src/grammar/items/adt.rs index addfb59d4b..67c0c56970 100644 --- a/crates/parser/src/grammar/items/adt.rs +++ b/crates/parser/src/grammar/items/adt.rs @@ -2,13 +2,13 @@ use super::*; -pub(super) fn struct_def(p: &mut Parser, m: Marker) { +pub(super) fn strukt(p: &mut Parser, m: Marker) { assert!(p.at(T![struct])); p.bump(T![struct]); struct_or_union(p, m, T![struct], STRUCT); } -pub(super) fn union_def(p: &mut Parser, m: Marker) { +pub(super) fn union(p: &mut Parser, m: Marker) { assert!(p.at_contextual_kw("union")); p.bump_remap(T![union]); struct_or_union(p, m, T![union], UNION); @@ -16,7 +16,7 @@ pub(super) fn union_def(p: &mut Parser, m: Marker) { fn struct_or_union(p: &mut Parser, m: Marker, kw: SyntaxKind, def: SyntaxKind) { name_r(p, ITEM_RECOVERY_SET); - type_params::opt_type_param_list(p); + type_params::opt_generic_param_list(p); match p.current() { T![where] => { type_params::opt_where_clause(p); @@ -24,7 +24,7 @@ fn struct_or_union(p: &mut Parser, m: Marker, kw: SyntaxKind, def: SyntaxKind) { T![;] => { p.bump(T![;]); } - T!['{'] => record_field_def_list(p), + T!['{'] => record_field_list(p), _ => { //FIXME: special case `(` error message p.error("expected `;` or `{`"); @@ -34,9 +34,9 @@ fn struct_or_union(p: &mut Parser, m: Marker, kw: SyntaxKind, def: SyntaxKind) { T![;] if kw == T![struct] => { p.bump(T![;]); } - T!['{'] => record_field_def_list(p), + T!['{'] => record_field_list(p), T!['('] if kw == T![struct] => { - tuple_field_def_list(p); + tuple_field_list(p); // test tuple_struct_where // struct Test(T) where T: Clone; // struct Test(T); @@ -53,21 +53,21 @@ fn struct_or_union(p: &mut Parser, m: Marker, kw: SyntaxKind, def: SyntaxKind) { m.complete(p, def); } -pub(super) fn enum_def(p: &mut Parser, m: Marker) { +pub(super) fn enum_(p: &mut Parser, m: Marker) { assert!(p.at(T![enum])); p.bump(T![enum]); name_r(p, ITEM_RECOVERY_SET); - type_params::opt_type_param_list(p); + type_params::opt_generic_param_list(p); type_params::opt_where_clause(p); if p.at(T!['{']) { - enum_variant_list(p); + variant_list(p); } else { p.error("expected `{`") } m.complete(p, ENUM); } -pub(crate) fn enum_variant_list(p: &mut Parser) { +pub(crate) fn variant_list(p: &mut Parser) { assert!(p.at(T!['{'])); let m = p.start(); p.bump(T!['{']); @@ -77,12 +77,12 @@ pub(crate) fn enum_variant_list(p: &mut Parser) { continue; } let var = p.start(); - attributes::outer_attributes(p); + attributes::outer_attrs(p); if p.at(IDENT) { name(p); match p.current() { - T!['{'] => record_field_def_list(p), - T!['('] => tuple_field_def_list(p), + T!['{'] => record_field_list(p), + T!['('] => tuple_field_list(p), _ => (), } @@ -104,7 +104,7 @@ pub(crate) fn enum_variant_list(p: &mut Parser) { m.complete(p, VARIANT_LIST); } -pub(crate) fn record_field_def_list(p: &mut Parser) { +pub(crate) fn record_field_list(p: &mut Parser) { assert!(p.at(T!['{'])); let m = p.start(); p.bump(T!['{']); @@ -128,7 +128,7 @@ pub(crate) fn record_field_def_list(p: &mut Parser) { // #[serde(with = "url_serde")] // pub uri: Uri, // } - attributes::outer_attributes(p); + attributes::outer_attrs(p); opt_visibility(p); if p.at(IDENT) { name(p); @@ -142,7 +142,7 @@ pub(crate) fn record_field_def_list(p: &mut Parser) { } } -fn tuple_field_def_list(p: &mut Parser) { +fn tuple_field_list(p: &mut Parser) { assert!(p.at(T!['('])); let m = p.start(); if !p.expect(T!['(']) { @@ -159,7 +159,7 @@ fn tuple_field_def_list(p: &mut Parser) { // enum S { // Uri(#[serde(with = "url_serde")] Uri), // } - attributes::outer_attributes(p); + attributes::outer_attrs(p); opt_visibility(p); if !p.at_ts(types::TYPE_FIRST) { p.error("expected a type"); diff --git a/crates/parser/src/grammar/items/consts.rs b/crates/parser/src/grammar/items/consts.rs index 35ad766dce..eb7d1f8281 100644 --- a/crates/parser/src/grammar/items/consts.rs +++ b/crates/parser/src/grammar/items/consts.rs @@ -2,11 +2,11 @@ use super::*; -pub(super) fn static_def(p: &mut Parser, m: Marker) { +pub(super) fn static_(p: &mut Parser, m: Marker) { const_or_static(p, m, T![static], STATIC) } -pub(super) fn const_def(p: &mut Parser, m: Marker) { +pub(super) fn konst(p: &mut Parser, m: Marker) { const_or_static(p, m, T![const], CONST) } diff --git a/crates/parser/src/grammar/items/traits.rs b/crates/parser/src/grammar/items/traits.rs index 751ce65f2d..8394020daf 100644 --- a/crates/parser/src/grammar/items/traits.rs +++ b/crates/parser/src/grammar/items/traits.rs @@ -5,11 +5,11 @@ use super::*; // test trait_item // trait T: Hash + Clone where U: Copy {} // trait X: Hash + Clone where U: Copy {} -pub(super) fn trait_def(p: &mut Parser) { +pub(super) fn trait_(p: &mut Parser) { assert!(p.at(T![trait])); p.bump(T![trait]); name_r(p, ITEM_RECOVERY_SET); - type_params::opt_type_param_list(p); + type_params::opt_generic_param_list(p); // test trait_alias // trait Z = T; // trait Z = T where U: Copy; @@ -25,41 +25,19 @@ pub(super) fn trait_def(p: &mut Parser) { } type_params::opt_where_clause(p); if p.at(T!['{']) { - trait_item_list(p); + assoc_item_list(p); } else { p.error("expected `{`"); } } -// test trait_item_list -// impl F { -// type A: Clone; -// const B: i32; -// fn foo() {} -// fn bar(&self); -// } -pub(crate) fn trait_item_list(p: &mut Parser) { - assert!(p.at(T!['{'])); - let m = p.start(); - p.bump(T!['{']); - while !p.at(EOF) && !p.at(T!['}']) { - if p.at(T!['{']) { - error_block(p, "expected an item"); - continue; - } - item_or_macro(p, true); - } - p.expect(T!['}']); - m.complete(p, ASSOC_ITEM_LIST); -} - // test impl_def // impl Foo {} -pub(super) fn impl_def(p: &mut Parser) { +pub(super) fn impl_(p: &mut Parser) { assert!(p.at(T![impl])); p.bump(T![impl]); if choose_type_params_over_qpath(p) { - type_params::opt_type_param_list(p); + type_params::opt_generic_param_list(p); } // FIXME: never type @@ -74,7 +52,7 @@ pub(super) fn impl_def(p: &mut Parser) { } type_params::opt_where_clause(p); if p.at(T!['{']) { - impl_item_list(p); + assoc_item_list(p); } else { p.error("expected `{`"); } @@ -87,7 +65,7 @@ pub(super) fn impl_def(p: &mut Parser) { // fn foo() {} // fn bar(&self) {} // } -pub(crate) fn impl_item_list(p: &mut Parser) { +pub(crate) fn assoc_item_list(p: &mut Parser) { assert!(p.at(T!['{'])); let m = p.start(); p.bump(T!['{']); @@ -97,7 +75,7 @@ pub(crate) fn impl_item_list(p: &mut Parser) { // //! This is a doc comment // #![doc("This is also a doc comment")] // } - attributes::inner_attributes(p); + attributes::inner_attrs(p); while !p.at(EOF) && !p.at(T!['}']) { if p.at(T!['{']) { diff --git a/crates/parser/src/grammar/items/use_item.rs b/crates/parser/src/grammar/items/use_item.rs index 8e836a77e1..20e6a13cf9 100644 --- a/crates/parser/src/grammar/items/use_item.rs +++ b/crates/parser/src/grammar/items/use_item.rs @@ -2,7 +2,7 @@ use super::*; -pub(super) fn use_item(p: &mut Parser, m: Marker) { +pub(super) fn use_(p: &mut Parser, m: Marker) { assert!(p.at(T![use])); p.bump(T![use]); use_tree(p, true); @@ -80,7 +80,7 @@ fn use_tree(p: &mut Parser, top_level: bool) { // running::out::of::synonyms::for_::different::* // }; // use Trait as _; - opt_alias(p); + opt_rename(p); } T![:] if p.at(T![::]) => { p.bump(T![::]); diff --git a/crates/parser/src/grammar/params.rs b/crates/parser/src/grammar/params.rs index f0da173cc1..a665ffc133 100644 --- a/crates/parser/src/grammar/params.rs +++ b/crates/parser/src/grammar/params.rs @@ -47,20 +47,20 @@ fn list_(p: &mut Parser, flavor: Flavor) { if let FnDef = flavor { // test self_param_outer_attr // fn f(#[must_use] self) {} - attributes::outer_attributes(p); + attributes::outer_attrs(p); opt_self_param(p); } while !p.at(EOF) && !p.at(ket) { // test param_outer_arg // fn f(#[attr1] pat: Type) {} - attributes::outer_attributes(p); + attributes::outer_attrs(p); - if !p.at_ts(VALUE_PARAMETER_FIRST) { + if !p.at_ts(PARAM_FIRST) { p.error("expected value parameter"); break; } - let param = value_parameter(p, flavor); + let param = param(p, flavor); if !p.at(ket) { p.expect(T![,]); } @@ -73,11 +73,11 @@ fn list_(p: &mut Parser, flavor: Flavor) { m.complete(p, PARAM_LIST); } -const VALUE_PARAMETER_FIRST: TokenSet = patterns::PATTERN_FIRST.union(types::TYPE_FIRST); +const PARAM_FIRST: TokenSet = patterns::PATTERN_FIRST.union(types::TYPE_FIRST); struct Variadic(bool); -fn value_parameter(p: &mut Parser, flavor: Flavor) -> Variadic { +fn param(p: &mut Parser, flavor: Flavor) -> Variadic { let mut res = Variadic(false); let m = p.start(); match flavor { diff --git a/crates/parser/src/grammar/paths.rs b/crates/parser/src/grammar/paths.rs index b503af1dc9..52562afa41 100644 --- a/crates/parser/src/grammar/paths.rs +++ b/crates/parser/src/grammar/paths.rs @@ -105,11 +105,11 @@ fn opt_path_type_args(p: &mut Parser, mode: Mode) { // type F = Box ()>; if p.at(T!['(']) { params::param_list_fn_trait(p); - opt_fn_ret_type(p); + opt_ret_type(p); } else { - type_args::opt_type_arg_list(p, false) + type_args::opt_generic_arg_list(p, false) } } - Mode::Expr => type_args::opt_type_arg_list(p, true), + Mode::Expr => type_args::opt_generic_arg_list(p, true), } } diff --git a/crates/parser/src/grammar/patterns.rs b/crates/parser/src/grammar/patterns.rs index 716bdc9784..07b1d6dd53 100644 --- a/crates/parser/src/grammar/patterns.rs +++ b/crates/parser/src/grammar/patterns.rs @@ -79,13 +79,13 @@ const PAT_RECOVERY_SET: TokenSet = fn atom_pat(p: &mut Parser, recovery_set: TokenSet) -> Option { let m = match p.nth(0) { T![box] => box_pat(p), - T![ref] | T![mut] => bind_pat(p, true), + T![ref] | T![mut] => ident_pat(p, true), IDENT => match p.nth(1) { // Checks the token after an IDENT to see if a pattern is a path (Struct { .. }) or macro // (T![x]). T!['('] | T!['{'] | T![!] => path_or_macro_pat(p), T![:] if p.nth_at(1, T![::]) => path_or_macro_pat(p), - _ => bind_pat(p, true), + _ => ident_pat(p, true), }, // test type_path_in_pattern @@ -93,8 +93,8 @@ fn atom_pat(p: &mut Parser, recovery_set: TokenSet) -> Option { _ if paths::is_path_start(p) => path_or_macro_pat(p), _ if is_literal_pat_start(p) => literal_pat(p), - T![.] if p.at(T![..]) => dot_dot_pat(p), - T![_] => placeholder_pat(p), + T![.] if p.at(T![..]) => rest_pat(p), + T![_] => wildcard_pat(p), T![&] => ref_pat(p), T!['('] => tuple_pat(p), T!['['] => slice_pat(p), @@ -149,7 +149,7 @@ fn path_or_macro_pat(p: &mut Parser) -> CompletedMarker { TUPLE_STRUCT_PAT } T!['{'] => { - record_field_pat_list(p); + record_pat_field_list(p); RECORD_PAT } // test marco_pat @@ -186,7 +186,7 @@ fn tuple_pat_fields(p: &mut Parser) { // let S { h: _, ..} = (); // let S { h: _, } = (); // } -fn record_field_pat_list(p: &mut Parser) { +fn record_pat_field_list(p: &mut Parser) { assert!(p.at(T!['{'])); let m = p.start(); p.bump(T!['{']); @@ -214,7 +214,7 @@ fn record_field_pat_list(p: &mut Parser) { box_pat(p); } _ => { - bind_pat(p, false); + ident_pat(p, false); } } m.complete(p, RECORD_PAT_FIELD); @@ -230,7 +230,7 @@ fn record_field_pat_list(p: &mut Parser) { // test placeholder_pat // fn main() { let _ = (); } -fn placeholder_pat(p: &mut Parser) -> CompletedMarker { +fn wildcard_pat(p: &mut Parser) -> CompletedMarker { assert!(p.at(T![_])); let m = p.start(); p.bump(T![_]); @@ -263,7 +263,7 @@ fn placeholder_pat(p: &mut Parser) -> CompletedMarker { // let [head, .., mid, tail @ ..] = (); // let [head, .., mid, .., cons] = (); // } -fn dot_dot_pat(p: &mut Parser) -> CompletedMarker { +fn rest_pat(p: &mut Parser) -> CompletedMarker { assert!(p.at(T![..])); let m = p.start(); p.bump(T![..]); @@ -353,7 +353,7 @@ fn pat_list(p: &mut Parser, ket: SyntaxKind) { // let e @ _ = (); // let ref mut f @ g @ _ = (); // } -fn bind_pat(p: &mut Parser, with_at: bool) -> CompletedMarker { +fn ident_pat(p: &mut Parser, with_at: bool) -> CompletedMarker { let m = p.start(); p.eat(T![ref]); p.eat(T![mut]); diff --git a/crates/parser/src/grammar/type_args.rs b/crates/parser/src/grammar/type_args.rs index aef7cd6fbb..f2d34a7499 100644 --- a/crates/parser/src/grammar/type_args.rs +++ b/crates/parser/src/grammar/type_args.rs @@ -2,7 +2,7 @@ use super::*; -pub(super) fn opt_type_arg_list(p: &mut Parser, colon_colon_required: bool) { +pub(super) fn opt_generic_arg_list(p: &mut Parser, colon_colon_required: bool) { let m; if p.at(T![::]) && p.nth(2) == T![<] { m = p.start(); @@ -16,7 +16,7 @@ pub(super) fn opt_type_arg_list(p: &mut Parser, colon_colon_required: bool) { } while !p.at(EOF) && !p.at(T![>]) { - type_arg(p); + generic_arg(p); if !p.at(T![>]) && !p.expect(T![,]) { break; } @@ -27,7 +27,7 @@ pub(super) fn opt_type_arg_list(p: &mut Parser, colon_colon_required: bool) { // test type_arg // type A = B<'static, i32, 1, { 2 }, Item=u64>; -fn type_arg(p: &mut Parser) { +fn generic_arg(p: &mut Parser) { let m = p.start(); match p.current() { LIFETIME => { diff --git a/crates/parser/src/grammar/type_params.rs b/crates/parser/src/grammar/type_params.rs index 90dabb4c0f..bc7d8d7244 100644 --- a/crates/parser/src/grammar/type_params.rs +++ b/crates/parser/src/grammar/type_params.rs @@ -2,14 +2,14 @@ use super::*; -pub(super) fn opt_type_param_list(p: &mut Parser) { +pub(super) fn opt_generic_param_list(p: &mut Parser) { if !p.at(T![<]) { return; } - type_param_list(p); + generic_param_list(p); } -fn type_param_list(p: &mut Parser) { +fn generic_param_list(p: &mut Parser) { assert!(p.at(T![<])); let m = p.start(); p.bump(T![<]); @@ -20,12 +20,12 @@ fn type_param_list(p: &mut Parser) { // test generic_lifetime_type_attribute // fn foo<#[derive(Lifetime)] 'a, #[derive(Type)] T>(_: &'a T) { // } - attributes::outer_attributes(p); + attributes::outer_attrs(p); match p.current() { LIFETIME => lifetime_param(p, m), IDENT => type_param(p, m), - CONST_KW => type_const_param(p, m), + CONST_KW => const_param(p, m), _ => { m.abandon(p); p.err_and_bump("expected type parameter") @@ -65,7 +65,7 @@ fn type_param(p: &mut Parser, m: Marker) { // test const_param // struct S; -fn type_const_param(p: &mut Parser, m: Marker) { +fn const_param(p: &mut Parser, m: Marker) { assert!(p.at(CONST_KW)); p.bump(T![const]); name(p); diff --git a/crates/parser/src/grammar/types.rs b/crates/parser/src/grammar/types.rs index 0aa173a52b..c876545f44 100644 --- a/crates/parser/src/grammar/types.rs +++ b/crates/parser/src/grammar/types.rs @@ -32,11 +32,11 @@ fn type_with_bounds_cond(p: &mut Parser, allow_bounds: bool) { match p.current() { T!['('] => paren_or_tuple_type(p), T![!] => never_type(p), - T![*] => pointer_type(p), + T![*] => ptr_type(p), T!['['] => array_or_slice_type(p), - T![&] => reference_type(p), - T![_] => placeholder_type(p), - T![fn] | T![unsafe] | T![extern] => fn_pointer_type(p), + T![&] => ref_type(p), + T![_] => infer_type(p), + T![fn] | T![unsafe] | T![extern] => fn_ptr_type(p), T![for] => for_type(p), T![impl] => impl_trait_type(p), T![dyn] => dyn_trait_type(p), @@ -96,7 +96,7 @@ fn never_type(p: &mut Parser) { m.complete(p, NEVER_TYPE); } -fn pointer_type(p: &mut Parser) { +fn ptr_type(p: &mut Parser) { assert!(p.at(T![*])); let m = p.start(); p.bump(T![*]); @@ -156,7 +156,7 @@ fn array_or_slice_type(p: &mut Parser) { // type A = &(); // type B = &'static (); // type C = &mut (); -fn reference_type(p: &mut Parser) { +fn ref_type(p: &mut Parser) { assert!(p.at(T![&])); let m = p.start(); p.bump(T![&]); @@ -168,7 +168,7 @@ fn reference_type(p: &mut Parser) { // test placeholder_type // type Placeholder = _; -fn placeholder_type(p: &mut Parser) { +fn infer_type(p: &mut Parser) { assert!(p.at(T![_])); let m = p.start(); p.bump(T![_]); @@ -180,7 +180,7 @@ fn placeholder_type(p: &mut Parser) { // type B = unsafe fn(); // type C = unsafe extern "C" fn(); // type D = extern "C" fn ( u8 , ... ) -> u8; -fn fn_pointer_type(p: &mut Parser) { +fn fn_ptr_type(p: &mut Parser) { let m = p.start(); p.eat(T![unsafe]); if p.at(T![extern]) { @@ -200,7 +200,7 @@ fn fn_pointer_type(p: &mut Parser) { } // test fn_pointer_type_with_ret // type F = fn() -> (); - opt_fn_ret_type(p); + opt_ret_type(p); m.complete(p, FN_PTR_TYPE); } @@ -208,7 +208,7 @@ pub(super) fn for_binder(p: &mut Parser) { assert!(p.at(T![for])); p.bump(T![for]); if p.at(T![<]) { - type_params::opt_type_param_list(p); + type_params::opt_generic_param_list(p); } else { p.error("expected `<`"); } diff --git a/crates/syntax/test_data/parser/inline/ok/0001_trait_item_list.rast b/crates/syntax/test_data/parser/inline/ok/0001_trait_item_list.rast deleted file mode 100644 index c7289e4008..0000000000 --- a/crates/syntax/test_data/parser/inline/ok/0001_trait_item_list.rast +++ /dev/null @@ -1,71 +0,0 @@ -SOURCE_FILE@0..83 - IMPL@0..82 - IMPL_KW@0..4 "impl" - WHITESPACE@4..5 " " - PATH_TYPE@5..6 - PATH@5..6 - PATH_SEGMENT@5..6 - NAME_REF@5..6 - IDENT@5..6 "F" - WHITESPACE@6..7 " " - ASSOC_ITEM_LIST@7..82 - L_CURLY@7..8 "{" - WHITESPACE@8..13 "\n " - TYPE_ALIAS@13..27 - TYPE_KW@13..17 "type" - WHITESPACE@17..18 " " - NAME@18..19 - IDENT@18..19 "A" - COLON@19..20 ":" - WHITESPACE@20..21 " " - TYPE_BOUND_LIST@21..26 - TYPE_BOUND@21..26 - PATH_TYPE@21..26 - PATH@21..26 - PATH_SEGMENT@21..26 - NAME_REF@21..26 - IDENT@21..26 "Clone" - SEMICOLON@26..27 ";" - WHITESPACE@27..32 "\n " - CONST@32..45 - CONST_KW@32..37 "const" - WHITESPACE@37..38 " " - NAME@38..39 - IDENT@38..39 "B" - COLON@39..40 ":" - WHITESPACE@40..41 " " - PATH_TYPE@41..44 - PATH@41..44 - PATH_SEGMENT@41..44 - NAME_REF@41..44 - IDENT@41..44 "i32" - SEMICOLON@44..45 ";" - WHITESPACE@45..50 "\n " - FN@50..61 - FN_KW@50..52 "fn" - WHITESPACE@52..53 " " - NAME@53..56 - IDENT@53..56 "foo" - PARAM_LIST@56..58 - L_PAREN@56..57 "(" - R_PAREN@57..58 ")" - WHITESPACE@58..59 " " - BLOCK_EXPR@59..61 - L_CURLY@59..60 "{" - R_CURLY@60..61 "}" - WHITESPACE@61..66 "\n " - FN@66..80 - FN_KW@66..68 "fn" - WHITESPACE@68..69 " " - NAME@69..72 - IDENT@69..72 "bar" - PARAM_LIST@72..79 - L_PAREN@72..73 "(" - SELF_PARAM@73..78 - AMP@73..74 "&" - SELF_KW@74..78 "self" - R_PAREN@78..79 ")" - SEMICOLON@79..80 ";" - WHITESPACE@80..81 "\n" - R_CURLY@81..82 "}" - WHITESPACE@82..83 "\n" diff --git a/crates/syntax/test_data/parser/inline/ok/0001_trait_item_list.rs b/crates/syntax/test_data/parser/inline/ok/0001_trait_item_list.rs deleted file mode 100644 index a5ec3239f8..0000000000 --- a/crates/syntax/test_data/parser/inline/ok/0001_trait_item_list.rs +++ /dev/null @@ -1,6 +0,0 @@ -impl F { - type A: Clone; - const B: i32; - fn foo() {} - fn bar(&self); -} From 0e1cda3079eb9936dcf8acec3e47bad48c5ccc58 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 18:06:14 +0200 Subject: [PATCH 107/119] Minor --- .../ide/src/completion/completion_context.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/crates/ide/src/completion/completion_context.rs b/crates/ide/src/completion/completion_context.rs index 047ecd9d77..09440334d3 100644 --- a/crates/ide/src/completion/completion_context.rs +++ b/crates/ide/src/completion/completion_context.rs @@ -9,15 +9,21 @@ use syntax::{ SyntaxKind::*, SyntaxNode, SyntaxToken, TextRange, TextSize, }; +use test_utils::mark; use text_edit::Indel; -use super::patterns::{ - has_bind_pat_parent, has_block_expr_parent, has_impl_as_prev_sibling, has_impl_parent, - has_item_list_or_source_file_parent, has_ref_parent, has_trait_as_prev_sibling, - has_trait_parent, if_is_prev, is_in_loop_body, is_match_arm, unsafe_is_prev, +use crate::{ + call_info::ActiveParameter, + completion::{ + patterns::{ + has_bind_pat_parent, has_block_expr_parent, has_impl_as_prev_sibling, has_impl_parent, + has_item_list_or_source_file_parent, has_ref_parent, has_trait_as_prev_sibling, + has_trait_parent, if_is_prev, is_in_loop_body, is_match_arm, unsafe_is_prev, + }, + CompletionConfig, + }, + FilePosition, }; -use crate::{call_info::ActiveParameter, completion::CompletionConfig, FilePosition}; -use test_utils::mark; /// `CompletionContext` is created early during completion to figure out, where /// exactly is the cursor, syntax-wise. From ef462ed6af7ae8e0d30894baefe6ba1ff49aab8f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 18:28:23 +0200 Subject: [PATCH 108/119] Better recovery in `use foo::;` --- crates/parser/src/grammar/items.rs | 16 ++++++++++++++-- .../parser/inline/err/0015_empty_segment.rast | 8 +++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/crates/parser/src/grammar/items.rs b/crates/parser/src/grammar/items.rs index b2f7cc21f6..8fd8f3b800 100644 --- a/crates/parser/src/grammar/items.rs +++ b/crates/parser/src/grammar/items.rs @@ -27,8 +27,20 @@ pub(super) fn mod_contents(p: &mut Parser, stop_on_r_curly: bool) { } pub(super) const ITEM_RECOVERY_SET: TokenSet = token_set![ - FN_KW, STRUCT_KW, ENUM_KW, IMPL_KW, TRAIT_KW, CONST_KW, STATIC_KW, LET_KW, MOD_KW, PUB_KW, - CRATE_KW, USE_KW, MACRO_KW + FN_KW, + STRUCT_KW, + ENUM_KW, + IMPL_KW, + TRAIT_KW, + CONST_KW, + STATIC_KW, + LET_KW, + MOD_KW, + PUB_KW, + CRATE_KW, + USE_KW, + MACRO_KW, + T![;], ]; pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool) { diff --git a/crates/syntax/test_data/parser/inline/err/0015_empty_segment.rast b/crates/syntax/test_data/parser/inline/err/0015_empty_segment.rast index 2f59d0606c..e872526d90 100644 --- a/crates/syntax/test_data/parser/inline/err/0015_empty_segment.rast +++ b/crates/syntax/test_data/parser/inline/err/0015_empty_segment.rast @@ -2,14 +2,12 @@ SOURCE_FILE@0..13 USE@0..12 USE_KW@0..3 "use" WHITESPACE@3..4 " " - USE_TREE@4..12 - PATH@4..12 + USE_TREE@4..11 + PATH@4..11 PATH@4..9 PATH_SEGMENT@4..9 CRATE_KW@4..9 "crate" COLON2@9..11 "::" - ERROR@11..12 - SEMICOLON@11..12 ";" + SEMICOLON@11..12 ";" WHITESPACE@12..13 "\n" error 11..11: expected identifier -error 12..12: expected SEMICOLON From 947a27b797cd87d5650477441c9c3c03b6364626 Mon Sep 17 00:00:00 2001 From: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> Date: Thu, 13 Aug 2020 22:13:34 +0200 Subject: [PATCH 109/119] display correctly 'impl Trait + Trait' #4814 Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> --- crates/hir_ty/src/display.rs | 1 + crates/ide/src/hover.rs | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/crates/hir_ty/src/display.rs b/crates/hir_ty/src/display.rs index 19770e609a..64b68014d8 100644 --- a/crates/hir_ty/src/display.rs +++ b/crates/hir_ty/src/display.rs @@ -511,6 +511,7 @@ fn write_bounds_like_dyn_trait( GenericPredicate::Implemented(trait_ref) => { if angle_open { write!(f, ">")?; + angle_open = false; } if !first { write!(f, " + ")?; diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs index 331aa4db0c..300c00edc8 100644 --- a/crates/ide/src/hover.rs +++ b/crates/ide/src/hover.rs @@ -766,6 +766,25 @@ fn main() { ) } + #[test] + fn hover_for_param_with_multiple_traits() { + check( + r#"trait Deref { + type Target: ?Sized; + } + trait DerefMut { + type Target: ?Sized; + } + fn f(_x<|>: impl Deref + DerefMut) {}"#, + expect![[r#" + *_x* + ```rust + impl Deref + DerefMut + ``` + "#]], + ) + } + #[test] fn test_hover_infer_associated_method_result() { check( From 86f89d9b31fc7e4fd9300570e6b6304c749caa6c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 22:41:55 +0200 Subject: [PATCH 110/119] Remove Hygiene from completion --- crates/ide/src/completion/complete_keyword.rs | 29 +++--- .../src/completion/complete_qualified_path.rs | 4 +- .../ide/src/completion/completion_context.rs | 89 +++++++++++-------- 3 files changed, 64 insertions(+), 58 deletions(-) diff --git a/crates/ide/src/completion/complete_keyword.rs b/crates/ide/src/completion/complete_keyword.rs index a80708935e..22ada3cf29 100644 --- a/crates/ide/src/completion/complete_keyword.rs +++ b/crates/ide/src/completion/complete_keyword.rs @@ -10,30 +10,21 @@ use crate::completion::{ pub(super) fn complete_use_tree_keyword(acc: &mut Completions, ctx: &CompletionContext) { // complete keyword "crate" in use stmt let source_range = ctx.source_range(); - match (ctx.use_item_syntax.as_ref(), ctx.path_prefix.as_ref()) { - (Some(_), None) => { + + if ctx.use_item_syntax.is_some() { + if ctx.path_qual.is_none() { CompletionItem::new(CompletionKind::Keyword, source_range, "crate::") .kind(CompletionItemKind::Keyword) .insert_text("crate::") .add_to(acc); - CompletionItem::new(CompletionKind::Keyword, source_range, "self") - .kind(CompletionItemKind::Keyword) - .add_to(acc); - CompletionItem::new(CompletionKind::Keyword, source_range, "super::") - .kind(CompletionItemKind::Keyword) - .insert_text("super::") - .add_to(acc); } - (Some(_), Some(_)) => { - CompletionItem::new(CompletionKind::Keyword, source_range, "self") - .kind(CompletionItemKind::Keyword) - .add_to(acc); - CompletionItem::new(CompletionKind::Keyword, source_range, "super::") - .kind(CompletionItemKind::Keyword) - .insert_text("super::") - .add_to(acc); - } - _ => {} + CompletionItem::new(CompletionKind::Keyword, source_range, "self") + .kind(CompletionItemKind::Keyword) + .add_to(acc); + CompletionItem::new(CompletionKind::Keyword, source_range, "super::") + .kind(CompletionItemKind::Keyword) + .insert_text("super::") + .add_to(acc); } // Suggest .await syntax for types that implement Future trait diff --git a/crates/ide/src/completion/complete_qualified_path.rs b/crates/ide/src/completion/complete_qualified_path.rs index cb7dd23c18..74794dc88b 100644 --- a/crates/ide/src/completion/complete_qualified_path.rs +++ b/crates/ide/src/completion/complete_qualified_path.rs @@ -8,7 +8,7 @@ use test_utils::mark; use crate::completion::{CompletionContext, Completions}; pub(super) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionContext) { - let path = match &ctx.path_prefix { + let path = match &ctx.path_qual { Some(path) => path.clone(), None => return, }; @@ -19,7 +19,7 @@ pub(super) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon let context_module = ctx.scope.module(); - let resolution = match ctx.scope.resolve_hir_path_qualifier(&path) { + let resolution = match ctx.sema.resolve_path(&path) { Some(res) => res, None => return, }; diff --git a/crates/ide/src/completion/completion_context.rs b/crates/ide/src/completion/completion_context.rs index 09440334d3..3857dce672 100644 --- a/crates/ide/src/completion/completion_context.rs +++ b/crates/ide/src/completion/completion_context.rs @@ -56,7 +56,7 @@ pub(crate) struct CompletionContext<'a> { /// A single-indent path, like `foo`. `::foo` should not be considered a trivial path. pub(super) is_trivial_path: bool, /// If not a trivial path, the prefix (qualifier). - pub(super) path_prefix: Option, + pub(super) path_qual: Option, pub(super) after_if: bool, /// `true` if we are a statement or a last expr in the block. pub(super) can_be_stmt: bool, @@ -137,7 +137,7 @@ impl<'a> CompletionContext<'a> { is_param: false, is_pat_binding_or_const: false, is_trivial_path: false, - path_prefix: None, + path_qual: None, after_if: false, can_be_stmt: false, is_expr: false, @@ -385,48 +385,54 @@ impl<'a> CompletionContext<'a> { self.is_path_type = path.syntax().parent().and_then(ast::PathType::cast).is_some(); self.has_type_args = segment.generic_arg_list().is_some(); - let hygiene = hir::Hygiene::new(self.db, self.position.file_id.into()); - if let Some(path) = hir::Path::from_src(path.clone(), &hygiene) { - if let Some(path_prefix) = path.qualifier() { - self.path_prefix = Some(path_prefix); + if let Some(path) = path_or_use_tree_qualifier(&path) { + self.path_qual = path + .segment() + .and_then(|it| { + find_node_with_range::( + original_file, + it.syntax().text_range(), + ) + }) + .map(|it| it.parent_path()); + return; + } + + if let Some(segment) = path.segment() { + if segment.coloncolon_token().is_some() { return; } } - if path.qualifier().is_none() { - self.is_trivial_path = true; + self.is_trivial_path = true; - // Find either enclosing expr statement (thing with `;`) or a - // block. If block, check that we are the last expr. - self.can_be_stmt = name_ref - .syntax() - .ancestors() - .find_map(|node| { - if let Some(stmt) = ast::ExprStmt::cast(node.clone()) { - return Some( - stmt.syntax().text_range() == name_ref.syntax().text_range(), - ); - } - if let Some(block) = ast::BlockExpr::cast(node) { - return Some( - block.expr().map(|e| e.syntax().text_range()) - == Some(name_ref.syntax().text_range()), - ); - } - None - }) - .unwrap_or(false); - self.is_expr = path.syntax().parent().and_then(ast::PathExpr::cast).is_some(); + // Find either enclosing expr statement (thing with `;`) or a + // block. If block, check that we are the last expr. + self.can_be_stmt = name_ref + .syntax() + .ancestors() + .find_map(|node| { + if let Some(stmt) = ast::ExprStmt::cast(node.clone()) { + return Some(stmt.syntax().text_range() == name_ref.syntax().text_range()); + } + if let Some(block) = ast::BlockExpr::cast(node) { + return Some( + block.expr().map(|e| e.syntax().text_range()) + == Some(name_ref.syntax().text_range()), + ); + } + None + }) + .unwrap_or(false); + self.is_expr = path.syntax().parent().and_then(ast::PathExpr::cast).is_some(); - if let Some(off) = name_ref.syntax().text_range().start().checked_sub(2.into()) { - if let Some(if_expr) = - self.sema.find_node_at_offset_with_macros::(original_file, off) + if let Some(off) = name_ref.syntax().text_range().start().checked_sub(2.into()) { + if let Some(if_expr) = + self.sema.find_node_at_offset_with_macros::(original_file, off) + { + if if_expr.syntax().text_range().end() < name_ref.syntax().text_range().start() { - if if_expr.syntax().text_range().end() - < name_ref.syntax().text_range().start() - { - self.after_if = true; - } + self.after_if = true; } } } @@ -469,3 +475,12 @@ fn is_node(node: &SyntaxNode) -> bool { Some(n) => n.syntax().text_range() == node.text_range(), } } + +fn path_or_use_tree_qualifier(path: &ast::Path) -> Option { + if let Some(qual) = path.qualifier() { + return Some(qual); + } + let use_tree_list = path.syntax().ancestors().find_map(ast::UseTreeList::cast)?; + let use_tree = use_tree_list.syntax().parent().and_then(ast::UseTree::cast)?; + use_tree.path() +} From 9664c57e60ec5662b3e8b063324d9ab7879d5570 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 23:52:14 +0200 Subject: [PATCH 111/119] Make hygiene private to hir --- crates/hir/src/code_model.rs | 7 +++++++ crates/hir/src/lib.rs | 8 ++++++-- crates/hir/src/semantics.rs | 16 +++++++++++++--- crates/ssr/src/resolving.rs | 24 +++++++++++++----------- 4 files changed, 39 insertions(+), 16 deletions(-) diff --git a/crates/hir/src/code_model.rs b/crates/hir/src/code_model.rs index 8ffb9e99b0..5dc3ae3b19 100644 --- a/crates/hir/src/code_model.rs +++ b/crates/hir/src/code_model.rs @@ -883,6 +883,13 @@ where } impl AssocItem { + pub fn name(self, db: &dyn HirDatabase) -> Option { + match self { + AssocItem::Function(it) => Some(it.name(db)), + AssocItem::Const(it) => it.name(db), + AssocItem::TypeAlias(it) => Some(it.name(db)), + } + } pub fn module(self, db: &dyn HirDatabase) -> Module { match self { AssocItem::Function(f) => f.module(db), diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 24a0f6b4b1..4ae2bd0855 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -52,8 +52,12 @@ pub use hir_def::{ type_ref::{Mutability, TypeRef}, }; pub use hir_expand::{ - hygiene::Hygiene, name::Name, HirFileId, InFile, MacroCallId, MacroCallLoc, - MacroDefId, /* FIXME */ + name::Name, HirFileId, InFile, MacroCallId, MacroCallLoc, /* FIXME */ MacroDefId, MacroFile, Origin, }; pub use hir_ty::display::HirDisplay; + +// These are negative re-exports: pub using these names is forbidden, they +// should remain private to hir internals. +#[allow(unused)] +use hir_expand::hygiene::Hygiene; diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs index 1467d825d9..d8beac98a6 100644 --- a/crates/hir/src/semantics.rs +++ b/crates/hir/src/semantics.rs @@ -502,18 +502,19 @@ impl<'db> SemanticsImpl<'db> { fn scope(&self, node: &SyntaxNode) -> SemanticsScope<'db> { let node = self.find_file(node.clone()); let resolver = self.analyze2(node.as_ref(), None).resolver; - SemanticsScope { db: self.db, resolver } + SemanticsScope { db: self.db, file_id: node.file_id, resolver } } fn scope_at_offset(&self, node: &SyntaxNode, offset: TextSize) -> SemanticsScope<'db> { let node = self.find_file(node.clone()); let resolver = self.analyze2(node.as_ref(), Some(offset)).resolver; - SemanticsScope { db: self.db, resolver } + SemanticsScope { db: self.db, file_id: node.file_id, resolver } } fn scope_for_def(&self, def: Trait) -> SemanticsScope<'db> { + let file_id = self.db.lookup_intern_trait(def.id).id.file_id; let resolver = def.id.resolver(self.db.upcast()); - SemanticsScope { db: self.db, resolver } + SemanticsScope { db: self.db, file_id, resolver } } fn analyze(&self, node: &SyntaxNode) -> SourceAnalyzer { @@ -709,6 +710,7 @@ fn find_root(node: &SyntaxNode) -> SyntaxNode { #[derive(Debug)] pub struct SemanticsScope<'a> { pub db: &'a dyn HirDatabase, + file_id: HirFileId, resolver: Resolver, } @@ -752,6 +754,14 @@ impl<'a> SemanticsScope<'a> { }) } + /// Resolve a path as-if it was written at the given scope. This is + /// necessary a heuristic, as it doesn't take hygiene into account. + pub fn resolve_hypothetical(&self, path: &ast::Path) -> Option { + let hygiene = Hygiene::new(self.db.upcast(), self.file_id); + let path = Path::from_src(path.clone(), &hygiene)?; + self.resolve_hir_path(&path) + } + pub fn resolve_hir_path(&self, path: &Path) -> Option { resolve_hir_path(self.db, &self.resolver, path) } diff --git a/crates/ssr/src/resolving.rs b/crates/ssr/src/resolving.rs index 020fd79941..4441fb426a 100644 --- a/crates/ssr/src/resolving.rs +++ b/crates/ssr/src/resolving.rs @@ -10,7 +10,6 @@ use test_utils::mark; pub(crate) struct ResolutionScope<'db> { scope: hir::SemanticsScope<'db>, - hygiene: hir::Hygiene, node: SyntaxNode, } @@ -201,11 +200,7 @@ impl<'db> ResolutionScope<'db> { .unwrap_or_else(|| file.syntax().clone()); let node = pick_node_for_resolution(node); let scope = sema.scope(&node); - ResolutionScope { - scope, - hygiene: hir::Hygiene::new(sema.db, resolve_context.file_id.into()), - node, - } + ResolutionScope { scope, node } } /// Returns the function in which SSR was invoked, if any. @@ -214,24 +209,31 @@ impl<'db> ResolutionScope<'db> { } fn resolve_path(&self, path: &ast::Path) -> Option { - let hir_path = hir::Path::from_src(path.clone(), &self.hygiene)?; // First try resolving the whole path. This will work for things like // `std::collections::HashMap`, but will fail for things like // `std::collections::HashMap::new`. - if let Some(resolution) = self.scope.resolve_hir_path(&hir_path) { + if let Some(resolution) = self.scope.resolve_hypothetical(&path) { return Some(resolution); } // Resolution failed, try resolving the qualifier (e.g. `std::collections::HashMap` and if // that succeeds, then iterate through the candidates on the resolved type with the provided // name. - let resolved_qualifier = self.scope.resolve_hir_path_qualifier(&hir_path.qualifier()?)?; + let resolved_qualifier = self.scope.resolve_hypothetical(&path.qualifier()?)?; if let hir::PathResolution::Def(hir::ModuleDef::Adt(adt)) = resolved_qualifier { + let name = path.segment()?.name_ref()?; adt.ty(self.scope.db).iterate_path_candidates( self.scope.db, self.scope.module()?.krate(), &self.scope.traits_in_scope(), - Some(hir_path.segments().last()?.name), - |_ty, assoc_item| Some(hir::PathResolution::AssocItem(assoc_item)), + None, + |_ty, assoc_item| { + let item_name = assoc_item.name(self.scope.db)?; + if item_name.to_string().as_str() == name.text().as_str() { + Some(hir::PathResolution::AssocItem(assoc_item)) + } else { + None + } + }, ) } else { None From 8fc254597f7351e06b19052933aa01a044583b71 Mon Sep 17 00:00:00 2001 From: Armin Sander Date: Fri, 14 Aug 2020 01:19:46 +0200 Subject: [PATCH 112/119] Sophisticate Windows path encoding --- crates/vfs/src/vfs_path.rs | 139 +++++++++++++++++++++++++++++++++++-- 1 file changed, 132 insertions(+), 7 deletions(-) diff --git a/crates/vfs/src/vfs_path.rs b/crates/vfs/src/vfs_path.rs index 04a42264e8..944a702df0 100644 --- a/crates/vfs/src/vfs_path.rs +++ b/crates/vfs/src/vfs_path.rs @@ -57,23 +57,42 @@ impl VfsPath { }; buf.push(tag); match &self.0 { - VfsPathRepr::PathBuf(it) => { - let path: &std::ffi::OsStr = it.as_os_str(); + VfsPathRepr::PathBuf(path) => { #[cfg(windows)] { - use std::os::windows::ffi::OsStrExt; - for wchar in path.encode_wide() { - buf.extend(wchar.to_le_bytes().iter().copied()); + use windows_paths::Encode; + let components = path.components(); + let mut add_sep = false; + for component in components { + if add_sep { + windows_paths::SEP.encode(buf); + } + let len_before = buf.len(); + match component { + std::path::Component::Prefix(prefix) => { + // kind() returns a normalized and comparable path prefix. + prefix.kind().encode(buf); + } + std::path::Component::RootDir => { + if !add_sep { + component.as_os_str().encode(buf); + } + } + _ => component.as_os_str().encode(buf), + } + + // some components may be encoded empty + add_sep = len_before != buf.len(); } } #[cfg(unix)] { use std::os::unix::ffi::OsStrExt; - buf.extend(path.as_bytes()); + buf.extend(path.as_os_str().as_bytes()); } #[cfg(not(any(windows, unix)))] { - buf.extend(path.to_string_lossy().as_bytes()); + buf.extend(path.as_os_str().to_string_lossy().as_bytes()); } } VfsPathRepr::VirtualPath(VirtualPath(s)) => buf.extend(s.as_bytes()), @@ -81,6 +100,112 @@ impl VfsPath { } } +#[cfg(windows)] +mod windows_paths { + pub trait Encode { + fn encode(&self, buf: &mut Vec); + } + + impl Encode for std::ffi::OsStr { + fn encode(&self, buf: &mut Vec) { + use std::os::windows::ffi::OsStrExt; + for wchar in self.encode_wide() { + buf.extend(wchar.to_le_bytes().iter().copied()); + } + } + } + + impl Encode for u8 { + fn encode(&self, buf: &mut Vec) { + let wide = *self as u16; + buf.extend(wide.to_le_bytes().iter().copied()) + } + } + + impl Encode for &str { + fn encode(&self, buf: &mut Vec) { + debug_assert!(self.is_ascii()); + for b in self.as_bytes() { + b.encode(buf) + } + } + } + + pub const SEP: &str = "\\"; + const VERBATIM: &str = "\\\\?\\"; + const UNC: &str = "UNC"; + const DEVICE: &str = "\\\\.\\"; + const COLON: &str = ":"; + + impl Encode for std::path::Prefix<'_> { + fn encode(&self, buf: &mut Vec) { + match self { + std::path::Prefix::Verbatim(c) => { + VERBATIM.encode(buf); + c.encode(buf); + } + std::path::Prefix::VerbatimUNC(server, share) => { + VERBATIM.encode(buf); + UNC.encode(buf); + SEP.encode(buf); + server.encode(buf); + SEP.encode(buf); + share.encode(buf); + } + std::path::Prefix::VerbatimDisk(d) => { + VERBATIM.encode(buf); + d.encode(buf); + COLON.encode(buf); + } + std::path::Prefix::DeviceNS(device) => { + DEVICE.encode(buf); + device.encode(buf); + } + std::path::Prefix::UNC(server, share) => { + SEP.encode(buf); + SEP.encode(buf); + server.encode(buf); + SEP.encode(buf); + share.encode(buf); + } + std::path::Prefix::Disk(d) => { + d.encode(buf); + COLON.encode(buf); + } + } + } + } + #[test] + fn paths_encoding() { + // drive letter casing agnostic + test_eq("C:/x.rs", "c:/x.rs"); + // separator agnostic + test_eq("C:/x/y.rs", "C:\\x\\y.rs"); + + fn test_eq(a: &str, b: &str) { + let mut b1 = Vec::new(); + let mut b2 = Vec::new(); + vfs(a).encode(&mut b1); + vfs(b).encode(&mut b2); + assert_eq!(b1, b2); + } + } + + #[test] + fn test_sep_root_dir_encoding() { + let mut buf = Vec::new(); + vfs("C:/x/y").encode(&mut buf); + assert_eq!(&buf, &[0, 67, 0, 58, 0, 92, 0, 120, 0, 92, 0, 121, 0]) + } + + #[cfg(test)] + fn vfs(str: &str) -> super::VfsPath { + use super::{AbsPathBuf, VfsPath}; + use std::convert::TryFrom; + VfsPath::from(AbsPathBuf::try_from(str).unwrap()) + } +} + #[derive(Clone, Ord, PartialOrd, Eq, PartialEq, Hash)] enum VfsPathRepr { PathBuf(AbsPathBuf), From 58e338a72996edc4b29f4fdada9d5b33c54ad608 Mon Sep 17 00:00:00 2001 From: Wilco Kusee Date: Mon, 13 Jul 2020 22:03:26 +0200 Subject: [PATCH 113/119] Print chalk programs in debug output --- crates/hir_ty/src/traits.rs | 9 +++++++-- crates/hir_ty/src/traits/chalk.rs | 22 ++++++++++++---------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/crates/hir_ty/src/traits.rs b/crates/hir_ty/src/traits.rs index 2553237170..6a012cd6a3 100644 --- a/crates/hir_ty/src/traits.rs +++ b/crates/hir_ty/src/traits.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use base_db::CrateId; use chalk_ir::cast::Cast; -use chalk_solve::Solver; +use chalk_solve::{logging_db::LoggingRustIrDatabase, Solver}; use hir_def::{lang_item::LangItemTarget, TraitId}; use crate::{db::HirDatabase, DebruijnIndex, Substs}; @@ -152,6 +152,9 @@ fn solve( goal: &chalk_ir::UCanonical>>, ) -> Option> { let context = ChalkContext { db, krate }; + + let logging_db = LoggingRustIrDatabase::new(context); + log::debug!("solve goal: {:?}", goal); let mut solver = create_chalk_solver(); @@ -167,7 +170,7 @@ fn solve( remaining > 0 }; let mut solve = || { - let solution = solver.solve_limited(&context, goal, should_continue); + let solution = solver.solve_limited(&logging_db, goal, should_continue); log::debug!("solve({:?}) => {:?}", goal, solution); solution }; @@ -176,6 +179,8 @@ fn solve( let solution = if is_chalk_debug() { chalk::tls::set_current_program(db, solve) } else { solve() }; + log::debug!("chalk program:\n{}", logging_db); + solution } diff --git a/crates/hir_ty/src/traits/chalk.rs b/crates/hir_ty/src/traits/chalk.rs index b336534179..08c2c9a3e3 100644 --- a/crates/hir_ty/src/traits/chalk.rs +++ b/crates/hir_ty/src/traits/chalk.rs @@ -240,20 +240,22 @@ impl<'a> chalk_solve::RustIrDatabase for ChalkContext<'a> { Substs::empty().to_chalk(self.db) } - fn trait_name(&self, _trait_id: chalk_ir::TraitId) -> String { - unimplemented!() + fn trait_name(&self, trait_id: chalk_ir::TraitId) -> String { + let id = from_chalk(self.db, trait_id); + self.db.trait_data(id).name.to_string() } - fn adt_name(&self, _struct_id: chalk_ir::AdtId) -> String { - unimplemented!() + // FIXME: lookup names + fn adt_name(&self, struct_id: chalk_ir::AdtId) -> String { + format!("Adt_{:?}", struct_id.0).replace("TypeCtorId(", "").replace(")", "") } - fn assoc_type_name(&self, _assoc_ty_id: chalk_ir::AssocTypeId) -> String { - unimplemented!() + fn assoc_type_name(&self, assoc_ty_id: chalk_ir::AssocTypeId) -> String { + format!("Assoc_{}", assoc_ty_id.0) } - fn opaque_type_name(&self, _opaque_ty_id: chalk_ir::OpaqueTyId) -> String { - unimplemented!() + fn opaque_type_name(&self, opaque_ty_id: chalk_ir::OpaqueTyId) -> String { + format!("Opaque_{}", opaque_ty_id.0) } - fn fn_def_name(&self, _fn_def_id: chalk_ir::FnDefId) -> String { - unimplemented!() + fn fn_def_name(&self, fn_def_id: chalk_ir::FnDefId) -> String { + format!("fn_{}", fn_def_id.0) } } From 10c33275b0c571a27e5858645984611fc5b162bf Mon Sep 17 00:00:00 2001 From: Wilco Kusee Date: Sun, 26 Jul 2020 12:27:25 +0200 Subject: [PATCH 114/119] Only use logging db if CHALK_DEBUG is active --- crates/hir_ty/src/traits.rs | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/crates/hir_ty/src/traits.rs b/crates/hir_ty/src/traits.rs index 6a012cd6a3..4932eac45e 100644 --- a/crates/hir_ty/src/traits.rs +++ b/crates/hir_ty/src/traits.rs @@ -152,9 +152,6 @@ fn solve( goal: &chalk_ir::UCanonical>>, ) -> Option> { let context = ChalkContext { db, krate }; - - let logging_db = LoggingRustIrDatabase::new(context); - log::debug!("solve goal: {:?}", goal); let mut solver = create_chalk_solver(); @@ -169,17 +166,23 @@ fn solve( } remaining > 0 }; - let mut solve = || { - let solution = solver.solve_limited(&logging_db, goal, should_continue); - log::debug!("solve({:?}) => {:?}", goal, solution); - solution - }; - // don't set the TLS for Chalk unless Chalk debugging is active, to make - // extra sure we only use it for debugging - let solution = - if is_chalk_debug() { chalk::tls::set_current_program(db, solve) } else { solve() }; - log::debug!("chalk program:\n{}", logging_db); + let solution = if is_chalk_debug() { + let logging_db = LoggingRustIrDatabase::new(context); + let solve = || { + let solution = solver.solve_limited(&logging_db, goal, should_continue); + log::debug!("chalk program:\n{}", logging_db); + solution + }; + + // don't set the TLS for Chalk unless Chalk debugging is active, to make + // extra sure we only use it for debugging + chalk::tls::set_current_program(db, solve) + } else { + solver.solve_limited(&context, goal, should_continue) + }; + + log::debug!("solve({:?}) => {:?}", goal, solution); solution } From 36052ce1a1c19379d67600b49d42f2e09e0450a7 Mon Sep 17 00:00:00 2001 From: Wilco Kusee Date: Sun, 26 Jul 2020 13:06:11 +0200 Subject: [PATCH 115/119] Lookup adt names --- crates/hir_ty/src/traits/chalk.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/hir_ty/src/traits/chalk.rs b/crates/hir_ty/src/traits/chalk.rs index 08c2c9a3e3..17c83b6a46 100644 --- a/crates/hir_ty/src/traits/chalk.rs +++ b/crates/hir_ty/src/traits/chalk.rs @@ -246,7 +246,8 @@ impl<'a> chalk_solve::RustIrDatabase for ChalkContext<'a> { } // FIXME: lookup names fn adt_name(&self, struct_id: chalk_ir::AdtId) -> String { - format!("Adt_{:?}", struct_id.0).replace("TypeCtorId(", "").replace(")", "") + let datum = self.db.struct_datum(self.krate, struct_id); + format!("{:?}", datum.name(&Interner)) } fn assoc_type_name(&self, assoc_ty_id: chalk_ir::AssocTypeId) -> String { format!("Assoc_{}", assoc_ty_id.0) From 200161c734e996e68f74d242d96d89b561a6dd17 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 14 Aug 2020 12:27:15 +0200 Subject: [PATCH 116/119] Document the most important CI invariant --- docs/dev/README.md | 5 +++++ docs/dev/style.md | 18 +++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/docs/dev/README.md b/docs/dev/README.md index ad18217f17..36edddc700 100644 --- a/docs/dev/README.md +++ b/docs/dev/README.md @@ -165,6 +165,11 @@ In general, API is centered around UI concerns -- the result of the call is what The results are 100% Rust specific though. Shout outs to LSP developers for popularizing the idea that "UI" is a good place to draw a boundary at. +## CI + +CI does not test rust-analyzer, CI is a core part of rust-analyzer, and is maintained with above average standard of quality. +CI is reproducible -- it can only be broken by changes to files in this repository, any dependence on externalities is a bug. + # Code Style & Review Process Do see [./style.md](./style.md). diff --git a/docs/dev/style.md b/docs/dev/style.md index 3bbab6da90..963a6d73d0 100644 --- a/docs/dev/style.md +++ b/docs/dev/style.md @@ -65,7 +65,7 @@ There are many benefits to this: It also makes sense to format snippets more compactly (for example, by placing enum definitions like `enum E { Foo, Bar }` on a single line), as long as they are still readable. -## Order of Imports +# Order of Imports Separate import groups with blank lines. Use one `use` per crate. @@ -91,7 +91,7 @@ use super::{} Module declarations come before the imports. Order them in "suggested reading order" for a person new to the code base. -## Import Style +# Import Style Qualify items from `hir` and `ast`. @@ -112,7 +112,7 @@ Avoid local `use MyEnum::*` imports. Prefer `use crate::foo::bar` to `use super::bar`. -## Order of Items +# Order of Items Optimize for the reader who sees the file for the first time, and wants to get a general idea about what's going on. People read things from top to bottom, so place most important things first. @@ -143,7 +143,7 @@ struct Foo { } ``` -## Variable Naming +# Variable Naming Use boring and long names for local variables ([yay code completion](https://github.com/rust-analyzer/rust-analyzer/pull/4162#discussion_r417130973)). The default name is a lowercased name of the type: `global_state: GlobalState`. @@ -151,12 +151,12 @@ Avoid ad-hoc acronyms and contractions, but use the ones that exist consistently The default name for "result of the function" local variable is `res`. The default name for "I don't really care about the name" variable is `it`. -## Collection types +# Collection types Prefer `rustc_hash::FxHashMap` and `rustc_hash::FxHashSet` instead of the ones in `std::collections`. They use a hasher that's slightly faster and using them consistently will reduce code size by some small amount. -## Preconditions +# Preconditions Express function preconditions in types and force the caller to provide them (rather than checking in callee): @@ -176,7 +176,7 @@ fn frobnicate(walrus: Option) { } ``` -## Premature Pessimization +# Premature Pessimization Avoid writing code which is slower than it needs to be. Don't allocate a `Vec` where an iterator would do, don't allocate strings needlessly. @@ -197,12 +197,12 @@ if words.len() != 2 { } ``` -## Documentation +# Documentation For `.md` and `.adoc` files, prefer a sentence-per-line format, don't wrap lines. If the line is too long, you want to split the sentence in two :-) -## Commit Style +# Commit Style We don't have specific rules around git history hygiene. Maintaining clean git history is encouraged, but not enforced. From de282ddd869f78fc8324f2333204b10e93939d83 Mon Sep 17 00:00:00 2001 From: Wilco Kusee Date: Fri, 14 Aug 2020 14:47:06 +0200 Subject: [PATCH 117/119] Only print chalk programs with CHALK_PRINT --- crates/hir_ty/src/traits.rs | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/crates/hir_ty/src/traits.rs b/crates/hir_ty/src/traits.rs index 4932eac45e..1c3abb18f0 100644 --- a/crates/hir_ty/src/traits.rs +++ b/crates/hir_ty/src/traits.rs @@ -167,21 +167,22 @@ fn solve( remaining > 0 }; - let solution = if is_chalk_debug() { - let logging_db = LoggingRustIrDatabase::new(context); - let solve = || { + let mut solve = || { + if is_chalk_print() { + let logging_db = LoggingRustIrDatabase::new(context); let solution = solver.solve_limited(&logging_db, goal, should_continue); log::debug!("chalk program:\n{}", logging_db); solution - }; - - // don't set the TLS for Chalk unless Chalk debugging is active, to make - // extra sure we only use it for debugging - chalk::tls::set_current_program(db, solve) - } else { - solver.solve_limited(&context, goal, should_continue) + } else { + solver.solve_limited(&context, goal, should_continue) + } }; + // don't set the TLS for Chalk unless Chalk debugging is active, to make + // extra sure we only use it for debugging + let solution = + if is_chalk_debug() { chalk::tls::set_current_program(db, solve) } else { solve() }; + log::debug!("solve({:?}) => {:?}", goal, solution); solution @@ -191,6 +192,10 @@ fn is_chalk_debug() -> bool { std::env::var("CHALK_DEBUG").is_ok() } +fn is_chalk_print() -> bool { + std::env::var("CHALK_PRINT").is_ok() +} + fn solution_from_chalk( db: &dyn HirDatabase, solution: chalk_solve::Solution, From 125744c057a953b2f1b03042e9a6ec49f1eb0a1e Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 14 Aug 2020 15:23:27 +0200 Subject: [PATCH 118/119] Rename hypothetical -> speculative --- crates/hir/src/semantics.rs | 9 ++++----- crates/ide/src/completion/completion_context.rs | 2 +- crates/ssr/src/resolving.rs | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs index d8beac98a6..3953017c3b 100644 --- a/crates/hir/src/semantics.rs +++ b/crates/hir/src/semantics.rs @@ -112,14 +112,13 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { pub fn expand(&self, macro_call: &ast::MacroCall) -> Option { self.imp.expand(macro_call) } - - pub fn expand_hypothetical( + pub fn speculative_expand( &self, actual_macro_call: &ast::MacroCall, hypothetical_args: &ast::TokenTree, token_to_map: SyntaxToken, ) -> Option<(SyntaxNode, SyntaxToken)> { - self.imp.expand_hypothetical(actual_macro_call, hypothetical_args, token_to_map) + self.imp.speculative_expand(actual_macro_call, hypothetical_args, token_to_map) } pub fn descend_into_macros(&self, token: SyntaxToken) -> SyntaxToken { @@ -311,7 +310,7 @@ impl<'db> SemanticsImpl<'db> { Some(node) } - fn expand_hypothetical( + fn speculative_expand( &self, actual_macro_call: &ast::MacroCall, hypothetical_args: &ast::TokenTree, @@ -756,7 +755,7 @@ impl<'a> SemanticsScope<'a> { /// Resolve a path as-if it was written at the given scope. This is /// necessary a heuristic, as it doesn't take hygiene into account. - pub fn resolve_hypothetical(&self, path: &ast::Path) -> Option { + pub fn speculative_resolve(&self, path: &ast::Path) -> Option { let hygiene = Hygiene::new(self.db.upcast(), self.file_id); let path = Path::from_src(path.clone(), &hygiene)?; self.resolve_hir_path(&path) diff --git a/crates/ide/src/completion/completion_context.rs b/crates/ide/src/completion/completion_context.rs index 3857dce672..85456a66f5 100644 --- a/crates/ide/src/completion/completion_context.rs +++ b/crates/ide/src/completion/completion_context.rs @@ -185,7 +185,7 @@ impl<'a> CompletionContext<'a> { }; if let (Some(actual_expansion), Some(hypothetical_expansion)) = ( ctx.sema.expand(&actual_macro_call), - ctx.sema.expand_hypothetical( + ctx.sema.speculative_expand( &actual_macro_call, &hypothetical_args, fake_ident_token, diff --git a/crates/ssr/src/resolving.rs b/crates/ssr/src/resolving.rs index 4441fb426a..b932132d5b 100644 --- a/crates/ssr/src/resolving.rs +++ b/crates/ssr/src/resolving.rs @@ -212,13 +212,13 @@ impl<'db> ResolutionScope<'db> { // First try resolving the whole path. This will work for things like // `std::collections::HashMap`, but will fail for things like // `std::collections::HashMap::new`. - if let Some(resolution) = self.scope.resolve_hypothetical(&path) { + if let Some(resolution) = self.scope.speculative_resolve(&path) { return Some(resolution); } // Resolution failed, try resolving the qualifier (e.g. `std::collections::HashMap` and if // that succeeds, then iterate through the candidates on the resolved type with the provided // name. - let resolved_qualifier = self.scope.resolve_hypothetical(&path.qualifier()?)?; + let resolved_qualifier = self.scope.speculative_resolve(&path.qualifier()?)?; if let hir::PathResolution::Def(hir::ModuleDef::Adt(adt)) = resolved_qualifier { let name = path.segment()?.name_ref()?; adt.ty(self.scope.db).iterate_path_candidates( From 1d11c9c91aeeb891f5d214f59d714eedd6679002 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 14 Aug 2020 17:30:16 +0200 Subject: [PATCH 119/119] Document xtask has few deps invariant --- xtask/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index 1a1140b04e..e9edbdd10b 100644 --- a/xtask/Cargo.toml +++ b/xtask/Cargo.toml @@ -18,3 +18,4 @@ quote = "1.0.2" ungrammar = "1.1.1" walkdir = "2.3.1" write-json = "0.1.0" +# Avoid adding more dependencies to this crate