[clippy] Fix a few clippy issues in lib/codegen/;
- don't generate "&& true" when generating instruction eq() fn; - use more Self; - use subsec_millis instead of subsec_nanos and divide; - coalesce two ifs;
This commit is contained in:
committed by
Dan Gohman
parent
0616a960d6
commit
bcc268a3cd
@@ -266,7 +266,7 @@ def gen_instruction_data_impl(fmt):
|
|||||||
n = '&InstructionData::' + f.name
|
n = '&InstructionData::' + f.name
|
||||||
members = ['opcode']
|
members = ['opcode']
|
||||||
if f.typevar_operand is None:
|
if f.typevar_operand is None:
|
||||||
args_eq = 'true'
|
args_eq = None
|
||||||
elif f.has_value_list:
|
elif f.has_value_list:
|
||||||
members.append('args')
|
members.append('args')
|
||||||
args_eq = 'args1.as_slice(pool) == ' \
|
args_eq = 'args1.as_slice(pool) == ' \
|
||||||
@@ -285,11 +285,12 @@ def gen_instruction_data_impl(fmt):
|
|||||||
for x in members)
|
for x in members)
|
||||||
with fmt.indented('({} {{ {} }}, {} {{ {} }}) => {{'
|
with fmt.indented('({} {{ {} }}, {} {{ {} }}) => {{'
|
||||||
.format(n, pat1, n, pat2), '}'):
|
.format(n, pat1, n, pat2), '}'):
|
||||||
fmt.line('opcode1 == opcode2 &&')
|
fmt.line('opcode1 == opcode2')
|
||||||
for field in f.imm_fields:
|
for field in f.imm_fields:
|
||||||
fmt.line('{}1 == {}2 &&'
|
fmt.line('&& {}1 == {}2'
|
||||||
.format(field.member, field.member))
|
.format(field.member, field.member))
|
||||||
fmt.line(args_eq)
|
if args_eq is not None:
|
||||||
|
fmt.line('&& {}'.format(args_eq))
|
||||||
fmt.line('_ => unsafe { '
|
fmt.line('_ => unsafe { '
|
||||||
'::std::hint::unreachable_unchecked() }')
|
'::std::hint::unreachable_unchecked() }')
|
||||||
fmt.line()
|
fmt.line()
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ const K: usize = 0x517cc1b727220a95;
|
|||||||
|
|
||||||
impl Default for FxHasher {
|
impl Default for FxHasher {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn default() -> FxHasher {
|
fn default() -> Self {
|
||||||
FxHasher { hash: 0 }
|
Self { hash: 0 }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ impl FromStr for ExternalName {
|
|||||||
// Try to parse as a libcall name, otherwise it's a test case.
|
// Try to parse as a libcall name, otherwise it's a test case.
|
||||||
match s.parse() {
|
match s.parse() {
|
||||||
Ok(lc) => Ok(ExternalName::LibCall(lc)),
|
Ok(lc) => Ok(ExternalName::LibCall(lc)),
|
||||||
Err(_) => Ok(ExternalName::testcase(s.as_bytes())),
|
Err(_) => Ok(Self::testcase(s.as_bytes())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,8 +154,7 @@ mod details {
|
|||||||
fn fmtdur(mut dur: Duration, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmtdur(mut dur: Duration, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
// Round to nearest ms by adding 500us.
|
// Round to nearest ms by adding 500us.
|
||||||
dur += Duration::new(0, 500_000);
|
dur += Duration::new(0, 500_000);
|
||||||
let ms = dur.subsec_nanos() / 1_000_000;
|
write!(f, "{:4}.{:03} ", dur.as_secs(), dur.subsec_millis())
|
||||||
write!(f, "{:4}.{:03} ", dur.as_secs(), ms)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fmtdur(time.total, f)?;
|
fmtdur(time.total, f)?;
|
||||||
|
|||||||
@@ -69,11 +69,9 @@ impl<'a> LocationVerifier<'a> {
|
|||||||
let opcode = dfg[inst].opcode();
|
let opcode = dfg[inst].opcode();
|
||||||
if opcode.is_return() {
|
if opcode.is_return() {
|
||||||
self.check_return_abi(inst, &divert)?;
|
self.check_return_abi(inst, &divert)?;
|
||||||
} else if opcode.is_branch() {
|
} else if opcode.is_branch() && !divert.is_empty() {
|
||||||
if !divert.is_empty() {
|
|
||||||
self.check_cfg_edges(inst, &divert)?;
|
self.check_cfg_edges(inst, &divert)?;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
self.update_diversions(inst, &mut divert)?;
|
self.update_diversions(inst, &mut divert)?;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user