Use more Self keywords instead of repeating the type name.
This commit is contained in:
@@ -43,12 +43,8 @@ impl<'a> MemoryCodeSink<'a> {
|
||||
///
|
||||
/// This function is unsafe since `MemoryCodeSink` does not perform bounds checking on the
|
||||
/// memory buffer, and it can't guarantee that the `data` pointer is valid.
|
||||
pub unsafe fn new<'sink>(
|
||||
data: *mut u8,
|
||||
relocs: &'sink mut RelocSink,
|
||||
traps: &'sink mut TrapSink,
|
||||
) -> MemoryCodeSink<'sink> {
|
||||
MemoryCodeSink {
|
||||
pub unsafe fn new(data: *mut u8, relocs: &'a mut RelocSink, traps: &'a mut TrapSink) -> Self {
|
||||
Self {
|
||||
data,
|
||||
offset: 0,
|
||||
code_size: 0,
|
||||
|
||||
@@ -15,8 +15,8 @@ pub struct CFGPrinter<'a> {
|
||||
/// A utility for pretty-printing the CFG of a `Function`.
|
||||
impl<'a> CFGPrinter<'a> {
|
||||
/// Create a new CFGPrinter.
|
||||
pub fn new(func: &'a Function) -> CFGPrinter<'a> {
|
||||
CFGPrinter {
|
||||
pub fn new(func: &'a Function) -> Self {
|
||||
Self {
|
||||
func,
|
||||
cfg: ControlFlowGraph::with_function(func),
|
||||
}
|
||||
|
||||
@@ -580,8 +580,8 @@ pub struct FuncCursor<'f> {
|
||||
|
||||
impl<'f> FuncCursor<'f> {
|
||||
/// Create a new `FuncCursor` pointing nowhere.
|
||||
pub fn new(func: &'f mut ir::Function) -> FuncCursor<'f> {
|
||||
FuncCursor {
|
||||
pub fn new(func: &'f mut ir::Function) -> Self {
|
||||
Self {
|
||||
pos: CursorPosition::Nowhere,
|
||||
srcloc: Default::default(),
|
||||
func,
|
||||
@@ -662,8 +662,8 @@ pub struct EncCursor<'f> {
|
||||
|
||||
impl<'f> EncCursor<'f> {
|
||||
/// Create a new `EncCursor` pointing nowhere.
|
||||
pub fn new(func: &'f mut ir::Function, isa: &'f TargetIsa) -> EncCursor<'f> {
|
||||
EncCursor {
|
||||
pub fn new(func: &'f mut ir::Function, isa: &'f TargetIsa) -> Self {
|
||||
Self {
|
||||
pos: CursorPosition::Nowhere,
|
||||
srcloc: Default::default(),
|
||||
built_inst: None,
|
||||
|
||||
@@ -74,8 +74,8 @@ pub struct InsertBuilder<'f, IIB: InstInserterBase<'f>> {
|
||||
impl<'f, IIB: InstInserterBase<'f>> InsertBuilder<'f, IIB> {
|
||||
/// Create a new builder which inserts instructions at `pos`.
|
||||
/// The `dfg` and `pos.layout` references should be from the same `Function`.
|
||||
pub fn new(inserter: IIB) -> InsertBuilder<'f, IIB> {
|
||||
InsertBuilder {
|
||||
pub fn new(inserter: IIB) -> Self {
|
||||
Self {
|
||||
inserter,
|
||||
unused: PhantomData,
|
||||
}
|
||||
@@ -185,8 +185,8 @@ pub struct ReplaceBuilder<'f> {
|
||||
|
||||
impl<'f> ReplaceBuilder<'f> {
|
||||
/// Create a `ReplaceBuilder` that will overwrite `inst`.
|
||||
pub fn new(dfg: &'f mut DataFlowGraph, inst: Inst) -> ReplaceBuilder {
|
||||
ReplaceBuilder { dfg, inst }
|
||||
pub fn new(dfg: &'f mut DataFlowGraph, inst: Inst) -> Self {
|
||||
Self { dfg, inst }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -782,8 +782,8 @@ mod tests {
|
||||
impl<'f> LayoutCursor<'f> {
|
||||
/// Create a new `LayoutCursor` for `layout`.
|
||||
/// The cursor holds a mutable reference to `layout` for its entire lifetime.
|
||||
pub fn new(layout: &'f mut Layout) -> LayoutCursor<'f> {
|
||||
LayoutCursor {
|
||||
pub fn new(layout: &'f mut Layout) -> Self {
|
||||
Self {
|
||||
layout,
|
||||
pos: CursorPosition::Nowhere,
|
||||
}
|
||||
|
||||
@@ -188,11 +188,8 @@ pub struct LiveRangeContext<'a, PO: 'a + ProgramOrder> {
|
||||
|
||||
impl<'a, PO: ProgramOrder> LiveRangeContext<'a, PO> {
|
||||
/// Make a new context.
|
||||
pub fn new(
|
||||
order: &'a PO,
|
||||
forest: &'a bforest::MapForest<Ebb, Inst>,
|
||||
) -> LiveRangeContext<'a, PO> {
|
||||
LiveRangeContext { order, forest }
|
||||
pub fn new(order: &'a PO, forest: &'a bforest::MapForest<Ebb, Inst>) -> Self {
|
||||
Self { order, forest }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ impl<'a> PredicateView<'a> {
|
||||
/// Create a new view of a precomputed predicate vector.
|
||||
///
|
||||
/// See the `predicate_view()` method on the various `Flags` types defined for each ISA.
|
||||
pub fn new(bits: &'a [u8]) -> PredicateView {
|
||||
pub fn new(bits: &'a [u8]) -> Self {
|
||||
PredicateView(bits)
|
||||
}
|
||||
|
||||
|
||||
@@ -311,10 +311,10 @@ struct Verifier<'a> {
|
||||
}
|
||||
|
||||
impl<'a> Verifier<'a> {
|
||||
pub fn new(func: &'a Function, fisa: FlagsOrIsa<'a>) -> Verifier<'a> {
|
||||
pub fn new(func: &'a Function, fisa: FlagsOrIsa<'a>) -> Self {
|
||||
let expected_cfg = ControlFlowGraph::with_function(func);
|
||||
let expected_domtree = DominatorTree::with_function(func, &expected_cfg);
|
||||
Verifier {
|
||||
Self {
|
||||
func,
|
||||
expected_cfg,
|
||||
expected_domtree,
|
||||
|
||||
Reference in New Issue
Block a user