Fix 2018 edition idioms

This commit is contained in:
Dale Wijnand 2018-12-06 20:21:24 +01:00
parent 04ddd4d0fc
commit 6d1d3a6840
No known key found for this signature in database
GPG key ID: 4F256E3D151DF5EF
39 changed files with 60 additions and 60 deletions

View file

@ -1,4 +1,4 @@
extern crate clap;
use clap;
use clap::{AppSettings, Arg, ArgMatches};
@ -132,7 +132,7 @@ fn expand_aliases(
Ok(args)
}
fn execute_subcommand(config: &mut Config, args: &ArgMatches) -> CliResult {
fn execute_subcommand(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let (cmd, subcommand_args) = match args.subcommand() {
(cmd, Some(args)) => (cmd, args),
_ => {

View file

@ -70,7 +70,7 @@ Compilation can be customized with the `bench` profile in the manifest.
)
}
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let ws = args.workspace(config)?;
let mut compile_opts = args.compile_options(config, CompileMode::Bench)?;
compile_opts.build_config.release = true;

View file

@ -46,7 +46,7 @@ the --release flag will use the `release` profile instead.
)
}
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let ws = args.workspace(config)?;
let mut compile_opts = args.compile_options(config, CompileMode::Build)?;
compile_opts.export_dir = args.value_of_path("out-dir", config);

View file

@ -53,7 +53,7 @@ The `--profile test` flag can be used to check unit tests with the
)
}
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let ws = args.workspace(config)?;
let test = match args.value_of("profile") {
Some("test") => true,

View file

@ -21,7 +21,7 @@ and its format, see the `cargo help pkgid` command.
)
}
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let ws = args.workspace(config)?;
let opts = CleanOptions {
config,

View file

@ -45,7 +45,7 @@ the `cargo help pkgid` command.
)
}
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let ws = args.workspace(config)?;
let mode = CompileMode::Doc {
deps: !args.is_present("no-deps"),

View file

@ -22,7 +22,7 @@ all updated.
)
}
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let ws = args.workspace(config)?;
let opts = FetchOptions {

View file

@ -104,7 +104,7 @@ https://github.com/rust-lang/cargo
)
}
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let ws = args.workspace(config)?;
let test = match args.value_of("profile") {
Some("test") => true,

View file

@ -8,7 +8,7 @@ pub fn cli() -> App {
.arg_manifest_path()
}
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let ws = args.workspace(config)?;
ops::generate_lockfile(&ws)?;
Ok(())

View file

@ -21,7 +21,7 @@ pub fn cli() -> App {
)
}
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let url = args.value_of("url").unwrap().to_url()?;
let reference = args.value_of("reference").unwrap();

View file

@ -10,7 +10,7 @@ pub fn cli() -> App {
.arg_new_opts()
}
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let opts = args.new_options(config)?;
ops::init(&opts, config)?;
config

View file

@ -74,7 +74,7 @@ continuous integration systems.",
)
}
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let registry = args.registry(config)?;
config.reload_rooted_at_cargo_home()?;

View file

@ -13,7 +13,7 @@ pub struct ProjectLocation<'a> {
root: &'a str,
}
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let root = args.root_manifest(config)?;
let root = root.to_str()

View file

