Skip to content

Commit

Permalink
Apply rustfmt::skip on imports (rust-lang#3289)
Browse files Browse the repository at this point in the history
  • Loading branch information
topecongiro authored Jan 27, 2019
1 parent 4e7eda4 commit 35d5ef7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/reorder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

//! Reorder items.
//!
//! `mod`, `extern crate` and `use` declarations are reorderd in alphabetical
//! `mod`, `extern crate` and `use` declarations are reordered in alphabetical
//! order. Trait items are reordered in pre-determined order (associated types
//! and constants comes before methods).
Expand All @@ -28,7 +28,7 @@ use rewrite::{Rewrite, RewriteContext};
use shape::Shape;
use source_map::LineRangeUtils;
use spanned::Spanned;
use utils::mk_sp;
use utils::{contains_skip, mk_sp};
use visitor::FmtVisitor;

use std::cmp::{Ord, Ordering};
Expand Down Expand Up @@ -186,7 +186,9 @@ enum ReorderableItemKind {
impl ReorderableItemKind {
fn from(item: &ast::Item) -> Self {
match item.node {
_ if contains_macro_use_attr(item) => ReorderableItemKind::Other,
_ if contains_macro_use_attr(item) | contains_skip(&item.attrs) => {
ReorderableItemKind::Other
}
ast::ItemKind::ExternCrate(..) => ReorderableItemKind::ExternCrate,
ast::ItemKind::Mod(..) if is_mod_decl(item) => ReorderableItemKind::Mod,
ast::ItemKind::Use(..) => ReorderableItemKind::Use,
Expand Down
4 changes: 4 additions & 0 deletions tests/source/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,7 @@ use imports_with_attr;

// #2888
use std::f64::consts::{SQRT_2, E, PI};

// #3273
#[rustfmt::skip]
use std::fmt::{self, {Display, Formatter}};
4 changes: 4 additions & 0 deletions tests/target/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,7 @@ use imports_with_attr;

// #2888
use std::f64::consts::{E, PI, SQRT_2};

// #3273
#[rustfmt::skip]
use std::fmt::{self, {Display, Formatter}};

0 comments on commit 35d5ef7

Please sign in to comment.