fix clippy::redundant_closure

This commit is contained in:
Matthias Krüger 2022-03-12 13:35:31 +01:00
parent 1f70886b15
commit 451fcd3c79
11 changed files with 17 additions and 25 deletions

View file

@ -421,12 +421,12 @@ impl BodySourceMap {
}
pub fn node_expr(&self, node: InFile<&ast::Expr>) -> Option<ExprId> {
let src = node.map(|it| AstPtr::new(it));
let src = node.map(AstPtr::new);
self.expr_map.get(&src).cloned()
}
pub fn node_macro_file(&self, node: InFile<&ast::MacroCall>) -> Option<HirFileId> {
let src = node.map(|it| AstPtr::new(it));
let src = node.map(AstPtr::new);
self.expansions.get(&src).cloned()
}
@ -449,7 +449,7 @@ impl BodySourceMap {
}
pub fn node_label(&self, node: InFile<&ast::Label>) -> Option<LabelId> {
let src = node.map(|it| AstPtr::new(it));
let src = node.map(AstPtr::new);
self.label_map.get(&src).cloned()
}
@ -457,7 +457,7 @@ impl BodySourceMap {
self.field_map_back[&expr].clone()
}
pub fn node_field(&self, node: InFile<&ast::RecordExprField>) -> Option<ExprId> {
let src = node.map(|it| AstPtr::new(it));
let src = node.map(AstPtr::new);
self.field_map.get(&src).cloned()
}

View file

@ -941,17 +941,15 @@ impl From<ast::LiteralKind> for Literal {
LiteralKind::IntNumber(lit) => {
if let builtin @ Some(_) = lit.suffix().and_then(BuiltinFloat::from_suffix) {
Literal::Float(Default::default(), builtin)
} else if let builtin @ Some(_) =
lit.suffix().and_then(|it| BuiltinInt::from_suffix(it))
{
} else if let builtin @ Some(_) = lit.suffix().and_then(BuiltinInt::from_suffix) {
Literal::Int(lit.value().unwrap_or(0) as i128, builtin)
} else {
let builtin = lit.suffix().and_then(|it| BuiltinUint::from_suffix(it));
let builtin = lit.suffix().and_then(BuiltinUint::from_suffix);
Literal::Uint(lit.value().unwrap_or(0), builtin)
}
}
LiteralKind::FloatNumber(lit) => {
let ty = lit.suffix().and_then(|it| BuiltinFloat::from_suffix(it));
let ty = lit.suffix().and_then(BuiltinFloat::from_suffix);
Literal::Float(Default::default(), ty)
}
LiteralKind::ByteString(bs) => {

View file

@ -66,7 +66,7 @@ impl FunctionData {
.by_key("rustc_legacy_const_generics")
.tt_values()
.next()
.map(|arg| parse_rustc_legacy_const_generics(arg))
.map(parse_rustc_legacy_const_generics)
.unwrap_or_default();
Arc::new(FunctionData {

View file

@ -88,9 +88,8 @@ fn parse_adt(tt: &tt::Subtree) -> Result<BasicAdtInfo, ExpandError> {
debug!("parsed item has no name");
ExpandError::Other("missing name".into())
})?;
let name_token_id = token_map
.token_by_range(name.syntax().text_range())
.unwrap_or_else(|| TokenId::unspecified());
let name_token_id =
token_map.token_by_range(name.syntax().text_range()).unwrap_or_else(TokenId::unspecified);
let name_token = tt::Ident { id: name_token_id, text: name.text().into() };
let type_or_const_params =
params.map_or(0, |type_param_list| type_param_list.type_or_const_params().count());

View file

@ -446,7 +446,7 @@ fn concat_bytes_expand(
match token.kind() {
syntax::SyntaxKind::BYTE => bytes.push(token.text().to_string()),
syntax::SyntaxKind::BYTE_STRING => {
let components = unquote_byte_string(lit).unwrap_or_else(|| Vec::new());
let components = unquote_byte_string(lit).unwrap_or_else(Vec::new);
components.into_iter().for_each(|x| bytes.push(x.to_string()));
}
_ => {

View file

@ -128,6 +128,6 @@ mod unsafe_tls {
// type.
let static_p: &DebugContext<'static> =
unsafe { std::mem::transmute::<&DebugContext, &DebugContext<'static>>(&ctx) };
PROGRAM.set(static_p, || op())
PROGRAM.set(static_p, op)
}
}

View file

@ -283,7 +283,7 @@ fn extend_list_item(node: &SyntaxNode) -> Option<TextRange> {
let final_node = delimiter_node
.next_sibling_or_token()
.and_then(|it| it.into_token())
.filter(|node| is_single_line_ws(node))
.filter(is_single_line_ws)
.unwrap_or(delimiter_node);
return Some(TextRange::new(node.text_range().start(), final_node.text_range().end()));

View file

@ -417,7 +417,7 @@ impl Module {
replacements.append(&mut impl_item_replacements);
record_field_parents.into_iter().for_each(|x| {
x.1.descendants().filter_map(|x| ast::RecordField::cast(x)).for_each(|desc| {
x.1.descendants().filter_map(ast::RecordField::cast).for_each(|desc| {
let is_record_field_present = record_fields
.clone()
.into_iter()

View file

@ -85,7 +85,7 @@ pub fn insert_ws_into(syn: SyntaxNode) -> SyntaxNode {
}
mods.push(do_nl(after, tok));
}
LIFETIME_IDENT if is_next(|it| is_text(it), true) => {
LIFETIME_IDENT if is_next(is_text, true) => {
mods.push(do_ws(after, tok));
}
AS_KW | DYN_KW | IMPL_KW => {

View file

@ -117,12 +117,7 @@ fn make_fixes(
}
// If there are existing `mod m;` items, append after them (after the first group of them, rather).
match ast
.items()
.skip_while(|item| !is_outline_mod(item))
.take_while(|item| is_outline_mod(item))
.last()
{
match ast.items().skip_while(|item| !is_outline_mod(item)).take_while(is_outline_mod).last() {
Some(last) => {
cov_mark::hit!(unlinked_file_append_to_existing_mods);
let offset = last.syntax().text_range().end();

View file

@ -49,7 +49,7 @@ pub mod ext {
) -> Option<ast::Expr> {
let mut iter = parts.into_iter();
let base = expr_path(ext::ident_path(iter.next()?));
let expr = iter.fold(base, |base, s| expr_field(base, s));
let expr = iter.fold(base, expr_field);
Some(expr)
}