Skip to content

Commit

Permalink
Rollup merge of rust-lang#81680 - camsteffen:primty, r=oli-obk
Browse files Browse the repository at this point in the history
Refactor `PrimitiveTypeTable` for Clippy

I removed `PrimitiveTypeTable` and added `PrimTy::ALL` and `PrimTy::from_name` in its place. This allows Clippy to use `PrimTy::from_name` for the `builtin_type_shadow` lint, and a `const` list of primitive types is deleted from Clippy code (the goal). All changes should be a little faster, if anything.
  • Loading branch information
jonas-schievink authored Feb 6, 2021
2 parents a9ad492 + f2e82af commit a5d442c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 18 deletions.
8 changes: 4 additions & 4 deletions clippy_lints/src/misc_early.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use crate::utils::{constants, snippet_opt, span_lint, span_lint_and_help, span_lint_and_sugg, span_lint_and_then};
use crate::utils::{snippet_opt, span_lint, span_lint_and_help, span_lint_and_sugg, span_lint_and_then};
use rustc_ast::ast::{
BindingMode, Expr, ExprKind, GenericParamKind, Generics, Lit, LitFloatType, LitIntType, LitKind, Mutability,
NodeId, Pat, PatKind, UnOp,
};
use rustc_ast::visit::FnKind;
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::Applicability;
use rustc_hir::PrimTy;
use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
use rustc_middle::lint::in_external_macro;
use rustc_session::{declare_lint_pass, declare_tool_lint};
Expand Down Expand Up @@ -264,13 +265,12 @@ impl EarlyLintPass for MiscEarlyLints {
fn check_generics(&mut self, cx: &EarlyContext<'_>, gen: &Generics) {
for param in &gen.params {
if let GenericParamKind::Type { .. } = param.kind {
let name = param.ident.as_str();
if constants::BUILTIN_TYPES.contains(&&*name) {
if let Some(prim_ty) = PrimTy::from_name(param.ident.name) {
span_lint(
cx,
BUILTIN_TYPE_SHADOW,
param.ident.span,
&format!("this generic shadows the built-in type `{}`", name),
&format!("this generic shadows the built-in type `{}`", prim_ty.name()),
);
}
}
Expand Down
13 changes: 0 additions & 13 deletions clippy_lints/src/utils/constants.rs

This file was deleted.

1 change: 0 additions & 1 deletion clippy_lints/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ pub mod author;
pub mod camel_case;
pub mod comparisons;
pub mod conf;
pub mod constants;
mod diagnostics;
pub mod eager_or_lazy;
pub mod higher;
Expand Down

0 comments on commit a5d442c

Please sign in to comment.