Skip to content

Commit 799eef6

Browse files
committed
Auto merge of #5818 - flip1995:rustup, r=flip1995
Rename TypeckTables to TypeckResults. r? @ghost changelog: none
2 parents 9a945c7 + 0f501ac commit 799eef6

File tree

104 files changed

+471
-425
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+471
-425
lines changed

clippy_lints/src/arithmetic.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl<'tcx> LateLintPass<'tcx> for Arithmetic {
8686
_ => (),
8787
}
8888

89-
let (l_ty, r_ty) = (cx.tables().expr_ty(l), cx.tables().expr_ty(r));
89+
let (l_ty, r_ty) = (cx.typeck_results().expr_ty(l), cx.typeck_results().expr_ty(r));
9090
if l_ty.peel_refs().is_integral() && r_ty.peel_refs().is_integral() {
9191
span_lint(cx, INTEGER_ARITHMETIC, expr.span, "integer arithmetic detected");
9292
self.expr_span = Some(expr.span);
@@ -96,8 +96,8 @@ impl<'tcx> LateLintPass<'tcx> for Arithmetic {
9696
}
9797
},
9898
hir::ExprKind::Unary(hir::UnOp::UnNeg, arg) => {
99-
let ty = cx.tables().expr_ty(arg);
100-
if constant_simple(cx, cx.tables(), expr).is_none() {
99+
let ty = cx.typeck_results().expr_ty(arg);
100+
if constant_simple(cx, cx.typeck_results(), expr).is_none() {
101101
if ty.is_integral() {
102102
span_lint(cx, INTEGER_ARITHMETIC, expr.span, "integer arithmetic detected");
103103
self.expr_span = Some(expr.span);

clippy_lints/src/assertions_on_constants.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl<'tcx> LateLintPass<'tcx> for AssertionsOnConstants {
7272
}
7373
if_chain! {
7474
if let ExprKind::Unary(_, ref lit) = e.kind;
75-
if let Some((Constant::Bool(is_true), _)) = constant(cx, cx.tables(), lit);
75+
if let Some((Constant::Bool(is_true), _)) = constant(cx, cx.typeck_results(), lit);
7676
if is_true;
7777
then {
7878
lint_true(true);
@@ -121,7 +121,7 @@ fn match_assert_with_message<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>)
121121
if let ExprKind::DropTemps(ref expr) = expr.kind;
122122
if let ExprKind::Unary(UnOp::UnNot, ref expr) = expr.kind;
123123
// bind the first argument of the `assert!` macro
124-
if let Some((Constant::Bool(is_true), _)) = constant(cx, cx.tables(), expr);
124+
if let Some((Constant::Bool(is_true), _)) = constant(cx, cx.typeck_results(), expr);
125125
// arm 1 pattern
126126
if let PatKind::Lit(ref lit_expr) = arms[0].pat.kind;
127127
if let ExprKind::Lit(ref lit) = lit_expr.kind;

clippy_lints/src/assign_ops.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ impl<'tcx> LateLintPass<'tcx> for AssignOps {
8282
hir::ExprKind::Assign(assignee, e, _) => {
8383
if let hir::ExprKind::Binary(op, l, r) = &e.kind {
8484
let lint = |assignee: &hir::Expr<'_>, rhs: &hir::Expr<'_>| {
85-
let ty = cx.tables().expr_ty(assignee);
86-
let rty = cx.tables().expr_ty(rhs);
85+
let ty = cx.typeck_results().expr_ty(assignee);
86+
let rty = cx.typeck_results().expr_ty(rhs);
8787
macro_rules! ops {
8888
($op:expr,
8989
$cx:expr,
@@ -167,7 +167,7 @@ impl<'tcx> LateLintPass<'tcx> for AssignOps {
167167
// a = b commutative_op a
168168
// Limited to primitive type as these ops are know to be commutative
169169
if SpanlessEq::new(cx).ignore_fn().eq_expr(assignee, r)
170-
&& cx.tables().expr_ty(assignee).is_primitive_ty()
170+
&& cx.typeck_results().expr_ty(assignee).is_primitive_ty()
171171
{
172172
match op.node {
173173
hir::BinOpKind::Add

clippy_lints/src/atomic_ordering.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const ATOMIC_TYPES: [&str; 12] = [
5353
];
5454

5555
fn type_is_atomic(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
56-
if let ty::Adt(&ty::AdtDef { did, .. }, _) = cx.tables().expr_ty(expr).kind {
56+
if let ty::Adt(&ty::AdtDef { did, .. }, _) = cx.typeck_results().expr_ty(expr).kind {
5757
ATOMIC_TYPES
5858
.iter()
5959
.any(|ty| match_def_path(cx, did, &["core", "sync", "atomic", ty]))

clippy_lints/src/attrs.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -461,15 +461,15 @@ fn check_clippy_lint_names(cx: &LateContext<'_>, ident: &str, items: &[NestedMet
461461

462462
fn is_relevant_item(cx: &LateContext<'_>, item: &Item<'_>) -> bool {
463463
if let ItemKind::Fn(_, _, eid) = item.kind {
464-
is_relevant_expr(cx, cx.tcx.body_tables(eid), &cx.tcx.hir().body(eid).value)
464+
is_relevant_expr(cx, cx.tcx.typeck_body(eid), &cx.tcx.hir().body(eid).value)
465465
} else {
466466
true
467467
}
468468
}
469469

470470
fn is_relevant_impl(cx: &LateContext<'_>, item: &ImplItem<'_>) -> bool {
471471
match item.kind {
472-
ImplItemKind::Fn(_, eid) => is_relevant_expr(cx, cx.tcx.body_tables(eid), &cx.tcx.hir().body(eid).value),
472+
ImplItemKind::Fn(_, eid) => is_relevant_expr(cx, cx.tcx.typeck_body(eid), &cx.tcx.hir().body(eid).value),
473473
_ => false,
474474
}
475475
}
@@ -478,31 +478,34 @@ fn is_relevant_trait(cx: &LateContext<'_>, item: &TraitItem<'_>) -> bool {
478478
match item.kind {
479479
TraitItemKind::Fn(_, TraitFn::Required(_)) => true,
480480
TraitItemKind::Fn(_, TraitFn::Provided(eid)) => {
481-
is_relevant_expr(cx, cx.tcx.body_tables(eid), &cx.tcx.hir().body(eid).value)
481+
is_relevant_expr(cx, cx.tcx.typeck_body(eid), &cx.tcx.hir().body(eid).value)
482482
},
483483
_ => false,
484484
}
485485
}
486486

487-
fn is_relevant_block(cx: &LateContext<'_>, tables: &ty::TypeckTables<'_>, block: &Block<'_>) -> bool {
487+
fn is_relevant_block(cx: &LateContext<'_>, typeck_results: &ty::TypeckResults<'_>, block: &Block<'_>) -> bool {
488488
block.stmts.first().map_or(
489-
block.expr.as_ref().map_or(false, |e| is_relevant_expr(cx, tables, e)),
489+
block
490+
.expr
491+
.as_ref()
492+
.map_or(false, |e| is_relevant_expr(cx, typeck_results, e)),
490493
|stmt| match &stmt.kind {
491494
StmtKind::Local(_) => true,
492-
StmtKind::Expr(expr) | StmtKind::Semi(expr) => is_relevant_expr(cx, tables, expr),
495+
StmtKind::Expr(expr) | StmtKind::Semi(expr) => is_relevant_expr(cx, typeck_results, expr),
493496
_ => false,
494497
},
495498
)
496499
}
497500

498-
fn is_relevant_expr(cx: &LateContext<'_>, tables: &ty::TypeckTables<'_>, expr: &Expr<'_>) -> bool {
501+
fn is_relevant_expr(cx: &LateContext<'_>, typeck_results: &ty::TypeckResults<'_>, expr: &Expr<'_>) -> bool {
499502
match &expr.kind {
500-
ExprKind::Block(block, _) => is_relevant_block(cx, tables, block),
501-
ExprKind::Ret(Some(e)) => is_relevant_expr(cx, tables, e),
503+
ExprKind::Block(block, _) => is_relevant_block(cx, typeck_results, block),
504+
ExprKind::Ret(Some(e)) => is_relevant_expr(cx, typeck_results, e),
502505
ExprKind::Ret(None) | ExprKind::Break(_, None) => false,
503506
ExprKind::Call(path_expr, _) => {
504507
if let ExprKind::Path(qpath) = &path_expr.kind {
505-
tables
508+
typeck_results
506509
.qpath_res(qpath, path_expr.hir_id)
507510
.opt_def_id()
508511
.map_or(true, |fun_id| !match_def_path(cx, fun_id, &paths::BEGIN_PANIC))

clippy_lints/src/await_holding_lock.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ impl LateLintPass<'_> for AwaitHoldingLock {
5959
hir_id: body.value.hir_id,
6060
};
6161
let def_id = cx.tcx.hir().body_owner_def_id(body_id);
62-
let tables = cx.tcx.typeck_tables_of(def_id);
63-
check_interior_types(cx, &tables.generator_interior_types, body.value.span);
62+
let typeck_results = cx.tcx.typeck(def_id);
63+
check_interior_types(cx, &typeck_results.generator_interior_types, body.value.span);
6464
}
6565
}
6666
}

clippy_lints/src/bit_mask.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ fn check_ineffective_gt(cx: &LateContext<'_>, span: Span, m: u128, c: u128, op:
319319
}
320320

321321
fn fetch_int_literal(cx: &LateContext<'_>, lit: &Expr<'_>) -> Option<u128> {
322-
match constant(cx, cx.tables(), lit)?.0 {
322+
match constant(cx, cx.typeck_results(), lit)?.0 {
323323
Constant::Int(n) => Some(n),
324324
_ => None,
325325
}

clippy_lints/src/booleans.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,12 @@ impl<'a, 'tcx, 'v> Hir2Qmm<'a, 'tcx, 'v> {
111111
match &e.kind {
112112
ExprKind::Unary(UnOp::UnNot, inner) => return Ok(Bool::Not(box self.run(inner)?)),
113113
ExprKind::Binary(binop, lhs, rhs) => match &binop.node {
114-
BinOpKind::Or => return Ok(Bool::Or(self.extract(BinOpKind::Or, &[lhs, rhs], Vec::new())?)),
115-
BinOpKind::And => return Ok(Bool::And(self.extract(BinOpKind::And, &[lhs, rhs], Vec::new())?)),
114+
BinOpKind::Or => {
115+
return Ok(Bool::Or(self.extract(BinOpKind::Or, &[lhs, rhs], Vec::new())?));
116+
},
117+
BinOpKind::And => {
118+
return Ok(Bool::And(self.extract(BinOpKind::And, &[lhs, rhs], Vec::new())?));
119+
},
116120
_ => (),
117121
},
118122
ExprKind::Lit(lit) => match lit.node {
@@ -248,7 +252,7 @@ fn simplify_not(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option<String> {
248252
})
249253
},
250254
ExprKind::MethodCall(path, _, args, _) if args.len() == 1 => {
251-
let type_of_receiver = cx.tables().expr_ty(&args[0]);
255+
let type_of_receiver = cx.typeck_results().expr_ty(&args[0]);
252256
if !is_type_diagnostic_item(cx, type_of_receiver, sym!(option_type))
253257
&& !is_type_diagnostic_item(cx, type_of_receiver, sym!(result_type))
254258
{
@@ -450,7 +454,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NonminimalBoolVisitor<'a, 'tcx> {
450454
self.bool_expr(e)
451455
},
452456
ExprKind::Unary(UnOp::UnNot, inner) => {
453-
if self.cx.tables().node_types()[inner.hir_id].is_bool() {
457+
if self.cx.typeck_results().node_types()[inner.hir_id].is_bool() {
454458
self.bool_expr(e);
455459
} else {
456460
walk_expr(self, e);
@@ -465,7 +469,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NonminimalBoolVisitor<'a, 'tcx> {
465469
}
466470

467471
fn implements_ord<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>) -> bool {
468-
let ty = cx.tables().expr_ty(expr);
472+
let ty = cx.typeck_results().expr_ty(expr);
469473
get_trait_def_id(cx, &paths::ORD).map_or(false, |id| implements_trait(cx, ty, id, &[]))
470474
}
471475

clippy_lints/src/bytecount.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl<'tcx> LateLintPass<'tcx> for ByteCount {
5353
if let ExprKind::Binary(ref op, ref l, ref r) = body.value.kind;
5454
if op.node == BinOpKind::Eq;
5555
if match_type(cx,
56-
walk_ptrs_ty(cx.tables().expr_ty(&filter_args[0])),
56+
walk_ptrs_ty(cx.typeck_results().expr_ty(&filter_args[0])),
5757
&paths::SLICE_ITER);
5858
then {
5959
let needle = match get_path_name(l) {
@@ -63,7 +63,7 @@ impl<'tcx> LateLintPass<'tcx> for ByteCount {
6363
_ => { return; }
6464
}
6565
};
66-
if ty::Uint(UintTy::U8) != walk_ptrs_ty(cx.tables().expr_ty(needle)).kind {
66+
if ty::Uint(UintTy::U8) != walk_ptrs_ty(cx.typeck_results().expr_ty(needle)).kind {
6767
return;
6868
}
6969
let haystack = if let ExprKind::MethodCall(ref path, _, ref args, _) =

clippy_lints/src/cognitive_complexity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl CognitiveComplexity {
6060
let mut helper = CCHelper { cc: 1, returns: 0 };
6161
helper.visit_expr(expr);
6262
let CCHelper { cc, returns } = helper;
63-
let ret_ty = cx.tables().node_type(expr.hir_id);
63+
let ret_ty = cx.typeck_results().node_type(expr.hir_id);
6464
let ret_adjust = if is_type_diagnostic_item(cx, ret_ty, sym!(result_type)) {
6565
returns
6666
} else {

0 commit comments

Comments
 (0)