Gave Clippy some love

This commit is contained in:
Emmanuel BENOîT 2023-01-17 07:42:36 +01:00
parent 3861062565
commit c36bcf5bc9
4 changed files with 6 additions and 9 deletions

View file

@ -105,7 +105,7 @@ fn dump_statement(dumper: &mut Dumper, stmt: &StmtNode) {
if !decl.members.is_empty() {
dumper.depth += 1;
for member in decl.members.iter() {
dump_member(dumper, &member);
dump_member(dumper, member);
}
dumper.depth -= 1;
dumper.add_line(String::default());

View file

@ -161,7 +161,7 @@ where
{
let mut cls = class.clone();
loop {
if let Some(member) = cls.borrow().members.get(&mb_key) {
if let Some(member) = cls.borrow().members.get(mb_key) {
return Some(f(member));
}
let nclr = if let Some(sc) = &cls.borrow().superclass {

View file

@ -282,10 +282,7 @@ fn on_class_decl(es: &mut InterpreterState, decl: &ClassDecl) -> InterpreterResu
return error(&superclass.token, "superclass must be a class");
};
let mut sub_env = InterpreterState::create_child(es);
sub_env
.environment
.borrow_mut()
.set("super", sc_value.clone());
sub_env.environment.borrow_mut().set("super", sc_value);
Class::new(
decl.name.lexeme.clone(),
sc_ref,
@ -584,7 +581,7 @@ fn on_super(itpr_state: &mut InterpreterState, super_expr: &SuperExpr) -> Interp
)?;
Ok(obj_ref
.with_property_carrier(
|inst| inst.get_super(itpr_state, &super_expr, distance),
|inst| inst.get_super(itpr_state, super_expr, distance),
|| panic!("'this' didn't contain an instance"),
)?
.into())

View file

@ -228,7 +228,7 @@ impl Parser {
let superclass = match self.expect(&[TokenType::Less]) {
None => None,
Some(_) => Some(VariableExpr {
token: self.consume_identifier("expected superclass name")?.clone(),
token: self.consume_identifier("expected superclass name")?,
id: self.make_id(),
}),
};
@ -336,7 +336,7 @@ impl Parser {
/// block := "{" block_contents
/// ```
fn parse_block(&mut self, err_string: &str) -> Result<StmtNode, SloxError> {
self.consume(&TokenType::LeftBrace, &err_string)?;
self.consume(&TokenType::LeftBrace, err_string)?;
self.loop_state.push(LoopParsingState::None);
let result = self.parse_block_contents();
self.loop_state.pop();