mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-12-04 00:54:52 +00:00
Cleanup imports
This commit is contained in:
parent
a5b5582836
commit
ad0648dc95
3 changed files with 12 additions and 6 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue