Skip to content

Commit 362a93b

Browse files
authored
Unrolled build for rust-lang#125730
Rollup merge of rust-lang#125730 - mu001999-contrib:clippy-fix, r=oli-obk Apply `x clippy --fix` and `x fmt` on Rustc <!-- If this PR is related to an unstable feature or an otherwise tracked effort, please link to the relevant tracking issue here. If you don't know of a related tracking issue or there are none, feel free to ignore this. This PR will get automatically assigned to a reviewer. In case you would like a specific user to review your work, you can assign it to them by using r​? <reviewer name> --> Just run `x clippy --fix` and `x fmt`, and remove some changes like `impl Default`.
2 parents 2a2c29a + dabd05b commit 362a93b

File tree

14 files changed

+28
-30
lines changed

14 files changed

+28
-30
lines changed

compiler/rustc_data_structures/src/graph/dominators/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ fn dominators_impl<G: ControlFlowGraph>(graph: &G) -> Inner<G::Node> {
9393
// These are all done here rather than through one of the 'standard'
9494
// graph traversals to help make this fast.
9595
'recurse: while let Some(frame) = stack.last_mut() {
96-
while let Some(successor) = frame.iter.next() {
96+
for successor in frame.iter.by_ref() {
9797
if real_to_pre_order[successor].is_none() {
9898
let pre_order_idx = pre_order_to_real.push(successor);
9999
real_to_pre_order[successor] = Some(pre_order_idx);

compiler/rustc_data_structures/src/graph/iterate/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ fn post_order_walk<G: DirectedGraph + Successors>(
4848
let node = frame.node;
4949
visited[node] = true;
5050

51-
while let Some(successor) = frame.iter.next() {
51+
for successor in frame.iter.by_ref() {
5252
if !visited[successor] {
5353
stack.push(PostOrderFrame { node: successor, iter: graph.successors(successor) });
5454
continue 'recurse;
@@ -112,7 +112,7 @@ where
112112
/// This is equivalent to just invoke `next` repeatedly until
113113
/// you get a `None` result.
114114
pub fn complete_search(&mut self) {
115-
while let Some(_) = self.next() {}
115+
for _ in self.by_ref() {}
116116
}
117117

118118
/// Returns true if node has been visited thus far.

compiler/rustc_data_structures/src/graph/scc/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub struct SccData<S: Idx> {
4040
}
4141

4242
impl<N: Idx, S: Idx + Ord> Sccs<N, S> {
43-
pub fn new(graph: &(impl DirectedGraph<Node = N> + Successors)) -> Self {
43+
pub fn new(graph: &impl Successors<Node = N>) -> Self {
4444
SccsConstruction::construct(graph)
4545
}
4646

compiler/rustc_data_structures/src/profiling.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ impl SelfProfiler {
562562
// ASLR is disabled and the heap is otherwise deterministic.
563563
let pid: u32 = process::id();
564564
let filename = format!("{crate_name}-{pid:07}.rustc_profile");
565-
let path = output_directory.join(&filename);
565+
let path = output_directory.join(filename);
566566
let profiler =
567567
Profiler::with_counter(&path, measureme::counters::Counter::by_name(counter_name)?)?;
568568

compiler/rustc_data_structures/src/sorted_map.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,13 @@ impl<K: Ord, V> SortedMap<K, V> {
125125

126126
/// Iterate over the keys, sorted
127127
#[inline]
128-
pub fn keys(&self) -> impl Iterator<Item = &K> + ExactSizeIterator + DoubleEndedIterator {
128+
pub fn keys(&self) -> impl ExactSizeIterator<Item = &K> + DoubleEndedIterator {
129129
self.data.iter().map(|(k, _)| k)
130130
}
131131

132132
/// Iterate over values, sorted by key
133133
#[inline]
134-
pub fn values(&self) -> impl Iterator<Item = &V> + ExactSizeIterator + DoubleEndedIterator {
134+
pub fn values(&self) -> impl ExactSizeIterator<Item = &V> + DoubleEndedIterator {
135135
self.data.iter().map(|(_, v)| v)
136136
}
137137

compiler/rustc_data_structures/src/sync/lock.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ mod maybe_sync {
6969
match self.mode {
7070
Mode::NoSync => {
7171
let cell = unsafe { &self.lock.mode_union.no_sync };
72-
debug_assert_eq!(cell.get(), true);
72+
debug_assert!(cell.get());
7373
cell.set(false);
7474
}
7575
// SAFETY (unlock): We know that the lock is locked as this type is a proof of that.

compiler/rustc_parse_format/src/lib.rs

+8-10
Original file line numberDiff line numberDiff line change
@@ -286,13 +286,11 @@ impl<'a> Iterator for Parser<'a> {
286286
lbrace_byte_pos.to(InnerOffset(rbrace_byte_pos.0 + width)),
287287
);
288288
}
289-
} else {
290-
if let Some(&(_, maybe)) = self.cur.peek() {
291-
match maybe {
292-
'?' => self.suggest_format_debug(),
293-
'<' | '^' | '>' => self.suggest_format_align(maybe),
294-
_ => self.suggest_positional_arg_instead_of_captured_arg(arg),
295-
}
289+
} else if let Some(&(_, maybe)) = self.cur.peek() {
290+
match maybe {
291+
'?' => self.suggest_format_debug(),
292+
'<' | '^' | '>' => self.suggest_format_align(maybe),
293+
_ => self.suggest_positional_arg_instead_of_captured_arg(arg),
296294
}
297295
}
298296
Some(NextArgument(Box::new(arg)))
@@ -1028,7 +1026,7 @@ fn find_width_map_from_snippet(
10281026
if next_c == '{' {
10291027
// consume up to 6 hexanumeric chars
10301028
let digits_len =
1031-
s.clone().take(6).take_while(|(_, c)| c.is_digit(16)).count();
1029+
s.clone().take(6).take_while(|(_, c)| c.is_ascii_hexdigit()).count();
10321030

10331031
let len_utf8 = s
10341032
.as_str()
@@ -1047,14 +1045,14 @@ fn find_width_map_from_snippet(
10471045
width += required_skips + 2;
10481046

10491047
s.nth(digits_len);
1050-
} else if next_c.is_digit(16) {
1048+
} else if next_c.is_ascii_hexdigit() {
10511049
width += 1;
10521050

10531051
// We suggest adding `{` and `}` when appropriate, accept it here as if
10541052
// it were correct
10551053
let mut i = 0; // consume up to 6 hexanumeric chars
10561054
while let (Some((_, c)), _) = (s.next(), i < 6) {
1057-
if c.is_digit(16) {
1055+
if c.is_ascii_hexdigit() {
10581056
width += 1;
10591057
} else {
10601058
break;

compiler/rustc_serialize/src/serialize.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ impl<S: Encoder> Encodable<S> for () {
252252
}
253253

254254
impl<D: Decoder> Decodable<D> for () {
255-
fn decode(_: &mut D) -> () {}
255+
fn decode(_: &mut D) {}
256256
}
257257

258258
impl<S: Encoder, T> Encodable<S> for PhantomData<T> {

compiler/stable_mir/src/mir/pretty.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ fn pretty_terminator<W: Write>(writer: &mut W, terminator: &TerminatorKind) -> i
156156

157157
fn pretty_terminator_head<W: Write>(writer: &mut W, terminator: &TerminatorKind) -> io::Result<()> {
158158
use self::TerminatorKind::*;
159-
const INDENT: &'static str = " ";
159+
const INDENT: &str = " ";
160160
match terminator {
161161
Goto { .. } => write!(writer, "{INDENT}goto"),
162162
SwitchInt { discr, .. } => {
@@ -315,7 +315,7 @@ fn pretty_operand(operand: &Operand) -> String {
315315
}
316316

317317
fn pretty_const(literal: &Const) -> String {
318-
with(|cx| cx.const_pretty(&literal))
318+
with(|cx| cx.const_pretty(literal))
319319
}
320320

321321
fn pretty_rvalue<W: Write>(writer: &mut W, rval: &Rvalue) -> io::Result<()> {

compiler/stable_mir/src/ty.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ pub enum IntTy {
526526
impl IntTy {
527527
pub fn num_bytes(self) -> usize {
528528
match self {
529-
IntTy::Isize => crate::target::MachineInfo::target_pointer_width().bytes().into(),
529+
IntTy::Isize => crate::target::MachineInfo::target_pointer_width().bytes(),
530530
IntTy::I8 => 1,
531531
IntTy::I16 => 2,
532532
IntTy::I32 => 4,
@@ -549,7 +549,7 @@ pub enum UintTy {
549549
impl UintTy {
550550
pub fn num_bytes(self) -> usize {
551551
match self {
552-
UintTy::Usize => crate::target::MachineInfo::target_pointer_width().bytes().into(),
552+
UintTy::Usize => crate::target::MachineInfo::target_pointer_width().bytes(),
553553
UintTy::U8 => 1,
554554
UintTy::U16 => 2,
555555
UintTy::U32 => 4,
@@ -1185,7 +1185,7 @@ impl Allocation {
11851185
match self.read_int()? {
11861186
0 => Ok(false),
11871187
1 => Ok(true),
1188-
val @ _ => Err(error!("Unexpected value for bool: `{val}`")),
1188+
val => Err(error!("Unexpected value for bool: `{val}`")),
11891189
}
11901190
}
11911191

library/proc_macro/src/bridge/fxhash.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl Hasher for FxHasher {
6969
hash.add_to_hash(u16::from_ne_bytes(bytes[..2].try_into().unwrap()) as usize);
7070
bytes = &bytes[2..];
7171
}
72-
if (size_of::<usize>() > 1) && bytes.len() >= 1 {
72+
if (size_of::<usize>() > 1) && !bytes.is_empty() {
7373
hash.add_to_hash(bytes[0] as usize);
7474
}
7575
self.hash = hash.hash;

library/proc_macro/src/bridge/rpc.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,9 @@ impl From<Box<dyn Any + Send>> for PanicMessage {
264264
}
265265
}
266266

267-
impl Into<Box<dyn Any + Send>> for PanicMessage {
268-
fn into(self) -> Box<dyn Any + Send> {
269-
match self {
267+
impl From<PanicMessage> for Box<dyn Any + Send> {
268+
fn from(val: PanicMessage) -> Self {
269+
match val {
270270
PanicMessage::StaticStr(s) => Box::new(s),
271271
PanicMessage::String(s) => Box::new(s),
272272
PanicMessage::Unknown => {

library/test/src/cli.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ Test Attributes:
200200
pub fn parse_opts(args: &[String]) -> Option<OptRes> {
201201
// Parse matches.
202202
let opts = optgroups();
203-
let binary = args.get(0).map(|c| &**c).unwrap_or("...");
203+
let binary = args.first().map(|c| &**c).unwrap_or("...");
204204
let args = args.get(1..).unwrap_or(args);
205205
let matches = match opts.parse(args) {
206206
Ok(m) => m,

library/test/src/term/terminfo/parm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ fn format(val: Param, op: FormatOp, flags: Flags) -> Result<Vec<u8>, String> {
524524
} else {
525525
let mut s_ = Vec::with_capacity(flags.width);
526526
s_.extend(repeat(b' ').take(n));
527-
s_.extend(s.into_iter());
527+
s_.extend(s);
528528
s = s_;
529529
}
530530
}

0 commit comments

Comments
 (0)