Skip to content

Commit

Permalink
Merge pull request #1393 from onur-ozkan/rustfmt-group-imports
Browse files Browse the repository at this point in the history
organize import sections with rustfmt `group_imports`
  • Loading branch information
bjorn3 authored Sep 14, 2023
2 parents 02e5f38 + e048674 commit 5c7a87c
Show file tree
Hide file tree
Showing 25 changed files with 62 additions and 89 deletions.
6 changes: 2 additions & 4 deletions src/abi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,17 @@ mod returning;

use std::borrow::Cow;

use cranelift_codegen::ir::{AbiParam, SigRef};
use cranelift_module::ModuleError;
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use rustc_middle::ty::layout::FnAbiOf;
use rustc_session::Session;
use rustc_target::abi::call::{Conv, FnAbi};
use rustc_target::spec::abi::Abi;

use cranelift_codegen::ir::{AbiParam, SigRef};

use self::pass_mode::*;
use crate::prelude::*;

pub(crate) use self::returning::codegen_return;
use crate::prelude::*;

fn clif_sig_from_fn_abi<'tcx>(
tcx: TyCtxt<'tcx>,
Expand Down
6 changes: 3 additions & 3 deletions src/abi/pass_mode.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
//! Argument passing
use crate::prelude::*;
use crate::value_and_place::assert_assignable;

use cranelift_codegen::ir::{ArgumentExtension, ArgumentPurpose};
use rustc_target::abi::call::{
ArgAbi, ArgAttributes, ArgExtension as RustcArgExtension, CastTarget, PassMode, Reg, RegKind,
};
use smallvec::{smallvec, SmallVec};

use crate::prelude::*;
use crate::value_and_place::assert_assignable;

