Rollup merge of #81680 - camsteffen:primty, r=oli-obk
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.
This commit is contained in:
@@ -20,7 +20,7 @@ use rustc_errors::DiagnosticId;
|
||||
use rustc_hir::def::Namespace::{self, *};
|
||||
use rustc_hir::def::{self, CtorKind, DefKind, PartialRes, PerNS};
|
||||
use rustc_hir::def_id::{DefId, CRATE_DEF_INDEX};
|
||||
use rustc_hir::TraitCandidate;
|
||||
use rustc_hir::{PrimTy, TraitCandidate};
|
||||
use rustc_middle::{bug, span_bug};
|
||||
use rustc_session::lint;
|
||||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||
@@ -1927,7 +1927,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
|
||||
self.r.trait_map.insert(id, traits);
|
||||
}
|
||||
|
||||
if self.r.primitive_type_table.primitive_types.contains_key(&path[0].ident.name) {
|
||||
if PrimTy::from_name(path[0].ident.name).is_some() {
|
||||
let mut std_path = Vec::with_capacity(1 + path.len());
|
||||
|
||||
std_path.push(Segment::from_ident(Ident::with_dummy_span(sym::std)));
|
||||
@@ -2121,13 +2121,9 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
|
||||
// The same fallback is used when `a` resolves to nothing.
|
||||
PathResult::Module(ModuleOrUniformRoot::Module(_)) | PathResult::Failed { .. }
|
||||
if (ns == TypeNS || path.len() > 1)
|
||||
&& self
|
||||
.r
|
||||
.primitive_type_table
|
||||
.primitive_types
|
||||
.contains_key(&path[0].ident.name) =>
|
||||
&& PrimTy::from_name(path[0].ident.name).is_some() =>
|
||||
{
|
||||
let prim = self.r.primitive_type_table.primitive_types[&path[0].ident.name];
|
||||
let prim = PrimTy::from_name(path[0].ident.name).unwrap();
|
||||
PartialRes::with_unresolved_segments(Res::PrimTy(prim), path.len() - 1)
|
||||
}
|
||||
PathResult::Module(ModuleOrUniformRoot::Module(module)) => {
|
||||
|
||||
Reference in New Issue
Block a user