mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
refactor: change imports of encode
simplifies the moving over of the schemas
This commit is contained in:
parent
535f7730fa
commit
efc42e1342
@ -1,7 +1,8 @@
|
|||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
|
|
||||||
|
use crate::core::resolver::encode::EncodableResolve;
|
||||||
use crate::core::resolver::encode::into_resolve;
|
use crate::core::resolver::encode::into_resolve;
|
||||||
use crate::core::{Resolve, ResolveVersion, Workspace, resolver};
|
use crate::core::{Resolve, ResolveVersion, Workspace};
|
||||||
use crate::util::Filesystem;
|
use crate::util::Filesystem;
|
||||||
use crate::util::errors::CargoResult;
|
use crate::util::errors::CargoResult;
|
||||||
|
|
||||||
@ -23,7 +24,7 @@ pub fn load_pkg_lockfile(ws: &Workspace<'_>) -> CargoResult<Option<Resolve>> {
|
|||||||
.with_context(|| format!("failed to read file: {}", f.path().display()))?;
|
.with_context(|| format!("failed to read file: {}", f.path().display()))?;
|
||||||
|
|
||||||
let resolve = (|| -> CargoResult<Option<Resolve>> {
|
let resolve = (|| -> CargoResult<Option<Resolve>> {
|
||||||
let v: resolver::EncodableResolve = toml::from_str(&s)?;
|
let v: EncodableResolve = toml::from_str(&s)?;
|
||||||
Ok(Some(into_resolve(v, &s, ws)?))
|
Ok(Some(into_resolve(v, &s, ws)?))
|
||||||
})()
|
})()
|
||||||
.with_context(|| format!("failed to parse lock file at: {}", f.path().display()))?;
|
.with_context(|| format!("failed to parse lock file at: {}", f.path().display()))?;
|
||||||
@ -207,8 +208,8 @@ fn are_equal_lockfiles(orig: &str, current: &str, ws: &Workspace<'_>) -> bool {
|
|||||||
// common case where we can update lock files.
|
// common case where we can update lock files.
|
||||||
if !ws.gctx().lock_update_allowed() {
|
if !ws.gctx().lock_update_allowed() {
|
||||||
let res: CargoResult<bool> = (|| {
|
let res: CargoResult<bool> = (|| {
|
||||||
let old: resolver::EncodableResolve = toml::from_str(orig)?;
|
let old: EncodableResolve = toml::from_str(orig)?;
|
||||||
let new: resolver::EncodableResolve = toml::from_str(current)?;
|
let new: EncodableResolve = toml::from_str(current)?;
|
||||||
Ok(into_resolve(old, orig, ws)? == into_resolve(new, current, ws)?)
|
Ok(into_resolve(old, orig, ws)? == into_resolve(new, current, ws)?)
|
||||||
})();
|
})();
|
||||||
if let Ok(true) = res {
|
if let Ok(true) = res {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user