diff options
| author | bors <bors@rust-lang.org> | 2024-07-29 02:43:41 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-07-29 02:43:41 +0000 |
| commit | 2e630267b2bce50af3258ce4817e377fa09c145b (patch) | |
| tree | 29006db815bf547dfd0129910b23b8c54675bd98 /compiler/rustc_codegen_ssa/src/back | |
| parent | 2cbbe8b8bb2be672b14cf741a2f0ec24a49f3f0b (diff) | |
| parent | 84ac80f1921afc243d71fd0caaa4f2838c294102 (diff) | |
| download | rust-2e630267b2bce50af3258ce4817e377fa09c145b.tar.gz rust-2e630267b2bce50af3258ce4817e377fa09c145b.zip | |
Auto merge of #125443 - nnethercote:rustfmt-use-decls, r=lcnr,cuviper,GuillaumeGomez
rustfmt `use` declarations This PR implements https://github.com/rust-lang/compiler-team/issues/750, which changes how `use` declarations are formatted by adding these options to `rustfmt.toml`: ``` group_imports = "StdExternalCrate" imports_granularity = "Module" ``` r? `@ghost`
Diffstat (limited to 'compiler/rustc_codegen_ssa/src/back')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/archive.rs | 22 | ||||
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/command.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/link.rs | 46 | ||||
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/linker.rs | 13 | ||||
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/lto.rs | 10 | ||||
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/metadata.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/rpath.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/rpath/tests.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/symbol_export.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/write.rs | 39 |
10 files changed, 71 insertions, 81 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/archive.rs b/compiler/rustc_codegen_ssa/src/back/archive.rs index eade00d75fd..fd39ef2649b 100644 --- a/compiler/rustc_codegen_ssa/src/back/archive.rs +++ b/compiler/rustc_codegen_ssa/src/back/archive.rs @@ -1,22 +1,20 @@ -use rustc_data_structures::fx::FxIndexSet; -use rustc_data_structures::memmap::Mmap; -use rustc_session::cstore::DllImport; -use rustc_session::Session; -use rustc_span::symbol::Symbol; - -use super::metadata::search_for_section; +use std::error::Error; +use std::fs::{self, File}; +use std::io::{self, Write}; +use std::path::{Path, PathBuf}; use ar_archive_writer::{write_archive_to_stream, ArchiveKind, NewArchiveMember}; pub use ar_archive_writer::{ObjectReader, DEFAULT_OBJECT_READER}; use object::read::archive::ArchiveFile; use object::read::macho::FatArch; +use rustc_data_structures::fx::FxIndexSet; +use rustc_data_structures::memmap::Mmap; +use rustc_session::cstore::DllImport; +use rustc_session::Session; +use rustc_span::symbol::Symbol; use tempfile::Builder as TempFileBuilder; -use std::error::Error; -use std::fs::{self, File}; -use std::io::{self, Write}; -use std::path::{Path, PathBuf}; - +use super::metadata::search_for_section; // Re-exporting for rustc_codegen_llvm::back::archive pub use crate::errors::{ArchiveBuildFailure, ExtractBundledLibsError, UnknownArchiveKind}; diff --git a/compiler/rustc_codegen_ssa/src/back/command.rs b/compiler/rustc_codegen_ssa/src/back/command.rs index 3a89be89951..95c4af2e59e 100644 --- a/compiler/rustc_codegen_ssa/src/back/command.rs +++ b/compiler/rustc_codegen_ssa/src/back/command.rs @@ -2,10 +2,8 @@ //! read the arguments that are built up. use std::ffi::{OsStr, OsString}; -use std::fmt; -use std::io; -use std::mem; use std::process::{self, Output}; +use std::{fmt, io, mem}; use rustc_target::spec::LldFlavor; diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index f7460a64d0a..55662bfc2cf 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -1,3 +1,15 @@ +use std::collections::BTreeSet; +use std::ffi::OsString; +use std::fs::{read, File, OpenOptions}; +use std::io::{BufWriter, Write}; +use std::ops::Deref; +use std::path::{Path, PathBuf}; +use std::process::{ExitStatus, Output, Stdio}; +use std::{env, fmt, fs, io, mem, str}; + +use cc::windows_registry; +use itertools::Itertools; +use regex::Regex; use rustc_arena::TypedArena; use rustc_ast::CRATE_NODE_ID; use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; @@ -12,9 +24,10 @@ use rustc_middle::bug; use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile; use rustc_middle::middle::dependency_format::Linkage; use rustc_middle::middle::exported_symbols::SymbolExportKind; -use rustc_session::config::LinkerFeaturesCli; -use rustc_session::config::{self, CFGuard, CrateType, DebugInfo, OutFileName, Strip}; -use rustc_session::config::{OutputFilenames, OutputType, PrintKind, SplitDwarfKind}; +use rustc_session::config::{ + self, CFGuard, CrateType, DebugInfo, LinkerFeaturesCli, OutFileName, OutputFilenames, + OutputType, PrintKind, SplitDwarfKind, Strip, +}; use rustc_session::cstore::DllImport; use rustc_session::output::{check_file_is_writeable, invalid_output_for_target, out_filename}; use rustc_session::search_paths::PathKind; @@ -24,11 +37,13 @@ use rustc_session::utils::NativeLibKind; use rustc_session::{filesearch, Session}; use rustc_span::symbol::Symbol; use rustc_target::spec::crt_objects::CrtObjects; -use rustc_target::spec::LinkSelfContainedDefault; -use rustc_target::spec::LinkerFlavorCli; -use rustc_target::spec::{Cc, LinkOutputKind, LinkerFlavor, Lld, PanicStrategy}; -use rustc_target::spec::{LinkSelfContainedComponents, LinkerFeatures}; -use rustc_target::spec::{RelocModel, RelroLevel, SanitizerSet, SplitDebuginfo}; +use rustc_target::spec::{ + Cc, LinkOutputKind, LinkSelfContainedComponents, LinkSelfContainedDefault, LinkerFeatures, + LinkerFlavor, LinkerFlavorCli, Lld, PanicStrategy, RelocModel, RelroLevel, SanitizerSet, + SplitDebuginfo, +}; +use tempfile::Builder as TempFileBuilder; +use tracing::{debug, info, warn}; use super::archive::{ArchiveBuilder, ArchiveBuilderBuilder}; use super::command::Command; @@ -39,21 +54,6 @@ use crate::{ errors, looks_like_rust_object_file, CodegenResults, CompiledModule, CrateInfo, NativeLib, }; -use cc::windows_registry; -use regex::Regex; -use tempfile::Builder as TempFileBuilder; - -use itertools::Itertools; -use std::collections::BTreeSet; -use std::ffi::OsString; -use std::fs::{read, File, OpenOptions}; -use std::io::{BufWriter, Write}; -use std::ops::Deref; -use std::path::{Path, PathBuf}; -use std::process::{ExitStatus, Output, Stdio}; -use std::{env, fmt, fs, io, mem, str}; -use tracing::{debug, info, warn}; - pub fn ensure_removed(dcx: DiagCtxtHandle<'_>, path: &Path) { if let Err(e) = fs::remove_file(path) { if e.kind() != io::ErrorKind::NotFound { diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs index dd134ebbe6b..febeb7093a3 100644 --- a/compiler/rustc_codegen_ssa/src/back/linker.rs +++ b/compiler/rustc_codegen_ssa/src/back/linker.rs @@ -1,8 +1,3 @@ -use super::command::Command; -use super::symbol_export; -use crate::errors; -use rustc_span::symbol::sym; - use std::ffi::{OsStr, OsString}; use std::fs::{self, File}; use std::io::prelude::*; @@ -10,6 +5,7 @@ use std::io::{self, BufWriter}; use std::path::{Path, PathBuf}; use std::{env, iter, mem, str}; +use cc::windows_registry; use rustc_hir::def_id::{CrateNum, LOCAL_CRATE}; use rustc_metadata::find_native_static_library; use rustc_middle::bug; @@ -19,11 +15,14 @@ use rustc_middle::middle::exported_symbols::{ExportedSymbol, SymbolExportInfo, S use rustc_middle::ty::TyCtxt; use rustc_session::config::{self, CrateType, DebugInfo, LinkerPluginLto, Lto, OptLevel, Strip}; use rustc_session::Session; +use rustc_span::symbol::sym; use rustc_target::spec::{Cc, LinkOutputKind, LinkerFlavor, Lld}; - -use cc::windows_registry; use tracing::{debug, warn}; +use super::command::Command; +use super::symbol_export; +use crate::errors; + /// Disables non-English messages from localized linkers. /// Such messages may cause issues with text encoding on Windows (#35785) /// and prevent inspection of linker output in case of errors, which we occasionally do. diff --git a/compiler/rustc_codegen_ssa/src/back/lto.rs b/compiler/rustc_codegen_ssa/src/back/lto.rs index 5291cad148e..8b6f6b5a220 100644 --- a/compiler/rustc_codegen_ssa/src/back/lto.rs +++ b/compiler/rustc_codegen_ssa/src/back/lto.rs @@ -1,12 +1,12 @@ -use super::write::CodegenContext; -use crate::traits::*; -use crate::ModuleCodegen; +use std::ffi::CString; +use std::sync::Arc; use rustc_data_structures::memmap::Mmap; use rustc_errors::FatalError; -use std::ffi::CString; -use std::sync::Arc; +use super::write::CodegenContext; +use crate::traits::*; +use crate::ModuleCodegen; pub struct ThinModule<B: WriteBackendMethods> { pub shared: Arc<ThinShared<B>>, diff --git a/compiler/rustc_codegen_ssa/src/back/metadata.rs b/compiler/rustc_codegen_ssa/src/back/metadata.rs index 31a03a3c94a..19394029c94 100644 --- a/compiler/rustc_codegen_ssa/src/back/metadata.rs +++ b/compiler/rustc_codegen_ssa/src/back/metadata.rs @@ -10,7 +10,6 @@ use object::{ elf, pe, xcoff, Architecture, BinaryFormat, Endianness, FileFlags, Object, ObjectSection, ObjectSymbol, SectionFlags, SectionKind, SubArchitecture, SymbolFlags, SymbolKind, SymbolScope, }; - use rustc_data_structures::memmap::Mmap; use rustc_data_structures::owned_slice::{try_slice_owned, OwnedSlice}; use rustc_metadata::creader::MetadataLoader; diff --git a/compiler/rustc_codegen_ssa/src/back/rpath.rs b/compiler/rustc_codegen_ssa/src/back/rpath.rs index 82070d4453b..42f8c3114ff 100644 --- a/compiler/rustc_codegen_ssa/src/back/rpath.rs +++ b/compiler/rustc_codegen_ssa/src/back/rpath.rs @@ -1,8 +1,9 @@ +use std::ffi::OsString; +use std::path::{Path, PathBuf}; + use pathdiff::diff_paths; use rustc_data_structures::fx::FxHashSet; use rustc_fs_util::try_canonicalize; -use std::ffi::OsString; -use std::path::{Path, PathBuf}; use tracing::debug; pub struct RPathConfig<'a> { diff --git a/compiler/rustc_codegen_ssa/src/back/rpath/tests.rs b/compiler/rustc_codegen_ssa/src/back/rpath/tests.rs index c620e92db1f..0de0b8a52b1 100644 --- a/compiler/rustc_codegen_ssa/src/back/rpath/tests.rs +++ b/compiler/rustc_codegen_ssa/src/back/rpath/tests.rs @@ -1,8 +1,8 @@ -use super::RPathConfig; -use super::{get_rpath_relative_to_output, minimize_rpaths, rpaths_to_flags}; use std::ffi::OsString; use std::path::{Path, PathBuf}; +use super::{get_rpath_relative_to_output, minimize_rpaths, rpaths_to_flags, RPathConfig}; + #[test] fn test_rpaths_to_flags() { let flags = rpaths_to_flags(vec!["path1".into(), "path2".into()]); diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs index b7ad09b055a..d2f11d48140 100644 --- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs +++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs @@ -1,5 +1,3 @@ -use crate::base::allocator_kind_for_codegen; - use std::collections::hash_map::Entry::*; use rustc_ast::expand::allocator::{ALLOCATOR_METHODS, NO_ALLOC_SHIM_IS_UNSTABLE}; @@ -12,14 +10,14 @@ use rustc_middle::middle::exported_symbols::{ metadata_symbol_name, ExportedSymbol, SymbolExportInfo, SymbolExportKind, SymbolExportLevel, }; use rustc_middle::query::LocalCrate; -use rustc_middle::ty::Instance; -use rustc_middle::ty::{self, SymbolName, TyCtxt}; -use rustc_middle::ty::{GenericArgKind, GenericArgsRef}; +use rustc_middle::ty::{self, GenericArgKind, GenericArgsRef, Instance, SymbolName, TyCtxt}; use rustc_middle::util::Providers; use rustc_session::config::{CrateType, OomStrategy}; use rustc_target::spec::{SanitizerSet, TlsModel}; use tracing::debug; +use crate::base::allocator_kind_for_codegen; + pub fn threshold(tcx: TyCtxt<'_>) -> SymbolExportLevel { crates_export_threshold(tcx.crate_types()) } diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index 56e94529bc1..bea12747a51 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -1,12 +1,10 @@ -use super::link::{self, ensure_removed}; -use super::lto::{self, SerializedModule}; -use super::symbol_export::symbol_name_for_instance_in_crate; +use std::any::Any; +use std::marker::PhantomData; +use std::path::{Path, PathBuf}; +use std::sync::mpsc::{channel, Receiver, Sender}; +use std::sync::Arc; +use std::{fs, io, mem, str, thread}; -use crate::errors; -use crate::traits::*; -use crate::{ - CachedModuleCodegen, CodegenResults, CompiledModule, CrateInfo, ModuleCodegen, ModuleKind, -}; use jobserver::{Acquired, Client}; use rustc_ast::attr; use rustc_data_structures::fx::{FxHashMap, FxIndexMap}; @@ -30,26 +28,25 @@ use rustc_middle::bug; use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; use rustc_middle::middle::exported_symbols::SymbolExportInfo; use rustc_middle::ty::TyCtxt; -use rustc_session::config::{self, CrateType, Lto, OutFileName, OutputFilenames, OutputType}; -use rustc_session::config::{Passes, SwitchWithOptPath}; +use rustc_session::config::{ + self, CrateType, Lto, OutFileName, OutputFilenames, OutputType, Passes, SwitchWithOptPath, +}; use rustc_session::Session; use rustc_span::source_map::SourceMap; use rustc_span::symbol::sym; use rustc_span::{BytePos, FileName, InnerSpan, Pos, Span}; use rustc_target::spec::{MergeFunctions, SanitizerSet}; +use tracing::debug; +use super::link::{self, ensure_removed}; +use super::lto::{self, SerializedModule}; +use super::symbol_export::symbol_name_for_instance_in_crate; use crate::errors::ErrorCreatingRemarkDir; -use std::any::Any; -use std::fs; -use std::io; -use std::marker::PhantomData; -use std::mem; -use std::path::{Path, PathBuf}; -use std::str; -use std::sync::mpsc::{channel, Receiver, Sender}; -use std::sync::Arc; -use std::thread; -use tracing::debug; +use crate::traits::*; +use crate::{ + errors, CachedModuleCodegen, CodegenResults, CompiledModule, CrateInfo, ModuleCodegen, + ModuleKind, +}; const PRE_LTO_BC_EXT: &str = "pre-lto.bc"; |
