diff options
| author | Michael Goulet <michael@errs.io> | 2024-09-22 19:05:04 -0400 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2024-09-22 19:11:29 -0400 |
| commit | c682aa162b0d41e21cc6748f4fecfe01efb69d1f (patch) | |
| tree | 0c31b640e3faacfb187a1509e3da5d5b6ba0109c /src/tools | |
| parent | 1173204b364841b51598744fc69d7c80be10f956 (diff) | |
Reformat using the new identifier sorting from rustfmt
Diffstat (limited to 'src/tools')
45 files changed, 197 insertions, 249 deletions
diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index eb5faeeaf9a..62e1695cbe3 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -598,14 +598,11 @@ impl Builder { }) .collect(); - dst.insert( - pkg.manifest_component_name(), - Package { - version: version_info.version.unwrap_or_default(), - git_commit_hash: version_info.git_commit, - target: targets, - }, - ); + dst.insert(pkg.manifest_component_name(), Package { + version: version_info.version.unwrap_or_default(), + git_commit_hash: version_info.git_commit, + target: targets, + }); } fn url(&self, path: &Path) -> String { diff --git a/src/tools/build-manifest/src/manifest.rs b/src/tools/build-manifest/src/manifest.rs index 695a8f5d4e7..f038deea702 100644 --- a/src/tools/build-manifest/src/manifest.rs +++ b/src/tools/build-manifest/src/manifest.rs @@ -3,8 +3,8 @@ use std::path::{Path, PathBuf}; use serde::{Serialize, Serializer}; -use crate::versions::PkgType; use crate::Builder; +use crate::versions::PkgType; #[derive(Serialize)] #[serde(rename_all = "kebab-case")] diff --git a/src/tools/bump-stage0/src/main.rs b/src/tools/bump-stage0/src/main.rs index f8c75ca7226..b2dc044ec66 100644 --- a/src/tools/bump-stage0/src/main.rs +++ b/src/tools/bump-stage0/src/main.rs @@ -1,7 +1,7 @@ #![deny(unused_variables)] use anyhow::{Context, Error}; -use build_helper::stage0_parser::{parse_stage0_file, Stage0Config, VersionMetadata}; +use build_helper::stage0_parser::{Stage0Config, VersionMetadata, parse_stage0_file}; use curl::easy::Easy; use indexmap::IndexMap; diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 414f9f3a7f1..2d8c0c3fa5e 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -11,7 +11,7 @@ use serde::de::{Deserialize, Deserializer, Error as _}; use test::{ColorConfig, OutputFormat}; pub use self::Mode::*; -use crate::util::{add_dylib_path, PathBufExt}; +use crate::util::{PathBufExt, add_dylib_path}; macro_rules! string_enum { ($(#[$meta:meta])* $vis:vis enum $name:ident { $($variant:ident => $repr:expr,)* }) => { diff --git a/src/tools/compiletest/src/errors.rs b/src/tools/compiletest/src/errors.rs index 4ca9f02ddc7..efe758e65cf 100644 --- a/src/tools/compiletest/src/errors.rs +++ b/src/tools/compiletest/src/errors.rs @@ -1,7 +1,7 @@ use std::fmt; use std::fs::File; -use std::io::prelude::*; use std::io::BufReader; +use std::io::prelude::*; use std::path::Path; use std::str::FromStr; use std::sync::OnceLock; diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 93df6aa7255..a291ff37112 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -1,8 +1,8 @@ use std::collections::HashSet; use std::env; use std::fs::File; -use std::io::prelude::*; use std::io::BufReader; +use std::io::prelude::*; use std::path::{Path, PathBuf}; use std::process::Command; use std::sync::OnceLock; @@ -11,7 +11,7 @@ use regex::Regex; use tracing::*; use crate::common::{Config, Debugger, FailMode, Mode, PassMode}; -use crate::header::cfg::{parse_cfg_name_directive, MatchOutcome}; +use crate::header::cfg::{MatchOutcome, parse_cfg_name_directive}; use crate::header::needs::CachedNeedsConditions; use crate::util::static_regex; use crate::{extract_cdb_version, extract_gdb_version}; diff --git a/src/tools/compiletest/src/header/needs.rs b/src/tools/compiletest/src/header/needs.rs index e903f60ceb3..99c0e850f1a 100644 --- a/src/tools/compiletest/src/header/needs.rs +++ b/src/tools/compiletest/src/header/needs.rs @@ -1,5 +1,5 @@ use crate::common::{Config, Sanitizer}; -use crate::header::{llvm_has_libzstd, IgnoreDecision}; +use crate::header::{IgnoreDecision, llvm_has_libzstd}; pub(super) fn handle_needs( cache: &CachedNeedsConditions, diff --git a/src/tools/compiletest/src/header/tests.rs b/src/tools/compiletest/src/header/tests.rs index 3a9a7eb9118..ae661200c6c 100644 --- a/src/tools/compiletest/src/header/tests.rs +++ b/src/tools/compiletest/src/header/tests.rs @@ -4,7 +4,7 @@ use std::str::FromStr; use super::iter_header; use crate::common::{Config, Debugger, Mode}; -use crate::header::{parse_normalize_rule, EarlyProps, HeadersCache}; +use crate::header::{EarlyProps, HeadersCache, parse_normalize_rule}; fn make_test_description<R: Read>( config: &Config, @@ -226,10 +226,9 @@ fn revisions() { let config: Config = cfg().build(); assert_eq!(parse_rs(&config, "//@ revisions: a b c").revisions, vec!["a", "b", "c"],); - assert_eq!( - parse_makefile(&config, "# revisions: hello there").revisions, - vec!["hello", "there"], - ); + assert_eq!(parse_makefile(&config, "# revisions: hello there").revisions, vec![ + "hello", "there" + ],); } #[test] diff --git a/src/tools/compiletest/src/lib.rs b/src/tools/compiletest/src/lib.rs index 3339116d542..cfc619f9342 100644 --- a/src/tools/compiletest/src/lib.rs +++ b/src/tools/compiletest/src/lib.rs @@ -34,10 +34,10 @@ use test::ColorConfig; use tracing::*; use walkdir::WalkDir; -use self::header::{make_test_description, EarlyProps}; +use self::header::{EarlyProps, make_test_description}; use crate::common::{ - expected_output_path, output_base_dir, output_relative_path, Config, Debugger, Mode, PassMode, - TestPaths, UI_EXTENSIONS, + Config, Debugger, Mode, PassMode, TestPaths, UI_EXTENSIONS, expected_output_path, + output_base_dir, output_relative_path, }; use crate::header::HeadersCache; use crate::util::logv; diff --git a/src/tools/compiletest/src/read2.rs b/src/tools/compiletest/src/read2.rs index b2d068e78b4..2375f391d03 100644 --- a/src/tools/compiletest/src/read2.rs +++ b/src/tools/compiletest/src/read2.rs @@ -232,9 +232,9 @@ mod imp { use std::process::{ChildStderr, ChildStdout}; use std::{io, slice}; + use miow::Overlapped; use miow::iocp::{CompletionPort, CompletionStatus}; use miow::pipe::NamedPipe; - use miow::Overlapped; use windows::Win32::Foundation::ERROR_BROKEN_PIPE; struct Pipe<'a> { diff --git a/src/tools/compiletest/src/read2/tests.rs b/src/tools/compiletest/src/read2/tests.rs index 9e052ff069b..10572725431 100644 --- a/src/tools/compiletest/src/read2/tests.rs +++ b/src/tools/compiletest/src/read2/tests.rs @@ -1,6 +1,6 @@ use std::io::Write; -use crate::read2::{ProcOutput, FILTERED_PATHS_PLACEHOLDER_LEN, MAX_OUT_LEN}; +use crate::read2::{FILTERED_PATHS_PLACEHOLDER_LEN, MAX_OUT_LEN, ProcOutput}; #[test] fn test_abbreviate_short_string() { diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 7b23aa34639..177d4044ec2 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -3,7 +3,7 @@ use std::borrow::Cow; use std::collections::{HashMap, HashSet}; use std::ffi::OsString; -use std::fs::{self, create_dir_all, File}; +use std::fs::{self, File, create_dir_all}; use std::hash::{DefaultHasher, Hash, Hasher}; use std::io::prelude::*; use std::io::{self, BufReader}; @@ -18,18 +18,18 @@ use regex::{Captures, Regex}; use tracing::*; use crate::common::{ - expected_output_path, incremental_dir, output_base_dir, output_base_name, - output_testname_unique, Assembly, Codegen, CodegenUnits, CompareMode, Config, CoverageMap, - CoverageRun, Crashes, DebugInfo, Debugger, FailMode, Incremental, JsDocTest, MirOpt, PassMode, - Pretty, RunMake, RunPassValgrind, Rustdoc, RustdocJson, TestPaths, Ui, UI_EXTENSIONS, UI_FIXED, - UI_RUN_STDERR, UI_RUN_STDOUT, UI_STDERR, UI_STDOUT, UI_SVG, UI_WINDOWS_SVG, + Assembly, Codegen, CodegenUnits, CompareMode, Config, CoverageMap, CoverageRun, Crashes, + DebugInfo, Debugger, FailMode, Incremental, JsDocTest, MirOpt, PassMode, Pretty, RunMake, + RunPassValgrind, Rustdoc, RustdocJson, TestPaths, UI_EXTENSIONS, UI_FIXED, UI_RUN_STDERR, + UI_RUN_STDOUT, UI_STDERR, UI_STDOUT, UI_SVG, UI_WINDOWS_SVG, Ui, expected_output_path, + incremental_dir, output_base_dir, output_base_name, output_testname_unique, }; use crate::compute_diff::{write_diff, write_filtered_diff}; use crate::errors::{self, Error, ErrorKind}; use crate::header::TestProps; -use crate::read2::{read2_abbreviated, Truncated}; -use crate::util::{add_dylib_path, logv, static_regex, PathBufExt}; -use crate::{json, ColorConfig}; +use crate::read2::{Truncated, read2_abbreviated}; +use crate::util::{PathBufExt, add_dylib_path, logv, static_regex}; +use crate::{ColorConfig, json}; mod debugger; @@ -62,7 +62,7 @@ fn disable_error_reporting<F: FnOnce() -> R, R>(f: F) -> R { use std::sync::Mutex; use windows::Win32::System::Diagnostics::Debug::{ - SetErrorMode, SEM_NOGPFAULTERRORBOX, THREAD_ERROR_MODE, + SEM_NOGPFAULTERRORBOX, SetErrorMode, THREAD_ERROR_MODE, }; static LOCK: Mutex<()> = Mutex::new(()); diff --git a/src/tools/compiletest/src/runtest/mir_opt.rs b/src/tools/compiletest/src/runtest/mir_opt.rs index 02289a8df1e..d1ec0035744 100644 --- a/src/tools/compiletest/src/runtest/mir_opt.rs +++ b/src/tools/compiletest/src/runtest/mir_opt.rs @@ -2,7 +2,7 @@ use std::fs; use std::path::{Path, PathBuf}; use glob::glob; -use miropt_test_tools::{files_for_miropt_test, MiroptTest, MiroptTestFile}; +use miropt_test_tools::{MiroptTest, MiroptTestFile, files_for_miropt_test}; use tracing::debug; use super::{Emit, TestCx, WillExecute}; diff --git a/src/tools/compiletest/src/runtest/rustdoc.rs b/src/tools/compiletest/src/runtest/rustdoc.rs index 6a31888527e..3f33862d2cf 100644 --- a/src/tools/compiletest/src/runtest/rustdoc.rs +++ b/src/tools/compiletest/src/runtest/rustdoc.rs @@ -1,6 +1,6 @@ use std::process::Command; -use super::{remove_and_create_dir_all, TestCx}; +use super::{TestCx, remove_and_create_dir_all}; impl TestCx<'_> { pub(super) fn run_rustdoc_test(&self) { diff --git a/src/tools/compiletest/src/runtest/rustdoc_json.rs b/src/tools/compiletest/src/runtest/rustdoc_json.rs index a39887ccd02..31fdb0a5d13 100644 --- a/src/tools/compiletest/src/runtest/rustdoc_json.rs +++ b/src/tools/compiletest/src/runtest/rustdoc_json.rs @@ -1,6 +1,6 @@ use std::process::Command; -use super::{remove_and_create_dir_all, TestCx}; +use super::{TestCx, remove_and_create_dir_all}; impl TestCx<'_> { pub(super) fn run_rustdoc_json_test(&self) { diff --git a/src/tools/compiletest/src/runtest/ui.rs b/src/tools/compiletest/src/runtest/ui.rs index 88a0ec3aa3b..bd8ef952a86 100644 --- a/src/tools/compiletest/src/runtest/ui.rs +++ b/src/tools/compiletest/src/runtest/ui.rs @@ -2,12 +2,12 @@ use std::collections::HashSet; use std::fs::OpenOptions; use std::io::Write; -use rustfix::{apply_suggestions, get_suggestions_from_json, Filter}; +use rustfix::{Filter, apply_suggestions, get_suggestions_from_json}; use tracing::debug; use super::{ AllowUnused, Emit, ErrorKind, FailMode, LinkToAux, PassMode, TargetLocation, TestCx, - TestOutput, Truncated, WillExecute, UI_FIXED, + TestOutput, Truncated, UI_FIXED, WillExecute, }; use crate::{errors, json}; diff --git a/src/tools/coverage-dump/src/covfun.rs b/src/tools/coverage-dump/src/covfun.rs index 4729b327de5..c779dd0583c 100644 --- a/src/tools/coverage-dump/src/covfun.rs +++ b/src/tools/coverage-dump/src/covfun.rs @@ -2,10 +2,10 @@ use std::collections::HashMap; use std::fmt::{self, Debug, Write as _}; use std::sync::OnceLock; -use anyhow::{anyhow, Context}; +use anyhow::{Context, anyhow}; use regex::Regex; -use crate::parser::{unescape_llvm_string_contents, Parser}; +use crate::parser::{Parser, unescape_llvm_string_contents}; pub(crate) fn dump_covfun_mappings( llvm_ir: &str, diff --git a/src/tools/coverage-dump/src/prf_names.rs b/src/tools/coverage-dump/src/prf_names.rs index c5f9c4ce54c..96d097c79a3 100644 --- a/src/tools/coverage-dump/src/prf_names.rs +++ b/src/tools/coverage-dump/src/prf_names.rs @@ -4,7 +4,7 @@ use std::sync::OnceLock; use anyhow::{anyhow, ensure}; use regex::Regex; -use crate::parser::{unescape_llvm_string_contents, Parser}; +use crate::parser::{Parser, unescape_llvm_string_contents}; /// Scans through the contents of an LLVM IR assembly file to find `__llvm_prf_names` /// entries, decodes them, and creates a table that maps name hash values to diff --git a/src/tools/error_index_generator/main.rs b/src/tools/error_index_generator/main.rs index 53a26112911..58224aed148 100644 --- a/src/tools/error_index_generator/main.rs +++ b/src/tools/error_index_generator/main.rs @@ -12,7 +12,7 @@ use std::io::Write; use std::path::{Path, PathBuf}; use std::str::FromStr; -use mdbook::book::{parse_summary, BookItem, Chapter}; +use mdbook::book::{BookItem, Chapter, parse_summary}; use mdbook::{Config, MDBook}; use rustc_errors::codes::DIAGNOSTICS; diff --git a/src/tools/generate-copyright/src/cargo_metadata.rs b/src/tools/generate-copyright/src/cargo_metadata.rs index c85e4aa371a..31b18c3dc10 100644 --- a/src/tools/generate-copyright/src/cargo_metadata.rs +++ b/src/tools/generate-copyright/src/cargo_metadata.rs @@ -99,15 +99,12 @@ pub fn get_metadata( } // otherwise it's an out-of-tree dependency let package_id = Package { name: package.name, version: package.version.to_string() }; - output.insert( - package_id, - PackageMetadata { - license: package.license.unwrap_or_else(|| String::from("Unspecified")), - authors: package.authors, - notices: BTreeMap::new(), - is_in_libstd: None, - }, - ); + output.insert(package_id, PackageMetadata { + license: package.license.unwrap_or_else(|| String::from("Unspecified")), + authors: package.authors, + notices: BTreeMap::new(), + is_in_libstd: None, + }); } } diff --git a/src/tools/jsondoclint/src/main.rs b/src/tools/jsondoclint/src/main.rs index aaaba78cb46..5cbf3460860 100644 --- a/src/tools/jsondoclint/src/main.rs +++ b/src/tools/jsondoclint/src/main.rs @@ -1,10 +1,10 @@ use std::io::{BufWriter, Write}; use std::path::{Path, PathBuf}; -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; use clap::Parser; use fs_err as fs; -use rustdoc_json_types::{Crate, Id, FORMAT_VERSION}; +use rustdoc_json_types::{Crate, FORMAT_VERSION, Id}; use serde::Serialize; use serde_json::Value; diff --git a/src/tools/jsondoclint/src/validator.rs b/src/tools/jsondoclint/src/validator.rs index 10ab62cb24a..b04919bdd3e 100644 --- a/src/tools/jsondoclint/src/validator.rs +++ b/src/tools/jsondoclint/src/validator.rs @@ -11,7 +11,7 @@ use rustdoc_json_types::{ use serde_json::Value; use crate::item_kind::Kind; -use crate::{json_find, Error, ErrorKind}; +use crate::{Error, ErrorKind, json_find}; // This is a rustc implementation detail that we rely on here const LOCAL_CRATE_ID: u32 = 0; diff --git a/src/tools/jsondoclint/src/validator/tests.rs b/src/tools/jsondoclint/src/validator/tests.rs index f28702de06d..d15aa7db315 100644 --- a/src/tools/jsondoclint/src/validator/tests.rs +++ b/src/tools/jsondoclint/src/validator/tests.rs @@ -1,5 +1,5 @@ use rustc_hash::FxHashMap; -use rustdoc_json_types::{Item, ItemKind, Visibility, FORMAT_VERSION}; +use rustdoc_json_types::{FORMAT_VERSION, Item, ItemKind, Visibility}; use super::*; use crate::json_find::SelectorPart; @@ -25,42 +25,32 @@ fn errors_on_missing_links() { root: id("0"), crate_version: None, includes_private: false, - index: FxHashMap::from_iter([( - id("0"), - Item { - name: Some("root".to_owned()), - id: id(""), - crate_id: 0, - span: None, - visibility: Visibility::Public, - docs: None, - links: FxHashMap::from_iter([("Not Found".to_owned(), id("1"))]), - attrs: vec![], - deprecation: None, - inner: ItemEnum::Module(Module { - is_crate: true, - items: vec![], - is_stripped: false, - }), - }, - )]), + index: FxHashMap::from_iter([(id("0"), Item { + name: Some("root".to_owned()), + id: id(""), + crate_id: 0, + span: None, + visibility: Visibility::Public, + docs: None, + links: FxHashMap::from_iter([("Not Found".to_owned(), id("1"))]), + attrs: vec![], + deprecation: None, + inner: ItemEnum::Module(Module { is_crate: true, items: vec![], is_stripped: false }), + })]), paths: FxHashMap::default(), external_crates: FxHashMap::default(), format_version: rustdoc_json_types::FORMAT_VERSION, }; - check( - &k, - &[Error { - kind: ErrorKind::NotFound(vec![vec![ - SelectorPart::Field("index".to_owned()), - SelectorPart::Field("0".to_owned()), - SelectorPart::Field("links".to_owned()), - SelectorPart::Field("Not Found".to_owned()), - ]]), - id: id("1"), - }], - ); + check(&k, &[Error { + kind: ErrorKind::NotFound(vec![vec![ + SelectorPart::Field("index".to_owned()), + SelectorPart::Field("0".to_owned()), + SelectorPart::Field("links".to_owned()), + SelectorPart::Field("Not Found".to_owned()), + ]]), + id: id("1"), + }]); } // Test we would catch @@ -72,60 +62,48 @@ fn errors_on_local_in_paths_and_not_index() { crate_version: None, includes_private: false, index: FxHashMap::from_iter([ - ( - id("0:0:1572"), - Item { - id: id("0:0:1572"), - crate_id: 0, - name: Some("microcore".to_owned()), - span: None, - visibility: Visibility::Public, - docs: None, - links: FxHashMap::from_iter([(("prim@i32".to_owned(), id("0:1:1571")))]), - attrs: Vec::new(), - deprecation: None, - inner: ItemEnum::Module(Module { - is_crate: true, - items: vec![id("0:1:717")], - is_stripped: false, - }), - }, - ), - ( - id("0:1:717"), - Item { - id: id("0:1:717"), - crate_id: 0, - name: Some("i32".to_owned()), - span: None, - visibility: Visibility::Public, - docs: None, - links: FxHashMap::default(), - attrs: Vec::new(), - deprecation: None, - inner: ItemEnum::Primitive(Primitive { name: "i32".to_owned(), impls: vec![] }), - }, - ), - ]), - paths: FxHashMap::from_iter([( - id("0:1:1571"), - ItemSummary { + (id("0:0:1572"), Item { + id: id("0:0:1572"), crate_id: 0, - path: vec!["microcore".to_owned(), "i32".to_owned()], - kind: ItemKind::Primitive, - }, - )]), + name: Some("microcore".to_owned()), + span: None, + visibility: Visibility::Public, + docs: None, + links: FxHashMap::from_iter([(("prim@i32".to_owned(), id("0:1:1571")))]), + attrs: Vec::new(), + deprecation: None, + inner: ItemEnum::Module(Module { + is_crate: true, + items: vec![id("0:1:717")], + is_stripped: false, + }), + }), + (id("0:1:717"), Item { + id: id("0:1:717"), + crate_id: 0, + name: Some("i32".to_owned()), + span: None, + visibility: Visibility::Public, + docs: None, + links: FxHashMap::default(), + attrs: Vec::new(), + deprecation: None, + inner: ItemEnum::Primitive(Primitive { name: "i32".to_owned(), impls: vec![] }), + }), + ]), + paths: FxHashMap::from_iter([(id("0:1:1571"), ItemSummary { + crate_id: 0, + path: vec!["microcore".to_owned(), "i32".to_owned()], + kind: ItemKind::Primitive, + })]), external_crates: FxHashMap::default(), format_version: rustdoc_json_types::FORMAT_VERSION, }; - check( - &krate, - &[Error { - id: id("0:1:1571"), - kind: ErrorKind::Custom("Id for local item in `paths` but not in `index`".to_owned()), - }], - ); + check(&krate, &[Error { + id: id("0:1:1571"), + kind: ErrorKind::Custom("Id for local item in `paths` but not in `index`".to_owned()), + }]); } #[test] @@ -135,25 +113,18 @@ fn checks_local_crate_id_is_correct() { root: id("root"), crate_version: None, includes_private: false, - index: FxHashMap::from_iter([( - id("root"), - Item { - id: id("root"), - crate_id: LOCAL_CRATE_ID.wrapping_add(1), - name: Some("irrelavent".to_owned()), - span: None, - visibility: Visibility::Public, - docs: None, - links: FxHashMap::default(), - attrs: Vec::new(), - deprecation: None, - inner: ItemEnum::Module(Module { - is_crate: true, - items: vec![], - is_stripped: false, - }), - }, - )]), + index: FxHashMap::from_iter([(id("root"), Item { + id: id("root"), + crate_id: LOCAL_CRATE_ID.wrapping_add(1), + name: Some("irrelavent".to_owned()), + span: None, + visibility: Visibility::Public, + docs: None, + links: FxHashMap::default(), + attrs: Vec::new(), + deprecation: None, + inner: ItemEnum::Module(Module { is_crate: true, items: vec![], is_stripped: false }), + })]), paths: FxHashMap::default(), external_crates: FxHashMap::default(), format_version: FORMAT_VERSION, diff --git a/src/tools/lint-docs/src/lib.rs b/src/tools/lint-docs/src/lib.rs index 532a27b22aa..8c7ff08ccd7 100644 --- a/src/tools/lint-docs/src/lib.rs +++ b/src/tools/lint-docs/src/lib.rs @@ -19,30 +19,24 @@ mod groups; /// level of the lint, which will be more difficult to support, since rustc /// currently does not track that historical information. static RENAMES: &[(Level, &[(&str, &str)])] = &[ - ( - Level::Allow, - &[ - ("single-use-lifetime", "single-use-lifetimes"), - ("elided-lifetime-in-path", "elided-lifetimes-in-paths"), - ("async-idents", "keyword-idents"), - ("disjoint-capture-migration", "rust-2021-incompatible-closure-captures"), - ("keyword-idents", "keyword-idents-2018"), - ("or-patterns-back-compat", "rust-2021-incompatible-or-patterns"), - ], - ), - ( - Level::Warn, - &[ - ("bare-trait-object", "bare-trait-objects"), - ("unstable-name-collision", "unstable-name-collisions"), - ("unused-doc-comment", "unused-doc-comments"), - ("redundant-semicolon", "redundant-semicolons"), - ("overlapping-patterns", "overlapping-range-endpoints"), - ("non-fmt-panic", "non-fmt-panics"), - ("unused-tuple-struct-fields", "dead-code"), - ("static-mut-ref", "static-mut-refs"), - ], - ), + (Level::Allow, &[ + ("single-use-lifetime", "single-use-lifetimes"), + ("elided-lifetime-in-path", "elided-lifetimes-in-paths"), + ("async-idents", "keyword-idents"), + ("disjoint-capture-migration", "rust-2021-incompatible-closure-captures"), + ("keyword-idents", "keyword-idents-2018"), + ("or-patterns-back-compat", "rust-2021-incompatible-or-patterns"), + ]), + (Level::Warn, &[ + ("bare-trait-object", "bare-trait-objects"), + ("unstable-name-collision", "unstable-name-collisions"), + ("unused-doc-comment", "unused-doc-comments"), + ("redundant-semicolon", "redundant-semicolons"), + ("overlapping-patterns", "overlapping-range-endpoints"), + ("non-fmt-panic", "non-fmt-panics"), + ("unused-tuple-struct-fields", "dead-code"), + ("static-mut-ref", "static-mut-refs"), + ]), (Level::Deny, &[("exceeding-bitshifts", "arithmetic-overflow")]), ]; diff --git a/src/tools/opt-dist/src/main.rs b/src/tools/opt-dist/src/main.rs index 73389f930bd..6211b5670aa 100644 --- a/src/tools/opt-dist/src/main.rs +++ b/src/tools/opt-dist/src/main.rs @@ -6,7 +6,7 @@ use utils::io; use crate::bolt::{bolt_optimize, with_bolt_instrumented}; use crate::environment::{Environment, EnvironmentBuilder}; -use crate::exec::{cmd, Bootstrap}; +use crate::exec::{Bootstrap, cmd}; use crate::tests::run_tests; use crate::timer::Timer; use crate::training::{ diff --git a/src/tools/opt-dist/src/tests.rs b/src/tools/opt-dist/src/tests.rs index e7a3ed787ed..82c393d34a6 100644 --- a/src/tools/opt-dist/src/tests.rs +++ b/src/tools/opt-dist/src/tests.rs @@ -1,7 +1,7 @@ use anyhow::Context; use camino::{Utf8Path, Utf8PathBuf}; -use crate::environment::{executable_extension, Environment}; +use crate::environment::{Environment, executable_extension}; use crate::exec::cmd; use crate::utils::io::{copy_directory, find_file_in_dir, unpack_archive}; diff --git a/src/tools/opt-dist/src/training.rs b/src/tools/opt-dist/src/training.rs index 97e8ec5c6ed..30c79f95947 100644 --- a/src/tools/opt-dist/src/training.rs +++ b/src/tools/opt-dist/src/training.rs @@ -3,8 +3,8 @@ use build_helper::{LLVM_PGO_CRATES, RUSTC_PGO_CRATES}; use camino::{Utf8Path, Utf8PathBuf}; use humansize::BINARY; -use crate::environment::{executable_extension, Environment}; -use crate::exec::{cmd, CmdBuilder}; +use crate::environment::{Environment, executable_extension}; +use crate::exec::{CmdBuilder, cmd}; use crate::utils::io::{count_files, delete_directory}; use crate::utils::with_log_group; diff --git a/src/tools/opt-dist/src/utils/artifact_size.rs b/src/tools/opt-dist/src/utils/artifact_size.rs index e51b5f06dfb..74f7f75b9c0 100644 --- a/src/tools/opt-dist/src/utils/artifact_size.rs +++ b/src/tools/opt-dist/src/utils/artifact_size.rs @@ -11,7 +11,7 @@ use crate::utils::io::get_files_from_dir; pub fn print_binary_sizes(env: &Environment) -> anyhow::Result<()> { use std::fmt::Write; - use humansize::{format_size, BINARY}; + use humansize::{BINARY, format_size}; let root = env.build_artifacts().join("stage2"); diff --git a/src/tools/rust-installer/src/combiner.rs b/src/tools/rust-installer/src/combiner.rs index 66b3d324568..487b7cae844 100644 --- a/src/tools/rust-installer/src/combiner.rs +++ b/src/tools/rust-installer/src/combiner.rs @@ -1,7 +1,7 @@ use std::io::{Read, Write}; use std::path::Path; -use anyhow::{bail, Context, Result}; +use anyhow::{Context, Result, bail}; use tar::Archive; use super::{Scripter, Tarballer}; diff --git a/src/tools/rust-installer/src/compression.rs b/src/tools/rust-installer/src/compression.rs index df3a98ae789..96c48657c46 100644 --- a/src/tools/rust-installer/src/compression.rs +++ b/src/tools/rust-installer/src/compression.rs @@ -81,17 +81,14 @@ impl CompressionFormat { let file = crate::util::create_new_file(path)?; Ok(match self { - CompressionFormat::Gz => Box::new(GzEncoder::new( - file, - match profile { - CompressionProfile::Fast => flate2::Compression::fast(), - CompressionProfile::Balanced => flate2::Compression::new(6), - CompressionProfile::Best => flate2::Compression::best(), - CompressionProfile::NoOp => panic!( - "compression profile 'no-op' should not call `CompressionFormat::encode`." - ), - }, - )), + CompressionFormat::Gz => Box::new(GzEncoder::new(file, match profile { + CompressionProfile::Fast => flate2::Compression::fast(), + CompressionProfile::Balanced => flate2::Compression::new(6), + CompressionProfile::Best => flate2::Compression::best(), + CompressionProfile::NoOp => panic!( + "compression profile 'no-op' should not call `CompressionFormat::encode`." + ), + })), CompressionFormat::Xz => { let encoder = match profile { CompressionProfile::NoOp => panic!( diff --git a/src/tools/rust-installer/src/generator.rs b/src/tools/rust-installer/src/generator.rs index e1228693344..d8a8a11332b 100644 --- a/src/tools/rust-installer/src/generator.rs +++ b/src/tools/rust-installer/src/generator.rs @@ -2,7 +2,7 @@ use std::collections::BTreeSet; use std::io::Write; use std::path::Path; -use anyhow::{bail, format_err, Context, Result}; +use anyhow::{Context, Result, bail, format_err}; use super::{Scripter, Tarballer}; use crate::compression::{CompressionFormats, CompressionProfile}; diff --git a/src/tools/rust-installer/src/tarballer.rs b/src/tools/rust-installer/src/tarballer.rs index a101be8f5ff..854bb85f2c5 100644 --- a/src/tools/rust-installer/src/tarballer.rs +++ b/src/tools/rust-installer/src/tarballer.rs @@ -2,7 +2,7 @@ use std::fs::{read_link, symlink_metadata}; use std::io::{BufWriter, Write}; use std::path::Path; -use anyhow::{bail, Context, Result}; +use anyhow::{Context, Result, bail}; use tar::{Builder, Header, HeaderMode}; use walkdir::WalkDir; diff --git a/src/tools/rust-installer/src/util.rs b/src/tools/rust-installer/src/util.rs index 51b8c9c9d1b..bbded1df310 100644 --- a/src/tools/rust-installer/src/util.rs +++ b/src/tools/rust-installer/src/util.rs @@ -1,15 +1,15 @@ use std::fs; -// FIXME: what about Windows? Are default ACLs executable? -#[cfg(unix)] -use std::os::unix::fs::symlink as symlink_file; // Needed to set the script mode to executable. #[cfg(unix)] use std::os::unix::fs::OpenOptionsExt; +// FIXME: what about Windows? Are default ACLs executable? +#[cfg(unix)] +use std::os::unix::fs::symlink as symlink_file; #[cfg(windows)] use std::os::windows::fs::symlink_file; use std::path::Path; -use anyhow::{format_err, Context, Result}; +use anyhow::{Context, Result, format_err}; use walkdir::WalkDir; /// Converts a `&Path` to a UTF-8 `&str`. diff --git a/src/tools/rustbook/src/main.rs b/src/tools/rustbook/src/main.rs index a4faac0760f..2118af61396 100644 --- a/src/tools/rustbook/src/main.rs +++ b/src/tools/rustbook/src/main.rs @@ -1,9 +1,9 @@ use std::env; use std::path::{Path, PathBuf}; -use clap::{arg, crate_version, ArgMatches, Command}; -use mdbook::errors::Result as Result3; +use clap::{ArgMatches, Command, arg, crate_version}; use mdbook::MDBook; +use mdbook::errors::Result as Result3; use mdbook_i18n_helpers::preprocessors::Gettext; use mdbook_spec::Spec; use mdbook_trpl_listing::TrplListing; diff --git a/src/tools/rustdoc-themes/main.rs b/src/tools/rustdoc-themes/main.rs index 1eba83a8057..9f0663bd8ee 100644 --- a/src/tools/rustdoc-themes/main.rs +++ b/src/tools/rustdoc-themes/main.rs @@ -1,8 +1,8 @@ use std::env::args; -use std::fs::{create_dir_all, File}; +use std::fs::{File, create_dir_all}; use std::io::{BufRead, BufReader, BufWriter, Write}; use std::path::Path; -use std::process::{exit, Command}; +use std::process::{Command, exit}; fn get_themes<P: AsRef<Path>>(style_path: P) -> Vec<String> { let mut ret = Vec::with_capacity(10); diff --git a/src/tools/suggest-tests/src/main.rs b/src/tools/suggest-tests/src/main.rs index 6f09bddcf60..ee8cc40404d 100644 --- a/src/tools/suggest-tests/src/main.rs +++ b/src/tools/suggest-tests/src/main.rs @@ -1,6 +1,6 @@ use std::process::ExitCode; -use build_helper::git::{get_git_modified_files, GitConfig}; +use build_helper::git::{GitConfig, get_git_modified_files}; use suggest_tests::get_suggestions; fn main() -> ExitCode { diff --git a/src/tools/suggest-tests/src/static_suggestions.rs b/src/tools/suggest-tests/src/static_suggestions.rs index a282facd9df..b216138cf9a 100644 --- a/src/tools/suggest-tests/src/static_suggestions.rs +++ b/src/tools/suggest-tests/src/static_suggestions.rs @@ -1,6 +1,6 @@ use std::sync::OnceLock; -use crate::{sug, Suggestion}; +use crate::{Suggestion, sug}; // FIXME: perhaps this could use `std::lazy` when it is stablizied macro_rules! static_suggestions { diff --git a/src/tools/tidy/src/ext_tool_checks.rs b/src/tools/tidy/src/ext_tool_checks.rs index ea9ab01aaf8..8f21338c7db 100644 --- a/src/tools/tidy/src/ext_tool_checks.rs +++ b/src/tools/tidy/src/ext_tool_checks.rs @@ -172,11 +172,10 @@ fn check_impl( let files; if file_args_clang_format.is_empty() { let llvm_wrapper = root_path.join("compiler/rustc_llvm/llvm-wrapper"); - files = find_with_extension( - root_path, - Some(llvm_wrapper.as_path()), - &[OsStr::new("h"), OsStr::new("cpp")], - )?; + files = find_with_extension(root_path, Some(llvm_wrapper.as_path()), &[ + OsStr::new("h"), + OsStr::new("cpp"), + ])?; file_args_clang_format.extend(files.iter().map(|p| p.as_os_str())); } let args = merge_args(&cfg_args_clang_format, &file_args_clang_format); diff --git a/src/tools/tidy/src/main.rs b/src/tools/tidy/src/main.rs index 38b3f3f6417..40608952c0b 100644 --- a/src/tools/tidy/src/main.rs +++ b/src/tools/tidy/src/main.rs @@ -9,7 +9,7 @@ use std::num::NonZeroUsize; use std::path::PathBuf; use std::str::FromStr; use std::sync::atomic::{AtomicBool, Ordering}; -use std::thread::{self, scope, ScopedJoinHandle}; +use std::thread::{self, ScopedJoinHandle, scope}; use std::{env, process}; use tidy::*; diff --git a/src/tools/tidy/src/target_specific_tests.rs b/src/tools/tidy/src/target_specific_tests.rs index c1032b19f97..751d678e581 100644 --- a/src/tools/tidy/src/target_specific_tests.rs +++ b/src/tools/tidy/src/target_specific_tests.rs @@ -4,7 +4,7 @@ use std::collections::BTreeMap; use std::path::Path; -use crate::iter_header::{iter_header, HeaderLine}; +use crate::iter_header::{HeaderLine, iter_header}; use crate::walk::filter_not_rust; const LLVM_COMPONENTS_HEADER: &str = "needs-llvm-components:"; diff --git a/src/tools/tidy/src/unknown_revision.rs b/src/tools/tidy/src/unknown_revision.rs index abfff1d632a..0ba05c80a79 100644 --- a/src/tools/tidy/src/unknown_revision.rs +++ b/src/tools/tidy/src/unknown_revision.rs @@ -12,7 +12,7 @@ use std::sync::OnceLock; use ignore::DirEntry; use regex::Regex; -use crate::iter_header::{iter_header, HeaderLine}; +use crate::iter_header::{HeaderLine, iter_header}; use crate::walk::{filter_dirs, filter_not_rust, walk}; pub fn check(tests_path: impl AsRef<Path>, bad: &mut bool) { diff --git a/src/tools/unicode-table-generator/src/case_mapping.rs b/src/tools/unicode-table-generator/src/case_mapping.rs index f28161c7829..00241b7ee0e 100644 --- a/src/tools/unicode-table-generator/src/case_mapping.rs +++ b/src/tools/unicode-table-generator/src/case_mapping.rs @@ -2,7 +2,7 @@ use std::char; use std::collections::BTreeMap; use std::fmt::{self, Write}; -use crate::{fmt_list, UnicodeData}; +use crate::{UnicodeData, fmt_list}; const INDEX_MASK: u32 = 1 << 22; diff --git a/src/tools/unicode-table-generator/src/main.rs b/src/tools/unicode-table-generator/src/main.rs index 9f89e7c33f7..e1832091d70 100644 --- a/src/tools/unicode-table-generator/src/main.rs +++ b/src/tools/unicode-table-generator/src/main.rs @@ -82,7 +82,7 @@ mod raw_emitter; mod skiplist; mod unicode_download; -use raw_emitter::{emit_codepoints, emit_whitespace, RawEmitter}; +use raw_emitter::{RawEmitter, emit_codepoints, emit_whitespace}; static PROPERTIES: &[&str] = &[ "Alphabetic", diff --git a/src/tools/unicode-table-generator/src/raw_emitter.rs b/src/tools/unicode-table-generator/src/raw_emitter.rs index 47120e4f169..bfffa1eee60 100644 --- a/src/tools/unicode-table-generator/src/raw_emitter.rs +++ b/src/tools/unicode-table-generator/src/raw_emitter.rs @@ -360,15 +360,12 @@ impl Canonicalized { let unique_mapping = unique_mapping .into_iter() .map(|(key, value)| { - ( - key, - match value { - UniqueMapping::Canonicalized(idx) => { - u8::try_from(canonical_words.len() + idx).unwrap() - } - UniqueMapping::Canonical(idx) => u8::try_from(idx).unwrap(), - }, - ) + (key, match value { + UniqueMapping::Canonicalized(idx) => { + u8::try_from(canonical_words.len() + idx).unwrap() + } + UniqueMapping::Canonical(idx) => u8::try_from(idx).unwrap(), + }) }) .collect::<HashMap<_, _>>(); @@ -383,24 +380,21 @@ impl Canonicalized { let canonicalized_words = canonicalized_words .into_iter() .map(|v| { - ( - u8::try_from(v.0).unwrap(), - match v.1 { - Mapping::RotateAndInvert(amount) => { - assert_eq!(amount, amount & LOWER_6); - 1 << 6 | (amount as u8) - } - Mapping::Rotate(amount) => { - assert_eq!(amount, amount & LOWER_6); - amount as u8 - } - Mapping::Invert => 1 << 6, - Mapping::ShiftRight(shift_by) => { - assert_eq!(shift_by, shift_by & LOWER_6); - 1 << 7 | (shift_by as u8) - } - }, - ) + (u8::try_from(v.0).unwrap(), match v.1 { + Mapping::RotateAndInvert(amount) => { + assert_eq!(amount, amount & LOWER_6); + 1 << 6 | (amount as u8) + } + Mapping::Rotate(amount) => { + assert_eq!(amount, amount & LOWER_6); + amount as u8 + } + Mapping::Invert => 1 << 6, + Mapping::ShiftRight(shift_by) => { + assert_eq!(shift_by, shift_by & LOWER_6); + 1 << 7 | (shift_by as u8) + } + }) }) .collect::<Vec<(u8, u8)>>(); Canonicalized { unique_mapping, canonical_words, canonicalized_words } diff --git a/src/tools/unstable-book-gen/src/main.rs b/src/tools/unstable-book-gen/src/main.rs index 9af8802b012..6cbdc83d5b5 100644 --- a/src/tools/unstable-book-gen/src/main.rs +++ b/src/tools/unstable-book-gen/src/main.rs @@ -5,11 +5,11 @@ use std::env; use std::fs::{self, write}; use std::path::Path; -use tidy::features::{collect_lang_features, collect_lib_features, Features}; +use tidy::features::{Features, collect_lang_features, collect_lib_features}; use tidy::t; use tidy::unstable_book::{ - collect_unstable_book_section_file_names, collect_unstable_feature_names, LANG_FEATURES_DIR, - LIB_FEATURES_DIR, PATH_STR, + LANG_FEATURES_DIR, LIB_FEATURES_DIR, PATH_STR, collect_unstable_book_section_file_names, + collect_unstable_feature_names, }; fn generate_stub_issue(path: &Path, name: &str, issue: u32) { |
