|
1 | | -use crate::utils::{constants, snippet_opt, span_lint, span_lint_and_help, span_lint_and_sugg, span_lint_and_then}; |
| 1 | +use crate::utils::{snippet_opt, span_lint, span_lint_and_help, span_lint_and_sugg, span_lint_and_then}; |
2 | 2 | use rustc_ast::ast::{ |
3 | 3 | BindingMode, Expr, ExprKind, GenericParamKind, Generics, Lit, LitFloatType, LitIntType, LitKind, Mutability, |
4 | 4 | NodeId, Pat, PatKind, UnOp, |
5 | 5 | }; |
6 | 6 | use rustc_ast::visit::FnKind; |
7 | 7 | use rustc_data_structures::fx::FxHashMap; |
8 | 8 | use rustc_errors::Applicability; |
| 9 | +use rustc_hir::PrimTy; |
9 | 10 | use rustc_lint::{EarlyContext, EarlyLintPass, LintContext}; |
10 | 11 | use rustc_middle::lint::in_external_macro; |
11 | 12 | use rustc_session::{declare_lint_pass, declare_tool_lint}; |
@@ -264,13 +265,12 @@ impl EarlyLintPass for MiscEarlyLints { |
264 | 265 | fn check_generics(&mut self, cx: &EarlyContext<'_>, gen: &Generics) { |
265 | 266 | for param in &gen.params { |
266 | 267 | if let GenericParamKind::Type { .. } = param.kind { |
267 | | - let name = param.ident.as_str(); |
268 | | - if constants::BUILTIN_TYPES.contains(&&*name) { |
| 268 | + if let Some(prim_ty) = PrimTy::from_name(param.ident.name) { |
269 | 269 | span_lint( |
270 | 270 | cx, |
271 | 271 | BUILTIN_TYPE_SHADOW, |
272 | 272 | param.ident.span, |
273 | | - &format!("this generic shadows the built-in type `{}`", name), |
| 273 | + &format!("this generic shadows the built-in type `{}`", prim_ty.name()), |
274 | 274 | ); |
275 | 275 | } |
276 | 276 | } |
|
0 commit comments