pub(super) trait ArgAbiExt<'tcx> {
fn get_abi_param(&self, tcx: TyCtxt<'tcx>) -> SmallVec<[AbiParam; 2]>;
fn get_abi_return(&self, tcx: TyCtxt<'tcx>) -> (Option<AbiParam>, Vec<AbiParam>);
Expand Down
4 changes: 2 additions & 2 deletions src/abi/returning.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//! Return value handling
use crate::prelude::*;

use rustc_target::abi::call::{ArgAbi, PassMode};
use smallvec::{smallvec, SmallVec};

use crate::prelude::*;

/// Return a place where the return value of the current function can be written to. If necessary
/// this adds an extra parameter pointing to where the return value needs to be stored.
pub(super) fn codegen_return_param<'tcx>(
Expand Down
4 changes: 2 additions & 2 deletions src/allocator.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
//! Allocator shim
// Adapted from rustc

use crate::prelude::*;

use rustc_ast::expand::allocator::{
alloc_error_handler_name, default_fn_name, global_fn_name, AllocatorKind, AllocatorTy,
ALLOCATOR_METHODS, NO_ALLOC_SHIM_IS_UNSTABLE,
};
use rustc_codegen_ssa::base::allocator_kind_for_codegen;
use rustc_session::config::OomStrategy;

use crate::prelude::*;

/// Returns whether an allocator shim was created
pub(crate) fn codegen(
tcx: TyCtxt<'_>,
Expand Down
4 changes: 2 additions & 2 deletions src/analyze.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//! SSA analysis
use crate::prelude::*;

use rustc_index::IndexVec;
use rustc_middle::mir::StatementKind::*;
use rustc_middle::ty::Ty;

use crate::prelude::*;

#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub(crate) enum SsaKind {
NotSsa,
Expand Down
7 changes: 3 additions & 4 deletions src/base.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
//! Codegen of a single function
use cranelift_codegen::ir::UserFuncName;
use cranelift_codegen::CodegenError;
use cranelift_module::ModuleError;
use rustc_ast::InlineAsmOptions;
use rustc_index::IndexVec;
use rustc_middle::ty::adjustment::PointerCoercion;
use rustc_middle::ty::layout::FnAbiOf;
use rustc_middle::ty::print::with_no_trimmed_paths;

use cranelift_codegen::ir::UserFuncName;
use cranelift_codegen::CodegenError;
use cranelift_module::ModuleError;

use crate::constant::ConstantCx;
use crate::debuginfo::FunctionDebugContext;
use crate::prelude::*;
Expand Down
1 change: 0 additions & 1 deletion src/common.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use cranelift_codegen::isa::TargetFrontendConfig;
use gimli::write::FileId;

use rustc_data_structures::sync::Lrc;
use rustc_index::IndexVec;
use rustc_middle::ty::layout::{
Expand Down
3 changes: 1 addition & 2 deletions src/concurrency_limiter.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use std::sync::{Arc, Condvar, Mutex};

use rustc_session::Session;

use jobserver::HelperThread;
use rustc_session::Session;

// FIXME don't panic when a worker thread panics

Expand Down
3 changes: 1 addition & 2 deletions src/constant.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
//! Handling of `static`s, `const`s and promoted allocations
use cranelift_module::*;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use rustc_middle::mir::interpret::{
read_target_uint, AllocId, ConstAllocation, ConstValue, ErrorHandled, GlobalAlloc, Scalar,
};

use cranelift_module::*;

use crate::prelude::*;

pub(crate) struct ConstantCx {
Expand Down
3 changes: 1 addition & 2 deletions src/debuginfo/emit.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
//! Write the debuginfo into an object file.
use cranelift_object::ObjectProduct;
use rustc_data_structures::fx::FxHashMap;

use gimli::write::{Address, AttributeValue, EndianVec, Result, Sections, Writer};
use gimli::{RunTimeEndian, SectionId};
use rustc_data_structures::fx::FxHashMap;

use super::object::WriteDebugInfo;
use super::DebugContext;
Expand Down
16 changes: 7 additions & 9 deletions src/debuginfo/line_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@
use std::ffi::OsStr;
use std::path::{Component, Path};

use crate::debuginfo::FunctionDebugContext;
use crate::prelude::*;

use rustc_data_structures::sync::Lrc;
use rustc_span::{
FileName, Pos, SourceFile, SourceFileAndLine, SourceFileHash, SourceFileHashAlgorithm,
};

use cranelift_codegen::binemit::CodeOffset;
use cranelift_codegen::MachSrcLoc;

use gimli::write::{
Address, AttributeValue, FileId, FileInfo, LineProgram, LineString, LineStringTable,
};
use rustc_data_structures::sync::Lrc;
use rustc_span::{
FileName, Pos, SourceFile, SourceFileAndLine, SourceFileHash, SourceFileHashAlgorithm,
};

use crate::debuginfo::FunctionDebugContext;
use crate::prelude::*;

// OPTIMIZATION: It is cheaper to do this in one pass than using `.parent()` and `.file_name()`.
fn split_path_dir_and_file(path: &Path) -> (&Path, &OsStr) {
Expand Down
8 changes: 3 additions & 5 deletions src/debuginfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@ mod line_info;
mod object;
mod unwind;

use crate::prelude::*;

use cranelift_codegen::ir::Endianness;
use cranelift_codegen::isa::TargetIsa;

use gimli::write::{
Address, AttributeValue, DwarfUnit, FileId, LineProgram, LineString, Range, RangeList,
UnitEntryId,
};
use gimli::{Encoding, Format, LineEncoding, RunTimeEndian};
use indexmap::IndexSet;

pub(crate) use emit::{DebugReloc, DebugRelocName};
pub(crate) use unwind::UnwindContext;
pub(crate) use self::emit::{DebugReloc, DebugRelocName};
pub(crate) use self::unwind::UnwindContext;
use crate::prelude::*;

pub(crate) fn producer() -> String {
format!(
Expand Down
7 changes: 2 additions & 5 deletions src/debuginfo/object.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
use rustc_data_structures::fx::FxHashMap;

use cranelift_module::FuncId;
use cranelift_object::ObjectProduct;

use gimli::SectionId;
use object::write::{Relocation, StandardSegment};
use object::{RelocationEncoding, SectionKind};

use gimli::SectionId;
use rustc_data_structures::fx::FxHashMap;

use crate::debuginfo::{DebugReloc, DebugRelocName};

Expand Down
4 changes: 1 addition & 3 deletions src/debuginfo/unwind.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
//! Unwind info generation (`.eh_frame`)
use crate::prelude::*;

use cranelift_codegen::ir::Endianness;
use cranelift_codegen::isa::{unwind::UnwindInfo, TargetIsa};

use cranelift_object::ObjectProduct;
use gimli::write::{Address, CieId, EhFrame, FrameTable, Section};
use gimli::RunTimeEndian;

use super::object::WriteDebugInfo;
use crate::prelude::*;

pub(crate) struct UnwindContext {
endian: RunTimeEndian,
Expand Down
3 changes: 1 addition & 2 deletions src/driver/aot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::path::PathBuf;
use std::sync::Arc;
use std::thread::JoinHandle;

use cranelift_object::{ObjectBuilder, ObjectModule};
use rustc_codegen_ssa::back::metadata::create_compressed_metadata_file;
use rustc_codegen_ssa::{CodegenResults, CompiledModule, CrateInfo, ModuleKind};
use rustc_data_structures::profiling::SelfProfilerRef;
Expand All @@ -17,8 +18,6 @@ use rustc_session::cgu_reuse_tracker::CguReuse;
use rustc_session::config::{DebugInfo, OutputFilenames, OutputType};
use rustc_session::Session;

use cranelift_object::{ObjectBuilder, ObjectModule};

use crate::concurrency_limiter::{ConcurrencyLimiter, ConcurrencyLimiterToken};
use crate::global_asm::GlobalAsmConfig;
use crate::{prelude::*, BackendConfig};
Expand Down
3 changes: 1 addition & 2 deletions src/driver/jit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ use std::ffi::CString;
use std::os::raw::{c_char, c_int};
use std::sync::{mpsc, Mutex, OnceLock};

use cranelift_jit::{JITBuilder, JITModule};
use rustc_codegen_ssa::CrateInfo;
use rustc_middle::mir::mono::MonoItem;
use rustc_session::Session;
use rustc_span::Symbol;

use cranelift_jit::{JITBuilder, JITModule};

use crate::{prelude::*, BackendConfig};
use crate::{CodegenCx, CodegenMode};

Expand Down
4 changes: 2 additions & 2 deletions src/inline_asm.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
//! Codegen of `asm!` invocations.
use crate::prelude::*;

use std::fmt::Write;

use rustc_ast::ast::{InlineAsmOptions, InlineAsmTemplatePiece};
use rustc_middle::mir::InlineAsmOperand;
use rustc_span::sym;
use rustc_target::asm::*;

use crate::prelude::*;

enum CInlineAsmOperand<'tcx> {
In {
reg: InlineAsmRegOrRegClass,
Expand Down
4 changes: 2 additions & 2 deletions src/intrinsics/llvm.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//! Emulate LLVM intrinsics
use rustc_middle::ty::GenericArgsRef;

use crate::intrinsics::*;
use crate::prelude::*;

use rustc_middle::ty::GenericArgsRef;

pub(crate) fn codegen_llvm_intrinsic_call<'tcx>(
fx: &mut FunctionCx<'_, '_, 'tcx>,
intrinsic: &str,
Expand Down
4 changes: 2 additions & 2 deletions src/intrinsics/llvm_aarch64.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//! Emulate AArch64 LLVM intrinsics
use rustc_middle::ty::GenericArgsRef;

use crate::intrinsics::*;
use crate::prelude::*;

use rustc_middle::ty::GenericArgsRef;

pub(crate) fn codegen_aarch64_llvm_intrinsic_call<'tcx>(
fx: &mut FunctionCx<'_, '_, 'tcx>,
intrinsic: &str,
Expand Down
4 changes: 2 additions & 2 deletions src/intrinsics/llvm_x86.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//! Emulate x86 LLVM intrinsics
use rustc_middle::ty::GenericArgsRef;

use crate::intrinsics::*;
use crate::prelude::*;

use rustc_middle::ty::GenericArgsRef;

pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>(
fx: &mut FunctionCx<'_, '_, 'tcx>,
intrinsic: &str,
Expand Down
7 changes: 3 additions & 4 deletions src/intrinsics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,16 @@ mod llvm_aarch64;
mod llvm_x86;
mod simd;

pub(crate) use cpuid::codegen_cpuid_call;
pub(crate) use llvm::codegen_llvm_intrinsic_call;

use cranelift_codegen::ir::AtomicRmwOp;
use rustc_middle::ty;
use rustc_middle::ty::layout::{HasParamEnv, ValidityRequirement};
use rustc_middle::ty::print::{with_no_trimmed_paths, with_no_visible_paths};
use rustc_middle::ty::GenericArgsRef;
use rustc_span::symbol::{kw, sym, Symbol};

pub(crate) use self::cpuid::codegen_cpuid_call;
pub(crate) use self::llvm::codegen_llvm_intrinsic_call;
use crate::prelude::*;
use cranelift_codegen::ir::AtomicRmwOp;

fn bug_on_incorrect_arg_count(intrinsic: impl std::fmt::Display) -> ! {
bug!("wrong number of args for intrinsic {}", intrinsic);
Expand Down
Loading

0 comments on commit 5c7a87c

Please sign in to comment.