Skip to content

Commit ae1acbd

Browse files
committed
Document import style
1 parent a609336 commit ae1acbd

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

docs/dev/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,27 @@ use crate::{}
184184
use super::{} // but prefer `use crate::`
185185
```
186186

187+
## Import Style
188+
189+
Items from `hir` and `ast` should be used qualified:
190+
191+
```rust
192+
// Good
193+
use ra_syntax::ast;
194+
195+
fn frobnicate(func: hir::Function, strukt: ast::StructDef) {}
196+
197+
// Not as good
198+
use hir::Function;
199+
use ra_syntax::ast::StructDef;
200+
201+
fn frobnicate(func: Function, strukt: StructDef) {}
202+
```
203+
204+
Avoid local `use MyEnum::*` imports.
205+
206+
Prefer `use crate::foo::bar` to `use super::bar`.
207+
187208
## Order of Items
188209

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

0 commit comments

Comments
 (0)