Rollup merge of #110124 - Nilstrieb:📎-told-me-so, r=compiler-errors
Some clippy fixes in the compiler
Best reviewed commit-by-commit 📎.
This commit is contained in:
commit
97921abc06
54 changed files with 141 additions and 139 deletions
|
@ -74,18 +74,17 @@ impl<'hir> Iterator for ParentHirIterator<'hir> {
|
|||
if self.current_id == CRATE_HIR_ID {
|
||||
return None;
|
||||
}
|
||||
loop {
|
||||
// There are nodes that do not have entries, so we need to skip them.
|
||||
let parent_id = self.map.parent_id(self.current_id);
|
||||
|
||||
if parent_id == self.current_id {
|
||||
self.current_id = CRATE_HIR_ID;
|
||||
return None;
|
||||
}
|
||||
// There are nodes that do not have entries, so we need to skip them.
|
||||
let parent_id = self.map.parent_id(self.current_id);
|
||||
|
||||
self.current_id = parent_id;
|
||||
return Some(parent_id);
|
||||
if parent_id == self.current_id {
|
||||
self.current_id = CRATE_HIR_ID;
|
||||
return None;
|
||||
}
|
||||
|
||||
self.current_id = parent_id;
|
||||
return Some(parent_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -109,26 +109,34 @@ const MAX_HASHED_BUFFER_LEN: usize = 2 * MAX_BYTES_TO_HASH;
|
|||
// large.
|
||||
impl hash::Hash for Allocation {
|
||||
fn hash<H: hash::Hasher>(&self, state: &mut H) {
|
||||
let Self {
|
||||
bytes,
|
||||
provenance,
|
||||
init_mask,
|
||||
align,
|
||||
mutability,
|
||||
extra: (), // don't bother hashing ()
|
||||
} = self;
|
||||
|
||||
// Partially hash the `bytes` buffer when it is large. To limit collisions with common
|
||||
// prefixes and suffixes, we hash the length and some slices of the buffer.
|
||||
let byte_count = self.bytes.len();
|
||||
let byte_count = bytes.len();
|
||||
if byte_count > MAX_HASHED_BUFFER_LEN {
|
||||
// Hash the buffer's length.
|
||||
byte_count.hash(state);
|
||||
|
||||
// And its head and tail.
|
||||
self.bytes[..MAX_BYTES_TO_HASH].hash(state);
|
||||
self.bytes[byte_count - MAX_BYTES_TO_HASH..].hash(state);
|
||||
bytes[..MAX_BYTES_TO_HASH].hash(state);
|
||||
bytes[byte_count - MAX_BYTES_TO_HASH..].hash(state);
|
||||
} else {
|
||||
self.bytes.hash(state);
|
||||
bytes.hash(state);
|
||||
}
|
||||
|
||||
// Hash the other fields as usual.
|
||||
self.provenance.hash(state);
|
||||
self.init_mask.hash(state);
|
||||
self.align.hash(state);
|
||||
self.mutability.hash(state);
|
||||
self.extra.hash(state);
|
||||
provenance.hash(state);
|
||||
init_mask.hash(state);
|
||||
align.hash(state);
|
||||
mutability.hash(state);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -915,7 +915,7 @@ pub enum LocalInfo<'tcx> {
|
|||
|
||||
impl<'tcx> LocalDecl<'tcx> {
|
||||
pub fn local_info(&self) -> &LocalInfo<'tcx> {
|
||||
&**self.local_info.as_ref().assert_crate_local()
|
||||
&self.local_info.as_ref().assert_crate_local()
|
||||
}
|
||||
|
||||
/// Returns `true` only if local is a binding that can itself be
|
||||
|
|
|
@ -133,21 +133,21 @@ impl<'tcx> MirPatch<'tcx> {
|
|||
let mut new_decl = LocalDecl::new(ty, span).internal();
|
||||
**new_decl.local_info.as_mut().assert_crate_local() = local_info;
|
||||
self.new_locals.push(new_decl);
|
||||
Local::new(index as usize)
|
||||
Local::new(index)
|
||||
}
|
||||
|
||||
pub fn new_temp(&mut self, ty: Ty<'tcx>, span: Span) -> Local {
|
||||
let index = self.next_local;
|
||||
self.next_local += 1;
|
||||
self.new_locals.push(LocalDecl::new(ty, span));
|
||||
Local::new(index as usize)
|
||||
Local::new(index)
|
||||
}
|
||||
|
||||
pub fn new_internal(&mut self, ty: Ty<'tcx>, span: Span) -> Local {
|
||||
let index = self.next_local;
|
||||
self.next_local += 1;
|
||||
self.new_locals.push(LocalDecl::new(ty, span).internal());
|
||||
Local::new(index as usize)
|
||||
Local::new(index)
|
||||
}
|
||||
|
||||
pub fn new_block(&mut self, data: BasicBlockData<'tcx>) -> BasicBlock {
|
||||
|
|
|
@ -98,7 +98,7 @@ impl<'tcx> PlaceTy<'tcx> {
|
|||
ty::Array(inner, _) if !from_end => tcx.mk_array(*inner, (to - from) as u64),
|
||||
ty::Array(inner, size) if from_end => {
|
||||
let size = size.eval_target_usize(tcx, param_env);
|
||||
let len = size - (from as u64) - (to as u64);
|
||||
let len = size - from - to;
|
||||
tcx.mk_array(*inner, len)
|
||||
}
|
||||
_ => bug!("cannot subslice non-array type: `{:?}`", self),
|
||||
|
|
|
@ -178,17 +178,7 @@ impl<'a, 'tcx> Postorder<'a, 'tcx> {
|
|||
// When we yield `B` and call `traverse_successor`, we push `C` to the stack, but
|
||||
// since we've already visited `E`, that child isn't added to the stack. The last
|
||||
// two iterations yield `C` and finally `A` for a final traversal of [E, D, B, C, A]
|
||||
loop {
|
||||
let bb = if let Some(&mut (_, ref mut iter)) = self.visit_stack.last_mut() {
|
||||
if let Some(bb) = iter.next() {
|
||||
bb
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
};
|
||||
|
||||
while let Some(&mut (_, ref mut iter)) = self.visit_stack.last_mut() && let Some(bb) = iter.next() {
|
||||
if self.visited.insert(bb) {
|
||||
if let Some(term) = &self.basic_blocks[bb].terminator {
|
||||
self.visit_stack.push((bb, term.successors()));
|
||||
|
|
|
@ -923,7 +923,7 @@ impl ObjectSafetyViolation {
|
|||
}
|
||||
}
|
||||
ObjectSafetyViolation::SupertraitNonLifetimeBinder(_) => {
|
||||
format!("where clause cannot reference non-lifetime `for<...>` variables").into()
|
||||
"where clause cannot reference non-lifetime `for<...>` variables".into()
|
||||
}
|
||||
ObjectSafetyViolation::Method(name, MethodViolationCode::StaticMethod(_), _) => {
|
||||
format!("associated function `{}` has no `self` parameter", name).into()
|
||||
|
|
|
@ -115,7 +115,7 @@ impl<'tcx> std::ops::Deref for ExternalConstraints<'tcx> {
|
|||
type Target = ExternalConstraintsData<'tcx>;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&*self.0
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -337,7 +337,7 @@ impl ScalarInt {
|
|||
/// Fails if the size of the `ScalarInt` is not equal to `Size { raw: 16 }`
|
||||
/// and returns the `ScalarInt`s size in that case.
|
||||
pub fn try_to_i128(self) -> Result<i128, Size> {
|
||||
self.try_to_int(Size::from_bits(128)).map(|v| i128::try_from(v).unwrap())
|
||||
self.try_to_int(Size::from_bits(128))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -924,7 +924,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
crate_name,
|
||||
// Don't print the whole stable crate id. That's just
|
||||
// annoying in debug output.
|
||||
stable_crate_id.to_u64() >> 8 * 6,
|
||||
stable_crate_id.to_u64() >> (8 * 6),
|
||||
self.def_path(def_id).to_string_no_crate_verbose()
|
||||
)
|
||||
}
|
||||
|
@ -2379,7 +2379,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
pub fn in_scope_traits(self, id: HirId) -> Option<&'tcx [TraitCandidate]> {
|
||||
let map = self.in_scope_traits_map(id.owner)?;
|
||||
let candidates = map.get(&id.local_id)?;
|
||||
Some(&*candidates)
|
||||
Some(candidates)
|
||||
}
|
||||
|
||||
pub fn named_bound_var(self, id: HirId) -> Option<resolve_bound_vars::ResolvedArg> {
|
||||
|
|
|
@ -1891,7 +1891,7 @@ impl<'tcx> Ty<'tcx> {
|
|||
// The way we evaluate the `N` in `[T; N]` here only works since we use
|
||||
// `simd_size_and_type` post-monomorphization. It will probably start to ICE
|
||||
// if we use it in generic code. See the `simd-array-trait` ui test.
|
||||
(f0_len.eval_target_usize(tcx, ParamEnv::empty()) as u64, *f0_elem_ty)
|
||||
(f0_len.eval_target_usize(tcx, ParamEnv::empty()), *f0_elem_ty)
|
||||
}
|
||||
// Otherwise, the fields of this Adt are the SIMD components (and we assume they
|
||||
// all have the same type).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue