mirror of https://github.com/rust-lang/cargo
lint: fix errors for rust 2018 idioms
This commit is contained in:
parent
85a3e9ace0
commit
aef3bd22d3
|
@ -21,7 +21,7 @@ pub enum ParseErrorKind {
|
|||
}
|
||||
|
||||
impl fmt::Display for ParseError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"failed to parse `{}` as a cfg expression: {}",
|
||||
|
@ -31,7 +31,7 @@ impl fmt::Display for ParseError {
|
|||
}
|
||||
|
||||
impl fmt::Display for ParseErrorKind {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
use ParseErrorKind::*;
|
||||
match self {
|
||||
UnterminatedString => write!(f, "unterminated string in cfg"),
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
extern crate proc_macro;
|
||||
|
||||
use proc_macro::*;
|
||||
use std::process::Command;
|
||||
use std::sync::Once;
|
||||
|
|
|
@ -790,7 +790,7 @@ impl HttpServer {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_authorized(&self, req: &Request, mutation: Option<Mutation>) -> bool {
|
||||
fn check_authorized(&self, req: &Request, mutation: Option<Mutation<'_>>) -> bool {
|
||||
let (private_key, private_key_subject) = if mutation.is_some() || self.auth_required {
|
||||
match &self.token {
|
||||
Token::Plaintext(token) => return Some(token) == req.authorization.as_ref(),
|
||||
|
@ -832,7 +832,8 @@ impl HttpServer {
|
|||
url: &'a str,
|
||||
kip: &'a str,
|
||||
}
|
||||
let footer: Footer = t!(serde_json::from_slice(untrusted_token.untrusted_footer()).ok());
|
||||
let footer: Footer<'_> =
|
||||
t!(serde_json::from_slice(untrusted_token.untrusted_footer()).ok());
|
||||
if footer.kip != paserk_pub_key_id {
|
||||
return false;
|
||||
}
|
||||
|
@ -861,7 +862,7 @@ impl HttpServer {
|
|||
_challenge: Option<&'a str>, // todo: PASETO with challenges
|
||||
v: Option<u8>,
|
||||
}
|
||||
let message: Message = t!(serde_json::from_str(trusted_token.payload()).ok());
|
||||
let message: Message<'_> = t!(serde_json::from_str(trusted_token.payload()).ok());
|
||||
let token_time = t!(OffsetDateTime::parse(message.iat, &Rfc3339).ok());
|
||||
let now = OffsetDateTime::now_utc();
|
||||
if (now - token_time) > Duration::MINUTE {
|
||||
|
|
|
@ -12,7 +12,7 @@ use std::path::Path;
|
|||
type FormatterRef<'a> = &'a (dyn Formatter + Send + Sync);
|
||||
|
||||
/// Processes the handlebars template at the given file.
|
||||
pub fn expand(file: &Path, formatter: FormatterRef) -> Result<String, Error> {
|
||||
pub fn expand(file: &Path, formatter: FormatterRef<'_>) -> Result<String, Error> {
|
||||
let mut handlebars = Handlebars::new();
|
||||
handlebars.set_strict_mode(true);
|
||||
handlebars.register_helper("lower", Box::new(lower));
|
||||
|
@ -174,10 +174,10 @@ impl HelperDef for ManLinkHelper<'_> {
|
|||
///
|
||||
/// This sets a variable to a value within the template context.
|
||||
fn set_decorator(
|
||||
d: &Decorator,
|
||||
_: &Handlebars,
|
||||
d: &Decorator<'_, '_>,
|
||||
_: &Handlebars<'_>,
|
||||
_ctx: &Context,
|
||||
rc: &mut RenderContext,
|
||||
rc: &mut RenderContext<'_, '_>,
|
||||
) -> Result<(), RenderError> {
|
||||
let data_to_set = d.hash();
|
||||
for (k, v) in data_to_set {
|
||||
|
@ -187,7 +187,7 @@ fn set_decorator(
|
|||
}
|
||||
|
||||
/// Sets a variable to a value within the context.
|
||||
fn set_in_context(rc: &mut RenderContext, key: &str, value: serde_json::Value) {
|
||||
fn set_in_context(rc: &mut RenderContext<'_, '_>, key: &str, value: serde_json::Value) {
|
||||
let mut ctx = match rc.context() {
|
||||
Some(c) => (*c).clone(),
|
||||
None => Context::wraps(serde_json::Value::Object(serde_json::Map::new())).unwrap(),
|
||||
|
@ -201,7 +201,7 @@ fn set_in_context(rc: &mut RenderContext, key: &str, value: serde_json::Value) {
|
|||
}
|
||||
|
||||
/// Removes a variable from the context.
|
||||
fn remove_from_context(rc: &mut RenderContext, key: &str) {
|
||||
fn remove_from_context(rc: &mut RenderContext<'_, '_>, key: &str) {
|
||||
let ctx = rc.context().expect("cannot remove from null context");
|
||||
let mut ctx = (*ctx).clone();
|
||||
if let serde_json::Value::Object(m) = ctx.data_mut() {
|
||||
|
|
|
@ -64,7 +64,7 @@ pub fn convert(
|
|||
type EventIter<'a> = Box<dyn Iterator<Item = (Event<'a>, Range<usize>)> + 'a>;
|
||||
|
||||
/// Creates a new markdown parser with the given input.
|
||||
pub(crate) fn md_parser(input: &str, url: Option<Url>) -> EventIter {
|
||||
pub(crate) fn md_parser(input: &str, url: Option<Url>) -> EventIter<'_> {
|
||||
let mut options = Options::empty();
|
||||
options.insert(Options::ENABLE_TABLES);
|
||||
options.insert(Options::ENABLE_FOOTNOTES);
|
||||
|
|
|
@ -105,7 +105,7 @@ fn config_configure(config: &mut Config, args: &ArgMatches) -> CliResult {
|
|||
/// Main entry of `xtask-bump-check`.
|
||||
///
|
||||
/// Assumption: version number are incremental. We never have point release for old versions.
|
||||
fn bump_check(args: &clap::ArgMatches, config: &mut cargo::util::Config) -> CargoResult<()> {
|
||||
fn bump_check(args: &clap::ArgMatches, config: &cargo::util::Config) -> CargoResult<()> {
|
||||
let ws = args.workspace(config)?;
|
||||
let repo = git2::Repository::open(ws.root())?;
|
||||
let base_commit = get_base_commit(config, args, &repo)?;
|
||||
|
@ -184,7 +184,7 @@ fn bump_check(args: &clap::ArgMatches, config: &mut cargo::util::Config) -> Carg
|
|||
|
||||
status("no version bump needed for member crates.")?;
|
||||
|
||||
return Ok(());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Returns the commit of upstream `master` branch if `base-rev` is missing.
|
||||
|
@ -256,7 +256,7 @@ fn get_referenced_commit<'a>(
|
|||
repo: &'a git2::Repository,
|
||||
base: &git2::Commit<'a>,
|
||||
) -> CargoResult<Option<git2::Commit<'a>>> {
|
||||
let [beta, stable] = beta_and_stable_branch(&repo)?;
|
||||
let [beta, stable] = beta_and_stable_branch(repo)?;
|
||||
let rev_id = base.id();
|
||||
let stable_commit = stable.get().peel_to_commit()?;
|
||||
let beta_commit = beta.get().peel_to_commit()?;
|
||||
|
|
|
@ -255,8 +255,8 @@ pub struct OnePasswordCredential {}
|
|||
impl Credential for OnePasswordCredential {
|
||||
fn perform(
|
||||
&self,
|
||||
registry: &RegistryInfo,
|
||||
action: &Action,
|
||||
registry: &RegistryInfo<'_>,
|
||||
action: &Action<'_>,
|
||||
args: &[&str],
|
||||
) -> Result<CredentialResponse, Error> {
|
||||
let op = OnePasswordKeychain::new(args)?;
|
||||
|
|
|
@ -104,16 +104,16 @@ mod linux {
|
|||
impl Credential for LibSecretCredential {
|
||||
fn perform(
|
||||
&self,
|
||||
registry: &RegistryInfo,
|
||||
action: &Action,
|
||||
registry: &RegistryInfo<'_>,
|
||||
action: &Action<'_>,
|
||||
_args: &[&str],
|
||||
) -> Result<CredentialResponse, Error> {
|
||||
// Dynamically load libsecret to avoid users needing to install
|
||||
// additional -dev packages when building this provider.
|
||||
let lib;
|
||||
let secret_password_lookup_sync: Symbol<SecretPasswordLookupSync>;
|
||||
let secret_password_store_sync: Symbol<SecretPasswordStoreSync>;
|
||||
let secret_password_clear_sync: Symbol<SecretPasswordClearSync>;
|
||||
let secret_password_lookup_sync: Symbol<'_, SecretPasswordLookupSync>;
|
||||
let secret_password_store_sync: Symbol<'_, SecretPasswordStoreSync>;
|
||||
let secret_password_clear_sync: Symbol<'_, SecretPasswordClearSync>;
|
||||
unsafe {
|
||||
lib = Library::new("libsecret-1.so").context(
|
||||
"failed to load libsecret: try installing the `libsecret` \
|
||||
|
|
|
@ -38,8 +38,8 @@ mod win {
|
|||
impl Credential for WindowsCredential {
|
||||
fn perform(
|
||||
&self,
|
||||
registry: &RegistryInfo,
|
||||
action: &Action,
|
||||
registry: &RegistryInfo<'_>,
|
||||
action: &Action<'_>,
|
||||
_args: &[&str],
|
||||
) -> Result<CredentialResponse, Error> {
|
||||
match action {
|
||||
|
|
|
@ -12,8 +12,8 @@ struct FileCredential;
|
|||
impl Credential for FileCredential {
|
||||
fn perform(
|
||||
&self,
|
||||
registry: &RegistryInfo,
|
||||
action: &Action,
|
||||
registry: &RegistryInfo<'_>,
|
||||
action: &Action<'_>,
|
||||
_args: &[&str],
|
||||
) -> Result<CredentialResponse, cargo_credential::Error> {
|
||||
if registry.index_url != "https://github.com/rust-lang/crates.io-index" {
|
||||
|
|
|
@ -7,8 +7,8 @@ struct MyCredential;
|
|||
impl Credential for MyCredential {
|
||||
fn perform(
|
||||
&self,
|
||||
_registry: &RegistryInfo,
|
||||
_action: &Action,
|
||||
_registry: &RegistryInfo<'_>,
|
||||
_action: &Action<'_>,
|
||||
_args: &[&str],
|
||||
) -> Result<CredentialResponse, Error> {
|
||||
// Informational messages should be sent on stderr.
|
||||
|
|
|
@ -61,8 +61,8 @@ pub struct UnsupportedCredential;
|
|||
impl Credential for UnsupportedCredential {
|
||||
fn perform(
|
||||
&self,
|
||||
_registry: &RegistryInfo,
|
||||
_action: &Action,
|
||||
_registry: &RegistryInfo<'_>,
|
||||
_action: &Action<'_>,
|
||||
_args: &[&str],
|
||||
) -> Result<CredentialResponse, Error> {
|
||||
Err(Error::UrlNotSupported)
|
||||
|
@ -215,8 +215,8 @@ pub trait Credential {
|
|||
/// Retrieves a token for the given registry.
|
||||
fn perform(
|
||||
&self,
|
||||
registry: &RegistryInfo,
|
||||
action: &Action,
|
||||
registry: &RegistryInfo<'_>,
|
||||
action: &Action<'_>,
|
||||
args: &[&str],
|
||||
) -> Result<CredentialResponse, Error>;
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ fn doit(
|
|||
fn deserialize_request(
|
||||
value: &str,
|
||||
) -> Result<CredentialRequest<'_>, Box<dyn std::error::Error + Send + Sync>> {
|
||||
let request: CredentialRequest = serde_json::from_str(&value)?;
|
||||
let request: CredentialRequest<'_> = serde_json::from_str(&value)?;
|
||||
if request.v != PROTOCOL_VERSION_1 {
|
||||
return Err(format!("unsupported protocol version {}", request.v).into());
|
||||
}
|
||||
|
@ -276,8 +276,8 @@ pub fn read_line() -> Result<String, io::Error> {
|
|||
|
||||
/// Prompt the user for a token.
|
||||
pub fn read_token(
|
||||
login_options: &LoginOptions,
|
||||
registry: &RegistryInfo,
|
||||
login_options: &LoginOptions<'_>,
|
||||
registry: &RegistryInfo<'_>,
|
||||
) -> Result<Secret<String>, Error> {
|
||||
if let Some(token) = &login_options.token {
|
||||
return Ok(token.to_owned());
|
||||
|
@ -387,7 +387,7 @@ mod tests {
|
|||
r#"{"v":1,"registry":{"index-url":"url"},"kind":"get","operation":"owners","name":"pkg"}"#
|
||||
);
|
||||
|
||||
let cr: CredentialRequest =
|
||||
let cr: CredentialRequest<'_> =
|
||||
serde_json::from_str(r#"{"extra-1":true,"v":1,"registry":{"index-url":"url","extra-2":true},"kind":"get","operation":"owners","name":"pkg","args":[]}"#).unwrap();
|
||||
assert_eq!(cr, get_oweners);
|
||||
}
|
||||
|
@ -405,7 +405,7 @@ mod tests {
|
|||
action: Action::Logout,
|
||||
};
|
||||
|
||||
let cr: CredentialRequest = serde_json::from_str(
|
||||
let cr: CredentialRequest<'_> = serde_json::from_str(
|
||||
r#"{"v":1,"registry":{"index-url":"url"},"kind":"logout","extra-1":true,"args":[]}"#,
|
||||
)
|
||||
.unwrap();
|
||||
|
@ -425,7 +425,7 @@ mod tests {
|
|||
action: Action::Unknown,
|
||||
};
|
||||
|
||||
let cr: CredentialRequest = serde_json::from_str(
|
||||
let cr: CredentialRequest<'_> = serde_json::from_str(
|
||||
r#"{"v":1,"registry":{"index-url":""},"kind":"unexpected-1","extra-1":true,"args":[]}"#,
|
||||
)
|
||||
.unwrap();
|
||||
|
|
Loading…
Reference in New Issue