@@ -48,13 +48,23 @@ pub struct Resolve {
48
48
49
49
/// A version to indicate how a `Cargo.lock` should be serialized.
50
50
///
51
- /// When creating a new lockfile, the default version defined in
52
- /// [`ResolveVersion::default`] is used.
51
+ /// When creating a new lockfile, the version with `#[default]` is used.
53
52
/// If an old version of lockfile already exists, it will stay as-is.
54
53
///
54
+ /// It's important that if a new version is added that this is not updated
55
+ /// until *at least* the support for the version is in the stable release of Rust.
56
+ ///
57
+ /// This resolve version will be used for all new lock files, for example
58
+ /// those generated by `cargo update` (update everything) or building after
59
+ /// a `cargo new` (where no lock file previously existed). This is also used
60
+ /// for *updated* lock files such as when a dependency is added or when a
61
+ /// version requirement changes. In this situation Cargo's updating the lock
62
+ /// file anyway so it takes the opportunity to bump the lock file version
63
+ /// forward.
64
+ ///
55
65
/// It's theorized that we can add more here over time to track larger changes
56
66
/// to the `Cargo.lock` format, but we've yet to see how that strategy pans out.
57
- #[ derive( PartialEq , Eq , Clone , Copy , Debug , PartialOrd , Ord ) ]
67
+ #[ derive( Default , PartialEq , Eq , Clone , Copy , Debug , PartialOrd , Ord ) ]
58
68
pub enum ResolveVersion {
59
69
/// Historical baseline for when this abstraction was added.
60
70
V1 ,
@@ -68,6 +78,7 @@ pub enum ResolveVersion {
68
78
/// `branch = "master"` are no longer encoded the same way as those without
69
79
/// branch specifiers. Introduced in 2020 in version 1.47. New lockfiles use
70
80
/// V3 by default staring in 1.53.
81
+ #[ default]
71
82
V3 ,
72
83
}
73
84
@@ -394,22 +405,3 @@ impl fmt::Debug for Resolve {
394
405
write ! ( fmt, "}}" )
395
406
}
396
407
}
397
-
398
- impl Default for ResolveVersion {
399
- /// The default way to encode new or updated `Cargo.lock` files.
400
- ///
401
- /// It's important that if a new version of [`ResolveVersion`] is added that
402
- /// this is not updated until *at least* the support for the version is in
403
- /// the stable release of Rust.
404
- ///
405
- /// This resolve version will be used for all new lock files, for example
406
- /// those generated by `cargo update` (update everything) or building after
407
- /// a `cargo new` (where no lock file previously existed). This is also used
408
- /// for *updated* lock files such as when a dependency is added or when a
409
- /// version requirement changes. In this situation Cargo's updating the lock
410
- /// file anyway so it takes the opportunity to bump the lock file version
411
- /// forward.
412
- fn default ( ) -> ResolveVersion {
413
- ResolveVersion :: V3
414
- }
415
- }
0 commit comments