Skip to content

Commit d95948c

Browse files
authored
Rollup merge of #79732 - matthiaskrgr:cl12ppy, r=Dylan-DPC
minor stylistic clippy cleanups simplify if let Some(_) = x to if x.is_some() (clippy::redundant_pattern_matching) don't create owned values for comparison (clippy::cmp_owned) use .contains() or .any() instead of find(x).is_some() (clippy::search_is_some) don't wrap code block in Ok() (clipppy::unit_arg)
2 parents c16d52d + 20f8538 commit d95948c

File tree

5 files changed

+10
-9
lines changed

5 files changed

+10
-9
lines changed

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/different_lifetimes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
121121

122122
(Some(ret_span), _) => {
123123
let sup_future = self.future_return_type(scope_def_id_sup);
124-
let (return_type, action) = if let Some(_) = sup_future {
124+
let (return_type, action) = if sup_future.is_some() {
125125
("returned future", "held across an await point")
126126
} else {
127127
("return type", "returned")
@@ -140,7 +140,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
140140
}
141141
(_, Some(ret_span)) => {
142142
let sub_future = self.future_return_type(scope_def_id_sub);
143-
let (return_type, action) = if let Some(_) = sub_future {
143+
let (return_type, action) = if sub_future.is_some() {
144144
("returned future", "held across an await point")
145145
} else {
146146
("return type", "returned")

compiler/rustc_lint/src/nonstandard_style.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ impl NonCamelCaseTypes {
131131
let cc = to_camel_case(name);
132132
// We cannot provide meaningful suggestions
133133
// if the characters are in the category of "Lowercase Letter".
134-
if name.to_string() != cc {
134+
if *name != cc {
135135
err.span_suggestion(
136136
ident.span,
137137
"convert the identifier to upper camel case",
@@ -271,7 +271,7 @@ impl NonSnakeCase {
271271
let mut err = lint.build(&msg);
272272
// We cannot provide meaningful suggestions
273273
// if the characters are in the category of "Uppercase Letter".
274-
if name.to_string() != sc {
274+
if *name != sc {
275275
// We have a valid span in almost all cases, but we don't have one when linting a crate
276276
// name provided via the command line.
277277
if !ident.span.is_dummy() {
@@ -455,7 +455,7 @@ impl NonUpperCaseGlobals {
455455
lint.build(&format!("{} `{}` should have an upper case name", sort, name));
456456
// We cannot provide meaningful suggestions
457457
// if the characters are in the category of "Lowercase Letter".
458-
if name.to_string() != uc {
458+
if *name != uc {
459459
err.span_suggestion(
460460
ident.span,
461461
"convert the identifier to upper case",

compiler/rustc_mir/src/borrow_check/diagnostics/region_name.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
445445
"highlight_if_we_cannot_match_hir_ty: type_name={:?} needle_fr={:?}",
446446
type_name, needle_fr
447447
);
448-
if type_name.find(&format!("'{}", counter)).is_some() {
448+
if type_name.contains(&format!("'{}", counter)) {
449449
// Only add a label if we can confirm that a region was labelled.
450450
RegionNameHighlight::CannotMatchHirTy(span, type_name)
451451
} else {

src/bootstrap/setup.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ simply delete the `pre-commit` file from .git/hooks."
198198
};
199199
};
200200

201-
Ok(if should_install {
201+
if should_install {
202202
let src = src_path.join("src").join("etc").join("pre-commit.sh");
203203
let git = t!(Command::new("git").args(&["rev-parse", "--git-common-dir"]).output().map(
204204
|output| {
@@ -217,5 +217,6 @@ simply delete the `pre-commit` file from .git/hooks."
217217
};
218218
} else {
219219
println!("Ok, skipping installation!");
220-
})
220+
}
221+
Ok(())
221222
}

src/librustdoc/html/markdown.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for LinkReplacer<'a, I> {
391391
_,
392392
))) => {
393393
debug!("saw end of shortcut link to {}", dest);
394-
if self.links.iter().find(|&link| *link.href == **dest).is_some() {
394+
if self.links.iter().any(|link| *link.href == **dest) {
395395
assert!(self.shortcut_link.is_some(), "saw closing link without opening tag");
396396
self.shortcut_link = None;
397397
}

0 commit comments

Comments
 (0)