Skip to content

Commit 24beda8

Browse files
committed
Cargo clippy fix
1 parent 8cb5061 commit 24beda8

File tree

6 files changed

+58
-65
lines changed

6 files changed

+58
-65
lines changed

enderpy/src/main.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,7 @@ fn tokenize(file: &PathBuf) -> Result<()> {
7171

7272
fn parse(file: &PathBuf) -> Result<()> {
7373
let source = fs::read_to_string(file)?;
74-
let file_path = match file.to_str() {
75-
Some(path) => path,
76-
None => "",
77-
};
74+
let file_path = file.to_str().unwrap_or("");
7875
let mut parser = Parser::new(source, file_path.into());
7976
let ast = parser.parse();
8077
println!("{:#?}", ast);

parser/src/parser/parser.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl Parser {
7474
if stmt.is_ok() {
7575
body.push(stmt.unwrap());
7676
} else {
77-
self.errors.push(stmt.err().unwrap().into());
77+
self.errors.push(stmt.err().unwrap());
7878
self.bump_any();
7979
}
8080
}
@@ -2870,7 +2870,7 @@ impl Parser {
28702870
.unwrap()),
28712871
};
28722872
self.bump_any();
2873-
Ok(op?)
2873+
op
28742874
}
28752875

28762876
fn parse_keyword_item(&mut self) -> Result<Keyword, ParsingError> {
@@ -3064,7 +3064,7 @@ mod tests {
30643064
use std::fs;
30653065

30663066
use super::*;
3067-
use insta::{assert_debug_snapshot, glob, assert_display_snapshot};
3067+
use insta::{assert_debug_snapshot, glob};
30683068

30693069
#[test]
30703070
fn test_parse_assignment() {

typechecker/src/build.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,7 @@ impl BuildManager {
8686
}
8787

8888
pub fn parse_file(build_source: BuildSource) -> EnderpyFile {
89-
let file_path = match build_source.path.to_str() {
90-
Some(path) => path,
91-
None => "",
92-
};
89+
let file_path = build_source.path.to_str().unwrap_or("");
9390
let mut parser = Parser::new(build_source.source.clone(), file_path.into());
9491
let tree = parser.parse();
9592
EnderpyFile::from(

typechecker/src/semantic_analyzer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use enderpy_python_parser::ast::Expression;
22
use enderpy_python_parser as parser;
3-
use log::{debug};
3+
44
use parser::ast::Statement;
55

66
use crate::{

typechecker/src/type_check/checker.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use enderpy_python_parser as parser;
44

55
use crate::{
66
ast_visitor::TraversalVisitor, settings::Settings, state::State, symbol_table::SymbolTable,
7-
type_check::rules::is_reassignment_valid,
87
};
98

109
use super::{type_evaluator::TypeEvaluator, type_inference::type_check_bin_op, types::PythonType};

typechecker/src/type_check/type_evaluator.rs

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl TypeEvaluator {
4040
let decl = symbol
4141
.declaration_until_position(position);
4242
match decl {
43-
Some(decl) => self.get_type_from_declaration(&decl),
43+
Some(decl) => self.get_type_from_declaration(decl),
4444
None => Ok(PythonType::Unknown),
4545
}
4646
}
@@ -314,207 +314,207 @@ impl TraversalVisitorImmutGeneric<PythonType> for TypeEvaluator {
314314
}
315315

316316
fn visit_import(&self, _i: &ast::Import) -> PythonType {
317-
return PythonType::Unknown;
317+
PythonType::Unknown
318318
}
319319

320320
fn visit_import_from(&self, _i: &ast::ImportFrom) -> PythonType {
321-
return PythonType::Unknown;
321+
PythonType::Unknown
322322
}
323323

324324
fn visit_if(&self, i: &parser::ast::If) -> PythonType {
325-
return PythonType::Unknown;
325+
PythonType::Unknown
326326
}
327327

328328
fn visit_while(&self, w: &parser::ast::While) -> PythonType {
329-
return PythonType::Unknown;
329+
PythonType::Unknown
330330
}
331331

332332
fn visit_for(&self, f: &parser::ast::For) -> PythonType {
333-
return PythonType::Unknown;
333+
PythonType::Unknown
334334
}
335335

336336
fn visit_with(&self, w: &parser::ast::With) -> PythonType {
337-
return PythonType::Unknown;
337+
PythonType::Unknown
338338
}
339339

340340
fn visit_try(&self, t: &parser::ast::Try) -> PythonType {
341-
return PythonType::Unknown;
341+
PythonType::Unknown
342342
}
343343

344344
fn visit_try_star(&self, t: &parser::ast::TryStar) -> PythonType {
345-
return PythonType::Unknown;
345+
PythonType::Unknown
346346
}
347347

348348
fn visit_function_def(&self, f: &parser::ast::FunctionDef) -> PythonType {
349-
return PythonType::Unknown;
349+
PythonType::Unknown
350350
}
351351

352352
fn visit_class_def(&self, c: &parser::ast::ClassDef) -> PythonType {
353-
return PythonType::Unknown;
353+
PythonType::Unknown
354354
}
355355

356356
fn visit_match(&self, m: &parser::ast::Match) -> PythonType {
357-
return PythonType::Unknown;
357+
PythonType::Unknown
358358
}
359359

360360
fn visit_constant(&self, _c: &ast::Constant) -> PythonType {
361-
return PythonType::Unknown;
361+
PythonType::Unknown
362362
}
363363

364364
fn visit_list(&self, _l: &ast::List) -> PythonType {
365-
return PythonType::Unknown;
365+
PythonType::Unknown
366366
}
367367

368368
fn visit_tuple(&self, _t: &ast::Tuple) -> PythonType {
369-
return PythonType::Unknown;
369+
PythonType::Unknown
370370
}
371371

372372
fn visit_dict(&self, _d: &ast::Dict) -> PythonType {
373-
return PythonType::Unknown;
373+
PythonType::Unknown
374374
}
375375

376376
fn visit_set(&self, _s: &ast::Set) -> PythonType {
377-
return PythonType::Unknown;
377+
PythonType::Unknown
378378
}
379379

380380
fn visit_name(&self, _n: &ast::Name) -> PythonType {
381-
return PythonType::Unknown;
381+
PythonType::Unknown
382382
}
383383

384384
fn visit_bool_op(&self, _b: &ast::BoolOperation) -> PythonType {
385-
return PythonType::Unknown;
385+
PythonType::Unknown
386386
}
387387

388388
fn visit_unary_op(&self, _u: &ast::UnaryOperation) -> PythonType {
389-
return PythonType::Unknown;
389+
PythonType::Unknown
390390
}
391391

392392
fn visit_bin_op(&self, _b: &ast::BinOp) -> PythonType {
393-
return PythonType::Unknown;
393+
PythonType::Unknown
394394
}
395395

396396
fn visit_named_expr(&self, _n: &ast::NamedExpression) -> PythonType {
397-
return PythonType::Unknown;
397+
PythonType::Unknown
398398
}
399399

400400
fn visit_yield(&self, _y: &ast::Yield) -> PythonType {
401-
return PythonType::Unknown;
401+
PythonType::Unknown
402402
}
403403

404404
fn visit_yield_from(&self, _y: &ast::YieldFrom) -> PythonType {
405-
return PythonType::Unknown;
405+
PythonType::Unknown
406406
}
407407

408408
fn visit_starred(&self, _s: &ast::Starred) -> PythonType {
409-
return PythonType::Unknown;
409+
PythonType::Unknown
410410
}
411411

412412
fn visit_generator(&self, _g: &ast::Generator) -> PythonType {
413-
return PythonType::Unknown;
413+
PythonType::Unknown
414414
}
415415

416416
fn visit_list_comp(&self, _l: &ast::ListComp) -> PythonType {
417-
return PythonType::Unknown;
417+
PythonType::Unknown
418418
}
419419

420420
fn visit_set_comp(&self, _s: &ast::SetComp) -> PythonType {
421-
return PythonType::Unknown;
421+
PythonType::Unknown
422422
}
423423

424424
fn visit_dict_comp(&self, _d: &ast::DictComp) -> PythonType {
425-
return PythonType::Unknown;
425+
PythonType::Unknown
426426
}
427427

428428
fn visit_attribute(&self, _a: &ast::Attribute) -> PythonType {
429-
return PythonType::Unknown;
429+
PythonType::Unknown
430430
}
431431

432432
fn visit_subscript(&self, _s: &ast::Subscript) -> PythonType {
433-
return PythonType::Unknown;
433+
PythonType::Unknown
434434
}
435435

436436
fn visit_slice(&self, _s: &ast::Slice) -> PythonType {
437-
return PythonType::Unknown;
437+
PythonType::Unknown
438438
}
439439

440440
fn visit_call(&self, _c: &ast::Call) -> PythonType {
441-
return PythonType::Unknown;
441+
PythonType::Unknown
442442
}
443443

444444
fn visit_await(&self, _a: &ast::Await) -> PythonType {
445-
return PythonType::Unknown;
445+
PythonType::Unknown
446446
}
447447

448448
fn visit_compare(&self, _c: &ast::Compare) -> PythonType {
449-
return PythonType::Unknown;
449+
PythonType::Unknown
450450
}
451451

452452
fn visit_lambda(&self, _l: &ast::Lambda) -> PythonType {
453-
return PythonType::Unknown;
453+
PythonType::Unknown
454454
}
455455

456456
fn visit_if_exp(&self, _i: &ast::IfExp) -> PythonType {
457-
return PythonType::Unknown;
457+
PythonType::Unknown
458458
}
459459

460460
fn visit_joined_str(&self, _j: &ast::JoinedStr) -> PythonType {
461-
return PythonType::Unknown;
461+
PythonType::Unknown
462462
}
463463

464464
fn visit_formatted_value(&self, _f: &ast::FormattedValue) -> PythonType {
465-
return PythonType::Unknown;
465+
PythonType::Unknown
466466
}
467467

468468
fn visit_alias(&self, _a: &ast::Alias) -> PythonType {
469-
return PythonType::Unknown;
469+
PythonType::Unknown
470470
}
471471

472472
fn visit_assign(&self, _a: &ast::Assign) -> PythonType {
473-
return PythonType::Unknown;
473+
PythonType::Unknown
474474
}
475475

476476
fn visit_ann_assign(&self, _a: &ast::AnnAssign) -> PythonType {
477-
return PythonType::Unknown;
477+
PythonType::Unknown
478478
}
479479

480480
fn visit_aug_assign(&self, _a: &ast::AugAssign) -> PythonType {
481-
return PythonType::Unknown;
481+
PythonType::Unknown
482482
}
483483

484484
fn visit_assert(&self, _a: &ast::Assert) -> PythonType {
485-
return PythonType::Unknown;
485+
PythonType::Unknown
486486
}
487487

488488
fn visit_pass(&self, _p: &ast::Pass) -> PythonType {
489-
return PythonType::Unknown;
489+
PythonType::Unknown
490490
}
491491

492492
fn visit_delete(&self, _d: &ast::Delete) -> PythonType {
493-
return PythonType::Unknown;
493+
PythonType::Unknown
494494
}
495495

496496
fn visit_return(&self, _r: &ast::Return) -> PythonType {
497-
return PythonType::Unknown;
497+
PythonType::Unknown
498498
}
499499

500500
fn visit_raise(&self, _r: &ast::Raise) -> PythonType {
501-
return PythonType::Unknown;
501+
PythonType::Unknown
502502
}
503503

504504
fn visit_break(&self, _b: &ast::Break) -> PythonType {
505-
return PythonType::Unknown;
505+
PythonType::Unknown
506506
}
507507

508508
fn visit_continue(&self, _c: &ast::Continue) -> PythonType {
509-
return PythonType::Unknown;
509+
PythonType::Unknown
510510
}
511511

512512
fn visit_global(&self, _g: &ast::Global) -> PythonType {
513-
return PythonType::Unknown;
513+
PythonType::Unknown
514514
}
515515

516516
fn visit_nonlocal(&self, _n: &ast::Nonlocal) -> PythonType {
517-
return PythonType::Unknown;
517+
PythonType::Unknown
518518
}
519519
}
520520

0 commit comments

Comments
 (0)