diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-05-13 20:38:56 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-13 20:38:56 +0000 |
| commit | 9c8c72b7c42bc8fa213355f1769216519dda052d (patch) | |
| tree | 99dd0f11e264ca33a503639e28464326b6f5fb6f | |
| parent | 1552fdd3bcbecd77971617d16be210c74c88e409 (diff) | |
| parent | ad0648dc95d2d1e9d35cd825c2661fe002c02fc9 (diff) | |
| download | rust-9c8c72b7c42bc8fa213355f1769216519dda052d.tar.gz rust-9c8c72b7c42bc8fa213355f1769216519dda052d.zip | |
Merge #8822
8822: minor: Cleanup imports r=Veykril a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
| -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 8360426f139..98b485b6020 100644 --- a/crates/hir_def/src/body.rs +++ b/crates/hir_def/src/body.rs @@ -21,8 +21,6 @@ use profile::Count; use rustc_hash::FxHashMap; use syntax::{ast, AstNode, AstPtr}; -pub use lower::LowerCtx; - use crate::{ attr::{Attrs, RawAttrs}, db::DefDatabase, @@ -35,6 +33,8 @@ use crate::{ UnresolvedMacro, }; +pub use lower::LowerCtx; + /// A subset of Expander that only deals with cfg attributes. We only need it to /// avoid cyclic queries in crate def map during enum processing. #[derive(Debug)] diff --git a/crates/syntax/src/parsing.rs b/crates/syntax/src/parsing.rs index 333bde54abb..431ed06999d 100644 --- a/crates/syntax/src/parsing.rs +++ b/crates/syntax/src/parsing.rs @@ -6,14 +6,13 @@ mod text_token_source; mod text_tree_sink; mod reparsing; -use crate::{syntax_node::GreenNode, AstNode, SyntaxError, SyntaxNode}; +use parser::SyntaxKind; use text_token_source::TextTokenSource; use text_tree_sink::TextTreeSink; -pub(crate) use lexer::*; +use crate::{syntax_node::GreenNode, AstNode, SyntaxError, SyntaxNode}; -pub(crate) use self::reparsing::incremental_reparse; -use parser::SyntaxKind; +pub(crate) use crate::parsing::{lexer::*, reparsing::incremental_reparse}; pub(crate) fn parse_text(text: &str) -> (GreenNode, Vec<SyntaxError>) { let (tokens, lexer_errors) = tokenize(&text); diff --git a/docs/dev/style.md b/docs/dev/style.md index d24a5952eda..9b0ddec6620 100644 --- a/docs/dev/style.md +++ b/docs/dev/style.md @@ -636,6 +636,10 @@ use crate::{} // Finally, parent and child modules, but prefer `use crate::`. use super::{} + +// Re-exports are treated as item definitions rather than imports, so they go +// after imports and modules. Use them sparingly. +pub use crate::x::Z; ``` **Rationale:** consistency. @@ -694,6 +698,9 @@ Avoid local `use MyEnum::*` imports. Prefer `use crate::foo::bar` to `use super::bar` or `use self::bar::baz`. **Rationale:** consistency, this is the style which works in all cases. +By default, avoid re-exports. +**Rationale:** for non-library code, re-exports introduce two ways to use something and allow for inconsistency. + ## Order of Items Optimize for the reader who sees the file for the first time, and wants to get a general idea about what's going on. |
