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 @@ fn get_horizontal_trim(lines: &[&str], kind: CommentKind) -> Option<String> {
|
|||||||
CommentKind::Block => {
|
CommentKind::Block => {
|
||||||
// Whatever happens, we skip the first line.
|
// Whatever happens, we skip the first line.
|
||||||
let mut i = lines
|
let mut i = lines
|
||||||
.get(0)
|
.first()
|
||||||
.map(|l| if l.trim_start().starts_with('*') { 0 } else { 1 })
|
.map(|l| if l.trim_start().starts_with('*') { 0 } else { 1 })
|
||||||
.unwrap_or(0);
|
.unwrap_or(0);
|
||||||
let mut j = lines.len();
|
let mut j = lines.len();
|
||||||
|
@ -286,7 +286,7 @@ pub(super) fn lower_expr_mut(&mut self, e: &Expr) -> hir::Expr<'hir> {
|
|||||||
ExprKind::OffsetOf(container, fields) => hir::ExprKind::OffsetOf(
|
ExprKind::OffsetOf(container, fields) => hir::ExprKind::OffsetOf(
|
||||||
self.lower_ty(
|
self.lower_ty(
|
||||||
container,
|
container,
|
||||||
&mut ImplTraitContext::Disallowed(ImplTraitPosition::OffsetOf),
|
&ImplTraitContext::Disallowed(ImplTraitPosition::OffsetOf),
|
||||||
),
|
),
|
||||||
self.arena.alloc_from_iter(fields.iter().map(|&ident| self.lower_ident(ident))),
|
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();
|
write!(template, "{n}").unwrap();
|
||||||
if p.format_options != Default::default() || p.format_trait != FormatTrait::Display
|
if p.format_options != Default::default() || p.format_trait != FormatTrait::Display
|
||||||
{
|
{
|
||||||
template.push_str(":");
|
template.push(':');
|
||||||
}
|
}
|
||||||
if let Some(fill) = p.format_options.fill {
|
if let Some(fill) = p.format_options.fill {
|
||||||
template.push(fill);
|
template.push(fill);
|
||||||
}
|
}
|
||||||
match p.format_options.alignment {
|
match p.format_options.alignment {
|
||||||
Some(FormatAlignment::Left) => template.push_str("<"),
|
Some(FormatAlignment::Left) => template.push('<'),
|
||||||
Some(FormatAlignment::Right) => template.push_str(">"),
|
Some(FormatAlignment::Right) => template.push('>'),
|
||||||
Some(FormatAlignment::Center) => template.push_str("^"),
|
Some(FormatAlignment::Center) => template.push('^'),
|
||||||
None => {}
|
None => {}
|
||||||
}
|
}
|
||||||
match p.format_options.sign {
|
match p.format_options.sign {
|
||||||
|
@ -268,11 +268,7 @@ pub fn remove(&mut self, key: &K) -> Option<V> {
|
|||||||
pub fn remove_entry(&mut self, key: &K) -> Option<(K, V)> {
|
pub fn remove_entry(&mut self, key: &K) -> Option<(K, V)> {
|
||||||
match self {
|
match self {
|
||||||
SsoHashMap::Array(array) => {
|
SsoHashMap::Array(array) => {
|
||||||
if let Some(index) = array.iter().position(|(k, _v)| k == key) {
|
array.iter().position(|(k, _v)| k == key).map(|index| array.swap_remove(index))
|
||||||
Some(array.swap_remove(index))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
SsoHashMap::Map(map) => map.remove_entry(key),
|
SsoHashMap::Map(map) => map.remove_entry(key),
|
||||||
}
|
}
|
||||||
|
@ -3013,8 +3013,7 @@ pub struct FieldDef<'hir> {
|
|||||||
impl FieldDef<'_> {
|
impl FieldDef<'_> {
|
||||||
// Still necessary in couple of places
|
// Still necessary in couple of places
|
||||||
pub fn is_positional(&self) -> bool {
|
pub fn is_positional(&self) -> bool {
|
||||||
let first = self.ident.as_str().as_bytes()[0];
|
self.ident.as_str().as_bytes()[0].is_ascii_digit()
|
||||||
(b'0'..=b'9').contains(&first)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1041,10 +1041,7 @@ fn list(ns: &[usize]) -> String {
|
|||||||
}
|
}
|
||||||
elem(curr, curr_count);
|
elem(curr, curr_count);
|
||||||
|
|
||||||
let mut s = "[".to_string();
|
format!("[{}]", v.join(", "))
|
||||||
s.push_str(&v.join(", "));
|
|
||||||
s.push_str("]");
|
|
||||||
s
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -400,7 +400,7 @@ fn encode_ty_name(tcx: TyCtxt<'_>, def_id: DefId) -> String {
|
|||||||
let _ = write!(s, "{}", name.len());
|
let _ = write!(s, "{}", name.len());
|
||||||
|
|
||||||
// Prepend a '_' if name starts with a digit or '_'
|
// 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'_' {
|
if first.is_ascii_digit() || *first == b'_' {
|
||||||
s.push('_');
|
s.push('_');
|
||||||
}
|
}
|
||||||
|
@ -194,7 +194,7 @@ fn try_fold_ty(&mut self, ty: Ty<'tcx>) -> Result<Ty<'tcx>, Self::Error> {
|
|||||||
mapped_regions,
|
mapped_regions,
|
||||||
mapped_types,
|
mapped_types,
|
||||||
mapped_consts,
|
mapped_consts,
|
||||||
&mut self.universes,
|
&self.universes,
|
||||||
result,
|
result,
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
@ -224,7 +224,7 @@ fn try_fold_const(&mut self, ct: ty::Const<'tcx>) -> Result<ty::Const<'tcx>, Sel
|
|||||||
mapped_regions,
|
mapped_regions,
|
||||||
mapped_types,
|
mapped_types,
|
||||||
mapped_consts,
|
mapped_consts,
|
||||||
&mut self.universes,
|
&self.universes,
|
||||||
result,
|
result,
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user