Merge branch 'main' of github.com:roc-lang/roc into clippy-1.74

This commit is contained in:
Anton-4 2023-12-25 17:05:37 +01:00
commit cd632fe549
No known key found for this signature in database
GPG key ID: 0971D718C0A9B937
271 changed files with 7741 additions and 7417 deletions

View file

@ -631,10 +631,14 @@ fn specialize_drops_stmt<'a, 'i>(
),
}),
Stmt::Dbg {
source_location,
source,
symbol,
variable,
remainder,
} => arena.alloc(Stmt::Dbg {
source_location,
source,
symbol: *symbol,
variable: *variable,
remainder: specialize_drops_stmt(
@ -1536,7 +1540,7 @@ fn low_level_no_rc(lowlevel: &LowLevel) -> RC {
StrGetUnsafe | ListGetUnsafe => RC::NoRc,
ListConcat => RC::Rc,
StrConcat => RC::Rc,
StrSubstringUnsafe => RC::NoRc,
StrSubstringUnsafe => RC::Rc,
StrReserve => RC::Rc,
StrAppendScalar => RC::Rc,
StrGetScalarUnsafe => RC::NoRc,

View file

@ -689,6 +689,8 @@ fn insert_refcount_operations_stmt<'v, 'a>(
})
}
Stmt::Dbg {
source_location,
source,
symbol,
variable,
remainder,
@ -703,6 +705,8 @@ fn insert_refcount_operations_stmt<'v, 'a>(
);
arena.alloc(Stmt::Dbg {
source_location,
source,
symbol: *symbol,
variable: *variable,
remainder: newer_remainder,
@ -1288,7 +1292,7 @@ fn lowlevel_borrow_signature(arena: &Bump, op: LowLevel) -> &[Ownership] {
StrGetUnsafe | ListGetUnsafe => arena.alloc_slice_copy(&[borrowed, irrelevant]),
ListConcat => arena.alloc_slice_copy(&[owned, owned]),
StrConcat => arena.alloc_slice_copy(&[owned, borrowed]),
StrSubstringUnsafe => arena.alloc_slice_copy(&[borrowed, irrelevant, irrelevant]),
StrSubstringUnsafe => arena.alloc_slice_copy(&[owned, irrelevant, irrelevant]),
StrReserve => arena.alloc_slice_copy(&[owned, irrelevant]),
StrAppendScalar => arena.alloc_slice_copy(&[owned, irrelevant]),
StrGetScalarUnsafe => arena.alloc_slice_copy(&[borrowed, irrelevant]),

View file

@ -1531,6 +1531,10 @@ pub enum Stmt<'a> {
remainder: &'a Stmt<'a>,
},
Dbg {
/// The location this dbg is in source as a printable string.
source_location: &'a str,
/// The source code of the expression being debugged.
source: &'a str,
/// The expression we're displaying
symbol: Symbol,
/// The specialized variable of the expression
@ -4606,6 +4610,8 @@ pub fn with_hole<'a>(
Expect { .. } => unreachable!("I think this is unreachable"),
ExpectFx { .. } => unreachable!("I think this is unreachable"),
Dbg {
source_location,
source,
loc_message,
loc_continuation,
variable: cond_variable,
@ -4625,6 +4631,8 @@ pub fn with_hole<'a>(
env,
procs,
layout_cache,
&*arena.alloc(source_location),
&*arena.alloc(source),
dbg_symbol,
*loc_message,
cond_variable,
@ -5896,8 +5904,10 @@ fn compile_dbg<'a>(
env: &mut Env<'a, '_>,
procs: &mut Procs<'a>,
layout_cache: &mut LayoutCache<'a>,
source_location: &'a str,
source: &'a str,
dbg_symbol: Symbol,
loc_condition: Loc<roc_can::expr::Expr>,
loc_message: Loc<roc_can::expr::Expr>,
variable: Variable,
continuation: Stmt<'a>,
) -> Stmt<'a> {
@ -5908,6 +5918,8 @@ fn compile_dbg<'a>(
.fresh_unnamed_flex_var();
let dbg_stmt = Stmt::Dbg {
source_location,
source,
symbol: dbg_symbol,
variable: spec_var,
remainder: env.arena.alloc(continuation),
@ -5918,17 +5930,17 @@ fn compile_dbg<'a>(
store_specialized_expectation_lookups(env, [variable], &[spec_var]);
let symbol_is_reused = matches!(
can_reuse_symbol(env, layout_cache, procs, &loc_condition.value, variable),
can_reuse_symbol(env, layout_cache, procs, &loc_message.value, variable),
ReuseSymbol::Value(_)
);
// skip evaluating the condition if it's just a symbol
// skip evaluating the message if it's just a symbol
if symbol_is_reused {
dbg_stmt
} else {
with_hole(
env,
loc_condition.value,
loc_message.value,
variable,
procs,
layout_cache,
@ -7141,6 +7153,8 @@ pub fn from_can<'a>(
}
Dbg {
source_location,
source,
loc_message,
loc_continuation,
variable: cond_variable,
@ -7152,6 +7166,8 @@ pub fn from_can<'a>(
env,
procs,
layout_cache,
&*env.arena.alloc(source_location),
&*env.arena.alloc(source),
dbg_symbol,
*loc_message,
cond_variable,
@ -7625,6 +7641,8 @@ fn substitute_in_stmt_help<'a>(
}
Dbg {
source_location,
source,
symbol,
variable,
remainder,
@ -7633,6 +7651,8 @@ fn substitute_in_stmt_help<'a>(
substitute_in_stmt_help(arena, remainder, subs).unwrap_or(remainder);
let expect = Dbg {
source_location,
source,
symbol: substitute(subs, *symbol).unwrap_or(*symbol),
variable: *variable,
remainder: new_remainder,

View file

@ -1544,7 +1544,13 @@ fn store_list_pattern<'a>(
}
}
stmt = store_list_rest(env, list_sym, list_arity, list_layout, opt_rest, stmt);
stmt = match store_list_rest(env, list_sym, list_arity, list_layout, opt_rest, stmt) {
StorePattern::Productive(new) => {
is_productive = true;
new
}
StorePattern::NotProductive(new) => new,
};
if is_productive {
StorePattern::Productive(stmt)
@ -1560,8 +1566,12 @@ fn store_list_rest<'a>(
list_layout: InLayout<'a>,
opt_rest: &Option<(usize, Option<Symbol>)>,
mut stmt: Stmt<'a>,
) -> Stmt<'a> {
) -> StorePattern<'a> {
let mut is_productive = false;
if let Some((index, Some(rest_sym))) = opt_rest {
is_productive = true;
let usize_layout = Layout::usize(env.target_info);
let total_dropped = list_arity.min_len();
@ -1608,7 +1618,12 @@ fn store_list_rest<'a>(
stmt = Stmt::Let(sym, expr, lay, env.arena.alloc(stmt));
}
}
stmt
if is_productive {
StorePattern::Productive(stmt)
} else {
StorePattern::NotProductive(stmt)
}
}
#[allow(clippy::too_many_arguments)]

View file

@ -651,6 +651,8 @@ fn insert_reset_reuse_operations_stmt<'a, 'i>(
})
}
Stmt::Dbg {
source_location,
source,
symbol,
variable,
remainder,
@ -666,6 +668,8 @@ fn insert_reset_reuse_operations_stmt<'a, 'i>(
);
arena.alloc(Stmt::Dbg {
source_location,
source,
symbol: *symbol,
variable: *variable,
remainder: new_remainder,

View file

@ -330,6 +330,8 @@ fn insert_jumps<'a>(
}
Dbg {
source_location,
source,
symbol,
variable,
remainder,
@ -342,6 +344,8 @@ fn insert_jumps<'a>(
needle_result,
) {
Some(cont) => Some(arena.alloc(Dbg {
source_location,
source,
symbol: *symbol,
variable: *variable,
remainder: cont,
@ -1020,10 +1024,14 @@ impl<'a> TrmcEnv<'a> {
remainder: arena.alloc(self.walk_stmt(env, remainder)),
},
Stmt::Dbg {
source_location,
source,
symbol,
variable,
remainder,
} => Stmt::Dbg {
source_location,
source,
symbol: *symbol,
variable: *variable,
remainder: arena.alloc(self.walk_stmt(env, remainder)),