mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 13:13:34 +00:00
Handle ExprKind::ConstBlock on clippy
This commit is contained in:
parent
d2feccc1ef
commit
0af467ebf2
6 changed files with 17 additions and 1 deletions
|
@ -742,6 +742,7 @@ fn never_loop_expr(expr: &Expr<'_>, main_loop_id: HirId) -> NeverLoopResult {
|
|||
| ExprKind::Closure(_, _, _, _, _)
|
||||
| ExprKind::LlvmInlineAsm(_)
|
||||
| ExprKind::Path(_)
|
||||
| ExprKind::ConstBlock(_)
|
||||
| ExprKind::Lit(_)
|
||||
| ExprKind::Err => NeverLoopResult::Otherwise,
|
||||
}
|
||||
|
|
|
@ -506,6 +506,11 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor {
|
|||
println!(" if {}.len() == {};", fields_pat, fields.len());
|
||||
println!(" // unimplemented: field checks");
|
||||
},
|
||||
ExprKind::ConstBlock(_) => {
|
||||
let value_pat = self.next("value");
|
||||
println!("Const({})", value_pat);
|
||||
self.current = value_pat;
|
||||
},
|
||||
// FIXME: compute length (needs type info)
|
||||
ExprKind::Repeat(ref value, _) => {
|
||||
let value_pat = self.next("value");
|
||||
|
|
|
@ -23,7 +23,7 @@ use rustc_middle::hir::map::Map;
|
|||
/// This function is named so to stress that it isn't exhaustive and returns FNs.
|
||||
fn identify_some_pure_patterns(expr: &Expr<'_>) -> bool {
|
||||
match expr.kind {
|
||||
ExprKind::Lit(..) | ExprKind::Path(..) | ExprKind::Field(..) => true,
|
||||
ExprKind::Lit(..) | ExprKind::ConstBlock(..) | ExprKind::Path(..) | ExprKind::Field(..) => true,
|
||||
ExprKind::AddrOf(_, _, addr_of_expr) => identify_some_pure_patterns(addr_of_expr),
|
||||
ExprKind::Tup(tup_exprs) => tup_exprs.iter().all(|expr| identify_some_pure_patterns(expr)),
|
||||
ExprKind::Struct(_, fields, expr) => {
|
||||
|
|
|
@ -559,6 +559,9 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
|
|||
self.hash_name(path.ident.name);
|
||||
self.hash_exprs(args);
|
||||
},
|
||||
ExprKind::ConstBlock(ref l_id) => {
|
||||
self.hash_body(l_id.body);
|
||||
},
|
||||
ExprKind::Repeat(ref e, ref l_id) => {
|
||||
self.hash_expr(e);
|
||||
self.hash_body(l_id.body);
|
||||
|
|
|
@ -338,6 +338,11 @@ fn print_expr(cx: &LateContext<'_>, expr: &hir::Expr<'_>, indent: usize) {
|
|||
print_expr(cx, base, indent + 1);
|
||||
}
|
||||
},
|
||||
hir::ExprKind::ConstBlock(ref anon_const) => {
|
||||
println!("{}ConstBlock", ind);
|
||||
println!("{}anon_const:", ind);
|
||||
print_expr(cx, &cx.tcx.hir().body(anon_const.body).value, indent + 1);
|
||||
},
|
||||
hir::ExprKind::Repeat(ref val, ref anon_const) => {
|
||||
println!("{}Repeat", ind);
|
||||
println!("{}value:", ind);
|
||||
|
|
|
@ -110,6 +110,7 @@ impl<'a> Sugg<'a> {
|
|||
| hir::ExprKind::Index(..)
|
||||
| hir::ExprKind::InlineAsm(..)
|
||||
| hir::ExprKind::LlvmInlineAsm(..)
|
||||
| hir::ExprKind::ConstBlock(..)
|
||||
| hir::ExprKind::Lit(..)
|
||||
| hir::ExprKind::Loop(..)
|
||||
| hir::ExprKind::MethodCall(..)
|
||||
|
@ -157,6 +158,7 @@ impl<'a> Sugg<'a> {
|
|||
| ast::ExprKind::Index(..)
|
||||
| ast::ExprKind::InlineAsm(..)
|
||||
| ast::ExprKind::LlvmInlineAsm(..)
|
||||
| ast::ExprKind::ConstBlock(..)
|
||||
| ast::ExprKind::Lit(..)
|
||||
| ast::ExprKind::Loop(..)
|
||||
| ast::ExprKind::MacCall(..)
|
||||
|
|
Loading…
Reference in a new issue