Upgrade to Rust 1.17.

- Remove some uses of 'static in const and static globals that are no
  longer needed.
- Use the new struct initialization shorthand.
This commit is contained in:
Jakob Stoklund Olesen
2017-04-27 12:28:18 -07:00
parent eaf1ed09fc
commit ee5f035e31
31 changed files with 118 additions and 153 deletions

View File

@@ -56,7 +56,7 @@ impl<'c, 'fc, 'fd> InsertBuilder<'c, 'fc, 'fd> {
pub fn new(dfg: &'fd mut DataFlowGraph,
pos: &'c mut Cursor<'fc>)
-> InsertBuilder<'c, 'fc, 'fd> {
InsertBuilder { dfg: dfg, pos: pos }
InsertBuilder { dfg, pos }
}
/// Reuse result values in `reuse`.
@@ -72,7 +72,7 @@ impl<'c, 'fc, 'fd> InsertBuilder<'c, 'fc, 'fd> {
InsertReuseBuilder {
dfg: self.dfg,
pos: self.pos,
reuse: reuse,
reuse,
}
}
@@ -154,10 +154,7 @@ 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: dfg,
inst: inst,
}
ReplaceBuilder { dfg, inst }
}
}

View File

@@ -240,10 +240,7 @@ impl DataFlowGraph {
self.value_type(dest),
ty);
self.values[dest] = ValueData::Alias {
ty: ty,
original: original,
};
self.values[dest] = ValueData::Alias { ty, original };
}
/// Create a new value alias.
@@ -252,10 +249,7 @@ impl DataFlowGraph {
pub fn make_value_alias(&mut self, src: Value) -> Value {
let ty = self.value_type(src);
let data = ValueData::Alias {
ty: ty,
original: src,
};
let data = ValueData::Alias { ty, original: src };
self.make_value(data)
}
}
@@ -462,9 +456,9 @@ impl DataFlowGraph {
assert!(num <= u16::MAX as usize, "Too many result values");
let ty = self.value_type(res);
self.values[res] = ValueData::Inst {
ty: ty,
ty,
num: num as u16,
inst: inst,
inst,
};
}
@@ -474,8 +468,8 @@ impl DataFlowGraph {
let num = self.results[inst].push(res, &mut self.value_lists);
assert!(num <= u16::MAX as usize, "Too many result values");
self.make_value(ValueData::Inst {
ty: ty,
inst: inst,
ty,
inst,
num: num as u16,
})
}
@@ -594,9 +588,9 @@ impl DataFlowGraph {
let num = self.ebbs[ebb].args.push(arg, &mut self.value_lists);
assert!(num <= u16::MAX as usize, "Too many arguments to EBB");
self.make_value(ValueData::Arg {
ty: ty,
ty,
num: num as u16,
ebb: ebb,
ebb,
})
}
@@ -611,9 +605,9 @@ impl DataFlowGraph {
assert!(num <= u16::MAX as usize, "Too many arguments to EBB");
let ty = self.value_type(arg);
self.values[arg] = ValueData::Arg {
ty: ty,
ty,
num: num as u16,
ebb: ebb,
ebb,
};
}
@@ -635,8 +629,8 @@ impl DataFlowGraph {
};
let new_arg = self.make_value(ValueData::Arg {
ty: new_type,
num: num,
ebb: ebb,
num,
ebb,
});
self.ebbs[ebb].args.as_mut_slice(&mut self.value_lists)[num as usize] = new_arg;

View File

