Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/project_model/src/cargo_workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl CargoConfig {
UnsetTestCrates::Only(unset_test_crates) => CfgOverrides::Selective(
unset_test_crates
.iter()
.map(|name| name.clone())
.cloned()
.zip(iter::repeat_with(|| {
cfg::CfgDiff::new(Vec::new(), vec![cfg::CfgAtom::Flag("test".into())])
.unwrap()
Expand Down
3 changes: 1 addition & 2 deletions crates/project_model/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,12 @@ fn get_test_json_file<T: DeserializeOwned>(file: &str) -> T {
fixup_paths(&mut json);
return serde_json::from_value(json).unwrap();

fn fixup_paths(val: &mut serde_json::Value) -> () {
fn fixup_paths(val: &mut serde_json::Value) {
match val {
serde_json::Value::String(s) => replace_root(s, true),
serde_json::Value::Array(vals) => vals.iter_mut().for_each(fixup_paths),
serde_json::Value::Object(kvals) => kvals.values_mut().for_each(fixup_paths),
serde_json::Value::Null | serde_json::Value::Bool(_) | serde_json::Value::Number(_) => {
()
}
}
}
Expand Down
46 changes: 22 additions & 24 deletions crates/project_model/src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ impl ProjectWorkspace {
Some(rustc_dir) => Some({
let meta = CargoWorkspace::fetch_metadata(&rustc_dir, config, progress)
.with_context(|| {
format!("Failed to read Cargo metadata for Rust sources")
"Failed to read Cargo metadata for Rust sources".to_string()
})?;
CargoWorkspace::new(meta)
}),
Expand Down Expand Up @@ -328,12 +328,12 @@ impl ProjectWorkspace {
}
PackageRoot { is_local, include, exclude }
})
.chain(sysroot.into_iter().map(|sysroot| PackageRoot {
.chain(sysroot.iter().map(|sysroot| PackageRoot {
is_local: false,
include: vec![sysroot.root().to_path_buf()],
exclude: Vec::new(),
}))
.chain(rustc.into_iter().flat_map(|rustc| {
.chain(rustc.iter().flat_map(|rustc| {
rustc.packages().map(move |krate| PackageRoot {
is_local: false,
include: vec![rustc[krate].manifest.parent().to_path_buf()],
Expand All @@ -343,7 +343,7 @@ impl ProjectWorkspace {
.collect()
}
ProjectWorkspace::DetachedFiles { files, sysroot, .. } => files
.into_iter()
.iter()
.map(|detached_file| PackageRoot {
is_local: true,
include: vec![detached_file.clone()],
Expand Down Expand Up @@ -553,7 +553,7 @@ fn cargo_to_crate_graph(
&mut crate_graph,
&cargo[pkg],
build_scripts.outputs.get(pkg),
&cfg_options,
cfg_options,
load_proc_macro,
file_id,
&cargo[tgt].name,
Expand Down Expand Up @@ -815,17 +815,15 @@ fn add_target_crate_root(
.map(|feat| CfgFlag::KeyValue { key: "feature".into(), value: feat.0.into() }),
);

let crate_id = crate_graph.add_crate_root(
crate_graph.add_crate_root(
file_id,
edition,
Some(display_name),
cfg_options,
potential_cfg_options,
env,
proc_macro,
);

crate_id
)
}

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

let manifest_dir = package.manifest.parent();
env.set("CARGO_MANIFEST_DIR".into(), manifest_dir.as_os_str().to_string_lossy().into_owned());
env.set("CARGO_MANIFEST_DIR", manifest_dir.as_os_str().to_string_lossy().into_owned());

// Not always right, but works for common cases.
env.set("CARGO".into(), "cargo".into());
env.set("CARGO", "cargo".into());

env.set("CARGO_PKG_VERSION".into(), package.version.to_string());
env.set("CARGO_PKG_VERSION_MAJOR".into(), package.version.major.to_string());
env.set("CARGO_PKG_VERSION_MINOR".into(), package.version.minor.to_string());
env.set("CARGO_PKG_VERSION_PATCH".into(), package.version.patch.to_string());
env.set("CARGO_PKG_VERSION_PRE".into(), package.version.pre.to_string());
env.set("CARGO_PKG_VERSION", package.version.to_string());
env.set("CARGO_PKG_VERSION_MAJOR", package.version.major.to_string());
env.set("CARGO_PKG_VERSION_MINOR", package.version.minor.to_string());
env.set("CARGO_PKG_VERSION_PATCH", package.version.patch.to_string());
env.set("CARGO_PKG_VERSION_PRE", package.version.pre.to_string());

env.set("CARGO_PKG_AUTHORS".into(), String::new());
env.set("CARGO_PKG_AUTHORS", String::new());

env.set("CARGO_PKG_NAME".into(), package.name.clone());
env.set("CARGO_PKG_NAME", package.name.clone());
// FIXME: This isn't really correct (a package can have many crates with different names), but
// it's better than leaving the variable unset.
env.set("CARGO_CRATE_NAME".into(), CrateName::normalize_dashes(&package.name).to_string());
env.set("CARGO_PKG_DESCRIPTION".into(), String::new());
env.set("CARGO_PKG_HOMEPAGE".into(), String::new());
env.set("CARGO_PKG_REPOSITORY".into(), String::new());
env.set("CARGO_PKG_LICENSE".into(), String::new());
env.set("CARGO_CRATE_NAME", CrateName::normalize_dashes(&package.name).to_string());
env.set("CARGO_PKG_DESCRIPTION", String::new());
env.set("CARGO_PKG_HOMEPAGE", String::new());
env.set("CARGO_PKG_REPOSITORY", String::new());
env.set("CARGO_PKG_LICENSE", String::new());

env.set("CARGO_PKG_LICENSE_FILE".into(), String::new());
env.set("CARGO_PKG_LICENSE_FILE", String::new());
}
2 changes: 1 addition & 1 deletion crates/syntax/src/algo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ pub fn diff(from: &SyntaxNode, to: &SyntaxNode) -> TreeDiff {
look_ahead_scratch.push(rhs_ele.clone());
let mut rhs_children_clone = rhs_children.clone();
let mut insert = false;
while let Some(rhs_child) = rhs_children_clone.next() {
for rhs_child in &mut rhs_children_clone {
if syntax_element_eq(&lhs_ele, &rhs_child) {
cov_mark::hit!(diff_insertions);
insert = true;
Expand Down
2 changes: 1 addition & 1 deletion crates/syntax/src/ast/make.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ pub fn param(pat: ast::Pat, ty: ast::Type) -> ast::Param {
}

pub fn self_param() -> ast::SelfParam {
ast_from_text(&format!("fn f(&self) {{ }}"))
ast_from_text("fn f(&self) { }")
}

pub fn ret_type(ty: ast::Type) -> ast::RetType {
Expand Down
1 change: 0 additions & 1 deletion crates/test_utils/src/fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ impl MiniCore {
panic!("unused minicore flag: {:?}", flag);
}
}
format!("{}", buf);
buf
}
}
Expand Down