chore: clippy warnings

This commit is contained in:
rvcas
2022-12-15 22:05:49 -05:00
committed by Lucas
parent ac14512706
commit b3266fb837
12 changed files with 24 additions and 30 deletions

View File

@@ -24,13 +24,10 @@ pub struct Comment<'a> {
impl<'a> From<(&Span, &'a str)> for Comment<'a> {
fn from(src: (&Span, &'a str)) -> Comment<'a> {
let start = src.0.start;
let end = src.0.end as usize;
let end = src.0.end;
Comment {
start,
content: src
.1
.get(start as usize..end)
.expect("From span to comment"),
content: src.1.get(start..end).expect("From span to comment"),
}
}
}

View File

@@ -509,7 +509,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
.push(Warning::NoFieldsRecordUpdate { location });
}
if arguments.len() == field_map.arity as usize {
if arguments.len() == field_map.arity {
self.environment
.warnings
.push(Warning::AllFieldsRecordUpdate { location });

View File

@@ -44,11 +44,11 @@ impl FieldMap {
let mut seen_labels = std::collections::HashSet::new();
let mut unknown_labels = Vec::new();
if self.arity as usize != args.len() {
if self.arity != args.len() {
return Err(Error::IncorrectArity {
labels: self.incorrect_arity_labels(args),
location,
expected: self.arity as usize,
expected: self.arity,
given: args.len(),
});
}
@@ -103,7 +103,7 @@ impl FieldMap {
};
// If the argument is already in the right place
if position as usize == i {
if position == i {
seen_labels.insert(label.clone());
i += 1;
@@ -117,7 +117,7 @@ impl FieldMap {
seen_labels.insert(label.clone());
args.swap(position as usize, i);
args.swap(position, i);
}
}

View File

@@ -438,13 +438,13 @@ impl<'a, 'b> PatternTyper<'a, 'b> {
if with_spread {
// Using the spread operator when you have already provided variables for all of the
// record's fields throws an error
if pattern_args.len() == field_map.arity as usize {
if pattern_args.len() == field_map.arity {
return Err(Error::UnnecessarySpreadOperator {
location: Span {
start: location.end - 3,
end: location.end - 1,
},
arity: field_map.arity as usize,
arity: field_map.arity,
});
}
@@ -465,7 +465,7 @@ impl<'a, 'b> PatternTyper<'a, 'b> {
.position(|a| a.label.is_some())
.unwrap_or(pattern_args.len());
while pattern_args.len() < field_map.arity as usize {
while pattern_args.len() < field_map.arity {
let new_call_arg = CallArg {
value: Pattern::Discard {
name: "_".to_string(),