Skip to content

Commit

Permalink
remove redundant imports
Browse files Browse the repository at this point in the history
detects redundant imports that can be eliminated.

for rust-lang#117772 :

In order to facilitate review and modification, split the checking code and
removing redundant imports code into two PR.
  • Loading branch information
surechen committed Dec 10, 2023
1 parent 9c809ce commit 1b9bf8a
Show file tree
Hide file tree
Showing 12 changed files with 4 additions and 16 deletions.
3 changes: 1 addition & 2 deletions src/comment.rs
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
// Formatting and tools for comments.

use std::{self, borrow::Cow, iter};
use std::{borrow::Cow, iter};

use itertools::{multipeek, MultiPeek};
use lazy_static::lazy_static;
Expand Down Expand Up @@ -1847,7 1847,6 @@ fn remove_comment_header(comment: &str) -> &str {
#[cfg(test)]
mod test {
use super::*;
use crate::shape::{Indent, Shape};

#[test]
fn char_classes() {
Expand Down
2 changes: 1 addition & 1 deletion src/config/file_lines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 6,7 @@ use std::path::PathBuf;
use std::{cmp, fmt, iter, str};

use rustc_data_structures::sync::Lrc;
use rustc_span::{self, SourceFile};
use rustc_span::SourceFile;
use serde::{ser, Deserialize, Deserializer, Serialize, Serializer};
use serde_json as json;
use thiserror::Error;
Expand Down
2 changes: 0 additions & 2 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 1,4 @@
use std::cell::Cell;
use std::default::Default;
use std::fs::File;
use std::io::{Error, ErrorKind, Read};
use std::path::{Path, PathBuf};
Expand Down Expand Up @@ -1017,7 1016,6 @@ make_backup = false
#[cfg(test)]
mod partially_unstable_option {
use super::mock::{Config, PartiallyUnstableOption};
use super::*;

/// From the command line, we can override with a stable variant.
#[test]
Expand Down
1 change: 0 additions & 1 deletion src/emitter/checkstyle.rs
Original file line number Diff line number Diff line change
@@ -1,7 1,6 @@
use self::xml::XmlEscaped;
use super::*;
use crate::rustfmt_diff::{make_diff, DiffLine, Mismatch};
use std::io::{self, Write};

mod xml;

Expand Down
2 changes: 0 additions & 2 deletions src/emitter/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 51,6 @@ impl Emitter for DiffEmitter {
#[cfg(test)]
mod tests {
use super::*;
use crate::config::Config;
use crate::FileName;
use std::path::PathBuf;

#[test]
Expand Down
2 changes: 0 additions & 2 deletions src/emitter/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 2,6 @@ use super::*;
use crate::rustfmt_diff::{make_diff, DiffLine, Mismatch};
use serde::Serialize;
use serde_json::to_string as to_json_string;
use std::io::{self, Write};

#[derive(Debug, Default)]
pub(crate) struct JsonEmitter {
Expand Down Expand Up @@ -106,7 105,6 @@ impl JsonEmitter {
#[cfg(test)]
mod tests {
use super::*;
use crate::FileName;
use std::path::PathBuf;

#[test]
Expand Down
1 change: 0 additions & 1 deletion src/emitter/modified_lines.rs
Original file line number Diff line number Diff line change
@@ -1,6 1,5 @@
use super::*;
use crate::rustfmt_diff::{make_diff, ModifiedLines};
use std::io::Write;

#[derive(Debug, Default)]
pub(crate) struct ModifiedLinesEmitter;
Expand Down
1 change: 0 additions & 1 deletion src/emitter/stdout.rs
Original file line number Diff line number Diff line change
@@ -1,6 1,5 @@
use super::*;
use crate::config::Verbosity;
use std::io::Write;

#[derive(Debug)]
pub(crate) struct StdoutEmitter {
Expand Down
2 changes: 1 addition & 1 deletion src/ignore_path.rs
Original file line number Diff line number Diff line change
@@ -1,4 1,4 @@
use ignore::{self, gitignore};
use ignore::gitignore;

use crate::config::{FileName, IgnoreList};

Expand Down
1 change: 0 additions & 1 deletion src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 1102,6 @@ enum SharedPrefix {
#[cfg(test)]
mod test {
use super::*;
use rustc_span::DUMMY_SP;

// Parse the path part of an import. This parser is not robust and is only
// suitable for use in a test harness.
Expand Down
2 changes: 1 addition & 1 deletion src/reorder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 6,7 @@

// FIXME(#2455): Reorder trait items.

use std::cmp::{Ord, Ordering};
use std::cmp::Ordering;

use rustc_ast::{ast, attr};
use rustc_span::{symbol::sym, Span};
Expand Down
1 change: 0 additions & 1 deletion src/types.rs
Original file line number Diff line number Diff line change
@@ -1,4 1,3 @@
use std::iter::ExactSizeIterator;
use std::ops::Deref;

use rustc_ast::ast::{self, FnRetTy, Mutability, Term};
Expand Down

0 comments on commit 1b9bf8a

Please sign in to comment.