mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
Cleanup unstable flags handling
This commit is contained in:
parent
df85aac1d4
commit
b398bc6af7
@ -62,7 +62,10 @@ impl BuildScriptOutput {
|
|||||||
self.cfgs.is_empty()
|
self.cfgs.is_empty()
|
||||||
&& self.envs.is_empty()
|
&& self.envs.is_empty()
|
||||||
&& self.out_dir.is_none()
|
&& self.out_dir.is_none()
|
||||||
&& self.proc_macro_dylib_path == ProcMacroDylibPath::NotBuilt
|
&& matches!(
|
||||||
|
self.proc_macro_dylib_path,
|
||||||
|
ProcMacroDylibPath::NotBuilt | ProcMacroDylibPath::NotProcMacro
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -462,10 +465,10 @@ impl WorkspaceBuildScripts {
|
|||||||
let lockfile_path =
|
let lockfile_path =
|
||||||
<_ as AsRef<Utf8Path>>::as_ref(manifest_path).with_extension("lock");
|
<_ as AsRef<Utf8Path>>::as_ref(manifest_path).with_extension("lock");
|
||||||
if let Some((temp_dir, target_lockfile)) = make_lockfile_copy(&lockfile_path) {
|
if let Some((temp_dir, target_lockfile)) = make_lockfile_copy(&lockfile_path) {
|
||||||
|
requires_unstable_options = true;
|
||||||
temp_dir_guard = Some(temp_dir);
|
temp_dir_guard = Some(temp_dir);
|
||||||
cmd.arg("--lockfile-path");
|
cmd.arg("--lockfile-path");
|
||||||
cmd.arg(target_lockfile.as_str());
|
cmd.arg(target_lockfile.as_str());
|
||||||
requires_unstable_options = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
match &config.features {
|
match &config.features {
|
||||||
@ -499,7 +502,7 @@ impl WorkspaceBuildScripts {
|
|||||||
// available in current toolchain's cargo, use it to build compile time deps only.
|
// available in current toolchain's cargo, use it to build compile time deps only.
|
||||||
const COMP_TIME_DEPS_MIN_TOOLCHAIN_VERSION: semver::Version = semver::Version {
|
const COMP_TIME_DEPS_MIN_TOOLCHAIN_VERSION: semver::Version = semver::Version {
|
||||||
major: 1,
|
major: 1,
|
||||||
minor: 189,
|
minor: 89,
|
||||||
patch: 0,
|
patch: 0,
|
||||||
pre: semver::Prerelease::EMPTY,
|
pre: semver::Prerelease::EMPTY,
|
||||||
build: semver::BuildMetadata::EMPTY,
|
build: semver::BuildMetadata::EMPTY,
|
||||||
|
@ -601,7 +601,6 @@ impl FetchMetadata {
|
|||||||
}
|
}
|
||||||
command.current_dir(current_dir);
|
command.current_dir(current_dir);
|
||||||
|
|
||||||
let mut needs_nightly = false;
|
|
||||||
let mut other_options = vec![];
|
let mut other_options = vec![];
|
||||||
// cargo metadata only supports a subset of flags of what cargo usually accepts, and usually
|
// cargo metadata only supports a subset of flags of what cargo usually accepts, and usually
|
||||||
// the only relevant flags for metadata here are unstable ones, so we pass those along
|
// the only relevant flags for metadata here are unstable ones, so we pass those along
|
||||||
@ -611,7 +610,6 @@ impl FetchMetadata {
|
|||||||
if arg == "-Z"
|
if arg == "-Z"
|
||||||
&& let Some(arg) = extra_args.next()
|
&& let Some(arg) = extra_args.next()
|
||||||
{
|
{
|
||||||
needs_nightly = true;
|
|
||||||
other_options.push("-Z".to_owned());
|
other_options.push("-Z".to_owned());
|
||||||
other_options.push(arg.to_owned());
|
other_options.push(arg.to_owned());
|
||||||
}
|
}
|
||||||
@ -619,7 +617,6 @@ impl FetchMetadata {
|
|||||||
|
|
||||||
let mut lockfile_path = None;
|
let mut lockfile_path = None;
|
||||||
if cargo_toml.is_rust_manifest() {
|
if cargo_toml.is_rust_manifest() {
|
||||||
needs_nightly = true;
|
|
||||||
other_options.push("-Zscript".to_owned());
|
other_options.push("-Zscript".to_owned());
|
||||||
} else if config
|
} else if config
|
||||||
.toolchain_version
|
.toolchain_version
|
||||||
@ -637,10 +634,6 @@ impl FetchMetadata {
|
|||||||
|
|
||||||
command.other_options(other_options.clone());
|
command.other_options(other_options.clone());
|
||||||
|
|
||||||
if needs_nightly {
|
|
||||||
command.env("__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS", "nightly");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pre-fetch basic metadata using `--no-deps`, which:
|
// Pre-fetch basic metadata using `--no-deps`, which:
|
||||||
// - avoids fetching registries like crates.io,
|
// - avoids fetching registries like crates.io,
|
||||||
// - skips dependency resolution and does not modify lockfiles,
|
// - skips dependency resolution and does not modify lockfiles,
|
||||||
@ -710,7 +703,7 @@ impl FetchMetadata {
|
|||||||
other_options.push(target_lockfile.to_string());
|
other_options.push(target_lockfile.to_string());
|
||||||
using_lockfile_copy = true;
|
using_lockfile_copy = true;
|
||||||
}
|
}
|
||||||
if using_lockfile_copy {
|
if using_lockfile_copy || other_options.iter().any(|it| it.starts_with("-Z")) {
|
||||||
command.env("__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS", "nightly");
|
command.env("__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS", "nightly");
|
||||||
other_options.push("-Zunstable-options".to_owned());
|
other_options.push("-Zunstable-options".to_owned());
|
||||||
}
|
}
|
||||||
|
@ -1316,14 +1316,17 @@ fn cargo_to_crate_graph(
|
|||||||
public_deps.add_to_crate_graph(crate_graph, from);
|
public_deps.add_to_crate_graph(crate_graph, from);
|
||||||
|
|
||||||
// Add dep edge of all targets to the package's lib target
|
// Add dep edge of all targets to the package's lib target
|
||||||
if let Some((to, name)) = lib_tgt.clone() {
|
if let Some((to, name)) = lib_tgt.clone()
|
||||||
match to != from && kind != TargetKind::BuildScript {
|
&& to != from
|
||||||
true => {
|
&& kind != TargetKind::BuildScript
|
||||||
let name = CrateName::normalize_dashes(&name);
|
{
|
||||||
add_dep(crate_graph, from, name, to);
|
// (build script can not depend on its library target)
|
||||||
}
|
|
||||||
false => (),
|
// For root projects with dashes in their name,
|
||||||
}
|
// cargo metadata does not do any normalization,
|
||||||
|
// so we do it ourselves currently
|
||||||
|
let name = CrateName::normalize_dashes(&name);
|
||||||
|
add_dep(crate_graph, from, name, to);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user