Skip to content

Commit 9351d31

Browse files
authored
Rollup merge of #93632 - matthiaskrgr:rustdoclippy2, r=GuillaumeGomez
rustdoc: clippy::complexity fixes clippy::map_flatten clippy::clone_on_copy clippy::useless_conversion clippy::needless_arbitrary_self_type
2 parents 4b70359 + f1a399a commit 9351d31

File tree

7 files changed

+7
-13
lines changed

7 files changed

+7
-13
lines changed

src/librustdoc/clean/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1533,9 +1533,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
15331533
for pb in obj.projection_bounds() {
15341534
bindings.push(TypeBinding {
15351535
name: cx.tcx.associated_item(pb.item_def_id()).name,
1536-
kind: TypeBindingKind::Equality {
1537-
term: pb.skip_binder().term.clean(cx).into(),
1538-
},
1536+
kind: TypeBindingKind::Equality { term: pb.skip_binder().term.clean(cx) },
15391537
});
15401538
}
15411539

src/librustdoc/clean/types.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1036,8 +1036,7 @@ impl Attributes {
10361036
// Additional documentation should be shown before the original documentation
10371037
let other_attrs = additional_attrs
10381038
.into_iter()
1039-
.map(|(attrs, id)| attrs.iter().map(move |attr| (attr, Some(id))))
1040-
.flatten()
1039+
.flat_map(|(attrs, id)| attrs.iter().map(move |attr| (attr, Some(id))))
10411040
.chain(attrs.iter().map(|attr| (attr, None)))
10421041
.filter_map(clean_attr)
10431042
.collect();

src/librustdoc/config.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -439,13 +439,12 @@ impl Options {
439439
matches
440440
.opt_str("default-theme")
441441
.iter()
442-
.map(|theme| {
442+
.flat_map(|theme| {
443443
vec![
444444
("use-system-theme".to_string(), "false".to_string()),
445445
("theme".to_string(), theme.to_string()),
446446
]
447447
})
448-
.flatten()
449448
.collect(),
450449
matches
451450
.opt_strs("default-setting")

src/librustdoc/html/format.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl core::fmt::Write for Buffer {
7676
}
7777

7878
#[inline]
79-
fn write_fmt(self: &mut Self, args: fmt::Arguments<'_>) -> fmt::Result {
79+
fn write_fmt(&mut self, args: fmt::Arguments<'_>) -> fmt::Result {
8080
self.buffer.write_fmt(args)
8181
}
8282
}

src/librustdoc/html/highlight.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,7 @@ impl Decorations {
274274
let (mut starts, mut ends): (Vec<_>, Vec<_>) = info
275275
.0
276276
.into_iter()
277-
.map(|(kind, ranges)| ranges.into_iter().map(move |(lo, hi)| ((lo, kind), hi)))
278-
.flatten()
277+
.flat_map(|(kind, ranges)| ranges.into_iter().map(move |(lo, hi)| ((lo, kind), hi)))
279278
.unzip();
280279

281280
// Sort the sequences in document order.

src/librustdoc/html/render/search_index.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ crate fn build_index<'tcx>(krate: &clean::Crate, cache: &mut Cache, tcx: TyCtxt<
8181
lastpathid += 1;
8282

8383
if let Some(&(ref fqp, short)) = paths.get(&defid) {
84-
crate_paths.push((short, fqp.last().unwrap().clone()));
84+
crate_paths.push((short, *fqp.last().unwrap()));
8585
Some(pathid)
8686
} else {
8787
None

src/librustdoc/scrape_examples.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,7 @@ crate fn run(
247247
let target_crates = options
248248
.target_crates
249249
.into_iter()
250-
.map(|target| all_crates.iter().filter(move |(_, name)| name.as_str() == target))
251-
.flatten()
250+
.flat_map(|target| all_crates.iter().filter(move |(_, name)| name.as_str() == target))
252251
.map(|(crate_num, _)| **crate_num)
253252
.collect::<Vec<_>>();
254253

0 commit comments

Comments
 (0)