Skip to content

Commit

Permalink
sort rustfmt imports
Browse files Browse the repository at this point in the history
The version-sort algorithm makes changes to the sort order of imports,
and we're updating them here for the self tests.
  • Loading branch information
ytmimi committed Aug 16, 2024
1 parent f49fe9e commit de40520
Show file tree
Hide file tree
Showing 43 changed files with 116 additions and 116 deletions.
2 changes: 1 addition & 1 deletion config_proc_macro/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use proc_macro2::TokenStream;
use quote::{quote, ToTokens};
use quote::{ToTokens, quote};

pub fn fold_quote<F, I, T>(input: impl Iterator<Item = I>, f: F) -> TokenStream
where
Expand Down
12 changes: 6 additions & 6 deletions src/attr.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
//! Format attributes and meta items.
use rustc_ast::ast;
use rustc_ast::HasAttrs;
use rustc_span::{symbol::sym, Span};
use rustc_ast::ast;
use rustc_span::{Span, symbol::sym};

use self::doc_comment::DocCommentFormatter;
use crate::comment::{contains_comment, rewrite_doc_comment, CommentStyle};
use crate::config::lists::*;
use crate::comment::{CommentStyle, contains_comment, rewrite_doc_comment};
use crate::config::IndentStyle;
use crate::config::lists::*;
use crate::expr::rewrite_literal;
use crate::lists::{definitive_tactic, itemize_list, write_list, ListFormatting, Separator};
use crate::lists::{ListFormatting, Separator, definitive_tactic, itemize_list, write_list};
use crate::overflow;
use crate::rewrite::{Rewrite, RewriteContext, RewriteError, RewriteErrorExt, RewriteResult};
use crate::shape::Shape;
use crate::source_map::SpanUtils;
use crate::types::{rewrite_path, PathContext};
use crate::types::{PathContext, rewrite_path};
use crate::utils::{count_newlines, mk_sp};

mod doc_comment;
Expand Down
8 changes: 4 additions & 4 deletions src/bin/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![feature(rustc_private)]

use anyhow::{format_err, Result};
use anyhow::{Result, format_err};

use io::Error as IoError;
use thiserror::Error;
Expand All @@ -11,15 +11,15 @@ use tracing_subscriber::EnvFilter;
use std::collections::HashMap;
use std::env;
use std::fs::File;
use std::io::{self, stdout, Read, Write};
use std::io::{self, Read, Write, stdout};
use std::path::{Path, PathBuf};
use std::str::FromStr;

use getopts::{Matches, Options};

use crate::rustfmt::{
load_config, CliOptions, Color, Config, Edition, EmitMode, FileLines, FileName,
FormatReportFormatterBuilder, Input, Session, StyleEdition, Verbosity,
CliOptions, Color, Config, Edition, EmitMode, FileLines, FileName,
FormatReportFormatterBuilder, Input, Session, StyleEdition, Verbosity, load_config,
};

const BUG_REPORT_URL: &str = "https://github.com/rust-lang/rustfmt/issues/new?labels=bug";
Expand Down
4 changes: 2 additions & 2 deletions src/chains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ use std::borrow::Cow;
use std::cmp::min;

use rustc_ast::{ast, ptr};
use rustc_span::{symbol, BytePos, Span};
use rustc_span::{BytePos, Span, symbol};

use crate::comment::{rewrite_comment, CharClasses, FullCodeCharKind, RichChar};
use crate::comment::{CharClasses, FullCodeCharKind, RichChar, rewrite_comment};
use crate::config::{IndentStyle, StyleEdition};
use crate::expr::rewrite_call;
use crate::lists::extract_pre_comment;
Expand Down
6 changes: 3 additions & 3 deletions src/closures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ use rustc_span::Span;
use thin_vec::thin_vec;

