Skip to content

Commit 59d0e8c

Browse files
committed
and a few more from other dirs
1 parent cb6d126 commit 59d0e8c

File tree

10 files changed

+46
-50
lines changed

10 files changed

+46
-50
lines changed

clippy_dev/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ fn main() {
4141
matches.contains_id("msrv"),
4242
) {
4343
Ok(_) => update_lints::update(update_lints::UpdateMode::Change),
44-
Err(e) => eprintln!("Unable to create lint: {}", e),
44+
Err(e) => eprintln!("Unable to create lint: {e}"),
4545
}
4646
},
4747
Some(("setup", sub_command)) => match sub_command.subcommand() {

clippy_utils/src/attrs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@ pub fn get_unique_inner_attr(sess: &Session, attrs: &[ast::Attribute], name: &'s
131131
match attr.style {
132132
ast::AttrStyle::Inner if unique_attr.is_none() => unique_attr = Some(attr.clone()),
133133
ast::AttrStyle::Inner => {
134-
sess.struct_span_err(attr.span, &format!("`{}` is defined multiple times", name))
134+
sess.struct_span_err(attr.span, &format!("`{name}` is defined multiple times"))
135135
.span_note(unique_attr.as_ref().unwrap().span, "first definition found here")
136136
.emit();
137137
},
138138
ast::AttrStyle::Outer => {
139-
sess.span_err(attr.span, &format!("`{}` cannot be an outer attribute", name));
139+
sess.span_err(attr.span, &format!("`{name}` cannot be an outer attribute"));
140140
},
141141
}
142142
}

clippy_utils/src/diagnostics.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@ fn docs_link(diag: &mut Diagnostic, lint: &'static Lint) {
1818
if env::var("CLIPPY_DISABLE_DOCS_LINKS").is_err() {
1919
if let Some(lint) = lint.name_lower().strip_prefix("clippy::") {
2020
diag.help(&format!(
21-
"for further information visit https://rust-lang.github.io/rust-clippy/{}/index.html#{}",
21+
"for further information visit https://rust-lang.github.io/rust-clippy/{}/index.html#{lint}",
2222
&option_env!("RUST_RELEASE_NUM").map_or("master".to_string(), |n| {
2323
// extract just major + minor version and ignore patch versions
2424
format!("rust-{}", n.rsplit_once('.').unwrap().1)
25-
}),
26-
lint
25+
})
2726
));
2827
}
2928
}

clippy_utils/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ pub fn parse_msrv(msrv: &str, sess: Option<&Session>, span: Option<Span>) -> Opt
121121
return Some(version);
122122
} else if let Some(sess) = sess {
123123
if let Some(span) = span {
124-
sess.span_err(span, &format!("`{}` is not a valid Rust version", msrv));
124+
sess.span_err(span, &format!("`{msrv}` is not a valid Rust version"));
125125
}
126126
}
127127
None

clippy_utils/src/macros.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ impl FormatString {
392392
unescape_literal(inner, mode, &mut |_, ch| match ch {
393393
Ok(ch) => unescaped.push(ch),
394394
Err(e) if !e.is_fatal() => (),
395-
Err(e) => panic!("{:?}", e),
395+
Err(e) => panic!("{e:?}"),
396396
});
397397

398398
let mut parts = Vec::new();

clippy_utils/src/qualify_min_const_fn.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ pub fn is_min_const_fn<'a, 'tcx>(tcx: TyCtxt<'tcx>, body: &'a Body<'tcx>, msrv:
3333
| ty::PredicateKind::ConstEquate(..)
3434
| ty::PredicateKind::Trait(..)
3535
| ty::PredicateKind::TypeWellFormedFromEnv(..) => continue,
36-
ty::PredicateKind::ObjectSafe(_) => panic!("object safe predicate on function: {:#?}", predicate),
37-
ty::PredicateKind::ClosureKind(..) => panic!("closure kind predicate on function: {:#?}", predicate),
38-
ty::PredicateKind::Subtype(_) => panic!("subtype predicate on function: {:#?}", predicate),
39-
ty::PredicateKind::Coerce(_) => panic!("coerce predicate on function: {:#?}", predicate),
36+
ty::PredicateKind::ObjectSafe(_) => panic!("object safe predicate on function: {predicate:#?}"),
37+
ty::PredicateKind::ClosureKind(..) => panic!("closure kind predicate on function: {predicate:#?}"),
38+
ty::PredicateKind::Subtype(_) => panic!("subtype predicate on function: {predicate:#?}"),
39+
ty::PredicateKind::Coerce(_) => panic!("coerce predicate on function: {predicate:#?}"),
4040
}
4141
}
4242
match predicates.parent {
@@ -315,8 +315,7 @@ fn check_terminator<'a, 'tcx>(
315315
span,
316316
format!(
317317
"can only call other `const fn` within a `const fn`, \
318-
but `{:?}` is not stable as `const fn`",
319-
func,
318+
but `{func:?}` is not stable as `const fn`",
320319
)
321320
.into(),
322321
));

