Skip to content

Commit

Permalink
chore: rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Ray Redondo committed Jan 22, 2024
1 parent fdd8846 commit 57da2db
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 13 deletions.
56 changes: 45 additions & 11 deletions rust/src/irgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ pub mod name_visitor;
pub mod xir_visitor;

use crate::{
helpers::nzu16,
interning::Symbol,
irgen::xir_visitor::{XirModTypeGatherer, XirModVisitor},
sema::{DefId, Definitions, ty::{IntType, IntWidth}}, helpers::nzu16,
sema::{
ty::{IntType, IntWidth},
DefId, Definitions,
},
};

use xlang::ir;
Expand Down Expand Up @@ -63,16 +67,46 @@ impl IntMangler {

fn mangle(&self, ty: &IntType) -> char {
char::from(match *ty {
IntType { signed: true, width: IntWidth::Bits(x) } if x == nzu16!(8) => self.i8,
IntType { signed: true, width: IntWidth::Bits(x) } if x == nzu16!(16) => self.i16,
IntType { signed: true, width: IntWidth::Bits(x) } if x == nzu16!(32) => self.i32,
IntType { signed: true, width: IntWidth::Bits(x) } if x == nzu16!(64) => self.i64,
IntType { signed: true, width: IntWidth::Bits(x) } if x == nzu16!(128) => self.i128,
IntType { signed: false, width: IntWidth::Bits(x) } if x == nzu16!(8) => self.u8,
IntType { signed: false, width: IntWidth::Bits(x) } if x == nzu16!(16) => self.u16,
IntType { signed: false, width: IntWidth::Bits(x) } if x == nzu16!(32) => self.u32,
IntType { signed: false, width: IntWidth::Bits(x) } if x == nzu16!(64) => self.u64,
IntType { signed: false, width: IntWidth::Bits(x) } if x == nzu16!(128) => self.u128,
IntType {
signed: true,
width: IntWidth::Bits(x),
} if x == nzu16!(8) => self.i8,
IntType {
signed: true,
width: IntWidth::Bits(x),
} if x == nzu16!(16) => self.i16,
IntType {
signed: true,
width: IntWidth::Bits(x),
} if x == nzu16!(32) => self.i32,
IntType {
signed: true,
width: IntWidth::Bits(x),
} if x == nzu16!(64) => self.i64,
IntType {
signed: true,
width: IntWidth::Bits(x),
} if x == nzu16!(128) => self.i128,
IntType {
signed: false,
width: IntWidth::Bits(x),
} if x == nzu16!(8) => self.u8,
IntType {
signed: false,
width: IntWidth::Bits(x),
} if x == nzu16!(16) => self.u16,
IntType {
signed: false,
width: IntWidth::Bits(x),
} if x == nzu16!(32) => self.u32,
IntType {
signed: false,
width: IntWidth::Bits(x),
} if x == nzu16!(64) => self.u64,
IntType {
signed: false,
width: IntWidth::Bits(x),
} if x == nzu16!(128) => self.u128,
_ => unreachable!(),
})
}
Expand Down
1 change: 1 addition & 0 deletions rust/src/sema/mir/transform/remove_discard.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

8 changes: 6 additions & 2 deletions rust/src/sema/tyck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,12 @@ pub struct Inferer<'a> {
}

impl<'a> Inferer<'a> {
pub fn new(defs: &'a Definitions, curdef: DefId, curmod: DefId, vardefs: &'a mut HashMap<HirVarId, ThirVarDef>) -> Self {
pub fn new(
defs: &'a Definitions,
curdef: DefId,
curmod: DefId,
vardefs: &'a mut HashMap<HirVarId, ThirVarDef>,
) -> Self {
Self {
defs,
curdef,
Expand Down Expand Up @@ -1665,7 +1670,6 @@ impl<'a> Inferer<'a> {
let mut ty = std::mem::replace(&mut *self.vardefs[var].ty, Type::Never);
status &= self.propagate_type(&mut ty)?;
*self.vardefs[var].ty = ty;

}
ThirStatement::Return(ret) => status &= self.propagate_expr(ret)?,
ThirStatement::Block(blk) => status &= self.propagate_block(blk)?,
Expand Down

0 comments on commit 57da2db

Please sign in to comment.