@@ -138,7 +138,7 @@ impl ArgumentType {
ArgumentType {
value_type: vt,
extension: ArgumentExtension::None,
purpose: purpose,
purpose,
location: ArgumentLoc::Reg(regunit),
}
}
@@ -239,7 +239,7 @@ pub enum ArgumentPurpose {
}
/// Text format names of the `ArgumentPurpose` variants.
static PURPOSE_NAMES: [&'static str; 5] = ["normal", "sret", "link", "fp", "csr"];
static PURPOSE_NAMES: [&str; 5] = ["normal", "sret", "link", "fp", "csr"];
impl fmt::Display for ArgumentPurpose {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {

View File

@@ -57,7 +57,7 @@ impl Function {
/// Create a function with the given name and signature.
pub fn with_name_signature(name: FunctionName, sig: Signature) -> Function {
Function {
name: name,
name,
signature: sig,
stack_slots: EntityMap::new(),
jump_tables: EntityMap::new(),

View File

@@ -647,7 +647,7 @@ impl<'f> Cursor<'f> {
/// The cursor holds a mutable reference to `layout` for its entire lifetime.
pub fn new(layout: &'f mut Layout) -> Cursor {
Cursor {
layout: layout,
layout,
pos: CursorPosition::Nowhere,
}
}

View File

@@ -7,7 +7,7 @@ enum FlagBit {
Aligned,
}
const NAMES: [&'static str; 2] = ["notrap", "aligned"];
const NAMES: [&str; 2] = ["notrap", "aligned"];
/// Flags for memory operations like load/store.
///

View File

@@ -39,7 +39,7 @@ fn isa_constructor(shared_flags: shared_settings::Flags,
};
Box::new(Isa {
isa_flags: settings::Flags::new(&shared_flags, builder),
shared_flags: shared_flags,
shared_flags,
cpumode: level1,
})
}

View File

@@ -33,7 +33,7 @@ fn isa_constructor(shared_flags: shared_settings::Flags,
-> Box<TargetIsa> {
Box::new(Isa {
isa_flags: settings::Flags::new(&shared_flags, builder),
shared_flags: shared_flags,
shared_flags,
})
}

View File

@@ -19,10 +19,7 @@ pub struct Encoding {
impl Encoding {
/// Create a new `Encoding` containing `(recipe, bits)`.
pub fn new(recipe: u16, bits: u16) -> Encoding {
Encoding {
recipe: recipe,
bits: bits,
}
Encoding { recipe, bits }
}
/// Get the recipe number in this encoding.

View File

@@ -39,7 +39,7 @@ fn isa_constructor(shared_flags: shared_settings::Flags,
};
Box::new(Isa {
isa_flags: settings::Flags::new(&shared_flags, builder),
shared_flags: shared_flags,
shared_flags,
cpumode: level1,
})
}

View File

@@ -220,7 +220,7 @@ impl RegInfo {
/// Make a temporary object that can display a register unit.
pub fn display_regunit(&self, regunit: RegUnit) -> DisplayRegUnit {
DisplayRegUnit {
regunit: regunit,
regunit,
reginfo: self,
}
}

View File

@@ -39,7 +39,7 @@ fn isa_constructor(shared_flags: shared_settings::Flags,
};
Box::new(Isa {
isa_flags: settings::Flags::new(&shared_flags, builder),
shared_flags: shared_flags,
shared_flags,
cpumode: level1,
})
}

View File

@@ -8,10 +8,7 @@ pub trait IteratorExtras: Iterator {
Self::Item: Clone
{
let elem = self.next();
AdjacentPairs {
iter: self,
elem: elem,
}
AdjacentPairs { iter: self, elem }
}
}

View File

@@ -261,11 +261,11 @@ fn add_repair(concat: Opcode,
hi_num: usize,
repairs: &mut Vec<Repair>) {
repairs.push(Repair {
concat: concat,
split_type: split_type,
ebb: ebb,
num: num,
hi_num: hi_num,
concat,
split_type,
ebb,
num,
hi_num,
});
}

View File

@@ -99,8 +99,8 @@ impl Coloring {
let mut ctx = Context {
reginfo: isa.register_info(),
encinfo: isa.encoding_info(),
domtree: domtree,
liveness: liveness,
domtree,
liveness,
usable_regs: isa.allocatable_registers(func),
};
ctx.run(self, func, tracker)

View File

@@ -70,9 +70,9 @@ impl LiveValueVec {
fn push(&mut self, value: Value, endpoint: Inst, affinity: Affinity) {
self.values
.push(LiveValue {
value: value,
endpoint: endpoint,
affinity: affinity,
value,
endpoint,
affinity,
});
}

View File

@@ -208,8 +208,8 @@ impl LiveRange {
/// The live range will be created as dead, but it can be extended with `extend_in_ebb()`.
pub fn new(value: Value, def: ProgramPoint, affinity: Affinity) -> LiveRange {
LiveRange {
value: value,
affinity: affinity,
value,
affinity,
def_begin: def,
def_end: def,
liveins: Vec::new(),

View File

@@ -27,10 +27,10 @@ pub fn verify_liveness(isa: &TargetIsa,
liveness: &Liveness)
-> Result {
let verifier = LivenessVerifier {
isa: isa,
func: func,
cfg: cfg,
liveness: liveness,
isa,
func,
cfg,
liveness,
};
verifier.check_ebbs()?;
verifier.check_insts()?;

View File

@@ -139,10 +139,10 @@ impl<'a> Verifier<'a> {
let cfg = ControlFlowGraph::with_function(func);
let domtree = DominatorTree::with_function(func, &cfg);
Verifier {
func: func,
cfg: cfg,
domtree: domtree,
isa: isa,
func,
cfg,
domtree,
isa,
}
}