Skip to content

Commit 06ea89d

Browse files
bors[bot]Veykril
andauthored
Merge #10290
10290: minor: Simplify r=Veykril a=Veykril bors r+ Co-authored-by: Lukas Wirth <[email protected]>
2 parents b02027d + 3987bf5 commit 06ea89d

File tree

6 files changed

+26
-30
lines changed

6 files changed

+26
-30
lines changed

crates/project_model/src/cargo_workspace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl CargoConfig {
106106
UnsetTestCrates::Only(unset_test_crates) => CfgOverrides::Selective(
107107
unset_test_crates
108108
.iter()
109-
.map(|name| name.clone())
109+
.cloned()
110110
.zip(iter::repeat_with(|| {
111111
cfg::CfgDiff::new(Vec::new(), vec![cfg::CfgAtom::Flag("test".into())])
112112
.unwrap()

crates/project_model/src/tests.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,12 @@ fn get_test_json_file<T: DeserializeOwned>(file: &str) -> T {
4747
fixup_paths(&mut json);
4848
return serde_json::from_value(json).unwrap();
4949

50-
fn fixup_paths(val: &mut serde_json::Value) -> () {
50+
fn fixup_paths(val: &mut serde_json::Value) {
5151
match val {
5252
serde_json::Value::String(s) => replace_root(s, true),
5353
serde_json::Value::Array(vals) => vals.iter_mut().for_each(fixup_paths),
5454
serde_json::Value::Object(kvals) => kvals.values_mut().for_each(fixup_paths),
5555
serde_json::Value::Null | serde_json::Value::Bool(_) | serde_json::Value::Number(_) => {
56-
()
5756
}
5857
}
5958
}

crates/project_model/src/workspace.rs

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ impl ProjectWorkspace {
189189
Some(rustc_dir) => Some({
190190
let meta = CargoWorkspace::fetch_metadata(&rustc_dir, config, progress)
191191
.with_context(|| {
192-
format!("Failed to read Cargo metadata for Rust sources")
192+
"Failed to read Cargo metadata for Rust sources".to_string()
193193
})?;
194194
CargoWorkspace::new(meta)
195195
}),
@@ -328,12 +328,12 @@ impl ProjectWorkspace {
328328
}
329329
PackageRoot { is_local, include, exclude }
330330
})
331-
.chain(sysroot.into_iter().map(|sysroot| PackageRoot {
331+
.chain(sysroot.iter().map(|sysroot| PackageRoot {
332332
is_local: false,
333333
include: vec![sysroot.root().to_path_buf()],
334334
exclude: Vec::new(),
335335
}))
336-
.chain(rustc.into_iter().flat_map(|rustc| {
336+
.chain(rustc.iter().flat_map(|rustc| {
337337
rustc.packages().map(move |krate| PackageRoot {
338338
is_local: false,
339339
include: vec![rustc[krate].manifest.parent().to_path_buf()],
@@ -343,7 +343,7 @@ impl ProjectWorkspace {
343343
.collect()
344344
}
345345
ProjectWorkspace::DetachedFiles { files, sysroot, .. } => files
346-
.into_iter()
346+
.iter()
347347
.map(|detached_file| PackageRoot {
348348
is_local: true,
349349
include: vec![detached_file.clone()],
@@ -553,7 +553,7 @@ fn cargo_to_crate_graph(
553553
&mut crate_graph,
554554
&cargo[pkg],
555555
build_scripts.outputs.get(pkg),
556-
&cfg_options,
556+
cfg_options,
557557
load_proc_macro,
558558
file_id,
559559
&cargo[tgt].name,
@@ -815,17 +815,15 @@ fn add_target_crate_root(
815815
.map(|feat| CfgFlag::KeyValue { key: "feature".into(), value: feat.0.into() }),
816816
);
817817

818-
let crate_id = crate_graph.add_crate_root(
818+
crate_graph.add_crate_root(
819819
file_id,
820820
edition,
821821
Some(display_name),
822822
cfg_options,
823823
potential_cfg_options,
824824
env,
825825
proc_macro,
826-
);
827-
828-
crate_id
826+
)
829827
}
830828

831829
fn sysroot_to_crate_graph(
@@ -893,27 +891,27 @@ fn inject_cargo_env(package: &PackageData, env: &mut Env) {
893891
// CARGO_BIN_NAME, CARGO_BIN_EXE_<name>
894892

895893
let manifest_dir = package.manifest.parent();
896-
env.set("CARGO_MANIFEST_DIR".into(), manifest_dir.as_os_str().to_string_lossy().into_owned());
894+
env.set("CARGO_MANIFEST_DIR", manifest_dir.as_os_str().to_string_lossy().into_owned());
897895

898896
// Not always right, but works for common cases.
899-
env.set("CARGO".into(), "cargo".into());
897+
env.set("CARGO", "cargo".into());
900898

901-
env.set("CARGO_PKG_VERSION".into(), package.version.to_string());
902-
env.set("CARGO_PKG_VERSION_MAJOR".into(), package.version.major.to_string());
903-
env.set("CARGO_PKG_VERSION_MINOR".into(), package.version.minor.to_string());
904-
env.set("CARGO_PKG_VERSION_PATCH".into(), package.version.patch.to_string());
905-
env.set("CARGO_PKG_VERSION_PRE".into(), package.version.pre.to_string());
899+
env.set("CARGO_PKG_VERSION", package.version.to_string());
900+
env.set("CARGO_PKG_VERSION_MAJOR", package.version.major.to_string());
901+
env.set("CARGO_PKG_VERSION_MINOR", package.version.minor.to_string());
902+
env.set("CARGO_PKG_VERSION_PATCH", package.version.patch.to_string());
903+
env.set("CARGO_PKG_VERSION_PRE", package.version.pre.to_string());
906904

907-
env.set("CARGO_PKG_AUTHORS".into(), String::new());
905+
env.set("CARGO_PKG_AUTHORS", String::new());
908906

909-
env.set("CARGO_PKG_NAME".into(), package.name.clone());
907+
env.set("CARGO_PKG_NAME", package.name.clone());
910908
// FIXME: This isn't really correct (a package can have many crates with different names), but
911909
// it's better than leaving the variable unset.
912-
env.set("CARGO_CRATE_NAME".into(), CrateName::normalize_dashes(&package.name).to_string());
913-
env.set("CARGO_PKG_DESCRIPTION".into(), String::new());
914-
env.set("CARGO_PKG_HOMEPAGE".into(), String::new());
915-
env.set("CARGO_PKG_REPOSITORY".into(), String::new());
916-
env.set("CARGO_PKG_LICENSE".into(), String::new());
910+
env.set("CARGO_CRATE_NAME", CrateName::normalize_dashes(&package.name).to_string());
911+
env.set("CARGO_PKG_DESCRIPTION", String::new());
912+
env.set("CARGO_PKG_HOMEPAGE", String::new());
913+
env.set("CARGO_PKG_REPOSITORY", String::new());
914+
env.set("CARGO_PKG_LICENSE", String::new());
917915

918-
env.set("CARGO_PKG_LICENSE_FILE".into(), String::new());
916+
env.set("CARGO_PKG_LICENSE_FILE", String::new());
919917
}

crates/syntax/src/algo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ pub fn diff(from: &SyntaxNode, to: &SyntaxNode) -> TreeDiff {
212212
look_ahead_scratch.push(rhs_ele.clone());
213213
let mut rhs_children_clone = rhs_children.clone();
214214
let mut insert = false;
215-
while let Some(rhs_child) = rhs_children_clone.next() {
215+
for rhs_child in &mut rhs_children_clone {
216216
if syntax_element_eq(&lhs_ele, &rhs_child) {
217217
cov_mark::hit!(diff_insertions);
218218
insert = true;

crates/syntax/src/ast/make.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ pub fn param(pat: ast::Pat, ty: ast::Type) -> ast::Param {
556556
}
557557

558558
pub fn self_param() -> ast::SelfParam {
559-
ast_from_text(&format!("fn f(&self) {{ }}"))
559+
ast_from_text("fn f(&self) { }")
560560
}
561561

562562
pub fn ret_type(ty: ast::Type) -> ast::RetType {

crates/test_utils/src/fixture.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,6 @@ impl MiniCore {
346346
panic!("unused minicore flag: {:?}", flag);
347347
}
348348
}
349-
format!("{}", buf);
350349
buf
351350
}
352351
}

0 commit comments

Comments
 (0)