Skip to content

Commit 35d5ef7

Browse files
authored
Apply rustfmt::skip on imports (rust-lang#3289)
1 parent 4e7eda4 commit 35d5ef7

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/reorder.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
//! Reorder items.
1212
//!
13-
//! `mod`, `extern crate` and `use` declarations are reorderd in alphabetical
13+
//! `mod`, `extern crate` and `use` declarations are reordered in alphabetical
1414
//! order. Trait items are reordered in pre-determined order (associated types
1515
//! and constants comes before methods).
1616
@@ -28,7 +28,7 @@ use rewrite::{Rewrite, RewriteContext};
2828
use shape::Shape;
2929
use source_map::LineRangeUtils;
3030
use spanned::Spanned;
31-
use utils::mk_sp;
31+
use utils::{contains_skip, mk_sp};
3232
use visitor::FmtVisitor;
3333

3434
use std::cmp::{Ord, Ordering};
@@ -186,7 +186,9 @@ enum ReorderableItemKind {
186186
impl ReorderableItemKind {
187187
fn from(item: &ast::Item) -> Self {
188188
match item.node {
189-
_ if contains_macro_use_attr(item) => ReorderableItemKind::Other,
189+
_ if contains_macro_use_attr(item) | contains_skip(&item.attrs) => {
190+
ReorderableItemKind::Other
191+
}
190192
ast::ItemKind::ExternCrate(..) => ReorderableItemKind::ExternCrate,
191193
ast::ItemKind::Mod(..) if is_mod_decl(item) => ReorderableItemKind::Mod,
192194
ast::ItemKind::Use(..) => ReorderableItemKind::Use,

tests/source/imports.rs

+4
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,7 @@ use imports_with_attr;
101101

102102
// #2888
103103
use std::f64::consts::{SQRT_2, E, PI};
104+
105+
// #3273
106+
#[rustfmt::skip]
107+
use std::fmt::{self, {Display, Formatter}};

tests/target/imports.rs

+4
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,7 @@ use imports_with_attr;
123123

124124
// #2888
125125
use std::f64::consts::{E, PI, SQRT_2};
126+
127+
// #3273
128+
#[rustfmt::skip]
129+
use std::fmt::{self, {Display, Formatter}};

0 commit comments

Comments
 (0)