mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 11:52:19 +00:00
Clippy
This commit is contained in:
parent
15afa36344
commit
4ef8ceef9e
5 changed files with 16 additions and 23 deletions
|
@ -53,10 +53,8 @@ pub fn deep_copy_type_vars_into_expr<'a>(
|
|||
let go_help = |e: &Expr| help(subs, e, substitutions);
|
||||
|
||||
match expr {
|
||||
Num(var, str, val, bound) => Num(sub!(*var), str.clone(), val.clone(), *bound),
|
||||
Int(v1, v2, str, val, bound) => {
|
||||
Int(sub!(*v1), sub!(*v2), str.clone(), val.clone(), *bound)
|
||||
}
|
||||
Num(var, str, val, bound) => Num(sub!(*var), str.clone(), *val, *bound),
|
||||
Int(v1, v2, str, val, bound) => Int(sub!(*v1), sub!(*v2), str.clone(), *val, *bound),
|
||||
Float(v1, v2, str, val, bound) => {
|
||||
Float(sub!(*v1), sub!(*v2), str.clone(), *val, *bound)
|
||||
}
|
||||
|
|
|
@ -8849,16 +8849,16 @@ enum NumLiteral {
|
|||
}
|
||||
|
||||
impl NumLiteral {
|
||||
fn to_expr_literal(self) -> Literal<'static> {
|
||||
match self {
|
||||
fn to_expr_literal(&self) -> Literal<'static> {
|
||||
match *self {
|
||||
NumLiteral::Int(n, _) => Literal::Int(n),
|
||||
NumLiteral::U128(n) => Literal::U128(n),
|
||||
NumLiteral::Float(n, _) => Literal::Float(n),
|
||||
NumLiteral::Decimal(n) => Literal::Decimal(n),
|
||||
}
|
||||
}
|
||||
fn to_pattern(self) -> Pattern<'static> {
|
||||
match self {
|
||||
fn to_pattern(&self) -> Pattern<'static> {
|
||||
match *self {
|
||||
NumLiteral::Int(n, w) => Pattern::IntLiteral(n, w),
|
||||
NumLiteral::U128(_) => todo!(),
|
||||
NumLiteral::Float(n, w) => Pattern::FloatLiteral(f64::to_bits(n), w),
|
||||
|
@ -8867,11 +8867,7 @@ impl NumLiteral {
|
|||
}
|
||||
}
|
||||
|
||||
fn make_num_literal<'a>(
|
||||
layout: Layout<'a>,
|
||||
num_str: &str,
|
||||
num_value: IntOrFloatValue,
|
||||
) -> NumLiteral {
|
||||
fn make_num_literal(layout: Layout<'_>, num_str: &str, num_value: IntOrFloatValue) -> NumLiteral {
|
||||
match layout {
|
||||
Layout::Builtin(Builtin::Int(width)) => match num_value {
|
||||
IntOrFloatValue::Int(IntValue::I128(n)) => NumLiteral::Int(n, width),
|
||||
|
@ -8888,7 +8884,7 @@ fn make_num_literal<'a>(
|
|||
},
|
||||
},
|
||||
Layout::Builtin(Builtin::Decimal) => {
|
||||
let dec = match RocDec::from_str(&num_str) {
|
||||
let dec = match RocDec::from_str(num_str) {
|
||||
Some(d) => d,
|
||||
None => internal_error!(
|
||||
"Invalid decimal for float literal = {}. This should be a type error!",
|
||||
|
@ -8914,7 +8910,7 @@ fn assign_num_literal_expr<'a>(
|
|||
hole: &'a Stmt<'a>,
|
||||
) -> Stmt<'a> {
|
||||
let layout = layout_cache
|
||||
.from_var(env.arena, variable, &env.subs)
|
||||
.from_var(env.arena, variable, env.subs)
|
||||
.unwrap();
|
||||
let literal = make_num_literal(layout, num_str, num_value).to_expr_literal();
|
||||
|
||||
|
@ -8929,7 +8925,7 @@ fn make_num_literal_pattern<'a>(
|
|||
num_value: IntOrFloatValue,
|
||||
) -> Pattern<'a> {
|
||||
let layout = layout_cache
|
||||
.from_var(env.arena, variable, &env.subs)
|
||||
.from_var(env.arena, variable, env.subs)
|
||||
.unwrap();
|
||||
let literal = make_num_literal(layout, num_str, num_value);
|
||||
literal.to_pattern()
|
||||
|
|
|
@ -177,7 +177,7 @@ impl IntLitWidth {
|
|||
}
|
||||
|
||||
fn is_signed(&self) -> bool {
|
||||
return self.signedness_and_width().0 == IntSignedness::Signed;
|
||||
self.signedness_and_width().0 == IntSignedness::Signed
|
||||
}
|
||||
|
||||
pub fn type_str(&self) -> &'static str {
|
||||
|
|
|
@ -804,7 +804,7 @@ fn write_content<'a>(
|
|||
Parens::Unnecessary,
|
||||
);
|
||||
}
|
||||
buf.push_str(")");
|
||||
buf.push(')');
|
||||
}
|
||||
Error => buf.push_str("<type mismatch>"),
|
||||
}
|
||||
|
|
|
@ -3676,11 +3676,10 @@ fn content_to_err_type(
|
|||
let err_type = var_to_err_type(subs, state, aliased_to);
|
||||
|
||||
// Lift RangedNumber up if needed.
|
||||
match (symbol, &err_type) {
|
||||
(Symbol::NUM_INT | Symbol::NUM_NUM | Symbol::NUM_INTEGER, ErrorType::Range(_)) => {
|
||||
return err_type;
|
||||
}
|
||||
_ => {}
|
||||
if let (Symbol::NUM_INT | Symbol::NUM_NUM | Symbol::NUM_INTEGER, ErrorType::Range(_)) =
|
||||
(symbol, &err_type)
|
||||
{
|
||||
return err_type;
|
||||
}
|
||||
|
||||
let mut err_args = Vec::with_capacity(args.len());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue