Skip to content

Commit 33d663a

Browse files
committed
cargo fix & fmt
1 parent 9822e49 commit 33d663a

File tree

11 files changed

+51
-45
lines changed

11 files changed

+51
-45
lines changed

crates/ash_core/src/ir/ir.rs

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl<'a> IR<'a> {
107107
let expr_stmt = ir::Stmt::Expression(returns, ty);
108108
DesugaredAst::new((expr_stmt, span), expr.rest)
109109
}
110-
None => DesugaredAst::rest(expr.rest)
110+
None => DesugaredAst::rest(expr.rest),
111111
}
112112
}
113113
ty::Stmt::VariableAssign {
@@ -189,7 +189,7 @@ impl<'a> IR<'a> {
189189
right,
190190
ty,
191191
};
192-
192+
193193
DesugaredAst::new(binary, rest)
194194
}
195195
ty::Expr::Literal(value) => DesugaredAst::returns(ir::Expr::Literal(value)),
@@ -278,16 +278,17 @@ impl<'a> IR<'a> {
278278

279279
fn desugar_if_stmt(&mut self, r#if: If<ty::Expr, ty::Stmt>) -> DesugaredAst<Spanned<ir::Stmt>> {
280280
let mut insert_before = Vec::new();
281-
let mut desugar_inner = |inner: IfInner<ty::Expr, ty::Stmt>| -> IfInner<ir::Expr, ir::Stmt> {
282-
let mut condition_desugar = self.desugar_expr(inner.condition.0);
283-
insert_before.append(&mut condition_desugar.rest);
284-
let condition = (condition_desugar.returns.unwrap(), inner.condition.1);
285-
286-
IfInner {
287-
condition,
288-
body: self.desugar_statements(inner.body),
289-
}
290-
};
281+
let mut desugar_inner =
282+
|inner: IfInner<ty::Expr, ty::Stmt>| -> IfInner<ir::Expr, ir::Stmt> {
283+
let mut condition_desugar = self.desugar_expr(inner.condition.0);
284+
insert_before.append(&mut condition_desugar.rest);
285+
let condition = (condition_desugar.returns.unwrap(), inner.condition.1);
286+
287+
IfInner {
288+
condition,
289+
body: self.desugar_statements(inner.body),
290+
}
291+
};
291292

292293
let r#if = If {
293294
then: Box::new(desugar_inner(*r#if.then)),
@@ -303,11 +304,7 @@ impl<'a> IR<'a> {
303304
DesugaredAst::new((if_stmt, Span::default()), insert_before)
304305
}
305306

306-
fn desugar_if_expr(
307-
&mut self,
308-
r#if: If<ty::Expr, ty::Stmt>,
309-
ty: Ty,
310-
) -> DesugaredAst<ir::Expr> {
307+
fn desugar_if_expr(&mut self, r#if: If<ty::Expr, ty::Stmt>, ty: Ty) -> DesugaredAst<ir::Expr> {
311308
let mut insert_before = Vec::new();
312309
let (final_var_id, final_var_name) = self.init_new_var(&mut insert_before, ty.clone());
313310

@@ -360,10 +357,7 @@ impl<'a> IR<'a> {
360357
),
361358
};
362359

363-
insert_before.push((
364-
ir::Stmt::If(r#if),
365-
Span::default(),
366-
));
360+
insert_before.push((ir::Stmt::If(r#if), Span::default()));
367361
DesugaredAst::new(
368362
self.new_var_read(final_var_name, ty, final_var_id),
369363
insert_before,
@@ -390,7 +384,7 @@ impl<'a> IR<'a> {
390384
let fun_ty = ir_fun.proto.0.ty.fun_return_ty();
391385
let span = fun.body.1.clone();
392386
let body = match fun.body.0 {
393-
ty::Stmt::Expression(ty::Expr::Block(mut statements, _), _) => {
387+
ty::Stmt::Expression(ty::Expr::Block(statements, _), _) => {
394388
let statements = self.desugar_statements(statements);
395389
self.desugar_fun_return_expr(statements, fun_ty.clone())
396390
}

crates/ash_core/src/ir/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
pub mod ir;
21
pub mod ast;
2+
pub mod ir;
33

4+
pub use ast::*;
45
pub use ir::*;
5-
pub use ast::*;

crates/ash_core/src/parser/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ pub(super) fn block_parser<'a>(
4343
.padded_by(just(Token::NewLine).repeated())
4444
.then_ignore(just(Token::RBrace))
4545
.map(Expr::Block)
46-
// .recover_with(skip_until([Token::LBrace, Token::RBrace], |_| Expr::Block(Vec::new())))
47-
// .recover_with(nested_delimiters(Token::LBrace, Token::RBrace, [], |_| Expr::Block(Vec::new())))
46+
// .recover_with(skip_until([Token::LBrace, Token::RBrace], |_| Expr::Block(Vec::new())))
47+
// .recover_with(nested_delimiters(Token::LBrace, Token::RBrace, [], |_| Expr::Block(Vec::new())))
4848
}
4949

5050
pub(super) fn type_parser() -> impl Parser<Token, Ty, Error = Simple<Token>> {

crates/ash_core/src/parser/conditional.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::{core::Spanned, lexer::token::Token};
22
use chumsky::prelude::*;
33

4-
use super::{common::block_parser, expression_parser, Expr, StmtRecursive, Stmt};
4+
use super::{common::block_parser, expression_parser, Expr, StmtRecursive};
55

66
#[derive(Debug, Clone)]
77
pub(crate) struct If<E, S> {
@@ -37,9 +37,11 @@ pub(super) fn if_parser<'a>(
3737
then.labelled("if")
3838
.then(else_if.labelled("else if").repeated())
3939
.then(otherwise.labelled("else").or_not())
40-
.map(|((then, else_ifs), otherwise)| Expr::If(If {
41-
then: Box::new(then),
42-
else_ifs,
43-
otherwise: otherwise.unwrap_or(Vec::new()),
44-
}))
40+
.map(|((then, else_ifs), otherwise)| {
41+
Expr::If(If {
42+
then: Box::new(then),
43+
else_ifs,
44+
otherwise: otherwise.unwrap_or(Vec::new()),
45+
})
46+
})
4547
}

crates/ash_core/src/parser/expr.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ use super::{
1010
function::call_parser,
1111
literal::literal_parser,
1212
operator::{operator_parser, BinaryOp, UnaryOp},
13-
stmt::Stmt, If,
13+
stmt::Stmt,
14+
If,
1415
};
1516

1617
#[derive(Debug, Clone)]
@@ -39,7 +40,7 @@ impl Expr {
3940
pub fn block_data(self) -> Vec<Spanned<Stmt>> {
4041
match self {
4142
Self::Block(data) => data,
42-
_ => unreachable!("Not block expression")
43+
_ => unreachable!("Not block expression"),
4344
}
4445
}
4546
}
@@ -48,8 +49,7 @@ pub(super) type ExprRecursive<'a> = Recursive<'a, Token, Expr, Simple<Token>>;
4849

4950
pub(super) fn expression_parser() -> impl Parser<Token, Expr, Error = Simple<Token>> + Clone {
5051
recursive(|expr| {
51-
let variable = ident_parser()
52-
.map(|name| Expr::Variable(next_id(), name));
52+
let variable = ident_parser().map(|name| Expr::Variable(next_id(), name));
5353
let group = expr
5454
.clone()
5555
.delimited_by(just(Token::LParen), just(Token::RParen))

crates/ash_core/src/parser/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1+
pub use conditional::*;
12
pub use expr::*;
23
pub use stmt::*;
3-
pub use conditional::*;
44

55
mod annotation;
66
mod common;
7+
pub mod conditional;
78
pub(crate) mod expr;
89
mod function;
910
mod literal;
1011
pub(crate) mod operator;
1112
pub(crate) mod parser;
1213
pub(crate) mod stmt;
1314
mod variable;
14-
pub mod conditional;

crates/ash_core/src/parser/stmt.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ use chumsky::prelude::*;
1111
use super::{
1212
annotation::annotation_parser,
1313
common::block_parser,
14+
conditional::if_parser,
1415
expr::{expression_parser, Expr},
1516
function::{function_parser, function_proto_parser, return_parser},
16-
variable::{variable_assign_parse, variable_decl_parse}, conditional::if_parser,
17+
variable::{variable_assign_parse, variable_decl_parse},
1718
};
1819

1920
#[derive(Debug, Clone)]
@@ -67,5 +68,7 @@ pub(super) fn statement_parser() -> impl Parser<Token, Spanned<Stmt>, Error = Si
6768
pub(super) fn stmt_expression_parser<'a>(
6869
stmt: StmtRecursive<'a>,
6970
) -> impl Parser<Token, Expr, Error = Simple<Token>> + 'a {
70-
if_parser(stmt.clone()).or(block_parser(stmt)).or(expression_parser())
71+
if_parser(stmt.clone())
72+
.or(block_parser(stmt))
73+
.or(expression_parser())
7174
}

crates/ash_core/src/resolver/resolver.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,11 @@ impl<'a> Resolver<'a> {
197197
}
198198
Expr::Group(expr) => self.resolve_expr(expr, span),
199199
Expr::Block(stmts) => self.block(stmts),
200-
Expr::If(If { then, else_ifs, otherwise }) => {
200+
Expr::If(If {
201+
then,
202+
else_ifs,
203+
otherwise,
204+
}) => {
201205
let (cond, cond_span) = &then.condition;
202206
self.resolve_expr(cond, cond_span);
203207
self.resolve_statements(&then.body);

crates/ash_core/src/ty/ast.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
use crate::{
22
core::{Annotation, Id, Spanned},
3-
parser::{operator::{BinaryOp, UnaryOp}, conditional::IfInner, If},
3+
parser::{
4+
operator::{BinaryOp, UnaryOp},
5+
If,
6+
},
47
};
58

69
use super::{
710
function::{Function, ProtoFunction},
811
ty::Ty,
9-
Value, TypeSystem,
12+
TypeSystem, Value,
1013
};
1114

1215
#[derive(Debug)]

crates/ash_core/src/ty/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub(crate) enum Ty {
1111
F64,
1212
Void,
1313
Fun(Vec<Ty>, Box<Ty>),
14-
DeferTyCheck(Vec<Ty>, Span)
14+
DeferTyCheck(Vec<Ty>, Span),
1515
}
1616

1717
impl Default for Ty {

0 commit comments

Comments
 (0)