Use Self instead of repeating the type name.

This commit is contained in:
Dan Gohman
2017-11-08 10:40:47 -08:00
parent b7f979a8be
commit 3ab4349c1b
41 changed files with 105 additions and 105 deletions

View File

@@ -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() }
}
}

View File

@@ -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
}

View File

@@ -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))
}

View File

@@ -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()
}
}

View File

@@ -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,
}

View File

@@ -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,

View File

@@ -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.

View File

@@ -33,7 +33,7 @@ impl SourceLoc {
}
impl Default for SourceLoc {
fn default() -> SourceLoc {
fn default() -> Self {
SourceLoc(!0)
}
}

View File

@@ -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(),

View File

@@ -321,7 +321,7 @@ impl Debug for Type {
}
impl Default for Type {
fn default() -> Type {
fn default() -> Self {
VOID
}
}