@@ -95,7 +95,15 @@ pub(super) fn activation_error(
95
95
96
96
msg. push_str ( "\n versions that meet the requirements `" ) ;
97
97
msg. push_str ( & dep. version_req ( ) . to_string ( ) ) ;
98
- msg. push_str ( "` are: " ) ;
98
+ msg. push_str ( "` " ) ;
99
+
100
+ if let Some ( v) = dep. version_req ( ) . locked_version ( ) {
101
+ msg. push_str ( "(locked to " ) ;
102
+ msg. push_str ( & v. to_string ( ) ) ;
103
+ msg. push_str ( ") " ) ;
104
+ }
105
+
106
+ msg. push_str ( "are: " ) ;
99
107
msg. push_str (
100
108
& candidates
101
109
. iter ( )
@@ -239,12 +247,19 @@ pub(super) fn activation_error(
239
247
versions. join ( ", " )
240
248
} ;
241
249
250
+ let locked_version = dep
251
+ . version_req ( )
252
+ . locked_version ( )
253
+ . map ( |v| format ! ( " (locked to {})" , v) )
254
+ . unwrap_or_default ( ) ;
255
+
242
256
let mut msg = format ! (
243
- "failed to select a version for the requirement `{} = \" {}\" `\n \
257
+ "failed to select a version for the requirement `{} = \" {}\" `{} \n \
244
258
candidate versions found which didn't match: {}\n \
245
259
location searched: {}\n ",
246
260
dep. package_name( ) ,
247
261
dep. version_req( ) ,
262
+ locked_version,
248
263
versions,
249
264
registry. describe_source( dep. source_id( ) ) ,
250
265
) ;
@@ -254,7 +269,7 @@ pub(super) fn activation_error(
254
269
// If we have a path dependency with a locked version, then this may
255
270
// indicate that we updated a sub-package and forgot to run `cargo
256
271
// update`. In this case try to print a helpful error!
257
- if dep. source_id ( ) . is_path ( ) && dep. version_req ( ) . to_string ( ) . starts_with ( '=' ) {
272
+ if dep. source_id ( ) . is_path ( ) && dep. version_req ( ) . is_locked ( ) {
258
273
msg. push_str (
259
274
"\n consider running `cargo update` to update \
260
275
a path dependency's locked version",
0 commit comments