diff options
| author | Devin Ragotzy <devin.ragotzy@gmail.com> | 2021-07-22 08:40:24 -0400 |
|---|---|---|
| committer | Devin Ragotzy <devin.ragotzy@gmail.com> | 2021-07-27 10:01:38 -0400 |
| commit | a1bab3bc63d183d3d319d52742e31fa54ec7caae (patch) | |
| tree | 595cc5375f1de08e22603b2e553914a72e7696cb /clippy_utils | |
| parent | ceb7a868d39ee19bbe75ec14beb62951f2413052 (diff) | |
| download | rust-a1bab3bc63d183d3d319d52742e31fa54ec7caae.tar.gz rust-a1bab3bc63d183d3d319d52742e31fa54ec7caae.zip | |
Add primitive type support to disallowed_type lint
Fix docs of disallowed_type Add ability to name primitive types without import path Move primitive resolution to clippy_utils path_to_res fn Refactor Res matching, fix naming and docs from review Use tcx.def_path_str when emitting the lint
Diffstat (limited to 'clippy_utils')
| -rw-r--r-- | clippy_utils/src/lib.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/clippy_utils/src/lib.rs b/clippy_utils/src/lib.rs index 6dfb8c38a76..59f878f8b20 100644 --- a/clippy_utils/src/lib.rs +++ b/clippy_utils/src/lib.rs @@ -72,7 +72,7 @@ use rustc_hir::LangItem::{ResultErr, ResultOk}; use rustc_hir::{ def, Arm, BindingAnnotation, Block, Body, Constness, Destination, Expr, ExprKind, FnDecl, GenericArgs, HirId, Impl, ImplItem, ImplItemKind, IsAsync, Item, ItemKind, LangItem, Local, MatchSource, Node, Param, Pat, PatKind, Path, - PathSegment, QPath, Stmt, StmtKind, TraitItem, TraitItemKind, TraitRef, TyKind, UnOp, + PathSegment, PrimTy, QPath, Stmt, StmtKind, TraitItem, TraitItemKind, TraitRef, TyKind, UnOp, }; use rustc_lint::{LateContext, Level, Lint, LintContext}; use rustc_middle::hir::exports::Export; @@ -490,6 +490,9 @@ pub fn path_to_res(cx: &LateContext<'_>, path: &[&str]) -> Res { let (krate, first, path) = match *path { [krate, first, ref path @ ..] => (krate, first, path), + [primitive] => { + return PrimTy::from_name(Symbol::intern(primitive)).map_or(Res::Err, Res::PrimTy); + }, _ => return Res::Err, }; let tcx = cx.tcx; |
