minor code cleanups
This commit is contained in:
parent
37d7de3379
commit
2ea368e53c
8 changed files with 11 additions and 20 deletions
|
@ -802,12 +802,9 @@ impl Integer {
|
|||
pub fn for_align<C: HasDataLayout>(cx: &C, wanted: Align) -> Option<Integer> {
|
||||
let dl = cx.data_layout();
|
||||
|
||||
for candidate in [I8, I16, I32, I64, I128] {
|
||||
if wanted == candidate.align(dl).abi && wanted.bytes() == candidate.size().bytes() {
|
||||
return Some(candidate);
|
||||
}
|
||||
}
|
||||
None
|
||||
[I8, I16, I32, I64, I128].into_iter().find(|&candidate| {
|
||||
wanted == candidate.align(dl).abi && wanted.bytes() == candidate.size().bytes()
|
||||
})
|
||||
}
|
||||
|
||||
/// Find the largest integer with the given alignment or less.
|
||||
|
|
|
@ -9,7 +9,7 @@ pub const MAX_BASE: usize = 64;
|
|||
pub const ALPHANUMERIC_ONLY: usize = 62;
|
||||
pub const CASE_INSENSITIVE: usize = 36;
|
||||
|
||||
const BASE_64: &[u8; MAX_BASE as usize] =
|
||||
const BASE_64: &[u8; MAX_BASE] =
|
||||
b"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@$";
|
||||
|
||||
#[inline]
|
||||
|
|
|
@ -802,7 +802,7 @@ impl Diagnostic {
|
|||
debug_assert!(
|
||||
!(suggestions
|
||||
.iter()
|
||||
.flat_map(|suggs| suggs)
|
||||
.flatten()
|
||||
.any(|(sp, suggestion)| sp.is_empty() && suggestion.is_empty())),
|
||||
"Span must not be empty and have no suggestion"
|
||||
);
|
||||
|
|
|
@ -1308,7 +1308,7 @@ impl EmitterWriter {
|
|||
// see how it *looks* with
|
||||
// very *weird* formats
|
||||
// see?
|
||||
for &(ref text, ref style) in msg.iter() {
|
||||
for (text, style) in msg.iter() {
|
||||
let text = self.translate_message(text, args);
|
||||
let lines = text.split('\n').collect::<Vec<_>>();
|
||||
if lines.len() > 1 {
|
||||
|
@ -1370,7 +1370,7 @@ impl EmitterWriter {
|
|||
buffer.append(0, ": ", header_style);
|
||||
label_width += 2;
|
||||
}
|
||||
for &(ref text, _) in msg.iter() {
|
||||
for (text, _) in msg.iter() {
|
||||
let text = self.translate_message(text, args);
|
||||
// Account for newlines to align output to its label.
|
||||
for (line, text) in normalize_whitespace(&text).lines().enumerate() {
|
||||
|
|
|
@ -548,12 +548,7 @@ impl<'hir> Generics<'hir> {
|
|||
}
|
||||
|
||||
pub fn get_named(&self, name: Symbol) -> Option<&GenericParam<'hir>> {
|
||||
for param in self.params {
|
||||
if name == param.name.ident().name {
|
||||
return Some(param);
|
||||
}
|
||||
}
|
||||
None
|
||||
self.params.iter().find(|¶m| name == param.name.ident().name)
|
||||
}
|
||||
|
||||
pub fn spans(&self) -> MultiSpan {
|
||||
|
|
|
@ -209,7 +209,7 @@ impl<T: Idx> BitSet<T> {
|
|||
self.words[start_word_index] |= !(start_mask - 1);
|
||||
// And all trailing bits (i.e. from 0..=end) in the end word,
|
||||
// including the end.
|
||||
self.words[end_word_index] |= end_mask | end_mask - 1;
|
||||
self.words[end_word_index] |= end_mask | (end_mask - 1);
|
||||
} else {
|
||||
self.words[start_word_index] |= end_mask | (end_mask - start_mask);
|
||||
}
|
||||
|
|
|
@ -204,14 +204,13 @@ fn scan_escape(chars: &mut Chars<'_>, is_byte: bool) -> Result<char, EscapeError
|
|||
})?;
|
||||
}
|
||||
Some(c) => {
|
||||
let digit =
|
||||
let digit: u32 =
|
||||
c.to_digit(16).ok_or(EscapeError::InvalidCharInUnicodeEscape)?;
|
||||
n_digits += 1;
|
||||
if n_digits > 6 {
|
||||
// Stop updating value since we're sure that it's incorrect already.
|
||||
continue;
|
||||
}
|
||||
let digit = digit as u32;
|
||||
value = value * 16 + digit;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1150,7 +1150,7 @@ impl FilePathMapping {
|
|||
// NOTE: We are iterating over the mapping entries from last to first
|
||||
// because entries specified later on the command line should
|
||||
// take precedence.
|
||||
for &(ref from, ref to) in mapping.iter().rev() {
|
||||
for (from, to) in mapping.iter().rev() {
|
||||
debug!("Trying to apply {from:?} => {to:?}");
|
||||
|
||||
if let Ok(rest) = path.strip_prefix(from) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue