From 1834bae5b86c54ed9dece26e82436919d59e6cb7 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 4 Jul 2019 23:05:17 +0300 Subject: 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 --- crates/ra_assists/src/add_derive.rs | 4 ++-- crates/ra_assists/src/add_explicit_type.rs | 11 ++++------- crates/ra_assists/src/add_impl.rs | 4 ++-- crates/ra_assists/src/add_missing_impl_members.rs | 11 +++++++---- crates/ra_assists/src/assist_ctx.rs | 10 +++++----- crates/ra_assists/src/ast_editor.rs | 10 ++++++---- crates/ra_assists/src/auto_import.rs | 17 +++++++++-------- crates/ra_assists/src/change_visibility.rs | 13 ++++++++----- crates/ra_assists/src/fill_match_arms.rs | 9 +++------ crates/ra_assists/src/flip_binexpr.rs | 4 ++-- crates/ra_assists/src/flip_comma.rs | 8 ++------ crates/ra_assists/src/inline_local_variable.rs | 4 ++-- crates/ra_assists/src/introduce_variable.rs | 12 ++++++++---- crates/ra_assists/src/lib.rs | 16 ++++++++-------- crates/ra_assists/src/move_guard.rs | 9 ++++----- crates/ra_assists/src/remove_dbg.rs | 5 ++--- crates/ra_assists/src/replace_if_let_with_match.rs | 6 +++--- crates/ra_assists/src/split_import.rs | 8 ++------ 18 files changed, 79 insertions(+), 82 deletions(-) (limited to 'crates/ra_assists/src') 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 @@ use hir::db::HirDatabase; use ra_syntax::{ ast::{self, AstNode, AttrsOwner}, - SyntaxKind::{WHITESPACE, COMMENT}, + SyntaxKind::{COMMENT, WHITESPACE}, TextUnit, }; -use crate::{AssistCtx, Assist, AssistId}; +use crate::{Assist, AssistCtx, AssistId}; pub(crate) fn add_derive(mut ctx: AssistCtx) -> Option { let nominal = ctx.node_at_offset::()?; 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 @@ -use hir::{ - HirDisplay, Ty, - db::HirDatabase, -}; +use hir::{db::HirDatabase, HirDisplay, Ty}; use ra_syntax::{ + ast::{AstNode, LetStmt, NameOwner, PatKind}, T, - ast::{LetStmt, PatKind, NameOwner, AstNode} }; -use crate::{AssistCtx, Assist, AssistId}; +use crate::{Assist, AssistCtx, AssistId}; /// Add explicit type assist. pub(crate) fn add_explicit_type(mut ctx: AssistCtx) -> Option { @@ -56,7 +53,7 @@ fn is_unknown(ty: &Ty) -> bool { mod tests { use super::*; - use crate::helpers::{ check_assist, check_assist_target, check_assist_not_applicable }; + use crate::helpers::{check_assist, check_assist_not_applicable, check_assist_target}; #[test] 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 @@ -use join_to_string::join; use hir::db::HirDatabase; +use join_to_string::join; use ra_syntax::{ ast::{self, AstNode, NameOwner, TypeParamsOwner}, TextUnit, }; -use crate::{AssistCtx, Assist, AssistId}; +use crate::{Assist, AssistCtx, AssistId}; pub(crate) fn add_impl(mut ctx: AssistCtx) -> Option { let nominal = ctx.node_at_offset::()?; 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 @@ -use crate::{Assist, AssistId, AssistCtx, ast_editor::{AstEditor, AstBuilder}}; +use crate::{ + ast_editor::{AstBuilder, AstEditor}, + Assist, AssistCtx, AssistId, +}; -use hir::{HasSource, db::HirDatabase}; -use ra_syntax::{SmolStr, TreeArc}; -use ra_syntax::ast::{self, AstNode, ImplItem, ImplItemKind, NameOwner}; +use hir::{db::HirDatabase, HasSource}; use ra_db::FilePosition; +use ra_syntax::ast::{self, AstNode, ImplItem, ImplItemKind, NameOwner}; +use ra_syntax::{SmolStr, TreeArc}; #[derive(PartialEq)] enum 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 @@ use hir::db::HirDatabase; -use ra_text_edit::TextEditBuilder; use ra_db::FileRange; +use ra_fmt::{leading_indent, reindent}; use ra_syntax::{ - SourceFile, TextRange, AstNode, TextUnit, SyntaxNode, SyntaxElement, SyntaxToken, - algo::{find_token_at_offset, find_node_at_offset, find_covering_element, TokenAtOffset}, + algo::{find_covering_element, find_node_at_offset, find_token_at_offset, TokenAtOffset}, + AstNode, SourceFile, SyntaxElement, SyntaxNode, SyntaxToken, TextRange, TextUnit, }; -use ra_fmt::{leading_indent, reindent}; +use ra_text_edit::TextEditBuilder; -use crate::{AssistLabel, AssistAction, AssistId}; +use crate::{AssistAction, AssistId, AssistLabel}; #[derive(Clone, Debug)] pub(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 @@ use std::{iter, ops::RangeInclusive}; use arrayvec::ArrayVec; -use ra_text_edit::TextEditBuilder; -use ra_syntax::{AstNode, TreeArc, ast, SyntaxKind::*, SyntaxElement, SourceFile, InsertPosition, Direction, T}; -use ra_fmt::leading_indent; use hir::Name; +use ra_fmt::leading_indent; +use ra_syntax::{ + ast, AstNode, Direction, InsertPosition, SourceFile, SyntaxElement, SyntaxKind::*, TreeArc, T, +}; +use ra_text_edit::TextEditBuilder; pub struct AstEditor { original_ast: TreeArc, @@ -283,7 +285,7 @@ fn ast_node_from_file_text(text: &str) -> TreeArc { mod tokens { use once_cell::sync::Lazy; - use ra_syntax::{AstNode, SourceFile, TreeArc, SyntaxToken, SyntaxKind::*, T}; + use ra_syntax::{AstNode, SourceFile, SyntaxKind::*, SyntaxToken, TreeArc, T}; static SOURCE_FILE: Lazy> = Lazy::new(|| SourceFile::parse(",\n; ;").tree); 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 @@ +use hir::{self, db::HirDatabase}; use ra_text_edit::TextEditBuilder; -use hir::{ self, db::HirDatabase}; -use ra_syntax::{ - T, - ast::{ self, NameOwner }, AstNode, SyntaxNode, Direction, TextRange, SmolStr, - SyntaxKind::{ PATH, PATH_SEGMENT } -}; use crate::{ + assist_ctx::{Assist, AssistCtx}, AssistId, - assist_ctx::{AssistCtx, Assist}, +}; +use ra_syntax::{ + ast::{self, NameOwner}, + AstNode, Direction, SmolStr, + SyntaxKind::{PATH, PATH_SEGMENT}, + SyntaxNode, TextRange, T, }; fn collect_path_segments_raw<'a>( @@ -577,7 +578,7 @@ pub(crate) fn auto_import(mut ctx: AssistCtx) -> Option) -> Option { if let Some(vis) = ctx.node_at_offset::() { 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 @@ -use std::fmt::Write; use itertools::Itertools; +use std::fmt::Write; -use hir::{ - AdtDef, FieldSource, HasSource, - db::HirDatabase, -}; +use hir::{db::HirDatabase, AdtDef, FieldSource, HasSource}; use ra_syntax::ast::{self, AstNode}; -use crate::{AssistCtx, Assist, AssistId}; +use crate::{Assist, AssistCtx, AssistId}; fn is_trivial_arm(arm: &ast::MatchArm) -> bool { fn single_pattern(arm: &ast::MatchArm) -> Option { 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 @@ use hir::db::HirDatabase; use ra_syntax::ast::{AstNode, BinExpr, BinOp}; -use crate::{AssistCtx, Assist, AssistId}; +use crate::{Assist, AssistCtx, AssistId}; /// Flip binary expression assist. pub(crate) fn flip_binexpr(mut ctx: AssistCtx) -> Option { @@ -68,7 +68,7 @@ impl From for FlipAction { mod tests { use super::*; - use crate::helpers::{ check_assist, check_assist_target, check_assist_not_applicable }; + use crate::helpers::{check_assist, check_assist_not_applicable, check_assist_target}; #[test] 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 @@ use hir::db::HirDatabase; -use ra_syntax::{ - T, - Direction, - algo::non_trivia_sibling, -}; +use ra_syntax::{algo::non_trivia_sibling, Direction, T}; -use crate::{AssistCtx, Assist, AssistId}; +use crate::{Assist, AssistCtx, AssistId}; pub(crate) fn flip_comma(mut ctx: AssistCtx) -> Option { 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 @@ use hir::db::HirDatabase; use ra_syntax::{ - ast::{self, AstNode, AstToken, PatKind, ExprKind}, + ast::{self, AstNode, AstToken, ExprKind, PatKind}, TextRange, }; -use crate::{Assist, AssistCtx, AssistId}; use crate::assist_ctx::AssistBuilder; +use crate::{Assist, AssistCtx, AssistId}; pub(crate) fn inline_local_varialbe(mut ctx: AssistCtx) -> Option { let let_stmt = ctx.node_at_offset::()?; 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 @@ -use test_utils::tested_by; use hir::db::HirDatabase; use ra_syntax::{ ast::{self, AstNode}, + SyntaxKind::{ + BREAK_EXPR, COMMENT, LAMBDA_EXPR, LOOP_EXPR, MATCH_ARM, PATH_EXPR, RETURN_EXPR, WHITESPACE, + }, SyntaxNode, TextUnit, - SyntaxKind::{WHITESPACE, MATCH_ARM, LAMBDA_EXPR, PATH_EXPR, BREAK_EXPR, LOOP_EXPR, RETURN_EXPR, COMMENT}, }; +use test_utils::tested_by; -use crate::{AssistCtx, Assist, AssistId}; +use crate::{Assist, AssistCtx, AssistId}; pub(crate) fn introduce_variable(mut ctx: AssistCtx) -> Option { if ctx.frange.range.is_empty() { @@ -121,7 +123,9 @@ fn anchor_stmt(expr: &ast::Expr) -> Option<(&SyntaxNode, bool)> { mod tests { use test_utils::covers; - use crate::helpers::{check_assist_range_not_applicable, check_assist_range, check_assist_range_target}; + use crate::helpers::{ + check_assist_range, check_assist_range_not_applicable, check_assist_range_target, + }; use super::*; 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; use itertools::Itertools; -use ra_text_edit::TextEdit; -use ra_syntax::{TextRange, TextUnit}; -use ra_db::FileRange; use hir::db::HirDatabase; +use ra_db::FileRange; +use ra_syntax::{TextRange, TextUnit}; +use ra_text_edit::TextEdit; -pub(crate) use crate::assist_ctx::{AssistCtx, Assist}; +pub(crate) use crate::assist_ctx::{Assist, AssistCtx}; /// Unique identifier of the assist, should not be shown to the user /// directly. @@ -127,11 +127,11 @@ fn all_assists() -> &'static [fn(AssistCtx) -> Option) -> Option, @@ -289,8 +289,8 @@ mod helpers { #[cfg(test)] mod tests { use hir::mock::MockDatabase; - use ra_syntax::TextRange; use ra_db::FileRange; + use ra_syntax::TextRange; use test_utils::{extract_offset, extract_range}; #[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 @@ use hir::db::HirDatabase; use ra_syntax::{ - TextUnit, - SyntaxElement, - ast::{MatchArm, AstNode, AstToken, IfExpr}, ast, + ast::{AstNode, AstToken, IfExpr, MatchArm}, + SyntaxElement, TextUnit, }; -use crate::{AssistCtx, Assist, AssistId}; +use crate::{Assist, AssistCtx, AssistId}; pub(crate) fn move_guard_to_arm_body(mut ctx: AssistCtx) -> Option { let match_arm = ctx.node_at_offset::()?; @@ -84,7 +83,7 @@ pub(crate) fn move_arm_cond_to_match_guard(mut ctx: AssistCtx) mod tests { use super::*; - use crate::helpers::{ check_assist, check_assist_target, check_assist_not_applicable }; + use crate::helpers::{check_assist, check_assist_not_applicable, check_assist_target}; #[test] 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 @@ +use crate::{Assist, AssistCtx, AssistId}; use hir::db::HirDatabase; use ra_syntax::{ ast::{self, AstNode}, - TextUnit, - T + TextUnit, T, }; -use crate::{AssistCtx, Assist, AssistId}; pub(crate) fn remove_dbg(mut ctx: AssistCtx) -> Option { let macro_call = ctx.node_at_offset::()?; 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 @@ -use ra_syntax::{AstNode, ast}; -use ra_fmt::extract_trivial_expression; use hir::db::HirDatabase; +use ra_fmt::extract_trivial_expression; +use ra_syntax::{ast, AstNode}; -use crate::{AssistCtx, Assist, AssistId}; +use crate::{Assist, AssistCtx, AssistId}; pub(crate) fn replace_if_let_with_match(mut ctx: AssistCtx) -> Option { 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 @@ use std::iter::successors; use hir::db::HirDatabase; -use ra_syntax::{ - T, - TextUnit, AstNode, - ast, -}; +use ra_syntax::{ast, AstNode, TextUnit, T}; -use crate::{AssistCtx, Assist, AssistId}; +use crate::{Assist, AssistCtx, AssistId}; pub(crate) fn split_import(mut ctx: AssistCtx) -> Option { let colon_colon = ctx.token_at_offset().find(|leaf| leaf.kind() == T![::])?; -- cgit v1.2.3