@ -18,7 +18,7 @@ pub fn cli() -> App {
.arg(opt("registry", "Registry to use").value_name("REGISTRY"))
}
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let registry = args.registry(config)?;
let token = match args.value_of("token") {

View file

@ -24,7 +24,7 @@ pub fn cli() -> App {
)
}
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let ws = args.workspace(config)?;
let version = match args.value_of("format-version") {

View file

@ -35,7 +35,7 @@ pub fn builtin() -> Vec<App> {
]
}
pub fn builtin_exec(cmd: &str) -> Option<fn(&mut Config, &ArgMatches) -> CliResult> {
pub fn builtin_exec(cmd: &str) -> Option<fn(&mut Config, &ArgMatches<'_>) -> CliResult> {
let f = match cmd {
"bench" => bench::exec,
"build" => build::exec,

View file

@ -10,7 +10,7 @@ pub fn cli() -> App {
.arg_new_opts()
}
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let opts = args.new_options(config)?;
ops::new(&opts, config)?;

View file

@ -28,7 +28,7 @@ Explicitly named owners can also modify the set of owners, so take care!
)
}
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let registry = args.registry(config)?;
let opts = OwnersOptions {
krate: args.value_of("crate").map(|s| s.to_string()),

View file

@ -29,7 +29,7 @@ pub fn cli() -> App {
.arg_jobs()
}
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let ws = args.workspace(config)?;
ops::package(
&ws,

View file

@ -32,7 +32,7 @@ Example Package IDs
)
}
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let ws = args.workspace(config)?;
let spec = args.value_of("spec").or_else(|| args.value_of("package"));
let spec = ops::pkgid(&ws, spec)?;

View file

@ -23,7 +23,7 @@ pub fn cli() -> App {
.arg(opt("registry", "Registry to publish to").value_name("REGISTRY"))
}
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let registry = args.registry(config)?;
let ws = args.workspace(config)?;
let index = args.index(config)?;

View file

@ -14,7 +14,7 @@ Deprecated, use `cargo metadata --no-deps` instead.\
.arg_manifest_path()
}
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let ws = args.workspace(config)?;
print_json(&ws.current()?);
Ok(())

View file

@ -36,7 +36,7 @@ run. If you're passing arguments to both Cargo and the binary, the ones after
)
}
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let ws = args.workspace(config)?;
let mut compile_opts = args.compile_options(config, CompileMode::Build)?;

View file

@ -46,7 +46,7 @@ processes spawned by Cargo, use the $RUSTFLAGS environment variable or the
)
}
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let ws = args.workspace(config)?;
let mode = match args.value_of("profile") {
Some("dev") | None => CompileMode::Build,

View file

@ -48,7 +48,7 @@ the `cargo help pkgid` command.
)
}
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let ws = args.workspace(config)?;
let mut compile_opts =
args.compile_options_for_single_package(config, CompileMode::Doc { deps: false })?;

View file

@ -18,7 +18,7 @@ pub fn cli() -> App {
.arg(opt("registry", "Registry to use").value_name("REGISTRY"))
}
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let registry = args.registry(config)?;
let index = args.index(config)?;
let limit = args.value_of_u32("limit")?;

View file

@ -89,7 +89,7 @@ To get the list of all options available for the test binaries use this:
)
}
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let ws = args.workspace(config)?;
let mut compile_opts = args.compile_options(config, CompileMode::Test)?;

View file

@ -19,7 +19,7 @@ only uninstall particular binaries.
)
}
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let root = args.value_of("root");
let specs = args
.values_of("spec")

View file

