Auto merge of #16560 - lnicola:sysroot-metadata, r=Veykril

internal: Set channel override when querying the sysroot metadata

This is pretty hard to discover, and makes the setting useless, we should probably enable it for now.

CC #16486
This commit is contained in:
bors 2024-02-14 08:04:34 +00:00
commit efe68e3f78
2 changed files with 9 additions and 3 deletions

View File

@ -254,10 +254,18 @@ pub fn load(
.ok()?; .ok()?;
let current_dir = let current_dir =
AbsPathBuf::try_from(&*format!("{sysroot_src_dir}/sysroot")).ok()?; AbsPathBuf::try_from(&*format!("{sysroot_src_dir}/sysroot")).ok()?;
let mut cargo_config = CargoConfig::default();
// the sysroot uses `public-dependency`, so we make cargo think it's a nightly
cargo_config.extra_env.insert(
"__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS".to_owned(),
"nightly".to_owned(),
);
let res = CargoWorkspace::fetch_metadata( let res = CargoWorkspace::fetch_metadata(
&sysroot_cargo_toml, &sysroot_cargo_toml,
&current_dir, &current_dir,
&CargoConfig::default(), &cargo_config,
None, None,
&|_| (), &|_| (),
) )

View File

@ -117,8 +117,6 @@ fn measure_analysis_stats_path(
sh, sh,
"./target/release/rust-analyzer -q analysis-stats {path} --query-sysroot-metadata" "./target/release/rust-analyzer -q analysis-stats {path} --query-sysroot-metadata"
) )
// the sysroot uses `public-dependency`, so we make cargo think it's a nightly
.env("__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS", "nightly")
.read()?; .read()?;
for (metric, value, unit) in parse_metrics(&output) { for (metric, value, unit) in parse_metrics(&output) {
self.report(&format!("analysis-stats/{name}/{metric}"), value, unit.into()); self.report(&format!("analysis-stats/{name}/{metric}"), value, unit.into());