Skip to content

Commit 590e07b

Browse files
committed
rustc_lint: avoid using TypeckTables::empty for LateContext.
1 parent 3c5ee33 commit 590e07b

27 files changed

+70
-69
lines changed

clippy_lints/src/atomic_ordering.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ fn check_atomic_load_store(cx: &LateContext<'_, '_>, expr: &Expr<'_>) {
7676
if method == "load" || method == "store";
7777
let ordering_arg = if method == "load" { &args[1] } else { &args[2] };
7878
if let ExprKind::Path(ref ordering_qpath) = ordering_arg.kind;
79-
if let Some(ordering_def_id) = cx.tables().qpath_res(ordering_qpath, ordering_arg.hir_id).opt_def_id();
79+
if let Some(ordering_def_id) = cx.qpath_res(ordering_qpath, ordering_arg.hir_id).opt_def_id();
8080
then {
8181
if method == "load" &&
8282
match_ordering_def_path(cx, ordering_def_id, &["Release", "AcqRel"]) {
@@ -107,12 +107,12 @@ fn check_memory_fence(cx: &LateContext<'_, '_>, expr: &Expr<'_>) {
107107
if_chain! {
108108
if let ExprKind::Call(ref func, ref args) = expr.kind;
109109
if let ExprKind::Path(ref func_qpath) = func.kind;
110-
if let Some(def_id) = cx.tables().qpath_res(func_qpath, func.hir_id).opt_def_id();
110+
if let Some(def_id) = cx.qpath_res(func_qpath, func.hir_id).opt_def_id();
111111
if ["fence", "compiler_fence"]
112112
.iter()
113113
.any(|func| match_def_path(cx, def_id, &["core", "sync", "atomic", func]));
114114
if let ExprKind::Path(ref ordering_qpath) = &args[0].kind;
115-
if let Some(ordering_def_id) = cx.tables().qpath_res(ordering_qpath, args[0].hir_id).opt_def_id();
115+
if let Some(ordering_def_id) = cx.qpath_res(ordering_qpath, args[0].hir_id).opt_def_id();
116116
if match_ordering_def_path(cx, ordering_def_id, &["Relaxed"]);
117117
then {
118118
span_lint_and_help(

clippy_lints/src/copies.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ fn lint_same_then_else(cx: &LateContext<'_, '_>, blocks: &[&Block<'_>]) {
192192
/// Implementation of `IFS_SAME_COND`.
193193
fn lint_same_cond(cx: &LateContext<'_, '_>, conds: &[&Expr<'_>]) {
194194
let hash: &dyn Fn(&&Expr<'_>) -> u64 = &|expr| -> u64 {
195-
let mut h = SpanlessHash::new(cx, cx.tables());
195+
let mut h = SpanlessHash::new(cx);
196196
h.hash_expr(expr);
197197
h.finish()
198198
};
@@ -215,7 +215,7 @@ fn lint_same_cond(cx: &LateContext<'_, '_>, conds: &[&Expr<'_>]) {
215215
/// Implementation of `SAME_FUNCTIONS_IN_IF_CONDITION`.
216216
fn lint_same_fns_in_if_cond(cx: &LateContext<'_, '_>, conds: &[&Expr<'_>]) {
217217
let hash: &dyn Fn(&&Expr<'_>) -> u64 = &|expr| -> u64 {
218-
let mut h = SpanlessHash::new(cx, cx.tables());
218+
let mut h = SpanlessHash::new(cx);
219219
h.hash_expr(expr);
220220
h.finish()
221221
};
@@ -251,7 +251,7 @@ fn lint_match_arms<'tcx>(cx: &LateContext<'_, 'tcx>, expr: &Expr<'_>) {
251251

252252
if let ExprKind::Match(_, ref arms, MatchSource::Normal) = expr.kind {
253253
let hash = |&(_, arm): &(usize, &Arm<'_>)| -> u64 {
254-
let mut h = SpanlessHash::new(cx, cx.tables());
254+
let mut h = SpanlessHash::new(cx);
255255
h.hash_expr(&arm.body);
256256
h.finish()
257257
};

clippy_lints/src/default_trait_access.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DefaultTraitAccess {
3636
if let ExprKind::Call(ref path, ..) = expr.kind;
3737
if !any_parent_is_automatically_derived(cx.tcx, expr.hir_id);
3838
if let ExprKind::Path(ref qpath) = path.kind;
39-
if let Some(def_id) = cx.tables().qpath_res(qpath, path.hir_id).opt_def_id();
39+
if let Some(def_id) = cx.qpath_res(qpath, path.hir_id).opt_def_id();
4040
if match_def_path(cx, def_id, &paths::DEFAULT_TRAIT_METHOD);
4141
then {
4242
match qpath {

clippy_lints/src/eval_order_dependence.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EvalOrderDependence {
7575
if let ExprKind::Path(ref qpath) = lhs.kind {
7676
if let QPath::Resolved(_, ref path) = *qpath {
7777
if path.segments.len() == 1 {
78-
if let def::Res::Local(var) = cx.tables().qpath_res(qpath, lhs.hir_id) {
78+
if let def::Res::Local(var) = cx.qpath_res(qpath, lhs.hir_id) {
7979
let mut visitor = ReadVisitor {
8080
cx,
8181
var,
@@ -309,7 +309,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ReadVisitor<'a, 'tcx> {
309309
if_chain! {
310310
if let QPath::Resolved(None, ref path) = *qpath;
311311
if path.segments.len() == 1;
312-
if let def::Res::Local(local_id) = self.cx.tables().qpath_res(qpath, expr.hir_id);
312+
if let def::Res::Local(local_id) = self.cx.qpath_res(qpath, expr.hir_id);
313313
if local_id == self.var;
314314
// Check that this is a read, not a write.
315315
if !is_in_assignment_position(self.cx, expr);

clippy_lints/src/format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ fn on_argumentv1_new<'a, 'tcx>(
8888
// matches `core::fmt::Display::fmt`
8989
if args.len() == 2;
9090
if let ExprKind::Path(ref qpath) = args[1].kind;
91-
if let Some(did) = cx.tables().qpath_res(qpath, args[1].hir_id).opt_def_id();
91+
if let Some(did) = cx.qpath_res(qpath, args[1].hir_id).opt_def_id();
9292
if match_def_path(cx, did, &paths::DISPLAY_FMT_METHOD);
9393
// check `(arg0,)` in match block
9494
if let PatKind::Tuple(ref pats, None) = arms[0].pat.kind;

clippy_lints/src/implicit_return.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ fn expr_match(cx: &LateContext<'_, '_>, expr: &Expr<'_>) {
108108
ExprKind::Call(expr, ..) => {
109109
if_chain! {
110110
if let ExprKind::Path(qpath) = &expr.kind;
111-
if let Some(path_def_id) = cx.tables().qpath_res(qpath, expr.hir_id).opt_def_id();
111+
if let Some(path_def_id) = cx.qpath_res(qpath, expr.hir_id).opt_def_id();
112112
if match_def_path(cx, path_def_id, &BEGIN_PANIC) ||
113113
match_def_path(cx, path_def_id, &BEGIN_PANIC_FMT);
114114
then { }

clippy_lints/src/let_and_return.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl BorrowVisitor<'_, '_> {
107107
..
108108
},
109109
..,
110-
) => self.cx.tables().qpath_res(qpath, expr.hir_id).opt_def_id(),
110+
) => self.cx.qpath_res(qpath, expr.hir_id).opt_def_id(),
111111
_ => None,
112112
}
113113
}

clippy_lints/src/lifetimes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ impl<'v, 't> RefVisitor<'v, 't> {
343343
})
344344
{
345345
let hir_id = ty.hir_id;
346-
match self.cx.tables().qpath_res(qpath, hir_id) {
346+
match self.cx.qpath_res(qpath, hir_id) {
347347
Res::Def(DefKind::TyAlias | DefKind::Struct, def_id) => {
348348
let generics = self.cx.tcx.generics_of(def_id);
349349
for _ in generics.params.as_slice() {

clippy_lints/src/map_unit_fn.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ fn reduce_unit_expression<'a>(cx: &LateContext<'_, '_>, expr: &'a hir::Expr<'_>)
160160
}
161161
}
162162

163-
fn unit_closure<'a, 'tcx>(
164-
cx: &LateContext<'a, 'tcx>,
165-
expr: &'a hir::Expr<'a>,
166-
) -> Option<(&'tcx hir::Param<'tcx>, &'a hir::Expr<'a>)> {
163+
fn unit_closure<'tcx>(
164+
cx: &LateContext<'_, 'tcx>,
165+
expr: &hir::Expr<'_>,
166+
) -> Option<(&'tcx hir::Param<'tcx>, &'tcx hir::Expr<'tcx>)> {
167167
if let hir::ExprKind::Closure(_, ref decl, inner_expr_id, _, _) = expr.kind {
168168
let body = cx.tcx.hir().body(inner_expr_id);
169169
let body_expr = &body.value;

clippy_lints/src/mem_discriminant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MemDiscriminant {
3535
if let ExprKind::Call(ref func, ref func_args) = expr.kind;
3636
// is `mem::discriminant`
3737
if let ExprKind::Path(ref func_qpath) = func.kind;
38-
if let Some(def_id) = cx.tables().qpath_res(func_qpath, func.hir_id).opt_def_id();
38+
if let Some(def_id) = cx.qpath_res(func_qpath, func.hir_id).opt_def_id();
3939
if match_def_path(cx, def_id, &paths::MEM_DISCRIMINANT);
4040
// type is non-enum
4141
let ty_param = cx.tables().node_substs(func.hir_id).type_at(0);

0 commit comments

Comments
 (0)