Rollup merge of #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`.
This commit is contained in:
commit
e9046602c5
@ -93,7 +93,7 @@ fn dominators_impl<G: ControlFlowGraph>(graph: &G) -> Inner<G::Node> {
|
|||||||
// These are all done here rather than through one of the 'standard'
|
// These are all done here rather than through one of the 'standard'
|
||||||
// graph traversals to help make this fast.
|
// graph traversals to help make this fast.
|
||||||
'recurse: while let Some(frame) = stack.last_mut() {
|
'recurse: while let Some(frame) = stack.last_mut() {
|
||||||
while let Some(successor) = frame.iter.next() {
|
for successor in frame.iter.by_ref() {
|
||||||
if real_to_pre_order[successor].is_none() {
|
if real_to_pre_order[successor].is_none() {
|
||||||
let pre_order_idx = pre_order_to_real.push(successor);
|
let pre_order_idx = pre_order_to_real.push(successor);
|
||||||
real_to_pre_order[successor] = Some(pre_order_idx);
|
real_to_pre_order[successor] = Some(pre_order_idx);
|
||||||
|
@ -48,7 +48,7 @@ struct PostOrderFrame<Node, Iter> {
|
|||||||
let node = frame.node;
|
let node = frame.node;
|
||||||
visited[node] = true;
|
visited[node] = true;
|
||||||
|
|
||||||
while let Some(successor) = frame.iter.next() {
|
for successor in frame.iter.by_ref() {
|
||||||
if !visited[successor] {
|
if !visited[successor] {
|
||||||
stack.push(PostOrderFrame { node: successor, iter: graph.successors(successor) });
|
stack.push(PostOrderFrame { node: successor, iter: graph.successors(successor) });
|
||||||
continue 'recurse;
|
continue 'recurse;
|
||||||
@ -112,7 +112,7 @@ pub fn push_start_node(&mut self, start_node: G::Node) {
|
|||||||
/// This is equivalent to just invoke `next` repeatedly until
|
/// This is equivalent to just invoke `next` repeatedly until
|
||||||
/// you get a `None` result.
|
/// you get a `None` result.
|
||||||
pub fn complete_search(&mut self) {
|
pub fn complete_search(&mut self) {
|
||||||
while let Some(_) = self.next() {}
|
for _ in self.by_ref() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true if node has been visited thus far.
|
/// Returns true if node has been visited thus far.
|
||||||
|
@ -40,7 +40,7 @@ pub struct SccData<S: Idx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<N: Idx, S: Idx + Ord> Sccs<N, S> {
|
impl<N: Idx, S: Idx + Ord> Sccs<N, S> {
|
||||||
pub fn new(graph: &(impl DirectedGraph<Node = N> + Successors)) -> Self {
|
pub fn new(graph: &impl Successors<Node = N>) -> Self {
|
||||||
SccsConstruction::construct(graph)
|
SccsConstruction::construct(graph)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -562,7 +562,7 @@ pub fn new(
|
|||||||
// ASLR is disabled and the heap is otherwise deterministic.
|
// ASLR is disabled and the heap is otherwise deterministic.
|
||||||
let pid: u32 = process::id();
|
let pid: u32 = process::id();
|
||||||
let filename = format!("{crate_name}-{pid:07}.rustc_profile");
|
let filename = format!("{crate_name}-{pid:07}.rustc_profile");
|
||||||
let path = output_directory.join(&filename);
|
let path = output_directory.join(filename);
|
||||||
let profiler =
|
let profiler =
|
||||||
Profiler::with_counter(&path, measureme::counters::Counter::by_name(counter_name)?)?;
|
Profiler::with_counter(&path, measureme::counters::Counter::by_name(counter_name)?)?;
|
||||||
|
|
||||||
|
@ -125,13 +125,13 @@ pub fn iter(&self) -> std::slice::Iter<'_, (K, V)> {
|
|||||||
|
|
||||||
/// Iterate over the keys, sorted
|
/// Iterate over the keys, sorted
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn keys(&self) -> impl Iterator<Item = &K> + ExactSizeIterator + DoubleEndedIterator {
|
pub fn keys(&self) -> impl ExactSizeIterator<Item = &K> + DoubleEndedIterator {
|
||||||
self.data.iter().map(|(k, _)| k)
|
self.data.iter().map(|(k, _)| k)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Iterate over values, sorted by key
|
/// Iterate over values, sorted by key
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn values(&self) -> impl Iterator<Item = &V> + ExactSizeIterator + DoubleEndedIterator {
|
pub fn values(&self) -> impl ExactSizeIterator<Item = &V> + DoubleEndedIterator {
|
||||||
self.data.iter().map(|(_, v)| v)
|
self.data.iter().map(|(_, v)| v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ fn drop(&mut self) {
|
|||||||
match self.mode {
|
match self.mode {
|
||||||
Mode::NoSync => {
|
Mode::NoSync => {
|
||||||
let cell = unsafe { &self.lock.mode_union.no_sync };
|
let cell = unsafe { &self.lock.mode_union.no_sync };
|
||||||
debug_assert_eq!(cell.get(), true);
|
debug_assert!(cell.get());
|
||||||
cell.set(false);
|
cell.set(false);
|
||||||
}
|
}
|
||||||
// SAFETY (unlock): We know that the lock is locked as this type is a proof of that.
|
// SAFETY (unlock): We know that the lock is locked as this type is a proof of that.
|
||||||
|
@ -286,13 +286,11 @@ fn next(&mut self) -> Option<Piece<'a>> {
|
|||||||
lbrace_byte_pos.to(InnerOffset(rbrace_byte_pos.0 + width)),
|
lbrace_byte_pos.to(InnerOffset(rbrace_byte_pos.0 + width)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else if let Some(&(_, maybe)) = self.cur.peek() {
|
||||||
if let Some(&(_, maybe)) = self.cur.peek() {
|
match maybe {
|
||||||
match maybe {
|
'?' => self.suggest_format_debug(),
|
||||||
'?' => self.suggest_format_debug(),
|
'<' | '^' | '>' => self.suggest_format_align(maybe),
|
||||||
'<' | '^' | '>' => self.suggest_format_align(maybe),
|
_ => self.suggest_positional_arg_instead_of_captured_arg(arg),
|
||||||
_ => self.suggest_positional_arg_instead_of_captured_arg(arg),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(NextArgument(Box::new(arg)))
|
Some(NextArgument(Box::new(arg)))
|
||||||
@ -1028,7 +1026,7 @@ fn find_width_map_from_snippet(
|
|||||||
if next_c == '{' {
|
if next_c == '{' {
|
||||||
// consume up to 6 hexanumeric chars
|
// consume up to 6 hexanumeric chars
|
||||||
let digits_len =
|
let digits_len =
|
||||||
s.clone().take(6).take_while(|(_, c)| c.is_digit(16)).count();
|
s.clone().take(6).take_while(|(_, c)| c.is_ascii_hexdigit()).count();
|
||||||
|
|
||||||
let len_utf8 = s
|
let len_utf8 = s
|
||||||
.as_str()
|
.as_str()
|
||||||
@ -1047,14 +1045,14 @@ fn find_width_map_from_snippet(
|
|||||||
width += required_skips + 2;
|
width += required_skips + 2;
|
||||||
|
|
||||||
s.nth(digits_len);
|
s.nth(digits_len);
|
||||||
} else if next_c.is_digit(16) {
|
} else if next_c.is_ascii_hexdigit() {
|
||||||
width += 1;
|
width += 1;
|
||||||
|
|
||||||
// We suggest adding `{` and `}` when appropriate, accept it here as if
|
// We suggest adding `{` and `}` when appropriate, accept it here as if
|
||||||
// it were correct
|
// it were correct
|
||||||
let mut i = 0; // consume up to 6 hexanumeric chars
|
let mut i = 0; // consume up to 6 hexanumeric chars
|
||||||
while let (Some((_, c)), _) = (s.next(), i < 6) {
|
while let (Some((_, c)), _) = (s.next(), i < 6) {
|
||||||
if c.is_digit(16) {
|
if c.is_ascii_hexdigit() {
|
||||||
width += 1;
|
width += 1;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
|
@ -252,7 +252,7 @@ fn encode(&self, _s: &mut S) {}
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<D: Decoder> Decodable<D> for () {
|
impl<D: Decoder> Decodable<D> for () {
|
||||||
fn decode(_: &mut D) -> () {}
|
fn decode(_: &mut D) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: Encoder, T> Encodable<S> for PhantomData<T> {
|
impl<S: Encoder, T> Encodable<S> for PhantomData<T> {
|
||||||
|
@ -156,7 +156,7 @@ fn pretty_terminator<W: Write>(writer: &mut W, terminator: &TerminatorKind) -> i
|
|||||||
|
|
||||||
fn pretty_terminator_head<W: Write>(writer: &mut W, terminator: &TerminatorKind) -> io::Result<()> {
|
fn pretty_terminator_head<W: Write>(writer: &mut W, terminator: &TerminatorKind) -> io::Result<()> {
|
||||||
use self::TerminatorKind::*;
|
use self::TerminatorKind::*;
|
||||||
const INDENT: &'static str = " ";
|
const INDENT: &str = " ";
|
||||||
match terminator {
|
match terminator {
|
||||||
Goto { .. } => write!(writer, "{INDENT}goto"),
|
Goto { .. } => write!(writer, "{INDENT}goto"),
|
||||||
SwitchInt { discr, .. } => {
|
SwitchInt { discr, .. } => {
|
||||||
@ -315,7 +315,7 @@ fn pretty_operand(operand: &Operand) -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn pretty_const(literal: &Const) -> String {
|
fn pretty_const(literal: &Const) -> String {
|
||||||
with(|cx| cx.const_pretty(&literal))
|
with(|cx| cx.const_pretty(literal))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pretty_rvalue<W: Write>(writer: &mut W, rval: &Rvalue) -> io::Result<()> {
|
fn pretty_rvalue<W: Write>(writer: &mut W, rval: &Rvalue) -> io::Result<()> {
|
||||||
|
@ -526,7 +526,7 @@ pub enum IntTy {
|
|||||||
impl IntTy {
|
impl IntTy {
|
||||||
pub fn num_bytes(self) -> usize {
|
pub fn num_bytes(self) -> usize {
|
||||||
match self {
|
match self {
|
||||||
IntTy::Isize => crate::target::MachineInfo::target_pointer_width().bytes().into(),
|
IntTy::Isize => crate::target::MachineInfo::target_pointer_width().bytes(),
|
||||||
IntTy::I8 => 1,
|
IntTy::I8 => 1,
|
||||||
IntTy::I16 => 2,
|
IntTy::I16 => 2,
|
||||||
IntTy::I32 => 4,
|
IntTy::I32 => 4,
|
||||||
@ -549,7 +549,7 @@ pub enum UintTy {
|
|||||||
impl UintTy {
|
impl UintTy {
|
||||||
pub fn num_bytes(self) -> usize {
|
pub fn num_bytes(self) -> usize {
|
||||||
match self {
|
match self {
|
||||||
UintTy::Usize => crate::target::MachineInfo::target_pointer_width().bytes().into(),
|
UintTy::Usize => crate::target::MachineInfo::target_pointer_width().bytes(),
|
||||||
UintTy::U8 => 1,
|
UintTy::U8 => 1,
|
||||||
UintTy::U16 => 2,
|
UintTy::U16 => 2,
|
||||||
UintTy::U32 => 4,
|
UintTy::U32 => 4,
|
||||||
@ -1185,7 +1185,7 @@ pub fn read_bool(&self) -> Result<bool, Error> {
|
|||||||
match self.read_int()? {
|
match self.read_int()? {
|
||||||
0 => Ok(false),
|
0 => Ok(false),
|
||||||
1 => Ok(true),
|
1 => Ok(true),
|
||||||
val @ _ => Err(error!("Unexpected value for bool: `{val}`")),
|
val => Err(error!("Unexpected value for bool: `{val}`")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ fn write(&mut self, mut bytes: &[u8]) {
|
|||||||
hash.add_to_hash(u16::from_ne_bytes(bytes[..2].try_into().unwrap()) as usize);
|
hash.add_to_hash(u16::from_ne_bytes(bytes[..2].try_into().unwrap()) as usize);
|
||||||
bytes = &bytes[2..];
|
bytes = &bytes[2..];
|
||||||
}
|
}
|
||||||
if (size_of::<usize>() > 1) && bytes.len() >= 1 {
|
if (size_of::<usize>() > 1) && !bytes.is_empty() {
|
||||||
hash.add_to_hash(bytes[0] as usize);
|
hash.add_to_hash(bytes[0] as usize);
|
||||||
}
|
}
|
||||||
self.hash = hash.hash;
|
self.hash = hash.hash;
|
||||||
|
@ -264,9 +264,9 @@ fn from(payload: Box<dyn Any + Send + 'static>) -> Self {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<Box<dyn Any + Send>> for PanicMessage {
|
impl From<PanicMessage> for Box<dyn Any + Send> {
|
||||||
fn into(self) -> Box<dyn Any + Send> {
|
fn from(val: PanicMessage) -> Self {
|
||||||
match self {
|
match val {
|
||||||
PanicMessage::StaticStr(s) => Box::new(s),
|
PanicMessage::StaticStr(s) => Box::new(s),
|
||||||
PanicMessage::String(s) => Box::new(s),
|
PanicMessage::String(s) => Box::new(s),
|
||||||
PanicMessage::Unknown => {
|
PanicMessage::Unknown => {
|
||||||
|
@ -200,7 +200,7 @@ fn usage(binary: &str, options: &getopts::Options) {
|
|||||||
pub fn parse_opts(args: &[String]) -> Option<OptRes> {
|
pub fn parse_opts(args: &[String]) -> Option<OptRes> {
|
||||||
// Parse matches.
|
// Parse matches.
|
||||||
let opts = optgroups();
|
let opts = optgroups();
|
||||||
let binary = args.get(0).map(|c| &**c).unwrap_or("...");
|
let binary = args.first().map(|c| &**c).unwrap_or("...");
|
||||||
let args = args.get(1..).unwrap_or(args);
|
let args = args.get(1..).unwrap_or(args);
|
||||||
let matches = match opts.parse(args) {
|
let matches = match opts.parse(args) {
|
||||||
Ok(m) => m,
|
Ok(m) => m,
|
||||||
|
@ -524,7 +524,7 @@ fn format(val: Param, op: FormatOp, flags: Flags) -> Result<Vec<u8>, String> {
|
|||||||
} else {
|
} else {
|
||||||
let mut s_ = Vec::with_capacity(flags.width);
|
let mut s_ = Vec::with_capacity(flags.width);
|
||||||
s_.extend(repeat(b' ').take(n));
|
s_.extend(repeat(b' ').take(n));
|
||||||
s_.extend(s.into_iter());
|
s_.extend(s);
|
||||||
s = s_;
|
s = s_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user