diff --git a/cranelift/src/filetest/binemit.rs b/cranelift/src/filetest/binemit.rs index cc8dcad0b7..9c19533c64 100644 --- a/cranelift/src/filetest/binemit.rs +++ b/cranelift/src/filetest/binemit.rs @@ -35,8 +35,8 @@ struct TextSink { impl TextSink { /// Create a new empty TextSink. - pub fn new(isa: &TargetIsa) -> TextSink { - TextSink { + pub fn new(isa: &TargetIsa) -> Self { + Self { rnames: isa.reloc_names(), offset: 0, text: String::new(), diff --git a/cranelift/src/filetest/concurrent.rs b/cranelift/src/filetest/concurrent.rs index 430fb54142..4f7cca6935 100644 --- a/cranelift/src/filetest/concurrent.rs +++ b/cranelift/src/filetest/concurrent.rs @@ -38,7 +38,7 @@ pub struct ConcurrentRunner { impl ConcurrentRunner { /// Create a new `ConcurrentRunner` with threads spun up. - pub fn new() -> ConcurrentRunner { + pub fn new() -> Self { let (request_tx, request_rx) = channel(); let request_mutex = Arc::new(Mutex::new(request_rx)); let (reply_tx, reply_rx) = channel(); @@ -51,7 +51,7 @@ impl ConcurrentRunner { }) .collect(); - ConcurrentRunner { + Self { request_tx: Some(request_tx), reply_rx, handles, diff --git a/cranelift/src/filetest/runner.rs b/cranelift/src/filetest/runner.rs index 6425482084..8e0f7721a7 100644 --- a/cranelift/src/filetest/runner.rs +++ b/cranelift/src/filetest/runner.rs @@ -81,8 +81,8 @@ pub struct TestRunner { impl TestRunner { /// Create a new blank TrstRunner. - pub fn new(verbose: bool) -> TestRunner { - TestRunner { + pub fn new(verbose: bool) -> Self { + Self { verbose, dir_stack: Vec::new(), tests: Vec::new(), diff --git a/lib/cretonne/src/bitset.rs b/lib/cretonne/src/bitset.rs index 2ed4efe15b..62e0286bb3 100644 --- a/lib/cretonne/src/bitset.rs +++ b/lib/cretonne/src/bitset.rs @@ -61,7 +61,7 @@ where } /// Construct a BitSet with the half-open range [lo,hi) filled in - pub fn from_range(lo: u8, hi: u8) -> BitSet { + pub fn from_range(lo: u8, hi: u8) -> Self { assert!(lo <= hi); assert!((hi as usize) <= Self::bits()); let one: T = T::from(1); diff --git a/lib/cretonne/src/context.rs b/lib/cretonne/src/context.rs index ca2cd43854..6f7f7a65c1 100644 --- a/lib/cretonne/src/context.rs +++ b/lib/cretonne/src/context.rs @@ -47,8 +47,8 @@ impl Context { /// /// The returned instance should be reused for compiling multiple functions in order to avoid /// needless allocator thrashing. - pub fn new() -> Context { - Context { + pub fn new() -> Self { + Self { func: Function::new(), cfg: ControlFlowGraph::new(), domtree: DominatorTree::new(), diff --git a/lib/cretonne/src/dominator_tree.rs b/lib/cretonne/src/dominator_tree.rs index 4a3965540e..2c2fd1b48c 100644 --- a/lib/cretonne/src/dominator_tree.rs +++ b/lib/cretonne/src/dominator_tree.rs @@ -204,8 +204,8 @@ impl DominatorTree { impl DominatorTree { /// Allocate a new blank dominator tree. Use `compute` to compute the dominator tree for a /// function. - pub fn new() -> DominatorTree { - DominatorTree { + pub fn new() -> Self { + Self { nodes: EntityMap::new(), postorder: Vec::new(), stack: Vec::new(), @@ -214,8 +214,8 @@ impl DominatorTree { } /// Allocate and compute a dominator tree. - pub fn with_function(func: &Function, cfg: &ControlFlowGraph) -> DominatorTree { - let mut domtree = DominatorTree::new(); + pub fn with_function(func: &Function, cfg: &ControlFlowGraph) -> Self { + let mut domtree = Self::new(); domtree.compute(func, cfg); domtree } diff --git a/lib/cretonne/src/entity/keys.rs b/lib/cretonne/src/entity/keys.rs index 795e896a00..3ad5b660b6 100644 --- a/lib/cretonne/src/entity/keys.rs +++ b/lib/cretonne/src/entity/keys.rs @@ -12,8 +12,8 @@ pub struct Keys { impl Keys { /// Create a `Keys` iterator that visits `count` entities starting from 0. - pub fn new(count: usize) -> Keys { - Keys { + pub fn new(count: usize) -> Self { + Self { pos: 0, rev_pos: count, unused: PhantomData, diff --git a/lib/cretonne/src/entity/list.rs b/lib/cretonne/src/entity/list.rs index 03c66a8ec0..c9bb5b1a69 100644 --- a/lib/cretonne/src/entity/list.rs +++ b/lib/cretonne/src/entity/list.rs @@ -68,7 +68,7 @@ pub struct EntityList { /// Create an empty list. impl Default for EntityList { fn default() -> Self { - EntityList { + Self { index: 0, unused: PhantomData, } @@ -82,7 +82,7 @@ impl Hash for EntityList { } impl PartialEq for EntityList { - fn eq(&self, _: &EntityList) -> bool { + fn eq(&self, _: &Self) -> bool { panic!("eq called on EntityList"); } } @@ -121,8 +121,8 @@ fn is_sclass_min_length(len: usize) -> bool { impl ListPool { /// Create a new list pool. - pub fn new() -> ListPool { - ListPool { + pub fn new() -> Self { + Self { data: Vec::new(), free: Vec::new(), } @@ -311,7 +311,7 @@ impl EntityList { /// Take all elements from this list and return them as a new list. Leave this list empty. /// /// This is the equivalent of `Option::take()`. - pub fn take(&mut self) -> EntityList { + pub fn take(&mut self) -> Self { mem::replace(self, Default::default()) } diff --git a/lib/cretonne/src/entity/map.rs b/lib/cretonne/src/entity/map.rs index 200aa464c3..9622f93485 100644 --- a/lib/cretonne/src/entity/map.rs +++ b/lib/cretonne/src/entity/map.rs @@ -34,7 +34,7 @@ where where V: Default, { - EntityMap { + Self { elems: Vec::new(), default: Default::default(), unused: PhantomData, @@ -45,7 +45,7 @@ where /// /// This constructor does not require V to implement Default. pub fn with_default(default: V) -> Self { - EntityMap { + Self { elems: Vec::new(), default: default, unused: PhantomData, diff --git a/lib/cretonne/src/entity/primary.rs b/lib/cretonne/src/entity/primary.rs index c0347304aa..137320f3e5 100644 --- a/lib/cretonne/src/entity/primary.rs +++ b/lib/cretonne/src/entity/primary.rs @@ -27,7 +27,7 @@ where { /// Create a new empty map. pub fn new() -> Self { - PrimaryMap { + Self { elems: Vec::new(), unused: PhantomData, } diff --git a/lib/cretonne/src/entity/set.rs b/lib/cretonne/src/entity/set.rs index b1c351b650..8b5d32e790 100644 --- a/lib/cretonne/src/entity/set.rs +++ b/lib/cretonne/src/entity/set.rs @@ -24,7 +24,7 @@ where { /// Create a new empty set. pub fn new() -> Self { - EntitySet { + Self { elems: Vec::new(), len: 0, unused: PhantomData, diff --git a/lib/cretonne/src/entity/sparse.rs b/lib/cretonne/src/entity/sparse.rs index 26be799afd..dacbf66031 100644 --- a/lib/cretonne/src/entity/sparse.rs +++ b/lib/cretonne/src/entity/sparse.rs @@ -66,7 +66,7 @@ where { /// Create a new empty mapping. pub fn new() -> Self { - SparseMap { + Self { sparse: EntityMap::new(), dense: Vec::new(), } @@ -215,7 +215,7 @@ impl SparseMapValue for T where T: EntityRef, { - fn key(&self) -> T { + fn key(&self) -> Self { *self } } diff --git a/lib/cretonne/src/flowgraph.rs b/lib/cretonne/src/flowgraph.rs index 67ff150196..bc6096ad9a 100644 --- a/lib/cretonne/src/flowgraph.rs +++ b/lib/cretonne/src/flowgraph.rs @@ -51,16 +51,16 @@ pub struct ControlFlowGraph { impl ControlFlowGraph { /// Allocate a new blank control flow graph. - pub fn new() -> ControlFlowGraph { - ControlFlowGraph { + pub fn new() -> Self { + Self { data: EntityMap::new(), valid: false, } } /// Allocate and compute the control flow graph for `func`. - pub fn with_function(func: &Function) -> ControlFlowGraph { - let mut cfg = ControlFlowGraph::new(); + pub fn with_function(func: &Function) -> Self { + let mut cfg = Self::new(); cfg.compute(func); cfg } diff --git a/lib/cretonne/src/ir/dfg.rs b/lib/cretonne/src/ir/dfg.rs index 83a32f7ff8..e2328e46dc 100644 --- a/lib/cretonne/src/ir/dfg.rs +++ b/lib/cretonne/src/ir/dfg.rs @@ -62,8 +62,8 @@ pub struct DataFlowGraph { impl DataFlowGraph { /// Create a new empty `DataFlowGraph`. - pub fn new() -> DataFlowGraph { - DataFlowGraph { + pub fn new() -> Self { + Self { insts: PrimaryMap::new(), results: EntityMap::new(), ebbs: PrimaryMap::new(), @@ -829,8 +829,8 @@ struct EbbData { } impl EbbData { - fn new() -> EbbData { - EbbData { params: ValueList::new() } + fn new() -> Self { + Self { params: ValueList::new() } } } diff --git a/lib/cretonne/src/ir/extfunc.rs b/lib/cretonne/src/ir/extfunc.rs index 4403b6ebef..b3c3a274e7 100644 --- a/lib/cretonne/src/ir/extfunc.rs +++ b/lib/cretonne/src/ir/extfunc.rs @@ -38,8 +38,8 @@ pub struct Signature { impl Signature { /// Create a new blank signature. - pub fn new(call_conv: CallConv) -> Signature { - Signature { + pub fn new(call_conv: CallConv) -> Self { + Self { params: Vec::new(), returns: Vec::new(), call_conv, @@ -138,8 +138,8 @@ pub struct AbiParam { impl AbiParam { /// Create a parameter with default flags. - pub fn new(vt: Type) -> AbiParam { - AbiParam { + pub fn new(vt: Type) -> Self { + Self { value_type: vt, extension: ArgumentExtension::None, purpose: ArgumentPurpose::Normal, @@ -148,8 +148,8 @@ impl AbiParam { } /// Create a special-purpose parameter that is not (yet) bound to a specific register. - pub fn special(vt: Type, purpose: ArgumentPurpose) -> AbiParam { - AbiParam { + pub fn special(vt: Type, purpose: ArgumentPurpose) -> Self { + Self { value_type: vt, extension: ArgumentExtension::None, purpose, @@ -158,8 +158,8 @@ impl AbiParam { } /// Create a parameter for a special-purpose register. - pub fn special_reg(vt: Type, purpose: ArgumentPurpose, regunit: RegUnit) -> AbiParam { - AbiParam { + pub fn special_reg(vt: Type, purpose: ArgumentPurpose, regunit: RegUnit) -> Self { + Self { value_type: vt, extension: ArgumentExtension::None, purpose, @@ -168,18 +168,18 @@ impl AbiParam { } /// Convert `self` to a parameter with the `uext` flag set. - pub fn uext(self) -> AbiParam { + pub fn uext(self) -> Self { debug_assert!(self.value_type.is_int(), "uext on {} arg", self.value_type); - AbiParam { + Self { extension: ArgumentExtension::Uext, ..self } } /// Convert `self` to a parameter type with the `sext` flag set. - pub fn sext(self) -> AbiParam { + pub fn sext(self) -> Self { debug_assert!(self.value_type.is_int(), "sext on {} arg", self.value_type); - AbiParam { + Self { extension: ArgumentExtension::Sext, ..self } diff --git a/lib/cretonne/src/ir/function.rs b/lib/cretonne/src/ir/function.rs index 4c348b6ce9..457b47a5e0 100644 --- a/lib/cretonne/src/ir/function.rs +++ b/lib/cretonne/src/ir/function.rs @@ -66,8 +66,8 @@ pub struct Function { impl Function { /// Create a function with the given name and signature. - pub fn with_name_signature(name: ExternalName, sig: Signature) -> Function { - Function { + pub fn with_name_signature(name: ExternalName, sig: Signature) -> Self { + Self { name, signature: sig, stack_slots: StackSlots::new(), @@ -99,7 +99,7 @@ impl Function { } /// Create a new empty, anonymous function with a native calling convention. - pub fn new() -> Function { + pub fn new() -> Self { Self::with_name_signature(ExternalName::default(), Signature::new(CallConv::Native)) } diff --git a/lib/cretonne/src/ir/instructions.rs b/lib/cretonne/src/ir/instructions.rs index 6c101d751e..0038fa42c4 100644 --- a/lib/cretonne/src/ir/instructions.rs +++ b/lib/cretonne/src/ir/instructions.rs @@ -262,7 +262,7 @@ pub struct VariableArgs(Vec); impl VariableArgs { /// Create an empty argument list. - pub fn new() -> VariableArgs { + pub fn new() -> Self { VariableArgs(Vec::new()) } @@ -314,8 +314,8 @@ impl Display for VariableArgs { } impl Default for VariableArgs { - fn default() -> VariableArgs { - VariableArgs::new() + fn default() -> Self { + Self::new() } } diff --git a/lib/cretonne/src/ir/jumptable.rs b/lib/cretonne/src/ir/jumptable.rs index a6cfad3346..2d09aab4da 100644 --- a/lib/cretonne/src/ir/jumptable.rs +++ b/lib/cretonne/src/ir/jumptable.rs @@ -24,16 +24,16 @@ pub struct JumpTableData { impl JumpTableData { /// Create a new empty jump table. - pub fn new() -> JumpTableData { - JumpTableData { + pub fn new() -> Self { + Self { table: Vec::new(), holes: 0, } } /// Create a new empty jump table with the specified capacity. - pub fn with_capacity(capacity: usize) -> JumpTableData { - JumpTableData { + pub fn with_capacity(capacity: usize) -> Self { + Self { table: Vec::with_capacity(capacity), holes: 0, } diff --git a/lib/cretonne/src/ir/layout.rs b/lib/cretonne/src/ir/layout.rs index 8bb61cb11f..551055394a 100644 --- a/lib/cretonne/src/ir/layout.rs +++ b/lib/cretonne/src/ir/layout.rs @@ -42,8 +42,8 @@ pub struct Layout { impl Layout { /// Create a new empty `Layout`. - pub fn new() -> Layout { - Layout { + pub fn new() -> Self { + Self { ebbs: EntityMap::new(), insts: EntityMap::new(), first_ebb: None, diff --git a/lib/cretonne/src/ir/memflags.rs b/lib/cretonne/src/ir/memflags.rs index fd836d2752..e87fb3c4ec 100644 --- a/lib/cretonne/src/ir/memflags.rs +++ b/lib/cretonne/src/ir/memflags.rs @@ -21,8 +21,8 @@ pub struct MemFlags { impl MemFlags { /// Create a new empty set of flags. - pub fn new() -> MemFlags { - MemFlags { bits: 0 } + pub fn new() -> Self { + Self { bits: 0 } } /// Read a flag bit. diff --git a/lib/cretonne/src/ir/sourceloc.rs b/lib/cretonne/src/ir/sourceloc.rs index 104bc541b6..ffcf0db943 100644 --- a/lib/cretonne/src/ir/sourceloc.rs +++ b/lib/cretonne/src/ir/sourceloc.rs @@ -33,7 +33,7 @@ impl SourceLoc { } impl Default for SourceLoc { - fn default() -> SourceLoc { + fn default() -> Self { SourceLoc(!0) } } diff --git a/lib/cretonne/src/ir/stackslot.rs b/lib/cretonne/src/ir/stackslot.rs index f46f91dd74..dc02f0df6b 100644 --- a/lib/cretonne/src/ir/stackslot.rs +++ b/lib/cretonne/src/ir/stackslot.rs @@ -172,8 +172,8 @@ pub struct StackSlots { /// Stack slot manager functions that behave mostly like an entity map. impl StackSlots { /// Create an empty stack slot manager. - pub fn new() -> StackSlots { - StackSlots { + pub fn new() -> Self { + Self { slots: PrimaryMap::new(), outgoing: Vec::new(), emergency: Vec::new(), diff --git a/lib/cretonne/src/ir/types.rs b/lib/cretonne/src/ir/types.rs index e0cdcd02ce..da502f9bf7 100644 --- a/lib/cretonne/src/ir/types.rs +++ b/lib/cretonne/src/ir/types.rs @@ -321,7 +321,7 @@ impl Debug for Type { } impl Default for Type { - fn default() -> Type { + fn default() -> Self { VOID } } diff --git a/lib/cretonne/src/isa/registers.rs b/lib/cretonne/src/isa/registers.rs index f21c946b99..55ec2bb8a8 100644 --- a/lib/cretonne/src/isa/registers.rs +++ b/lib/cretonne/src/isa/registers.rs @@ -214,7 +214,7 @@ impl fmt::Debug for RegClassData { /// Within an ISA, register classes are uniquely identified by their index. impl PartialEq for RegClassData { - fn eq(&self, other: &RegClassData) -> bool { + fn eq(&self, other: &Self) -> bool { self.index == other.index } } diff --git a/lib/cretonne/src/loop_analysis.rs b/lib/cretonne/src/loop_analysis.rs index c994ff3027..e6390aa100 100644 --- a/lib/cretonne/src/loop_analysis.rs +++ b/lib/cretonne/src/loop_analysis.rs @@ -42,8 +42,8 @@ impl LoopData { impl LoopAnalysis { /// Allocate a new blank loop analysis struct. Use `compute` to compute the loop analysis for /// a function. - pub fn new() -> LoopAnalysis { - LoopAnalysis { + pub fn new() -> Self { + Self { valid: false, loops: PrimaryMap::new(), ebb_loop_map: EntityMap::new(), diff --git a/lib/cretonne/src/regalloc/allocatable_set.rs b/lib/cretonne/src/regalloc/allocatable_set.rs index 355443affc..0e8e559cca 100644 --- a/lib/cretonne/src/regalloc/allocatable_set.rs +++ b/lib/cretonne/src/regalloc/allocatable_set.rs @@ -37,8 +37,8 @@ impl AllocatableSet { /// /// Note that this includes *all* registers. Query the `TargetIsa` object to get a set of /// allocatable registers where reserved registers have been filtered out. - pub fn new() -> AllocatableSet { - AllocatableSet { avail: [!0; 3] } + pub fn new() -> Self { + Self { avail: [!0; 3] } } /// Returns `true` if the specified register is available. diff --git a/lib/cretonne/src/regalloc/coalescing.rs b/lib/cretonne/src/regalloc/coalescing.rs index 28cde8c10c..cd54f2ece2 100644 --- a/lib/cretonne/src/regalloc/coalescing.rs +++ b/lib/cretonne/src/regalloc/coalescing.rs @@ -74,8 +74,8 @@ impl Node { impl DomForest { /// Create a new empty dominator forest. - pub fn new() -> DomForest { - DomForest { + pub fn new() -> Self { + Self { values: Vec::new(), stack: Vec::new(), } @@ -252,8 +252,8 @@ struct Context<'a> { impl Coalescing { /// Create a new coalescing pass. - pub fn new() -> Coalescing { - Coalescing { + pub fn new() -> Self { + Self { forest: DomForest::new(), values: Vec::new(), split_values: Vec::new(), diff --git a/lib/cretonne/src/regalloc/coloring.rs b/lib/cretonne/src/regalloc/coloring.rs index d8607e4bd1..ff5bc0ef69 100644 --- a/lib/cretonne/src/regalloc/coloring.rs +++ b/lib/cretonne/src/regalloc/coloring.rs @@ -101,8 +101,8 @@ struct Context<'a> { impl Coloring { /// Allocate scratch space data structures for the coloring pass. - pub fn new() -> Coloring { - Coloring { + pub fn new() -> Self { + Self { divert: RegDiversions::new(), solver: Solver::new(), } diff --git a/lib/cretonne/src/regalloc/context.rs b/lib/cretonne/src/regalloc/context.rs index 06d27ff325..a35ddb3484 100644 --- a/lib/cretonne/src/regalloc/context.rs +++ b/lib/cretonne/src/regalloc/context.rs @@ -36,8 +36,8 @@ impl Context { /// /// This context should be reused for multiple functions in order to avoid repeated memory /// allocations. - pub fn new() -> Context { - Context { + pub fn new() -> Self { + Self { liveness: Liveness::new(), virtregs: VirtRegs::new(), coalescing: Coalescing::new(), diff --git a/lib/cretonne/src/regalloc/diversion.rs b/lib/cretonne/src/regalloc/diversion.rs index c6d25f543e..588ad040a5 100644 --- a/lib/cretonne/src/regalloc/diversion.rs +++ b/lib/cretonne/src/regalloc/diversion.rs @@ -44,8 +44,8 @@ pub struct RegDiversions { impl RegDiversions { /// Create a new empty diversion tracker. - pub fn new() -> RegDiversions { - RegDiversions { current: Vec::new() } + pub fn new() -> Self { + Self { current: Vec::new() } } /// Clear the tracker, preparing for a new EBB. diff --git a/lib/cretonne/src/regalloc/live_value_tracker.rs b/lib/cretonne/src/regalloc/live_value_tracker.rs index 10fe9ff595..cb57683661 100644 --- a/lib/cretonne/src/regalloc/live_value_tracker.rs +++ b/lib/cretonne/src/regalloc/live_value_tracker.rs @@ -65,8 +65,8 @@ struct LiveValueVec { } impl LiveValueVec { - fn new() -> LiveValueVec { - LiveValueVec { + fn new() -> Self { + Self { values: Vec::new(), live_prefix: None, } @@ -124,8 +124,8 @@ impl LiveValueVec { impl LiveValueTracker { /// Create a new blank tracker. - pub fn new() -> LiveValueTracker { - LiveValueTracker { + pub fn new() -> Self { + Self { live: LiveValueVec::new(), idom_sets: HashMap::new(), idom_pool: ListPool::new(), diff --git a/lib/cretonne/src/regalloc/liveness.rs b/lib/cretonne/src/regalloc/liveness.rs index 0a449bd85c..e5face5ef4 100644 --- a/lib/cretonne/src/regalloc/liveness.rs +++ b/lib/cretonne/src/regalloc/liveness.rs @@ -299,8 +299,8 @@ impl Liveness { /// /// The memory allocated for this analysis can be reused for multiple functions. Use the /// `compute` method to actually runs the analysis for a function. - pub fn new() -> Liveness { - Liveness { + pub fn new() -> Self { + Self { ranges: LiveRangeSet::new(), worklist: Vec::new(), ebb_params: Vec::new(), diff --git a/lib/cretonne/src/regalloc/reload.rs b/lib/cretonne/src/regalloc/reload.rs index 97b849f3a9..9b0006b990 100644 --- a/lib/cretonne/src/regalloc/reload.rs +++ b/lib/cretonne/src/regalloc/reload.rs @@ -46,8 +46,8 @@ struct Context<'a> { impl Reload { /// Create a new blank reload pass. - pub fn new() -> Reload { - Reload { + pub fn new() -> Self { + Self { candidates: Vec::new(), reloads: SparseMap::new(), } diff --git a/lib/cretonne/src/regalloc/solver.rs b/lib/cretonne/src/regalloc/solver.rs index 69b7bd1dd3..a18599a127 100644 --- a/lib/cretonne/src/regalloc/solver.rs +++ b/lib/cretonne/src/regalloc/solver.rs @@ -502,8 +502,8 @@ pub struct Solver { /// Interface for programming the constraints into the solver. impl Solver { /// Create a new empty solver. - pub fn new() -> Solver { - Solver { + pub fn new() -> Self { + Self { assignments: SparseMap::new(), vars: Vec::new(), inputs_done: false, diff --git a/lib/cretonne/src/regalloc/spilling.rs b/lib/cretonne/src/regalloc/spilling.rs index 85d7b20b4a..65d2f2d076 100644 --- a/lib/cretonne/src/regalloc/spilling.rs +++ b/lib/cretonne/src/regalloc/spilling.rs @@ -63,8 +63,8 @@ struct Context<'a> { impl Spilling { /// Create a new spilling data structure. - pub fn new() -> Spilling { - Spilling { + pub fn new() -> Self { + Self { spills: Vec::new(), reg_uses: Vec::new(), } diff --git a/lib/cretonne/src/regalloc/virtregs.rs b/lib/cretonne/src/regalloc/virtregs.rs index 21a2a917d5..c2cb6c8ffe 100644 --- a/lib/cretonne/src/regalloc/virtregs.rs +++ b/lib/cretonne/src/regalloc/virtregs.rs @@ -45,8 +45,8 @@ pub struct VirtRegs { #[allow(dead_code)] impl VirtRegs { /// Create a new virtual register collection. - pub fn new() -> VirtRegs { - VirtRegs { + pub fn new() -> Self { + Self { pool: ListPool::new(), vregs: PrimaryMap::new(), value_vregs: EntityMap::new(), diff --git a/lib/cretonne/src/topo_order.rs b/lib/cretonne/src/topo_order.rs index db566ae7c8..d71dc63ccf 100644 --- a/lib/cretonne/src/topo_order.rs +++ b/lib/cretonne/src/topo_order.rs @@ -26,8 +26,8 @@ pub struct TopoOrder { impl TopoOrder { /// Create a new empty topological order. - pub fn new() -> TopoOrder { - TopoOrder { + pub fn new() -> Self { + Self { preferred: Vec::new(), next: 0, visited: SparseSet::new(), diff --git a/lib/filecheck/src/checker.rs b/lib/filecheck/src/checker.rs index bad8e4774e..b3a68fba4c 100644 --- a/lib/filecheck/src/checker.rs +++ b/lib/filecheck/src/checker.rs @@ -95,8 +95,8 @@ pub struct CheckerBuilder { impl CheckerBuilder { /// Create a new, blank `CheckerBuilder`. - pub fn new() -> CheckerBuilder { - CheckerBuilder { + pub fn new() -> Self { + Self { directives: Vec::new(), linerx: Regex::new(DIRECTIVE_RX).unwrap(), } @@ -146,8 +146,8 @@ pub struct Checker { } impl Checker { - fn new(directives: Vec) -> Checker { - Checker { directives: directives } + fn new(directives: Vec) -> Self { + Self { directives: directives } } /// An empty checker contains no directives, and will match any input string. diff --git a/lib/filecheck/src/pattern.rs b/lib/filecheck/src/pattern.rs index 7969bc00ec..934150dca7 100644 --- a/lib/filecheck/src/pattern.rs +++ b/lib/filecheck/src/pattern.rs @@ -54,8 +54,8 @@ impl Part { impl Pattern { /// Create a new blank pattern. Use the `FromStr` trait to generate Patterns with content. - fn new() -> Pattern { - Pattern { + fn new() -> Self { + Self { parts: Vec::new(), defs: Vec::new(), } diff --git a/lib/wasm/src/func_translator.rs b/lib/wasm/src/func_translator.rs index fd784a4491..57821c49c5 100644 --- a/lib/wasm/src/func_translator.rs +++ b/lib/wasm/src/func_translator.rs @@ -30,8 +30,8 @@ pub struct FuncTranslator { impl FuncTranslator { /// Create a new translator. - pub fn new() -> FuncTranslator { - FuncTranslator { + pub fn new() -> Self { + Self { il_builder: ILBuilder::new(), state: TranslationState::new(), } diff --git a/lib/wasm/src/state.rs b/lib/wasm/src/state.rs index 91737a370c..f9f76d2934 100644 --- a/lib/wasm/src/state.rs +++ b/lib/wasm/src/state.rs @@ -126,8 +126,8 @@ pub struct TranslationState { } impl TranslationState { - pub fn new() -> TranslationState { - TranslationState { + pub fn new() -> Self { + Self { stack: Vec::new(), control_stack: Vec::new(), phantom_unreachable_stack_depth: 0,