Cleanup imports

This commit is contained in:
Aleksey Kladov 2021-05-13 13:44:47 +03:00
parent a5b5582836
commit ad0648dc95
3 changed files with 12 additions and 6 deletions

View file

@ -21,8 +21,6 @@ use profile::Count;
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
use syntax::{ast, AstNode, AstPtr}; use syntax::{ast, AstNode, AstPtr};
pub use lower::LowerCtx;
use crate::{ use crate::{
attr::{Attrs, RawAttrs}, attr::{Attrs, RawAttrs},
db::DefDatabase, db::DefDatabase,
@ -35,6 +33,8 @@ use crate::{
UnresolvedMacro, UnresolvedMacro,
}; };
pub use lower::LowerCtx;
/// A subset of Expander that only deals with cfg attributes. We only need it to /// 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. /// avoid cyclic queries in crate def map during enum processing.
#[derive(Debug)] #[derive(Debug)]

View file

@ -6,14 +6,13 @@ mod text_token_source;
mod text_tree_sink; mod text_tree_sink;
mod reparsing; mod reparsing;
use crate::{syntax_node::GreenNode, AstNode, SyntaxError, SyntaxNode}; use parser::SyntaxKind;
use text_token_source::TextTokenSource; use text_token_source::TextTokenSource;
use text_tree_sink::TextTreeSink; use text_tree_sink::TextTreeSink;
pub(crate) use lexer::*; use crate::{syntax_node::GreenNode, AstNode, SyntaxError, SyntaxNode};
pub(crate) use self::reparsing::incremental_reparse; pub(crate) use crate::parsing::{lexer::*, reparsing::incremental_reparse};
use parser::SyntaxKind;
pub(crate) fn parse_text(text: &str) -> (GreenNode, Vec<SyntaxError>) { pub(crate) fn parse_text(text: &str) -> (GreenNode, Vec<SyntaxError>) {
let (tokens, lexer_errors) = tokenize(&text); let (tokens, lexer_errors) = tokenize(&text);

View file

@ -636,6 +636,10 @@ use crate::{}
// Finally, parent and child modules, but prefer `use crate::`. // Finally, parent and child modules, but prefer `use crate::`.
use super::{} 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. **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`. 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. **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 ## 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. Optimize for the reader who sees the file for the first time, and wants to get a general idea about what's going on.