Fix clippy errors

This commit is contained in:
Ali Bektas 2025-01-21 23:22:39 +01:00
parent 419231c79d
commit 76b93c0d1f
4 changed files with 10 additions and 16 deletions

View file

@ -1802,10 +1802,10 @@ impl ExprCollector<'_> {
if ident.is_simple_ident() {
return ident
.name()
.and_then(|name| Some(name.as_name()))
.and_then(|hir_name| Some(Path::from(hir_name)))
.and_then(|path| {
Some(self.alloc_expr_from_pat(Expr::Path(path), ptr))
.map(|name| name.as_name())
.map(Path::from)
.map(|path| {
self.alloc_expr_from_pat(Expr::Path(path), ptr)
});
}

View file

@ -56,10 +56,7 @@ impl ExprOrPatId {
}
pub fn is_expr(&self) -> bool {
match self {
Self::ExprId(_) => true,
_ => false,
}
matches!(self, Self::ExprId(_))
}
pub fn as_pat(self) -> Option<PatId> {
@ -70,10 +67,7 @@ impl ExprOrPatId {
}
pub fn is_pat(&self) -> bool {
match self {
Self::PatId(_) => true,
_ => false,
}
matches!(self, Self::PatId(_))
}
}
stdx::impl_from!(ExprId, PatId for ExprOrPatId);

View file

@ -1359,7 +1359,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
}
fn lower_literal_or_const_to_operand(&mut self, ty: Ty, loc: &ExprId) -> Result<Operand> {
match dbg!(&self.body.exprs[*loc]) {
match &self.body.exprs[*loc] {
Expr::Literal(l) => self.lower_literal_to_operand(ty, l),
Expr::Path(c) => {
let edition = self.edition();
@ -1369,7 +1369,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
.resolver
.resolve_path_in_value_ns(self.db.upcast(), c, HygieneId::ROOT)
.ok_or_else(unresolved_name)?;
dbg!(match dbg!(pr) {
match pr {
ResolveValueResult::ValueNs(v, _) => {
if let ValueNs::ConstId(c) = v {
self.lower_const_to_operand(Substitution::empty(Interner), c.into(), ty)
@ -1380,7 +1380,7 @@ impl<'ctx> MirLowerCtx<'ctx> {
ResolveValueResult::Partial(_, _, _) => {
not_supported!("associated constants in range pattern")
}
})
}
}
_ => {
not_supported!("only `char` and numeric types are allowed in range patterns");

View file

@ -347,7 +347,7 @@ impl SourceToDefCtx<'_, '_> {
&mut self,
src: InFile<&ast::IdentPat>,
) -> Option<(DefWithBodyId, BindingId)> {
let container = dbg!(self.find_pat_or_label_container(src.syntax_ref()))?;
let container = self.find_pat_or_label_container(src.syntax_ref())?;
let (body, source_map) = self.db.body_with_source_map(container);
let src = src.cloned().map(ast::Pat::from);
let pat_id = source_map.node_pat(src.as_ref())?;