-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix many clippy warnings across Kani #1287
Conversation
@@ -510,7 +514,7 @@ impl Expr { | |||
|
|||
/// `union {double d; uint64_t bp} u = {.bp = 0x1234}; >>> u.d <<<` | |||
pub fn double_constant_from_bitpattern(bp: u64) -> Self { | |||
let c = unsafe { std::mem::transmute(bp) }; | |||
let c = f64::from_bits(bp); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice to get rid of an unsafe transmute
here
@@ -1446,12 +1450,12 @@ impl Expr { | |||
} | |||
} | |||
None => { | |||
for i in 0..fields.len() { | |||
if fields[i].is_padding() { | |||
for field in fields { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not an issue for this PR, but this whole function looks more complicated that it needs to be.
@@ -138,7 +138,7 @@ impl Location { | |||
file.into(), | |||
function.intern(), | |||
line, | |||
col.map(|x| x.try_into().unwrap()), | |||
col, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol
let (prefix, name) = if orig_name.starts_with("tag-") { | ||
(&orig_name[..4], &orig_name[4..]) | ||
let (prefix, name) = if let Some(tag) = orig_name.strip_prefix("tag-") { | ||
("tag-", tag) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Impressed clippy found this pattern
@@ -113,7 +113,7 @@ fn try_parse_args(cur_args: Vec<String>, name: &str, line: &str) -> Vec<String> | |||
let name = format!("{}-flags:", name); | |||
let mut split = line.split(&name).skip(1); | |||
let args: Vec<String> = if let Some(rest) = split.next() { | |||
rest.trim().split_whitespace().map(String::from).collect() | |||
rest.split_whitespace().map(String::from).collect() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this change the semantics?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope! That's apparently why clippy has this lint. :)
} else { | ||
None | ||
} | ||
args.unwind.or(harness_metadata.unwind_value).or(args.default_unwind) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is easier to read :)
@@ -206,7 +206,7 @@ impl ToIrep for ExprValue { | |||
} | |||
//TODO, determine if there is an endineness problem here | |||
ExprValue::DoubleConstant(i) => { | |||
let c: u64 = unsafe { std::mem::transmute(*i) }; | |||
let c: u64 = i.to_bits(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
@@ -405,8 +405,7 @@ impl ToIrep for StmtBody { | |||
StmtBody::Assume { cond } => code_irep(IrepId::Assume, vec![cond.to_irep(mm)]), | |||
StmtBody::AtomicBlock(stmts) => { | |||
let mut irep_stmts = vec![code_irep(IrepId::AtomicBegin, vec![])]; | |||
irep_stmts | |||
.append(&mut stmts.into_iter().map(|x| x.to_irep(mm)).collect::<Vec<Irep>>()); | |||
irep_stmts.append(&mut stmts.iter().map(|x| x.to_irep(mm)).collect()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bye bye turbo🐠
@@ -46,7 +46,8 @@ impl From<RoundingMode> for BigInt { | |||
} | |||
} | |||
|
|||
/// Constructor | |||
// TODO: This file should be refactored. This is a bit "OO" style when it doesn't have to be. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tracking issue
Description of changes:
#![allow(...
directives.Resolved issues:
Call-outs:
Testing:
How is this change tested? existing regression
Is this a refactor change? yep
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.