Skip to content

Commit 3fb2cd2

Browse files
committed
autofix remaining perf findings
1 parent 196650d commit 3fb2cd2

File tree

7 files changed

+12
-11
lines changed

7 files changed

+12
-11
lines changed

crates/hir-ty/src/mir/lower.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2070,8 +2070,8 @@ pub fn mir_body_for_closure_query(
20702070
prev_projs
20712071
.lookup(&store)
20722072
.iter()
2073-
.cloned()
2074-
.skip(it.0.place.projections.len()),
2073+
.skip(it.0.place.projections.len())
2074+
.cloned(),
20752075
);
20762076
p.projection = store.intern(next_projs.into());
20772077
}

crates/hir/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1854,7 +1854,7 @@ impl DefWithBody {
18541854
let local = Local { parent: self.into(), binding_id };
18551855
match (need_mut, local.is_mut(db)) {
18561856
(mir::MutabilityReason::Unused, _) => {
1857-
let should_ignore = matches!(body[binding_id].name.as_str(), Some(it) if it.starts_with("_"));
1857+
let should_ignore = matches!(body[binding_id].name.as_str(), Some(it) if it.starts_with('_'));
18581858
if !should_ignore {
18591859
acc.push(UnusedVariable { local }.into())
18601860
}
@@ -1879,7 +1879,7 @@ impl DefWithBody {
18791879
}
18801880
(mir::MutabilityReason::Not, true) => {
18811881
if !infer.mutated_bindings_in_closure.contains(&binding_id) {
1882-
let should_ignore = matches!(body[binding_id].name.as_str(), Some(it) if it.starts_with("_"));
1882+
let should_ignore = matches!(body[binding_id].name.as_str(), Some(it) if it.starts_with('_'));
18831883
if !should_ignore {
18841884
acc.push(UnusedMut { local }.into())
18851885
}

crates/ide-assists/src/handlers/convert_nested_function_to_closure.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ pub(crate) fn convert_nested_function_to_closure(
4949
target,
5050
|edit| {
5151
let params = &param_list.syntax().text().to_string();
52-
let params = params.strip_prefix("(").unwrap_or(params);
53-
let params = params.strip_suffix(")").unwrap_or(params);
52+
let params = params.strip_prefix('(').unwrap_or(params);
53+
let params = params.strip_suffix(')').unwrap_or(params);
5454

5555
let mut body = body.to_string();
5656
if !has_semicolon(&function) {

crates/ide-assists/src/handlers/extract_variable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ pub(crate) fn extract_variable(acc: &mut Assists, ctx: &AssistContext<'_>) -> Op
112112
let insert_place = edit.make_syntax_mut(place);
113113

114114
// Adjust ws to insert depending on if this is all inline or on separate lines
115-
let trailing_ws = if prev_ws.is_some_and(|it| it.text().starts_with("\n")) {
115+
let trailing_ws = if prev_ws.is_some_and(|it| it.text().starts_with('\n')) {
116116
format!("\n{indent_to}")
117117
} else {
118118
format!(" ")

crates/ide-assists/src/handlers/remove_parentheses.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub(crate) fn remove_parentheses(acc: &mut Assists, ctx: &AssistContext<'_>) ->
4343
let prev_token = parens.syntax().first_token().and_then(|it| it.prev_token());
4444
let need_to_add_ws = match prev_token {
4545
Some(it) => {
46-
let tokens = vec![T![&], T![!], T!['('], T!['['], T!['{']];
46+
let tokens = [T![&], T![!], T!['('], T!['['], T!['{']];
4747
it.kind() != SyntaxKind::WHITESPACE && !tokens.contains(&it.kind())
4848
}
4949
None => false,

crates/ide-diagnostics/src/tests.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ fn check_nth_fix(nth: usize, ra_fixture_before: &str, ra_fixture_after: &str) {
4242
super::diagnostics(&db, &conf, &AssistResolveStrategy::All, file_position.file_id)
4343
.pop()
4444
.expect("no diagnostics");
45-
let fix =
46-
&diagnostic.fixes.expect(&format!("{:?} diagnostic misses fixes", diagnostic.code))[nth];
45+
let fix = &diagnostic
46+
.fixes
47+
.unwrap_or_else(|| panic!("{:?} diagnostic misses fixes", diagnostic.code))[nth];
4748
let actual = {
4849
let source_change = fix.source_change.as_ref().unwrap();
4950
let file_id = *source_change.source_file_edits.keys().next().unwrap();

crates/project-model/src/workspace.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1277,7 +1277,7 @@ fn add_target_crate_root(
12771277
inject_cargo_env(pkg, &mut env);
12781278
if let Ok(cname) = String::from_str(cargo_name) {
12791279
// CARGO_CRATE_NAME is the name of the Cargo target with - converted to _, such as the name of the library, binary, example, integration test, or benchmark.
1280-
env.set("CARGO_CRATE_NAME", cname.replace("-", "_"));
1280+
env.set("CARGO_CRATE_NAME", cname.replace('-', "_"));
12811281
}
12821282

12831283
if let Some(envs) = build_data.map(|it| &it.envs) {

0 commit comments

Comments
 (0)