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_syntax/src/algo.rs | 2 +- crates/ra_syntax/src/ast.rs | 8 ++++---- crates/ra_syntax/src/ast/expr_extensions.rs | 6 +++--- crates/ra_syntax/src/ast/extensions.rs | 6 +++--- crates/ra_syntax/src/ast/tokens.rs | 6 +++--- crates/ra_syntax/src/ast/traits.rs | 4 ++-- crates/ra_syntax/src/fuzz.rs | 2 +- crates/ra_syntax/src/lib.rs | 19 +++++++++++-------- crates/ra_syntax/src/parsing.rs | 7 ++----- crates/ra_syntax/src/parsing/lexer.rs | 3 +-- crates/ra_syntax/src/parsing/lexer/numbers.rs | 5 +---- crates/ra_syntax/src/parsing/reparsing.rs | 15 ++++++++------- crates/ra_syntax/src/parsing/text_token_source.rs | 7 ++----- crates/ra_syntax/src/parsing/text_tree_sink.rs | 7 ++++--- crates/ra_syntax/src/ptr.rs | 9 ++------- crates/ra_syntax/src/syntax_error.rs | 5 +---- crates/ra_syntax/src/syntax_node.rs | 8 ++++---- crates/ra_syntax/src/syntax_text.rs | 7 +++++-- crates/ra_syntax/src/validation.rs | 7 +++---- crates/ra_syntax/src/validation/block.rs | 5 +++-- crates/ra_syntax/src/validation/field_expr.rs | 7 ++++--- crates/ra_syntax/src/validation/unescape.rs | 2 +- crates/ra_syntax/tests/test.rs | 6 +++--- 23 files changed, 72 insertions(+), 81 deletions(-) (limited to 'crates/ra_syntax') 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; use itertools::Itertools; -use crate::{SyntaxNode, TextRange, TextUnit, AstNode, Direction, SyntaxToken, SyntaxElement}; +use crate::{AstNode, Direction, SyntaxElement, SyntaxNode, SyntaxToken, TextRange, TextUnit}; pub use rowan::TokenAtOffset; 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; use std::marker::PhantomData; use crate::{ - syntax_node::{SyntaxNode, SyntaxNodeChildren, TreeArc, SyntaxToken}, + syntax_node::{SyntaxNode, SyntaxNodeChildren, SyntaxToken, TreeArc}, SmolStr, }; pub use self::{ + expr_extensions::{ArrayExprKind, BinOp, ElseBranch, LiteralKind, PrefixOp}, + extensions::{FieldKind, PathSegmentKind, SelfParamKind, StructKind}, generated::*, - traits::*, tokens::*, - extensions::{PathSegmentKind, StructKind,FieldKind, SelfParamKind}, - expr_extensions::{ElseBranch, PrefixOp, BinOp, LiteralKind,ArrayExprKind}, + traits::*, }; /// 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 @@ //! Various extension methods to ast Expr Nodes, which are hard to code-generate. use crate::{ - SyntaxToken, SyntaxElement, SmolStr, - ast::{self, AstNode, AstChildren, children, child_opt}, + ast::{self, child_opt, children, AstChildren, AstNode}, + SmolStr, SyntaxElement, SyntaxKind::*, - T + SyntaxToken, T, }; #[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 @@ use itertools::Itertools; use crate::{ - SmolStr, SyntaxToken, - ast::{self, AstNode, children, child_opt}, + ast::{self, child_opt, children, AstNode}, + SmolStr, SyntaxElement, SyntaxKind::*, - SyntaxElement, T, + SyntaxToken, T, }; use ra_parser::SyntaxKind; 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 @@ //! There are many AstNodes, but only a few tokens, so we hand-write them here. use crate::{ - SyntaxToken, - SyntaxKind::{COMMENT, WHITESPACE}, ast::AstToken, + SyntaxKind::{COMMENT, WHITESPACE}, + SyntaxToken, }; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] @@ -61,7 +61,7 @@ pub enum CommentPlacement { } const COMMENT_PREFIX_TO_KIND: &[(&str, CommentKind)] = { - use {CommentShape::*, CommentPlacement::*}; + use {CommentPlacement::*, CommentShape::*}; &[ ("///", CommentKind { shape: Line, doc: Some(Outer) }), ("//!", 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 @@ use itertools::Itertools; use crate::{ - syntax_node::{SyntaxNodeChildren, SyntaxElementChildren}, - ast::{self, child_opt, children, AstNode, AstToken, AstChildren}, + ast::{self, child_opt, children, AstChildren, AstNode, AstToken}, + syntax_node::{SyntaxElementChildren, SyntaxNodeChildren}, }; pub 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 @@ -use crate::{SourceFile, validation, TextUnit, TextRange, AstNode}; +use crate::{validation, AstNode, SourceFile, TextRange, TextUnit}; use ra_text_edit::AtomTextEdit; use std::str::{self, FromStr}; 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; #[doc(hidden)] pub mod fuzz; -use std::{sync::Arc, fmt::Write}; +use std::{fmt::Write, sync::Arc}; use ra_text_edit::AtomTextEdit; use crate::syntax_node::GreenNode; -pub use rowan::{SmolStr, TextRange, TextUnit}; -pub use ra_parser::SyntaxKind; -pub use ra_parser::T; pub use crate::{ ast::AstNode, - syntax_error::{SyntaxError, SyntaxErrorKind, Location}, + parsing::{classify_literal, tokenize, Token}, + ptr::{AstPtr, SyntaxNodePtr}, + syntax_error::{Location, SyntaxError, SyntaxErrorKind}, + syntax_node::{ + Direction, InsertPosition, SyntaxElement, SyntaxNode, SyntaxToken, SyntaxTreeBuilder, + TreeArc, WalkEvent, + }, syntax_text::SyntaxText, - syntax_node::{Direction, SyntaxNode, WalkEvent, TreeArc, SyntaxTreeBuilder, SyntaxElement, SyntaxToken, InsertPosition}, - ptr::{SyntaxNodePtr, AstPtr}, - parsing::{tokenize, classify_literal, Token}, }; +pub use ra_parser::SyntaxKind; +pub use ra_parser::T; +pub use rowan::{SmolStr, TextRange, TextUnit}; /// `Parse` is the result of the parsing: a syntax tree and a collection of /// 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; mod text_tree_sink; mod reparsing; -use crate::{ - SyntaxError, - syntax_node::GreenNode, -}; +use crate::{syntax_node::GreenNode, SyntaxError}; -pub use self::lexer::{tokenize, classify_literal, Token}; +pub use self::lexer::{classify_literal, tokenize, Token}; pub(crate) use self::reparsing::incremental_reparse; 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; use crate::{ SyntaxKind::{self, *}, - TextUnit, - T, + TextUnit, T, }; use 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 @@ -use crate::parsing::lexer::{ - ptr::Ptr, - classes::*, -}; +use crate::parsing::lexer::{classes::*, ptr::Ptr}; use crate::SyntaxKind::{self, *}; 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 @@ //! - otherwise, we search for the nearest `{}` block which contains the edit //! and try to parse only this block. -use ra_text_edit::AtomTextEdit; use ra_parser::Reparser; +use ra_text_edit::AtomTextEdit; use crate::{ - SyntaxKind::*, TextRange, TextUnit, SyntaxError, algo, - syntax_node::{GreenNode, SyntaxNode, GreenToken, SyntaxElement}, parsing::{ + lexer::{tokenize, Token}, text_token_source::TextTokenSource, text_tree_sink::TextTreeSink, - lexer::{tokenize, Token}, }, - T, + syntax_node::{GreenNode, GreenToken, SyntaxElement, SyntaxNode}, + SyntaxError, + SyntaxKind::*, + TextRange, TextUnit, T, }; pub(crate) fn incremental_reparse( @@ -168,10 +169,10 @@ fn merge_errors( mod tests { use std::sync::Arc; - use test_utils::{extract_range, assert_eq_text}; + use test_utils::{assert_eq_text, extract_range}; - use crate::{SourceFile, AstNode, Parse}; use super::*; + use crate::{AstNode, Parse, SourceFile}; fn do_check(before: &str, replace_with: &str, reparsed_len: u32) { 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 @@ -use ra_parser::TokenSource; use ra_parser::Token as PToken; +use ra_parser::TokenSource; -use crate::{ - SyntaxKind::EOF, TextRange, TextUnit, - parsing::lexer::Token, -}; +use crate::{parsing::lexer::Token, SyntaxKind::EOF, TextRange, TextUnit}; pub(crate) struct TextTokenSource<'t> { 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 @@ use std::mem; -use ra_parser::{TreeSink, ParseError}; +use ra_parser::{ParseError, TreeSink}; use crate::{ - SmolStr, SyntaxError, TextUnit, TextRange, SyntaxTreeBuilder, - SyntaxKind::{self, *}, parsing::Token, syntax_node::GreenNode, + SmolStr, SyntaxError, + SyntaxKind::{self, *}, + SyntaxTreeBuilder, TextRange, TextUnit, }; /// 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 @@ -use std::{ - marker::PhantomData, - iter::successors, -}; -use crate::{ - AstNode, SyntaxKind, SyntaxNode, TextRange, -}; +use crate::{AstNode, SyntaxKind, SyntaxNode, TextRange}; +use std::{iter::successors, marker::PhantomData}; /// A pointer to a syntax node inside a file. It can be used to remember a /// 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; use ra_parser::ParseError; -use crate::{ - TextRange, TextUnit, - validation::EscapeError, -}; +use crate::{validation::EscapeError, TextRange, TextUnit}; #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub 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 @@ //! modules just wraps its API. use std::{ - ops::RangeInclusive, - fmt::{self, Write}, borrow::Borrow, + fmt::{self, Write}, iter::successors, + ops::RangeInclusive, }; use ra_parser::ParseError; -use rowan::{TransparentNewType, GreenNodeBuilder}; +use rowan::{GreenNodeBuilder, TransparentNewType}; use crate::{ - SmolStr, SyntaxKind, TextUnit, TextRange, SyntaxText, SourceFile, AstNode, SyntaxNodePtr, syntax_error::{SyntaxError, SyntaxErrorKind}, + AstNode, SmolStr, SourceFile, SyntaxKind, SyntaxNodePtr, SyntaxText, TextRange, TextUnit, }; pub 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 @@ -use std::{fmt, ops::{self, Bound}}; +use std::{ + fmt, + ops::{self, Bound}, +}; -use crate::{SmolStr, SyntaxNode, TextRange, TextUnit, SyntaxElement}; +use crate::{SmolStr, SyntaxElement, SyntaxNode, TextRange, TextUnit}; #[derive(Clone)] pub 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; mod field_expr; use crate::{ - SourceFile, SyntaxError, AstNode, SyntaxNode, TextUnit, - SyntaxKind::{BYTE, BYTE_STRING, STRING, CHAR}, - ast, algo::visit::{visitor_ctx, VisitorCtx}, - T, + ast, AstNode, SourceFile, SyntaxError, + SyntaxKind::{BYTE, BYTE_STRING, CHAR, STRING}, + SyntaxNode, TextUnit, T, }; pub(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 @@ -use crate::{SyntaxKind::*, - ast::{self, AttrsOwner, AstNode}, +use crate::{ + ast::{self, AstNode, AttrsOwner}, SyntaxError, SyntaxErrorKind::*, + SyntaxKind::*, }; pub(crate) fn validate_block_node(node: &ast::Block, errors: &mut Vec) { 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 @@ -use crate::{ast::{self, FieldKind}, - SyntaxError, - SyntaxErrorKind::*, +use crate::{ + ast::{self, FieldKind}, + SyntaxError, + SyntaxErrorKind::*, }; pub(crate) fn validate_field_expr_node(node: &ast::FieldExpr, errors: &mut Vec) { 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 @@ //! //! Hopefully, we'll share this code in a proper way some day -use std::str::Chars; use std::ops::Range; +use std::str::Chars; #[derive(Debug, PartialEq, Eq, Clone, Hash)] pub 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; use std::{ fmt::Write, - path::{PathBuf, Component}, + path::{Component, PathBuf}, }; -use test_utils::{project_dir, dir_tests, read_text, collect_tests}; -use ra_syntax::{SourceFile, fuzz}; +use ra_syntax::{fuzz, SourceFile}; +use test_utils::{collect_tests, dir_tests, project_dir, read_text}; #[test] fn lexer_tests() { -- cgit v1.2.3