From b098d1340728c85f40fa7d16da72824307bfef8c Mon Sep 17 00:00:00 2001 From: Anton-4 <17049058+Anton-4@users.noreply.github.com> Date: Sat, 20 Feb 2021 20:00:37 +0100 Subject: [PATCH] new rustfmt and clippy --- compiler/mono/src/decision_tree.rs | 6 +++++- compiler/mono/src/layout.rs | 5 ++++- compiler/reporting/src/error/type.rs | 24 ++++++++++++++++++++---- compiler/types/src/types.rs | 19 +++++++++---------- 4 files changed, 38 insertions(+), 16 deletions(-) diff --git a/compiler/mono/src/decision_tree.rs b/compiler/mono/src/decision_tree.rs index 4e2388101a..5a1f03a49a 100644 --- a/compiler/mono/src/decision_tree.rs +++ b/compiler/mono/src/decision_tree.rs @@ -229,7 +229,11 @@ fn flatten<'a>( tag_name, layout, } if union.alternatives.len() == 1 - && !matches!(layout, Layout::Union(UnionLayout::NullableWrapped { .. })| Layout::Union(UnionLayout::NullableUnwrapped { .. })) => + && !matches!( + layout, + Layout::Union(UnionLayout::NullableWrapped { .. }) + | Layout::Union(UnionLayout::NullableUnwrapped { .. }) + ) => { // TODO ^ do we need to check that guard.is_none() here? diff --git a/compiler/mono/src/layout.rs b/compiler/mono/src/layout.rs index 94883e2152..daa69c67e8 100644 --- a/compiler/mono/src/layout.rs +++ b/compiler/mono/src/layout.rs @@ -643,7 +643,10 @@ impl<'a> Layout<'a> { Union(variant) => { use UnionLayout::*; - matches!(variant, Recursive(_)| NullableWrapped { .. } | NullableUnwrapped { .. }) + matches!( + variant, + Recursive(_) | NullableWrapped { .. } | NullableUnwrapped { .. } + ) } RecursivePointer => true, diff --git a/compiler/reporting/src/error/type.rs b/compiler/reporting/src/error/type.rs index 2ed9c4c437..b2249518d5 100644 --- a/compiler/reporting/src/error/type.rs +++ b/compiler/reporting/src/error/type.rs @@ -1628,10 +1628,18 @@ fn to_diff<'b>( ErrorType::Alias(Symbol::NUM_INT, _, _) => true, ErrorType::Type(Symbol::NUM_NUM, args) => { - matches!( &args.get(0) ,Some(ErrorType::Type(Symbol::NUM_INTEGER, _)) | Some(ErrorType::Alias(Symbol::NUM_INTEGER, _, _))) + matches!( + &args.get(0), + Some(ErrorType::Type(Symbol::NUM_INTEGER, _)) + | Some(ErrorType::Alias(Symbol::NUM_INTEGER, _, _)) + ) } ErrorType::Alias(Symbol::NUM_NUM, args, _) => { - matches!(&args.get(0), Some((_, ErrorType::Type(Symbol::NUM_INTEGER, _))) | Some((_, ErrorType::Alias(Symbol::NUM_INTEGER, _, _)))) + matches!( + &args.get(0), + Some((_, ErrorType::Type(Symbol::NUM_INTEGER, _))) + | Some((_, ErrorType::Alias(Symbol::NUM_INTEGER, _, _))) + ) } _ => false, }; @@ -1640,11 +1648,19 @@ fn to_diff<'b>( ErrorType::Alias(Symbol::NUM_FLOAT, _, _) => true, ErrorType::Type(Symbol::NUM_NUM, args) => { - matches!(&args.get(0), Some(ErrorType::Type(Symbol::NUM_FLOATINGPOINT, _)) | Some(ErrorType::Alias(Symbol::NUM_FLOATINGPOINT, _, _))) + matches!( + &args.get(0), + Some(ErrorType::Type(Symbol::NUM_FLOATINGPOINT, _)) + | Some(ErrorType::Alias(Symbol::NUM_FLOATINGPOINT, _, _)) + ) } ErrorType::Alias(Symbol::NUM_NUM, args, _) => { - matches!(&args.get(0), Some((_, ErrorType::Type(Symbol::NUM_FLOATINGPOINT, _))) | Some((_, ErrorType::Alias(Symbol::NUM_FLOATINGPOINT, _, _)))) + matches!( + &args.get(0), + Some((_, ErrorType::Type(Symbol::NUM_FLOATINGPOINT, _))) + | Some((_, ErrorType::Alias(Symbol::NUM_FLOATINGPOINT, _, _))) + ) } _ => false, }; diff --git a/compiler/types/src/types.rs b/compiler/types/src/types.rs index b3ecff2252..81b0cf8965 100644 --- a/compiler/types/src/types.rs +++ b/compiler/types/src/types.rs @@ -648,17 +648,16 @@ impl Type { // attribute on the recursion variable must match the uniqueness of the whole tag // union. We enforce that here. - if let Some(rec_uvar) = find_rec_var_uniqueness(base_type, aliases) { - if let Bool::Container(unbound_cvar, mvars1) = rec_uvar { - if let Type::Boolean(Bool::Container(bound_cvar, mvars2)) = uniqueness_type - { - debug_assert!(mvars1.is_empty()); - debug_assert!(mvars2.is_empty()); + if let Some(Bool::Container(unbound_cvar, mvars1)) = + find_rec_var_uniqueness(base_type, aliases) + { + if let Type::Boolean(Bool::Container(bound_cvar, mvars2)) = uniqueness_type { + debug_assert!(mvars1.is_empty()); + debug_assert!(mvars2.is_empty()); - let mut substitution = ImMap::default(); - substitution.insert(unbound_cvar, Type::Variable(*bound_cvar)); - base_type.substitute(&substitution); - } + let mut substitution = ImMap::default(); + substitution.insert(unbound_cvar, Type::Variable(*bound_cvar)); + base_type.substitute(&substitution); } } }