clippy_utils/src/source.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ pub fn expr_block<'a, T: LintContext>(
2525
if expr.span.from_expansion() {
2626
Cow::Owned(format!("{{ {} }}", snippet_with_macro_callsite(cx, expr.span, default)))
2727
} else if let ExprKind::Block(_, _) = expr.kind {
28-
Cow::Owned(format!("{}{}", code, string))
28+
Cow::Owned(format!("{code}{string}"))
2929
} else if string.is_empty() {
30-
Cow::Owned(format!("{{ {} }}", code))
30+
Cow::Owned(format!("{{ {code} }}"))
3131
} else {
32-
Cow::Owned(format!("{{\n{};\n{}\n}}", code, string))
32+
Cow::Owned(format!("{{\n{code};\n{string}\n}}"))
3333
}
3434
}
3535

@@ -466,7 +466,7 @@ mod test {
466466
#[test]
467467
fn test_without_block_comments_lines_without_block_comments() {
468468
let result = without_block_comments(vec!["/*", "", "*/"]);
469-
println!("result: {:?}", result);
469+
println!("result: {result:?}");
470470
assert!(result.is_empty());
471471

472472
let result = without_block_comments(vec!["", "/*", "", "*/", "#[crate_type = \"lib\"]", "/*", "", "*/", ""]);

clippy_utils/src/sugg.rs

+25-27
Original file line numberDiff line numberDiff line change
@@ -310,19 +310,19 @@ impl<'a> Sugg<'a> {
310310

311311
/// Convenience method to transform suggestion into a return call
312312
pub fn make_return(self) -> Sugg<'static> {
313-
Sugg::NonParen(Cow::Owned(format!("return {}", self)))
313+
Sugg::NonParen(Cow::Owned(format!("return {self}")))
314314
}
315315

316316
/// Convenience method to transform suggestion into a block
317317
/// where the suggestion is a trailing expression
318318
pub fn blockify(self) -> Sugg<'static> {
319-
Sugg::NonParen(Cow::Owned(format!("{{ {} }}", self)))
319+
Sugg::NonParen(Cow::Owned(format!("{{ {self} }}")))
320320
}
321321

322322
/// Convenience method to prefix the expression with the `async` keyword.
323323
/// Can be used after `blockify` to create an async block.
324324
pub fn asyncify(self) -> Sugg<'static> {
325-
Sugg::NonParen(Cow::Owned(format!("async {}", self)))
325+
Sugg::NonParen(Cow::Owned(format!("async {self}")))
326326
}
327327

