Skip to content

Commit

Permalink
fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
liquidev committed Oct 30, 2023
1 parent 5de5ca8 commit 1d0b7d8
Show file tree
Hide file tree
Showing 9 changed files with 300 additions and 207 deletions.
477 changes: 284 additions & 193 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/hl/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ impl Engine {
identifier: &str,
) -> Gc<DispatchTable> {
let fields = identifier.split('+').enumerate().map(|(index, name)| (name, index));
let type_name = if identifier.len() == 0 {
let type_name = if identifier.is_empty() {
String::from("Record{}")
} else {
format!("Record{{{}}}", identifier.replace("+", ", "))
format!("Record{{{}}}", identifier.replace('+', ", "))
};
self.corelib
.define_record(fields, TypeBuilder::new(type_name))
Expand Down
4 changes: 1 addition & 3 deletions src/hl/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,7 @@ pub mod into_value {
impl EngineUse for DoesNotUseEngine {
type EngineState<'a> = ();

fn change_type<'a>(_: &Library, _: &mut Memory) -> Self::EngineState<'static> {
()
}
fn change_type<'a>(_: &Library, _: &mut Memory) -> Self::EngineState<'static> {}
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/ll/bytecode/library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl Library {
);
self.builtin_dtables.records.push(Rc::new(RecordType {
dtable,
identifier: Rc::clone(&identifier),
identifier: Rc::clone(identifier),
field_count: if identifier.len() > 0 {
identifier.chars().filter(|&c| c == '+').count() + 1
} else {
Expand All @@ -112,7 +112,7 @@ pub fn make_record_identifier<'a>(fields: impl Iterator<Item = &'a str>) -> Rc<s
let mut identifier = fields.fold(String::new(), |mut a, b| {
a.reserve(b.len() + 1);
a.push_str(b);
a.push_str("+");
a.push('+');
a
});
identifier.pop();
Expand Down
9 changes: 7 additions & 2 deletions src/ll/codegen/tuples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl<'e> CodeGenerator<'e> {
let identifier = make_record_identifier(fields.iter().map(|&rc| rc.deref()));
let record_type_index = self
.library
.get_or_generate_record(&mut self.env, &mut self.gc, &identifier)
.get_or_generate_record(self.env, self.gc, &identifier)
.map_err(|_| ast.error(node, LanguageErrorKind::TooManyRecords))?;

self.chunk.emit((Opcode::CreateRecord, record_type_index.to_opr24()));
Expand All @@ -90,7 +90,12 @@ impl<'e> CodeGenerator<'e> {
let is_non_exhaustive =
!pairs.is_empty() && ast.kind(*pairs.last().unwrap()) == NodeKind::Rest;

fn destructure_member(generator: &mut CodeGenerator, ast: &Ast, key: NodeId, value: NodeId) -> Result<(), LanguageError> {
fn destructure_member(
generator: &mut CodeGenerator,
ast: &Ast,
key: NodeId,
value: NodeId,
) -> Result<(), LanguageError> {
let pattern = if value == NodeId::EMPTY { key } else { value };
if ast.kind(pattern) == NodeKind::DiscardPattern {
generator.chunk.emit(Opcode::Discard);
Expand Down
2 changes: 1 addition & 1 deletion src/ll/gc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ impl<T> GcRaw<T> {

impl<T> Clone for GcRaw<T> {
fn clone(&self) -> Self {
Self(self.0)
*self
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/ll/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ impl Parser {
match &token.kind {
TokenKind::Eof => return Err(self.error(&token, LanguageErrorKind::UnexpectedEof)),
kind if is_end(kind) => {
return Ok(self.lexer.next_token()?);
return self.lexer.next_token();
}
_ => (),
}
Expand Down
2 changes: 1 addition & 1 deletion src/ll/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl RawValue {
.to_owned()
.into(),
ValueKind::UserData => unsafe {
self.0.get_raw_user_data_unchecked().get().type_name().into()
self.0.get_raw_user_data_unchecked().get().type_name()
},
}
}
Expand Down
3 changes: 1 addition & 2 deletions xtask/src/codegen/function_variants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,7 @@ fn generate_variant(
SelfMode::Disabled => None,
SelfMode::Enabled { .. } => Some("arg_self".to_string()),
};
let variable_list: Vec<_> =
self_variable.into_iter().chain(variable_list.into_iter()).collect();
let variable_list: Vec<_> = self_variable.into_iter().chain(variable_list).collect();

let args = variable_list.join(", ");
write!(
Expand Down

0 comments on commit 1d0b7d8

Please sign in to comment.