diff --git a/crates/cargo-platform/src/error.rs b/crates/cargo-platform/src/error.rs index bf4b35f27..2d5b315f9 100644 --- a/crates/cargo-platform/src/error.rs +++ b/crates/cargo-platform/src/error.rs @@ -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"), diff --git a/crates/cargo-test-macro/src/lib.rs b/crates/cargo-test-macro/src/lib.rs index aa06f477d..937fbce6b 100644 --- a/crates/cargo-test-macro/src/lib.rs +++ b/crates/cargo-test-macro/src/lib.rs @@ -1,5 +1,3 @@ -extern crate proc_macro; - use proc_macro::*; use std::process::Command; use std::sync::Once; diff --git a/crates/cargo-test-support/src/registry.rs b/crates/cargo-test-support/src/registry.rs index 05af009ce..f70bacf04 100644 --- a/crates/cargo-test-support/src/registry.rs +++ b/crates/cargo-test-support/src/registry.rs @@ -790,7 +790,7 @@ impl HttpServer { } } - fn check_authorized(&self, req: &Request, mutation: Option) -> bool { + fn check_authorized(&self, req: &Request, mutation: Option>) -> 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, } - 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 { diff --git a/crates/mdman/src/hbs.rs b/crates/mdman/src/hbs.rs index 81ad7ee45..055eb3f28 100644 --- a/crates/mdman/src/hbs.rs +++ b/crates/mdman/src/hbs.rs @@ -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 { +pub fn expand(file: &Path, formatter: FormatterRef<'_>) -> Result { 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() { diff --git a/crates/mdman/src/lib.rs b/crates/mdman/src/lib.rs index 01c3c8d31..5cfb3f4ca 100644 --- a/crates/mdman/src/lib.rs +++ b/crates/mdman/src/lib.rs @@ -64,7 +64,7 @@ pub fn convert( type EventIter<'a> = Box, Range)> + 'a>; /// Creates a new markdown parser with the given input. -pub(crate) fn md_parser(input: &str, url: Option) -> EventIter { +pub(crate) fn md_parser(input: &str, url: Option) -> EventIter<'_> { let mut options = Options::empty(); options.insert(Options::ENABLE_TABLES); options.insert(Options::ENABLE_FOOTNOTES); diff --git a/crates/xtask-bump-check/src/xtask.rs b/crates/xtask-bump-check/src/xtask.rs index c50d51efd..5af9491bb 100644 --- a/crates/xtask-bump-check/src/xtask.rs +++ b/crates/xtask-bump-check/src/xtask.rs @@ -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>> { - 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()?; diff --git a/credential/cargo-credential-1password/src/main.rs b/credential/cargo-credential-1password/src/main.rs index a2607fd2f..921b52145 100644 --- a/credential/cargo-credential-1password/src/main.rs +++ b/credential/cargo-credential-1password/src/main.rs @@ -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 { let op = OnePasswordKeychain::new(args)?; diff --git a/credential/cargo-credential-libsecret/src/lib.rs b/credential/cargo-credential-libsecret/src/lib.rs index f83b424ee..ee1797605 100644 --- a/credential/cargo-credential-libsecret/src/lib.rs +++ b/credential/cargo-credential-libsecret/src/lib.rs @@ -104,16 +104,16 @@ mod linux { impl Credential for LibSecretCredential { fn perform( &self, - registry: &RegistryInfo, - action: &Action, + registry: &RegistryInfo<'_>, + action: &Action<'_>, _args: &[&str], ) -> Result { // Dynamically load libsecret to avoid users needing to install // additional -dev packages when building this provider. let lib; - let secret_password_lookup_sync: Symbol; - let secret_password_store_sync: Symbol; - let secret_password_clear_sync: Symbol; + 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` \ diff --git a/credential/cargo-credential-wincred/src/lib.rs b/credential/cargo-credential-wincred/src/lib.rs index 9200ca58f..24b072ee2 100644 --- a/credential/cargo-credential-wincred/src/lib.rs +++ b/credential/cargo-credential-wincred/src/lib.rs @@ -38,8 +38,8 @@ mod win { impl Credential for WindowsCredential { fn perform( &self, - registry: &RegistryInfo, - action: &Action, + registry: &RegistryInfo<'_>, + action: &Action<'_>, _args: &[&str], ) -> Result { match action { diff --git a/credential/cargo-credential/examples/file-provider.rs b/credential/cargo-credential/examples/file-provider.rs index d11958536..3ed312cb8 100644 --- a/credential/cargo-credential/examples/file-provider.rs +++ b/credential/cargo-credential/examples/file-provider.rs @@ -12,8 +12,8 @@ struct FileCredential; impl Credential for FileCredential { fn perform( &self, - registry: &RegistryInfo, - action: &Action, + registry: &RegistryInfo<'_>, + action: &Action<'_>, _args: &[&str], ) -> Result { if registry.index_url != "https://github.com/rust-lang/crates.io-index" { diff --git a/credential/cargo-credential/examples/stdout-redirected.rs b/credential/cargo-credential/examples/stdout-redirected.rs index 0b9bcc2f7..75a2d16d1 100644 --- a/credential/cargo-credential/examples/stdout-redirected.rs +++ b/credential/cargo-credential/examples/stdout-redirected.rs @@ -7,8 +7,8 @@ struct MyCredential; impl Credential for MyCredential { fn perform( &self, - _registry: &RegistryInfo, - _action: &Action, + _registry: &RegistryInfo<'_>, + _action: &Action<'_>, _args: &[&str], ) -> Result { // Informational messages should be sent on stderr. diff --git a/credential/cargo-credential/src/lib.rs b/credential/cargo-credential/src/lib.rs index 85ff9919e..60bce65be 100644 --- a/credential/cargo-credential/src/lib.rs +++ b/credential/cargo-credential/src/lib.rs @@ -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 { 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; } @@ -260,7 +260,7 @@ fn doit( fn deserialize_request( value: &str, ) -> Result, Box> { - 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 { /// Prompt the user for a token. pub fn read_token( - login_options: &LoginOptions, - registry: &RegistryInfo, + login_options: &LoginOptions<'_>, + registry: &RegistryInfo<'_>, ) -> Result, 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();