@ -37,7 +37,7 @@ For more information about package id specifications, see `cargo help pkgid`.
)
}
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let ws = args.workspace(config)?;
let update_opts = UpdateOptions {

View file

@ -11,7 +11,7 @@ pub fn cli() -> App {
.arg_manifest_path()
}
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
fn fail(reason: &str, value: &str) -> ! {
let mut h = HashMap::new();
h.insert(reason.to_string(), value.to_string());

View file

@ -6,7 +6,7 @@ pub fn cli() -> App {
subcommand("version").about("Show version information")
}
pub fn exec(_config: &mut Config, args: &ArgMatches) -> CliResult {
pub fn exec(_config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let verbose = args.occurrences_of("verbose") > 0;
let version = cli::get_version_string(verbose);
print!("{}", version);

View file

@ -27,7 +27,7 @@ crates to be locked to any yanked version.
)
}
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let registry = args.registry(config)?;
ops::yank(

View file

@ -1,20 +1,20 @@
#![cfg_attr(feature = "cargo-clippy", allow(clippy::too_many_arguments))] // large project
#![cfg_attr(feature = "cargo-clippy", allow(clippy::redundant_closure))] // there's a false positive
extern crate cargo;
extern crate clap;
use cargo;
#[cfg(feature = "pretty-env-logger")]
extern crate pretty_env_logger;
#[cfg(not(feature = "pretty-env-logger"))]
extern crate env_logger;
#[macro_use]
extern crate failure;
extern crate git2_curl;
extern crate log;
use git2_curl;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
extern crate toml;
use std::collections::BTreeSet;
use std::env;

View file

@ -1,13 +1,13 @@
#![allow(unknown_lints)]
#![cfg_attr(feature = "cargo-clippy", allow(identity_op))] // used for vertical alignment
extern crate curl;
#[macro_use]
extern crate failure;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
extern crate url;
use serde_json;
use std::collections::BTreeMap;
use std::fs::File;
@ -302,7 +302,7 @@ impl Registry {
}
}
fn handle(handle: &mut Easy, read: &mut FnMut(&mut [u8]) -> usize) -> Result<String> {
fn handle(handle: &mut Easy, read: &mut dyn FnMut(&mut [u8]) -> usize) -> Result<String> {
let mut headers = Vec::new();
let mut body = Vec::new();
{

View file

@ -15,7 +15,7 @@ fn http_auth_offered() {
let server = TcpListener::bind("127.0.0.1:0").unwrap();
let addr = server.local_addr().unwrap();
fn headers(rdr: &mut BufRead) -> HashSet<String> {
fn headers(rdr: &mut dyn BufRead) -> HashSet<String> {
let valid = ["GET", "Authorization", "Accept"];
rdr.lines()
.map(|s| s.unwrap())

View file

@ -18,7 +18,7 @@ enum FakeKind<'a> {
/// Add an empty file with executable flags (and platform-dependent suffix).
/// TODO: move this to `Project` if other cases using this emerge.
fn fake_file(proj: Project, dir: &Path, name: &str, kind: &FakeKind) -> Project {
fn fake_file(proj: Project, dir: &Path, name: &str, kind: &FakeKind<'_>) -> Project {
let path = proj
.root()
.join(dir)

View file

@ -2,25 +2,25 @@
#![cfg_attr(feature = "cargo-clippy", allow(blacklisted_name))]
#![cfg_attr(feature = "cargo-clippy", allow(explicit_iter_loop))]
extern crate bufstream;
extern crate cargo;
extern crate filetime;
extern crate flate2;
extern crate git2;
extern crate glob;
extern crate hex;
use cargo;
use filetime;
use git2;
use hex;
#[macro_use]
extern crate lazy_static;
extern crate libc;
use libc;
#[macro_use]
extern crate proptest;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate serde_json;
extern crate tar;
extern crate toml;
extern crate url;
use toml;
#[cfg(windows)]
extern crate winapi;

View file

@ -1301,7 +1301,7 @@ fn zip_all<T, I1: Iterator<Item = T>, I2: Iterator<Item = T>>(a: I1, b: I2) -> Z
}
impl fmt::Debug for Execs {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "execs")
}
}

View file

@ -76,7 +76,7 @@ pub fn resolve_with_config_raw(
fn query(
&mut self,
dep: &Dependency,
f: &mut FnMut(Summary),
f: &mut dyn FnMut(Summary),
fuzzy: bool,
) -> CargoResult<()> {
for summary in self.0.iter() {
@ -273,7 +273,7 @@ pub fn loc_names(names: &[(&'static str, &'static str)]) -> Vec<PackageId> {
pub struct PrettyPrintRegistry(pub Vec<Summary>);
impl fmt::Debug for PrettyPrintRegistry {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "vec![")?;
for s in &self.0 {
if s.dependencies().is_empty() {
@ -518,7 +518,7 @@ fn meta_test_multiple_versions_strategy() {
.current();
let reg = registry(input.clone());
for this in input.iter().rev().take(10) {
let mut res = resolve(
let res = resolve(
&pkg_id("root"),
vec![dep_req(&this.name(), &format!("={}", this.version()))],
&reg,