@@ -236,8 +236,15 @@ file_names.iter().map(|x| x.as_str()).join(", "))]
236
236
#[ error( "Failed to create canonical path for package {0}" ) ]
237
237
DependencyCanonicalizationFailed ( String ) ,
238
238
239
- #[ error( "Dependency tree resolution failed: {0}" ) ]
240
- DependencyResolutionFailed ( String ) ,
239
+ #[ error( "Could not find versions that satisfy dependency requirements" ) ]
240
+ DependencyResolutionNoSolution {
241
+ root_package_name : EcoString ,
242
+ derivation_tree :
243
+ NeverEqual < pubgrub:: DerivationTree < String , pubgrub:: Ranges < Version > , String > > ,
244
+ } ,
245
+
246
+ #[ error( "Dependency resolution failed: {0}" ) ]
247
+ DependencyResolutionError ( String ) ,
241
248
242
249
#[ error( "The package {0} is listed in dependencies and dev-dependencies" ) ]
243
250
DuplicateDependency ( EcoString ) ,
@@ -329,6 +336,17 @@ file_names.iter().map(|x| x.as_str()).join(", "))]
329
336
CannotAddSelfAsDependency { name : EcoString } ,
330
337
}
331
338
339
+ // A wrapper that ignores the inner value for equality:
340
+ #[ derive( Debug , Clone ) ]
341
+ pub struct NeverEqual < T > ( pub T ) ;
342
+
343
+ impl < T > PartialEq for NeverEqual < T > {
344
+ fn eq ( & self , _other : & Self ) -> bool {
345
+ false
346
+ }
347
+ }
348
+ impl < T > Eq for NeverEqual < T > { }
349
+
332
350
/// This is to make clippy happy and not make the error variant too big by
333
351
/// storing an entire `hexpm::version::Version` in the error.
334
352
///
@@ -435,27 +453,30 @@ impl Error {
435
453
error : ResolutionError < ' _ , T > ,
436
454
root_package_name : EcoString ,
437
455
) -> Error {
438
- Self :: DependencyResolutionFailed ( match error {
439
- ResolutionError :: NoSolution ( derivation_tree) => {
440
- DerivationTreePrinter :: new ( root_package_name, derivation_tree) . print ( )
441
- }
456
+ match error {
457
+ ResolutionError :: NoSolution ( derivation_tree) => Self :: DependencyResolutionNoSolution {
458
+ root_package_name,
459
+ derivation_tree : NeverEqual ( derivation_tree) ,
460
+ } ,
442
461
443
462
ResolutionError :: ErrorRetrievingDependencies {
444
463
package,
445
464
version,
446
465
source,
447
- } => format ! (
466
+ } => Self :: DependencyResolutionError ( format ! (
448
467
"An error occurred while trying to retrieve dependencies of {package}@{version}: {source}" ,
449
- ) ,
468
+ ) ) ,
450
469
451
470
ResolutionError :: ErrorChoosingVersion { package, source } => {
452
- format ! ( "An error occured while chosing the version of {package}: {source}" , )
471
+ Self :: DependencyResolutionError ( format ! (
472
+ "An error occured while chosing the version of {package}: {source}" ,
473
+ ) )
453
474
}
454
475
455
- ResolutionError :: ErrorInShouldCancel ( err) => {
456
- format ! ( "Dependency resolution was cancelled. {err}" )
457
- }
458
- } )
476
+ ResolutionError :: ErrorInShouldCancel ( err) => Self :: DependencyResolutionError ( format ! (
477
+ "Dependency resolution was cancelled. {err}"
478
+ ) ) ,
479
+ }
459
480
}
460
481
461
482
pub fn expand_tar < E > ( error : E ) -> Error
@@ -4202,14 +4223,34 @@ manifest.toml and a version range specified in gleam.toml:
4202
4223
} ]
4203
4224
}
4204
4225
4205
- Error :: DependencyResolutionFailed ( error) => vec ! [ Diagnostic {
4226
+ Error :: DependencyResolutionError ( error) => vec ! [ Diagnostic {
4206
4227
title: "Dependency resolution failed" . into( ) ,
4207
4228
text: wrap( error) ,
4208
4229
hint: None ,
4209
4230
location: None ,
4210
4231
level: Level :: Error ,
4211
4232
} ] ,
4212
4233
4234
+ Error :: DependencyResolutionNoSolution {
4235
+ root_package_name,
4236
+ derivation_tree,
4237
+ } => {
4238
+ let text = wrap (
4239
+ & DerivationTreePrinter :: new (
4240
+ root_package_name. clone ( ) ,
4241
+ derivation_tree. 0 . clone ( ) ,
4242
+ )
4243
+ . print ( ) ,
4244
+ ) ;
4245
+ vec ! [ Diagnostic {
4246
+ title: "Dependency resolution failed" . into( ) ,
4247
+ text,
4248
+ hint: None ,
4249
+ location: None ,
4250
+ level: Level :: Error ,
4251
+ } ]
4252
+ }
4253
+
4213
4254
Error :: WrongDependencyProvided {
4214
4255
path,
4215
4256
expected,
0 commit comments