mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-16 09:48:10 +00:00
Merge #5908
5908: fmt import
r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
8146700f82
1 changed files with 16 additions and 0 deletions
|
@ -112,6 +112,22 @@ Avoid local `use MyEnum::*` imports.
|
|||
|
||||
Prefer `use crate::foo::bar` to `use super::bar`.
|
||||
|
||||
When implementing `Debug` or `Display`, import `std::fmt`:
|
||||
|
||||
```rust
|
||||
// Good
|
||||
use std::fmt;
|
||||
|
||||
impl fmt::Display for RenameError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { .. }
|
||||
}
|
||||
|
||||
// Not as good
|
||||
impl std::fmt::Display for RenameError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { .. }
|
||||
}
|
||||
```
|
||||
|
||||
# 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…
Reference in a new issue