Skip to content

Commit 0e31c89

Browse files
committed
clippy fixes
1 parent cbea0ff commit 0e31c89

File tree

4 files changed

+26
-27
lines changed

4 files changed

+26
-27
lines changed

crates/language-server/Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.PHONY: clippy
2+
clippy:
3+
cargo clippy -- -D warnings -A clippy::upper-case-acronyms -A clippy::large-enum-variant

crates/language-server/src/goto.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ mod tests {
205205
for cursor in &cursors {
206206
let resolved_path = goto_enclosing_path(db, top_mod, *cursor);
207207

208-
match resolved_path {
209-
Some(path) => match path {
208+
if let Some(path) = resolved_path {
209+
match path {
210210
EarlyResolvedPath::Full(bucket) => {
211211
let path = bucket
212212
.iter()
@@ -222,9 +222,8 @@ mod tests {
222222
let path = res.pretty_path(db).unwrap();
223223
cursor_path_map.insert(*cursor, path);
224224
}
225-
},
226-
None => {}
227-
};
225+
}
226+
}
228227
}
229228

230229
let result = format!(

crates/language-server/src/handlers/request.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,18 @@ pub fn handle_hover(
5050

5151
let ingot_info: Option<String> = {
5252
let ingot_type = match ingot {
53-
Some(ingot) => match ingot.kind(&mut state.db) {
53+
Some(ingot) => match ingot.kind(&state.db) {
5454
IngotKind::StandAlone => None,
5555
IngotKind::Local => Some("Local ingot"),
5656
IngotKind::External => Some("External ingot"),
5757
IngotKind::Std => Some("Standard library"),
5858
},
5959
None => Some("No ingot information available"),
6060
};
61-
let ingot_file_count = ingot.unwrap().files(&mut state.db).len();
61+
let ingot_file_count = ingot.unwrap().files(&state.db).len();
6262
let ingot_path = ingot
6363
.unwrap()
64-
.path(&mut state.db)
64+
.path(&state.db)
6565
.strip_prefix(&state.workspace.root_path.clone().unwrap_or("".into()))
6666
.ok();
6767

crates/language-server/src/workspace.rs

+16-19
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,8 @@ impl IngotFileContext for Workspace {
322322
path: &str,
323323
) -> Option<InputIngot> {
324324
let ctx = get_containing_ingot(&mut self.ingot_contexts, path);
325-
if ctx.is_some() {
326-
Some(ctx.unwrap().ingot_from_file_path(db, path).unwrap())
325+
if let Some(ctx) = ctx {
326+
Some(ctx.ingot_from_file_path(db, path).unwrap())
327327
} else {
328328
self.standalone_ingot_context.ingot_from_file_path(db, path)
329329
}
@@ -335,8 +335,8 @@ impl IngotFileContext for Workspace {
335335
path: &str,
336336
) -> Option<TopLevelMod> {
337337
let ctx = get_containing_ingot(&mut self.ingot_contexts, path);
338-
if ctx.is_some() {
339-
Some(ctx.unwrap().top_mod_from_file_path(db, path).unwrap())
338+
if let Some(ctx) = ctx {
339+
Some(ctx.top_mod_from_file_path(db, path).unwrap())
340340
} else {
341341
self.standalone_ingot_context
342342
.top_mod_from_file_path(db, path)
@@ -451,10 +451,10 @@ mod tests {
451451
let ingot = ctx.ingot_from_file_path(&mut db, file_path);
452452
assert!(ingot.is_some());
453453
assert_eq!(
454-
ingot.unwrap().kind(&mut db),
454+
ingot.unwrap().kind(&db),
455455
common::input::IngotKind::StandAlone
456456
);
457-
assert_eq!(ingot.unwrap(), file.unwrap().ingot(&mut db));
457+
assert_eq!(ingot.unwrap(), file.unwrap().ingot(&db));
458458
}
459459

460460
#[test]
@@ -473,7 +473,7 @@ mod tests {
473473

474474
let _ingot_context_ingot = {
475475
let ingot_context = workspace.ingot_context_from_config_path(
476-
&mut crate::db::LanguageServerDatabase::default(),
476+
&crate::db::LanguageServerDatabase::default(),
477477
config_path,
478478
);
479479

@@ -505,7 +505,7 @@ mod tests {
505505
let mut db = crate::db::LanguageServerDatabase::default();
506506

507507
let ingot_context_ingot = {
508-
let ingot_context = workspace.ingot_context_from_config_path(&mut db, config_path);
508+
let ingot_context = workspace.ingot_context_from_config_path(&db, config_path);
509509

510510
assert!(ingot_context.is_some());
511511
ingot_context.map(|ctx| ctx.ingot)
@@ -518,16 +518,13 @@ mod tests {
518518
let ingot = workspace.ingot_from_file_path(&mut db, file_path);
519519
assert!(ingot.is_some());
520520

521-
assert_eq!(file.map(|f| f.ingot(&mut db)).unwrap(), ingot.unwrap());
521+
assert_eq!(file.map(|f| f.ingot(&db)).unwrap(), ingot.unwrap());
522522

523523
assert_eq!(
524-
ingot_context_ingot.unwrap().kind(&mut db),
525-
common::input::IngotKind::Local
526-
);
527-
assert_eq!(
528-
ingot.unwrap().kind(&mut db),
524+
ingot_context_ingot.unwrap().kind(&db),
529525
common::input::IngotKind::Local
530526
);
527+
assert_eq!(ingot.unwrap().kind(&db), common::input::IngotKind::Local);
531528
assert_eq!(ingot_context_ingot.unwrap(), ingot.unwrap());
532529
}
533530

@@ -549,7 +546,7 @@ mod tests {
549546
let fe_source_path = ingot_base_dir.join("src/main.fe");
550547
let input = workspace.input_from_file_path(&mut db, fe_source_path.to_str().unwrap());
551548
assert!(input.is_some());
552-
assert!(input.unwrap().ingot(&mut db).kind(&mut db) == common::input::IngotKind::Local);
549+
assert!(input.unwrap().ingot(&db).kind(&db) == common::input::IngotKind::Local);
553550
}
554551

555552
#[test]
@@ -621,7 +618,7 @@ mod tests {
621618
let contents = std::fs::read_to_string(&file).unwrap();
622619
let file = foo_context.input_from_file_path(&mut db, &file).unwrap();
623620

624-
assert!(*file.text(&mut db) == contents);
621+
assert!(*file.text(&db) == contents);
625622
}
626623
}
627624

@@ -640,15 +637,15 @@ mod tests {
640637
.unwrap();
641638

642639
assert_eq!(
643-
dangling_file.ingot(&db).kind(&mut db),
640+
dangling_file.ingot(&db).kind(&db),
644641
common::input::IngotKind::StandAlone
645642
);
646643

647644
// TODO: make it easier to go both ways between an ingot root path and its config path
648645
let ingot_paths = workspace
649646
.ingot_contexts
650647
.values()
651-
.map(|ctx| format!("{}{}", ctx.ingot.path(&mut db), FE_CONFIG_SUFFIX))
648+
.map(|ctx| format!("{}{}", ctx.ingot.path(&db), FE_CONFIG_SUFFIX))
652649
.collect::<Vec<String>>();
653650

654651
for ingot_path in ingot_paths {
@@ -661,7 +658,7 @@ mod tests {
661658
.unwrap();
662659

663660
assert_eq!(
664-
non_dangling_input.ingot(&db).kind(&mut db),
661+
non_dangling_input.ingot(&db).kind(&db),
665662
common::input::IngotKind::Local
666663
);
667664
}

0 commit comments

Comments
 (0)