use crate::attr::get_attrs_from_stmt;
use crate::config::lists::*;
use crate::config::StyleEdition;
use crate::config::lists::*;
use crate::expr::{block_contains_comment, is_simple_block, is_unsafe_block, rewrite_cond};
use crate::items::{span_hi_for_param, span_lo_for_param};
use crate::lists::{definitive_tactic, itemize_list, write_list, ListFormatting, Separator};
use crate::lists::{ListFormatting, Separator, definitive_tactic, itemize_list, write_list};
use crate::overflow::OverflowableItem;
use crate::rewrite::{Rewrite, RewriteContext, RewriteError, RewriteErrorExt, RewriteResult};
use crate::shape::Shape;
use crate::source_map::SpanUtils;
use crate::types::rewrite_bound_params;
use crate::utils::{last_line_width, left_most_sub_expr, stmt_expr, NodeIdExt};
use crate::utils::{NodeIdExt, last_line_width, left_most_sub_expr, stmt_expr};

// This module is pretty messy because of the rules around closures and blocks:
// FIXME - the below is probably no longer true in full.
Expand Down
4 changes: 2 additions & 2 deletions src/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

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

use itertools::{multipeek, MultiPeek};
use itertools::{MultiPeek, multipeek};
use rustc_span::Span;

use crate::config::Config;
use crate::rewrite::{RewriteContext, RewriteErrorExt, RewriteResult};
use crate::shape::{Indent, Shape};
use crate::string::{rewrite_string, StringFormat};
use crate::string::{StringFormat, rewrite_string};
use crate::utils::{
count_newlines, first_line_width, last_line_width, trim_left_preserve_layout,
trimmed_last_line_width, unicode_str_width,
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 @@ -7,7 +7,7 @@ use std::{cmp, fmt, iter, str};

use rustc_data_structures::sync::Lrc;
use rustc_span::SourceFile;
use serde::{ser, Deserialize, Deserializer, Serialize, Serializer};
use serde::{Deserialize, Deserializer, Serialize, Serializer, ser};
use serde_json as json;
use thiserror::Error;

Expand Down
4 changes: 2 additions & 2 deletions src/config/options.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![allow(unused_imports)]

use std::collections::{hash_set, HashSet};
use std::collections::{HashSet, hash_set};
use std::fmt;
use std::path::{Path, PathBuf};
use std::str::FromStr;
Expand All @@ -11,10 +11,10 @@ use serde::de::{SeqAccess, Visitor};
use serde::ser::SerializeSeq;
use serde::{Deserialize, Deserializer, Serialize, Serializer};

use crate::config::Config;
use crate::config::file_lines::FileLines;
use crate::config::lists::*;
use crate::config::macro_names::MacroSelectors;
use crate::config::Config;

#[config_type]
pub enum NewlineStyle {
Expand Down
2 changes: 1 addition & 1 deletion src/emitter/checkstyle.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use self::xml::XmlEscaped;
use super::*;
use crate::rustfmt_diff::{make_diff, DiffLine, Mismatch};
use crate::rustfmt_diff::{DiffLine, Mismatch, make_diff};

mod xml;

Expand Down
2 changes: 1 addition & 1 deletion src/emitter/json.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::*;
use crate::rustfmt_diff::{make_diff, DiffLine, Mismatch};
use crate::rustfmt_diff::{DiffLine, Mismatch, make_diff};
use serde::Serialize;
use serde_json::to_string as to_json_string;

Expand Down
2 changes: 1 addition & 1 deletion src/emitter/modified_lines.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::*;
use crate::rustfmt_diff::{make_diff, ModifiedLines};
use crate::rustfmt_diff::{ModifiedLines, make_diff};

#[derive(Debug, Default)]
pub(crate) struct ModifiedLinesEmitter;
Expand Down
18 changes: 9 additions & 9 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,32 @@ use std::cmp::min;

use itertools::Itertools;
use rustc_ast::token::{Delimiter, Lit, LitKind};
use rustc_ast::{ast, ptr, token, ForLoopKind, MatchKind};
use rustc_ast::{ForLoopKind, MatchKind, ast, ptr, token};
use rustc_span::{BytePos, Span};

use crate::chains::rewrite_chain;
use crate::closures;
use crate::comment::{
combine_strs_with_missing_comments, contains_comment, recover_comment_removed, rewrite_comment,
rewrite_missing_comment, CharClasses, FindUncommented,
CharClasses, FindUncommented, combine_strs_with_missing_comments, contains_comment,
recover_comment_removed, rewrite_comment, rewrite_missing_comment,
};
use crate::config::lists::*;
use crate::config::{Config, ControlBraceStyle, HexLiteralCase, IndentStyle, StyleEdition};
use crate::lists::{
definitive_tactic, itemize_list, shape_for_tactic, struct_lit_formatting, struct_lit_shape,
struct_lit_tactic, write_list, ListFormatting, Separator,
ListFormatting, Separator, definitive_tactic, itemize_list, shape_for_tactic,
struct_lit_formatting, struct_lit_shape, struct_lit_tactic, write_list,
};
use crate::macros::{rewrite_macro, MacroPosition};
use crate::macros::{MacroPosition, rewrite_macro};
use crate::matches::rewrite_match;
use crate::overflow::{self, IntoOverflowableItem, OverflowableItem};
use crate::pairs::{rewrite_all_pairs, rewrite_pair, PairParts};
use crate::pairs::{PairParts, rewrite_all_pairs, rewrite_pair};
use crate::rewrite::{Rewrite, RewriteContext, RewriteError, RewriteErrorExt, RewriteResult};
use crate::shape::{Indent, Shape};
use crate::source_map::{LineRangeUtils, SpanUtils};
use crate::spanned::Spanned;
use crate::stmt;
use crate::string::{rewrite_string, StringFormat};
use crate::types::{rewrite_path, PathContext};
use crate::string::{StringFormat, rewrite_string};
use crate::types::{PathContext, rewrite_path};
use crate::utils::{
colon_spaces, contains_skip, count_newlines, filtered_str_fits, first_line_ends_with,
inner_attributes, last_line_extendable, last_line_width, mk_sp, outer_attributes,
Expand Down
2 changes: 1 addition & 1 deletion src/formatting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::parse::parser::{DirectoryOwnership, Parser, ParserError};
use crate::parse::session::ParseSess;
use crate::utils::{contains_skip, count_newlines};
use crate::visitor::FmtVisitor;
use crate::{modules, source_file, ErrorKind, FormatReport, Input, Session};
use crate::{ErrorKind, FormatReport, Input, Session, modules, source_file};

mod generated;
mod newline_style;
Expand Down
2 changes: 1 addition & 1 deletion src/git-rustfmt/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use getopts::{Matches, Options};
use rustfmt_nightly as rustfmt;
use tracing_subscriber::EnvFilter;

use crate::rustfmt::{load_config, CliOptions, FormatReportFormatterBuilder, Input, Session};
use crate::rustfmt::{CliOptions, FormatReportFormatterBuilder, Input, Session, load_config};

fn prune_files(files: Vec<&str>) -> Vec<&str> {
let prefixes: Vec<_> = files
Expand Down
6 changes: 3 additions & 3 deletions src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ use itertools::Itertools;

use rustc_ast::ast::{self, UseTreeKind};
use rustc_span::{
BytePos, DUMMY_SP, Span,
symbol::{self, sym},
BytePos, Span, DUMMY_SP,
};

use crate::comment::combine_strs_with_missing_comments;
use crate::config::lists::*;
use crate::config::ImportGranularity;
use crate::config::lists::*;
use crate::config::{Edition, IndentStyle, StyleEdition};
use crate::lists::{
definitive_tactic, itemize_list, write_list, ListFormatting, ListItem, Separator,
ListFormatting, ListItem, Separator, definitive_tactic, itemize_list, write_list,
};
use crate::rewrite::{Rewrite, RewriteContext, RewriteErrorExt, RewriteResult};
use crate::shape::Shape;
Expand Down
17 changes: 8 additions & 9 deletions src/items.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
// Formatting top-level items - functions, structs, enums, traits, impls.

use std::borrow::Cow;
use std::cmp::{max, min, Ordering};
use std::cmp::{Ordering, max, min};

use regex::Regex;
use rustc_ast::visit;
use rustc_ast::{ast, ptr};
use rustc_span::{symbol, BytePos, Span, DUMMY_SP};
use rustc_span::{BytePos, DUMMY_SP, Span, symbol};

use crate::attr::filter_inline_attrs;
use crate::comment::{
combine_strs_with_missing_comments, contains_comment, is_last_comment_block,
FindUncommented, combine_strs_with_missing_comments, contains_comment, is_last_comment_block,
recover_comment_removed, recover_missing_comment_in_span, rewrite_missing_comment,
FindUncommented,
};
use crate::config::lists::*;
use crate::config::{BraceStyle, Config, IndentStyle, StyleEdition};
use crate::expr::{
is_empty_block, is_simple_block_stmt, rewrite_assign_rhs, rewrite_assign_rhs_with,
rewrite_assign_rhs_with_comments, rewrite_else_kw_with_comments, rewrite_let_else_block,
RhsAssignKind, RhsTactics,
RhsAssignKind, RhsTactics, is_empty_block, is_simple_block_stmt, rewrite_assign_rhs,
rewrite_assign_rhs_with, rewrite_assign_rhs_with_comments, rewrite_else_kw_with_comments,
rewrite_let_else_block,
};
use crate::lists::{definitive_tactic, itemize_list, write_list, ListFormatting, Separator};
use crate::macros::{rewrite_macro, MacroPosition};
use crate::lists::{ListFormatting, Separator, definitive_tactic, itemize_list, write_list};
use crate::macros::{MacroPosition, rewrite_macro};
use crate::overflow;
use crate::rewrite::{Rewrite, RewriteContext, RewriteError, RewriteErrorExt, RewriteResult};
use crate::shape::{Indent, Shape};
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ use crate::shape::Indent;
use crate::utils::indent_next_line;

pub use crate::config::{
load_config, CliOptions, Color, Config, Edition, EmitMode, FileLines, FileName, NewlineStyle,
Range, StyleEdition, Verbosity,
CliOptions, Color, Config, Edition, EmitMode, FileLines, FileName, NewlineStyle, Range,
StyleEdition, Verbosity, load_config,
};

pub use crate::format_report_formatter::{FormatReportFormatter, FormatReportFormatterBuilder};
Expand Down
2 changes: 1 addition & 1 deletion src/lists.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::iter::Peekable;

use rustc_span::BytePos;

use crate::comment::{find_comment_end, rewrite_comment, FindUncommented};
use crate::comment::{FindUncommented, find_comment_end, rewrite_comment};
use crate::config::lists::*;
use crate::config::{Config, IndentStyle};
use crate::rewrite::{RewriteContext, RewriteError, RewriteResult};
Expand Down
18 changes: 9 additions & 9 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,34 @@
// and those with brackets will be formatted as array literals.

use std::collections::HashMap;
use std::panic::{catch_unwind, AssertUnwindSafe};
use std::panic::{AssertUnwindSafe, catch_unwind};

use rustc_ast::token::{BinOpToken, Delimiter, Token, TokenKind};
use rustc_ast::tokenstream::{RefTokenTreeCursor, TokenStream, TokenTree};
use rustc_ast::{ast, ptr};
use rustc_ast_pretty::pprust;
use rustc_span::{
BytePos, DUMMY_SP, Span, Symbol,
symbol::{self, kw},
BytePos, Span, Symbol, DUMMY_SP,
};

use crate::comment::{
contains_comment, CharClasses, FindUncommented, FullCodeCharKind, LineClasses,
CharClasses, FindUncommented, FullCodeCharKind, LineClasses, contains_comment,
};
use crate::config::lists::*;
use crate::config::StyleEdition;
use crate::expr::{rewrite_array, rewrite_assign_rhs, RhsAssignKind};
use crate::lists::{itemize_list, write_list, ListFormatting};
use crate::config::lists::*;
use crate::expr::{RhsAssignKind, rewrite_array, rewrite_assign_rhs};
use crate::lists::{ListFormatting, itemize_list, write_list};
use crate::overflow;
use crate::parse::macros::lazy_static::parse_lazy_static;
use crate::parse::macros::{parse_expr, parse_macro_args, ParsedMacroArgs};
use crate::parse::macros::{ParsedMacroArgs, parse_expr, parse_macro_args};
use crate::rewrite::{Rewrite, RewriteContext, RewriteError};
use crate::shape::{Indent, Shape};
use crate::source_map::SpanUtils;
use crate::spanned::Spanned;
use crate::utils::{
filtered_str_fits, format_visibility, indent_next_line, is_empty_line, mk_sp,
remove_trailing_white_spaces, rewrite_ident, trim_left_preserve_layout, NodeIdExt,
NodeIdExt, filtered_str_fits, format_visibility, indent_next_line, is_empty_line, mk_sp,
remove_trailing_white_spaces, rewrite_ident, trim_left_preserve_layout,
};
use crate::visitor::FmtVisitor;

Expand Down
10 changes: 5 additions & 5 deletions src/matches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
use std::iter::repeat;

use rustc_ast::{ast, ptr, MatchKind};
use rustc_ast::{MatchKind, ast, ptr};
use rustc_span::{BytePos, Span};

use crate::comment::{combine_strs_with_missing_comments, rewrite_comment, FindUncommented};
use crate::comment::{FindUncommented, combine_strs_with_missing_comments, rewrite_comment};
use crate::config::lists::*;
use crate::config::{Config, ControlBraceStyle, IndentStyle, MatchArmLeadingPipe, StyleEdition};
use crate::expr::{
format_expr, is_empty_block, is_simple_block, is_unsafe_block, prefer_next_line, rewrite_cond,
ExprType, RhsTactics,
ExprType, RhsTactics, format_expr, is_empty_block, is_simple_block, is_unsafe_block,
prefer_next_line, rewrite_cond,
};
use crate::lists::{itemize_list, write_list, ListFormatting};
use crate::lists::{ListFormatting, itemize_list, write_list};
use crate::rewrite::{Rewrite, RewriteContext, RewriteError, RewriteErrorExt, RewriteResult};
use crate::shape::Shape;
use crate::source_map::SpanUtils;
Expand Down
4 changes: 2 additions & 2 deletions src/missed_spans.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use rustc_span::{BytePos, Pos, Span};

use crate::comment::{is_last_comment_block, rewrite_comment, CodeCharKind, CommentCodeSlices};
use crate::config::file_lines::FileLines;
use crate::comment::{CodeCharKind, CommentCodeSlices, is_last_comment_block, rewrite_comment};
use crate::config::FileName;
use crate::config::StyleEdition;
use crate::config::file_lines::FileLines;
use crate::coverage::transform_missing_snippet;
use crate::shape::{Indent, Shape};
use crate::source_map::LineRangeUtils;
Expand Down
2 changes: 1 addition & 1 deletion src/modules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use std::path::{Path, PathBuf};

use rustc_ast::ast;
use rustc_ast::visit::Visitor;
use rustc_span::symbol::{self, sym, Symbol};
use rustc_span::Span;
use rustc_span::symbol::{self, Symbol, sym};
use thin_vec::ThinVec;
use thiserror::Error;

Expand Down
Loading

0 comments on commit de40520

Please sign in to comment.