Fix --release warnings

This commit is contained in:
Richard Feldman 2022-05-15 22:09:21 -04:00
parent d484988a50
commit de75f2e550
No known key found for this signature in database
GPG key ID: 7E4127D1E4241798
6 changed files with 65 additions and 34 deletions

View file

@ -28,7 +28,11 @@ pub fn func_name_bytes(proc: &Proc) -> [u8; SIZE] {
#[inline(always)] #[inline(always)]
fn debug() -> bool { fn debug() -> bool {
use roc_debug_flags::{dbg_do, ROC_DEBUG_ALIAS_ANALYSIS}; use roc_debug_flags::dbg_do;
#[cfg(debug_assertions)]
use roc_debug_flags::ROC_DEBUG_ALIAS_ANALYSIS;
dbg_do!(ROC_DEBUG_ALIAS_ANALYSIS, { dbg_do!(ROC_DEBUG_ALIAS_ANALYSIS, {
return true; return true;
}); });

View file

@ -56,7 +56,9 @@ use morphic_lib::{
use roc_builtins::bitcode::{self, FloatWidth, IntWidth, IntrinsicName}; use roc_builtins::bitcode::{self, FloatWidth, IntWidth, IntrinsicName};
use roc_builtins::{float_intrinsic, llvm_int_intrinsic}; use roc_builtins::{float_intrinsic, llvm_int_intrinsic};
use roc_collections::all::{ImMap, MutMap, MutSet}; use roc_collections::all::{ImMap, MutMap, MutSet};
use roc_debug_flags::{dbg_do, ROC_PRINT_LLVM_FN_VERIFICATION}; use roc_debug_flags::dbg_do;
#[cfg(debug_assertions)]
use roc_debug_flags::ROC_PRINT_LLVM_FN_VERIFICATION;
use roc_error_macros::internal_error; use roc_error_macros::internal_error;
use roc_module::low_level::LowLevel; use roc_module::low_level::LowLevel;
use roc_module::symbol::{Interns, ModuleId, Symbol}; use roc_module::symbol::{Interns, ModuleId, Symbol};

View file

@ -15,9 +15,11 @@ use roc_constrain::module::{
constrain_builtin_imports, constrain_module, ExposedByModule, ExposedForModule, constrain_builtin_imports, constrain_module, ExposedByModule, ExposedForModule,
ExposedModuleTypes, ExposedModuleTypes,
}; };
use roc_debug_flags::dbg_do;
#[cfg(debug_assertions)]
use roc_debug_flags::{ use roc_debug_flags::{
dbg_do, ROC_PRINT_IR_AFTER_REFCOUNT, ROC_PRINT_IR_AFTER_RESET_REUSE, ROC_PRINT_IR_AFTER_REFCOUNT, ROC_PRINT_IR_AFTER_RESET_REUSE, ROC_PRINT_IR_AFTER_SPECIALIZATION,
ROC_PRINT_IR_AFTER_SPECIALIZATION, ROC_PRINT_LOAD_LOG, ROC_PRINT_LOAD_LOG,
}; };
use roc_error_macros::internal_error; use roc_error_macros::internal_error;
use roc_module::ident::{Ident, ModuleName, QualifiedModuleName}; use roc_module::ident::{Ident, ModuleName, QualifiedModuleName};
@ -3873,7 +3875,8 @@ fn canonicalize_and_constrain<'a>(
.. ..
} = parsed; } = parsed;
let before = roc_types::types::get_type_clone_count(); // _before has an underscore because it's unused in --release builds
let _before = roc_types::types::get_type_clone_count();
let mut var_store = VarStore::default(); let mut var_store = VarStore::default();
let module_output = canonicalize_module_defs( let module_output = canonicalize_module_defs(
@ -3891,14 +3894,15 @@ fn canonicalize_and_constrain<'a>(
&mut var_store, &mut var_store,
); );
let after = roc_types::types::get_type_clone_count(); // _after has an underscore because it's unused in --release builds
let _after = roc_types::types::get_type_clone_count();
log!( log!(
"canonicalize of {:?} cloned Type {} times ({} -> {})", "canonicalize of {:?} cloned Type {} times ({} -> {})",
module_id, module_id,
after - before, _after - _before,
before, _before,
after _after
); );
let canonicalize_end = SystemTime::now(); let canonicalize_end = SystemTime::now();
@ -3921,7 +3925,8 @@ fn canonicalize_and_constrain<'a>(
} }
}; };
let before = roc_types::types::get_type_clone_count(); // _before has an underscore because it's unused in --release builds
let _before = roc_types::types::get_type_clone_count();
let mut constraints = Constraints::new(); let mut constraints = Constraints::new();
@ -3937,14 +3942,15 @@ fn canonicalize_and_constrain<'a>(
) )
}; };
let after = roc_types::types::get_type_clone_count(); // _after has an underscore because it's unused in --release builds
let _after = roc_types::types::get_type_clone_count();
log!( log!(
"constraint gen of {:?} cloned Type {} times ({} -> {})", "constraint gen of {:?} cloned Type {} times ({} -> {})",
module_id, module_id,
after - before, _after - _before,
before, _before,
after _after
); );
// scope has imported aliases, but misses aliases from inner scopes // scope has imported aliases, but misses aliases from inner scopes

