mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 02:03:53 +00:00
more clippy::style fixes:
get_first single_char_add_str unnecessary_mut_passed manual_map manual_is_ascii_check
This commit is contained in:
parent
ed4c5fef72
commit
af2b370100
@ -62,7 +62,7 @@ pub fn beautify_doc_string(data: Symbol, kind: CommentKind) -> Symbol {
|
||||
CommentKind::Block => {
|
||||
// Whatever happens, we skip the first line.
|
||||
let mut i = lines
|
||||
.get(0)
|
||||
.first()
|
||||
.map(|l| if l.trim_start().starts_with('*') { 0 } else { 1 })
|
||||
.unwrap_or(0);
|
||||
let mut j = lines.len();
|
||||
|
@ -286,7 +286,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
ExprKind::OffsetOf(container, fields) => hir::ExprKind::OffsetOf(
|
||||
self.lower_ty(
|
||||
container,
|
||||
&mut ImplTraitContext::Disallowed(ImplTraitPosition::OffsetOf),
|
||||
&ImplTraitContext::Disallowed(ImplTraitPosition::OffsetOf),
|
||||
),
|
||||
self.arena.alloc_from_iter(fields.iter().map(|&ident| self.lower_ident(ident))),
|
||||
),
|
||||
|
@ -697,15 +697,15 @@ pub fn reconstruct_format_args_template_string(pieces: &[FormatArgsPiece]) -> St
|
||||
write!(template, "{n}").unwrap();
|
||||
if p.format_options != Default::default() || p.format_trait != FormatTrait::Display
|
||||
{
|
||||
template.push_str(":");
|
||||
template.push(':');
|
||||
}
|
||||
if let Some(fill) = p.format_options.fill {
|
||||
template.push(fill);
|
||||
}
|
||||
match p.format_options.alignment {
|
||||
Some(FormatAlignment::Left) => template.push_str("<"),
|
||||
Some(FormatAlignment::Right) => template.push_str(">"),
|
||||
Some(FormatAlignment::Center) => template.push_str("^"),
|
||||
Some(FormatAlignment::Left) => template.push('<'),
|
||||
Some(FormatAlignment::Right) => template.push('>'),
|
||||
Some(FormatAlignment::Center) => template.push('^'),
|
||||
None => {}
|
||||
}
|
||||
match p.format_options.sign {
|
||||
|
@ -268,11 +268,7 @@ impl<K: Eq + Hash, V> SsoHashMap<K, V> {
|
||||
pub fn remove_entry(&mut self, key: &K) -> Option<(K, V)> {
|
||||
match self {
|
||||
SsoHashMap::Array(array) => {
|
||||
if let Some(index) = array.iter().position(|(k, _v)| k == key) {
|
||||
Some(array.swap_remove(index))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
array.iter().position(|(k, _v)| k == key).map(|index| array.swap_remove(index))
|
||||
}
|
||||
SsoHashMap::Map(map) => map.remove_entry(key),
|
||||
}
|
||||
|
@ -3013,8 +3013,7 @@ pub struct FieldDef<'hir> {
|
||||
impl FieldDef<'_> {
|
||||
// Still necessary in couple of places
|
||||
pub fn is_positional(&self) -> bool {
|
||||
let first = self.ident.as_str().as_bytes()[0];
|
||||
(b'0'..=b'9').contains(&first)
|
||||
self.ident.as_str().as_bytes()[0].is_ascii_digit()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1041,10 +1041,7 @@ fn debug_dump<'a, 'tcx: 'a>(tcx: TyCtxt<'tcx>, label: &str, cgus: &[CodegenUnit<
|
||||
}
|
||||
elem(curr, curr_count);
|
||||
|
||||
let mut s = "[".to_string();
|
||||
s.push_str(&v.join(", "));
|
||||
s.push_str("]");
|
||||
s
|
||||
format!("[{}]", v.join(", "))
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -400,7 +400,7 @@ fn encode_ty_name(tcx: TyCtxt<'_>, def_id: DefId) -> String {
|
||||
let _ = write!(s, "{}", name.len());
|
||||
|
||||
// Prepend a '_' if name starts with a digit or '_'
|
||||
if let Some(first) = name.as_bytes().get(0) {
|
||||
if let Some(first) = name.as_bytes().first() {
|
||||
if first.is_ascii_digit() || *first == b'_' {
|
||||
s.push('_');
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for NormalizationFolder<'_, 'tcx> {
|
||||
mapped_regions,
|
||||
mapped_types,
|
||||
mapped_consts,
|
||||
&mut self.universes,
|
||||
&self.universes,
|
||||
result,
|
||||
))
|
||||
} else {
|
||||
@ -224,7 +224,7 @@ impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for NormalizationFolder<'_, 'tcx> {
|
||||
mapped_regions,
|
||||
mapped_types,
|
||||
mapped_consts,
|
||||
&mut self.universes,
|
||||
&self.universes,
|
||||
result,
|
||||
))
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user