diff options
author | Aleksey Kladov <[email protected]> | 2021-05-13 11:44:47 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2021-05-13 11:44:47 +0100 |
commit | ad0648dc95d2d1e9d35cd825c2661fe002c02fc9 (patch) | |
tree | 474ae2b2bc65146e757c894369e4be27b20cc319 | |
parent | a5b55828365b602f0ed117c9f1cc2a9eddd42512 (diff) |
Cleanup imports
-rw-r--r-- | crates/hir_def/src/body.rs | 4 | ||||
-rw-r--r-- | crates/syntax/src/parsing.rs | 7 | ||||
-rw-r--r-- | docs/dev/style.md | 7 |
3 files changed, 12 insertions, 6 deletions
diff --git a/crates/hir_def/src/body.rs b/crates/hir_def/src/body.rs index 8360426f1..98b485b60 100644 --- a/crates/hir_def/src/body.rs +++ b/crates/hir_def/src/body.rs | |||
@@ -21,8 +21,6 @@ use profile::Count; | |||
21 | use rustc_hash::FxHashMap; | 21 | use rustc_hash::FxHashMap; |
22 | use syntax::{ast, AstNode, AstPtr}; | 22 | use syntax::{ast, AstNode, AstPtr}; |
23 | 23 | ||
24 | pub use lower::LowerCtx; | ||
25 | |||
26 | use crate::{ | 24 | use crate::{ |
27 | attr::{Attrs, RawAttrs}, | 25 | attr::{Attrs, RawAttrs}, |
28 | db::DefDatabase, | 26 | db::DefDatabase, |
@@ -35,6 +33,8 @@ use crate::{ | |||
35 | UnresolvedMacro, | 33 | UnresolvedMacro, |
36 | }; | 34 | }; |
37 | 35 | ||
36 | pub use lower::LowerCtx; | ||
37 | |||
38 | /// A subset of Expander that only deals with cfg attributes. We only need it to | 38 | /// A subset of Expander that only deals with cfg attributes. We only need it to |
39 | /// avoid cyclic queries in crate def map during enum processing. | 39 | /// avoid cyclic queries in crate def map during enum processing. |
40 | #[derive(Debug)] | 40 | #[derive(Debug)] |
diff --git a/crates/syntax/src/parsing.rs b/crates/syntax/src/parsing.rs index 333bde54a..431ed0699 100644 --- a/crates/syntax/src/parsing.rs +++ b/crates/syntax/src/parsing.rs | |||
@@ -6,14 +6,13 @@ mod text_token_source; | |||
6 | mod text_tree_sink; | 6 | mod text_tree_sink; |
7 | mod reparsing; | 7 | mod reparsing; |
8 | 8 | ||
9 | use crate::{syntax_node::GreenNode, AstNode, SyntaxError, SyntaxNode}; | 9 | use parser::SyntaxKind; |
10 | use text_token_source::TextTokenSource; | 10 | use text_token_source::TextTokenSource; |
11 | use text_tree_sink::TextTreeSink; | 11 | use text_tree_sink::TextTreeSink; |
12 | 12 | ||
13 | pub(crate) use lexer::*; | 13 | use crate::{syntax_node::GreenNode, AstNode, SyntaxError, SyntaxNode}; |
14 | 14 | ||
15 | pub(crate) use self::reparsing::incremental_reparse; | 15 | pub(crate) use crate::parsing::{lexer::*, reparsing::incremental_reparse}; |
16 | use parser::SyntaxKind; | ||
17 | 16 | ||
18 | pub(crate) fn parse_text(text: &str) -> (GreenNode, Vec<SyntaxError>) { | 17 | pub(crate) fn parse_text(text: &str) -> (GreenNode, Vec<SyntaxError>) { |
19 | let (tokens, lexer_errors) = tokenize(&text); | 18 | let (tokens, lexer_errors) = tokenize(&text); |
diff --git a/docs/dev/style.md b/docs/dev/style.md index d24a5952e..9b0ddec66 100644 --- a/docs/dev/style.md +++ b/docs/dev/style.md | |||
@@ -636,6 +636,10 @@ use crate::{} | |||
636 | 636 | ||
637 | // Finally, parent and child modules, but prefer `use crate::`. | 637 | // Finally, parent and child modules, but prefer `use crate::`. |
638 | use super::{} | 638 | use super::{} |
639 | |||
640 | // Re-exports are treated as item definitions rather than imports, so they go | ||
641 | // after imports and modules. Use them sparingly. | ||
642 | pub use crate::x::Z; | ||
639 | ``` | 643 | ``` |
640 | 644 | ||
641 | **Rationale:** consistency. | 645 | **Rationale:** consistency. |
@@ -694,6 +698,9 @@ Avoid local `use MyEnum::*` imports. | |||
694 | Prefer `use crate::foo::bar` to `use super::bar` or `use self::bar::baz`. | 698 | Prefer `use crate::foo::bar` to `use super::bar` or `use self::bar::baz`. |
695 | **Rationale:** consistency, this is the style which works in all cases. | 699 | **Rationale:** consistency, this is the style which works in all cases. |
696 | 700 | ||
701 | By default, avoid re-exports. | ||
702 | **Rationale:** for non-library code, re-exports introduce two ways to use something and allow for inconsistency. | ||
703 | |||
697 | ## Order of Items | 704 | ## Order of Items |
698 | 705 | ||
699 | Optimize for the reader who sees the file for the first time, and wants to get a general idea about what's going on. | 706 | Optimize for the reader who sees the file for the first time, and wants to get a general idea about what's going on. |