|
9 | 9 |
|
10 | 10 |
|
11 | 11 | use crate::utils::{ |
12 | | - match_qpath, match_type, paths, span_help_and_lint, span_lint, span_lint_and_sugg, walk_ptrs_ty, |
| 12 | + match_def_path, match_qpath, match_type, paths, span_help_and_lint, span_lint, span_lint_and_sugg, walk_ptrs_ty, |
13 | 13 | }; |
14 | 14 | use if_chain::if_chain; |
15 | 15 | use crate::rustc::hir; |
16 | 16 | use crate::rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor}; |
17 | 17 | use crate::rustc::hir::*; |
| 18 | +use crate::rustc::hir::def::Def; |
18 | 19 | use crate::rustc::lint::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintArray, LintPass}; |
19 | 20 | use crate::rustc::{declare_tool_lint, lint_array}; |
20 | 21 | use crate::rustc_data_structures::fx::{FxHashMap, FxHashSet}; |
@@ -161,7 +162,8 @@ impl LintPass for LintWithoutLintPass { |
161 | 162 | impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LintWithoutLintPass { |
162 | 163 | fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) { |
163 | 164 | if let hir::ItemKind::Static(ref ty, MutImmutable, body_id) = item.node { |
164 | | - if is_lint_ref_type(ty) { |
| 165 | + |
| 166 | + if is_lint_ref_type(cx, ty) { |
165 | 167 | self.declared_lints.insert(item.name, item.span); |
166 | 168 | } else if is_lint_array_type(ty) && item.name == "ARRAY" { |
167 | 169 | if let VisibilityKind::Inherited = item.vis.node { |
@@ -203,19 +205,21 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LintWithoutLintPass { |
203 | 205 | } |
204 | 206 | } |
205 | 207 |
|
206 | | -fn is_lint_ref_type(ty: &Ty) -> bool { |
| 208 | +fn is_lint_ref_type<'tcx>(cx: &LateContext<'_, 'tcx>, ty: &Ty) -> bool { |
207 | 209 | if let TyKind::Rptr( |
208 | 210 | _, |
209 | 211 | MutTy { |
210 | 212 | ty: ref inner, |
211 | 213 | mutbl: MutImmutable, |
212 | 214 | }, |
213 | | - ) = ty.node |
214 | | - { |
| 215 | + ) = ty.node { |
215 | 216 | if let TyKind::Path(ref path) = inner.node { |
216 | | - return match_qpath(path, &paths::LINT); |
| 217 | + if let Def::Struct(def_id) = cx.tables.qpath_def(path, inner.hir_id) { |
| 218 | + return match_def_path(cx.tcx, def_id, &paths::LINT); |
| 219 | + } |
217 | 220 | } |
218 | 221 | } |
| 222 | + |
219 | 223 | false |
220 | 224 | } |
221 | 225 |
|
|
0 commit comments