Skip to content

Commit

Permalink
apply clippy suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
lenawanel committed Jun 17, 2024
1 parent cc631b2 commit 5048e24
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions crates/codegen/src/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ fn calc_single(ty: Intern<Ty>, ptr_ty: types::Type) {
{
let finals = unsafe { FINAL_TYS.lock() }.unwrap();
let finals = finals.get().unwrap();
if finals.finals.get(&ty).is_some() {
if finals.finals.contains_key(&ty) {
return;
}
}
Expand Down Expand Up @@ -340,7 +340,7 @@ fn simple_id(discriminant: u32, bit_width: u32, signed: bool) -> u32 {

let byte_width = bit_width / 8;

let align = byte_width.min(8).max(1) << 5;
let align = byte_width.clamp(1, 8) << 5;

let sign = (signed as u32) << 9;

Expand Down
2 changes: 1 addition & 1 deletion crates/codegen/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ fn calc_single(ty: Intern<Ty>, pointer_bit_width: u32) {
{
let layouts = unsafe { LAYOUTS.lock() }.unwrap();
let layouts = layouts.get().unwrap();
if layouts.sizes.get(&ty).is_some() {
if layouts.sizes.contains_key(&ty) {
return;
}
}
Expand Down
15 changes: 11 additions & 4 deletions crates/hir/src/body.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
use std::{cmp::Ordering, env, fmt::Debug, mem, path::Path, vec};
use std::{
cmp::Ordering,
env,
fmt::{Debug, Display},
mem,
path::Path,
vec,
};

use ast::{AstNode, AstToken};
use interner::{Interner, Key};
Expand Down Expand Up @@ -387,9 +394,9 @@ enum ScopeKind {
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
pub struct ScopeId(u32);

impl ToString for ScopeId {
fn to_string(&self) -> String {
self.0.to_string()
impl Display for ScopeId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(&self.0.to_string())
}
}

Expand Down

0 comments on commit 5048e24

Please sign in to comment.