]> git.lizzy.rs Git - rust.git/commitdiff
Document import style
authorAleksey Kladov <aleksey.kladov@gmail.com>
Sat, 6 Jun 2020 17:32:45 +0000 (19:32 +0200)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Sat, 6 Jun 2020 17:32:45 +0000 (19:32 +0200)
docs/dev/README.md

index 194a40e15c42206cf877c02281d6fc29d1ac929b..6f74d42236d428584efc8a6a88a9bd20f3db3925 100644 (file)
@@ -184,6 +184,27 @@ use crate::{}
 use super::{} // but prefer `use crate::`
 ```
 
+## Import Style
+
+Items from `hir` and `ast` should be used qualified:
+
+```rust
+// Good
+use ra_syntax::ast;
+
+fn frobnicate(func: hir::Function, strukt: ast::StructDef) {}
+
+// Not as good
+use hir::Function;
+use ra_syntax::ast::StructDef;
+
+fn frobnicate(func: Function, strukt: StructDef) {}
+```
+
+Avoid local `use MyEnum::*` imports.
+
+Prefer `use crate::foo::bar` to `use super::bar`.
+
 ## Order of Items
 
 Optimize for the reader who sees the file for the first time, and wants to get the general idea about what's going on.