Skip to content

Commit

Permalink
Merge pull request #270 from deg4uss3r/degausser/bump_cargo_0.54
Browse files Browse the repository at this point in the history
Degausser/bump cargo 0.54
  • Loading branch information
deg4uss3r authored Jun 26, 2021
2 parents 66085b8 + 5e3dac9 commit 390e2c5
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 31 deletions.
36 changes: 29 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cargo-outdated"
version = "0.9.15"
version = "0.9.16"
authors = [
"Kevin K. <[email protected]>",
"Frederick Z. <[email protected]>",
Expand Down Expand Up @@ -29,7 +29,7 @@ name = "cargo-outdated"

[dependencies]
anyhow = "1.0"
cargo = "0.52.0"
cargo = "0.54.0"
docopt = "1.1.0"
env_logger = "0.8.0"
git2-curl = "0.14.0"
Expand Down
36 changes: 25 additions & 11 deletions src/cargo_ops/elaborate_workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ use std::cell::RefCell;
use std::cmp::Ordering;
use std::collections::{BTreeSet, HashMap, VecDeque};
use std::io::{self, Write};
use std::rc::Rc;

use anyhow::anyhow;
use cargo::core::compiler::{CompileKind, RustcTargetData};
use cargo::core::resolver::features::{ForceAllTargets, HasDevUnits};
use cargo::core::resolver::CliFeatures;
use cargo::core::FeatureValue;
use cargo::core::{dependency::DepKind, Dependency, Package, PackageId, Workspace};
use cargo::ops::{self, Packages};
use cargo::util::interning::InternedString;
use cargo::util::{CargoResult, Config};
use serde::{Deserialize, Serialize};
use tabwriter::TabWriter;
Expand Down Expand Up @@ -45,11 +49,15 @@ pub struct Metadata {
}

impl Ord for Metadata {
fn cmp(&self, other: &Self) -> Ordering { self.name.cmp(&other.name) }
fn cmp(&self, other: &Self) -> Ordering {
self.name.cmp(&other.name)
}
}

impl PartialOrd for Metadata {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> { Some(self.cmp(other)) }
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}

impl<'ela> ElaborateWorkspace<'ela> {
Expand All @@ -58,14 +66,20 @@ impl<'ela> ElaborateWorkspace<'ela> {
workspace: &'ela Workspace<'_>,
options: &Options,
) -> CargoResult<ElaborateWorkspace<'ela>> {
use cargo::core::resolver::{features::RequestedFeatures, ResolveOpts};
// new in cargo 0.54.0
let flag_features: BTreeSet<FeatureValue> = options
.flag_features
.iter()
.map(|feature| FeatureValue::new(InternedString::from(feature)))
.collect();
let specs = Packages::All.to_package_id_specs(workspace)?;
let features = RequestedFeatures::from_command_line(
&options.flag_features,
options.all_features(),
options.no_default_features(),
);
let opts = ResolveOpts::new(true, features);

let cli_features = CliFeatures {
features: Rc::new(flag_features),
all_features: options.all_features(),
uses_default_features: options.no_default_features(),
};

//The CompileKind, this has no target since it's the temp workspace
//targets are blank since we don't need to fully build for the targets to get the dependencies
let compile_kind = CompileKind::from_requested_targets(workspace.config(), &[])?;
Expand All @@ -74,7 +88,7 @@ impl<'ela> ElaborateWorkspace<'ela> {
&workspace,
&target_data,
&compile_kind,
&opts,
&cli_features,
&specs,
HasDevUnits::Yes,
ForceAllTargets::Yes,
Expand Down Expand Up @@ -213,7 +227,7 @@ impl<'ela> ElaborateWorkspace<'ela> {
// generate pkg_status
let status = PkgStatus {
compat: Status::from_versions(pkg.version(), compat_pkg.map(PackageId::version)),
latest: Status::from_versions(pkg.version(), latest_pkg.map(PackageId::version)),
latest: Status::from_versions(&pkg.version(), latest_pkg.map(PackageId::version)),
};
debug!(
_config,
Expand Down
4 changes: 3 additions & 1 deletion src/cargo_ops/pkg_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ impl Status {
}
}

pub fn is_changed(&self) -> bool { !matches!(*self, Status::Unchanged) }
pub fn is_changed(&self) -> bool {
!matches!(*self, Status::Unchanged)
}
}

impl ::std::string::ToString for Status {
Expand Down
5 changes: 2 additions & 3 deletions src/cargo_ops/temp_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ use std::io::{Read, Write};
use std::path::{Path, PathBuf};
use std::rc::Rc;

use anyhow::anyhow;
use anyhow::{anyhow, Context};
use cargo::core::{Dependency, PackageId, Summary, Verbosity, Workspace};
use cargo::ops::{update_lockfile, UpdateOptions};
use cargo::util::errors::CargoResultExt;
use cargo::util::{CargoResult, Config};
use semver::{Identifier, Version, VersionReq};
use tempfile::{Builder, TempDir};
Expand Down Expand Up @@ -170,7 +169,7 @@ impl<'tmp> TempProject<'tmp> {
) -> CargoResult<Config> {
let shell = ::cargo::core::Shell::new();
let cwd = env::current_dir()
.chain_err(|| "Cargo couldn't get the current directory of the process")?;
.with_context(|| "Cargo couldn't get the current directory of the process")?;

let homedir = ::cargo::util::homedir(&cwd).ok_or_else(|| {
anyhow!(
Expand Down
19 changes: 12 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ mod macros;
mod cargo_ops;
use crate::cargo_ops::{ElaborateWorkspace, TempProject};

use cargo::core::maybe_allow_nightly_features;
use cargo::core::shell::Verbosity;
use cargo::core::Workspace;
use cargo::ops::needs_custom_http_transport;
Expand Down Expand Up @@ -63,15 +62,21 @@ pub struct Options {
}

impl Options {
fn all_features(&self) -> bool { self.flag_features.is_empty() }
fn all_features(&self) -> bool {
self.flag_features.is_empty()
}

fn no_default_features(&self) -> bool {
!(self.flag_features.is_empty() || self.flag_features.contains(&"default".to_owned()))
}

fn locked(&self) -> bool { false }
fn locked(&self) -> bool {
false
}

fn frozen(&self) -> bool { false }
fn frozen(&self) -> bool {
false
}
}

fn main() {
Expand Down Expand Up @@ -147,6 +152,9 @@ pub fn execute(options: Options, config: &mut Config) -> CargoResult<i32> {
// if it is, set it in the configure options
let cargo_home_path = std::env::var_os("CARGO_HOME").map(std::path::PathBuf::from);

// enabling nightly features
config.nightly_features_allowed = true;

config.configure(
options.flag_verbose,
options.flag_quiet,
Expand All @@ -160,9 +168,6 @@ pub fn execute(options: Options, config: &mut Config) -> CargoResult<i32> {
)?;
debug!(config, format!("options: {:?}", options));

// Needed to allow nightly features
maybe_allow_nightly_features();

verbose!(config, "Parsing...", "current workspace");
// the Cargo.toml that we are actually working on
let mut manifest_abspath: std::path::PathBuf;
Expand Down

0 comments on commit 390e2c5

Please sign in to comment.