aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-07-04 21:05:17 +0100
committerAleksey Kladov <[email protected]>2019-07-04 21:09:09 +0100
commit1834bae5b86c54ed9dece26e82436919d59e6cb7 (patch)
tree92c8b984e874b67fa1831613464bbe356c1af3dd
parent2b2cd829b0f95aef338227deb05ec7503dae9b6c (diff)
allow rustfmt to reorder imports
This wasn't a right decision in the first place, the feature flag was broken in the last rustfmt release, and syntax highlighting of imports is more important anyway
-rw-r--r--crates/gen_lsp_server/examples/01_gen_lsp_server.rs6
-rw-r--r--crates/gen_lsp_server/examples/02_gen_lsp_server_with_logging.rs12
-rw-r--r--crates/ra_arena/src/lib.rs2
-rw-r--r--crates/ra_assists/src/add_derive.rs4
-rw-r--r--crates/ra_assists/src/add_explicit_type.rs11
-rw-r--r--crates/ra_assists/src/add_impl.rs4
-rw-r--r--crates/ra_assists/src/add_missing_impl_members.rs11
-rw-r--r--crates/ra_assists/src/assist_ctx.rs10
-rw-r--r--crates/ra_assists/src/ast_editor.rs10
-rw-r--r--crates/ra_assists/src/auto_import.rs17
-rw-r--r--crates/ra_assists/src/change_visibility.rs13
-rw-r--r--crates/ra_assists/src/fill_match_arms.rs9
-rw-r--r--crates/ra_assists/src/flip_binexpr.rs4
-rw-r--r--crates/ra_assists/src/flip_comma.rs8
-rw-r--r--crates/ra_assists/src/inline_local_variable.rs4
-rw-r--r--crates/ra_assists/src/introduce_variable.rs12
-rw-r--r--crates/ra_assists/src/lib.rs16
-rw-r--r--crates/ra_assists/src/move_guard.rs9
-rw-r--r--crates/ra_assists/src/remove_dbg.rs5
-rw-r--r--crates/ra_assists/src/replace_if_let_with_match.rs6
-rw-r--r--crates/ra_assists/src/split_import.rs8
-rw-r--r--crates/ra_batch/src/lib.rs12
-rw-r--r--crates/ra_batch/src/vfs_filter.rs4
-rw-r--r--crates/ra_cli/src/analysis_bench.rs6
-rw-r--r--crates/ra_cli/src/analysis_stats.rs4
-rw-r--r--crates/ra_cli/src/main.rs6
-rw-r--r--crates/ra_db/src/input.rs2
-rw-r--r--crates/ra_db/src/lib.rs10
-rw-r--r--crates/ra_fmt/src/lib.rs6
-rw-r--r--crates/ra_hir/src/adt.rs9
-rw-r--r--crates/ra_hir/src/code_model.rs30
-rw-r--r--crates/ra_hir/src/code_model/docs.rs4
-rw-r--r--crates/ra_hir/src/code_model/src.rs8
-rw-r--r--crates/ra_hir/src/db.rs28
-rw-r--r--crates/ra_hir/src/diagnostics.rs6
-rw-r--r--crates/ra_hir/src/expr.rs20
-rw-r--r--crates/ra_hir/src/expr/scope.rs13
-rw-r--r--crates/ra_hir/src/expr/validation.rs11
-rw-r--r--crates/ra_hir/src/generics.rs11
-rw-r--r--crates/ra_hir/src/ids.rs10
-rw-r--r--crates/ra_hir/src/impl_block.rs16
-rw-r--r--crates/ra_hir/src/lang_item.rs8
-rw-r--r--crates/ra_hir/src/lib.rs42
-rw-r--r--crates/ra_hir/src/mock.rs7
-rw-r--r--crates/ra_hir/src/nameres.rs32
-rw-r--r--crates/ra_hir/src/nameres/collector.rs25
-rw-r--r--crates/ra_hir/src/nameres/raw.rs15
-rw-r--r--crates/ra_hir/src/nameres/tests.rs6
-rw-r--r--crates/ra_hir/src/path.rs7
-rw-r--r--crates/ra_hir/src/resolve.rs13
-rw-r--r--crates/ra_hir/src/source_binder.rs18
-rw-r--r--crates/ra_hir/src/source_id.rs12
-rw-r--r--crates/ra_hir/src/traits.rs6
-rw-r--r--crates/ra_hir/src/ty.rs13
-rw-r--r--crates/ra_hir/src/ty/autoderef.rs4
-rw-r--r--crates/ra_hir/src/ty/infer.rs39
-rw-r--r--crates/ra_hir/src/ty/infer/unify.rs4
-rw-r--r--crates/ra_hir/src/ty/lower.rs21
-rw-r--r--crates/ra_hir/src/ty/method_resolution.rs12
-rw-r--r--crates/ra_hir/src/ty/op.rs4
-rw-r--r--crates/ra_hir/src/ty/tests.rs15
-rw-r--r--crates/ra_hir/src/ty/traits.rs12
-rw-r--r--crates/ra_hir/src/ty/traits/chalk.rs19
-rw-r--r--crates/ra_hir/src/type_alias.rs7
-rw-r--r--crates/ra_ide_api/src/assists.rs4
-rw-r--r--crates/ra_ide_api/src/call_info.rs8
-rw-r--r--crates/ra_ide_api/src/change.rs15
-rw-r--r--crates/ra_ide_api/src/completion.rs14
-rw-r--r--crates/ra_ide_api/src/completion/complete_dot.rs4
-rw-r--r--crates/ra_ide_api/src/completion/complete_fn_param.rs5
-rw-r--r--crates/ra_ide_api/src/completion/complete_keyword.rs9
-rw-r--r--crates/ra_ide_api/src/completion/complete_path.rs6
-rw-r--r--crates/ra_ide_api/src/completion/complete_pattern.rs2
-rw-r--r--crates/ra_ide_api/src/completion/complete_postfix.rs15
-rw-r--r--crates/ra_ide_api/src/completion/complete_scope.rs10
-rw-r--r--crates/ra_ide_api/src/completion/complete_snippet.rs7
-rw-r--r--crates/ra_ide_api/src/completion/complete_struct_literal.rs2
-rw-r--r--crates/ra_ide_api/src/completion/completion_context.rs10
-rw-r--r--crates/ra_ide_api/src/completion/completion_item.rs4
-rw-r--r--crates/ra_ide_api/src/completion/presentation.rs12
-rw-r--r--crates/ra_ide_api/src/db.rs12
-rw-r--r--crates/ra_ide_api/src/diagnostics.rs17
-rw-r--r--crates/ra_ide_api/src/display.rs11
-rw-r--r--crates/ra_ide_api/src/display/function_signature.rs7
-rw-r--r--crates/ra_ide_api/src/display/navigation_target.rs11
-rw-r--r--crates/ra_ide_api/src/display/short_label.rs4
-rw-r--r--crates/ra_ide_api/src/display/structure.rs2
-rw-r--r--crates/ra_ide_api/src/extend_selection.rs10
-rw-r--r--crates/ra_ide_api/src/folding_ranges.rs5
-rw-r--r--crates/ra_ide_api/src/goto_definition.rs9
-rw-r--r--crates/ra_ide_api/src/goto_type_definition.rs7
-rw-r--r--crates/ra_ide_api/src/hover.rs22
-rw-r--r--crates/ra_ide_api/src/impls.rs9
-rw-r--r--crates/ra_ide_api/src/join_lines.rs11
-rw-r--r--crates/ra_ide_api/src/lib.rs28
-rw-r--r--crates/ra_ide_api/src/line_index.rs2
-rw-r--r--crates/ra_ide_api/src/line_index_utils.rs6
-rw-r--r--crates/ra_ide_api/src/matching_brace.rs8
-rw-r--r--crates/ra_ide_api/src/mock_analysis.rs5
-rw-r--r--crates/ra_ide_api/src/name_ref_kind.rs2
-rw-r--r--crates/ra_ide_api/src/parent_module.rs8
-rw-r--r--crates/ra_ide_api/src/references.rs30
-rw-r--r--crates/ra_ide_api/src/runnables.rs6
-rw-r--r--crates/ra_ide_api/src/status.rs22
-rw-r--r--crates/ra_ide_api/src/symbol_index.rs36
-rw-r--r--crates/ra_ide_api/src/syntax_highlighting.rs14
-rw-r--r--crates/ra_ide_api/src/syntax_tree.rs8
-rw-r--r--crates/ra_ide_api/src/typing.rs11
-rw-r--r--crates/ra_lsp_server/src/caps.rs7
-rw-r--r--crates/ra_lsp_server/src/cargo_target_spec.rs2
-rw-r--r--crates/ra_lsp_server/src/conv.rs14
-rw-r--r--crates/ra_lsp_server/src/lib.rs5
-rw-r--r--crates/ra_lsp_server/src/main.rs4
-rw-r--r--crates/ra_lsp_server/src/main_loop.rs9
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs21
-rw-r--r--crates/ra_lsp_server/src/project_model.rs2
-rw-r--r--crates/ra_lsp_server/src/req.rs11
-rw-r--r--crates/ra_lsp_server/src/vfs_filter.rs4
-rw-r--r--crates/ra_lsp_server/src/world.rs10
-rw-r--r--crates/ra_lsp_server/tests/heavy_tests/main.rs12
-rw-r--r--crates/ra_lsp_server/tests/heavy_tests/support.rs9
-rw-r--r--crates/ra_mbe/src/lib.rs10
-rw-r--r--crates/ra_mbe/src/mbe_expander.rs4
-rw-r--r--crates/ra_mbe/src/mbe_parser.rs2
-rw-r--r--crates/ra_mbe/src/subtree_parser.rs4
-rw-r--r--crates/ra_mbe/src/subtree_source.rs6
-rw-r--r--crates/ra_mbe/src/syntax_bridge.rs14
-rw-r--r--crates/ra_mbe/src/tt_cursor.rs4
-rw-r--r--crates/ra_parser/src/event.rs3
-rw-r--r--crates/ra_parser/src/grammar.rs2
-rw-r--r--crates/ra_parser/src/parser.rs6
-rw-r--r--crates/ra_prof/src/lib.rs15
-rw-r--r--crates/ra_project_model/src/cargo_workspace.rs6
-rw-r--r--crates/ra_project_model/src/lib.rs4
-rw-r--r--crates/ra_project_model/src/sysroot.rs2
-rw-r--r--crates/ra_syntax/src/algo.rs2
-rw-r--r--crates/ra_syntax/src/ast.rs8
-rw-r--r--crates/ra_syntax/src/ast/expr_extensions.rs6
-rw-r--r--crates/ra_syntax/src/ast/extensions.rs6
-rw-r--r--crates/ra_syntax/src/ast/tokens.rs6
-rw-r--r--crates/ra_syntax/src/ast/traits.rs4
-rw-r--r--crates/ra_syntax/src/fuzz.rs2
-rw-r--r--crates/ra_syntax/src/lib.rs19
-rw-r--r--crates/ra_syntax/src/parsing.rs7
-rw-r--r--crates/ra_syntax/src/parsing/lexer.rs3
-rw-r--r--crates/ra_syntax/src/parsing/lexer/numbers.rs5
-rw-r--r--crates/ra_syntax/src/parsing/reparsing.rs15
-rw-r--r--crates/ra_syntax/src/parsing/text_token_source.rs7
-rw-r--r--crates/ra_syntax/src/parsing/text_tree_sink.rs7
-rw-r--r--crates/ra_syntax/src/ptr.rs9
-rw-r--r--crates/ra_syntax/src/syntax_error.rs5
-rw-r--r--crates/ra_syntax/src/syntax_node.rs8
-rw-r--r--crates/ra_syntax/src/syntax_text.rs7
-rw-r--r--crates/ra_syntax/src/validation.rs7
-rw-r--r--crates/ra_syntax/src/validation/block.rs5
-rw-r--r--crates/ra_syntax/src/validation/field_expr.rs7
-rw-r--r--crates/ra_syntax/src/validation/unescape.rs2
-rw-r--r--crates/ra_syntax/tests/test.rs6
-rw-r--r--crates/ra_text_edit/src/test_utils.rs4
-rw-r--r--crates/ra_tools/src/bin/pre-commit.rs2
-rw-r--r--crates/ra_tools/src/lib.rs6
-rw-r--r--crates/ra_tools/src/main.rs6
-rw-r--r--crates/ra_tools/tests/cli.rs2
-rw-r--r--crates/ra_tt/src/buffer.rs2
-rw-r--r--crates/test_utils/src/lib.rs4
-rw-r--r--rustfmt.toml1
166 files changed, 772 insertions, 788 deletions
diff --git a/crates/gen_lsp_server/examples/01_gen_lsp_server.rs b/crates/gen_lsp_server/examples/01_gen_lsp_server.rs
index bc497f74a..f49965064 100644
--- a/crates/gen_lsp_server/examples/01_gen_lsp_server.rs
+++ b/crates/gen_lsp_server/examples/01_gen_lsp_server.rs
@@ -1,11 +1,11 @@
1use std::error::Error; 1use std::error::Error;
2 2
3use crossbeam_channel::{Sender, Receiver}; 3use crossbeam_channel::{Receiver, Sender};
4use gen_lsp_server::{handle_shutdown, run_server, stdio_transport, RawMessage, RawResponse};
4use lsp_types::{ 5use lsp_types::{
5 ServerCapabilities, InitializeParams,
6 request::{GotoDefinition, GotoDefinitionResponse}, 6 request::{GotoDefinition, GotoDefinitionResponse},
7 InitializeParams, ServerCapabilities,
7}; 8};
8use gen_lsp_server::{run_server, stdio_transport, handle_shutdown, RawMessage, RawResponse};
9 9
10fn main() -> Result<(), Box<dyn Error + Sync + Send>> { 10fn main() -> Result<(), Box<dyn Error + Sync + Send>> {
11 let (receiver, sender, io_threads) = stdio_transport(); 11 let (receiver, sender, io_threads) = stdio_transport();
diff --git a/crates/gen_lsp_server/examples/02_gen_lsp_server_with_logging.rs b/crates/gen_lsp_server/examples/02_gen_lsp_server_with_logging.rs
index 1a6174462..3c48106c5 100644
--- a/crates/gen_lsp_server/examples/02_gen_lsp_server_with_logging.rs
+++ b/crates/gen_lsp_server/examples/02_gen_lsp_server_with_logging.rs
@@ -44,14 +44,14 @@
44 44
45use std::error::Error; 45use std::error::Error;
46 46
47use crossbeam_channel::{Sender, Receiver}; 47use crossbeam_channel::{Receiver, Sender};
48use lsp_types::{ 48use gen_lsp_server::{
49 ServerCapabilities, InitializeParams, 49 handle_shutdown, run_server, stdio_transport, RawMessage, RawRequest, RawResponse,
50 request::{GotoDefinition, GotoDefinitionResponse},
51}; 50};
52use log::info; 51use log::info;
53use gen_lsp_server::{ 52use lsp_types::{
54 run_server, stdio_transport, handle_shutdown, RawMessage, RawResponse, RawRequest, 53 request::{GotoDefinition, GotoDefinitionResponse},
54 InitializeParams, ServerCapabilities,
55}; 55};
56 56
57fn main() -> Result<(), Box<dyn Error + Sync + Send>> { 57fn main() -> Result<(), Box<dyn Error + Sync + Send>> {
diff --git a/crates/ra_arena/src/lib.rs b/crates/ra_arena/src/lib.rs
index 26641e690..3b7cb77b1 100644
--- a/crates/ra_arena/src/lib.rs
+++ b/crates/ra_arena/src/lib.rs
@@ -2,9 +2,9 @@
2 2
3use std::{ 3use std::{
4 fmt, 4 fmt,
5 iter::FromIterator,
5 marker::PhantomData, 6 marker::PhantomData,
6 ops::{Index, IndexMut}, 7 ops::{Index, IndexMut},
7 iter::FromIterator,
8}; 8};
9 9
10pub mod map; 10pub mod map;
diff --git a/crates/ra_assists/src/add_derive.rs b/crates/ra_assists/src/add_derive.rs
index 0c4cf2615..bf7d55d6d 100644
--- a/crates/ra_assists/src/add_derive.rs
+++ b/crates/ra_assists/src/add_derive.rs
@@ -1,11 +1,11 @@
1use hir::db::HirDatabase; 1use hir::db::HirDatabase;
2use ra_syntax::{ 2use ra_syntax::{
3 ast::{self, AstNode, AttrsOwner}, 3 ast::{self, AstNode, AttrsOwner},
4 SyntaxKind::{WHITESPACE, COMMENT}, 4 SyntaxKind::{COMMENT, WHITESPACE},
5 TextUnit, 5 TextUnit,
6}; 6};
7 7
8use crate::{AssistCtx, Assist, AssistId}; 8use crate::{Assist, AssistCtx, AssistId};
9 9
10pub(crate) fn add_derive(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 10pub(crate) fn add_derive(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
11 let nominal = ctx.node_at_offset::<ast::NominalDef>()?; 11 let nominal = ctx.node_at_offset::<ast::NominalDef>()?;
diff --git a/crates/ra_assists/src/add_explicit_type.rs b/crates/ra_assists/src/add_explicit_type.rs
index f3ed74b7f..bb47a32f0 100644
--- a/crates/ra_assists/src/add_explicit_type.rs
+++ b/crates/ra_assists/src/add_explicit_type.rs
@@ -1,13 +1,10 @@
1use hir::{ 1use hir::{db::HirDatabase, HirDisplay, Ty};
2 HirDisplay, Ty,
3 db::HirDatabase,
4};
5use ra_syntax::{ 2use ra_syntax::{
3 ast::{AstNode, LetStmt, NameOwner, PatKind},
6 T, 4 T,
7 ast::{LetStmt, PatKind, NameOwner, AstNode}
8}; 5};
9 6
10use crate::{AssistCtx, Assist, AssistId}; 7use crate::{Assist, AssistCtx, AssistId};
11 8
12/// Add explicit type assist. 9/// Add explicit type assist.
13pub(crate) fn add_explicit_type(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 10pub(crate) fn add_explicit_type(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
@@ -56,7 +53,7 @@ fn is_unknown(ty: &Ty) -> bool {
56mod tests { 53mod tests {
57 use super::*; 54 use super::*;
58 55
59 use crate::helpers::{ check_assist, check_assist_target, check_assist_not_applicable }; 56 use crate::helpers::{check_assist, check_assist_not_applicable, check_assist_target};
60 57
61 #[test] 58 #[test]
62 fn add_explicit_type_target() { 59 fn add_explicit_type_target() {
diff --git a/crates/ra_assists/src/add_impl.rs b/crates/ra_assists/src/add_impl.rs
index fa1c85890..b81922c1d 100644
--- a/crates/ra_assists/src/add_impl.rs
+++ b/crates/ra_assists/src/add_impl.rs
@@ -1,11 +1,11 @@
1use join_to_string::join;
2use hir::db::HirDatabase; 1use hir::db::HirDatabase;
2use join_to_string::join;
3use ra_syntax::{ 3use ra_syntax::{
4 ast::{self, AstNode, NameOwner, TypeParamsOwner}, 4 ast::{self, AstNode, NameOwner, TypeParamsOwner},
5 TextUnit, 5 TextUnit,
6}; 6};
7 7
8use crate::{AssistCtx, Assist, AssistId}; 8use crate::{Assist, AssistCtx, AssistId};
9 9
10pub(crate) fn add_impl(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 10pub(crate) fn add_impl(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
11 let nominal = ctx.node_at_offset::<ast::NominalDef>()?; 11 let nominal = ctx.node_at_offset::<ast::NominalDef>()?;
diff --git a/crates/ra_assists/src/add_missing_impl_members.rs b/crates/ra_assists/src/add_missing_impl_members.rs
index 0c903a563..7fc8f63b3 100644
--- a/crates/ra_assists/src/add_missing_impl_members.rs
+++ b/crates/ra_assists/src/add_missing_impl_members.rs
@@ -1,9 +1,12 @@
1use crate::{Assist, AssistId, AssistCtx, ast_editor::{AstEditor, AstBuilder}}; 1use crate::{
2 ast_editor::{AstBuilder, AstEditor},
3 Assist, AssistCtx, AssistId,
4};
2 5
3use hir::{HasSource, db::HirDatabase}; 6use hir::{db::HirDatabase, HasSource};
4use ra_syntax::{SmolStr, TreeArc};
5use ra_syntax::ast::{self, AstNode, ImplItem, ImplItemKind, NameOwner};
6use ra_db::FilePosition; 7use ra_db::FilePosition;
8use ra_syntax::ast::{self, AstNode, ImplItem, ImplItemKind, NameOwner};
9use ra_syntax::{SmolStr, TreeArc};
7 10
8#[derive(PartialEq)] 11#[derive(PartialEq)]
9enum AddMissingImplMembersMode { 12enum AddMissingImplMembersMode {
diff --git a/crates/ra_assists/src/assist_ctx.rs b/crates/ra_assists/src/assist_ctx.rs
index 1d58d9e71..0ba5f3ae6 100644
--- a/crates/ra_assists/src/assist_ctx.rs
+++ b/crates/ra_assists/src/assist_ctx.rs
@@ -1,13 +1,13 @@
1use hir::db::HirDatabase; 1use hir::db::HirDatabase;
2use ra_text_edit::TextEditBuilder;
3use ra_db::FileRange; 2use ra_db::FileRange;
3use ra_fmt::{leading_indent, reindent};
4use ra_syntax::{ 4use ra_syntax::{
5 SourceFile, TextRange, AstNode, TextUnit, SyntaxNode, SyntaxElement, SyntaxToken, 5 algo::{find_covering_element, find_node_at_offset, find_token_at_offset, TokenAtOffset},
6 algo::{find_token_at_offset, find_node_at_offset, find_covering_element, TokenAtOffset}, 6 AstNode, SourceFile, SyntaxElement, SyntaxNode, SyntaxToken, TextRange, TextUnit,
7}; 7};
8use ra_fmt::{leading_indent, reindent}; 8use ra_text_edit::TextEditBuilder;
9 9
10use crate::{AssistLabel, AssistAction, AssistId}; 10use crate::{AssistAction, AssistId, AssistLabel};
11 11
12#[derive(Clone, Debug)] 12#[derive(Clone, Debug)]
13pub(crate) enum Assist { 13pub(crate) enum Assist {
diff --git a/crates/ra_assists/src/ast_editor.rs b/crates/ra_assists/src/ast_editor.rs
index 5f8ba3df6..c9a5cf8d9 100644
--- a/crates/ra_assists/src/ast_editor.rs
+++ b/crates/ra_assists/src/ast_editor.rs
@@ -1,10 +1,12 @@
1use std::{iter, ops::RangeInclusive}; 1use std::{iter, ops::RangeInclusive};
2 2
3use arrayvec::ArrayVec; 3use arrayvec::ArrayVec;
4use ra_text_edit::TextEditBuilder;
5use ra_syntax::{AstNode, TreeArc, ast, SyntaxKind::*, SyntaxElement, SourceFile, InsertPosition, Direction, T};
6use ra_fmt::leading_indent;
7use hir::Name; 4use hir::Name;
5use ra_fmt::leading_indent;
6use ra_syntax::{
7 ast, AstNode, Direction, InsertPosition, SourceFile, SyntaxElement, SyntaxKind::*, TreeArc, T,
8};
9use ra_text_edit::TextEditBuilder;
8 10
9pub struct AstEditor<N: AstNode> { 11pub struct AstEditor<N: AstNode> {
10 original_ast: TreeArc<N>, 12 original_ast: TreeArc<N>,
@@ -283,7 +285,7 @@ fn ast_node_from_file_text<N: AstNode>(text: &str) -> TreeArc<N> {
283 285
284mod tokens { 286mod tokens {
285 use once_cell::sync::Lazy; 287 use once_cell::sync::Lazy;
286 use ra_syntax::{AstNode, SourceFile, TreeArc, SyntaxToken, SyntaxKind::*, T}; 288 use ra_syntax::{AstNode, SourceFile, SyntaxKind::*, SyntaxToken, TreeArc, T};
287 289
288 static SOURCE_FILE: Lazy<TreeArc<SourceFile>> = Lazy::new(|| SourceFile::parse(",\n; ;").tree); 290 static SOURCE_FILE: Lazy<TreeArc<SourceFile>> = Lazy::new(|| SourceFile::parse(",\n; ;").tree);
289 291
diff --git a/crates/ra_assists/src/auto_import.rs b/crates/ra_assists/src/auto_import.rs
index 9617beb5c..75ab8fa0f 100644
--- a/crates/ra_assists/src/auto_import.rs
+++ b/crates/ra_assists/src/auto_import.rs
@@ -1,14 +1,15 @@
1use hir::{self, db::HirDatabase};
1use ra_text_edit::TextEditBuilder; 2use ra_text_edit::TextEditBuilder;
2use hir::{ self, db::HirDatabase};
3 3
4use ra_syntax::{
5 T,
6 ast::{ self, NameOwner }, AstNode, SyntaxNode, Direction, TextRange, SmolStr,
7 SyntaxKind::{ PATH, PATH_SEGMENT }
8};
9use crate::{ 4use crate::{
5 assist_ctx::{Assist, AssistCtx},
10 AssistId, 6 AssistId,
11 assist_ctx::{AssistCtx, Assist}, 7};
8use ra_syntax::{
9 ast::{self, NameOwner},
10 AstNode, Direction, SmolStr,
11 SyntaxKind::{PATH, PATH_SEGMENT},
12 SyntaxNode, TextRange, T,
12}; 13};
13 14
14fn collect_path_segments_raw<'a>( 15fn collect_path_segments_raw<'a>(
@@ -577,7 +578,7 @@ pub(crate) fn auto_import(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist
577#[cfg(test)] 578#[cfg(test)]
578mod tests { 579mod tests {
579 use super::*; 580 use super::*;
580 use crate::helpers::{ check_assist, check_assist_not_applicable }; 581 use crate::helpers::{check_assist, check_assist_not_applicable};
581 582
582 #[test] 583 #[test]
583 fn test_auto_import_add_use_no_anchor() { 584 fn test_auto_import_add_use_no_anchor() {
diff --git a/crates/ra_assists/src/change_visibility.rs b/crates/ra_assists/src/change_visibility.rs
index 4eb24d27f..6cabba3e3 100644
--- a/crates/ra_assists/src/change_visibility.rs
+++ b/crates/ra_assists/src/change_visibility.rs
@@ -1,12 +1,15 @@
1use hir::db::HirDatabase; 1use hir::db::HirDatabase;
2use ra_syntax::{ 2use ra_syntax::{
3 T, 3 ast::{self, NameOwner, VisibilityOwner},
4 AstNode, SyntaxNode, TextUnit, 4 AstNode,
5 ast::{self, VisibilityOwner, NameOwner}, 5 SyntaxKind::{
6 SyntaxKind::{VISIBILITY, FN_DEF, MODULE, STRUCT_DEF, ENUM_DEF, TRAIT_DEF, IDENT, WHITESPACE, COMMENT, ATTR}, 6 ATTR, COMMENT, ENUM_DEF, FN_DEF, IDENT, MODULE, STRUCT_DEF, TRAIT_DEF, VISIBILITY,
7 WHITESPACE,
8 },
9 SyntaxNode, TextUnit, T,
7}; 10};
8 11
9use crate::{AssistCtx, Assist, AssistId}; 12use crate::{Assist, AssistCtx, AssistId};
10 13
11pub(crate) fn change_visibility(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 14pub(crate) fn change_visibility(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
12 if let Some(vis) = ctx.node_at_offset::<ast::Visibility>() { 15 if let Some(vis) = ctx.node_at_offset::<ast::Visibility>() {
diff --git a/crates/ra_assists/src/fill_match_arms.rs b/crates/ra_assists/src/fill_match_arms.rs
index 71b101b40..d51010b84 100644
--- a/crates/ra_assists/src/fill_match_arms.rs
+++ b/crates/ra_assists/src/fill_match_arms.rs
@@ -1,13 +1,10 @@
1use std::fmt::Write;
2use itertools::Itertools; 1use itertools::Itertools;
2use std::fmt::Write;
3 3
4use hir::{ 4use hir::{db::HirDatabase, AdtDef, FieldSource, HasSource};
5 AdtDef, FieldSource, HasSource,
6 db::HirDatabase,
7};
8use ra_syntax::ast::{self, AstNode}; 5use ra_syntax::ast::{self, AstNode};
9 6
10use crate::{AssistCtx, Assist, AssistId}; 7use crate::{Assist, AssistCtx, AssistId};
11 8
12fn is_trivial_arm(arm: &ast::MatchArm) -> bool { 9fn is_trivial_arm(arm: &ast::MatchArm) -> bool {
13 fn single_pattern(arm: &ast::MatchArm) -> Option<ast::PatKind> { 10 fn single_pattern(arm: &ast::MatchArm) -> Option<ast::PatKind> {
diff --git a/crates/ra_assists/src/flip_binexpr.rs b/crates/ra_assists/src/flip_binexpr.rs
index 02d27f66d..5e41f9346 100644
--- a/crates/ra_assists/src/flip_binexpr.rs
+++ b/crates/ra_assists/src/flip_binexpr.rs
@@ -1,7 +1,7 @@
1use hir::db::HirDatabase; 1use hir::db::HirDatabase;
2use ra_syntax::ast::{AstNode, BinExpr, BinOp}; 2use ra_syntax::ast::{AstNode, BinExpr, BinOp};
3 3
4use crate::{AssistCtx, Assist, AssistId}; 4use crate::{Assist, AssistCtx, AssistId};
5 5
6/// Flip binary expression assist. 6/// Flip binary expression assist.
7pub(crate) fn flip_binexpr(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 7pub(crate) fn flip_binexpr(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
@@ -68,7 +68,7 @@ impl From<BinOp> for FlipAction {
68mod tests { 68mod tests {
69 use super::*; 69 use super::*;
70 70
71 use crate::helpers::{ check_assist, check_assist_target, check_assist_not_applicable }; 71 use crate::helpers::{check_assist, check_assist_not_applicable, check_assist_target};
72 72
73 #[test] 73 #[test]
74 fn flip_binexpr_target_is_the_op() { 74 fn flip_binexpr_target_is_the_op() {
diff --git a/crates/ra_assists/src/flip_comma.rs b/crates/ra_assists/src/flip_comma.rs
index 7626ffad3..d8dba779f 100644
--- a/crates/ra_assists/src/flip_comma.rs
+++ b/crates/ra_assists/src/flip_comma.rs
@@ -1,11 +1,7 @@
1use hir::db::HirDatabase; 1use hir::db::HirDatabase;
2use ra_syntax::{ 2use ra_syntax::{algo::non_trivia_sibling, Direction, T};
3 T,
4 Direction,
5 algo::non_trivia_sibling,
6};
7 3
8use crate::{AssistCtx, Assist, AssistId}; 4use crate::{Assist, AssistCtx, AssistId};
9 5
10pub(crate) fn flip_comma(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 6pub(crate) fn flip_comma(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
11 let comma = ctx.token_at_offset().find(|leaf| leaf.kind() == T![,])?; 7 let comma = ctx.token_at_offset().find(|leaf| leaf.kind() == T![,])?;
diff --git a/crates/ra_assists/src/inline_local_variable.rs b/crates/ra_assists/src/inline_local_variable.rs
index e0479ef13..554de8b46 100644
--- a/crates/ra_assists/src/inline_local_variable.rs
+++ b/crates/ra_assists/src/inline_local_variable.rs
@@ -1,11 +1,11 @@
1use hir::db::HirDatabase; 1use hir::db::HirDatabase;
2use ra_syntax::{ 2use ra_syntax::{
3 ast::{self, AstNode, AstToken, PatKind, ExprKind}, 3 ast::{self, AstNode, AstToken, ExprKind, PatKind},
4 TextRange, 4 TextRange,
5}; 5};
6 6
7use crate::{Assist, AssistCtx, AssistId};
8use crate::assist_ctx::AssistBuilder; 7use crate::assist_ctx::AssistBuilder;
8use crate::{Assist, AssistCtx, AssistId};
9 9
10pub(crate) fn inline_local_varialbe(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 10pub(crate) fn inline_local_varialbe(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
11 let let_stmt = ctx.node_at_offset::<ast::LetStmt>()?; 11 let let_stmt = ctx.node_at_offset::<ast::LetStmt>()?;
diff --git a/crates/ra_assists/src/introduce_variable.rs b/crates/ra_assists/src/introduce_variable.rs
index 28467d341..f7f5ccafa 100644
--- a/crates/ra_assists/src/introduce_variable.rs
+++ b/crates/ra_assists/src/introduce_variable.rs
@@ -1,12 +1,14 @@
1use test_utils::tested_by;
2use hir::db::HirDatabase; 1use hir::db::HirDatabase;
3use ra_syntax::{ 2use ra_syntax::{
4 ast::{self, AstNode}, 3 ast::{self, AstNode},
4 SyntaxKind::{
5 BREAK_EXPR, COMMENT, LAMBDA_EXPR, LOOP_EXPR, MATCH_ARM, PATH_EXPR, RETURN_EXPR, WHITESPACE,
6 },
5 SyntaxNode, TextUnit, 7 SyntaxNode, TextUnit,
6 SyntaxKind::{WHITESPACE, MATCH_ARM, LAMBDA_EXPR, PATH_EXPR, BREAK_EXPR, LOOP_EXPR, RETURN_EXPR, COMMENT},
7}; 8};
9use test_utils::tested_by;
8 10
9use crate::{AssistCtx, Assist, AssistId}; 11use crate::{Assist, AssistCtx, AssistId};
10 12
11pub(crate) fn introduce_variable(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 13pub(crate) fn introduce_variable(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
12 if ctx.frange.range.is_empty() { 14 if ctx.frange.range.is_empty() {
@@ -121,7 +123,9 @@ fn anchor_stmt(expr: &ast::Expr) -> Option<(&SyntaxNode, bool)> {
121mod tests { 123mod tests {
122 use test_utils::covers; 124 use test_utils::covers;
123 125
124 use crate::helpers::{check_assist_range_not_applicable, check_assist_range, check_assist_range_target}; 126 use crate::helpers::{
127 check_assist_range, check_assist_range_not_applicable, check_assist_range_target,
128 };
125 129
126 use super::*; 130 use super::*;
127 131
diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs
index 28eb0226b..0d848629d 100644
--- a/crates/ra_assists/src/lib.rs
+++ b/crates/ra_assists/src/lib.rs
@@ -11,12 +11,12 @@ pub mod ast_editor;
11 11
12use itertools::Itertools; 12use itertools::Itertools;
13 13
14use ra_text_edit::TextEdit;
15use ra_syntax::{TextRange, TextUnit};
16use ra_db::FileRange;
17use hir::db::HirDatabase; 14use hir::db::HirDatabase;
15use ra_db::FileRange;
16use ra_syntax::{TextRange, TextUnit};
17use ra_text_edit::TextEdit;
18 18
19pub(crate) use crate::assist_ctx::{AssistCtx, Assist}; 19pub(crate) use crate::assist_ctx::{Assist, AssistCtx};
20 20
21/// Unique identifier of the assist, should not be shown to the user 21/// Unique identifier of the assist, should not be shown to the user
22/// directly. 22/// directly.
@@ -127,11 +127,11 @@ fn all_assists<DB: HirDatabase>() -> &'static [fn(AssistCtx<DB>) -> Option<Assis
127#[cfg(test)] 127#[cfg(test)]
128mod helpers { 128mod helpers {
129 use hir::mock::MockDatabase; 129 use hir::mock::MockDatabase;
130 use ra_syntax::TextRange;
131 use ra_db::FileRange; 130 use ra_db::FileRange;
132 use test_utils::{extract_offset, extract_range, assert_eq_text, add_cursor}; 131 use ra_syntax::TextRange;
132 use test_utils::{add_cursor, assert_eq_text, extract_offset, extract_range};
133 133
134 use crate::{AssistCtx, Assist}; 134 use crate::{Assist, AssistCtx};
135 135
136 pub(crate) fn check_assist( 136 pub(crate) fn check_assist(
137 assist: fn(AssistCtx<MockDatabase>) -> Option<Assist>, 137 assist: fn(AssistCtx<MockDatabase>) -> Option<Assist>,
@@ -289,8 +289,8 @@ mod helpers {
289#[cfg(test)] 289#[cfg(test)]
290mod tests { 290mod tests {
291 use hir::mock::MockDatabase; 291 use hir::mock::MockDatabase;
292 use ra_syntax::TextRange;
293 use ra_db::FileRange; 292 use ra_db::FileRange;
293 use ra_syntax::TextRange;
294 use test_utils::{extract_offset, extract_range}; 294 use test_utils::{extract_offset, extract_range};
295 295
296 #[test] 296 #[test]
diff --git a/crates/ra_assists/src/move_guard.rs b/crates/ra_assists/src/move_guard.rs
index 22ba91fb7..e1ce86a33 100644
--- a/crates/ra_assists/src/move_guard.rs
+++ b/crates/ra_assists/src/move_guard.rs
@@ -1,12 +1,11 @@
1use hir::db::HirDatabase; 1use hir::db::HirDatabase;
2use ra_syntax::{ 2use ra_syntax::{
3 TextUnit,
4 SyntaxElement,
5 ast::{MatchArm, AstNode, AstToken, IfExpr},
6 ast, 3 ast,
4 ast::{AstNode, AstToken, IfExpr, MatchArm},
5 SyntaxElement, TextUnit,
7}; 6};
8 7
9use crate::{AssistCtx, Assist, AssistId}; 8use crate::{Assist, AssistCtx, AssistId};
10 9
11pub(crate) fn move_guard_to_arm_body(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 10pub(crate) fn move_guard_to_arm_body(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
12 let match_arm = ctx.node_at_offset::<MatchArm>()?; 11 let match_arm = ctx.node_at_offset::<MatchArm>()?;
@@ -84,7 +83,7 @@ pub(crate) fn move_arm_cond_to_match_guard(mut ctx: AssistCtx<impl HirDatabase>)
84mod tests { 83mod tests {
85 use super::*; 84 use super::*;
86 85
87 use crate::helpers::{ check_assist, check_assist_target, check_assist_not_applicable }; 86 use crate::helpers::{check_assist, check_assist_not_applicable, check_assist_target};
88 87
89 #[test] 88 #[test]
90 fn move_guard_to_arm_body_target() { 89 fn move_guard_to_arm_body_target() {
diff --git a/crates/ra_assists/src/remove_dbg.rs b/crates/ra_assists/src/remove_dbg.rs
index 6e900f8ef..5680f76ca 100644
--- a/crates/ra_assists/src/remove_dbg.rs
+++ b/crates/ra_assists/src/remove_dbg.rs
@@ -1,10 +1,9 @@
1use crate::{Assist, AssistCtx, AssistId};
1use hir::db::HirDatabase; 2use hir::db::HirDatabase;
2use ra_syntax::{ 3use ra_syntax::{
3 ast::{self, AstNode}, 4 ast::{self, AstNode},
4 TextUnit, 5 TextUnit, T,
5 T
6}; 6};
7use crate::{AssistCtx, Assist, AssistId};
8 7
9pub(crate) fn remove_dbg(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 8pub(crate) fn remove_dbg(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
10 let macro_call = ctx.node_at_offset::<ast::MacroCall>()?; 9 let macro_call = ctx.node_at_offset::<ast::MacroCall>()?;
diff --git a/crates/ra_assists/src/replace_if_let_with_match.rs b/crates/ra_assists/src/replace_if_let_with_match.rs
index 2b451f08d..c2c7cf70b 100644
--- a/crates/ra_assists/src/replace_if_let_with_match.rs
+++ b/crates/ra_assists/src/replace_if_let_with_match.rs
@@ -1,8 +1,8 @@
1use ra_syntax::{AstNode, ast};
2use ra_fmt::extract_trivial_expression;
3use hir::db::HirDatabase; 1use hir::db::HirDatabase;
2use ra_fmt::extract_trivial_expression;
3use ra_syntax::{ast, AstNode};
4 4
5use crate::{AssistCtx, Assist, AssistId}; 5use crate::{Assist, AssistCtx, AssistId};
6 6
7pub(crate) fn replace_if_let_with_match(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 7pub(crate) fn replace_if_let_with_match(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
8 let if_expr: &ast::IfExpr = ctx.node_at_offset()?; 8 let if_expr: &ast::IfExpr = ctx.node_at_offset()?;
diff --git a/crates/ra_assists/src/split_import.rs b/crates/ra_assists/src/split_import.rs
index 881c5ecdc..a8feb67c8 100644
--- a/crates/ra_assists/src/split_import.rs
+++ b/crates/ra_assists/src/split_import.rs
@@ -1,13 +1,9 @@
1use std::iter::successors; 1use std::iter::successors;
2 2
3use hir::db::HirDatabase; 3use hir::db::HirDatabase;
4use ra_syntax::{ 4use ra_syntax::{ast, AstNode, TextUnit, T};
5 T,
6 TextUnit, AstNode,
7 ast,
8};
9 5
10use crate::{AssistCtx, Assist, AssistId}; 6use crate::{Assist, AssistCtx, AssistId};
11 7
12pub(crate) fn split_import(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 8pub(crate) fn split_import(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
13 let colon_colon = ctx.token_at_offset().find(|leaf| leaf.kind() == T![::])?; 9 let colon_colon = ctx.token_at_offset().find(|leaf| leaf.kind() == T![::])?;
diff --git a/crates/ra_batch/src/lib.rs b/crates/ra_batch/src/lib.rs
index 43d3fb7e3..c25737aaa 100644
--- a/crates/ra_batch/src/lib.rs
+++ b/crates/ra_batch/src/lib.rs
@@ -1,14 +1,12 @@
1mod vfs_filter; 1mod vfs_filter;
2 2
3use std::{path::Path, collections::HashSet, error::Error}; 3use std::{collections::HashSet, error::Error, path::Path};
4 4
5use rustc_hash::FxHashMap; 5use rustc_hash::FxHashMap;
6 6
7use ra_db::{ 7use ra_db::{CrateGraph, FileId, SourceRootId};
8 CrateGraph, FileId, SourceRootId, 8use ra_ide_api::{AnalysisChange, AnalysisHost};
9}; 9use ra_project_model::{ProjectRoot, ProjectWorkspace};
10use ra_ide_api::{AnalysisHost, AnalysisChange};
11use ra_project_model::{ProjectWorkspace, ProjectRoot};
12use ra_vfs::{Vfs, VfsChange}; 10use ra_vfs::{Vfs, VfsChange};
13use vfs_filter::IncludeRustFiles; 11use vfs_filter::IncludeRustFiles;
14 12
@@ -106,8 +104,8 @@ pub fn load(
106 104
107#[cfg(test)] 105#[cfg(test)]
108mod tests { 106mod tests {
109 use ra_hir::Crate;
110 use super::*; 107 use super::*;
108 use ra_hir::Crate;
111 109
112 #[test] 110 #[test]
113 fn test_loading_rust_analyzer() { 111 fn test_loading_rust_analyzer() {
diff --git a/crates/ra_batch/src/vfs_filter.rs b/crates/ra_batch/src/vfs_filter.rs
index 8552ac999..2f0d8cb8b 100644
--- a/crates/ra_batch/src/vfs_filter.rs
+++ b/crates/ra_batch/src/vfs_filter.rs
@@ -1,6 +1,6 @@
1use std::path::PathBuf;
2use ra_project_model::ProjectRoot; 1use ra_project_model::ProjectRoot;
3use ra_vfs::{RootEntry, Filter, RelativePath}; 2use ra_vfs::{Filter, RelativePath, RootEntry};
3use std::path::PathBuf;
4 4
5/// `IncludeRustFiles` is used to convert 5/// `IncludeRustFiles` is used to convert
6/// from `ProjectRoot` to `RootEntry` for VFS 6/// from `ProjectRoot` to `RootEntry` for VFS
diff --git a/crates/ra_cli/src/analysis_bench.rs b/crates/ra_cli/src/analysis_bench.rs
index 33d472838..639ac763e 100644
--- a/crates/ra_cli/src/analysis_bench.rs
+++ b/crates/ra_cli/src/analysis_bench.rs
@@ -1,10 +1,10 @@
1use std::{ 1use std::{
2 path::{PathBuf, Path}, 2 path::{Path, PathBuf},
3 time::Instant, 3 time::Instant,
4}; 4};
5 5
6use ra_db::{SourceDatabase, salsa::Database}; 6use ra_db::{salsa::Database, SourceDatabase};
7use ra_ide_api::{AnalysisHost, Analysis, LineCol, FilePosition}; 7use ra_ide_api::{Analysis, AnalysisHost, FilePosition, LineCol};
8 8
9use crate::Result; 9use crate::Result;
10 10
diff --git a/crates/ra_cli/src/analysis_stats.rs b/crates/ra_cli/src/analysis_stats.rs
index a01c07c3f..b8ad6aebc 100644
--- a/crates/ra_cli/src/analysis_stats.rs
+++ b/crates/ra_cli/src/analysis_stats.rs
@@ -1,7 +1,7 @@
1use std::{collections::HashSet, time::Instant, fmt::Write, path::Path}; 1use std::{collections::HashSet, fmt::Write, path::Path, time::Instant};
2 2
3use ra_db::SourceDatabase; 3use ra_db::SourceDatabase;
4use ra_hir::{Crate, ModuleDef, Ty, ImplItem, HasSource}; 4use ra_hir::{Crate, HasSource, ImplItem, ModuleDef, Ty};
5use ra_syntax::AstNode; 5use ra_syntax::AstNode;
6 6
7use crate::Result; 7use crate::Result;
diff --git a/crates/ra_cli/src/main.rs b/crates/ra_cli/src/main.rs
index d2f6544f8..25edbd5f7 100644
--- a/crates/ra_cli/src/main.rs
+++ b/crates/ra_cli/src/main.rs
@@ -1,13 +1,13 @@
1mod analysis_stats; 1mod analysis_stats;
2mod analysis_bench; 2mod analysis_bench;
3 3
4use std::{io::Read, error::Error}; 4use std::{error::Error, io::Read};
5 5
6use clap::{App, Arg, SubCommand}; 6use clap::{App, Arg, SubCommand};
7use ra_ide_api::{file_structure, Analysis};
8use ra_syntax::{SourceFile, TreeArc, AstNode};
9use flexi_logger::Logger; 7use flexi_logger::Logger;
8use ra_ide_api::{file_structure, Analysis};
10use ra_prof::profile; 9use ra_prof::profile;
10use ra_syntax::{AstNode, SourceFile, TreeArc};
11 11
12type Result<T> = std::result::Result<T, Box<dyn Error + Send + Sync>>; 12type Result<T> = std::result::Result<T, Box<dyn Error + Send + Sync>>;
13 13
diff --git a/crates/ra_db/src/input.rs b/crates/ra_db/src/input.rs
index c103503bd..5d3a6b3c9 100644
--- a/crates/ra_db/src/input.rs
+++ b/crates/ra_db/src/input.rs
@@ -197,7 +197,7 @@ impl CrateGraph {
197 197
198#[cfg(test)] 198#[cfg(test)]
199mod tests { 199mod tests {
200 use super::{CrateGraph, FileId, SmolStr, Edition::Edition2018}; 200 use super::{CrateGraph, Edition::Edition2018, FileId, SmolStr};
201 201
202 #[test] 202 #[test]
203 fn it_should_panic_because_of_cycle_dependencies() { 203 fn it_should_panic_because_of_cycle_dependencies() {
diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs
index f08616100..11e18a03d 100644
--- a/crates/ra_db/src/lib.rs
+++ b/crates/ra_db/src/lib.rs
@@ -4,17 +4,15 @@ mod input;
4 4
5use std::{panic, sync::Arc}; 5use std::{panic, sync::Arc};
6 6
7use ra_syntax::{TextUnit, TextRange, SourceFile, Parse};
8use relative_path::RelativePathBuf;
9use ra_prof::profile; 7use ra_prof::profile;
8use ra_syntax::{Parse, SourceFile, TextRange, TextUnit};
9use relative_path::RelativePathBuf;
10 10
11pub use ::salsa as salsa;
12pub use crate::{ 11pub use crate::{
13 cancellation::Canceled, 12 cancellation::Canceled,
14 input::{ 13 input::{CrateGraph, CrateId, Dependency, Edition, FileId, SourceRoot, SourceRootId},
15 FileId, CrateId, SourceRoot, SourceRootId, CrateGraph, Dependency, Edition,
16 },
17}; 14};
15pub use ::salsa;
18 16
19pub trait CheckCanceled { 17pub trait CheckCanceled {
20 /// Aborts current query if there are pending changes. 18 /// Aborts current query if there are pending changes.
diff --git a/crates/ra_fmt/src/lib.rs b/crates/ra_fmt/src/lib.rs
index aac5a1d23..1c2c04ad2 100644
--- a/crates/ra_fmt/src/lib.rs
+++ b/crates/ra_fmt/src/lib.rs
@@ -1,11 +1,13 @@
1//! This crate provides some utilities for indenting rust code. 1//! This crate provides some utilities for indenting rust code.
2//! 2//!
3use std::iter::successors;
4use itertools::Itertools; 3use itertools::Itertools;
5use ra_syntax::{ 4use ra_syntax::{
6 SyntaxNode, SyntaxKind::*, SyntaxToken, SyntaxKind, T,
7 ast::{self, AstNode, AstToken}, 5 ast::{self, AstNode, AstToken},
6 SyntaxKind,
7 SyntaxKind::*,
8 SyntaxNode, SyntaxToken, T,
8}; 9};
10use std::iter::successors;
9 11
10pub fn reindent(text: &str, indent: &str) -> String { 12pub fn reindent(text: &str, indent: &str) -> String {
11 let indent = format!("\n{}", indent); 13 let indent = format!("\n{}", indent);
diff --git a/crates/ra_hir/src/adt.rs b/crates/ra_hir/src/adt.rs
index b3843b35c..9c0c8fdd0 100644
--- a/crates/ra_hir/src/adt.rs
+++ b/crates/ra_hir/src/adt.rs
@@ -3,16 +3,15 @@
3 3
4use std::sync::Arc; 4use std::sync::Arc;
5 5
6use ra_arena::{RawId, Arena, impl_arena_id}; 6use ra_arena::{impl_arena_id, Arena, RawId};
7use ra_syntax::{ 7use ra_syntax::{
8 ast::{self, NameOwner, StructKind, TypeAscriptionOwner},
8 TreeArc, 9 TreeArc,
9 ast::{self, NameOwner, StructKind, TypeAscriptionOwner}
10}; 10};
11 11
12use crate::{ 12use crate::{
13 Name, AsName, Struct, Union, Enum, EnumVariant, Crate, AstDatabase, 13 type_ref::TypeRef, AsName, AstDatabase, Crate, DefDatabase, Enum, EnumVariant, FieldSource,
14 HirDatabase, StructField, FieldSource, Source, HasSource, 14 HasSource, HirDatabase, Name, Source, Struct, StructField, Union,
15 type_ref::TypeRef, DefDatabase,
16}; 15};
17 16
18#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] 17#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index 75914ccb0..ed640d7fc 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -3,24 +3,32 @@ pub(crate) mod docs;
3 3
4use std::sync::Arc; 4use std::sync::Arc;
5 5
6use ra_db::{CrateId, SourceRootId, Edition, FileId}; 6use ra_db::{CrateId, Edition, FileId, SourceRootId};
7use ra_syntax::{ast::{self, NameOwner, TypeAscriptionOwner}, TreeArc}; 7use ra_syntax::{
8 ast::{self, NameOwner, TypeAscriptionOwner},
9 TreeArc,
10};
8 11
9use crate::{ 12use crate::{
10 Name, AsName, AstId, Ty, Either, KnownName, HasSource,
11 HirDatabase, DefDatabase, AstDatabase,
12 type_ref::TypeRef,
13 nameres::{ModuleScope, Namespace, ImportId, CrateModuleId},
14 expr::{Body, BodySourceMap, validation::ExprValidator},
15 ty::{TraitRef, InferenceResult, primitive::{IntTy, FloatTy, Signedness, IntBitness, FloatBitness}},
16 adt::{EnumVariantId, StructFieldId, VariantDef}, 13 adt::{EnumVariantId, StructFieldId, VariantDef},
14 diagnostics::DiagnosticSink,
15 expr::{validation::ExprValidator, Body, BodySourceMap},
17 generics::HasGenericParams, 16 generics::HasGenericParams,
18 ids::{FunctionId, StructId, EnumId, AstItemDef, ConstId, StaticId, TraitId, TypeAliasId, MacroDefId}, 17 ids::{
18 AstItemDef, ConstId, EnumId, FunctionId, MacroDefId, StaticId, StructId, TraitId,
19 TypeAliasId,
20 },
19 impl_block::ImplBlock, 21 impl_block::ImplBlock,
22 nameres::{CrateModuleId, ImportId, ModuleScope, Namespace},
20 resolve::Resolver, 23 resolve::Resolver,
21 diagnostics::{DiagnosticSink}, 24 traits::{TraitData, TraitItem},
22 traits::{TraitItem, TraitData}, 25 ty::{
26 primitive::{FloatBitness, FloatTy, IntBitness, IntTy, Signedness},
27 InferenceResult, TraitRef,
28 },
23 type_ref::Mutability, 29 type_ref::Mutability,
30 type_ref::TypeRef,
31 AsName, AstDatabase, AstId, DefDatabase, Either, HasSource, HirDatabase, KnownName, Name, Ty,
24}; 32};
25 33
26/// hir::Crate describes a single crate. It's the main interface with which 34/// hir::Crate describes a single crate. It's the main interface with which
diff --git a/crates/ra_hir/src/code_model/docs.rs b/crates/ra_hir/src/code_model/docs.rs
index da2b9b854..f696307a7 100644
--- a/crates/ra_hir/src/code_model/docs.rs
+++ b/crates/ra_hir/src/code_model/docs.rs
@@ -3,8 +3,8 @@ use std::sync::Arc;
3use ra_syntax::ast; 3use ra_syntax::ast;
4 4
5use crate::{ 5use crate::{
6 HirDatabase, DefDatabase, AstDatabase, HasSource, 6 AstDatabase, Const, DefDatabase, Enum, EnumVariant, FieldSource, Function, HasSource,
7 Module, StructField, Struct, Enum, EnumVariant, Static, Const, Function, Union, Trait, TypeAlias, FieldSource, MacroDef, 7 HirDatabase, MacroDef, Module, Static, Struct, StructField, Trait, TypeAlias, Union,
8}; 8};
9 9
10#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] 10#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
diff --git a/crates/ra_hir/src/code_model/src.rs b/crates/ra_hir/src/code_model/src.rs
index 5785d3b26..72451e0e7 100644
--- a/crates/ra_hir/src/code_model/src.rs
+++ b/crates/ra_hir/src/code_model/src.rs
@@ -1,9 +1,9 @@
1use ra_syntax::{TreeArc, ast}; 1use ra_syntax::{ast, TreeArc};
2 2
3use crate::{ 3use crate::{
4 HirFileId, DefDatabase, AstDatabase, Module, ModuleSource, 4 ids::AstItemDef, AstDatabase, Const, DefDatabase, Enum, EnumVariant, FieldSource, Function,
5 StructField, Struct, Enum, Union, EnumVariant, Function, Static, Trait, Const, TypeAlias, 5 HirFileId, MacroDef, Module, ModuleSource, Static, Struct, StructField, Trait, TypeAlias,
6 FieldSource, MacroDef, ids::AstItemDef, 6 Union,
7}; 7};
8 8
9pub struct Source<T> { 9pub struct Source<T> {
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs
index eda22c0b0..a9c6c52d9 100644
--- a/crates/ra_hir/src/db.rs
+++ b/crates/ra_hir/src/db.rs
@@ -1,23 +1,25 @@
1use std::sync::Arc; 1use std::sync::Arc;
2 2
3use parking_lot::Mutex; 3use parking_lot::Mutex;
4use ra_syntax::{SyntaxNode, TreeArc, SmolStr, ast}; 4use ra_db::{salsa, SourceDatabase};
5use ra_db::{SourceDatabase, salsa}; 5use ra_syntax::{ast, SmolStr, SyntaxNode, TreeArc};
6 6
7use crate::{ 7use crate::{
8 HirFileId, MacroDefId, AstIdMap, ErasedFileAstId, Crate, Module, MacroCallLoc, 8 adt::{EnumData, StructData},
9 Function, FnData, ExprScopes, TypeAlias, 9 generics::{GenericDef, GenericParams},
10 Struct, Enum, StructField,
11 Const, ConstData, Static,
12 DefWithBody, Trait,
13 ids, 10 ids,
14 nameres::{Namespace, ImportSourceMap, RawItems, CrateDefMap}, 11 impl_block::{ImplBlock, ImplSourceMap, ModuleImplBlocks},
15 ty::{InferenceResult, Ty, method_resolution::CrateImplBlocks, TypableDef, CallableDef, FnSig, TypeCtor, GenericPredicate, Substs}, 12 lang_item::{LangItemTarget, LangItems},
16 adt::{StructData, EnumData}, 13 nameres::{CrateDefMap, ImportSourceMap, Namespace, RawItems},
17 impl_block::{ModuleImplBlocks, ImplSourceMap, ImplBlock},
18 generics::{GenericParams, GenericDef},
19 traits::TraitData, 14 traits::TraitData,
20 lang_item::{LangItems, LangItemTarget}, type_alias::TypeAliasData, 15 ty::{
16 method_resolution::CrateImplBlocks, CallableDef, FnSig, GenericPredicate, InferenceResult,
17 Substs, Ty, TypableDef, TypeCtor,
18 },
19 type_alias::TypeAliasData,
20 AstIdMap, Const, ConstData, Crate, DefWithBody, Enum, ErasedFileAstId, ExprScopes, FnData,
21 Function, HirFileId, MacroCallLoc, MacroDefId, Module, Static, Struct, StructField, Trait,
22 TypeAlias,
21}; 23};
22 24
23/// We store all interned things in the single QueryGroup. 25/// We store all interned things in the single QueryGroup.
diff --git a/crates/ra_hir/src/diagnostics.rs b/crates/ra_hir/src/diagnostics.rs
index 2557ef18e..f5f2e65f3 100644
--- a/crates/ra_hir/src/diagnostics.rs
+++ b/crates/ra_hir/src/diagnostics.rs
@@ -1,9 +1,9 @@
1use std::{fmt, any::Any}; 1use std::{any::Any, fmt};
2 2
3use ra_syntax::{SyntaxNodePtr, TreeArc, AstPtr, TextRange, ast, SyntaxNode}; 3use ra_syntax::{ast, AstPtr, SyntaxNode, SyntaxNodePtr, TextRange, TreeArc};
4use relative_path::RelativePathBuf; 4use relative_path::RelativePathBuf;
5 5
6use crate::{HirFileId, HirDatabase, Name}; 6use crate::{HirDatabase, HirFileId, Name};
7 7
8/// Diagnostic defines hir API for errors and warnings. 8/// Diagnostic defines hir API for errors and warnings.
9/// 9///
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs
index b1973d19d..d5b4ba6b6 100644
--- a/crates/ra_hir/src/expr.rs
+++ b/crates/ra_hir/src/expr.rs
@@ -3,19 +3,25 @@ use std::sync::Arc;
3 3
4use rustc_hash::FxHashMap; 4use rustc_hash::FxHashMap;
5 5
6use ra_arena::{Arena, RawId, impl_arena_id, map::ArenaMap}; 6use ra_arena::{impl_arena_id, map::ArenaMap, Arena, RawId};
7use ra_syntax::{ 7use ra_syntax::{
8 SyntaxNodePtr, AstPtr, AstNode, 8 ast::{
9 ast::{self, TryBlockBodyOwner, LoopBodyOwner, ArgListOwner, NameOwner, LiteralKind,ArrayExprKind, TypeAscriptionOwner}, 9 self, ArgListOwner, ArrayExprKind, LiteralKind, LoopBodyOwner, NameOwner,
10 TryBlockBodyOwner, TypeAscriptionOwner,
11 },
12 AstNode, AstPtr, SyntaxNodePtr,
10}; 13};
11 14
12use crate::{ 15use crate::{
13 Path, Name, HirDatabase, Resolver,DefWithBody, Either, HirFileId, MacroCallLoc, MacroFileKind,
14 HasSource,
15 name::AsName, 16 name::AsName,
16 type_ref::{Mutability, TypeRef}, 17 type_ref::{Mutability, TypeRef},
18 DefWithBody, Either, HasSource, HirDatabase, HirFileId, MacroCallLoc, MacroFileKind, Name,
19 Path, Resolver,
20};
21use crate::{
22 path::GenericArgs,
23 ty::primitive::{FloatTy, IntTy, UncertainFloatTy, UncertainIntTy},
17}; 24};
18use crate::{path::GenericArgs, ty::primitive::{IntTy, UncertainIntTy, FloatTy, UncertainFloatTy}};
19 25
20pub use self::scope::ExprScopes; 26pub use self::scope::ExprScopes;
21 27
@@ -249,8 +255,8 @@ pub enum Expr {
249 Literal(Literal), 255 Literal(Literal),
250} 256}
251 257
252pub use ra_syntax::ast::PrefixOp as UnaryOp;
253pub use ra_syntax::ast::BinOp as BinaryOp; 258pub use ra_syntax::ast::BinOp as BinaryOp;
259pub use ra_syntax::ast::PrefixOp as UnaryOp;
254#[derive(Debug, Clone, Eq, PartialEq)] 260#[derive(Debug, Clone, Eq, PartialEq)]
255pub enum Array { 261pub enum Array {
256 ElementList(Vec<ExprId>), 262 ElementList(Vec<ExprId>),
diff --git a/crates/ra_hir/src/expr/scope.rs b/crates/ra_hir/src/expr/scope.rs
index 83d226fc1..f27cc6e8d 100644
--- a/crates/ra_hir/src/expr/scope.rs
+++ b/crates/ra_hir/src/expr/scope.rs
@@ -1,12 +1,11 @@
1use std::sync::Arc; 1use std::sync::Arc;
2 2
3use ra_arena::{impl_arena_id, Arena, RawId};
3use rustc_hash::FxHashMap; 4use rustc_hash::FxHashMap;
4use ra_arena::{Arena, RawId, impl_arena_id};
5 5
6use crate::{ 6use crate::{
7 Name, DefWithBody, 7 expr::{Body, Expr, ExprId, Pat, PatId, Statement},
8 expr::{PatId, ExprId, Pat, Expr, Body, Statement}, 8 DefWithBody, HirDatabase, Name,
9 HirDatabase,
10}; 9};
11 10
12#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] 11#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
@@ -173,10 +172,10 @@ fn compute_expr_scopes(expr: ExprId, body: &Body, scopes: &mut ExprScopes, scope
173#[cfg(test)] 172#[cfg(test)]
174mod tests { 173mod tests {
175 use ra_db::SourceDatabase; 174 use ra_db::SourceDatabase;
176 use ra_syntax::{algo::find_node_at_offset, AstNode, SyntaxNodePtr, ast}; 175 use ra_syntax::{algo::find_node_at_offset, ast, AstNode, SyntaxNodePtr};
177 use test_utils::{extract_offset, assert_eq_text}; 176 use test_utils::{assert_eq_text, extract_offset};
178 177
179 use crate::{source_binder::SourceAnalyzer, mock::MockDatabase}; 178 use crate::{mock::MockDatabase, source_binder::SourceAnalyzer};
180 179
181 fn do_check(code: &str, expected: &[&str]) { 180 fn do_check(code: &str, expected: &[&str]) {
182 let (off, code) = extract_offset(code); 181 let (off, code) = extract_offset(code);
diff --git a/crates/ra_hir/src/expr/validation.rs b/crates/ra_hir/src/expr/validation.rs
index 534fd482b..8206dae2e 100644
--- a/crates/ra_hir/src/expr/validation.rs
+++ b/crates/ra_hir/src/expr/validation.rs
@@ -1,17 +1,16 @@
1use std::sync::Arc;
2use rustc_hash::FxHashSet; 1use rustc_hash::FxHashSet;
2use std::sync::Arc;
3 3
4use ra_syntax::ast::{AstNode, StructLit}; 4use ra_syntax::ast::{AstNode, StructLit};
5 5
6use super::{Expr, ExprId, StructLitField};
6use crate::{ 7use crate::{
7 expr::AstPtr,
8 HirDatabase, Function, Name, HasSource,
9 diagnostics::{DiagnosticSink, MissingFields},
10 adt::AdtDef, 8 adt::AdtDef,
11 Path, 9 diagnostics::{DiagnosticSink, MissingFields},
10 expr::AstPtr,
12 ty::InferenceResult, 11 ty::InferenceResult,
12 Function, HasSource, HirDatabase, Name, Path,
13}; 13};
14use super::{Expr, StructLitField, ExprId};
15 14
16pub(crate) struct ExprValidator<'a, 'b: 'a> { 15pub(crate) struct ExprValidator<'a, 'b: 'a> {
17 func: Function, 16 func: Function,
diff --git a/crates/ra_hir/src/generics.rs b/crates/ra_hir/src/generics.rs
index 462b136b7..9929331d3 100644
--- a/crates/ra_hir/src/generics.rs
+++ b/crates/ra_hir/src/generics.rs
@@ -5,13 +5,14 @@
5 5
6use std::sync::Arc; 6use std::sync::Arc;
7 7
8use ra_syntax::ast::{self, NameOwner, TypeParamsOwner, TypeBoundsOwner, DefaultTypeParamOwner}; 8use ra_syntax::ast::{self, DefaultTypeParamOwner, NameOwner, TypeBoundsOwner, TypeParamsOwner};
9 9
10use crate::{ 10use crate::{
11 HasSource, 11 db::{AstDatabase, DefDatabase, HirDatabase},
12 Name, AsName, Function, Struct, Union, Enum, Trait, TypeAlias, ImplBlock, Container, AdtDef, 12 path::Path,
13 db::{HirDatabase, DefDatabase, AstDatabase}, 13 type_ref::TypeRef,
14 path::Path, type_ref::TypeRef, 14 AdtDef, AsName, Container, Enum, Function, HasSource, ImplBlock, Name, Struct, Trait,
15 TypeAlias, Union,
15}; 16};
16 17
17/// Data about a generic parameter (to a function, struct, impl, ...). 18/// Data about a generic parameter (to a function, struct, impl, ...).
diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs
index b7215ac03..bd1e2f2e6 100644
--- a/crates/ra_hir/src/ids.rs
+++ b/crates/ra_hir/src/ids.rs
@@ -3,14 +3,12 @@ use std::{
3 sync::Arc, 3 sync::Arc,
4}; 4};
5 5
6use ra_db::{FileId, salsa};
7use ra_syntax::{TreeArc, AstNode, ast, SyntaxNode};
8use ra_prof::profile;
9use mbe::MacroRules; 6use mbe::MacroRules;
7use ra_db::{salsa, FileId};
8use ra_prof::profile;
9use ra_syntax::{ast, AstNode, SyntaxNode, TreeArc};
10 10
11use crate::{ 11use crate::{AstDatabase, AstId, DefDatabase, FileAstId, InternDatabase, Module, Source};
12 Module, DefDatabase, AstId, FileAstId, AstDatabase, Source, InternDatabase,
13};
14 12
15/// hir makes heavy use of ids: integer (u32) handlers to various things. You 13/// hir makes heavy use of ids: integer (u32) handlers to various things. You
16/// can think of id as a pointer (but without a lifetime) or a file descriptor 14/// can think of id as a pointer (but without a lifetime) or a file descriptor
diff --git a/crates/ra_hir/src/impl_block.rs b/crates/ra_hir/src/impl_block.rs
index fb9daf1bf..ce134b27a 100644
--- a/crates/ra_hir/src/impl_block.rs
+++ b/crates/ra_hir/src/impl_block.rs
@@ -1,21 +1,21 @@
1use std::sync::Arc;
2use rustc_hash::FxHashMap; 1use rustc_hash::FxHashMap;
2use std::sync::Arc;
3 3
4use ra_arena::{Arena, RawId, impl_arena_id, map::ArenaMap}; 4use ra_arena::{impl_arena_id, map::ArenaMap, Arena, RawId};
5use ra_syntax::{ 5use ra_syntax::{
6 ast::{self, AstNode},
6 AstPtr, SourceFile, TreeArc, 7 AstPtr, SourceFile, TreeArc,
7 ast::{self, AstNode}
8}; 8};
9 9
10use crate::{ 10use crate::{
11 Const, TypeAlias, Function, HirFileId, AstDatabase, HasSource, Source, 11 code_model::{Module, ModuleSource},
12 HirDatabase, DefDatabase, TraitRef, 12 generics::HasGenericParams,
13 type_ref::TypeRef,
14 ids::LocationCtx, 13 ids::LocationCtx,
15 resolve::Resolver, 14 resolve::Resolver,
16 ty::Ty, 15 ty::Ty,
17 generics::HasGenericParams, 16 type_ref::TypeRef,
18 code_model::{Module, ModuleSource} 17 AstDatabase, Const, DefDatabase, Function, HasSource, HirDatabase, HirFileId, Source, TraitRef,
18 TypeAlias,
19}; 19};
20 20
21#[derive(Debug, Default, PartialEq, Eq)] 21#[derive(Debug, Default, PartialEq, Eq)]
diff --git a/crates/ra_hir/src/lang_item.rs b/crates/ra_hir/src/lang_item.rs
index 48b60f2dd..f9fe47b0f 100644
--- a/crates/ra_hir/src/lang_item.rs
+++ b/crates/ra_hir/src/lang_item.rs
@@ -1,11 +1,11 @@
1use std::sync::Arc;
2use rustc_hash::FxHashMap; 1use rustc_hash::FxHashMap;
2use std::sync::Arc;
3 3
4use ra_syntax::{SmolStr, TreeArc, ast::AttrsOwner}; 4use ra_syntax::{ast::AttrsOwner, SmolStr, TreeArc};
5 5
6use crate::{ 6use crate::{
7 Crate, DefDatabase, Enum, Function, HirDatabase, ImplBlock, Module, 7 AstDatabase, Crate, DefDatabase, Enum, Function, HasSource, HirDatabase, ImplBlock, Module,
8 Static, Struct, Trait, ModuleDef, AstDatabase, HasSource 8 ModuleDef, Static, Struct, Trait,
9}; 9};
10 10
11#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 11#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs
index 5afd846f5..ec0676783 100644
--- a/crates/ra_hir/src/lib.rs
+++ b/crates/ra_hir/src/lib.rs
@@ -47,39 +47,33 @@ mod code_model;
47mod marks; 47mod marks;
48 48
49use crate::{ 49use crate::{
50 db::{InternDatabase, AstDatabase, DefDatabase, HirDatabase}, 50 db::{AstDatabase, DefDatabase, HirDatabase, InternDatabase},
51 ids::MacroFileKind,
51 name::{AsName, KnownName}, 52 name::{AsName, KnownName},
52 source_id::{FileAstId, AstId},
53 resolve::Resolver, 53 resolve::Resolver,
54 ids::MacroFileKind, 54 source_id::{AstId, FileAstId},
55}; 55};
56 56
57pub use self::{ 57pub use self::{
58 either::Either,
59 path::{Path, PathKind},
60 name::Name,
61 source_id::{AstIdMap, ErasedFileAstId},
62 ids::{HirFileId, MacroDefId, MacroCallId, MacroCallLoc, MacroFile},
63 nameres::{PerNs, Namespace, ImportId},
64 ty::{Ty, ApplicationTy, TypeCtor, TraitRef, Substs, display::HirDisplay, CallableDef},
65 impl_block::{ImplBlock, ImplItem},
66 adt::AdtDef, 58 adt::AdtDef,
59 either::Either,
67 expr::ExprScopes, 60 expr::ExprScopes,
61 generics::{GenericParam, GenericParams, HasGenericParams},
62 ids::{HirFileId, MacroCallId, MacroCallLoc, MacroDefId, MacroFile},
63 impl_block::{ImplBlock, ImplItem},
64 name::Name,
65 nameres::{ImportId, Namespace, PerNs},
66 path::{Path, PathKind},
68 resolve::Resolution, 67 resolve::Resolution,
69 generics::{GenericParams, GenericParam, HasGenericParams}, 68 source_binder::{PathResolution, ScopeEntryWithSyntax, SourceAnalyzer},
70 source_binder::{SourceAnalyzer, PathResolution, ScopeEntryWithSyntax}, 69 source_id::{AstIdMap, ErasedFileAstId},
70 ty::{display::HirDisplay, ApplicationTy, CallableDef, Substs, TraitRef, Ty, TypeCtor},
71}; 71};
72 72
73pub use self::code_model::{ 73pub use self::code_model::{
74 Crate, CrateDependency, 74 docs::{DocDef, Docs, Documentation},
75 DefWithBody, 75 src::{HasSource, Source},
76 Module, ModuleDef, ModuleSource, 76 BuiltinType, Const, ConstData, Container, Crate, CrateDependency, DefWithBody, Enum,
77 Struct, Union, Enum, EnumVariant, 77 EnumVariant, FieldSource, FnData, Function, MacroDef, Module, ModuleDef, ModuleSource, Static,
78 Function, FnData, 78 Struct, StructField, Trait, TypeAlias, Union,
79 StructField, FieldSource,
80 Static, Const, ConstData,
81 Trait, TypeAlias, MacroDef, Container,
82 BuiltinType,
83 src::{Source, HasSource},
84 docs::{Docs, Documentation, DocDef},
85}; 79};
diff --git a/crates/ra_hir/src/mock.rs b/crates/ra_hir/src/mock.rs
index c57dfbf01..b26ea58c9 100644
--- a/crates/ra_hir/src/mock.rs
+++ b/crates/ra_hir/src/mock.rs
@@ -1,13 +1,12 @@
1use std::{sync::Arc, panic}; 1use std::{panic, sync::Arc};
2 2
3use parking_lot::Mutex; 3use parking_lot::Mutex;
4use ra_db::{ 4use ra_db::{
5 FilePosition, FileId, CrateGraph, SourceRoot, SourceRootId, SourceDatabase, salsa, 5 salsa, CrateGraph, Edition, FileId, FilePosition, SourceDatabase, SourceRoot, SourceRootId,
6 Edition,
7}; 6};
8use relative_path::RelativePathBuf; 7use relative_path::RelativePathBuf;
9use test_utils::{parse_fixture, CURSOR_MARKER, extract_offset};
10use rustc_hash::FxHashMap; 8use rustc_hash::FxHashMap;
9use test_utils::{extract_offset, parse_fixture, CURSOR_MARKER};
11 10
12use crate::{db, diagnostics::DiagnosticSink}; 11use crate::{db, diagnostics::DiagnosticSink};
13 12
diff --git a/crates/ra_hir/src/nameres.rs b/crates/ra_hir/src/nameres.rs
index f4ca454e4..53ef8d58a 100644
--- a/crates/ra_hir/src/nameres.rs
+++ b/crates/ra_hir/src/nameres.rs
@@ -55,28 +55,24 @@ mod tests;
55 55
56use std::sync::Arc; 56use std::sync::Arc;
57 57
58use once_cell::sync::Lazy;
59use ra_arena::{impl_arena_id, Arena, RawId};
60use ra_db::{Edition, FileId};
61use ra_prof::profile;
62use ra_syntax::ast;
58use rustc_hash::{FxHashMap, FxHashSet}; 63use rustc_hash::{FxHashMap, FxHashSet};
59use ra_arena::{Arena, RawId, impl_arena_id};
60use ra_db::{FileId, Edition};
61use test_utils::tested_by; 64use test_utils::tested_by;
62use ra_syntax::ast;
63use ra_prof::profile;
64use once_cell::sync::Lazy;
65 65
66use crate::{ 66use crate::{
67 ModuleDef, Name, Crate, Module, MacroDef, AsName, BuiltinType, AstDatabase, 67 diagnostics::DiagnosticSink, either::Either, ids::MacroDefId,
68 DefDatabase, Path, PathKind, HirFileId, Trait, 68 nameres::diagnostics::DefDiagnostic, AsName, AstDatabase, AstId, BuiltinType, Crate,
69 ids::MacroDefId, 69 DefDatabase, HirFileId, MacroDef, Module, ModuleDef, Name, Path, PathKind, Trait,
70 diagnostics::DiagnosticSink,
71 nameres::diagnostics::DefDiagnostic,
72 either::Either,
73 AstId,
74}; 70};
75 71
76pub(crate) use self::raw::{RawItems, ImportSourceMap}; 72pub(crate) use self::raw::{ImportSourceMap, RawItems};
77 73
78pub use self::{ 74pub use self::{
79 per_ns::{PerNs, Namespace}, 75 per_ns::{Namespace, PerNs},
80 raw::ImportId, 76 raw::ImportId,
81}; 77};
82 78
@@ -512,14 +508,14 @@ impl CrateDefMap {
512} 508}
513 509
514mod diagnostics { 510mod diagnostics {
511 use ra_syntax::{ast, AstPtr};
515 use relative_path::RelativePathBuf; 512 use relative_path::RelativePathBuf;
516 use ra_syntax::{AstPtr, ast};
517 513
518 use crate::{ 514 use crate::{
519 AstId, DefDatabase, AstDatabase, 515 diagnostics::{DiagnosticSink, UnresolvedModule},
520 nameres::CrateModuleId, 516 nameres::CrateModuleId,
521 diagnostics::{DiagnosticSink, UnresolvedModule} 517 AstDatabase, AstId, DefDatabase,
522}; 518 };
523 519
524 #[derive(Debug, PartialEq, Eq)] 520 #[derive(Debug, PartialEq, Eq)]
525 pub(super) enum DefDiagnostic { 521 pub(super) enum DefDiagnostic {
diff --git a/crates/ra_hir/src/nameres/collector.rs b/crates/ra_hir/src/nameres/collector.rs
index ef4d1ed70..2b07ebf4a 100644
--- a/crates/ra_hir/src/nameres/collector.rs
+++ b/crates/ra_hir/src/nameres/collector.rs
@@ -1,22 +1,19 @@
1use arrayvec::ArrayVec; 1use arrayvec::ArrayVec;
2use rustc_hash::FxHashMap;
3use relative_path::RelativePathBuf;
4use test_utils::tested_by;
5use ra_db::FileId; 2use ra_db::FileId;
6use ra_syntax::ast; 3use ra_syntax::ast;
4use relative_path::RelativePathBuf;
5use rustc_hash::FxHashMap;
6use test_utils::tested_by;
7 7
8use crate::{ 8use crate::{
9 Function, Module, Struct, Union, Enum, Const, Static, Trait, TypeAlias, MacroDef, 9 either::Either,
10 DefDatabase, HirFileId, Name, Path, 10 ids::{AstItemDef, LocationCtx, MacroCallId, MacroCallLoc, MacroDefId, MacroFileKind},
11 KnownName, AstId,
12 nameres::{ 11 nameres::{
13 Resolution, PerNs, ModuleDef, ReachedFixedPoint, ResolveMode, 12 diagnostics::DefDiagnostic, raw, CrateDefMap, CrateModuleId, ItemOrMacro, ModuleData,
14 CrateDefMap, CrateModuleId, ModuleData, ItemOrMacro, 13 ModuleDef, PerNs, ReachedFixedPoint, Resolution, ResolveMode,
15 diagnostics::DefDiagnostic,
16 raw,
17 }, 14 },
18 ids::{AstItemDef, LocationCtx, MacroCallLoc, MacroCallId, MacroDefId, MacroFileKind}, 15 AstId, Const, DefDatabase, Enum, Function, HirFileId, KnownName, MacroDef, Module, Name, Path,
19 either::Either, 16 Static, Struct, Trait, TypeAlias, Union,
20}; 17};
21 18
22pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> CrateDefMap { 19pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> CrateDefMap {
@@ -666,9 +663,9 @@ fn resolve_submodule(
666mod tests { 663mod tests {
667 use ra_db::SourceDatabase; 664 use ra_db::SourceDatabase;
668 665
669 use crate::{Crate, mock::MockDatabase, DefDatabase};
670 use ra_arena::{Arena};
671 use super::*; 666 use super::*;
667 use crate::{mock::MockDatabase, Crate, DefDatabase};
668 use ra_arena::Arena;
672 use rustc_hash::FxHashSet; 669 use rustc_hash::FxHashSet;
673 670
674 fn do_collect_defs( 671 fn do_collect_defs(
diff --git a/crates/ra_hir/src/nameres/raw.rs b/crates/ra_hir/src/nameres/raw.rs
index a0afe282c..7ea59cb75 100644
--- a/crates/ra_hir/src/nameres/raw.rs
+++ b/crates/ra_hir/src/nameres/raw.rs
@@ -1,13 +1,16 @@
1use std::{sync::Arc, ops::Index}; 1use std::{ops::Index, sync::Arc};
2 2
3use test_utils::tested_by; 3use ra_arena::{impl_arena_id, map::ArenaMap, Arena, RawId};
4use ra_arena::{Arena, impl_arena_id, RawId, map::ArenaMap};
5use ra_syntax::{ 4use ra_syntax::{
6 AstNode, SourceFile, AstPtr, TreeArc, 5 ast::{self, AttrsOwner, NameOwner},
7 ast::{self, NameOwner, AttrsOwner}, 6 AstNode, AstPtr, SourceFile, TreeArc,
8}; 7};
8use test_utils::tested_by;
9 9
10use crate::{DefDatabase, Name, AsName, Path, HirFileId, ModuleSource, AstIdMap, FileAstId, Either, AstDatabase}; 10use crate::{
11 AsName, AstDatabase, AstIdMap, DefDatabase, Either, FileAstId, HirFileId, ModuleSource, Name,
12 Path,
13};
11 14
12/// `RawItems` is a set of top-level items in a file (except for impls). 15/// `RawItems` is a set of top-level items in a file (except for impls).
13/// 16///
diff --git a/crates/ra_hir/src/nameres/tests.rs b/crates/ra_hir/src/nameres/tests.rs
index adac814d9..953610b37 100644
--- a/crates/ra_hir/src/nameres/tests.rs
+++ b/crates/ra_hir/src/nameres/tests.rs
@@ -5,14 +5,14 @@ mod primitives;
5 5
6use std::sync::Arc; 6use std::sync::Arc;
7 7
8use insta::assert_snapshot_matches;
8use ra_db::SourceDatabase; 9use ra_db::SourceDatabase;
9use test_utils::covers; 10use test_utils::covers;
10use insta::assert_snapshot_matches;
11 11
12use crate::{ 12use crate::{
13 Crate, Either, 13 mock::{CrateGraphFixture, MockDatabase},
14 mock::{MockDatabase, CrateGraphFixture},
15 nameres::Resolution, 14 nameres::Resolution,
15 Crate, Either,
16}; 16};
17 17
18use super::*; 18use super::*;
diff --git a/crates/ra_hir/src/path.rs b/crates/ra_hir/src/path.rs
index 67afd5027..bce9d2d4b 100644
--- a/crates/ra_hir/src/path.rs
+++ b/crates/ra_hir/src/path.rs
@@ -1,8 +1,11 @@
1use std::sync::Arc; 1use std::sync::Arc;
2 2
3use ra_syntax::{ast::{self, NameOwner}, AstNode}; 3use ra_syntax::{
4 ast::{self, NameOwner},
5 AstNode,
6};
4 7
5use crate::{Name, AsName, type_ref::TypeRef}; 8use crate::{type_ref::TypeRef, AsName, Name};
6 9
7#[derive(Debug, Clone, PartialEq, Eq, Hash)] 10#[derive(Debug, Clone, PartialEq, Eq, Hash)]
8pub struct Path { 11pub struct Path {
diff --git a/crates/ra_hir/src/resolve.rs b/crates/ra_hir/src/resolve.rs
index 7f8b3812c..fc981e9b3 100644
--- a/crates/ra_hir/src/resolve.rs
+++ b/crates/ra_hir/src/resolve.rs
@@ -4,16 +4,19 @@ use std::sync::Arc;
4use rustc_hash::{FxHashMap, FxHashSet}; 4use rustc_hash::{FxHashMap, FxHashSet};
5 5
6use crate::{ 6use crate::{
7 ModuleDef, Trait, MacroDef,
8 code_model::Crate, 7 code_model::Crate,
9 db::HirDatabase, 8 db::HirDatabase,
10 name::{Name, KnownName}, 9 either::Either,
11 nameres::{PerNs, CrateDefMap, CrateModuleId}, 10 expr::{
11 scope::{ExprScopes, ScopeId},
12 PatId,
13 },
12 generics::GenericParams, 14 generics::GenericParams,
13 expr::{scope::{ExprScopes, ScopeId}, PatId},
14 impl_block::ImplBlock, 15 impl_block::ImplBlock,
16 name::{KnownName, Name},
17 nameres::{CrateDefMap, CrateModuleId, PerNs},
15 path::Path, 18 path::Path,
16 either::Either, 19 MacroDef, ModuleDef, Trait,
17}; 20};
18 21
19#[derive(Debug, Clone, Default)] 22#[derive(Debug, Clone, Default)]
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs
index 08e86844d..429575fee 100644
--- a/crates/ra_hir/src/source_binder.rs
+++ b/crates/ra_hir/src/source_binder.rs
@@ -7,21 +7,25 @@
7/// purely for "IDE needs". 7/// purely for "IDE needs".
8use std::sync::Arc; 8use std::sync::Arc;
9 9
10use rustc_hash::{FxHashSet, FxHashMap};
11use ra_db::{FileId, FilePosition}; 10use ra_db::{FileId, FilePosition};
12use ra_syntax::{ 11use ra_syntax::{
13 SyntaxNode, AstPtr, TextUnit, SyntaxNodePtr, TextRange,
14 ast::{self, AstNode, NameOwner},
15 algo::find_node_at_offset, 12 algo::find_node_at_offset,
13 ast::{self, AstNode, NameOwner},
14 AstPtr,
16 SyntaxKind::*, 15 SyntaxKind::*,
16 SyntaxNode, SyntaxNodePtr, TextRange, TextUnit,
17}; 17};
18use rustc_hash::{FxHashMap, FxHashSet};
18 19
19use crate::{ 20use crate::{
20 HirDatabase, Function, Struct, Enum, Const, Static, Either, DefWithBody, PerNs, Name, 21 expr,
21 AsName, Module, HirFileId, Crate, Trait, Resolver, Ty, Path, MacroDef, 22 expr::{
22 expr::{BodySourceMap, scope::{ScopeId, ExprScopes}}, 23 scope::{ExprScopes, ScopeId},
24 BodySourceMap,
25 },
23 ids::LocationCtx, 26 ids::LocationCtx,
24 expr, AstId, 27 AsName, AstId, Const, Crate, DefWithBody, Either, Enum, Function, HirDatabase, HirFileId,
28 MacroDef, Module, Name, Path, PerNs, Resolver, Static, Struct, Trait, Ty,
25}; 29};
26 30
27/// Locates the module by `FileId`. Picks topmost module in the file. 31/// Locates the module by `FileId`. Picks topmost module in the file.
diff --git a/crates/ra_hir/src/source_id.rs b/crates/ra_hir/src/source_id.rs
index 986269e00..324b79824 100644
--- a/crates/ra_hir/src/source_id.rs
+++ b/crates/ra_hir/src/source_id.rs
@@ -1,9 +1,13 @@
1use std::{marker::PhantomData, sync::Arc, hash::{Hash, Hasher}}; 1use std::{
2 hash::{Hash, Hasher},
3 marker::PhantomData,
4 sync::Arc,
5};
2 6
3use ra_arena::{Arena, RawId, impl_arena_id}; 7use ra_arena::{impl_arena_id, Arena, RawId};
4use ra_syntax::{SyntaxNodePtr, TreeArc, SyntaxNode, AstNode, ast}; 8use ra_syntax::{ast, AstNode, SyntaxNode, SyntaxNodePtr, TreeArc};
5 9
6use crate::{HirFileId, AstDatabase}; 10use crate::{AstDatabase, HirFileId};
7 11
8/// `AstId` points to an AST node in any file. 12/// `AstId` points to an AST node in any file.
9/// 13///
diff --git a/crates/ra_hir/src/traits.rs b/crates/ra_hir/src/traits.rs
index f2950e1b2..fc0368303 100644
--- a/crates/ra_hir/src/traits.rs
+++ b/crates/ra_hir/src/traits.rs
@@ -1,13 +1,13 @@
1//! HIR for trait definitions. 1//! HIR for trait definitions.
2 2
3use std::sync::Arc;
4use rustc_hash::FxHashMap; 3use rustc_hash::FxHashMap;
4use std::sync::Arc;
5 5
6use ra_syntax::ast::{self, NameOwner}; 6use ra_syntax::ast::{self, NameOwner};
7 7
8use crate::{ 8use crate::{
9 Function, Const, TypeAlias, Name, DefDatabase, Trait, AstDatabase, Module, HasSource, 9 ids::LocationCtx, name::AsName, AstDatabase, Const, DefDatabase, Function, HasSource, Module,
10 ids::LocationCtx, name::AsName, 10 Name, Trait, TypeAlias,
11}; 11};
12 12
13#[derive(Debug, Clone, PartialEq, Eq)] 13#[derive(Debug, Clone, PartialEq, Eq)]
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs
index 842d49e1f..11afdc0f3 100644
--- a/crates/ra_hir/src/ty.rs
+++ b/crates/ra_hir/src/ty.rs
@@ -12,17 +12,20 @@ mod lower;
12mod infer; 12mod infer;
13pub(crate) mod display; 13pub(crate) mod display;
14 14
15use std::sync::Arc;
16use std::ops::Deref; 15use std::ops::Deref;
16use std::sync::Arc;
17use std::{fmt, mem}; 17use std::{fmt, mem};
18 18
19use crate::{Name, AdtDef, type_ref::Mutability, db::HirDatabase, Trait, GenericParams, TypeAlias}; 19use crate::{db::HirDatabase, type_ref::Mutability, AdtDef, GenericParams, Name, Trait, TypeAlias};
20use display::{HirDisplay, HirFormatter}; 20use display::{HirDisplay, HirFormatter};
21 21
22pub(crate) use lower::{TypableDef, type_for_def, type_for_field, callable_item_sig, generic_predicates, generic_defaults};
23pub(crate) use infer::{infer_query, InferenceResult, InferTy};
24pub use lower::CallableDef;
25pub(crate) use autoderef::autoderef; 22pub(crate) use autoderef::autoderef;
23pub(crate) use infer::{infer_query, InferTy, InferenceResult};
24pub use lower::CallableDef;
25pub(crate) use lower::{
26 callable_item_sig, generic_defaults, generic_predicates, type_for_def, type_for_field,
27 TypableDef,
28};
26pub(crate) use traits::ProjectionPredicate; 29pub(crate) use traits::ProjectionPredicate;
27 30
28/// A type constructor or type name: this might be something like the primitive 31/// A type constructor or type name: this might be something like the primitive
diff --git a/crates/ra_hir/src/ty/autoderef.rs b/crates/ra_hir/src/ty/autoderef.rs
index 1f443d49b..90c1ae630 100644
--- a/crates/ra_hir/src/ty/autoderef.rs
+++ b/crates/ra_hir/src/ty/autoderef.rs
@@ -7,8 +7,8 @@ use std::iter::successors;
7 7
8use log::{info, warn}; 8use log::{info, warn};
9 9
10use crate::{HirDatabase, Name, Resolver, HasGenericParams}; 10use super::{traits::Solution, Canonical, Ty};
11use super::{traits::Solution, Ty, Canonical}; 11use crate::{HasGenericParams, HirDatabase, Name, Resolver};
12 12
13const AUTODEREF_RECURSION_LIMIT: usize = 10; 13const AUTODEREF_RECURSION_LIMIT: usize = 10;
14 14
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs
index 2c05ca734..a2dc92370 100644
--- a/crates/ra_hir/src/ty/infer.rs
+++ b/crates/ra_hir/src/ty/infer.rs
@@ -15,38 +15,37 @@
15 15
16use std::borrow::Cow; 16use std::borrow::Cow;
17use std::iter::repeat; 17use std::iter::repeat;
18use std::mem;
18use std::ops::Index; 19use std::ops::Index;
19use std::sync::Arc; 20use std::sync::Arc;
20use std::mem;
21 21
22use ena::unify::{InPlaceUnificationTable, UnifyKey, UnifyValue, NoError}; 22use ena::unify::{InPlaceUnificationTable, NoError, UnifyKey, UnifyValue};
23use rustc_hash::FxHashMap; 23use rustc_hash::FxHashMap;
24 24
25use ra_arena::map::ArenaMap; 25use ra_arena::map::ArenaMap;
26use ra_prof::profile; 26use ra_prof::profile;
27use test_utils::tested_by; 27use test_utils::tested_by;
28 28
29use super::{
30 autoderef, method_resolution, op, primitive,
31 traits::{Guidance, Obligation, Solution},
32 ApplicationTy, CallableDef, Substs, TraitRef, Ty, TypableDef, TypeCtor,
33};
29use crate::{ 34use crate::{
30 Function, StructField, Path, Name, FnData, AdtDef, ConstData, HirDatabase, 35 adt::VariantDef,
31 DefWithBody, ImplItem, 36 diagnostics::DiagnosticSink,
32 type_ref::{TypeRef, Mutability},
33 expr::{ 37 expr::{
34 Body, Expr, BindingAnnotation, Literal, ExprId, Pat, PatId, UnaryOp, BinaryOp, Statement, 38 self, Array, BinaryOp, BindingAnnotation, Body, Expr, ExprId, FieldPat, Literal, Pat,
35 FieldPat, Array, self, 39 PatId, Statement, UnaryOp,
36 }, 40 },
37 generics::{GenericParams, HasGenericParams}, 41 generics::{GenericParams, HasGenericParams},
38 path::{GenericArgs, GenericArg},
39 ModuleDef,
40 adt::VariantDef,
41 resolve::{Resolver, Resolution},
42 nameres::Namespace, 42 nameres::Namespace,
43 path::{GenericArg, GenericArgs},
44 resolve::{Resolution, Resolver},
43 ty::infer::diagnostics::InferenceDiagnostic, 45 ty::infer::diagnostics::InferenceDiagnostic,
44 diagnostics::DiagnosticSink, 46 type_ref::{Mutability, TypeRef},
45}; 47 AdtDef, ConstData, DefWithBody, FnData, Function, HirDatabase, ImplItem, ModuleDef, Name, Path,
46use super::{ 48 StructField,
47 Ty, TypableDef, Substs, primitive, op, ApplicationTy, TypeCtor, CallableDef, TraitRef,
48 traits::{Solution, Obligation, Guidance},
49 method_resolution, autoderef,
50}; 49};
51 50
52mod unify; 51mod unify;
@@ -1415,10 +1414,10 @@ impl Expectation {
1415 1414
1416mod diagnostics { 1415mod diagnostics {
1417 use crate::{ 1416 use crate::{
1418 expr::ExprId,
1419 diagnostics::{DiagnosticSink, NoSuchField}, 1417 diagnostics::{DiagnosticSink, NoSuchField},
1420 HirDatabase, Function, HasSource, 1418 expr::ExprId,
1421}; 1419 Function, HasSource, HirDatabase,
1420 };
1422 1421
1423 #[derive(Debug, PartialEq, Eq, Clone)] 1422 #[derive(Debug, PartialEq, Eq, Clone)]
1424 pub(super) enum InferenceDiagnostic { 1423 pub(super) enum InferenceDiagnostic {
diff --git a/crates/ra_hir/src/ty/infer/unify.rs b/crates/ra_hir/src/ty/infer/unify.rs
index bc9719725..04633bdb2 100644
--- a/crates/ra_hir/src/ty/infer/unify.rs
+++ b/crates/ra_hir/src/ty/infer/unify.rs
@@ -1,8 +1,8 @@
1//! Unification and canonicalization logic. 1//! Unification and canonicalization logic.
2 2
3use crate::db::HirDatabase;
4use crate::ty::{Ty, Canonical, TraitRef, InferTy};
5use super::InferenceContext; 3use super::InferenceContext;
4use crate::db::HirDatabase;
5use crate::ty::{Canonical, InferTy, TraitRef, Ty};
6 6
7impl<'a, D: HirDatabase> InferenceContext<'a, D> { 7impl<'a, D: HirDatabase> InferenceContext<'a, D> {
8 pub(super) fn canonicalizer<'b>(&'b mut self) -> Canonicalizer<'a, 'b, D> 8 pub(super) fn canonicalizer<'b>(&'b mut self) -> Canonicalizer<'a, 'b, D>
diff --git a/crates/ra_hir/src/ty/lower.rs b/crates/ra_hir/src/ty/lower.rs
index cb494baf4..8b1b2a7f9 100644
--- a/crates/ra_hir/src/ty/lower.rs
+++ b/crates/ra_hir/src/ty/lower.rs
@@ -5,23 +5,22 @@
5//! - Building the type for an item: This happens through the `type_for_def` query. 5//! - Building the type for an item: This happens through the `type_for_def` query.
6//! 6//!
7//! This usually involves resolving names, collecting generic arguments etc. 7//! This usually involves resolving names, collecting generic arguments etc.
8use std::sync::Arc;
9use std::iter; 8use std::iter;
9use std::sync::Arc;
10 10
11use super::{FnSig, GenericPredicate, Substs, TraitRef, Ty, TypeCtor};
11use crate::{ 12use crate::{
12 Function, Struct, Union, StructField, Enum, EnumVariant, Path, ModuleDef, TypeAlias, Const, Static,
13 HirDatabase, BuiltinType,
14 type_ref::TypeRef,
15 nameres::Namespace,
16 resolve::{Resolver, Resolution},
17 path::{PathSegment, GenericArg},
18 generics::{HasGenericParams},
19 adt::VariantDef, 13 adt::VariantDef,
20 Trait, 14 generics::HasGenericParams,
21 generics::{WherePredicate, GenericDef}, 15 generics::{GenericDef, WherePredicate},
16 nameres::Namespace,
17 path::{GenericArg, PathSegment},
18 resolve::{Resolution, Resolver},
22 ty::AdtDef, 19 ty::AdtDef,
20 type_ref::TypeRef,
21 BuiltinType, Const, Enum, EnumVariant, Function, HirDatabase, ModuleDef, Path, Static, Struct,
22 StructField, Trait, TypeAlias, Union,
23}; 23};
24use super::{Ty, FnSig, Substs, TypeCtor, TraitRef, GenericPredicate};
25 24
26impl Ty { 25impl Ty {
27 pub(crate) fn from_hir(db: &impl HirDatabase, resolver: &Resolver, type_ref: &TypeRef) -> Self { 26 pub(crate) fn from_hir(db: &impl HirDatabase, resolver: &Resolver, type_ref: &TypeRef) -> Self {
diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs
index e023ff25a..bc890fe79 100644
--- a/crates/ra_hir/src/ty/method_resolution.rs
+++ b/crates/ra_hir/src/ty/method_resolution.rs
@@ -7,17 +7,17 @@ use std::sync::Arc;
7use arrayvec::ArrayVec; 7use arrayvec::ArrayVec;
8use rustc_hash::FxHashMap; 8use rustc_hash::FxHashMap;
9 9
10use super::{autoderef, Canonical, TraitRef};
10use crate::{ 11use crate::{
11 HirDatabase, Module, Crate, Name, Function, Trait, 12 generics::HasGenericParams,
12 impl_block::{ImplId, ImplBlock, ImplItem}, 13 impl_block::{ImplBlock, ImplId, ImplItem},
13 ty::{Ty, TypeCtor},
14 nameres::CrateModuleId, 14 nameres::CrateModuleId,
15 resolve::Resolver, 15 resolve::Resolver,
16 traits::TraitItem, 16 traits::TraitItem,
17 generics::HasGenericParams, 17 ty::primitive::{UncertainFloatTy, UncertainIntTy},
18 ty::primitive::{UncertainIntTy, UncertainFloatTy} 18 ty::{Ty, TypeCtor},
19 Crate, Function, HirDatabase, Module, Name, Trait,
19}; 20};
20use super::{TraitRef, Canonical, autoderef};
21 21
22/// This is used as a key for indexing impls. 22/// This is used as a key for indexing impls.
23#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] 23#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
diff --git a/crates/ra_hir/src/ty/op.rs b/crates/ra_hir/src/ty/op.rs
index 235661a5d..9ba868298 100644
--- a/crates/ra_hir/src/ty/op.rs
+++ b/crates/ra_hir/src/ty/op.rs
@@ -1,5 +1,5 @@
1use crate::{ ty::ApplicationTy, expr::BinaryOp}; 1use super::{InferTy, Ty, TypeCtor};
2use super::{Ty, TypeCtor, InferTy}; 2use crate::{expr::BinaryOp, ty::ApplicationTy};
3 3
4pub(super) fn binary_op_return_ty(op: BinaryOp, rhs_ty: Ty) -> Ty { 4pub(super) fn binary_op_return_ty(op: BinaryOp, rhs_ty: Ty) -> Ty {
5 match op { 5 match op {
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs
index 0fe7805e2..20fa74fb4 100644
--- a/crates/ra_hir/src/ty/tests.rs
+++ b/crates/ra_hir/src/ty/tests.rs
@@ -1,17 +1,18 @@
1use std::sync::Arc;
2use std::fmt::Write; 1use std::fmt::Write;
2use std::sync::Arc;
3 3
4use insta::assert_snapshot_matches; 4use insta::assert_snapshot_matches;
5 5
6use ra_db::{SourceDatabase, salsa::Database, FilePosition}; 6use ra_db::{salsa::Database, FilePosition, SourceDatabase};
7use ra_syntax::{algo, ast::{self, AstNode}, SyntaxKind::*}; 7use ra_syntax::{
8 algo,
9 ast::{self, AstNode},
10 SyntaxKind::*,
11};
8use test_utils::covers; 12use test_utils::covers;
9 13
10use crate::{ 14use crate::{
11 mock::MockDatabase, 15 expr::BodySourceMap, mock::MockDatabase, ty::display::HirDisplay, ty::InferenceResult,
12 ty::display::HirDisplay,
13 ty::InferenceResult,
14 expr::BodySourceMap,
15 SourceAnalyzer, 16 SourceAnalyzer,
16}; 17};
17 18
diff --git a/crates/ra_hir/src/ty/traits.rs b/crates/ra_hir/src/ty/traits.rs
index 69c03a36c..3c902451b 100644
--- a/crates/ra_hir/src/ty/traits.rs
+++ b/crates/ra_hir/src/ty/traits.rs
@@ -1,16 +1,16 @@
1//! Trait solving using Chalk. 1//! Trait solving using Chalk.
2use std::sync::Arc; 2use std::sync::Arc;
3 3
4use parking_lot::Mutex;
5use rustc_hash::FxHashSet;
6use log::debug;
7use chalk_ir::cast::Cast; 4use chalk_ir::cast::Cast;
5use log::debug;
6use parking_lot::Mutex;
8use ra_prof::profile; 7use ra_prof::profile;
8use rustc_hash::FxHashSet;
9 9
10use crate::{Crate, Trait, db::HirDatabase, ImplBlock}; 10use super::{Canonical, ProjectionTy, TraitRef, Ty};
11use super::{TraitRef, Ty, Canonical, ProjectionTy}; 11use crate::{db::HirDatabase, Crate, ImplBlock, Trait};
12 12
13use self::chalk::{ToChalk, from_chalk}; 13use self::chalk::{from_chalk, ToChalk};
14 14
15pub(crate) mod chalk; 15pub(crate) mod chalk;
16 16
diff --git a/crates/ra_hir/src/ty/traits/chalk.rs b/crates/ra_hir/src/ty/traits/chalk.rs
index 4ceb8b70b..2a0537bc3 100644
--- a/crates/ra_hir/src/ty/traits/chalk.rs
+++ b/crates/ra_hir/src/ty/traits/chalk.rs
@@ -3,20 +3,25 @@ use std::sync::Arc;
3 3
4use log::debug; 4use log::debug;
5 5
6use chalk_ir::{TypeId, ImplId, TypeKindId, Parameter, Identifier, cast::Cast, PlaceholderIndex, UniverseIndex, TypeName}; 6use chalk_ir::{
7use chalk_rust_ir::{AssociatedTyDatum, TraitDatum, StructDatum, ImplDatum}; 7 cast::Cast, Identifier, ImplId, Parameter, PlaceholderIndex, TypeId, TypeKindId, TypeName,
8 UniverseIndex,
9};
10use chalk_rust_ir::{AssociatedTyDatum, ImplDatum, StructDatum, TraitDatum};
8 11
9use test_utils::tested_by;
10use ra_db::salsa::{InternId, InternKey}; 12use ra_db::salsa::{InternId, InternKey};
13use test_utils::tested_by;
11 14
15use super::ChalkContext;
12use crate::{ 16use crate::{
13 Trait, HasGenericParams, ImplBlock, Crate,
14 db::HirDatabase, 17 db::HirDatabase,
15 ty::{TraitRef, Ty, ApplicationTy, TypeCtor, Substs, GenericPredicate, CallableDef, ProjectionTy}, 18 generics::GenericDef,
16 ty::display::HirDisplay, 19 ty::display::HirDisplay,
17 generics::GenericDef, TypeAlias, ImplItem, 20 ty::{
21 ApplicationTy, CallableDef, GenericPredicate, ProjectionTy, Substs, TraitRef, Ty, TypeCtor,
22 },
23 Crate, HasGenericParams, ImplBlock, ImplItem, Trait, TypeAlias,
18}; 24};
19use super::ChalkContext;
20 25
21/// This represents a trait whose name we could not resolve. 26/// This represents a trait whose name we could not resolve.
22const UNKNOWN_TRAIT: chalk_ir::TraitId = 27const UNKNOWN_TRAIT: chalk_ir::TraitId =
diff --git a/crates/ra_hir/src/type_alias.rs b/crates/ra_hir/src/type_alias.rs
index eada37274..3b38c4740 100644
--- a/crates/ra_hir/src/type_alias.rs
+++ b/crates/ra_hir/src/type_alias.rs
@@ -4,7 +4,12 @@ use std::sync::Arc;
4 4
5use ra_syntax::ast::NameOwner; 5use ra_syntax::ast::NameOwner;
6 6
7use crate::{TypeAlias, db::{DefDatabase, AstDatabase}, type_ref::TypeRef, name::{Name, AsName}, HasSource}; 7use crate::{
8 db::{AstDatabase, DefDatabase},
9 name::{AsName, Name},
10 type_ref::TypeRef,
11 HasSource, TypeAlias,
12};
8 13
9#[derive(Debug, Clone, PartialEq, Eq)] 14#[derive(Debug, Clone, PartialEq, Eq)]
10pub struct TypeAliasData { 15pub struct TypeAliasData {
diff --git a/crates/ra_ide_api/src/assists.rs b/crates/ra_ide_api/src/assists.rs
index 355c0a42a..e3d1ac529 100644
--- a/crates/ra_ide_api/src/assists.rs
+++ b/crates/ra_ide_api/src/assists.rs
@@ -1,6 +1,6 @@
1use ra_db::{FileRange, FilePosition}; 1use ra_db::{FilePosition, FileRange};
2 2
3use crate::{SourceFileEdit, SourceChange, db::RootDatabase}; 3use crate::{db::RootDatabase, SourceChange, SourceFileEdit};
4 4
5pub use ra_assists::AssistId; 5pub use ra_assists::AssistId;
6 6
diff --git a/crates/ra_ide_api/src/call_info.rs b/crates/ra_ide_api/src/call_info.rs
index 2948c646b..368fdcaa1 100644
--- a/crates/ra_ide_api/src/call_info.rs
+++ b/crates/ra_ide_api/src/call_info.rs
@@ -1,12 +1,12 @@
1use test_utils::tested_by;
2use ra_db::SourceDatabase; 1use ra_db::SourceDatabase;
3use ra_syntax::{ 2use ra_syntax::{
4 AstNode, SyntaxNode, TextUnit,
5 ast::{self, ArgListOwner},
6 algo::find_node_at_offset, 3 algo::find_node_at_offset,
4 ast::{self, ArgListOwner},
5 AstNode, SyntaxNode, TextUnit,
7}; 6};
7use test_utils::tested_by;
8 8
9use crate::{FilePosition, CallInfo, FunctionSignature, db::RootDatabase}; 9use crate::{db::RootDatabase, CallInfo, FilePosition, FunctionSignature};
10 10
11/// Computes parameter information for the given call expression. 11/// Computes parameter information for the given call expression.
12pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<CallInfo> { 12pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<CallInfo> {
diff --git a/crates/ra_ide_api/src/change.rs b/crates/ra_ide_api/src/change.rs
index c0c289335..2a1af0a0a 100644
--- a/crates/ra_ide_api/src/change.rs
+++ b/crates/ra_ide_api/src/change.rs
@@ -1,22 +1,19 @@
1use std::{ 1use std::{fmt, sync::Arc, time};
2 fmt, time,
3 sync::Arc,
4};
5 2
6use rustc_hash::FxHashMap;
7use ra_db::{ 3use ra_db::{
8 SourceRootId, FileId, CrateGraph, SourceDatabase, SourceRoot,
9 salsa::{Database, SweepStrategy}, 4 salsa::{Database, SweepStrategy},
5 CrateGraph, FileId, SourceDatabase, SourceRoot, SourceRootId,
10}; 6};
7use ra_prof::{memory_usage, profile, Bytes};
11use ra_syntax::SourceFile; 8use ra_syntax::SourceFile;
12use ra_prof::{profile, Bytes, memory_usage};
13use relative_path::RelativePathBuf;
14use rayon::prelude::*; 9use rayon::prelude::*;
10use relative_path::RelativePathBuf;
11use rustc_hash::FxHashMap;
15 12
16use crate::{ 13use crate::{
17 db::RootDatabase, 14 db::RootDatabase,
18 symbol_index::{SymbolIndex, SymbolsDatabase},
19 status::syntax_tree_stats, 15 status::syntax_tree_stats,
16 symbol_index::{SymbolIndex, SymbolsDatabase},
20}; 17};
21 18
22#[derive(Default)] 19#[derive(Default)]
diff --git a/crates/ra_ide_api/src/completion.rs b/crates/ra_ide_api/src/completion.rs
index 3a75bbf92..c23b5da59 100644
--- a/crates/ra_ide_api/src/completion.rs
+++ b/crates/ra_ide_api/src/completion.rs
@@ -14,19 +14,19 @@ mod complete_postfix;
14 14
15use ra_db::SourceDatabase; 15use ra_db::SourceDatabase;
16 16
17#[cfg(test)]
18use crate::completion::completion_item::{check_completion, do_completion};
17use crate::{ 19use crate::{
18 db,
19 FilePosition,
20 completion::{ 20 completion::{
21 completion_item::{Completions, CompletionKind},
22 completion_context::CompletionContext, 21 completion_context::CompletionContext,
22 completion_item::{CompletionKind, Completions},
23 }, 23 },
24 24 db, FilePosition,
25}; 25};
26#[cfg(test)]
27use crate::completion::completion_item::{do_completion, check_completion};
28 26
29pub use crate::completion::completion_item::{CompletionItem, CompletionItemKind, InsertTextFormat}; 27pub use crate::completion::completion_item::{
28 CompletionItem, CompletionItemKind, InsertTextFormat,
29};
30 30
31/// Main entry point for completion. We run completion as a two-phase process. 31/// Main entry point for completion. We run completion as a two-phase process.
32/// 32///
diff --git a/crates/ra_ide_api/src/completion/complete_dot.rs b/crates/ra_ide_api/src/completion/complete_dot.rs
index a97e876e9..a5f071442 100644
--- a/crates/ra_ide_api/src/completion/complete_dot.rs
+++ b/crates/ra_ide_api/src/completion/complete_dot.rs
@@ -1,4 +1,4 @@
1use hir::{Ty, AdtDef, TypeCtor}; 1use hir::{AdtDef, Ty, TypeCtor};
2 2
3use crate::completion::{CompletionContext, Completions}; 3use crate::completion::{CompletionContext, Completions};
4use rustc_hash::FxHashSet; 4use rustc_hash::FxHashSet;
@@ -49,7 +49,7 @@ fn complete_methods(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty
49 49
50#[cfg(test)] 50#[cfg(test)]
51mod tests { 51mod tests {
52 use crate::completion::{do_completion, CompletionKind, CompletionItem}; 52 use crate::completion::{do_completion, CompletionItem, CompletionKind};
53 use insta::assert_debug_snapshot_matches; 53 use insta::assert_debug_snapshot_matches;
54 54
55 fn do_ref_completion(code: &str) -> Vec<CompletionItem> { 55 fn do_ref_completion(code: &str) -> Vec<CompletionItem> {
diff --git a/crates/ra_ide_api/src/completion/complete_fn_param.rs b/crates/ra_ide_api/src/completion/complete_fn_param.rs
index d738ffc13..5a117c485 100644
--- a/crates/ra_ide_api/src/completion/complete_fn_param.rs
+++ b/crates/ra_ide_api/src/completion/complete_fn_param.rs
@@ -1,11 +1,10 @@
1use ra_syntax::{ 1use ra_syntax::{
2 algo::visit::{visitor_ctx, VisitorCtx}, 2 algo::visit::{visitor_ctx, VisitorCtx},
3 ast, 3 ast, AstNode,
4 AstNode,
5}; 4};
6use rustc_hash::FxHashMap; 5use rustc_hash::FxHashMap;
7 6
8use crate::completion::{CompletionContext, Completions, CompletionKind, CompletionItem}; 7use crate::completion::{CompletionContext, CompletionItem, CompletionKind, Completions};
9 8
10/// Complete repeated parameters, both name and type. For example, if all 9/// Complete repeated parameters, both name and type. For example, if all
11/// functions in a file have a `spam: &mut Spam` parameter, a completion with 10/// functions in a file have a `spam: &mut Spam` parameter, a completion with
diff --git a/crates/ra_ide_api/src/completion/complete_keyword.rs b/crates/ra_ide_api/src/completion/complete_keyword.rs
index cfb9fd6e8..034ed934d 100644
--- a/crates/ra_ide_api/src/completion/complete_keyword.rs
+++ b/crates/ra_ide_api/src/completion/complete_keyword.rs
@@ -1,11 +1,14 @@
1use ra_syntax::{ 1use ra_syntax::{
2 algo::visit::{visitor, Visitor}, 2 algo::visit::{visitor, Visitor},
3 AstNode,
4 ast::{self, LoopBodyOwner}, 3 ast::{self, LoopBodyOwner},
5 SyntaxKind::*, SyntaxToken, 4 AstNode,
5 SyntaxKind::*,
6 SyntaxToken,
6}; 7};
7 8
8use crate::completion::{CompletionContext, CompletionItem, Completions, CompletionKind, CompletionItemKind}; 9use crate::completion::{
10 CompletionContext, CompletionItem, CompletionItemKind, CompletionKind, Completions,
11};
9 12
10pub(super) fn complete_use_tree_keyword(acc: &mut Completions, ctx: &CompletionContext) { 13pub(super) fn complete_use_tree_keyword(acc: &mut Completions, ctx: &CompletionContext) {
11 // complete keyword "crate" in use stmt 14 // complete keyword "crate" in use stmt
diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs
index da8fb9d8e..29586cd1f 100644
--- a/crates/ra_ide_api/src/completion/complete_path.rs
+++ b/crates/ra_ide_api/src/completion/complete_path.rs
@@ -1,8 +1,8 @@
1use hir::{Resolution, Either}; 1use hir::{Either, Resolution};
2use ra_syntax::AstNode; 2use ra_syntax::AstNode;
3use test_utils::tested_by; 3use test_utils::tested_by;
4 4
5use crate::completion::{Completions, CompletionContext}; 5use crate::completion::{CompletionContext, Completions};
6 6
7pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) { 7pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
8 let path = match &ctx.path_prefix { 8 let path = match &ctx.path_prefix {
@@ -78,7 +78,7 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
78mod tests { 78mod tests {
79 use test_utils::covers; 79 use test_utils::covers;
80 80
81 use crate::completion::{CompletionKind, do_completion, CompletionItem}; 81 use crate::completion::{do_completion, CompletionItem, CompletionKind};
82 use insta::assert_debug_snapshot_matches; 82 use insta::assert_debug_snapshot_matches;
83 83
84 fn do_reference_completion(code: &str) -> Vec<CompletionItem> { 84 fn do_reference_completion(code: &str) -> Vec<CompletionItem> {
diff --git a/crates/ra_ide_api/src/completion/complete_pattern.rs b/crates/ra_ide_api/src/completion/complete_pattern.rs
index 6655a05a7..f12dfcc17 100644
--- a/crates/ra_ide_api/src/completion/complete_pattern.rs
+++ b/crates/ra_ide_api/src/completion/complete_pattern.rs
@@ -27,8 +27,8 @@ pub(super) fn complete_pattern(acc: &mut Completions, ctx: &CompletionContext) {
27 27
28#[cfg(test)] 28#[cfg(test)]
29mod tests { 29mod tests {
30 use crate::completion::{do_completion, CompletionItem, CompletionKind};
30 use insta::assert_debug_snapshot_matches; 31 use insta::assert_debug_snapshot_matches;
31 use crate::completion::{CompletionItem, CompletionKind, do_completion};
32 32
33 fn complete(code: &str) -> Vec<CompletionItem> { 33 fn complete(code: &str) -> Vec<CompletionItem> {
34 do_completion(code, CompletionKind::Reference) 34 do_completion(code, CompletionKind::Reference)
diff --git a/crates/ra_ide_api/src/completion/complete_postfix.rs b/crates/ra_ide_api/src/completion/complete_postfix.rs
index e20a12e2a..7042d8bff 100644
--- a/crates/ra_ide_api/src/completion/complete_postfix.rs
+++ b/crates/ra_ide_api/src/completion/complete_postfix.rs
@@ -1,18 +1,11 @@
1use crate::{ 1use crate::{
2 completion::{ 2 completion::{
3 completion_item::{
4 Completions,
5 Builder,
6 CompletionKind,
7 },
8 completion_context::CompletionContext, 3 completion_context::CompletionContext,
4 completion_item::{Builder, CompletionKind, Completions},
9 }, 5 },
10 CompletionItem 6 CompletionItem,
11};
12use ra_syntax::{
13 ast::AstNode,
14 TextRange
15}; 7};
8use ra_syntax::{ast::AstNode, TextRange};
16use ra_text_edit::TextEditBuilder; 9use ra_text_edit::TextEditBuilder;
17 10
18fn postfix_snippet(ctx: &CompletionContext, label: &str, detail: &str, snippet: &str) -> Builder { 11fn postfix_snippet(ctx: &CompletionContext, label: &str, detail: &str, snippet: &str) -> Builder {
@@ -58,7 +51,7 @@ pub(super) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) {
58 51
59#[cfg(test)] 52#[cfg(test)]
60mod tests { 53mod tests {
61 use crate::completion::{CompletionKind, check_completion}; 54 use crate::completion::{check_completion, CompletionKind};
62 55
63 fn check_snippet_completion(test_name: &str, code: &str) { 56 fn check_snippet_completion(test_name: &str, code: &str) {
64 check_completion(test_name, code, CompletionKind::Postfix); 57 check_completion(test_name, code, CompletionKind::Postfix);
diff --git a/crates/ra_ide_api/src/completion/complete_scope.rs b/crates/ra_ide_api/src/completion/complete_scope.rs
index 0f8cfaae8..1ba871257 100644
--- a/crates/ra_ide_api/src/completion/complete_scope.rs
+++ b/crates/ra_ide_api/src/completion/complete_scope.rs
@@ -1,9 +1,9 @@
1use rustc_hash::FxHashMap;
2use ra_text_edit::TextEditBuilder;
3use ra_syntax::{SmolStr, ast, AstNode};
4use ra_assists::auto_import; 1use ra_assists::auto_import;
2use ra_syntax::{ast, AstNode, SmolStr};
3use ra_text_edit::TextEditBuilder;
4use rustc_hash::FxHashMap;
5 5
6use crate::completion::{CompletionItem, Completions, CompletionKind, CompletionContext}; 6use crate::completion::{CompletionContext, CompletionItem, CompletionKind, Completions};
7 7
8pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) { 8pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) {
9 if ctx.is_trivial_path { 9 if ctx.is_trivial_path {
@@ -121,7 +121,7 @@ impl ImportResolver {
121 121
122#[cfg(test)] 122#[cfg(test)]
123mod tests { 123mod tests {
124 use crate::completion::{CompletionKind, check_completion}; 124 use crate::completion::{check_completion, CompletionKind};
125 125
126 fn check_reference_completion(name: &str, code: &str) { 126 fn check_reference_completion(name: &str, code: &str) {
127 check_completion(name, code, CompletionKind::Reference); 127 check_completion(name, code, CompletionKind::Reference);
diff --git a/crates/ra_ide_api/src/completion/complete_snippet.rs b/crates/ra_ide_api/src/completion/complete_snippet.rs
index e1df9e625..d2d364b57 100644
--- a/crates/ra_ide_api/src/completion/complete_snippet.rs
+++ b/crates/ra_ide_api/src/completion/complete_snippet.rs
@@ -1,4 +1,7 @@
1use crate::completion::{CompletionItem, Completions, CompletionKind, CompletionItemKind, CompletionContext, completion_item::Builder}; 1use crate::completion::{
2 completion_item::Builder, CompletionContext, CompletionItem, CompletionItemKind,
3 CompletionKind, Completions,
4};
2 5
3fn snippet(ctx: &CompletionContext, label: &str, snippet: &str) -> Builder { 6fn snippet(ctx: &CompletionContext, label: &str, snippet: &str) -> Builder {
4 CompletionItem::new(CompletionKind::Snippet, ctx.source_range(), label) 7 CompletionItem::new(CompletionKind::Snippet, ctx.source_range(), label)
@@ -36,7 +39,7 @@ fn ${1:feature}() {
36 39
37#[cfg(test)] 40#[cfg(test)]
38mod tests { 41mod tests {
39 use crate::completion::{CompletionKind, check_completion}; 42 use crate::completion::{check_completion, CompletionKind};
40 43
41 fn check_snippet_completion(name: &str, code: &str) { 44 fn check_snippet_completion(name: &str, code: &str) {
42 check_completion(name, code, CompletionKind::Snippet); 45 check_completion(name, code, CompletionKind::Snippet);
diff --git a/crates/ra_ide_api/src/completion/complete_struct_literal.rs b/crates/ra_ide_api/src/completion/complete_struct_literal.rs
index 1eeea58f6..35fb21113 100644
--- a/crates/ra_ide_api/src/completion/complete_struct_literal.rs
+++ b/crates/ra_ide_api/src/completion/complete_struct_literal.rs
@@ -27,8 +27,8 @@ pub(super) fn complete_struct_literal(acc: &mut Completions, ctx: &CompletionCon
27 27
28#[cfg(test)] 28#[cfg(test)]
29mod tests { 29mod tests {
30 use crate::completion::{do_completion, CompletionItem, CompletionKind};
30 use insta::assert_debug_snapshot_matches; 31 use insta::assert_debug_snapshot_matches;
31 use crate::completion::{CompletionItem, CompletionKind, do_completion};
32 32
33 fn complete(code: &str) -> Vec<CompletionItem> { 33 fn complete(code: &str) -> Vec<CompletionItem> {
34 do_completion(code, CompletionKind::Reference) 34 do_completion(code, CompletionKind::Reference)
diff --git a/crates/ra_ide_api/src/completion/completion_context.rs b/crates/ra_ide_api/src/completion/completion_context.rs
index bda7d9bb2..55fdba50d 100644
--- a/crates/ra_ide_api/src/completion/completion_context.rs
+++ b/crates/ra_ide_api/src/completion/completion_context.rs
@@ -1,11 +1,11 @@
1use ra_text_edit::AtomTextEdit; 1use hir::source_binder;
2use ra_syntax::{ 2use ra_syntax::{
3 AstNode, SyntaxNode, SourceFile, TextUnit, TextRange, SyntaxToken, Parse, 3 algo::{find_covering_element, find_node_at_offset, find_token_at_offset},
4 ast, 4 ast, AstNode, Parse, SourceFile,
5 algo::{find_token_at_offset, find_covering_element, find_node_at_offset},
6 SyntaxKind::*, 5 SyntaxKind::*,
6 SyntaxNode, SyntaxToken, TextRange, TextUnit,
7}; 7};
8use hir::source_binder; 8use ra_text_edit::AtomTextEdit;
9 9
10use crate::{db, FilePosition}; 10use crate::{db, FilePosition};
11 11
diff --git a/crates/ra_ide_api/src/completion/completion_item.rs b/crates/ra_ide_api/src/completion/completion_item.rs
index 6f2a60640..f78c4c877 100644
--- a/crates/ra_ide_api/src/completion/completion_item.rs
+++ b/crates/ra_ide_api/src/completion/completion_item.rs
@@ -2,7 +2,7 @@ use std::fmt;
2 2
3use hir::Documentation; 3use hir::Documentation;
4use ra_syntax::TextRange; 4use ra_syntax::TextRange;
5use ra_text_edit::{TextEditBuilder, TextEdit}; 5use ra_text_edit::{TextEdit, TextEditBuilder};
6 6
7/// `CompletionItem` describes a single completion variant in the editor pop-up. 7/// `CompletionItem` describes a single completion variant in the editor pop-up.
8/// It is basically a POD with various properties. To construct a 8/// It is basically a POD with various properties. To construct a
@@ -285,8 +285,8 @@ impl Into<Vec<CompletionItem>> for Completions {
285 285
286#[cfg(test)] 286#[cfg(test)]
287pub(crate) fn do_completion(code: &str, kind: CompletionKind) -> Vec<CompletionItem> { 287pub(crate) fn do_completion(code: &str, kind: CompletionKind) -> Vec<CompletionItem> {
288 use crate::mock_analysis::{single_file_with_position, analysis_and_position};
289 use crate::completion::completions; 288 use crate::completion::completions;
289 use crate::mock_analysis::{analysis_and_position, single_file_with_position};
290 let (analysis, position) = if code.contains("//-") { 290 let (analysis, position) = if code.contains("//-") {
291 analysis_and_position(code) 291 analysis_and_position(code)
292 } else { 292 } else {
diff --git a/crates/ra_ide_api/src/completion/presentation.rs b/crates/ra_ide_api/src/completion/presentation.rs
index 973936736..98060947a 100644
--- a/crates/ra_ide_api/src/completion/presentation.rs
+++ b/crates/ra_ide_api/src/completion/presentation.rs
@@ -1,16 +1,14 @@
1//! This modules takes care of rendering various defenitions as completion items. 1//! This modules takes care of rendering various defenitions as completion items.
2use hir::{Docs, HasSource, HirDisplay, PerNs, Resolution};
2use join_to_string::join; 3use join_to_string::join;
3use test_utils::tested_by;
4use hir::{Docs, PerNs, Resolution, HirDisplay, HasSource};
5use ra_syntax::ast::NameOwner; 4use ra_syntax::ast::NameOwner;
5use test_utils::tested_by;
6 6
7use crate::completion::{ 7use crate::completion::{
8 Completions, CompletionKind, CompletionItemKind, CompletionContext, CompletionItem, 8 CompletionContext, CompletionItem, CompletionItemKind, CompletionKind, Completions,
9}; 9};
10 10
11use crate::display::{ 11use crate::display::{const_label, function_label, type_label};
12 function_label, const_label, type_label,
13};
14 12
15impl Completions { 13impl Completions {
16 pub(crate) fn add_field( 14 pub(crate) fn add_field(
@@ -178,7 +176,7 @@ impl Completions {
178mod tests { 176mod tests {
179 use test_utils::covers; 177 use test_utils::covers;
180 178
181 use crate::completion::{CompletionKind, check_completion}; 179 use crate::completion::{check_completion, CompletionKind};
182 180
183 fn check_reference_completion(code: &str, expected_completions: &str) { 181 fn check_reference_completion(code: &str, expected_completions: &str) {
184 check_completion(code, expected_completions, CompletionKind::Reference); 182 check_completion(code, expected_completions, CompletionKind::Reference);
diff --git a/crates/ra_ide_api/src/db.rs b/crates/ra_ide_api/src/db.rs
index 94977764c..fc5b06ca8 100644
--- a/crates/ra_ide_api/src/db.rs
+++ b/crates/ra_ide_api/src/db.rs
@@ -1,14 +1,14 @@
1use std::{ 1use std::{sync::Arc, time};
2 sync::Arc,
3 time,
4};
5 2
6use ra_db::{ 3use ra_db::{
7 CheckCanceled, FileId, Canceled, SourceDatabase,
8 salsa::{self, Database}, 4 salsa::{self, Database},
5 Canceled, CheckCanceled, FileId, SourceDatabase,
9}; 6};
10 7
11use crate::{LineIndex, symbol_index::{self, SymbolsDatabase}}; 8use crate::{
9 symbol_index::{self, SymbolsDatabase},
10 LineIndex,
11};
12 12
13#[salsa::database( 13#[salsa::database(
14 ra_db::SourceDatabaseStorage, 14 ra_db::SourceDatabaseStorage,
diff --git a/crates/ra_ide_api/src/diagnostics.rs b/crates/ra_ide_api/src/diagnostics.rs
index 35b3d77df..9ab455b0e 100644
--- a/crates/ra_ide_api/src/diagnostics.rs
+++ b/crates/ra_ide_api/src/diagnostics.rs
@@ -1,17 +1,20 @@
1use std::cell::RefCell; 1use std::cell::RefCell;
2 2
3use hir::{
4 diagnostics::{Diagnostic as _, DiagnosticSink},
5 source_binder,
6};
3use itertools::Itertools; 7use itertools::Itertools;
4use hir::{source_binder, diagnostics::{Diagnostic as _, DiagnosticSink}}; 8use ra_assists::ast_editor::{AstBuilder, AstEditor};
5use ra_db::SourceDatabase; 9use ra_db::SourceDatabase;
10use ra_prof::profile;
6use ra_syntax::{ 11use ra_syntax::{
7 T, Location, TextRange, SyntaxNode, 12 ast::{self, AstNode, NamedField, NamedFieldList},
8 ast::{self, AstNode, NamedFieldList, NamedField}, 13 Location, SyntaxNode, TextRange, T,
9}; 14};
10use ra_assists::ast_editor::{AstEditor, AstBuilder};
11use ra_text_edit::{TextEdit, TextEditBuilder}; 15use ra_text_edit::{TextEdit, TextEditBuilder};
12use ra_prof::profile;
13 16
14use crate::{Diagnostic, FileId, FileSystemEdit, SourceChange, SourceFileEdit, db::RootDatabase}; 17use crate::{db::RootDatabase, Diagnostic, FileId, FileSystemEdit, SourceChange, SourceFileEdit};
15 18
16#[derive(Debug, Copy, Clone)] 19#[derive(Debug, Copy, Clone)]
17pub enum Severity { 20pub enum Severity {
@@ -170,9 +173,9 @@ fn check_struct_shorthand_initialization(
170 173
171#[cfg(test)] 174#[cfg(test)]
172mod tests { 175mod tests {
173 use test_utils::assert_eq_text;
174 use insta::assert_debug_snapshot_matches; 176 use insta::assert_debug_snapshot_matches;
175 use ra_syntax::SourceFile; 177 use ra_syntax::SourceFile;
178 use test_utils::assert_eq_text;
176 179
177 use crate::mock_analysis::single_file; 180 use crate::mock_analysis::single_file;
178 181
diff --git a/crates/ra_ide_api/src/display.rs b/crates/ra_ide_api/src/display.rs
index 882518838..cc59e99d8 100644
--- a/crates/ra_ide_api/src/display.rs
+++ b/crates/ra_ide_api/src/display.rs
@@ -6,14 +6,17 @@ mod navigation_target;
6mod structure; 6mod structure;
7mod short_label; 7mod short_label;
8 8
9use ra_syntax::{ast::{self, AstNode, TypeParamsOwner}, SyntaxKind::{ATTR, COMMENT}}; 9use ra_syntax::{
10 ast::{self, AstNode, TypeParamsOwner},
11 SyntaxKind::{ATTR, COMMENT},
12};
10 13
11pub use navigation_target::NavigationTarget;
12pub use structure::{StructureNode, file_structure};
13pub use function_signature::FunctionSignature; 14pub use function_signature::FunctionSignature;
15pub use navigation_target::NavigationTarget;
16pub use structure::{file_structure, StructureNode};
14 17
18pub(crate) use navigation_target::{description_from_symbol, docs_from_symbol};
15pub(crate) use short_label::ShortLabel; 19pub(crate) use short_label::ShortLabel;
16pub(crate) use navigation_target::{docs_from_symbol, description_from_symbol};
17 20
18pub(crate) fn function_label(node: &ast::FnDef) -> String { 21pub(crate) fn function_label(node: &ast::FnDef) -> String {
19 FunctionSignature::from(node).to_string() 22 FunctionSignature::from(node).to_string()
diff --git a/crates/ra_ide_api/src/display/function_signature.rs b/crates/ra_ide_api/src/display/function_signature.rs
index b0b0c7122..e7ad5a0d1 100644
--- a/crates/ra_ide_api/src/display/function_signature.rs
+++ b/crates/ra_ide_api/src/display/function_signature.rs
@@ -1,11 +1,14 @@
1use std::fmt::{self, Display}; 1use std::fmt::{self, Display};
2 2
3use hir::{Docs, Documentation, HasSource};
3use join_to_string::join; 4use join_to_string::join;
4use ra_syntax::ast::{self, AstNode, NameOwner, VisibilityOwner}; 5use ra_syntax::ast::{self, AstNode, NameOwner, VisibilityOwner};
5use std::convert::From; 6use std::convert::From;
6use hir::{Docs, Documentation, HasSource};
7 7
8use crate::{db, display::{where_predicates, generic_parameters}}; 8use crate::{
9 db,
10 display::{generic_parameters, where_predicates},
11};
9 12
10/// Contains information about a function signature 13/// Contains information about a function signature
11#[derive(Debug)] 14#[derive(Debug)]
diff --git a/crates/ra_ide_api/src/display/navigation_target.rs b/crates/ra_ide_api/src/display/navigation_target.rs
index 823cdaaf3..1edb64e3d 100644
--- a/crates/ra_ide_api/src/display/navigation_target.rs
+++ b/crates/ra_ide_api/src/display/navigation_target.rs
@@ -1,14 +1,15 @@
1use hir::{FieldSource, HasSource, ImplItem, ModuleSource};
1use ra_db::{FileId, SourceDatabase}; 2use ra_db::{FileId, SourceDatabase};
2use ra_syntax::{ 3use ra_syntax::{
3 SyntaxNode, AstNode, SmolStr, TextRange, AstPtr, TreeArc,
4 SyntaxKind::{self, NAME},
5 ast::{self, DocCommentsOwner},
6 algo::visit::{visitor, Visitor}, 4 algo::visit::{visitor, Visitor},
5 ast::{self, DocCommentsOwner},
6 AstNode, AstPtr, SmolStr,
7 SyntaxKind::{self, NAME},
8 SyntaxNode, TextRange, TreeArc,
7}; 9};
8use hir::{ModuleSource, FieldSource, ImplItem, HasSource};
9 10
10use crate::{FileSymbol, db::RootDatabase};
11use super::short_label::ShortLabel; 11use super::short_label::ShortLabel;
12use crate::{db::RootDatabase, FileSymbol};
12 13
13/// `NavigationTarget` represents and element in the editor's UI which you can 14/// `NavigationTarget` represents and element in the editor's UI which you can
14/// click on to navigate to a particular piece of code. 15/// click on to navigate to a particular piece of code.
diff --git a/crates/ra_ide_api/src/display/short_label.rs b/crates/ra_ide_api/src/display/short_label.rs
index dc8245c34..f926f631f 100644
--- a/crates/ra_ide_api/src/display/short_label.rs
+++ b/crates/ra_ide_api/src/display/short_label.rs
@@ -1,6 +1,4 @@
1use ra_syntax::{ 1use ra_syntax::ast::{self, AstNode, NameOwner, TypeAscriptionOwner, VisibilityOwner};
2 ast::{self, NameOwner, VisibilityOwner, TypeAscriptionOwner, AstNode},
3};
4 2
5pub(crate) trait ShortLabel { 3pub(crate) trait ShortLabel {
6 fn short_label(&self) -> Option<String>; 4 fn short_label(&self) -> Option<String>;
diff --git a/crates/ra_ide_api/src/display/structure.rs b/crates/ra_ide_api/src/display/structure.rs
index e5057e833..e5b257b9b 100644
--- a/crates/ra_ide_api/src/display/structure.rs
+++ b/crates/ra_ide_api/src/display/structure.rs
@@ -2,7 +2,7 @@ use crate::TextRange;
2 2
3use ra_syntax::{ 3use ra_syntax::{
4 algo::visit::{visitor, Visitor}, 4 algo::visit::{visitor, Visitor},
5 ast::{self, AttrsOwner, NameOwner, TypeParamsOwner, TypeAscriptionOwner}, 5 ast::{self, AttrsOwner, NameOwner, TypeAscriptionOwner, TypeParamsOwner},
6 AstNode, SourceFile, SyntaxKind, SyntaxNode, WalkEvent, 6 AstNode, SourceFile, SyntaxKind, SyntaxNode, WalkEvent,
7}; 7};
8 8
diff --git a/crates/ra_ide_api/src/extend_selection.rs b/crates/ra_ide_api/src/extend_selection.rs
index a713b762c..655852514 100644
--- a/crates/ra_ide_api/src/extend_selection.rs
+++ b/crates/ra_ide_api/src/extend_selection.rs
@@ -1,13 +1,13 @@
1use ra_db::SourceDatabase; 1use ra_db::SourceDatabase;
2use ra_syntax::{ 2use ra_syntax::{
3 Direction, SyntaxNode, TextRange, TextUnit, SyntaxElement,
4 algo::{find_covering_element, find_token_at_offset, TokenAtOffset}, 3 algo::{find_covering_element, find_token_at_offset, TokenAtOffset},
5 SyntaxKind::*, SyntaxToken,
6 ast::{self, AstNode, AstToken}, 4 ast::{self, AstNode, AstToken},
7 T 5 Direction, SyntaxElement,
6 SyntaxKind::*,
7 SyntaxNode, SyntaxToken, TextRange, TextUnit, T,
8}; 8};
9 9
10use crate::{FileRange, db::RootDatabase}; 10use crate::{db::RootDatabase, FileRange};
11 11
12// FIXME: restore macro support 12// FIXME: restore macro support
13pub(crate) fn extend_selection(db: &RootDatabase, frange: FileRange) -> TextRange { 13pub(crate) fn extend_selection(db: &RootDatabase, frange: FileRange) -> TextRange {
@@ -205,7 +205,7 @@ fn adj_comments(comment: ast::Comment, dir: Direction) -> ast::Comment {
205 205
206#[cfg(test)] 206#[cfg(test)]
207mod tests { 207mod tests {
208 use ra_syntax::{SourceFile, AstNode}; 208 use ra_syntax::{AstNode, SourceFile};
209 use test_utils::extract_offset; 209 use test_utils::extract_offset;
210 210
211 use super::*; 211 use super::*;
diff --git a/crates/ra_ide_api/src/folding_ranges.rs b/crates/ra_ide_api/src/folding_ranges.rs
index 4400ff232..a1e6f94e0 100644
--- a/crates/ra_ide_api/src/folding_ranges.rs
+++ b/crates/ra_ide_api/src/folding_ranges.rs
@@ -1,9 +1,10 @@
1use rustc_hash::FxHashSet; 1use rustc_hash::FxHashSet;
2 2
3use ra_syntax::{ 3use ra_syntax::{
4 SourceFile, SyntaxNode, TextRange, Direction, SyntaxElement,
5 SyntaxKind::{self, *},
6 ast::{self, AstNode, AstToken, VisibilityOwner}, 4 ast::{self, AstNode, AstToken, VisibilityOwner},
5 Direction, SourceFile, SyntaxElement,
6 SyntaxKind::{self, *},
7 SyntaxNode, TextRange,
7}; 8};
8 9
9#[derive(Debug, PartialEq, Eq)] 10#[derive(Debug, PartialEq, Eq)]
diff --git a/crates/ra_ide_api/src/goto_definition.rs b/crates/ra_ide_api/src/goto_definition.rs
index 63ba6cf9d..08feed7dc 100644
--- a/crates/ra_ide_api/src/goto_definition.rs
+++ b/crates/ra_ide_api/src/goto_definition.rs
@@ -1,19 +1,18 @@
1use ra_db::{FileId, SourceDatabase}; 1use ra_db::{FileId, SourceDatabase};
2use ra_syntax::{ 2use ra_syntax::{
3 AstNode, ast::{self, DocCommentsOwner},
4 algo::{ 3 algo::{
5 find_node_at_offset, 4 find_node_at_offset,
6 visit::{visitor, Visitor}, 5 visit::{visitor, Visitor},
7 }, 6 },
8 SyntaxNode, 7 ast::{self, DocCommentsOwner},
8 AstNode, SyntaxNode,
9}; 9};
10 10
11use crate::{ 11use crate::{
12 FilePosition, NavigationTarget,
13 db::RootDatabase, 12 db::RootDatabase,
14 RangeInfo,
15 name_ref_kind::{NameRefKind::*, classify_name_ref},
16 display::ShortLabel, 13 display::ShortLabel,
14 name_ref_kind::{classify_name_ref, NameRefKind::*},
15 FilePosition, NavigationTarget, RangeInfo,
17}; 16};
18 17
19pub(crate) fn goto_definition( 18pub(crate) fn goto_definition(
diff --git a/crates/ra_ide_api/src/goto_type_definition.rs b/crates/ra_ide_api/src/goto_type_definition.rs
index 6f5164e0b..d2d5eae9a 100644
--- a/crates/ra_ide_api/src/goto_type_definition.rs
+++ b/crates/ra_ide_api/src/goto_type_definition.rs
@@ -1,10 +1,7 @@
1use ra_db::SourceDatabase; 1use ra_db::SourceDatabase;
2use ra_syntax::{ 2use ra_syntax::{algo::find_token_at_offset, ast, AstNode};
3 AstNode, ast,
4 algo::find_token_at_offset
5};
6 3
7use crate::{FilePosition, NavigationTarget, db::RootDatabase, RangeInfo}; 4use crate::{db::RootDatabase, FilePosition, NavigationTarget, RangeInfo};
8 5
9pub(crate) fn goto_type_definition( 6pub(crate) fn goto_type_definition(
10 db: &RootDatabase, 7 db: &RootDatabase,
diff --git a/crates/ra_ide_api/src/hover.rs b/crates/ra_ide_api/src/hover.rs
index df877c324..1edeb7579 100644
--- a/crates/ra_ide_api/src/hover.rs
+++ b/crates/ra_ide_api/src/hover.rs
@@ -1,16 +1,22 @@
1use hir::{HasSource, HirDisplay};
1use ra_db::SourceDatabase; 2use ra_db::SourceDatabase;
2use ra_syntax::{ 3use ra_syntax::{
3 AstNode, TreeArc, 4 algo::{
5 ancestors_at_offset, find_covering_element, find_node_at_offset,
6 visit::{visitor, Visitor},
7 },
4 ast::{self, DocCommentsOwner}, 8 ast::{self, DocCommentsOwner},
5 algo::{find_covering_element, find_node_at_offset, ancestors_at_offset, visit::{visitor, Visitor}}, 9 AstNode, TreeArc,
6}; 10};
7use hir::{HirDisplay, HasSource};
8 11
9use crate::{ 12use crate::{
10 db::RootDatabase, 13 db::RootDatabase,
11 RangeInfo, FilePosition, FileRange, 14 display::{
12 display::{rust_code_markup, rust_code_markup_with_doc, ShortLabel, docs_from_symbol, description_from_symbol}, 15 description_from_symbol, docs_from_symbol, rust_code_markup, rust_code_markup_with_doc,
13 name_ref_kind::{NameRefKind::*, classify_name_ref}, 16 ShortLabel,
17 },
18 name_ref_kind::{classify_name_ref, NameRefKind::*},
19 FilePosition, FileRange, RangeInfo,
14}; 20};
15 21
16/// Contains the results when hovering over an item 22/// Contains the results when hovering over an item
@@ -256,8 +262,10 @@ pub(crate) fn type_of(db: &RootDatabase, frange: FileRange) -> Option<String> {
256 262
257#[cfg(test)] 263#[cfg(test)]
258mod tests { 264mod tests {
265 use crate::mock_analysis::{
266 analysis_and_position, single_file_with_position, single_file_with_range,
267 };
259 use ra_syntax::TextRange; 268 use ra_syntax::TextRange;
260 use crate::mock_analysis::{single_file_with_position, single_file_with_range, analysis_and_position};
261 269
262 fn trim_markup(s: &str) -> &str { 270 fn trim_markup(s: &str) -> &str {
263 s.trim_start_matches("```rust\n").trim_end_matches("\n```") 271 s.trim_start_matches("```rust\n").trim_end_matches("\n```")
diff --git a/crates/ra_ide_api/src/impls.rs b/crates/ra_ide_api/src/impls.rs
index b80238d9e..f8a62bd71 100644
--- a/crates/ra_ide_api/src/impls.rs
+++ b/crates/ra_ide_api/src/impls.rs
@@ -1,11 +1,8 @@
1use ra_db::SourceDatabase;
2use ra_syntax::{
3 AstNode, ast,
4 algo::find_node_at_offset,
5};
6use hir::{db::HirDatabase, source_binder}; 1use hir::{db::HirDatabase, source_binder};
2use ra_db::SourceDatabase;
3use ra_syntax::{algo::find_node_at_offset, ast, AstNode};
7 4
8use crate::{FilePosition, NavigationTarget, db::RootDatabase, RangeInfo}; 5use crate::{db::RootDatabase, FilePosition, NavigationTarget, RangeInfo};
9 6
10pub(crate) fn goto_implementation( 7pub(crate) fn goto_implementation(
11 db: &RootDatabase, 8 db: &RootDatabase,
diff --git a/crates/ra_ide_api/src/join_lines.rs b/crates/ra_ide_api/src/join_lines.rs
index 3978e9635..8ab485adb 100644
--- a/crates/ra_ide_api/src/join_lines.rs
+++ b/crates/ra_ide_api/src/join_lines.rs
@@ -1,14 +1,11 @@
1use itertools::Itertools; 1use itertools::Itertools;
2use ra_fmt::{compute_ws, extract_trivial_expression};
2use ra_syntax::{ 3use ra_syntax::{
3 T,
4 SourceFile, TextRange, TextUnit, SyntaxNode, SyntaxElement, SyntaxToken,
5 SyntaxKind::{self, WHITESPACE},
6 algo::{find_covering_element, non_trivia_sibling}, 4 algo::{find_covering_element, non_trivia_sibling},
7 ast::{self, AstNode, AstToken}, 5 ast::{self, AstNode, AstToken},
8 Direction, 6 Direction, SourceFile, SyntaxElement,
9}; 7 SyntaxKind::{self, WHITESPACE},
10use ra_fmt::{ 8 SyntaxNode, SyntaxToken, TextRange, TextUnit, T,
11 compute_ws, extract_trivial_expression
12}; 9};
13use ra_text_edit::{TextEdit, TextEditBuilder}; 10use ra_text_edit::{TextEdit, TextEditBuilder};
14 11
diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs
index 817e65df0..95de9bcb8 100644
--- a/crates/ra_ide_api/src/lib.rs
+++ b/crates/ra_ide_api/src/lib.rs
@@ -46,33 +46,35 @@ mod test_utils;
46 46
47use std::sync::Arc; 47use std::sync::Arc;
48 48
49use ra_syntax::{SourceFile, TreeArc, TextRange, TextUnit};
50use ra_text_edit::TextEdit;
51use ra_db::{ 49use ra_db::{
52 SourceDatabase, CheckCanceled,
53 salsa::{self, ParallelDatabase}, 50 salsa::{self, ParallelDatabase},
51 CheckCanceled, SourceDatabase,
54}; 52};
53use ra_syntax::{SourceFile, TextRange, TextUnit, TreeArc};
54use ra_text_edit::TextEdit;
55use relative_path::RelativePathBuf; 55use relative_path::RelativePathBuf;
56 56
57use crate::{symbol_index::FileSymbol, db::LineIndexDatabase}; 57use crate::{db::LineIndexDatabase, symbol_index::FileSymbol};
58 58
59pub use crate::{ 59pub use crate::{
60 assists::{Assist, AssistId},
60 change::{AnalysisChange, LibraryData}, 61 change::{AnalysisChange, LibraryData},
61 completion::{CompletionItem, CompletionItemKind, InsertTextFormat}, 62 completion::{CompletionItem, CompletionItemKind, InsertTextFormat},
62 runnables::{Runnable, RunnableKind}, 63 diagnostics::Severity,
63 references::ReferenceSearchResult, 64 display::{file_structure, FunctionSignature, NavigationTarget, StructureNode},
64 assists::{Assist, AssistId},
65 hover::{HoverResult},
66 line_index::{LineIndex, LineCol},
67 line_index_utils::translate_offset_with_edit,
68 folding_ranges::{Fold, FoldKind}, 65 folding_ranges::{Fold, FoldKind},
66 hover::HoverResult,
67 line_index::{LineCol, LineIndex},
68 line_index_utils::translate_offset_with_edit,
69 references::ReferenceSearchResult,
70 runnables::{Runnable, RunnableKind},
69 syntax_highlighting::HighlightedRange, 71 syntax_highlighting::HighlightedRange,
70 diagnostics::Severity,
71 display::{FunctionSignature, NavigationTarget, StructureNode, file_structure},
72}; 72};
73 73
74pub use ra_db::{Canceled, CrateGraph, CrateId, FileId, FilePosition, FileRange, SourceRootId, Edition};
75pub use hir::Documentation; 74pub use hir::Documentation;
75pub use ra_db::{
76 Canceled, CrateGraph, CrateId, Edition, FileId, FilePosition, FileRange, SourceRootId,
77};
76 78
77pub type Cancelable<T> = Result<T, Canceled>; 79pub type Cancelable<T> = Result<T, Canceled>;
78 80
diff --git a/crates/ra_ide_api/src/line_index.rs b/crates/ra_ide_api/src/line_index.rs
index a53cf9ee0..71de8a928 100644
--- a/crates/ra_ide_api/src/line_index.rs
+++ b/crates/ra_ide_api/src/line_index.rs
@@ -145,7 +145,7 @@ pub fn to_line_col(text: &str, offset: TextUnit) -> LineCol {
145mod test_line_index { 145mod test_line_index {
146 use super::*; 146 use super::*;
147 use proptest::{prelude::*, proptest}; 147 use proptest::{prelude::*, proptest};
148 use ra_text_edit::test_utils::{arb_text, arb_offset}; 148 use ra_text_edit::test_utils::{arb_offset, arb_text};
149 149
150 #[test] 150 #[test]
151 fn test_line_index() { 151 fn test_line_index() {
diff --git a/crates/ra_ide_api/src/line_index_utils.rs b/crates/ra_ide_api/src/line_index_utils.rs
index a03467011..f9073dca2 100644
--- a/crates/ra_ide_api/src/line_index_utils.rs
+++ b/crates/ra_ide_api/src/line_index_utils.rs
@@ -1,6 +1,6 @@
1use crate::{line_index::Utf16Char, LineCol, LineIndex};
2use ra_syntax::{TextRange, TextUnit};
1use ra_text_edit::{AtomTextEdit, TextEdit}; 3use ra_text_edit::{AtomTextEdit, TextEdit};
2use ra_syntax::{TextUnit, TextRange};
3use crate::{LineIndex, LineCol, line_index::Utf16Char};
4 4
5#[derive(Debug, Clone)] 5#[derive(Debug, Clone)]
6enum Step { 6enum Step {
@@ -292,8 +292,8 @@ pub fn translate_offset_with_edit(
292#[cfg(test)] 292#[cfg(test)]
293mod test { 293mod test {
294 use super::*; 294 use super::*;
295 use proptest::{prelude::*, proptest};
296 use crate::line_index; 295 use crate::line_index;
296 use proptest::{prelude::*, proptest};
297 use ra_text_edit::test_utils::{arb_offset, arb_text_with_edit}; 297 use ra_text_edit::test_utils::{arb_offset, arb_text_with_edit};
298 use ra_text_edit::TextEdit; 298 use ra_text_edit::TextEdit;
299 299
diff --git a/crates/ra_ide_api/src/matching_brace.rs b/crates/ra_ide_api/src/matching_brace.rs
index 7f3e65b46..438b07896 100644
--- a/crates/ra_ide_api/src/matching_brace.rs
+++ b/crates/ra_ide_api/src/matching_brace.rs
@@ -1,10 +1,4 @@
1use ra_syntax::{ 1use ra_syntax::{algo::find_token_at_offset, ast::AstNode, SourceFile, SyntaxKind, TextUnit, T};
2 SourceFile, TextUnit,
3 algo::find_token_at_offset,
4 SyntaxKind::{self},
5 ast::AstNode,
6 T
7};
8 2
9pub fn matching_brace(file: &SourceFile, offset: TextUnit) -> Option<TextUnit> { 3pub fn matching_brace(file: &SourceFile, offset: TextUnit) -> Option<TextUnit> {
10 const BRACES: &[SyntaxKind] = 4 const BRACES: &[SyntaxKind] =
diff --git a/crates/ra_ide_api/src/mock_analysis.rs b/crates/ra_ide_api/src/mock_analysis.rs
index cb12dd0b1..4dbbd489a 100644
--- a/crates/ra_ide_api/src/mock_analysis.rs
+++ b/crates/ra_ide_api/src/mock_analysis.rs
@@ -3,7 +3,10 @@ use std::sync::Arc;
3use relative_path::RelativePathBuf; 3use relative_path::RelativePathBuf;
4use test_utils::{extract_offset, extract_range, parse_fixture, CURSOR_MARKER}; 4use test_utils::{extract_offset, extract_range, parse_fixture, CURSOR_MARKER};
5 5
6use crate::{Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId, FilePosition, FileRange, SourceRootId, Edition::Edition2018}; 6use crate::{
7 Analysis, AnalysisChange, AnalysisHost, CrateGraph, Edition::Edition2018, FileId, FilePosition,
8 FileRange, SourceRootId,
9};
7 10
8/// Mock analysis is used in test to bootstrap an AnalysisHost/Analysis 11/// Mock analysis is used in test to bootstrap an AnalysisHost/Analysis
9/// from a set of in-memory files. 12/// from a set of in-memory files.
diff --git a/crates/ra_ide_api/src/name_ref_kind.rs b/crates/ra_ide_api/src/name_ref_kind.rs
index 000036db4..67381c9c8 100644
--- a/crates/ra_ide_api/src/name_ref_kind.rs
+++ b/crates/ra_ide_api/src/name_ref_kind.rs
@@ -1,5 +1,5 @@
1use ra_syntax::{AstNode, AstPtr, ast};
2use hir::Either; 1use hir::Either;
2use ra_syntax::{ast, AstNode, AstPtr};
3use test_utils::tested_by; 3use test_utils::tested_by;
4 4
5use crate::db::RootDatabase; 5use crate::db::RootDatabase;
diff --git a/crates/ra_ide_api/src/parent_module.rs b/crates/ra_ide_api/src/parent_module.rs
index 27788c984..7d5f9ea2c 100644
--- a/crates/ra_ide_api/src/parent_module.rs
+++ b/crates/ra_ide_api/src/parent_module.rs
@@ -1,6 +1,6 @@
1use ra_db::{FilePosition, FileId, CrateId}; 1use ra_db::{CrateId, FileId, FilePosition};
2 2
3use crate::{NavigationTarget, db::RootDatabase}; 3use crate::{db::RootDatabase, NavigationTarget};
4 4
5/// This returns `Vec` because a module may be included from several places. We 5/// This returns `Vec` because a module may be included from several places. We
6/// don't handle this case yet though, so the Vec has length at most one. 6/// don't handle this case yet though, so the Vec has length at most one.
@@ -29,10 +29,10 @@ pub(crate) fn crate_for(db: &RootDatabase, file_id: FileId) -> Vec<CrateId> {
29#[cfg(test)] 29#[cfg(test)]
30mod tests { 30mod tests {
31 use crate::{ 31 use crate::{
32 AnalysisChange, CrateGraph,
33 mock_analysis::{analysis_and_position, MockAnalysis}, 32 mock_analysis::{analysis_and_position, MockAnalysis},
33 AnalysisChange, CrateGraph,
34 Edition::Edition2018, 34 Edition::Edition2018,
35}; 35 };
36 36
37 #[test] 37 #[test]
38 fn test_resolve_parent_module() { 38 fn test_resolve_parent_module() {
diff --git a/crates/ra_ide_api/src/references.rs b/crates/ra_ide_api/src/references.rs
index 12cdc6a6d..766c0ad74 100644
--- a/crates/ra_ide_api/src/references.rs
+++ b/crates/ra_ide_api/src/references.rs
@@ -1,22 +1,11 @@
1use hir::{source_binder, Either, ModuleSource};
2use ra_db::SourceDatabase;
3use ra_syntax::{algo::find_node_at_offset, ast, AstNode, SourceFile, SyntaxNode};
1use relative_path::{RelativePath, RelativePathBuf}; 4use relative_path::{RelativePath, RelativePathBuf};
2use hir::{ModuleSource, source_binder, Either};
3use ra_db::{SourceDatabase};
4use ra_syntax::{
5 AstNode, SyntaxNode, SourceFile,
6 ast,
7 algo::find_node_at_offset,
8};
9 5
10use crate::{ 6use crate::{
11 db::RootDatabase, 7 db::RootDatabase, FileId, FilePosition, FileRange, FileSystemEdit, NavigationTarget,
12 FilePosition, 8 SourceChange, SourceFileEdit, TextRange,
13 FileRange,
14 FileId,
15 NavigationTarget,
16 FileSystemEdit,
17 SourceChange,
18 SourceFileEdit,
19 TextRange,
20}; 9};
21 10
22#[derive(Debug, Clone)] 11#[derive(Debug, Clone)]
@@ -210,13 +199,12 @@ fn rename_reference(
210 199
211#[cfg(test)] 200#[cfg(test)]
212mod tests { 201mod tests {
202 use crate::{
203 mock_analysis::analysis_and_position, mock_analysis::single_file_with_position, FileId,
204 ReferenceSearchResult,
205 };
213 use insta::assert_debug_snapshot_matches; 206 use insta::assert_debug_snapshot_matches;
214 use test_utils::assert_eq_text; 207 use test_utils::assert_eq_text;
215 use crate::{
216 mock_analysis::single_file_with_position,
217 mock_analysis::analysis_and_position,
218 FileId, ReferenceSearchResult
219};
220 208
221 #[test] 209 #[test]
222 fn test_find_all_refs_for_local() { 210 fn test_find_all_refs_for_local() {
diff --git a/crates/ra_ide_api/src/runnables.rs b/crates/ra_ide_api/src/runnables.rs
index afe629d50..2d2d0b40e 100644
--- a/crates/ra_ide_api/src/runnables.rs
+++ b/crates/ra_ide_api/src/runnables.rs
@@ -1,9 +1,9 @@
1use itertools::Itertools; 1use itertools::Itertools;
2use ra_db::SourceDatabase;
2use ra_syntax::{ 3use ra_syntax::{
3 TextRange, SyntaxNode, 4 ast::{self, AstNode, AttrsOwner, ModuleItemOwner, NameOwner},
4 ast::{self, AstNode, NameOwner, ModuleItemOwner, AttrsOwner}, 5 SyntaxNode, TextRange,
5}; 6};
6use ra_db::SourceDatabase;
7 7
8use crate::{db::RootDatabase, FileId}; 8use crate::{db::RootDatabase, FileId};
9 9
diff --git a/crates/ra_ide_api/src/status.rs b/crates/ra_ide_api/src/status.rs
index ce25f4a87..1bcba0b8b 100644
--- a/crates/ra_ide_api/src/status.rs
+++ b/crates/ra_ide_api/src/status.rs
@@ -1,20 +1,20 @@
1use std::{ 1use std::{fmt, iter::FromIterator, sync::Arc};
2 fmt,
3 iter::FromIterator,
4 sync::Arc,
5};
6 2
7use ra_syntax::{TreeArc, SyntaxNode, Parse, AstNode}; 3use hir::MacroFile;
8use ra_db::{ 4use ra_db::{
5 salsa::{
6 debug::{DebugQueryTable, TableEntry},
7 Database,
8 },
9 FileTextQuery, SourceRootId, 9 FileTextQuery, SourceRootId,
10 salsa::{Database, debug::{DebugQueryTable, TableEntry}},
11}; 10};
12use ra_prof::{Bytes, memory_usage}; 11use ra_prof::{memory_usage, Bytes};
13use hir::MacroFile; 12use ra_syntax::{AstNode, Parse, SyntaxNode, TreeArc};
14 13
15use crate::{ 14use crate::{
16 FileId, db::RootDatabase, 15 db::RootDatabase,
17 symbol_index::{SymbolIndex, LibrarySymbolsQuery}, 16 symbol_index::{LibrarySymbolsQuery, SymbolIndex},
17 FileId,
18}; 18};
19 19
20pub(crate) fn syntax_tree_stats(db: &RootDatabase) -> SyntaxTreeStats { 20pub(crate) fn syntax_tree_stats(db: &RootDatabase) -> SyntaxTreeStats {
diff --git a/crates/ra_ide_api/src/symbol_index.rs b/crates/ra_ide_api/src/symbol_index.rs
index a6cd7bf61..2ca0a25d4 100644
--- a/crates/ra_ide_api/src/symbol_index.rs
+++ b/crates/ra_ide_api/src/symbol_index.rs
@@ -20,31 +20,27 @@
20//! file in the current workspace, and run a query against the union of all 20//! file in the current workspace, and run a query against the union of all
21//! those FSTs. 21//! those FSTs.
22use std::{ 22use std::{
23 fmt,
23 hash::{Hash, Hasher}, 24 hash::{Hash, Hasher},
24 sync::Arc,
25 mem, 25 mem,
26 fmt, 26 sync::Arc,
27}; 27};
28 28
29use fst::{self, Streamer}; 29use fst::{self, Streamer};
30use ra_syntax::{
31 SyntaxNode, SyntaxNodePtr, SourceFile, SmolStr, TreeArc, AstNode,
32 algo::{visit::{visitor, Visitor}},
33 SyntaxKind::{self, *},
34 ast::{self, NameOwner},
35 WalkEvent,
36 TextRange,
37};
38use ra_db::{ 30use ra_db::{
39 SourceRootId, SourceDatabase,
40 salsa::{self, ParallelDatabase}, 31 salsa::{self, ParallelDatabase},
32 SourceDatabase, SourceRootId,
33};
34use ra_syntax::{
35 algo::visit::{visitor, Visitor},
36 ast::{self, NameOwner},
37 AstNode, SmolStr, SourceFile,
38 SyntaxKind::{self, *},
39 SyntaxNode, SyntaxNodePtr, TextRange, TreeArc, WalkEvent,
41}; 40};
42use rayon::prelude::*; 41use rayon::prelude::*;
43 42
44use crate::{ 43use crate::{db::RootDatabase, FileId, Query};
45 FileId, Query,
46 db::RootDatabase,
47};
48 44
49#[salsa::query_group(SymbolsDatabaseStorage)] 45#[salsa::query_group(SymbolsDatabaseStorage)]
50pub(crate) trait SymbolsDatabase: hir::db::HirDatabase { 46pub(crate) trait SymbolsDatabase: hir::db::HirDatabase {
@@ -305,15 +301,11 @@ fn to_file_symbol(node: &SyntaxNode, file_id: FileId) -> Option<FileSymbol> {
305 301
306#[cfg(test)] 302#[cfg(test)]
307mod tests { 303mod tests {
304 use crate::{display::NavigationTarget, mock_analysis::single_file, Query};
308 use ra_syntax::{ 305 use ra_syntax::{
309 SmolStr, 306 SmolStr,
310 SyntaxKind::{FN_DEF, STRUCT_DEF} 307 SyntaxKind::{FN_DEF, STRUCT_DEF},
311}; 308 };
312 use crate::{
313 display::NavigationTarget,
314 mock_analysis::single_file,
315 Query,
316};
317 309
318 #[test] 310 #[test]
319 fn test_world_symbols_with_no_container() { 311 fn test_world_symbols_with_no_container() {
diff --git a/crates/ra_ide_api/src/syntax_highlighting.rs b/crates/ra_ide_api/src/syntax_highlighting.rs
index 3a04a51cd..7c4285b02 100644
--- a/crates/ra_ide_api/src/syntax_highlighting.rs
+++ b/crates/ra_ide_api/src/syntax_highlighting.rs
@@ -1,12 +1,12 @@
1use rustc_hash::{FxHashSet, FxHashMap}; 1use rustc_hash::{FxHashMap, FxHashSet};
2 2
3use ra_syntax::{
4 ast, AstNode, TextRange, Direction, SmolStr, SyntaxKind, SyntaxKind::*, SyntaxElement, T,
5};
6use ra_db::SourceDatabase; 3use ra_db::SourceDatabase;
7use ra_prof::profile; 4use ra_prof::profile;
5use ra_syntax::{
6 ast, AstNode, Direction, SmolStr, SyntaxElement, SyntaxKind, SyntaxKind::*, TextRange, T,
7};
8 8
9use crate::{FileId, db::RootDatabase}; 9use crate::{db::RootDatabase, FileId};
10 10
11#[derive(Debug)] 11#[derive(Debug)]
12pub struct HighlightedRange { 12pub struct HighlightedRange {
@@ -64,7 +64,7 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRa
64 if let Some(name_ref) = node.as_node().and_then(ast::NameRef::cast) { 64 if let Some(name_ref) = node.as_node().and_then(ast::NameRef::cast) {
65 // FIXME: revisit this after #1340 65 // FIXME: revisit this after #1340
66 use crate::name_ref_kind::{classify_name_ref, NameRefKind::*}; 66 use crate::name_ref_kind::{classify_name_ref, NameRefKind::*};
67 use hir::{ModuleDef, ImplItem}; 67 use hir::{ImplItem, ModuleDef};
68 68
69 // FIXME: try to reuse the SourceAnalyzers 69 // FIXME: try to reuse the SourceAnalyzers
70 let analyzer = hir::SourceAnalyzer::new(db, file_id, name_ref.syntax(), None); 70 let analyzer = hir::SourceAnalyzer::new(db, file_id, name_ref.syntax(), None);
@@ -264,8 +264,8 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padding: 0.4e
264 264
265#[cfg(test)] 265#[cfg(test)]
266mod tests { 266mod tests {
267 use test_utils::{project_dir, read_text, assert_eq_text};
268 use crate::mock_analysis::single_file; 267 use crate::mock_analysis::single_file;
268 use test_utils::{assert_eq_text, project_dir, read_text};
269 269
270 #[test] 270 #[test]
271 fn test_highlighting() { 271 fn test_highlighting() {
diff --git a/crates/ra_ide_api/src/syntax_tree.rs b/crates/ra_ide_api/src/syntax_tree.rs
index 7165fa97a..8bdd08d58 100644
--- a/crates/ra_ide_api/src/syntax_tree.rs
+++ b/crates/ra_ide_api/src/syntax_tree.rs
@@ -1,9 +1,9 @@
1use ra_db::SourceDatabase;
2use crate::db::RootDatabase; 1use crate::db::RootDatabase;
2use ra_db::SourceDatabase;
3use ra_syntax::{ 3use ra_syntax::{
4 SourceFile, TextRange, AstNode, SyntaxToken, SyntaxElement, 4 algo, AstNode, SourceFile, SyntaxElement,
5 algo, 5 SyntaxKind::{RAW_STRING, STRING},
6 SyntaxKind::{STRING, RAW_STRING}, 6 SyntaxToken, TextRange,
7}; 7};
8 8
9pub use ra_db::FileId; 9pub use ra_db::FileId;
diff --git a/crates/ra_ide_api/src/typing.rs b/crates/ra_ide_api/src/typing.rs
index 3e35d8352..d3cb71ddb 100644
--- a/crates/ra_ide_api/src/typing.rs
+++ b/crates/ra_ide_api/src/typing.rs
@@ -1,13 +1,14 @@
1use crate::{db::RootDatabase, SourceChange, SourceFileEdit};
2use ra_db::{FilePosition, SourceDatabase};
3use ra_fmt::leading_indent;
1use ra_syntax::{ 4use ra_syntax::{
2 AstNode, SourceFile, SyntaxKind::*,
3 TextUnit, TextRange, SyntaxToken,
4 algo::{find_node_at_offset, find_token_at_offset, TokenAtOffset}, 5 algo::{find_node_at_offset, find_token_at_offset, TokenAtOffset},
5 ast::{self, AstToken}, 6 ast::{self, AstToken},
7 AstNode, SourceFile,
8 SyntaxKind::*,
9 SyntaxToken, TextRange, TextUnit,
6}; 10};
7use ra_fmt::leading_indent;
8use ra_text_edit::{TextEdit, TextEditBuilder}; 11use ra_text_edit::{TextEdit, TextEditBuilder};
9use ra_db::{FilePosition, SourceDatabase};
10use crate::{db::RootDatabase, SourceChange, SourceFileEdit};
11 12
12pub(crate) fn on_enter(db: &RootDatabase, position: FilePosition) -> Option<SourceChange> { 13pub(crate) fn on_enter(db: &RootDatabase, position: FilePosition) -> Option<SourceChange> {
13 let file = db.parse(position.file_id).tree; 14 let file = db.parse(position.file_id).tree;
diff --git a/crates/ra_lsp_server/src/caps.rs b/crates/ra_lsp_server/src/caps.rs
index 9095bee89..3851aadf2 100644
--- a/crates/ra_lsp_server/src/caps.rs
+++ b/crates/ra_lsp_server/src/caps.rs
@@ -1,8 +1,9 @@
1use lsp_types::{ 1use lsp_types::{
2 CodeActionProviderCapability, CodeLensOptions, CompletionOptions, DocumentOnTypeFormattingOptions, 2 CodeActionProviderCapability, CodeLensOptions, CompletionOptions,
3 ExecuteCommandOptions, FoldingRangeProviderCapability, RenameOptions, RenameProviderCapability, 3 DocumentOnTypeFormattingOptions, ExecuteCommandOptions, FoldingRangeProviderCapability,
4 GenericCapability, ImplementationProviderCapability, RenameOptions, RenameProviderCapability,
4 ServerCapabilities, SignatureHelpOptions, TextDocumentSyncCapability, TextDocumentSyncKind, 5 ServerCapabilities, SignatureHelpOptions, TextDocumentSyncCapability, TextDocumentSyncKind,
5 TextDocumentSyncOptions, ImplementationProviderCapability, GenericCapability, TypeDefinitionProviderCapability 6 TextDocumentSyncOptions, TypeDefinitionProviderCapability,
6}; 7};
7 8
8pub fn server_capabilities() -> ServerCapabilities { 9pub fn server_capabilities() -> ServerCapabilities {
diff --git a/crates/ra_lsp_server/src/cargo_target_spec.rs b/crates/ra_lsp_server/src/cargo_target_spec.rs
index 082ac8609..050c5fd95 100644
--- a/crates/ra_lsp_server/src/cargo_target_spec.rs
+++ b/crates/ra_lsp_server/src/cargo_target_spec.rs
@@ -1,7 +1,7 @@
1use crate::{ 1use crate::{
2 project_model::{self, TargetKind}, 2 project_model::{self, TargetKind},
3 world::WorldSnapshot, 3 world::WorldSnapshot,
4 Result 4 Result,
5}; 5};
6 6
7use ra_ide_api::{FileId, RunnableKind}; 7use ra_ide_api::{FileId, RunnableKind};
diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs
index 257492589..c8128f55b 100644
--- a/crates/ra_lsp_server/src/conv.rs
+++ b/crates/ra_lsp_server/src/conv.rs
@@ -1,13 +1,13 @@
1use lsp_types::{ 1use lsp_types::{
2 self, CreateFile, Documentation, DocumentChangeOperation, DocumentChanges, Location, LocationLink, 2 self, CreateFile, DocumentChangeOperation, DocumentChanges, Documentation, Location,
3 MarkupContent, MarkupKind, Position, Range, RenameFile, ResourceOp, SymbolKind, TextDocumentEdit, TextDocumentIdentifier, 3 LocationLink, MarkupContent, MarkupKind, Position, Range, RenameFile, ResourceOp, SymbolKind,
4 TextDocumentItem, TextDocumentPositionParams, Url, VersionedTextDocumentIdentifier, 4 TextDocumentEdit, TextDocumentIdentifier, TextDocumentItem, TextDocumentPositionParams, Url,
5 WorkspaceEdit, 5 VersionedTextDocumentIdentifier, WorkspaceEdit,
6}; 6};
7use ra_ide_api::{ 7use ra_ide_api::{
8 CompletionItem, CompletionItemKind, FileId, FilePosition, FileRange, FileSystemEdit, 8 translate_offset_with_edit, CompletionItem, CompletionItemKind, FileId, FilePosition,
9 NavigationTarget, SourceChange, SourceFileEdit, RangeInfo, 9 FileRange, FileSystemEdit, InsertTextFormat, LineCol, LineIndex, NavigationTarget, RangeInfo,
10 LineCol, LineIndex, translate_offset_with_edit, InsertTextFormat 10 SourceChange, SourceFileEdit,
11}; 11};
12use ra_syntax::{SyntaxKind, TextRange, TextUnit}; 12use ra_syntax::{SyntaxKind, TextRange, TextUnit};
13use ra_text_edit::{AtomTextEdit, TextEdit}; 13use ra_text_edit::{AtomTextEdit, TextEdit};
diff --git a/crates/ra_lsp_server/src/lib.rs b/crates/ra_lsp_server/src/lib.rs
index 14cfa401f..56a263aa5 100644
--- a/crates/ra_lsp_server/src/lib.rs
+++ b/crates/ra_lsp_server/src/lib.rs
@@ -10,4 +10,7 @@ pub mod init;
10mod world; 10mod world;
11 11
12pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>; 12pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
13pub use crate::{caps::server_capabilities, main_loop::main_loop, main_loop::LspError, init::InitializationOptions}; 13pub use crate::{
14 caps::server_capabilities, init::InitializationOptions, main_loop::main_loop,
15 main_loop::LspError,
16};
diff --git a/crates/ra_lsp_server/src/main.rs b/crates/ra_lsp_server/src/main.rs
index 4aadb5ea8..6aa6dd49f 100644
--- a/crates/ra_lsp_server/src/main.rs
+++ b/crates/ra_lsp_server/src/main.rs
@@ -1,8 +1,8 @@
1use serde::Deserialize;
2use flexi_logger::{Duplicate, Logger}; 1use flexi_logger::{Duplicate, Logger};
3use gen_lsp_server::{run_server, stdio_transport}; 2use gen_lsp_server::{run_server, stdio_transport};
3use serde::Deserialize;
4 4
5use ra_lsp_server::{Result, InitializationOptions}; 5use ra_lsp_server::{InitializationOptions, Result};
6use ra_prof; 6use ra_prof;
7 7
8fn main() -> Result<()> { 8fn main() -> Result<()> {
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs
index aeb8a2299..cb73e6586 100644
--- a/crates/ra_lsp_server/src/main_loop.rs
+++ b/crates/ra_lsp_server/src/main_loop.rs
@@ -2,7 +2,7 @@ mod handlers;
2mod subscriptions; 2mod subscriptions;
3pub(crate) mod pending_requests; 3pub(crate) mod pending_requests;
4 4
5use std::{fmt, path::PathBuf, sync::Arc, time::Instant, error::Error}; 5use std::{error::Error, fmt, path::PathBuf, sync::Arc, time::Instant};
6 6
7use crossbeam_channel::{select, unbounded, Receiver, RecvError, Sender}; 7use crossbeam_channel::{select, unbounded, Receiver, RecvError, Sender};
8use gen_lsp_server::{ 8use gen_lsp_server::{
@@ -10,21 +10,20 @@ use gen_lsp_server::{
10}; 10};
11use lsp_types::NumberOrString; 11use lsp_types::NumberOrString;
12use ra_ide_api::{Canceled, FileId, LibraryData}; 12use ra_ide_api::{Canceled, FileId, LibraryData};
13use ra_prof::profile;
13use ra_vfs::VfsTask; 14use ra_vfs::VfsTask;
14use serde::{de::DeserializeOwned, Serialize}; 15use serde::{de::DeserializeOwned, Serialize};
15use threadpool::ThreadPool; 16use threadpool::ThreadPool;
16use ra_prof::profile;
17 17
18use crate::{ 18use crate::{
19 main_loop::{ 19 main_loop::{
20 pending_requests::{PendingRequest, PendingRequests},
20 subscriptions::Subscriptions, 21 subscriptions::Subscriptions,
21 pending_requests::{PendingRequests, PendingRequest},
22 }, 22 },
23 project_model::workspace_loader, 23 project_model::workspace_loader,
24 req, 24 req,
25 world::{WorldSnapshot, WorldState}, 25 world::{WorldSnapshot, WorldState},
26 Result, 26 InitializationOptions, Result,
27 InitializationOptions,
28}; 27};
29 28
30const THREADPOOL_SIZE: usize = 8; 29const THREADPOOL_SIZE: usize = 8;
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs
index 47222cd0a..bbbc93b1c 100644
--- a/crates/ra_lsp_server/src/main_loop/handlers.rs
+++ b/crates/ra_lsp_server/src/main_loop/handlers.rs
@@ -1,22 +1,21 @@
1use std::{io::Write as _, fmt::Write as _}; 1use std::{fmt::Write as _, io::Write as _};
2 2
3use gen_lsp_server::ErrorCode; 3use gen_lsp_server::ErrorCode;
4use lsp_types::{ 4use lsp_types::{
5 CodeActionResponse, CodeLens, Command, Diagnostic, DiagnosticSeverity, CodeAction, 5 CodeAction, CodeActionResponse, CodeLens, Command, Diagnostic, DiagnosticSeverity,
6 DocumentFormattingParams, DocumentHighlight, DocumentSymbol, FoldingRange, 6 DocumentFormattingParams, DocumentHighlight, DocumentSymbol, FoldingRange, FoldingRangeKind,
7 FoldingRangeKind, FoldingRangeParams, Hover, HoverContents, Location, MarkupContent, 7 FoldingRangeParams, Hover, HoverContents, Location, MarkupContent, MarkupKind, Position,
8 MarkupKind, Position, PrepareRenameResponse, Range, 8 PrepareRenameResponse, Range, RenameParams, SymbolInformation, TextDocumentIdentifier,
9 RenameParams,SymbolInformation, TextDocumentIdentifier, TextEdit, 9 TextEdit, WorkspaceEdit,
10 WorkspaceEdit,
11}; 10};
12use ra_ide_api::{ 11use ra_ide_api::{
13 FileId, FilePosition, FileRange, FoldKind, Query, RangeInfo, RunnableKind, Severity, Cancelable, 12 AssistId, Cancelable, FileId, FilePosition, FileRange, FoldKind, Query, RangeInfo,
14 AssistId, 13 RunnableKind, Severity,
15}; 14};
16use ra_syntax::{AstNode, SyntaxKind, TextUnit, TextRange};
17use ra_prof::profile; 15use ra_prof::profile;
16use ra_syntax::{AstNode, SyntaxKind, TextRange, TextUnit};
18use rustc_hash::FxHashMap; 17use rustc_hash::FxHashMap;
19use serde::{Serialize, Deserialize}; 18use serde::{Deserialize, Serialize};
20use serde_json::to_value; 19use serde_json::to_value;
21use url_serde::Ser; 20use url_serde::Ser;
22 21
diff --git a/crates/ra_lsp_server/src/project_model.rs b/crates/ra_lsp_server/src/project_model.rs
index 7d6440fad..1130d08de 100644
--- a/crates/ra_lsp_server/src/project_model.rs
+++ b/crates/ra_lsp_server/src/project_model.rs
@@ -5,7 +5,7 @@ use thread_worker::Worker;
5use crate::Result; 5use crate::Result;
6 6
7pub use ra_project_model::{ 7pub use ra_project_model::{
8 ProjectWorkspace, CargoWorkspace, Package, Target, TargetKind, Sysroot, 8 CargoWorkspace, Package, ProjectWorkspace, Sysroot, Target, TargetKind,
9}; 9};
10 10
11pub fn workspace_loader() -> Worker<PathBuf, Result<ProjectWorkspace>> { 11pub fn workspace_loader() -> Worker<PathBuf, Result<ProjectWorkspace>> {
diff --git a/crates/ra_lsp_server/src/req.rs b/crates/ra_lsp_server/src/req.rs
index 992c24eac..27f2deb34 100644
--- a/crates/ra_lsp_server/src/req.rs
+++ b/crates/ra_lsp_server/src/req.rs
@@ -4,12 +4,11 @@ use serde::{Deserialize, Serialize};
4use url_serde; 4use url_serde;
5 5
6pub use lsp_types::{ 6pub use lsp_types::{
7 notification::*, request::*, ApplyWorkspaceEditParams, CodeActionParams, CodeLens, CodeLensParams, 7 notification::*, request::*, ApplyWorkspaceEditParams, CodeActionParams, CodeLens,
8 CompletionParams, CompletionResponse, DocumentOnTypeFormattingParams, DocumentSymbolParams, 8 CodeLensParams, CompletionParams, CompletionResponse, DocumentOnTypeFormattingParams,
9 DocumentSymbolResponse, ExecuteCommandParams, Hover, InitializeResult, 9 DocumentSymbolParams, DocumentSymbolResponse, ExecuteCommandParams, Hover, InitializeResult,
10 PublishDiagnosticsParams, ReferenceParams, SignatureHelp, TextDocumentEdit, 10 MessageType, PublishDiagnosticsParams, ReferenceParams, ShowMessageParams, SignatureHelp,
11 TextDocumentPositionParams, TextEdit, WorkspaceEdit, WorkspaceSymbolParams, 11 TextDocumentEdit, TextDocumentPositionParams, TextEdit, WorkspaceEdit, WorkspaceSymbolParams,
12 MessageType, ShowMessageParams,
13}; 12};
14 13
15pub enum AnalyzerStatus {} 14pub enum AnalyzerStatus {}
diff --git a/crates/ra_lsp_server/src/vfs_filter.rs b/crates/ra_lsp_server/src/vfs_filter.rs
index dd20c1203..e16a57da5 100644
--- a/crates/ra_lsp_server/src/vfs_filter.rs
+++ b/crates/ra_lsp_server/src/vfs_filter.rs
@@ -1,6 +1,6 @@
1use std::path::PathBuf;
2use ra_project_model::ProjectRoot; 1use ra_project_model::ProjectRoot;
3use ra_vfs::{RootEntry, Filter, RelativePath}; 2use ra_vfs::{Filter, RelativePath, RootEntry};
3use std::path::PathBuf;
4 4
5/// `IncludeRustFiles` is used to convert 5/// `IncludeRustFiles` is used to convert
6/// from `ProjectRoot` to `RootEntry` for VFS 6/// from `ProjectRoot` to `RootEntry` for VFS
diff --git a/crates/ra_lsp_server/src/world.rs b/crates/ra_lsp_server/src/world.rs
index 7822e1c1c..fdc577622 100644
--- a/crates/ra_lsp_server/src/world.rs
+++ b/crates/ra_lsp_server/src/world.rs
@@ -3,22 +3,20 @@ use std::{
3 sync::Arc, 3 sync::Arc,
4}; 4};
5 5
6use gen_lsp_server::ErrorCode;
6use lsp_types::Url; 7use lsp_types::Url;
8use parking_lot::RwLock;
7use ra_ide_api::{ 9use ra_ide_api::{
8 Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId, LibraryData, 10 Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId, LibraryData, SourceRootId,
9 SourceRootId
10}; 11};
11use ra_vfs::{Vfs, VfsChange, VfsFile, VfsRoot}; 12use ra_vfs::{Vfs, VfsChange, VfsFile, VfsRoot};
12use relative_path::RelativePathBuf; 13use relative_path::RelativePathBuf;
13use parking_lot::RwLock;
14use gen_lsp_server::ErrorCode;
15 14
16use crate::{ 15use crate::{
17 main_loop::pending_requests::{CompletedRequest, LatestRequests}, 16 main_loop::pending_requests::{CompletedRequest, LatestRequests},
18 project_model::ProjectWorkspace, 17 project_model::ProjectWorkspace,
19 vfs_filter::IncludeRustFiles, 18 vfs_filter::IncludeRustFiles,
20 Result, 19 LspError, Result,
21 LspError,
22}; 20};
23 21
24/// `WorldState` is the primary mutable state of the language server 22/// `WorldState` is the primary mutable state of the language server
diff --git a/crates/ra_lsp_server/tests/heavy_tests/main.rs b/crates/ra_lsp_server/tests/heavy_tests/main.rs
index 40d825893..d271b02fc 100644
--- a/crates/ra_lsp_server/tests/heavy_tests/main.rs
+++ b/crates/ra_lsp_server/tests/heavy_tests/main.rs
@@ -1,16 +1,14 @@
1mod support; 1mod support;
2 2
3use std::{ 3use std::{collections::HashMap, time::Instant};
4 collections::HashMap,
5 time::Instant,
6};
7 4
8use lsp_types::{ 5use lsp_types::{
9 CodeActionContext, DocumentFormattingParams, FormattingOptions, Position, Range, DidOpenTextDocumentParams, TextDocumentItem, TextDocumentPositionParams 6 CodeActionContext, DidOpenTextDocumentParams, DocumentFormattingParams, FormattingOptions,
7 Position, Range, TextDocumentItem, TextDocumentPositionParams,
10}; 8};
11use ra_lsp_server::req::{ 9use ra_lsp_server::req::{
12 CodeActionParams, CodeActionRequest, Formatting, Runnables, RunnablesParams, CompletionParams, Completion, 10 CodeActionParams, CodeActionRequest, Completion, CompletionParams, DidOpenTextDocument,
13 DidOpenTextDocument, OnEnter, 11 Formatting, OnEnter, Runnables, RunnablesParams,
14}; 12};
15use serde_json::json; 13use serde_json::json;
16use tempfile::TempDir; 14use tempfile::TempDir;
diff --git a/crates/ra_lsp_server/tests/heavy_tests/support.rs b/crates/ra_lsp_server/tests/heavy_tests/support.rs
index 75912afdd..a5e352da1 100644
--- a/crates/ra_lsp_server/tests/heavy_tests/support.rs
+++ b/crates/ra_lsp_server/tests/heavy_tests/support.rs
@@ -11,20 +11,17 @@ use flexi_logger::Logger;
11use gen_lsp_server::{RawMessage, RawNotification, RawRequest}; 11use gen_lsp_server::{RawMessage, RawNotification, RawRequest};
12use lsp_types::{ 12use lsp_types::{
13 notification::DidOpenTextDocument, 13 notification::DidOpenTextDocument,
14 notification::{Notification, ShowMessage},
14 request::{Request, Shutdown}, 15 request::{Request, Shutdown},
15 DidOpenTextDocumentParams, TextDocumentIdentifier, TextDocumentItem, Url, 16 DidOpenTextDocumentParams, TextDocumentIdentifier, TextDocumentItem, Url,
16 notification::{Notification, ShowMessage},
17}; 17};
18use serde::Serialize; 18use serde::Serialize;
19use serde_json::{to_string_pretty, Value}; 19use serde_json::{to_string_pretty, Value};
20use tempfile::TempDir; 20use tempfile::TempDir;
21use test_utils::{find_mismatch, parse_fixture};
21use thread_worker::Worker; 22use thread_worker::Worker;
22use test_utils::{parse_fixture, find_mismatch};
23 23
24use ra_lsp_server::{ 24use ra_lsp_server::{main_loop, req, InitializationOptions};
25 main_loop, req,
26 InitializationOptions,
27};
28 25
29pub struct Project<'a> { 26pub struct Project<'a> {
30 fixture: &'a str, 27 fixture: &'a str,
diff --git a/crates/ra_mbe/src/lib.rs b/crates/ra_mbe/src/lib.rs
index c146252a4..52c3d03b5 100644
--- a/crates/ra_mbe/src/lib.rs
+++ b/crates/ra_mbe/src/lib.rs
@@ -41,14 +41,8 @@ pub enum ExpandError {
41} 41}
42 42
43pub use crate::syntax_bridge::{ 43pub use crate::syntax_bridge::{
44 ast_to_token_tree, 44 ast_to_token_tree, syntax_node_to_token_tree, token_tree_to_ast_item_list, token_tree_to_expr,
45 token_tree_to_ast_item_list, 45 token_tree_to_macro_items, token_tree_to_macro_stmts, token_tree_to_pat, token_tree_to_ty,
46 syntax_node_to_token_tree,
47 token_tree_to_expr,
48 token_tree_to_pat,
49 token_tree_to_ty,
50 token_tree_to_macro_items,
51 token_tree_to_macro_stmts,
52}; 46};
53 47
54/// This struct contains AST for a single `macro_rules` definition. What might 48/// This struct contains AST for a single `macro_rules` definition. What might
diff --git a/crates/ra_mbe/src/mbe_expander.rs b/crates/ra_mbe/src/mbe_expander.rs
index 55a6ecf58..fbad8ebe2 100644
--- a/crates/ra_mbe/src/mbe_expander.rs
+++ b/crates/ra_mbe/src/mbe_expander.rs
@@ -1,12 +1,12 @@
1use ra_syntax::SmolStr;
1/// This module takes a (parsed) definition of `macro_rules` invocation, a 2/// This module takes a (parsed) definition of `macro_rules` invocation, a
2/// `tt::TokenTree` representing an argument of macro invocation, and produces a 3/// `tt::TokenTree` representing an argument of macro invocation, and produces a
3/// `tt::TokenTree` for the result of the expansion. 4/// `tt::TokenTree` for the result of the expansion.
4use rustc_hash::FxHashMap; 5use rustc_hash::FxHashMap;
5use ra_syntax::SmolStr;
6use tt::TokenId; 6use tt::TokenId;
7 7
8use crate::ExpandError;
9use crate::tt_cursor::TtCursor; 8use crate::tt_cursor::TtCursor;
9use crate::ExpandError;
10 10
11pub(crate) fn expand( 11pub(crate) fn expand(
12 rules: &crate::MacroRules, 12 rules: &crate::MacroRules,
diff --git a/crates/ra_mbe/src/mbe_parser.rs b/crates/ra_mbe/src/mbe_parser.rs
index dca16b537..a29885852 100644
--- a/crates/ra_mbe/src/mbe_parser.rs
+++ b/crates/ra_mbe/src/mbe_parser.rs
@@ -1,8 +1,8 @@
1use crate::tt_cursor::TtCursor;
1/// This module parses a raw `tt::TokenStream` into macro-by-example token 2/// This module parses a raw `tt::TokenStream` into macro-by-example token
2/// stream. This is a *mostly* identify function, expect for handling of 3/// stream. This is a *mostly* identify function, expect for handling of
3/// `$var:tt_kind` and `$(repeat),*` constructs. 4/// `$var:tt_kind` and `$(repeat),*` constructs.
4use crate::ParseError; 5use crate::ParseError;
5use crate::tt_cursor::TtCursor;
6 6
7pub(crate) fn parse(tt: &tt::Subtree) -> Result<crate::MacroRules, ParseError> { 7pub(crate) fn parse(tt: &tt::Subtree) -> Result<crate::MacroRules, ParseError> {
8 let mut parser = TtCursor::new(tt); 8 let mut parser = TtCursor::new(tt);
diff --git a/crates/ra_mbe/src/subtree_parser.rs b/crates/ra_mbe/src/subtree_parser.rs
index 4a6f6aa45..5688e7f7f 100644
--- a/crates/ra_mbe/src/subtree_parser.rs
+++ b/crates/ra_mbe/src/subtree_parser.rs
@@ -1,8 +1,8 @@
1use crate::subtree_source::SubtreeTokenSource; 1use crate::subtree_source::SubtreeTokenSource;
2 2
3use ra_parser::{TokenSource, TreeSink}; 3use ra_parser::{TokenSource, TreeSink};
4use ra_syntax::{SyntaxKind}; 4use ra_syntax::SyntaxKind;
5use tt::buffer::{TokenBuffer, Cursor}; 5use tt::buffer::{Cursor, TokenBuffer};
6 6
7struct OffsetTokenSink<'a> { 7struct OffsetTokenSink<'a> {
8 cursor: Cursor<'a>, 8 cursor: Cursor<'a>,
diff --git a/crates/ra_mbe/src/subtree_source.rs b/crates/ra_mbe/src/subtree_source.rs
index 7647e16d8..2489c996b 100644
--- a/crates/ra_mbe/src/subtree_source.rs
+++ b/crates/ra_mbe/src/subtree_source.rs
@@ -1,7 +1,7 @@
1use ra_parser::{TokenSource, Token}; 1use ra_parser::{Token, TokenSource};
2use ra_syntax::{classify_literal, SmolStr, SyntaxKind, SyntaxKind::*, T}; 2use ra_syntax::{classify_literal, SmolStr, SyntaxKind, SyntaxKind::*, T};
3use std::cell::{RefCell, Cell}; 3use std::cell::{Cell, RefCell};
4use tt::buffer::{TokenBuffer, Cursor}; 4use tt::buffer::{Cursor, TokenBuffer};
5 5
6#[derive(Debug, Clone, Eq, PartialEq)] 6#[derive(Debug, Clone, Eq, PartialEq)]
7struct TtToken { 7struct TtToken {
diff --git a/crates/ra_mbe/src/syntax_bridge.rs b/crates/ra_mbe/src/syntax_bridge.rs
index cb039ca37..b91b0e7a5 100644
--- a/crates/ra_mbe/src/syntax_bridge.rs
+++ b/crates/ra_mbe/src/syntax_bridge.rs
@@ -1,11 +1,11 @@
1use ra_parser::{TreeSink, ParseError}; 1use crate::subtree_source::SubtreeTokenSource;
2use crate::ExpandError;
3use ra_parser::{ParseError, TreeSink};
2use ra_syntax::{ 4use ra_syntax::{
3 AstNode, SyntaxNode, TextRange, SyntaxKind, SmolStr, SyntaxTreeBuilder, TreeArc, SyntaxElement, 5 ast, AstNode, SmolStr, SyntaxElement, SyntaxKind, SyntaxKind::*, SyntaxNode, SyntaxTreeBuilder,
4 ast, SyntaxKind::*, TextUnit, T 6 TextRange, TextUnit, TreeArc, T,
5}; 7};
6use tt::buffer::{TokenBuffer, Cursor}; 8use tt::buffer::{Cursor, TokenBuffer};
7use crate::subtree_source::{SubtreeTokenSource};
8use crate::ExpandError;
9 9
10/// Maps `tt::TokenId` to the relative range of the original token. 10/// Maps `tt::TokenId` to the relative range of the original token.
11#[derive(Default)] 11#[derive(Default)]
@@ -367,7 +367,7 @@ impl<'a> TreeSink for TtTreeSink<'a> {
367#[cfg(test)] 367#[cfg(test)]
368mod tests { 368mod tests {
369 use super::*; 369 use super::*;
370 use crate::tests::{expand, create_rules}; 370 use crate::tests::{create_rules, expand};
371 use ra_parser::TokenSource; 371 use ra_parser::TokenSource;
372 372
373 #[test] 373 #[test]
diff --git a/crates/ra_mbe/src/tt_cursor.rs b/crates/ra_mbe/src/tt_cursor.rs
index d85ab43e4..503c77ef3 100644
--- a/crates/ra_mbe/src/tt_cursor.rs
+++ b/crates/ra_mbe/src/tt_cursor.rs
@@ -1,6 +1,6 @@
1use crate::ParseError;
2use crate::subtree_parser::Parser; 1use crate::subtree_parser::Parser;
3use smallvec::{SmallVec, smallvec}; 2use crate::ParseError;
3use smallvec::{smallvec, SmallVec};
4 4
5#[derive(Debug, Clone)] 5#[derive(Debug, Clone)]
6pub(crate) struct TtCursor<'a> { 6pub(crate) struct TtCursor<'a> {
diff --git a/crates/ra_parser/src/event.rs b/crates/ra_parser/src/event.rs
index 51beb0866..a7d06a815 100644
--- a/crates/ra_parser/src/event.rs
+++ b/crates/ra_parser/src/event.rs
@@ -10,8 +10,9 @@
10use std::mem; 10use std::mem;
11 11
12use crate::{ 12use crate::{
13 ParseError, TreeSink, 13 ParseError,
14 SyntaxKind::{self, *}, 14 SyntaxKind::{self, *},
15 TreeSink,
15}; 16};
16 17
17/// `Parser` produces a flat list of `Event`s. 18/// `Parser` produces a flat list of `Event`s.
diff --git a/crates/ra_parser/src/grammar.rs b/crates/ra_parser/src/grammar.rs
index 5997636d6..658034097 100644
--- a/crates/ra_parser/src/grammar.rs
+++ b/crates/ra_parser/src/grammar.rs
@@ -37,9 +37,9 @@ mod type_params;
37mod types; 37mod types;
38 38
39use crate::{ 39use crate::{
40 parser::{CompletedMarker, Marker, Parser},
40 SyntaxKind::{self, *}, 41 SyntaxKind::{self, *},
41 TokenSet, 42 TokenSet,
42 parser::{CompletedMarker, Marker, Parser},
43}; 43};
44 44
45pub(crate) fn root(p: &mut Parser) { 45pub(crate) fn root(p: &mut Parser) {
diff --git a/crates/ra_parser/src/parser.rs b/crates/ra_parser/src/parser.rs
index 8a2e253ac..159ed50df 100644
--- a/crates/ra_parser/src/parser.rs
+++ b/crates/ra_parser/src/parser.rs
@@ -3,10 +3,10 @@ use std::cell::Cell;
3use drop_bomb::DropBomb; 3use drop_bomb::DropBomb;
4 4
5use crate::{ 5use crate::{
6 SyntaxKind::{self, ERROR, EOF, TOMBSTONE},
7 TokenSource, ParseError, TokenSet,
8 event::Event, 6 event::Event,
9 T 7 ParseError,
8 SyntaxKind::{self, EOF, ERROR, TOMBSTONE},
9 TokenSet, TokenSource, T,
10}; 10};
11 11
12/// `Parser` struct provides the low-level API for 12/// `Parser` struct provides the low-level API for
diff --git a/crates/ra_prof/src/lib.rs b/crates/ra_prof/src/lib.rs
index 6f7918745..919cc1b3c 100644
--- a/crates/ra_prof/src/lib.rs
+++ b/crates/ra_prof/src/lib.rs
@@ -2,18 +2,21 @@ mod memory_usage;
2 2
3use std::{ 3use std::{
4 cell::RefCell, 4 cell::RefCell,
5 time::{Duration, Instant}, 5 collections::HashSet,
6 mem,
7 io::{stderr, Write}, 6 io::{stderr, Write},
8 iter::repeat, 7 iter::repeat,
9 collections::HashSet, 8 mem,
10 sync::{RwLock, atomic::{AtomicBool, Ordering}}, 9 sync::{
10 atomic::{AtomicBool, Ordering},
11 RwLock,
12 },
13 time::{Duration, Instant},
11}; 14};
12 15
13use once_cell::sync::Lazy;
14use itertools::Itertools; 16use itertools::Itertools;
17use once_cell::sync::Lazy;
15 18
16pub use crate::memory_usage::{MemoryUsage, Bytes}; 19pub use crate::memory_usage::{Bytes, MemoryUsage};
17 20
18// We use jemalloc mainly to get heap usage statistics, actual performance 21// We use jemalloc mainly to get heap usage statistics, actual performance
19// difference is not measures. 22// difference is not measures.
diff --git a/crates/ra_project_model/src/cargo_workspace.rs b/crates/ra_project_model/src/cargo_workspace.rs
index d5ebf2c7a..2b06e9e37 100644
--- a/crates/ra_project_model/src/cargo_workspace.rs
+++ b/crates/ra_project_model/src/cargo_workspace.rs
@@ -1,9 +1,9 @@
1use std::path::{Path, PathBuf}; 1use std::path::{Path, PathBuf};
2 2
3use cargo_metadata::{MetadataCommand, CargoOpt}; 3use cargo_metadata::{CargoOpt, MetadataCommand};
4use ra_arena::{Arena, RawId, impl_arena_id}; 4use ra_arena::{impl_arena_id, Arena, RawId};
5use rustc_hash::FxHashMap;
6use ra_db::Edition; 5use ra_db::Edition;
6use rustc_hash::FxHashMap;
7 7
8use crate::Result; 8use crate::Result;
9 9
diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs
index 42156bea6..74b7efa9a 100644
--- a/crates/ra_project_model/src/lib.rs
+++ b/crates/ra_project_model/src/lib.rs
@@ -3,15 +3,15 @@ mod json_project;
3mod sysroot; 3mod sysroot;
4 4
5use std::{ 5use std::{
6 error::Error,
6 fs::File, 7 fs::File,
7 io::BufReader, 8 io::BufReader,
8 path::{Path, PathBuf}, 9 path::{Path, PathBuf},
9 error::Error
10}; 10};
11 11
12use rustc_hash::FxHashMap; 12use rustc_hash::FxHashMap;
13 13
14use ra_db::{CrateGraph, FileId, Edition}; 14use ra_db::{CrateGraph, Edition, FileId};
15 15
16use serde_json::from_reader; 16use serde_json::from_reader;
17 17
diff --git a/crates/ra_project_model/src/sysroot.rs b/crates/ra_project_model/src/sysroot.rs
index 9e0d8aaac..a419b81e8 100644
--- a/crates/ra_project_model/src/sysroot.rs
+++ b/crates/ra_project_model/src/sysroot.rs
@@ -3,7 +3,7 @@ use std::{
3 process::Command, 3 process::Command,
4}; 4};
5 5
6use ra_arena::{Arena, RawId, impl_arena_id}; 6use ra_arena::{impl_arena_id, Arena, RawId};
7 7
8use crate::Result; 8use crate::Result;
9 9
diff --git a/crates/ra_syntax/src/algo.rs b/crates/ra_syntax/src/algo.rs
index d31d00343..fad8da132 100644
--- a/crates/ra_syntax/src/algo.rs
+++ b/crates/ra_syntax/src/algo.rs
@@ -2,7 +2,7 @@ pub mod visit;
2 2
3use itertools::Itertools; 3use itertools::Itertools;
4 4
5use crate::{SyntaxNode, TextRange, TextUnit, AstNode, Direction, SyntaxToken, SyntaxElement}; 5use crate::{AstNode, Direction, SyntaxElement, SyntaxNode, SyntaxToken, TextRange, TextUnit};
6 6
7pub use rowan::TokenAtOffset; 7pub use rowan::TokenAtOffset;
8 8
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs
index 319110b6a..3dcf39f7e 100644
--- a/crates/ra_syntax/src/ast.rs
+++ b/crates/ra_syntax/src/ast.rs
@@ -9,16 +9,16 @@ mod expr_extensions;
9use std::marker::PhantomData; 9use std::marker::PhantomData;
10 10
11use crate::{ 11use crate::{
12 syntax_node::{SyntaxNode, SyntaxNodeChildren, TreeArc, SyntaxToken}, 12 syntax_node::{SyntaxNode, SyntaxNodeChildren, SyntaxToken, TreeArc},
13 SmolStr, 13 SmolStr,
14}; 14};
15 15
16pub use self::{ 16pub use self::{
17 expr_extensions::{ArrayExprKind, BinOp, ElseBranch, LiteralKind, PrefixOp},
18 extensions::{FieldKind, PathSegmentKind, SelfParamKind, StructKind},
17 generated::*, 19 generated::*,
18 traits::*,
19 tokens::*, 20 tokens::*,
20 extensions::{PathSegmentKind, StructKind,FieldKind, SelfParamKind}, 21 traits::*,
21 expr_extensions::{ElseBranch, PrefixOp, BinOp, LiteralKind,ArrayExprKind},
22}; 22};
23 23
24/// The main trait to go from untyped `SyntaxNode` to a typed ast. The 24/// The main trait to go from untyped `SyntaxNode` to a typed ast. The
diff --git a/crates/ra_syntax/src/ast/expr_extensions.rs b/crates/ra_syntax/src/ast/expr_extensions.rs
index d88671d45..87dbb0ea5 100644
--- a/crates/ra_syntax/src/ast/expr_extensions.rs
+++ b/crates/ra_syntax/src/ast/expr_extensions.rs
@@ -1,10 +1,10 @@
1//! Various extension methods to ast Expr Nodes, which are hard to code-generate. 1//! Various extension methods to ast Expr Nodes, which are hard to code-generate.
2 2
3use crate::{ 3use crate::{
4 SyntaxToken, SyntaxElement, SmolStr, 4 ast::{self, child_opt, children, AstChildren, AstNode},
5 ast::{self, AstNode, AstChildren, children, child_opt}, 5 SmolStr, SyntaxElement,
6 SyntaxKind::*, 6 SyntaxKind::*,
7 T 7 SyntaxToken, T,
8}; 8};
9 9
10#[derive(Debug, Clone, PartialEq, Eq)] 10#[derive(Debug, Clone, PartialEq, Eq)]
diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs
index 930b2d9fa..72a30232d 100644
--- a/crates/ra_syntax/src/ast/extensions.rs
+++ b/crates/ra_syntax/src/ast/extensions.rs
@@ -4,10 +4,10 @@
4use itertools::Itertools; 4use itertools::Itertools;
5 5
6use crate::{ 6use crate::{
7 SmolStr, SyntaxToken, 7 ast::{self, child_opt, children, AstNode},
8 ast::{self, AstNode, children, child_opt}, 8 SmolStr, SyntaxElement,
9 SyntaxKind::*, 9 SyntaxKind::*,
10 SyntaxElement, T, 10 SyntaxToken, T,
11}; 11};
12use ra_parser::SyntaxKind; 12use ra_parser::SyntaxKind;
13 13
diff --git a/crates/ra_syntax/src/ast/tokens.rs b/crates/ra_syntax/src/ast/tokens.rs
index 08882ea69..be63b3c9e 100644
--- a/crates/ra_syntax/src/ast/tokens.rs
+++ b/crates/ra_syntax/src/ast/tokens.rs
@@ -1,9 +1,9 @@
1//! There are many AstNodes, but only a few tokens, so we hand-write them here. 1//! There are many AstNodes, but only a few tokens, so we hand-write them here.
2 2
3use crate::{ 3use crate::{
4 SyntaxToken,
5 SyntaxKind::{COMMENT, WHITESPACE},
6 ast::AstToken, 4 ast::AstToken,
5 SyntaxKind::{COMMENT, WHITESPACE},
6 SyntaxToken,
7}; 7};
8 8
9#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 9#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
@@ -61,7 +61,7 @@ pub enum CommentPlacement {
61} 61}
62 62
63const COMMENT_PREFIX_TO_KIND: &[(&str, CommentKind)] = { 63const COMMENT_PREFIX_TO_KIND: &[(&str, CommentKind)] = {
64 use {CommentShape::*, CommentPlacement::*}; 64 use {CommentPlacement::*, CommentShape::*};
65 &[ 65 &[
66 ("///", CommentKind { shape: Line, doc: Some(Outer) }), 66 ("///", CommentKind { shape: Line, doc: Some(Outer) }),
67 ("//!", CommentKind { shape: Line, doc: Some(Inner) }), 67 ("//!", CommentKind { shape: Line, doc: Some(Inner) }),
diff --git a/crates/ra_syntax/src/ast/traits.rs b/crates/ra_syntax/src/ast/traits.rs
index 433485400..29cb53e35 100644
--- a/crates/ra_syntax/src/ast/traits.rs
+++ b/crates/ra_syntax/src/ast/traits.rs
@@ -5,8 +5,8 @@
5use itertools::Itertools; 5use itertools::Itertools;
6 6
7use crate::{ 7use crate::{
8 syntax_node::{SyntaxNodeChildren, SyntaxElementChildren}, 8 ast::{self, child_opt, children, AstChildren, AstNode, AstToken},
9 ast::{self, child_opt, children, AstNode, AstToken, AstChildren}, 9 syntax_node::{SyntaxElementChildren, SyntaxNodeChildren},
10}; 10};
11 11
12pub trait TypeAscriptionOwner: AstNode { 12pub trait TypeAscriptionOwner: AstNode {
diff --git a/crates/ra_syntax/src/fuzz.rs b/crates/ra_syntax/src/fuzz.rs
index 6a9905bd1..6d114aad4 100644
--- a/crates/ra_syntax/src/fuzz.rs
+++ b/crates/ra_syntax/src/fuzz.rs
@@ -1,4 +1,4 @@
1use crate::{SourceFile, validation, TextUnit, TextRange, AstNode}; 1use crate::{validation, AstNode, SourceFile, TextRange, TextUnit};
2use ra_text_edit::AtomTextEdit; 2use ra_text_edit::AtomTextEdit;
3use std::str::{self, FromStr}; 3use std::str::{self, FromStr};
4 4
diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs
index e46ad12db..9790a984d 100644
--- a/crates/ra_syntax/src/lib.rs
+++ b/crates/ra_syntax/src/lib.rs
@@ -31,23 +31,26 @@ pub mod ast;
31#[doc(hidden)] 31#[doc(hidden)]
32pub mod fuzz; 32pub mod fuzz;
33 33
34use std::{sync::Arc, fmt::Write}; 34use std::{fmt::Write, sync::Arc};
35 35
36use ra_text_edit::AtomTextEdit; 36use ra_text_edit::AtomTextEdit;
37 37
38use crate::syntax_node::GreenNode; 38use crate::syntax_node::GreenNode;
39 39
40pub use rowan::{SmolStr, TextRange, TextUnit};
41pub use ra_parser::SyntaxKind;
42pub use ra_parser::T;
43pub use crate::{ 40pub use crate::{
44 ast::AstNode, 41 ast::AstNode,
45 syntax_error::{SyntaxError, SyntaxErrorKind, Location}, 42 parsing::{classify_literal, tokenize, Token},
43 ptr::{AstPtr, SyntaxNodePtr},
44 syntax_error::{Location, SyntaxError, SyntaxErrorKind},
45 syntax_node::{
46 Direction, InsertPosition, SyntaxElement, SyntaxNode, SyntaxToken, SyntaxTreeBuilder,
47 TreeArc, WalkEvent,
48 },
46 syntax_text::SyntaxText, 49 syntax_text::SyntaxText,
47 syntax_node::{Direction, SyntaxNode, WalkEvent, TreeArc, SyntaxTreeBuilder, SyntaxElement, SyntaxToken, InsertPosition},
48 ptr::{SyntaxNodePtr, AstPtr},
49 parsing::{tokenize, classify_literal, Token},
50}; 50};
51pub use ra_parser::SyntaxKind;
52pub use ra_parser::T;
53pub use rowan::{SmolStr, TextRange, TextUnit};
51 54
52/// `Parse` is the result of the parsing: a syntax tree and a collection of 55/// `Parse` is the result of the parsing: a syntax tree and a collection of
53/// errors. 56/// errors.
diff --git a/crates/ra_syntax/src/parsing.rs b/crates/ra_syntax/src/parsing.rs
index 4c1fa6c4f..0387f0378 100644
--- a/crates/ra_syntax/src/parsing.rs
+++ b/crates/ra_syntax/src/parsing.rs
@@ -6,12 +6,9 @@ mod text_token_source;
6mod text_tree_sink; 6mod text_tree_sink;
7mod reparsing; 7mod reparsing;
8 8
9use crate::{ 9use crate::{syntax_node::GreenNode, SyntaxError};
10 SyntaxError,
11 syntax_node::GreenNode,
12};
13 10
14pub use self::lexer::{tokenize, classify_literal, Token}; 11pub use self::lexer::{classify_literal, tokenize, Token};
15 12
16pub(crate) use self::reparsing::incremental_reparse; 13pub(crate) use self::reparsing::incremental_reparse;
17 14
diff --git a/crates/ra_syntax/src/parsing/lexer.rs b/crates/ra_syntax/src/parsing/lexer.rs
index 6eb96f03d..60cf37047 100644
--- a/crates/ra_syntax/src/parsing/lexer.rs
+++ b/crates/ra_syntax/src/parsing/lexer.rs
@@ -6,8 +6,7 @@ mod strings;
6 6
7use crate::{ 7use crate::{
8 SyntaxKind::{self, *}, 8 SyntaxKind::{self, *},
9 TextUnit, 9 TextUnit, T,
10 T,
11}; 10};
12 11
13use self::{ 12use self::{
diff --git a/crates/ra_syntax/src/parsing/lexer/numbers.rs b/crates/ra_syntax/src/parsing/lexer/numbers.rs
index 874fb8b32..e53ae231b 100644
--- a/crates/ra_syntax/src/parsing/lexer/numbers.rs
+++ b/crates/ra_syntax/src/parsing/lexer/numbers.rs
@@ -1,7 +1,4 @@
1use crate::parsing::lexer::{ 1use crate::parsing::lexer::{classes::*, ptr::Ptr};
2 ptr::Ptr,
3 classes::*,
4};
5 2
6use crate::SyntaxKind::{self, *}; 3use crate::SyntaxKind::{self, *};
7 4
diff --git a/crates/ra_syntax/src/parsing/reparsing.rs b/crates/ra_syntax/src/parsing/reparsing.rs
index cf27a3393..eeca94020 100644
--- a/crates/ra_syntax/src/parsing/reparsing.rs
+++ b/crates/ra_syntax/src/parsing/reparsing.rs
@@ -6,19 +6,20 @@
6//! - otherwise, we search for the nearest `{}` block which contains the edit 6//! - otherwise, we search for the nearest `{}` block which contains the edit
7//! and try to parse only this block. 7//! and try to parse only this block.
8 8
9use ra_text_edit::AtomTextEdit;
10use ra_parser::Reparser; 9use ra_parser::Reparser;
10use ra_text_edit::AtomTextEdit;
11 11
12use crate::{ 12use crate::{
13 SyntaxKind::*, TextRange, TextUnit, SyntaxError,
14 algo, 13 algo,
15 syntax_node::{GreenNode, SyntaxNode, GreenToken, SyntaxElement},
16 parsing::{ 14 parsing::{
15 lexer::{tokenize, Token},
17 text_token_source::TextTokenSource, 16 text_token_source::TextTokenSource,
18 text_tree_sink::TextTreeSink, 17 text_tree_sink::TextTreeSink,
19 lexer::{tokenize, Token},
20 }, 18 },
21 T, 19 syntax_node::{GreenNode, GreenToken, SyntaxElement, SyntaxNode},
20 SyntaxError,
21 SyntaxKind::*,
22 TextRange, TextUnit, T,
22}; 23};
23 24
24pub(crate) fn incremental_reparse( 25pub(crate) fn incremental_reparse(
@@ -168,10 +169,10 @@ fn merge_errors(
168mod tests { 169mod tests {
169 use std::sync::Arc; 170 use std::sync::Arc;
170 171
171 use test_utils::{extract_range, assert_eq_text}; 172 use test_utils::{assert_eq_text, extract_range};
172 173
173 use crate::{SourceFile, AstNode, Parse};
174 use super::*; 174 use super::*;
175 use crate::{AstNode, Parse, SourceFile};
175 176
176 fn do_check(before: &str, replace_with: &str, reparsed_len: u32) { 177 fn do_check(before: &str, replace_with: &str, reparsed_len: u32) {
177 let (range, before) = extract_range(before); 178 let (range, before) = extract_range(before);
diff --git a/crates/ra_syntax/src/parsing/text_token_source.rs b/crates/ra_syntax/src/parsing/text_token_source.rs
index 71d2947f7..f592b499f 100644
--- a/crates/ra_syntax/src/parsing/text_token_source.rs
+++ b/crates/ra_syntax/src/parsing/text_token_source.rs
@@ -1,10 +1,7 @@
1use ra_parser::TokenSource;
2use ra_parser::Token as PToken; 1use ra_parser::Token as PToken;
2use ra_parser::TokenSource;
3 3
4use crate::{ 4use crate::{parsing::lexer::Token, SyntaxKind::EOF, TextRange, TextUnit};
5 SyntaxKind::EOF, TextRange, TextUnit,
6 parsing::lexer::Token,
7};
8 5
9pub(crate) struct TextTokenSource<'t> { 6pub(crate) struct TextTokenSource<'t> {
10 text: &'t str, 7 text: &'t str,
diff --git a/crates/ra_syntax/src/parsing/text_tree_sink.rs b/crates/ra_syntax/src/parsing/text_tree_sink.rs
index 71fc515f2..bf1b35c95 100644
--- a/crates/ra_syntax/src/parsing/text_tree_sink.rs
+++ b/crates/ra_syntax/src/parsing/text_tree_sink.rs
@@ -1,12 +1,13 @@
1use std::mem; 1use std::mem;
2 2
3use ra_parser::{TreeSink, ParseError}; 3use ra_parser::{ParseError, TreeSink};
4 4
5use crate::{ 5use crate::{
6 SmolStr, SyntaxError, TextUnit, TextRange, SyntaxTreeBuilder,
7 SyntaxKind::{self, *},
8 parsing::Token, 6 parsing::Token,
9 syntax_node::GreenNode, 7 syntax_node::GreenNode,
8 SmolStr, SyntaxError,
9 SyntaxKind::{self, *},
10 SyntaxTreeBuilder, TextRange, TextUnit,
10}; 11};
11 12
12/// Bridges the parser with our specific syntax tree representation. 13/// Bridges the parser with our specific syntax tree representation.
diff --git a/crates/ra_syntax/src/ptr.rs b/crates/ra_syntax/src/ptr.rs
index 10cddb852..0550dca1a 100644
--- a/crates/ra_syntax/src/ptr.rs
+++ b/crates/ra_syntax/src/ptr.rs
@@ -1,10 +1,5 @@
1use std::{ 1use crate::{AstNode, SyntaxKind, SyntaxNode, TextRange};
2 marker::PhantomData, 2use std::{iter::successors, marker::PhantomData};
3 iter::successors,
4};
5use crate::{
6 AstNode, SyntaxKind, SyntaxNode, TextRange,
7};
8 3
9/// A pointer to a syntax node inside a file. It can be used to remember a 4/// A pointer to a syntax node inside a file. It can be used to remember a
10/// specific node across reparses of the same file. 5/// specific node across reparses of the same file.
diff --git a/crates/ra_syntax/src/syntax_error.rs b/crates/ra_syntax/src/syntax_error.rs
index d29c0cf6c..5aefec768 100644
--- a/crates/ra_syntax/src/syntax_error.rs
+++ b/crates/ra_syntax/src/syntax_error.rs
@@ -2,10 +2,7 @@ use std::fmt;
2 2
3use ra_parser::ParseError; 3use ra_parser::ParseError;
4 4
5use crate::{ 5use crate::{validation::EscapeError, TextRange, TextUnit};
6 TextRange, TextUnit,
7 validation::EscapeError,
8};
9 6
10#[derive(Debug, Clone, PartialEq, Eq, Hash)] 7#[derive(Debug, Clone, PartialEq, Eq, Hash)]
11pub struct SyntaxError { 8pub struct SyntaxError {
diff --git a/crates/ra_syntax/src/syntax_node.rs b/crates/ra_syntax/src/syntax_node.rs
index 4105b5220..80c8639c8 100644
--- a/crates/ra_syntax/src/syntax_node.rs
+++ b/crates/ra_syntax/src/syntax_node.rs
@@ -7,18 +7,18 @@
7//! modules just wraps its API. 7//! modules just wraps its API.
8 8
9use std::{ 9use std::{
10 ops::RangeInclusive,
11 fmt::{self, Write},
12 borrow::Borrow, 10 borrow::Borrow,
11 fmt::{self, Write},
13 iter::successors, 12 iter::successors,
13 ops::RangeInclusive,
14}; 14};
15 15
16use ra_parser::ParseError; 16use ra_parser::ParseError;
17use rowan::{TransparentNewType, GreenNodeBuilder}; 17use rowan::{GreenNodeBuilder, TransparentNewType};
18 18
19use crate::{ 19use crate::{
20 SmolStr, SyntaxKind, TextUnit, TextRange, SyntaxText, SourceFile, AstNode, SyntaxNodePtr,
21 syntax_error::{SyntaxError, SyntaxErrorKind}, 20 syntax_error::{SyntaxError, SyntaxErrorKind},
21 AstNode, SmolStr, SourceFile, SyntaxKind, SyntaxNodePtr, SyntaxText, TextRange, TextUnit,
22}; 22};
23 23
24pub use rowan::WalkEvent; 24pub use rowan::WalkEvent;
diff --git a/crates/ra_syntax/src/syntax_text.rs b/crates/ra_syntax/src/syntax_text.rs
index c9038cd5c..e648dc082 100644
--- a/crates/ra_syntax/src/syntax_text.rs
+++ b/crates/ra_syntax/src/syntax_text.rs
@@ -1,6 +1,9 @@
1use std::{fmt, ops::{self, Bound}}; 1use std::{
2 fmt,
3 ops::{self, Bound},
4};
2 5
3use crate::{SmolStr, SyntaxNode, TextRange, TextUnit, SyntaxElement}; 6use crate::{SmolStr, SyntaxElement, SyntaxNode, TextRange, TextUnit};
4 7
5#[derive(Clone)] 8#[derive(Clone)]
6pub struct SyntaxText<'a> { 9pub struct SyntaxText<'a> {
diff --git a/crates/ra_syntax/src/validation.rs b/crates/ra_syntax/src/validation.rs
index b53900a4b..87522ec18 100644
--- a/crates/ra_syntax/src/validation.rs
+++ b/crates/ra_syntax/src/validation.rs
@@ -4,11 +4,10 @@ mod block;
4mod field_expr; 4mod field_expr;
5 5
6use crate::{ 6use crate::{
7 SourceFile, SyntaxError, AstNode, SyntaxNode, TextUnit,
8 SyntaxKind::{BYTE, BYTE_STRING, STRING, CHAR},
9 ast,
10 algo::visit::{visitor_ctx, VisitorCtx}, 7 algo::visit::{visitor_ctx, VisitorCtx},
11 T, 8 ast, AstNode, SourceFile, SyntaxError,
9 SyntaxKind::{BYTE, BYTE_STRING, CHAR, STRING},
10 SyntaxNode, TextUnit, T,
12}; 11};
13 12
14pub(crate) use unescape::EscapeError; 13pub(crate) use unescape::EscapeError;
diff --git a/crates/ra_syntax/src/validation/block.rs b/crates/ra_syntax/src/validation/block.rs
index f2cf3cbbd..46650d9b0 100644
--- a/crates/ra_syntax/src/validation/block.rs
+++ b/crates/ra_syntax/src/validation/block.rs
@@ -1,7 +1,8 @@
1use crate::{SyntaxKind::*, 1use crate::{
2 ast::{self, AttrsOwner, AstNode}, 2 ast::{self, AstNode, AttrsOwner},
3 SyntaxError, 3 SyntaxError,
4 SyntaxErrorKind::*, 4 SyntaxErrorKind::*,
5 SyntaxKind::*,
5}; 6};
6 7
7pub(crate) fn validate_block_node(node: &ast::Block, errors: &mut Vec<SyntaxError>) { 8pub(crate) fn validate_block_node(node: &ast::Block, errors: &mut Vec<SyntaxError>) {
diff --git a/crates/ra_syntax/src/validation/field_expr.rs b/crates/ra_syntax/src/validation/field_expr.rs
index 2b405062e..d3020edf7 100644
--- a/crates/ra_syntax/src/validation/field_expr.rs
+++ b/crates/ra_syntax/src/validation/field_expr.rs
@@ -1,6 +1,7 @@
1use crate::{ast::{self, FieldKind}, 1use crate::{
2 SyntaxError, 2 ast::{self, FieldKind},
3 SyntaxErrorKind::*, 3 SyntaxError,
4 SyntaxErrorKind::*,
4}; 5};
5 6
6pub(crate) fn validate_field_expr_node(node: &ast::FieldExpr, errors: &mut Vec<SyntaxError>) { 7pub(crate) fn validate_field_expr_node(node: &ast::FieldExpr, errors: &mut Vec<SyntaxError>) {
diff --git a/crates/ra_syntax/src/validation/unescape.rs b/crates/ra_syntax/src/validation/unescape.rs
index 91dbcfae8..4c3a7effc 100644
--- a/crates/ra_syntax/src/validation/unescape.rs
+++ b/crates/ra_syntax/src/validation/unescape.rs
@@ -7,8 +7,8 @@
7//! 7//!
8//! Hopefully, we'll share this code in a proper way some day 8//! Hopefully, we'll share this code in a proper way some day
9 9
10use std::str::Chars;
11use std::ops::Range; 10use std::ops::Range;
11use std::str::Chars;
12 12
13#[derive(Debug, PartialEq, Eq, Clone, Hash)] 13#[derive(Debug, PartialEq, Eq, Clone, Hash)]
14pub enum EscapeError { 14pub enum EscapeError {
diff --git a/crates/ra_syntax/tests/test.rs b/crates/ra_syntax/tests/test.rs
index f31e12588..2442c8505 100644
--- a/crates/ra_syntax/tests/test.rs
+++ b/crates/ra_syntax/tests/test.rs
@@ -4,11 +4,11 @@ extern crate walkdir;
4 4
5use std::{ 5use std::{
6 fmt::Write, 6 fmt::Write,
7 path::{PathBuf, Component}, 7 path::{Component, PathBuf},
8}; 8};
9 9
10use test_utils::{project_dir, dir_tests, read_text, collect_tests}; 10use ra_syntax::{fuzz, SourceFile};
11use ra_syntax::{SourceFile, fuzz}; 11use test_utils::{collect_tests, dir_tests, project_dir, read_text};
12 12
13#[test] 13#[test]
14fn lexer_tests() { 14fn lexer_tests() {
diff --git a/crates/ra_text_edit/src/test_utils.rs b/crates/ra_text_edit/src/test_utils.rs
index 2dc0e71af..2d6e7f216 100644
--- a/crates/ra_text_edit/src/test_utils.rs
+++ b/crates/ra_text_edit/src/test_utils.rs
@@ -1,6 +1,6 @@
1use proptest::prelude::*;
2use text_unit::{TextUnit, TextRange};
3use crate::{AtomTextEdit, TextEdit}; 1use crate::{AtomTextEdit, TextEdit};
2use proptest::prelude::*;
3use text_unit::{TextRange, TextUnit};
4 4
5pub fn arb_text() -> proptest::string::RegexGeneratorStrategy<String> { 5pub fn arb_text() -> proptest::string::RegexGeneratorStrategy<String> {
6 // generate multiple newlines 6 // generate multiple newlines
diff --git a/crates/ra_tools/src/bin/pre-commit.rs b/crates/ra_tools/src/bin/pre-commit.rs
index 95bb55cae..a628f64b2 100644
--- a/crates/ra_tools/src/bin/pre-commit.rs
+++ b/crates/ra_tools/src/bin/pre-commit.rs
@@ -1,6 +1,6 @@
1use std::process::Command; 1use std::process::Command;
2 2
3use ra_tools::{Result, run_rustfmt, run, project_root, Overwrite}; 3use ra_tools::{project_root, run, run_rustfmt, Overwrite, Result};
4 4
5fn main() -> Result<()> { 5fn main() -> Result<()> {
6 run_rustfmt(Overwrite)?; 6 run_rustfmt(Overwrite)?;
diff --git a/crates/ra_tools/src/lib.rs b/crates/ra_tools/src/lib.rs
index 821209567..d56e0d2ef 100644
--- a/crates/ra_tools/src/lib.rs
+++ b/crates/ra_tools/src/lib.rs
@@ -1,10 +1,10 @@
1use std::{ 1use std::{
2 fs,
3 collections::HashMap, 2 collections::HashMap,
3 error::Error,
4 fs,
5 io::{Error as IoError, ErrorKind},
4 path::{Path, PathBuf}, 6 path::{Path, PathBuf},
5 process::{Command, Output, Stdio}, 7 process::{Command, Output, Stdio},
6 io::{Error as IoError, ErrorKind},
7 error::Error
8}; 8};
9 9
10use itertools::Itertools; 10use itertools::Itertools;
diff --git a/crates/ra_tools/src/main.rs b/crates/ra_tools/src/main.rs
index 846e0223e..7ed592f71 100644
--- a/crates/ra_tools/src/main.rs
+++ b/crates/ra_tools/src/main.rs
@@ -1,10 +1,10 @@
1use clap::{App, SubCommand}; 1use clap::{App, SubCommand};
2use core::str; 2use core::str;
3use ra_tools::{ 3use ra_tools::{
4 generate, gen_tests, install_format_hook, run, run_with_output, run_rustfmt, 4 gen_tests, generate, install_format_hook, run, run_clippy, run_fuzzer, run_rustfmt,
5 Overwrite, Result, run_fuzzer, run_clippy, 5 run_with_output, Overwrite, Result,
6}; 6};
7use std::{path::{PathBuf}, env}; 7use std::{env, path::PathBuf};
8 8
9fn main() -> Result<()> { 9fn main() -> Result<()> {
10 let matches = App::new("tasks") 10 let matches = App::new("tasks")
diff --git a/crates/ra_tools/tests/cli.rs b/crates/ra_tools/tests/cli.rs
index 83640218f..ae0eb337d 100644
--- a/crates/ra_tools/tests/cli.rs
+++ b/crates/ra_tools/tests/cli.rs
@@ -1,6 +1,6 @@
1use walkdir::WalkDir; 1use walkdir::WalkDir;
2 2
3use ra_tools::{generate, gen_tests, run_rustfmt, Verify, project_root}; 3use ra_tools::{gen_tests, generate, project_root, run_rustfmt, Verify};
4 4
5#[test] 5#[test]
6fn generated_grammar_is_fresh() { 6fn generated_grammar_is_fresh() {
diff --git a/crates/ra_tt/src/buffer.rs b/crates/ra_tt/src/buffer.rs
index 5659aeae8..48c22a2d8 100644
--- a/crates/ra_tt/src/buffer.rs
+++ b/crates/ra_tt/src/buffer.rs
@@ -1,4 +1,4 @@
1use crate::{TokenTree, Subtree}; 1use crate::{Subtree, TokenTree};
2 2
3#[derive(Copy, Clone, Debug, Eq, PartialEq)] 3#[derive(Copy, Clone, Debug, Eq, PartialEq)]
4struct EntryId(usize); 4struct EntryId(usize);
diff --git a/crates/test_utils/src/lib.rs b/crates/test_utils/src/lib.rs
index 8bb3b3937..ea99ac062 100644
--- a/crates/test_utils/src/lib.rs
+++ b/crates/test_utils/src/lib.rs
@@ -3,11 +3,11 @@ pub mod marks;
3 3
4use std::{ 4use std::{
5 fs, 5 fs,
6 path::{Path, PathBuf} 6 path::{Path, PathBuf},
7}; 7};
8 8
9use text_unit::{TextRange, TextUnit};
10use serde_json::Value; 9use serde_json::Value;
10use text_unit::{TextRange, TextUnit};
11 11
12pub use difference::Changeset as __Changeset; 12pub use difference::Changeset as __Changeset;
13 13
diff --git a/rustfmt.toml b/rustfmt.toml
index 63d651a85..71007de81 100644
--- a/rustfmt.toml
+++ b/rustfmt.toml
@@ -1,3 +1,2 @@
1reorder_imports = false
2reorder_modules = false 1reorder_modules = false
3use_small_heuristics = "Max" 2use_small_heuristics = "Max"