328328
/// Convenience method to create the `<lhs>..<rhs>` or `<lhs>...<rhs>`
@@ -346,12 +346,12 @@ impl<'a> Sugg<'a> {
346346
if has_enclosing_paren(&sugg) {
347347
Sugg::MaybeParen(sugg)
348348
} else {
349-
Sugg::NonParen(format!("({})", sugg).into())
349+
Sugg::NonParen(format!("({sugg})").into())
350350
}
351351
},
352352
Sugg::BinOp(op, lhs, rhs) => {
353353
let sugg = binop_to_string(op, &lhs, &rhs);
354-
Sugg::NonParen(format!("({})", sugg).into())
354+
Sugg::NonParen(format!("({sugg})").into())
355355
},
356356
}
357357
}
@@ -379,20 +379,18 @@ fn binop_to_string(op: AssocOp, lhs: &str, rhs: &str) -> String {
379379
| AssocOp::Greater
380380
| AssocOp::GreaterEqual => {
381381
format!(
382-
"{} {} {}",
383-
lhs,
384-
op.to_ast_binop().expect("Those are AST ops").to_string(),
385-
rhs
382+
"{lhs} {} {rhs}",
383+
op.to_ast_binop().expect("Those are AST ops").to_string()
386384
)
387385
},
388-
AssocOp::Assign => format!("{} = {}", lhs, rhs),
386+
AssocOp::Assign => format!("{lhs} = {rhs}"),
389387
AssocOp::AssignOp(op) => {
390-
format!("{} {}= {}", lhs, token_kind_to_string(&token::BinOp(op)), rhs)
388+
format!("{lhs} {}= {rhs}", token_kind_to_string(&token::BinOp(op)))
391389
},
392-
AssocOp::As => format!("{} as {}", lhs, rhs),
393-
AssocOp::DotDot => format!("{}..{}", lhs, rhs),
394-
AssocOp::DotDotEq => format!("{}..={}", lhs, rhs),
395-
AssocOp::Colon => format!("{}: {}", lhs, rhs),
390+
AssocOp::As => format!("{lhs} as {rhs}"),
391+
AssocOp::DotDot => format!("{lhs}..{rhs}"),
392+
AssocOp::DotDotEq => format!("{lhs}..={rhs}"),
393+
AssocOp::Colon => format!("{lhs}: {rhs}"),
396394
}
397395
}
398396

