mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
Change diesel compatibility messages
Diesel 1.4.8 fixes the critical behaviour. This commit changes the corresponding messages for `cargo fix` and normal builds to promt the user to just update the diesel version to fix the corresponding compilation errors.
This commit is contained in:
parent
9a28ac83c9
commit
09374c56d1
@ -62,6 +62,7 @@ use cargo_util::ProcessBuilder;
|
|||||||
use crossbeam_utils::thread::Scope;
|
use crossbeam_utils::thread::Scope;
|
||||||
use jobserver::{Acquired, Client, HelperThread};
|
use jobserver::{Acquired, Client, HelperThread};
|
||||||
use log::{debug, info, trace};
|
use log::{debug, info, trace};
|
||||||
|
use semver::Version;
|
||||||
|
|
||||||
use super::context::OutputFile;
|
use super::context::OutputFile;
|
||||||
use super::job::{
|
use super::job::{
|
||||||
@ -74,9 +75,8 @@ use crate::core::compiler::future_incompat::{
|
|||||||
FutureBreakageItem, FutureIncompatReportPackage, OnDiskReports,
|
FutureBreakageItem, FutureIncompatReportPackage, OnDiskReports,
|
||||||
};
|
};
|
||||||
use crate::core::resolver::ResolveBehavior;
|
use crate::core::resolver::ResolveBehavior;
|
||||||
use crate::core::{FeatureValue, PackageId, Shell, TargetKind};
|
use crate::core::{PackageId, Shell, TargetKind};
|
||||||
use crate::util::diagnostic_server::{self, DiagnosticPrinter};
|
use crate::util::diagnostic_server::{self, DiagnosticPrinter};
|
||||||
use crate::util::interning::InternedString;
|
|
||||||
use crate::util::machine_message::{self, Message as _};
|
use crate::util::machine_message::{self, Message as _};
|
||||||
use crate::util::CargoResult;
|
use crate::util::CargoResult;
|
||||||
use crate::util::{self, internal, profile};
|
use crate::util::{self, internal, profile};
|
||||||
@ -1248,56 +1248,41 @@ impl<'cfg> DrainState<'cfg> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn back_compat_notice(&self, cx: &Context<'_, '_>, unit: &Unit) -> CargoResult<()> {
|
fn back_compat_notice(&self, cx: &Context<'_, '_>, unit: &Unit) -> CargoResult<()> {
|
||||||
|
fn is_broken_diesel(version: &Version) -> bool {
|
||||||
|
use semver::{Comparator, Op, Prerelease};
|
||||||
|
|
||||||
|
Comparator {
|
||||||
|
op: Op::Less,
|
||||||
|
major: 1,
|
||||||
|
minor: Some(4),
|
||||||
|
patch: Some(8),
|
||||||
|
pre: Prerelease::EMPTY,
|
||||||
|
}
|
||||||
|
.matches(version)
|
||||||
|
}
|
||||||
|
|
||||||
if unit.pkg.name() != "diesel"
|
if unit.pkg.name() != "diesel"
|
||||||
|| unit.pkg.version().major != 1
|
|| !is_broken_diesel(unit.pkg.version())
|
||||||
|| cx.bcx.ws.resolve_behavior() == ResolveBehavior::V1
|
|| cx.bcx.ws.resolve_behavior() == ResolveBehavior::V1
|
||||||
|| !unit.pkg.package_id().source_id().is_registry()
|
|| !unit.pkg.package_id().source_id().is_registry()
|
||||||
|| !unit.features.is_empty()
|
|| !unit.features.is_empty()
|
||||||
{
|
{
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
let other_diesel = match cx
|
if !cx
|
||||||
.bcx
|
.bcx
|
||||||
.unit_graph
|
.unit_graph
|
||||||
.keys()
|
.keys()
|
||||||
.find(|unit| unit.pkg.name() == "diesel" && !unit.features.is_empty())
|
.any(|unit| unit.pkg.name() == "diesel" && !unit.features.is_empty())
|
||||||
{
|
{
|
||||||
Some(u) => u,
|
return Ok(());
|
||||||
// Unlikely due to features.
|
|
||||||
None => return Ok(()),
|
|
||||||
};
|
|
||||||
let mut features_suggestion: BTreeSet<_> = other_diesel.features.iter().collect();
|
|
||||||
let fmap = other_diesel.pkg.summary().features();
|
|
||||||
// Remove any unnecessary features.
|
|
||||||
for feature in &other_diesel.features {
|
|
||||||
if let Some(feats) = fmap.get(feature) {
|
|
||||||
for feat in feats {
|
|
||||||
if let FeatureValue::Feature(f) = feat {
|
|
||||||
features_suggestion.remove(&f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
features_suggestion.remove(&InternedString::new("default"));
|
cx.bcx.config.shell().note(
|
||||||
let features_suggestion = toml::to_string(&features_suggestion).unwrap();
|
|
||||||
|
|
||||||
cx.bcx.config.shell().note(&format!(
|
|
||||||
"\
|
"\
|
||||||
This error may be due to an interaction between diesel and Cargo's new
|
This error may be due to an interaction between diesel and Cargo's new
|
||||||
feature resolver. Some workarounds you may want to consider:
|
feature resolver. Try updating to diesel 1.4.8 to fix this error.
|
||||||
- Add a build-dependency in Cargo.toml on diesel to force Cargo to add the appropriate
|
|
||||||
features. This may look something like this:
|
|
||||||
|
|
||||||
[build-dependencies]
|
|
||||||
diesel = {{ version = \"{}\", features = {} }}
|
|
||||||
|
|
||||||
- Try using the previous resolver by setting `resolver = \"1\"` in `Cargo.toml`
|
|
||||||
(see <https://doc.rust-lang.org/cargo/reference/resolver.html#resolver-versions>
|
|
||||||
for more information).
|
|
||||||
",
|
",
|
||||||
unit.pkg.version(),
|
)?;
|
||||||
features_suggestion
|
|
||||||
))?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,11 +50,12 @@ use cargo_util::{exit_status_to_string, is_simple_exit_code, paths, ProcessBuild
|
|||||||
use log::{debug, trace, warn};
|
use log::{debug, trace, warn};
|
||||||
use rustfix::diagnostics::Diagnostic;
|
use rustfix::diagnostics::Diagnostic;
|
||||||
use rustfix::{self, CodeFix};
|
use rustfix::{self, CodeFix};
|
||||||
|
use semver::{Comparator, Op, Prerelease};
|
||||||
|
|
||||||
use crate::core::compiler::{CompileKind, RustcTargetData, TargetInfo};
|
use crate::core::compiler::{CompileKind, RustcTargetData, TargetInfo};
|
||||||
use crate::core::resolver::features::{DiffMap, FeatureOpts, FeatureResolver};
|
use crate::core::resolver::features::{DiffMap, FeatureOpts, FeatureResolver};
|
||||||
use crate::core::resolver::{HasDevUnits, Resolve, ResolveBehavior};
|
use crate::core::resolver::{HasDevUnits, Resolve, ResolveBehavior};
|
||||||
use crate::core::{Edition, MaybePackage, Workspace};
|
use crate::core::{Edition, MaybePackage, PackageId, Workspace};
|
||||||
use crate::ops::resolve::WorkspaceResolve;
|
use crate::ops::resolve::WorkspaceResolve;
|
||||||
use crate::ops::{self, CompileOptions};
|
use crate::ops::{self, CompileOptions};
|
||||||
use crate::util::diagnostic_server::{Message, RustfixDiagnosticServer};
|
use crate::util::diagnostic_server::{Message, RustfixDiagnosticServer};
|
||||||
@ -321,17 +322,31 @@ fn check_resolver_change(ws: &Workspace<'_>, opts: &FixOptions) -> CargoResult<(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn report_maybe_diesel(config: &Config, resolve: &Resolve) -> CargoResult<()> {
|
fn report_maybe_diesel(config: &Config, resolve: &Resolve) -> CargoResult<()> {
|
||||||
if resolve
|
fn is_broken_diesel(pid: PackageId) -> bool {
|
||||||
.iter()
|
if pid.name() != "diesel" {
|
||||||
.any(|pid| pid.name() == "diesel" && pid.version().major == 1)
|
return false;
|
||||||
&& resolve.iter().any(|pid| pid.name() == "diesel_migrations")
|
}
|
||||||
{
|
Comparator {
|
||||||
|
op: Op::Less,
|
||||||
|
major: 1,
|
||||||
|
minor: Some(4),
|
||||||
|
patch: Some(8),
|
||||||
|
pre: Prerelease::EMPTY,
|
||||||
|
}
|
||||||
|
.matches(pid.version())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_broken_diesel_migration(pid: PackageId) -> bool {
|
||||||
|
pid.name() == "diesel_migrations" && pid.version().major <= 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if resolve.iter().any(is_broken_diesel) && resolve.iter().any(is_broken_diesel_migration) {
|
||||||
config.shell().note(
|
config.shell().note(
|
||||||
"\
|
"\
|
||||||
This project appears to use both diesel and diesel_migrations. These packages have
|
This project appears to use both diesel and diesel_migrations. These packages have
|
||||||
a known issue where the build may fail due to the version 2 resolver preventing
|
a known issue where the build may fail due to the version 2 resolver preventing
|
||||||
feature unification between those two packages. See
|
feature unification between those two packages. Please update to at least diesel 1.4.8
|
||||||
<https://github.com/rust-lang/cargo/issues/9450> for some potential workarounds.
|
to prevent this issue from happening.
|
||||||
",
|
",
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user