View file

@ -11,9 +11,10 @@ use roc_can::abilities::{AbilitiesStore, SpecializationId};
use roc_can::expr::{AnnotatedMark, ClosureData, IntValue}; use roc_can::expr::{AnnotatedMark, ClosureData, IntValue};
use roc_collections::all::{default_hasher, BumpMap, BumpMapDefault, MutMap}; use roc_collections::all::{default_hasher, BumpMap, BumpMapDefault, MutMap};
use roc_collections::{MutSet, VecMap}; use roc_collections::{MutSet, VecMap};
use roc_debug_flags::dbg_do;
#[cfg(debug_assertions)]
use roc_debug_flags::{ use roc_debug_flags::{
dbg_do, ROC_PRINT_IR_AFTER_REFCOUNT, ROC_PRINT_IR_AFTER_RESET_REUSE, ROC_PRINT_IR_AFTER_REFCOUNT, ROC_PRINT_IR_AFTER_RESET_REUSE, ROC_PRINT_IR_AFTER_SPECIALIZATION,
ROC_PRINT_IR_AFTER_SPECIALIZATION,
}; };
use roc_exhaustive::{Ctor, CtorName, Guard, RenderAs, TagId}; use roc_exhaustive::{Ctor, CtorName, Guard, RenderAs, TagId};
use roc_module::ident::{ForeignSymbol, Lowercase, TagName}; use roc_module::ident::{ForeignSymbol, Lowercase, TagName};

View file

@ -8,7 +8,9 @@ use roc_can::constraint::Constraint::{self, *};
use roc_can::constraint::{Constraints, Cycle, LetConstraint, OpportunisticResolve}; use roc_can::constraint::{Constraints, Cycle, LetConstraint, OpportunisticResolve};
use roc_can::expected::{Expected, PExpected}; use roc_can::expected::{Expected, PExpected};
use roc_collections::all::MutMap; use roc_collections::all::MutMap;
use roc_debug_flags::{dbg_do, ROC_VERIFY_RIGID_LET_GENERALIZED}; use roc_debug_flags::dbg_do;
#[cfg(debug_assertions)]
use roc_debug_flags::ROC_VERIFY_RIGID_LET_GENERALIZED;
use roc_error_macros::internal_error; use roc_error_macros::internal_error;
use roc_module::ident::TagName; use roc_module::ident::TagName;
use roc_module::symbol::Symbol; use roc_module::symbol::Symbol;

View file

