Skip to content

Commit

Permalink
Merge pull request #6008 from roc-lang/clippy-1.74
Browse files Browse the repository at this point in the history
Clippy 1.74
  • Loading branch information
Anton-4 authored Dec 25, 2023
2 parents 0bd15a5 + a4fd42b commit 613c6c4
Show file tree
Hide file tree
Showing 24 changed files with 933 additions and 4,378 deletions.
1 change: 0 additions & 1 deletion crates/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,6 @@ pub fn test(matches: &ArgMatches, triple: Triple) -> io::Result<i32> {

let arena = &arena;
let target = &triple;
let opt_level = opt_level;
let target_info = TargetInfo::from(target);
// TODO may need to determine this dynamically based on dev builds.
let function_kind = FunctionKind::LambdaSet;
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ fn main() -> io::Result<()> {
let triple = target.to_triple();
let function_kind = FunctionKind::LambdaSet;
let (platform_path, stub_lib, stub_dll_symbols) = roc_linker::generate_stub_lib(
&input_path,
input_path,
RocCacheDir::Persistent(cache::roc_cache_dir().as_path()),
&triple,
function_kind,
Expand Down
2 changes: 1 addition & 1 deletion crates/compiler/can/src/copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,7 @@ fn deep_copy_type_vars<C: CopyEnv>(
}
for uls_index in unspecialized {
let Uls(var, _, _) = env.source()[uls_index];
descend_var!(var);
let _ignored = descend_var!(var);
}
let new_ambient_function = descend_var!(ambient_function);

Expand Down
19 changes: 15 additions & 4 deletions crates/compiler/can/src/debug/pretty_print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,25 @@ fn print_declarations_help<'a>(
f.intersperse(defs, f.hardline().append(f.hardline()))
}

fn always_true() -> bool {
true
}

macro_rules! maybe_paren {
($paren_if_above:expr, $my_prec:expr, $doc:expr) => {
maybe_paren!($paren_if_above, $my_prec, || true, $doc)
maybe_paren!($paren_if_above, $my_prec, always_true, $doc)
};
($paren_if_above:expr, $my_prec:expr, $extra_cond:expr, $doc:expr) => {
if $my_prec > $paren_if_above && $extra_cond() {
$doc.parens().group()
} else {
'blk: {
if $my_prec > $paren_if_above {
#[allow(clippy::redundant_closure_call)]
let extra_cond = $extra_cond();

if extra_cond {
break 'blk $doc.parens().group();
}
}

$doc
}
};
Expand Down
142 changes: 71 additions & 71 deletions crates/compiler/can/tests/test_can.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,7 @@ mod test_can {
// );
//}

//// UNUSED
// // UNUSED

//#[test]
//fn mutual_unused_circular_vars() {
Expand Down Expand Up @@ -1483,7 +1483,7 @@ mod test_can {
// );
//}

//// ASSIGNMENT REORDERING
// // ASSIGNMENT REORDERING

//#[test]
//fn reorder_assignments() {
Expand Down Expand Up @@ -1623,7 +1623,7 @@ mod test_can {
// }
//}

//// CIRCULAR ASSIGNMENT
// // CIRCULAR ASSIGNMENT

//#[test]
//fn circular_assignment() {
Expand Down Expand Up @@ -1663,74 +1663,74 @@ mod test_can {
// assert_eq!(problems, vec![]);
//}

//// TODO verify that Apply handles output.references.calls correctly

//// UNSUPPORTED PATTERNS

//// TODO verify that in closures and assignments, you can't assign to int/string/underscore/etc

//// OPERATOR PRECEDENCE

//// fn parse_with_precedence(input: &str) -> Result<(Expr, &str), easy::Errors<char, &str, IndentablePosition>> {
//// parse_without_loc(input)
//// .map(|(expr, remaining)| (expr::apply_precedence_and_associativity(loc(expr)).unwrap().value, remaining))
//// }

//// #[test]
//// fn two_operator_precedence() {
//// assert_eq!(
//// parse_with_precedence("x + y * 5"),
//// Ok((BinOp(
//// loc_box(var("x")),
//// loc(Plus),
//// loc_box(
//// BinOp(
//// loc_box(var("y")),
//// loc(Star),
//// loc_box(Int(5))
//// )
//// ),
//// ),
//// ""))
//// );

//// assert_eq!(
//// parse_with_precedence("x * y + 5"),
//// Ok((BinOp(
//// loc_box(
//// BinOp(
//// loc_box(var("x")),
//// loc(Star),
//// loc_box(var("y")),
//// )
//// ),
//// loc(Plus),
//// loc_box(Int(5))
//// ),
//// ""))
//// );
//// }

//// #[test]
//// fn compare_and() {
//// assert_eq!(
//// parse_with_precedence("x > 1 || True"),
//// Ok((BinOp(
//// loc_box(
//// BinOp(
//// loc_box(var("x")),
//// loc(GreaterThan),
//// loc_box(Int(1))
//// )
//// ),
//// loc(Or),
//// loc_box(ApplyVariant(vname("True"), None))
//// ),
//// ""))
//// );
//// }

//// HELPERS
// // TODO verify that Apply handles output.references.calls correctly

// // UNSUPPORTED PATTERNS

// // TODO verify that in closures and assignments, you can't assign to int/string/underscore/etc

// // OPERATOR PRECEDENCE

// // fn parse_with_precedence(input: &str) -> Result<(Expr, &str), easy::Errors<char, &str, IndentablePosition>> {
// // parse_without_loc(input)
// // .map(|(expr, remaining)| (expr::apply_precedence_and_associativity(loc(expr)).unwrap().value, remaining))
// // }

// // #[test]
// // fn two_operator_precedence() {
// // assert_eq!(
// // parse_with_precedence("x + y * 5"),
// // Ok((BinOp(
// // loc_box(var("x")),
// // loc(Plus),
// // loc_box(
// // BinOp(
// // loc_box(var("y")),
// // loc(Star),
// // loc_box(Int(5))
// // )
// // ),
// // ),
// // ""))
// // );

// // assert_eq!(
// // parse_with_precedence("x * y + 5"),
// // Ok((BinOp(
// // loc_box(
// // BinOp(
// // loc_box(var("x")),
// // loc(Star),
// // loc_box(var("y")),
// // )
// // ),
// // loc(Plus),
// // loc_box(Int(5))
// // ),
// // ""))
// // );
// // }

// // #[test]
// // fn compare_and() {
// // assert_eq!(
// // parse_with_precedence("x > 1 || True"),
// // Ok((BinOp(
// // loc_box(
// // BinOp(
// // loc_box(var("x")),
// // loc(GreaterThan),
// // loc_box(Int(1))
// // )
// // ),
// // loc(Or),
// // loc_box(ApplyVariant(vname("True"), None))
// // ),
// // ""))
// // );
// // }

// // HELPERS

//#[test]
//fn sort_cyclic_idents() {
Expand Down
2 changes: 1 addition & 1 deletion crates/compiler/derive/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ fn hash_newtype_tag_union(
let hasher_var = synth_var(env.subs, Content::FlexAbleVar(None, Subs::AB_HASHER));

// A
let tag_name = tag_name;
// let tag_name = tag_name;
// t1 .. tn
let payload_vars = payload_variables;
// x11 .. x1n
Expand Down
2 changes: 1 addition & 1 deletion crates/compiler/gen_dev/src/object_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ fn generate_wrapper<'a, B: Backend<'a>>(
let (proc_data, offset) = backend.build_wrapped_jmp();
let proc_offset = output.add_symbol_data(proc_id, text_section, proc_data, 16);

let name = wraps.as_str().as_bytes();
let name = wraps.as_bytes();
// If the symbol is an undefined zig builtin, we need to add it here.
let symbol = Symbol {
name: name.to_vec(),
Expand Down
1 change: 0 additions & 1 deletion crates/compiler/gen_llvm/src/llvm/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4104,7 +4104,6 @@ fn const_i128<'ctx>(env: &Env<'_, 'ctx, '_>, value: i128) -> IntValue<'ctx> {

fn const_u128<'ctx>(env: &Env<'_, 'ctx, '_>, value: u128) -> IntValue<'ctx> {
// truncate the lower 64 bits
let value = value;
let a = value as u64;

// get the upper 64 bits
Expand Down
4 changes: 2 additions & 2 deletions crates/compiler/mono/src/inc_dec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1047,8 +1047,8 @@ fn insert_refcount_operations_binding<'a>(

closure_env_layout: _,

/// update mode of the higher order lowlevel itself
update_mode: _,
// update mode of the higher order lowlevel itself
update_mode: _,

passed_function,
}) => {
Expand Down
8 changes: 6 additions & 2 deletions crates/compiler/mono/src/ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3085,7 +3085,9 @@ fn specialize_host_specializations<'a>(
let from_app = offset_variable(from_app);
let index = specialize_external_help(env, procs, layout_cache, lambda_name, from_app);

let Some(from_platform) = opt_from_platform else { continue };
let Some(from_platform) = opt_from_platform else {
continue;
};

// now run the lambda set numbering scheme
let hels = find_lambda_sets(env.arena, env.subs, from_platform);
Expand Down Expand Up @@ -3146,7 +3148,9 @@ fn specialize_host_specializations<'a>(
};

let in_progress = &mut procs.specialized.procedures[index.0];
let InProgressProc::Done(proc) = in_progress else { unreachable!() };
let InProgressProc::Done(proc) = in_progress else {
unreachable!()
};

procs.host_exposed_lambda_sets.push((proc.name, key, hels));
}
Expand Down
2 changes: 1 addition & 1 deletion crates/compiler/mono/src/layout/intern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ pub trait LayoutInterner<'a>: Sized {
pub struct InLayout<'a>(usize, std::marker::PhantomData<&'a ()>);
impl<'a> Clone for InLayout<'a> {
fn clone(&self) -> Self {
Self(self.0, Default::default())
*self
}
}

Expand Down
5 changes: 2 additions & 3 deletions crates/compiler/parse/src/src64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl<'a> Src64<'a> {
}

// Safety: we got capacity by rounding up to the nearest 64B
let dest = unsafe { allocate_chunks(arena, capacity)? }.as_ptr() as *mut u8;
let dest = unsafe { allocate_chunks(arena, capacity)? }.as_ptr();

// Safety: `dest` has a length of `capacity`, which has been rounded up to a multiple of 64.
unsafe {
Expand Down Expand Up @@ -264,8 +264,7 @@ impl<'a> Src64<'a> {

// Safety: bytes_ptr came from an allocation of `capacity` bytes, it's had
// newlines filled at the end, and `file_size` bytes written over the rest.
let bytes =
unsafe { core::slice::from_raw_parts_mut(buf.as_ptr() as *mut u8, capacity) };
let bytes = unsafe { core::slice::from_raw_parts_mut(buf.as_ptr(), capacity) };

Ok(Self { bytes })
}
Expand Down
1 change: 1 addition & 0 deletions crates/compiler/solve/src/to_var.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ pub(crate) fn type_to_var_help(
)
.expect("extension var could not be seen as a tag union");

#[allow(clippy::never_loop)]
for _ in it {
unreachable!("we assert that the ext var is empty; otherwise we'd already know it was a tag union!");
}
Expand Down
11 changes: 2 additions & 9 deletions crates/compiler/types/src/subs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,22 +566,15 @@ impl<T> Copy for SubsIndex<T> {}

impl<T> Clone for SubsIndex<T> {
fn clone(&self) -> Self {
Self {
index: self.index,
_marker: self._marker,
}
*self
}
}

impl<T> Copy for SubsSlice<T> {}

impl<T> Clone for SubsSlice<T> {
fn clone(&self) -> Self {
Self {
start: self.start,
length: self.length,
_marker: self._marker,
}
*self
}
}

Expand Down
10 changes: 7 additions & 3 deletions crates/compiler/types/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1300,17 +1300,21 @@ mod debug_types {
Arg,
}

fn always_true() -> bool {
true
}

macro_rules! maybe_paren {
($paren_if_above:expr, $my_prec:expr, $doc:expr) => {
maybe_paren!($paren_if_above, $my_prec, || true, $doc)
maybe_paren!($paren_if_above, $my_prec, always_true, $doc)
};
($paren_if_above:expr, $my_prec:expr, $extra_cond:expr, $doc:expr) => {
($paren_if_above:expr, $my_prec:expr, $extra_cond:expr, $doc:expr) => {{
if $my_prec > $paren_if_above && $extra_cond() {
$doc.parens().group()
} else {
$doc
}
};
}};
}

fn typ<'a>(
Expand Down
Loading

0 comments on commit 613c6c4

Please sign in to comment.