Skip to content

Commit 9c8c72b

Browse files
bors[bot]matklad
andauthored
Merge #8822
8822: minor: Cleanup imports r=Veykril a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
2 parents 1552fdd + ad0648d commit 9c8c72b

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

crates/hir_def/src/body.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ use profile::Count;
2121
use rustc_hash::FxHashMap;
2222
use syntax::{ast, AstNode, AstPtr};
2323

24-
pub use lower::LowerCtx;
25-
2624
use crate::{
2725
attr::{Attrs, RawAttrs},
2826
db::DefDatabase,
@@ -35,6 +33,8 @@ use crate::{
3533
UnresolvedMacro,
3634
};
3735

36+
pub use lower::LowerCtx;
37+
3838
/// A subset of Expander that only deals with cfg attributes. We only need it to
3939
/// avoid cyclic queries in crate def map during enum processing.
4040
#[derive(Debug)]

crates/syntax/src/parsing.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@ mod text_token_source;
66
mod text_tree_sink;
77
mod reparsing;
88

9-
use crate::{syntax_node::GreenNode, AstNode, SyntaxError, SyntaxNode};
9+
use parser::SyntaxKind;
1010
use text_token_source::TextTokenSource;
1111
use text_tree_sink::TextTreeSink;
1212

13-
pub(crate) use lexer::*;
13+
use crate::{syntax_node::GreenNode, AstNode, SyntaxError, SyntaxNode};
1414

15-
pub(crate) use self::reparsing::incremental_reparse;
16-
use parser::SyntaxKind;
15+
pub(crate) use crate::parsing::{lexer::*, reparsing::incremental_reparse};
1716

1817
pub(crate) fn parse_text(text: &str) -> (GreenNode, Vec<SyntaxError>) {
1918
let (tokens, lexer_errors) = tokenize(&text);

docs/dev/style.md

+7
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,10 @@ use crate::{}
636636

637637
// Finally, parent and child modules, but prefer `use crate::`.
638638
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;
639643
```
640644

641645
**Rationale:** consistency.
@@ -694,6 +698,9 @@ Avoid local `use MyEnum::*` imports.
694698
Prefer `use crate::foo::bar` to `use super::bar` or `use self::bar::baz`.
695699
**Rationale:** consistency, this is the style which works in all cases.
696700

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+
697704
## Order of Items
698705

699706
Optimize for the reader who sees the file for the first time, and wants to get a general idea about what's going on.

0 commit comments

Comments
 (0)