@ -1,5 +1,7 @@
use bitflags::bitflags; use bitflags::bitflags;
use roc_debug_flags::{dbg_do, ROC_PRINT_MISMATCHES, ROC_PRINT_UNIFICATIONS}; use roc_debug_flags::dbg_do;
#[cfg(debug_assertions)]
use roc_debug_flags::{ROC_PRINT_MISMATCHES, ROC_PRINT_UNIFICATIONS};
use roc_error_macros::internal_error; use roc_error_macros::internal_error;
use roc_module::ident::{Lowercase, TagName}; use roc_module::ident::{Lowercase, TagName};
use roc_module::symbol::Symbol; use roc_module::symbol::Symbol;
@ -347,6 +349,8 @@ fn unify_context(subs: &mut Subs, pool: &mut Pool, ctx: Context) -> Outcome {
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
debug_print_unified_types(subs, &ctx, None); debug_print_unified_types(subs, &ctx, None);
// This #[allow] is needed in release builds, where `result` is no longer used.
#[allow(clippy::let_and_return)]
let result = match &ctx.first_desc.content { let result = match &ctx.first_desc.content {
FlexVar(opt_name) => unify_flex(subs, &ctx, opt_name, None, &ctx.second_desc.content), FlexVar(opt_name) => unify_flex(subs, &ctx, opt_name, None, &ctx.second_desc.content),
FlexAbleVar(opt_name, ability) => unify_flex( FlexAbleVar(opt_name, ability) => unify_flex(
@ -473,7 +477,8 @@ fn unify_two_aliases(
subs: &mut Subs, subs: &mut Subs,
pool: &mut Pool, pool: &mut Pool,
ctx: &Context, ctx: &Context,
symbol: Symbol, // _symbol has an underscore because it's unused in --release builds
_symbol: Symbol,
args: AliasVariables, args: AliasVariables,
real_var: Variable, real_var: Variable,
other_args: AliasVariables, other_args: AliasVariables,
@ -513,7 +518,7 @@ fn unify_two_aliases(
outcome outcome
} else { } else {
dbg!(args.len(), other_args.len()); dbg!(args.len(), other_args.len());
mismatch!("{:?}", symbol) mismatch!("{:?}", _symbol)
} }
} }
@ -629,9 +634,10 @@ fn unify_opaque(
outcome outcome
} }
} }
other => { // _other has an underscore because it's unused in --release builds
_other => {
// The type on the left is an opaque, but the one on the right is not! // The type on the left is an opaque, but the one on the right is not!
mismatch!("Cannot unify opaque {:?} with {:?}", symbol, other) mismatch!("Cannot unify opaque {:?} with {:?}", symbol, _other)
} }
} }
} }
@ -668,9 +674,14 @@ fn unify_structure(
} }
outcome outcome
} }
RigidVar(name) => { // _name has an underscore because it's unused in --release builds
RigidVar(_name) => {
// Type mismatch! Rigid can only unify with flex. // Type mismatch! Rigid can only unify with flex.
mismatch!("trying to unify {:?} with rigid var {:?}", &flat_type, name) mismatch!(
"trying to unify {:?} with rigid var {:?}",
&flat_type,
_name
)
} }
RecursionVar { structure, .. } => match flat_type { RecursionVar { structure, .. } => match flat_type {
FlatType::TagUnion(_, _) => { FlatType::TagUnion(_, _) => {
@ -714,7 +725,8 @@ fn unify_structure(
// Unify the two flat types // Unify the two flat types
unify_flat_type(subs, pool, ctx, flat_type, other_flat_type) unify_flat_type(subs, pool, ctx, flat_type, other_flat_type)
} }
Alias(sym, _, real_var, kind) => match kind { // _sym has an underscore because it's unused in --release builds
Alias(_sym, _, real_var, kind) => match kind {
AliasKind::Structural => { AliasKind::Structural => {
// NB: not treating this as a presence constraint seems pivotal! I // NB: not treating this as a presence constraint seems pivotal! I
// can't quite figure out why, but it doesn't seem to impact other types. // can't quite figure out why, but it doesn't seem to impact other types.
@ -724,7 +736,7 @@ fn unify_structure(
mismatch!( mismatch!(
"Cannot unify structure {:?} with opaque {:?}", "Cannot unify structure {:?} with opaque {:?}",
&flat_type, &flat_type,
sym _sym
) )
} }
}, },
@ -1693,12 +1705,13 @@ fn unify_flat_type(
unify_tag_union_new(subs, pool, ctx, tags1, *ext1, *tags2, *ext2, rec) unify_tag_union_new(subs, pool, ctx, tags1, *ext1, *tags2, *ext2, rec)
} }
(other1, other2) => { // these have underscores because they're unused in --release builds
(_other1, _other2) => {
// any other combination is a mismatch // any other combination is a mismatch
mismatch!( mismatch!(
"Trying to unify two flat types that are incompatible: {:?} ~ {:?}", "Trying to unify two flat types that are incompatible: {:?} ~ {:?}",
roc_types::subs::SubsFmtFlatType(other1, subs), roc_types::subs::SubsFmtFlatType(_other1, subs),
roc_types::subs::SubsFmtFlatType(other2, subs) roc_types::subs::SubsFmtFlatType(_other2, subs)
) )
} }
} }
@ -1784,13 +1797,15 @@ fn unify_rigid(
output.must_implement_ability.push(must_implement_ability); output.must_implement_ability.push(must_implement_ability);
output output
} }
(Some(ability), other) => {
// these have underscores because they're unused in --release builds
(Some(_ability), _other) => {
// For now, only allow opaque types with no type variables to implement abilities. // For now, only allow opaque types with no type variables to implement abilities.
mismatch!( mismatch!(
%not_able, ctx.second, ability, %not_able, ctx.second, _ability,
"RigidAble {:?} with non-opaque or opaque with type variables {:?}", "RigidAble {:?} with non-opaque or opaque with type variables {:?}",
ctx.first, ctx.first,
&other &_other
) )
} }
} }
@ -1923,11 +1938,12 @@ fn unify_recursion(
}, },
), ),
Alias(opaque, _, _, AliasKind::Opaque) => { // _opaque has an underscore because it's unused in --release builds
Alias(_opaque, _, _, AliasKind::Opaque) => {
mismatch!( mismatch!(
"RecursionVar {:?} cannot be equal to opaque {:?}", "RecursionVar {:?} cannot be equal to opaque {:?}",
ctx.first, ctx.first,
opaque _opaque
) )
} }