Use Self instead of repeating the type name.
This commit is contained in:
@@ -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() }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
|
||||
@@ -262,7 +262,7 @@ pub struct VariableArgs(Vec<Value>);
|
||||
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -33,7 +33,7 @@ impl SourceLoc {
|
||||
}
|
||||
|
||||
impl Default for SourceLoc {
|
||||
fn default() -> SourceLoc {
|
||||
fn default() -> Self {
|
||||
SourceLoc(!0)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -321,7 +321,7 @@ impl Debug for Type {
|
||||
}
|
||||
|
||||
impl Default for Type {
|
||||
fn default() -> Type {
|
||||
fn default() -> Self {
|
||||
VOID
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user