Skip to content

Commit

Permalink
Apply clippy suggestions after rust update
Browse files Browse the repository at this point in the history
  • Loading branch information
Schottkyc137 committed Jun 15, 2024
1 parent f3f468e commit 493c933
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 17 deletions.
4 changes: 2 additions & 2 deletions vhdl_lang/src/analysis/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,13 @@ mod tests {
match lock.entry() {
AnalysisEntry::Occupied(entry) => {
assert_eq!(*entry, 2);
assert!((*entry.result() - 1.0_f64).abs() < std::f64::EPSILON);
assert!((*entry.result() - 1.0_f64).abs() < f64::EPSILON);
}
_ => panic!("Expected Occupied entry"),
};

assert_eq!(*lock.get().unwrap(), 2);
assert!((*lock.get().unwrap().result() - 1.0_f64).abs() < std::f64::EPSILON);
assert!((*lock.get().unwrap().result() - 1.0_f64).abs() < f64::EPSILON);

// Check that lock is reset
lock.reset();
Expand Down
2 changes: 0 additions & 2 deletions vhdl_lang/src/analysis/names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,6 @@ pub enum AttrResolveResult<'a> {

#[derive(Debug)]
pub struct AttributeSuffix<'a> {
pub signature: &'a mut Option<WithTokenSpan<crate::ast::Signature>>,
pub attr: &'a mut WithToken<AttributeDesignator>,
pub expr: &'a mut Option<Box<WithTokenSpan<Expression>>>,
}
Expand Down Expand Up @@ -462,7 +461,6 @@ impl<'a> SplitName<'a> {
Name::Attribute(ref mut attr) => SplitName::Suffix(
&mut attr.name,
Suffix::Attribute(AttributeSuffix {
signature: &mut attr.signature,
attr: &mut attr.attr,
expr: &mut attr.expr,
}),
Expand Down
6 changes: 1 addition & 5 deletions vhdl_lang/src/analysis/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,7 @@ impl<'a, 't> AnalyzeContext<'a, 't> {
prefix.as_type_of_attr_prefix(
self.ctx,
name.span,
&AttributeSuffix {
signature,
attr,
expr,
},
&AttributeSuffix { attr, expr },
diagnostics,
)
}),
Expand Down
3 changes: 2 additions & 1 deletion vhdl_lang/src/named_entity/arena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ impl LocalArena {

let ent_id = EntityId::new_arena(self.id, LocalId(idx as u32));
ent.id = ent_id;
self.items.push(std::mem::transmute(ent));
self.items
.push(std::mem::transmute::<AnyEnt<'_>, AnyEnt<'_>>(ent));
self.get(ent_id.local_id())
}

Expand Down
14 changes: 7 additions & 7 deletions vhdl_lang/src/syntax/tokens/tokenizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -942,10 +942,10 @@ fn parse_exponent(reader: &mut ContentReader) -> Result<i32, TokenError> {

let exp = parse_integer(reader, 10, false)?;
if negative {
if exp <= (-(i32::min_value() as i64)) as u64 {
if exp <= (-(i32::MIN as i64)) as u64 {
return Ok((-(exp as i64)) as i32);
}
} else if exp <= i32::max_value() as u64 {
} else if exp <= i32::MAX as u64 {
return Ok(exp as i32);
}

Expand Down Expand Up @@ -2583,7 +2583,7 @@ comment
))]
);

let exponent_str = ((i32::max_value() as i64) + 1).to_string();
let exponent_str = ((i32::MAX as i64) + 1).to_string();
let large_int = format!("1e{exponent_str}");
let code = Code::new(&large_int);
let (tokens, _) = code.tokenize_result();
Expand All @@ -2595,7 +2595,7 @@ comment
))]
);

let exponent_str = ((i32::min_value() as i64) - 1).to_string();
let exponent_str = ((i32::MIN as i64) - 1).to_string();
let large_int = format!("1.0e{exponent_str}");
let code = Code::new(&large_int);
let (tokens, _) = code.tokenize_result();
Expand All @@ -2607,7 +2607,7 @@ comment
))]
);

let large_int = ((u64::max_value() as i128) + 1).to_string();
let large_int = ((u64::MAX as i128) + 1).to_string();
let code = Code::new(&large_int);
let (tokens, _) = code.tokenize_result();
assert_eq!(
Expand All @@ -2618,14 +2618,14 @@ comment
))]
);

let large_int = u64::max_value().to_string();
let large_int = u64::MAX.to_string();
let code = Code::new(&large_int);
let (tokens, _) = code.tokenize_result();
assert_eq!(
tokens,
vec![Ok(Token {
kind: AbstractLiteral,
value: Value::AbstractLiteral(ast::AbstractLiteral::Integer(u64::max_value())),
value: Value::AbstractLiteral(ast::AbstractLiteral::Integer(u64::MAX)),
pos: code.pos(),
comments: None,
})]
Expand Down

0 comments on commit 493c933

Please sign in to comment.