Rollup merge of #79678 - jyn514:THE-PAPERCLIP-COMETH, r=varkor
Fix some clippy lints Happy to revert these if you think they're less readable, but personally I like them better now (especially the `else { if { ... } }` to `else if { ... }` change).
This commit is contained in:
commit
5cebbaa6a1
9 changed files with 28 additions and 33 deletions
|
@ -97,7 +97,7 @@ cfg_if::cfg_if! {
|
|||
let ptr = src_bytes.as_ptr() as *const __m128i;
|
||||
// We don't know if the pointer is aligned to 16 bytes, so we
|
||||
// use `loadu`, which supports unaligned loading.
|
||||
let chunk = _mm_loadu_si128(ptr.offset(chunk_index as isize));
|
||||
let chunk = _mm_loadu_si128(ptr.add(chunk_index));
|
||||
|
||||
// For character in the chunk, see if its byte value is < 0, which
|
||||
// indicates that it's part of a UTF-8 char.
|
||||
|
@ -253,7 +253,7 @@ fn analyze_source_file_generic(
|
|||
let pos = BytePos::from_usize(i) + output_offset;
|
||||
|
||||
if char_len > 1 {
|
||||
assert!(char_len >= 2 && char_len <= 4);
|
||||
assert!((2..=4).contains(&char_len));
|
||||
let mbc = MultiByteChar { pos, bytes: char_len as u8 };
|
||||
multi_byte_chars.push(mbc);
|
||||
}
|
||||
|
|
|
@ -1015,10 +1015,7 @@ pub enum ExternalSourceKind {
|
|||
|
||||
impl ExternalSource {
|
||||
pub fn is_absent(&self) -> bool {
|
||||
match self {
|
||||
ExternalSource::Foreign { kind: ExternalSourceKind::Present(_), .. } => false,
|
||||
_ => true,
|
||||
}
|
||||
!matches!(self, ExternalSource::Foreign { kind: ExternalSourceKind::Present(_), .. })
|
||||
}
|
||||
|
||||
pub fn get_source(&self) -> Option<&Lrc<String>> {
|
||||
|
|
|
@ -623,7 +623,7 @@ impl SourceMap {
|
|||
self.span_to_source(sp, |src, start_index, end_index| {
|
||||
src.get(start_index..end_index)
|
||||
.map(|s| s.to_string())
|
||||
.ok_or_else(|| SpanSnippetError::IllFormedSpan(sp))
|
||||
.ok_or(SpanSnippetError::IllFormedSpan(sp))
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -640,9 +640,7 @@ impl SourceMap {
|
|||
/// Returns the source snippet as `String` before the given `Span`.
|
||||
pub fn span_to_prev_source(&self, sp: Span) -> Result<String, SpanSnippetError> {
|
||||
self.span_to_source(sp, |src, start_index, _| {
|
||||
src.get(..start_index)
|
||||
.map(|s| s.to_string())
|
||||
.ok_or_else(|| SpanSnippetError::IllFormedSpan(sp))
|
||||
src.get(..start_index).map(|s| s.to_string()).ok_or(SpanSnippetError::IllFormedSpan(sp))
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -1363,15 +1363,13 @@ impl fmt::Display for IdentPrinter {
|
|||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
if self.is_raw {
|
||||
f.write_str("r#")?;
|
||||
} else {
|
||||
if self.symbol == kw::DollarCrate {
|
||||
if let Some(span) = self.convert_dollar_crate {
|
||||
let converted = span.ctxt().dollar_crate_name();
|
||||
if !converted.is_path_segment_keyword() {
|
||||
f.write_str("::")?;
|
||||
}
|
||||
return fmt::Display::fmt(&converted, f);
|
||||
} else if self.symbol == kw::DollarCrate {
|
||||
if let Some(span) = self.convert_dollar_crate {
|
||||
let converted = span.ctxt().dollar_crate_name();
|
||||
if !converted.is_path_segment_keyword() {
|
||||
f.write_str("::")?;
|
||||
}
|
||||
return fmt::Display::fmt(&converted, f);
|
||||
}
|
||||
}
|
||||
fmt::Display::fmt(&self.symbol, f)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue