Skip to content

Commit aef3bd2

Browse files
committed
lint: fix errors for rust 2018 idioms
1 parent 85a3e9a commit aef3bd2

File tree

12 files changed

+39
-40
lines changed

12 files changed

+39
-40
lines changed

crates/cargo-platform/src/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub enum ParseErrorKind {
2121
}
2222

2323
impl fmt::Display for ParseError {
24-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
24+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2525
write!(
2626
f,
2727
"failed to parse `{}` as a cfg expression: {}",
@@ -31,7 +31,7 @@ impl fmt::Display for ParseError {
3131
}
3232

3333
impl fmt::Display for ParseErrorKind {
34-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
34+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3535
use ParseErrorKind::*;
3636
match self {
3737
UnterminatedString => write!(f, "unterminated string in cfg"),

crates/cargo-test-macro/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
extern crate proc_macro;
2-
31
use proc_macro::*;
42
use std::process::Command;
53
use std::sync::Once;

crates/cargo-test-support/src/registry.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ impl HttpServer {
790790
}
791791
}
792792

793-
fn check_authorized(&self, req: &Request, mutation: Option<Mutation>) -> bool {
793+
fn check_authorized(&self, req: &Request, mutation: Option<Mutation<'_>>) -> bool {
794794
let (private_key, private_key_subject) = if mutation.is_some() || self.auth_required {
795795
match &self.token {
796796
Token::Plaintext(token) => return Some(token) == req.authorization.as_ref(),
@@ -832,7 +832,8 @@ impl HttpServer {
832832
url: &'a str,
833833
kip: &'a str,
834834
}
835-
let footer: Footer = t!(serde_json::from_slice(untrusted_token.untrusted_footer()).ok());
835+
let footer: Footer<'_> =
836+
t!(serde_json::from_slice(untrusted_token.untrusted_footer()).ok());
836837
if footer.kip != paserk_pub_key_id {
837838
return false;
838839
}
@@ -861,7 +862,7 @@ impl HttpServer {
861862
_challenge: Option<&'a str>, // todo: PASETO with challenges
862863
v: Option<u8>,
863864
}
864-
let message: Message = t!(serde_json::from_str(trusted_token.payload()).ok());
865+
let message: Message<'_> = t!(serde_json::from_str(trusted_token.payload()).ok());
865866
let token_time = t!(OffsetDateTime::parse(message.iat, &Rfc3339).ok());
866867
let now = OffsetDateTime::now_utc();
867868
if (now - token_time) > Duration::MINUTE {

crates/mdman/src/hbs.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::path::Path;
1212
type FormatterRef<'a> = &'a (dyn Formatter + Send + Sync);
1313

1414
/// Processes the handlebars template at the given file.
15-
pub fn expand(file: &Path, formatter: FormatterRef) -> Result<String, Error> {
15+
pub fn expand(file: &Path, formatter: FormatterRef<'_>) -> Result<String, Error> {
1616
let mut handlebars = Handlebars::new();
1717
handlebars.set_strict_mode(true);
1818
handlebars.register_helper("lower", Box::new(lower));
@@ -174,10 +174,10 @@ impl HelperDef for ManLinkHelper<'_> {
174174
///
175175
/// This sets a variable to a value within the template context.
176176
fn set_decorator(
177-
d: &Decorator,
178-
_: &Handlebars,
177+
d: &Decorator<'_, '_>,
178+
_: &Handlebars<'_>,
179179
_ctx: &Context,
180-
rc: &mut RenderContext,
180+
rc: &mut RenderContext<'_, '_>,
181181
) -> Result<(), RenderError> {
182182
let data_to_set = d.hash();
183183
for (k, v) in data_to_set {
@@ -187,7 +187,7 @@ fn set_decorator(
187187
}
188188

189189
/// Sets a variable to a value within the context.
190-
fn set_in_context(rc: &mut RenderContext, key: &str, value: serde_json::Value) {
190+
fn set_in_context(rc: &mut RenderContext<'_, '_>, key: &str, value: serde_json::Value) {
191191
let mut ctx = match rc.context() {
192192
Some(c) => (*c).clone(),
193193
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) {
201201
}
202202

203203
/// Removes a variable from the context.
204-
fn remove_from_context(rc: &mut RenderContext, key: &str) {
204+
fn remove_from_context(rc: &mut RenderContext<'_, '_>, key: &str) {
205205
let ctx = rc.context().expect("cannot remove from null context");
206206
let mut ctx = (*ctx).clone();
207207
if let serde_json::Value::Object(m) = ctx.data_mut() {

crates/mdman/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub fn convert(
6464
type EventIter<'a> = Box<dyn Iterator<Item = (Event<'a>, Range<usize>)> + 'a>;
6565

6666
/// Creates a new markdown parser with the given input.
67-
pub(crate) fn md_parser(input: &str, url: Option<Url>) -> EventIter {
67+
pub(crate) fn md_parser(input: &str, url: Option<Url>) -> EventIter<'_> {
6868
let mut options = Options::empty();
6969
options.insert(Options::ENABLE_TABLES);
7070
options.insert(Options::ENABLE_FOOTNOTES);

crates/xtask-bump-check/src/xtask.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ fn config_configure(config: &mut Config, args: &ArgMatches) -> CliResult {
105105
/// Main entry of `xtask-bump-check`.
106106
///
107107
/// Assumption: version number are incremental. We never have point release for old versions.
108-
fn bump_check(args: &clap::ArgMatches, config: &mut cargo::util::Config) -> CargoResult<()> {
108+
fn bump_check(args: &clap::ArgMatches, config: &cargo::util::Config) -> CargoResult<()> {
109109
let ws = args.workspace(config)?;
110110
let repo = git2::Repository::open(ws.root())?;
111111
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
184184

185185
status("no version bump needed for member crates.")?;
186186

187-
return Ok(());
187+
Ok(())
188188
}
189189

190190
/// Returns the commit of upstream `master` branch if `base-rev` is missing.
@@ -256,7 +256,7 @@ fn get_referenced_commit<'a>(
256256
repo: &'a git2::Repository,
257257
base: &git2::Commit<'a>,
258258
) -> CargoResult<Option<git2::Commit<'a>>> {
259-
let [beta, stable] = beta_and_stable_branch(&repo)?;
259+
let [beta, stable] = beta_and_stable_branch(repo)?;
260260
let rev_id = base.id();
261261
let stable_commit = stable.get().peel_to_commit()?;
262262
let beta_commit = beta.get().peel_to_commit()?;

credential/cargo-credential-1password/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,8 @@ pub struct OnePasswordCredential {}
255255
impl Credential for OnePasswordCredential {
256256
fn perform(
257257
&self,
258-
registry: &RegistryInfo,
259-
action: &Action,
258+
registry: &RegistryInfo<'_>,
259+
action: &Action<'_>,
260260
args: &[&str],
261261
) -> Result<CredentialResponse, Error> {
262262
let op = OnePasswordKeychain::new(args)?;

credential/cargo-credential-libsecret/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,16 @@ mod linux {
104104
impl Credential for LibSecretCredential {
105105
fn perform(
106106
&self,
107-
registry: &RegistryInfo,
108-
action: &Action,
107+
registry: &RegistryInfo<'_>,
108+
action: &Action<'_>,
109109
_args: &[&str],
110110
) -> Result<CredentialResponse, Error> {
111111
// Dynamically load libsecret to avoid users needing to install
112112
// additional -dev packages when building this provider.
113113
let lib;
114-
let secret_password_lookup_sync: Symbol<SecretPasswordLookupSync>;
115-
let secret_password_store_sync: Symbol<SecretPasswordStoreSync>;
116-
let secret_password_clear_sync: Symbol<SecretPasswordClearSync>;
114+
let secret_password_lookup_sync: Symbol<'_, SecretPasswordLookupSync>;
115+
let secret_password_store_sync: Symbol<'_, SecretPasswordStoreSync>;
116+
let secret_password_clear_sync: Symbol<'_, SecretPasswordClearSync>;
117117
unsafe {
118118
lib = Library::new("libsecret-1.so").context(
119119
"failed to load libsecret: try installing the `libsecret` \

credential/cargo-credential-wincred/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ mod win {
3838
impl Credential for WindowsCredential {
3939
fn perform(
4040
&self,
41-
registry: &RegistryInfo,
42-
action: &Action,
41+
registry: &RegistryInfo<'_>,
42+
action: &Action<'_>,
4343
_args: &[&str],
4444
) -> Result<CredentialResponse, Error> {
4545
match action {

credential/cargo-credential/examples/file-provider.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ struct FileCredential;
1212
impl Credential for FileCredential {
1313
fn perform(
1414
&self,
15-
registry: &RegistryInfo,
16-
action: &Action,
15+
registry: &RegistryInfo<'_>,
16+
action: &Action<'_>,
1717
_args: &[&str],
1818
) -> Result<CredentialResponse, cargo_credential::Error> {
1919
if registry.index_url != "https://github.com/rust-lang/crates.io-index" {

0 commit comments

Comments
 (0)