Skip to content

Commit 64642cc

Browse files
committed
Auto merge of #12669 - weihanglo:lint-refactor, r=epage
refactor: fix lint errors in preparation of `[lints]` table integration
2 parents 5c84ce0 + c4f9712 commit 64642cc

File tree

21 files changed

+65
-72
lines changed

21 files changed

+65
-72
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clippy.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
allow-print-in-tests = true
22
allow-dbg-in-tests = true
33
disallowed-methods = [
4-
{ path = "std::env::var", reason = "Use `Config::get_env` instead. See rust-lang/cargo#11588" },
5-
{ path = "std::env::var_os", reason = "Use `Config::get_env_os` instead. See rust-lang/cargo#11588" },
6-
{ path = "std::env::vars", reason = "Not recommended to use in Cargo. See rust-lang/cargo#11588" },
7-
{ path = "std::env::vars_os", reason = "Not recommended to use in Cargo. See rust-lang/cargo#11588" },
4+
{ path = "std::env::var", reason = "use `Config::get_env` instead. See rust-lang/cargo#11588" },
5+
{ path = "std::env::var_os", reason = "use `Config::get_env_os` instead. See rust-lang/cargo#11588" },
6+
{ path = "std::env::vars", reason = "not recommended to use in Cargo. See rust-lang/cargo#11588" },
7+
{ path = "std::env::vars_os", reason = "not recommended to use in Cargo. See rust-lang/cargo#11588" },
88
]

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 & 10 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
}
@@ -846,7 +847,6 @@ impl HttpServer {
846847
if footer.url != "https://github.com/rust-lang/crates.io-index"
847848
&& footer.url != &format!("sparse+http://{}/index/", self.addr.to_string())
848849
{
849-
dbg!(footer.url);
850850
return false;
851851
}
852852

@@ -862,20 +862,18 @@ impl HttpServer {
862862
_challenge: Option<&'a str>, // todo: PASETO with challenges
863863
v: Option<u8>,
864864
}
865-
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());
866866
let token_time = t!(OffsetDateTime::parse(message.iat, &Rfc3339).ok());
867867
let now = OffsetDateTime::now_utc();
868868
if (now - token_time) > Duration::MINUTE {
869869
return false;
870870
}
871871
if private_key_subject.as_deref() != message.sub {
872-
dbg!(message.sub);
873872
return false;
874873
}
875874
// - If the claim v is set, that it has the value of 1.
876875
if let Some(v) = message.v {
877876
if v != 1 {
878-
dbg!(message.v);
879877
return false;
880878
}
881879
}
@@ -885,22 +883,18 @@ impl HttpServer {
885883
if let Some(mutation) = mutation {
886884
// - That the operation matches the mutation field and is one of publish, yank, or unyank.
887885
if message.mutation != Some(mutation.mutation) {
888-
dbg!(message.mutation);
889886
return false;
890887
}
891888
// - That the package, and version match the request.
892889
if message.name != mutation.name {
893-
dbg!(message.name);
894890
return false;
895891
}
896892
if message.vers != mutation.vers {
897-
dbg!(message.vers);
898893
return false;
899894
}
900895
// - If the mutation is publish, that the version has not already been published, and that the hash matches the request.
901896
if mutation.mutation == "publish" {
902897
if message.cksum != mutation.cksum {
903-
dbg!(message.cksum);
904898
return false;
905899
}
906900
}
File renamed without changes.

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/mdman/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ fn run() -> Result<(), Error> {
4848
if same_file::is_same_file(source, &out_path).unwrap_or(false) {
4949
bail!("cannot output to the same file as the source");
5050
}
51-
println!("Converting {} -> {}", source.display(), out_path.display());
51+
eprintln!("Converting {} -> {}", source.display(), out_path.display());
5252
let result = mdman::convert(&source, opts.format, opts.url.clone(), opts.man_map.clone())
5353
.with_context(|| format!("failed to translate {}", source.display()))?;
5454

crates/resolver-tests/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ pub fn resolve_with_config_raw(
163163
if std::thread::panicking() && self.list.len() != self.used.len() {
164164
// we found a case that causes a panic and did not use all of the input.
165165
// lets print the part of the input that was used for minimization.
166-
println!(
166+
eprintln!(
167167
"{:?}",
168168
PrettyPrintRegistry(
169169
self.list

0 commit comments

Comments
 (0)