@@ -523,7 +521,7 @@ impl<T: Display> Display for ParenHelper<T> {
523521
/// operators have the same
524522
/// precedence.
525523
pub fn make_unop(op: &str, expr: Sugg<'_>) -> Sugg<'static> {
526-
Sugg::MaybeParen(format!("{}{}", op, expr.maybe_par()).into())
524+
Sugg::MaybeParen(format!("{op}{}", expr.maybe_par()).into())
527525
}
528526

529527
/// Builds the string for `<lhs> <op> <rhs>` adding parenthesis when necessary.
@@ -744,7 +742,7 @@ impl<T: LintContext> DiagnosticExt<T> for rustc_errors::Diagnostic {
744742
if let Some(indent) = indentation(cx, item) {
745743
let span = item.with_hi(item.lo());
746744

747-
self.span_suggestion(span, msg, format!("{}\n{}", attr, indent), applicability);
745+
self.span_suggestion(span, msg, format!("{attr}\n{indent}"), applicability);
748746
}
749747
}
750748

@@ -758,14 +756,14 @@ impl<T: LintContext> DiagnosticExt<T> for rustc_errors::Diagnostic {
758756
.map(|l| {
759757
if first {
760758
first = false;
761-
format!("{}\n", l)
759+
format!("{l}\n")
762760
} else {
763-
format!("{}{}\n", indent, l)
761+
format!("{indent}{l}\n")
764762
}
765763
})
766764
.collect::<String>();
767765

768-
self.span_suggestion(span, msg, format!("{}\n{}", new_item, indent), applicability);
766+
self.span_suggestion(span, msg, format!("{new_item}\n{indent}"), applicability);
769767
}
770768
}
771769

@@ -863,7 +861,7 @@ impl<'tcx> DerefDelegate<'_, 'tcx> {
863861
pub fn finish(&mut self) -> String {
864862
let end_span = Span::new(self.next_pos, self.closure_span.hi(), self.closure_span.ctxt(), None);
865863
let end_snip = snippet_with_applicability(self.cx, end_span, "..", &mut self.applicability);
866-
let sugg = format!("{}{}", self.suggestion_start, end_snip);
864+
let sugg = format!("{}{end_snip}", self.suggestion_start);
867865
if self.closure_arg_is_type_annotated_double_ref {
868866
sugg.replacen('&', "", 1)
869867
} else {
@@ -925,7 +923,7 @@ impl<'tcx> Delegate<'tcx> for DerefDelegate<'_, 'tcx> {
925923
if cmt.place.projections.is_empty() {
926924
// handle item without any projection, that needs an explicit borrowing
927925
// i.e.: suggest `&x` instead of `x`
928-
let _ = write!(self.suggestion_start, "{}&{}", start_snip, ident_str);
926+
let _ = write!(self.suggestion_start, "{start_snip}&{ident_str}");
929927
} else {
930928
// cases where a parent `Call` or `MethodCall` is using the item
931929
// i.e.: suggest `.contains(&x)` for `.find(|x| [1, 2, 3].contains(x)).is_none()`
@@ -940,7 +938,7 @@ impl<'tcx> Delegate<'tcx> for DerefDelegate<'_, 'tcx> {
940938
// given expression is the self argument and will be handled completely by the compiler
941939
// i.e.: `|x| x.is_something()`
942940
ExprKind::MethodCall(_, self_expr, ..) if self_expr.hir_id == cmt.hir_id => {
943-
let _ = write!(self.suggestion_start, "{}{}", start_snip, ident_str_with_proj);
941+
let _ = write!(self.suggestion_start, "{start_snip}{ident_str_with_proj}");
944942
self.next_pos = span.hi();
945943
return;
946944
},
@@ -973,9 +971,9 @@ impl<'tcx> Delegate<'tcx> for DerefDelegate<'_, 'tcx> {
973971
} else {
974972
ident_str
975973
};
976-
format!("{}{}", start_snip, ident)
974+
format!("{start_snip}{ident}")
977975
} else {
978-
format!("{}&{}", start_snip, ident_str)
976+
format!("{start_snip}&{ident_str}")
979977
};
980978
self.suggestion_start.push_str(&ident_sugg);
981979
self.next_pos = span.hi();
@@ -1042,13 +1040,13 @@ impl<'tcx> Delegate<'tcx> for DerefDelegate<'_, 'tcx> {
10421040

10431041
for item in projections {
10441042
if item.kind == ProjectionKind::Deref {
1045-
replacement_str = format!("*{}", replacement_str);
1043+
replacement_str = format!("*{replacement_str}");
10461044
}
10471045
}
10481046
}
10491047
}
10501048

1051-
let _ = write!(self.suggestion_start, "{}{}", start_snip, replacement_str);
1049+
let _ = write!(self.suggestion_start, "{start_snip}{replacement_str}");
10521050
}
10531051
self.next_pos = span.hi();
10541052
}

rustc_tools_util/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ impl std::fmt::Display for VersionInfo {
4848
if (hash_trimmed.len() + date_trimmed.len()) > 0 {
4949
write!(
5050
f,
51-
"{} {}.{}.{} ({} {})",
52-
self.crate_name, self.major, self.minor, self.patch, hash_trimmed, date_trimmed,
51+
"{} {}.{}.{} ({hash_trimmed} {date_trimmed})",
52+
self.crate_name, self.major, self.minor, self.patch,
5353
)?;
5454
} else {
5555
write!(f, "{} {}.{}.{}", self.crate_name, self.major, self.minor, self.patch)?;
@@ -153,7 +153,7 @@ mod test {
153153
#[test]
154154
fn test_debug_local() {
155155
let vi = get_version_info!();
156-
let s = format!("{:?}", vi);
156+
let s = format!("{vi:?}");
157157
assert_eq!(
158158
s,
159159
"VersionInfo { crate_name: \"rustc_tools_util\", major: 0, minor: 2, patch: 0 }"

tests/integration.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::process::Command;
99
#[cfg_attr(feature = "integration", test)]
1010
fn integration_test() {
1111
let repo_name = env::var("INTEGRATION").expect("`INTEGRATION` var not set");
12-
let repo_url = format!("https://github.com/{}", repo_name);
12+
let repo_url = format!("https://github.com/{repo_name}");
1313
let crate_name = repo_name
1414
.split('/')
1515
.nth(1)
@@ -83,7 +83,7 @@ fn integration_test() {
8383

8484
match output.status.code() {
8585
Some(0) => println!("Compilation successful"),
86-
Some(code) => eprintln!("Compilation failed. Exit code: {}", code),
86+
Some(code) => eprintln!("Compilation failed. Exit code: {code}"),
8787
None => panic!("Process terminated by signal"),
8888
}
8989
}

0 commit comments

Comments
 (0)