mirror of
https://github.com/roc-lang/roc.git
synced 2024-09-19 06:40:20 +03:00
Merge pull request #3834 from roc-lang/rust-1.63-clippy
rust 1.63 clippy
This commit is contained in:
commit
3ca9202e3b
@ -55,8 +55,7 @@ fn flatten_directories(files: std::vec::Vec<PathBuf>) -> std::vec::Vec<PathBuf>
|
||||
}
|
||||
|
||||
fn is_roc_file(path: &Path) -> bool {
|
||||
let ext = path.extension().and_then(OsStr::to_str);
|
||||
return matches!(ext, Some("roc"));
|
||||
matches!(path.extension().and_then(OsStr::to_str), Some("roc"))
|
||||
}
|
||||
|
||||
pub fn format(files: std::vec::Vec<PathBuf>, mode: FormatMode) -> Result<(), String> {
|
||||
|
@ -114,7 +114,7 @@ pub fn new_assign_mn(
|
||||
|
||||
pub fn new_module_name_mn_id(mn_ids: Vec<MarkNodeId>, mark_node_pool: &mut SlowPool) -> MarkNodeId {
|
||||
if mn_ids.len() == 1 {
|
||||
*mn_ids.get(0).unwrap() // safe because we checked the length before
|
||||
*mn_ids.first().unwrap() // safe because we checked the length before
|
||||
} else {
|
||||
let nested_node = make_nested_mn(mn_ids, 0);
|
||||
mark_node_pool.add(nested_node)
|
||||
|
@ -202,7 +202,7 @@ pub fn constrain_expr(
|
||||
let field_var = field.var;
|
||||
let loc_field_expr = &field.loc_expr;
|
||||
let (field_type, field_con) =
|
||||
constrain_field(constraints, env, field_var, &*loc_field_expr);
|
||||
constrain_field(constraints, env, field_var, loc_field_expr);
|
||||
|
||||
field_vars.push(field_var);
|
||||
field_types.insert(label.clone(), RecordField::Required(field_type));
|
||||
|
@ -451,7 +451,7 @@ fn collect_ctors(matrix: &RefPatternMatrix) -> MutMap<TagId, Union> {
|
||||
let mut ctors = MutMap::default();
|
||||
|
||||
for row in matrix {
|
||||
if let Some(Ctor(union, id, _)) = row.get(row.len() - 1) {
|
||||
if let Some(Ctor(union, id, _)) = row.last() {
|
||||
ctors.insert(*id, union.clone());
|
||||
}
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ macro_rules! run_jit_function_dynamic_type {
|
||||
// first field is a char pointer (to the error message)
|
||||
// read value, and transmute to a pointer
|
||||
let ptr_as_int = *(result as *const u64).offset(1);
|
||||
let ptr = std::mem::transmute::<u64, *mut c_char>(ptr_as_int);
|
||||
let ptr = ptr_as_int as *mut c_char;
|
||||
|
||||
// make CString (null-terminated)
|
||||
let raw = CString::from_raw(ptr);
|
||||
|
@ -293,7 +293,7 @@ fn chomp_accessor(buffer: &[u8], pos: Position) -> Result<&str, BadIdent> {
|
||||
/// a `@Token` opaque
|
||||
fn chomp_opaque_ref(buffer: &[u8], pos: Position) -> Result<&str, BadIdent> {
|
||||
// assumes the leading `@` has NOT been chomped already
|
||||
debug_assert_eq!(buffer.get(0), Some(&b'@'));
|
||||
debug_assert_eq!(buffer.first(), Some(&b'@'));
|
||||
use encode_unicode::CharExt;
|
||||
|
||||
let bad_ident = BadIdent::BadOpaqueRef;
|
||||
|
@ -14,7 +14,7 @@ pub enum NumLiteral<'a> {
|
||||
|
||||
pub fn positive_number_literal<'a>() -> impl Parser<'a, NumLiteral<'a>, ENumber> {
|
||||
move |_arena, state: State<'a>| {
|
||||
match state.bytes().get(0) {
|
||||
match state.bytes().first() {
|
||||
Some(first_byte) if (*first_byte as char).is_ascii_digit() => {
|
||||
parse_number_base(false, state.bytes(), state)
|
||||
}
|
||||
@ -28,7 +28,7 @@ pub fn positive_number_literal<'a>() -> impl Parser<'a, NumLiteral<'a>, ENumber>
|
||||
|
||||
pub fn number_literal<'a>() -> impl Parser<'a, NumLiteral<'a>, ENumber> {
|
||||
move |_arena, state: State<'a>| {
|
||||
match state.bytes().get(0) {
|
||||
match state.bytes().first() {
|
||||
Some(first_byte) if *first_byte == b'-' => {
|
||||
// drop the minus
|
||||
parse_number_base(true, &state.bytes()[1..], state)
|
||||
@ -92,7 +92,7 @@ fn chomp_number_dec<'a>(
|
||||
return Err((Progress::NoProgress, ENumber::End, state));
|
||||
}
|
||||
|
||||
if !bytes.get(0).copied().unwrap_or_default().is_ascii_digit() {
|
||||
if !bytes.first().copied().unwrap_or_default().is_ascii_digit() {
|
||||
// we're probably actually looking at unary negation here
|
||||
return Err((Progress::NoProgress, ENumber::End, state));
|
||||
}
|
||||
@ -117,7 +117,7 @@ fn chomp_number(mut bytes: &[u8]) -> (bool, usize) {
|
||||
let start_bytes_len = bytes.len();
|
||||
let mut is_float = false;
|
||||
|
||||
while let Some(byte) = bytes.get(0) {
|
||||
while let Some(byte) = bytes.first() {
|
||||
match byte {
|
||||
b'.' => {
|
||||
// skip, fix multiple `.`s in canonicalization
|
||||
|
@ -1441,7 +1441,7 @@ where
|
||||
{
|
||||
debug_assert_ne!(word, b'\n');
|
||||
|
||||
move |_arena: &'a Bump, state: State<'a>| match state.bytes().get(0) {
|
||||
move |_arena: &'a Bump, state: State<'a>| match state.bytes().first() {
|
||||
Some(x) if *x == word => {
|
||||
let state = state.advance(1);
|
||||
Ok((MadeProgress, (), state))
|
||||
|
@ -1892,7 +1892,7 @@ pub fn surgery(
|
||||
let out_gen_start = Instant::now();
|
||||
|
||||
let mut offset = 0;
|
||||
let output = match target.binary_format {
|
||||
match target.binary_format {
|
||||
target_lexicon::BinaryFormat::Elf => {
|
||||
surgery_elf(verbose, &md, &mut exec_mmap, &mut offset, app_obj)
|
||||
}
|
||||
@ -1961,8 +1961,6 @@ pub fn surgery(
|
||||
);
|
||||
report_timing("Total", total_duration);
|
||||
}
|
||||
|
||||
output
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
|
@ -62,7 +62,7 @@ pub fn get_values<'a>(
|
||||
captures_niche: CapturesNiche::no_niche(),
|
||||
};
|
||||
|
||||
let element = jit_to_ast(
|
||||
jit_to_ast(
|
||||
arena,
|
||||
app,
|
||||
"expect_repl_main_fn",
|
||||
@ -71,9 +71,7 @@ pub fn get_values<'a>(
|
||||
subs,
|
||||
interns,
|
||||
target_info,
|
||||
)?;
|
||||
|
||||
element
|
||||
)?
|
||||
};
|
||||
|
||||
result.push(expr);
|
||||
|
Loading…
Reference in New Issue
Block a user