Skip to content

Commit 2e2f770

Browse files
committed
remove uncessary parens in closure body in library
1 parent 5c0c317 commit 2e2f770

File tree

8 files changed

+15
-15
lines changed

8 files changed

+15
-15
lines changed

compiler/rustc_lint/src/unused.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -913,8 +913,8 @@ trait UnusedDelimLint {
913913
MethodCall(ref call) => (&call.args[..], UnusedDelimsCtx::MethodArg),
914914
Closure(ref closure)
915915
if matches!(closure.fn_decl.output, FnRetTy::Default(_))
916-
// skip `#[core::contracts::requires(...)]` and `#[core::contracts::ensures(...)]` which generate closure
917-
// with span that is same as the closure body span
916+
// skip `#[core::contracts::requires(...)]` and `#[core::contracts::ensures(...)]`
917+
// which generate closure expr with span that is same as the inner closure body span
918918
&& e.span != closure.body.span =>
919919
{
920920
(&[closure.body.clone()][..], UnusedDelimsCtx::ClosureBody)

compiler/rustc_mir_transform/src/coverage/tests.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ fn print_mir_graphviz(name: &str, mir_body: &Body<'_>) {
217217
mir_body
218218
.basic_blocks
219219
.successors(bb)
220-
.map(|successor| { format!(" {:?} -> {:?};", bb, successor) })
220+
.map(|successor| format!(" {:?} -> {:?};", bb, successor))
221221
.join("\n")
222222
)
223223
})
@@ -241,7 +241,7 @@ fn print_coverage_graphviz(name: &str, mir_body: &Body<'_>, graph: &graph::Cover
241241
mir_body[bcb_data.last_bb()].terminator().kind.name(),
242242
graph
243243
.successors(bcb)
244-
.map(|successor| { format!(" {:?} -> {:?};", bcb, successor) })
244+
.map(|successor| format!(" {:?} -> {:?};", bcb, successor))
245245
.join("\n")
246246
)
247247
})

library/alloc/src/collections/btree/map/entry.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,12 @@ impl<'a, K: Ord, V, A: Allocator + Clone> Entry<'a, K, V, A> {
247247
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
248248
///
249249
/// map.entry("poneyland")
250-
/// .and_modify(|e| { *e += 1 })
250+
/// .and_modify(|e| *e += 1)
251251
/// .or_insert(42);
252252
/// assert_eq!(map["poneyland"], 42);
253253
///
254254
/// map.entry("poneyland")
255-
/// .and_modify(|e| { *e += 1 })
255+
/// .and_modify(|e| *e += 1)
256256
/// .or_insert(42);
257257
/// assert_eq!(map["poneyland"], 43);
258258
/// ```

library/alloc/src/vec/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3654,7 +3654,7 @@ impl<T, A: Allocator> Vec<T, A> {
36543654
///
36553655
/// ```
36563656
/// # use std::cmp::min;
3657-
/// # let some_predicate = |x: &mut i32| { *x == 2 || *x == 3 || *x == 6 };
3657+
/// # let some_predicate = |x: &mut i32| *x == 2 || *x == 3 || *x == 6;
36583658
/// # let mut vec = vec![1, 2, 3, 4, 5, 6];
36593659
/// # let range = 1..4;
36603660
/// let mut i = range.start;

library/std/src/collections/hash/map.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2026,13 +2026,13 @@ impl<'a, K, V, S> RawEntryMut<'a, K, V, S> {
20262026
///
20272027
/// map.raw_entry_mut()
20282028
/// .from_key("poneyland")
2029-
/// .and_modify(|_k, v| { *v += 1 })
2029+
/// .and_modify(|_k, v| *v += 1)
20302030
/// .or_insert("poneyland", 42);
20312031
/// assert_eq!(map["poneyland"], 42);
20322032
///
20332033
/// map.raw_entry_mut()
20342034
/// .from_key("poneyland")
2035-
/// .and_modify(|_k, v| { *v += 1 })
2035+
/// .and_modify(|_k, v| *v += 1)
20362036
/// .or_insert("poneyland", 0);
20372037
/// assert_eq!(map["poneyland"], 43);
20382038
/// ```
@@ -2883,12 +2883,12 @@ impl<'a, K, V> Entry<'a, K, V> {
28832883
/// let mut map: HashMap<&str, u32> = HashMap::new();
28842884
///
28852885
/// map.entry("poneyland")
2886-
/// .and_modify(|e| { *e += 1 })
2886+
/// .and_modify(|e| *e += 1)
28872887
/// .or_insert(42);
28882888
/// assert_eq!(map["poneyland"], 42);
28892889
///
28902890
/// map.entry("poneyland")
2891-
/// .and_modify(|e| { *e += 1 })
2891+
/// .and_modify(|e| *e += 1)
28922892
/// .or_insert(42);
28932893
/// assert_eq!(map["poneyland"], 43);
28942894
/// ```

library/std/src/sync/poison/condvar.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ impl Condvar {
238238
/// // Wait for the thread to start up.
239239
/// let (lock, cvar) = &*pair;
240240
/// // As long as the value inside the `Mutex<bool>` is `true`, we wait.
241-
/// let _guard = cvar.wait_while(lock.lock().unwrap(), |pending| { *pending }).unwrap();
241+
/// let _guard = cvar.wait_while(lock.lock().unwrap(), |pending| *pending).unwrap();
242242
/// ```
243243
#[stable(feature = "wait_until", since = "1.42.0")]
244244
pub fn wait_while<'a, T, F>(

library/std/tests/env_modify.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ fn test_env_set_var() {
9191
unsafe {
9292
set_var(&n, "VALUE");
9393
}
94-
assert!(!e.any(|(k, v)| { &*k == &*n && &*v == "VALUE" }));
94+
assert!(!e.any(|(k, v)| &*k == &*n && &*v == "VALUE"));
9595

96-
assert!(vars_os().any(|(k, v)| { &*k == &*n && &*v == "VALUE" }));
96+
assert!(vars_os().any(|(k, v)| &*k == &*n && &*v == "VALUE"));
9797
}
9898

9999
#[test]

src/etc/test-float-parse/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ fn launch_tests(tests: &mut [TestInfo], cfg: &Config) -> Duration {
333333
for test in tests.iter_mut() {
334334
test.progress = Some(ui::Progress::new(test, &mut all_progress_bars));
335335
ui::set_panic_hook(&all_progress_bars);
336-
((test.launch)(test, cfg));
336+
(t.launch)(test, cfg);
337337
}
338338

339339
start.elapsed()

0 commit comments

Comments
 (0)