chore: clippy warnings
This commit is contained in:
parent
ac14512706
commit
b3266fb837
|
@ -135,7 +135,7 @@ Find more on the [Aiken's user manual](https://aiken-lang.org).
|
|||
}
|
||||
|
||||
fn write(path: PathBuf, contents: &str) -> miette::Result<()> {
|
||||
let mut f = fs::File::create(&path).into_diagnostic()?;
|
||||
let mut f = fs::File::create(path).into_diagnostic()?;
|
||||
|
||||
f.write_all(contents.as_bytes()).into_diagnostic()?;
|
||||
Ok(())
|
||||
|
|
|
@ -32,7 +32,7 @@ pub fn exec(
|
|||
let mut program = if cbor {
|
||||
let cbor_hex = std::fs::read_to_string(&script).into_diagnostic()?;
|
||||
|
||||
let raw_cbor = hex::decode(&cbor_hex).into_diagnostic()?;
|
||||
let raw_cbor = hex::decode(cbor_hex).into_diagnostic()?;
|
||||
|
||||
let prog = Program::<FakeNamedDeBruijn>::from_cbor(&raw_cbor, &mut Vec::new())
|
||||
.into_diagnostic()?;
|
||||
|
|
|
@ -61,7 +61,7 @@ pub fn exec(
|
|||
format!("{}.flat", input.file_stem().unwrap().to_str().unwrap())
|
||||
};
|
||||
|
||||
fs::write(&out_name, &bytes).into_diagnostic()?;
|
||||
fs::write(out_name, &bytes).into_diagnostic()?;
|
||||
}
|
||||
} else {
|
||||
let cbor = program.to_hex().into_diagnostic()?;
|
||||
|
@ -75,7 +75,7 @@ pub fn exec(
|
|||
format!("{}.cbor", input.file_stem().unwrap().to_str().unwrap())
|
||||
};
|
||||
|
||||
fs::write(&out_name, &cbor).into_diagnostic()?;
|
||||
fs::write(out_name, &cbor).into_diagnostic()?;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ pub fn exec(
|
|||
format!("{}.uplc", input.file_stem().unwrap().to_str().unwrap())
|
||||
};
|
||||
|
||||
fs::write(&out_name, pretty).into_diagnostic()?;
|
||||
fs::write(out_name, pretty).into_diagnostic()?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -84,6 +84,9 @@ impl telemetry::EventListener for Terminal {
|
|||
telemetry::Event::ParsingProjectFiles => {
|
||||
println!("{}", "...Parsing project files".bold().purple());
|
||||
}
|
||||
telemetry::Event::WaitingForBuildDirLock => {
|
||||
println!("{}", "...Waiting for build directory lock".bold().purple());
|
||||
}
|
||||
telemetry::Event::TypeChecking => {
|
||||
println!("{}", "...Type-checking project".bold().purple());
|
||||
}
|
||||
|
|
|
@ -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"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 });
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -8,7 +8,7 @@ pub struct LineNumbers {
|
|||
impl LineNumbers {
|
||||
pub fn new(src: &str) -> Self {
|
||||
Self {
|
||||
length: src.len() as usize,
|
||||
length: src.len(),
|
||||
line_starts: std::iter::once(0)
|
||||
.chain(src.match_indices('\n').map(|(i, _)| i + 1))
|
||||
.collect(),
|
||||
|
@ -19,20 +19,14 @@ impl LineNumbers {
|
|||
pub fn line_number(&self, byte_index: usize) -> usize {
|
||||
self.line_starts
|
||||
.binary_search(&byte_index)
|
||||
.unwrap_or_else(|next_line| next_line - 1) as usize
|
||||
.unwrap_or_else(|next_line| next_line - 1)
|
||||
+ 1
|
||||
}
|
||||
|
||||
// TODO: handle unicode characters that may be more than 1 byte in width
|
||||
pub fn line_and_column_number(&self, byte_index: usize) -> LineColumn {
|
||||
let line = self.line_number(byte_index);
|
||||
let column = byte_index
|
||||
- self
|
||||
.line_starts
|
||||
.get(line as usize - 1)
|
||||
.copied()
|
||||
.unwrap_or_default()
|
||||
+ 1;
|
||||
let column = byte_index - self.line_starts.get(line - 1).copied().unwrap_or_default() + 1;
|
||||
LineColumn { line, column }
|
||||
}
|
||||
|
||||
|
@ -40,7 +34,7 @@ impl LineNumbers {
|
|||
/// 0 indexed line and character to byte index
|
||||
#[allow(dead_code)]
|
||||
pub fn byte_index(&self, line: usize, character: usize) -> usize {
|
||||
match self.line_starts.get((line) as usize) {
|
||||
match self.line_starts.get(line) {
|
||||
Some(line_index) => *line_index + character,
|
||||
None => self.length,
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ where
|
|||
pub fn to_hex(&self) -> Result<String, en::Error> {
|
||||
let bytes = self.to_cbor()?;
|
||||
|
||||
let hex = hex::encode(&bytes);
|
||||
let hex = hex::encode(bytes);
|
||||
|
||||
Ok(hex)
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ peg::parser! {
|
|||
= "(" _* "error" _* ")" { Term::Error }
|
||||
|
||||
rule constant_integer() -> Constant
|
||||
= "integer" _+ i:big_number() { Constant::Integer(i as i128) }
|
||||
= "integer" _+ i:big_number() { Constant::Integer(i) }
|
||||
|
||||
rule constant_bytestring() -> Constant
|
||||
= "bytestring" _+ bs:bytestring() { Constant::ByteString(bs) }
|
||||
|
|
Loading…
Reference in New Issue