We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
QPath::LangItem
1 parent dde93c9 commit bde529fCopy full SHA for bde529f
src/tools/clippy/clippy_lints/src/default_trait_access.rs
@@ -68,7 +68,7 @@ impl<'tcx> LateLintPass<'tcx> for DefaultTraitAccess {
68
);
69
}
70
},
71
- QPath::TypeRelative(..) => {},
+ QPath::TypeRelative(..) | QPath::LangItem(..) => {},
72
73
74
src/tools/clippy/clippy_lints/src/types.rs
@@ -475,6 +475,7 @@ impl Types {
475
476
477
478
+ QPath::LangItem(..) => {},
479
480
481
TyKind::Rptr(ref lt, ref mut_ty) => self.check_ty_rptr(cx, hir_ty, is_local, lt, mut_ty),
src/tools/clippy/clippy_lints/src/utils/author.rs
@@ -760,5 +760,6 @@ fn print_path(path: &QPath<'_>, first: &mut bool) {
760
761
ref other => print!("/* unimplemented: {:?}*/", other),
762
763
+ QPath::LangItem(lang_item, ..) => print!("#[lang = \"{}\"]", lang_item.name()),
764
765
src/tools/clippy/clippy_lints/src/utils/hir_utils.rs
@@ -601,6 +601,9 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
601
QPath::TypeRelative(_, ref path) => {
602
self.hash_name(path.ident.name);
603
604
+ QPath::LangItem(lang_item, ..) => {
605
+ lang_item.hash_stable(&mut self.cx.tcx.get_stable_hashing_context(), &mut self.s);
606
+ }
607
608
// self.maybe_typeck_results.unwrap().qpath_res(p, id).hash(&mut self.s);
609
@@ -710,6 +713,9 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
710
713
self.hash_ty(ty);
711
714
segment.ident.name.hash(&mut self.s);
712
715
716
717
+ lang_item.hash(&mut self.s);
718
719
720
TyKind::OpaqueDef(_, arg_list) => {
721
self.hash_generic_args(arg_list);
src/tools/clippy/clippy_lints/src/utils/inspector.rs
@@ -266,6 +266,9 @@ fn print_expr(cx: &LateContext<'_>, expr: &hir::Expr<'_>, indent: usize) {
266
println!("{}Relative Path, {:?}", ind, ty);
267
println!("{}seg: {:?}", ind, seg);
268
269
+ hir::ExprKind::Path(hir::QPath::LangItem(lang_item, ..)) => {
270
+ println!("{}Lang Item Path, {:?}", ind, lang_item.name());
271
+ },
272
hir::ExprKind::AddrOf(kind, ref muta, ref e) => {
273
println!("{}AddrOf", ind);
274
println!("kind: {:?}", kind);
@@ -488,6 +491,9 @@ fn print_pat(cx: &LateContext<'_>, pat: &hir::Pat<'_>, indent: usize) {
488
491
489
492
490
493
494
+ hir::PatKind::Path(hir::QPath::LangItem(lang_item, ..)) => {
495
496
497
hir::PatKind::Tuple(pats, opt_dots_position) => {
498
println!("{}Tuple", ind);
499
if let Some(dot_position) = opt_dots_position {
src/tools/clippy/clippy_lints/src/utils/mod.rs
@@ -163,13 +163,15 @@ pub fn last_path_segment<'tcx>(path: &QPath<'tcx>) -> &'tcx PathSegment<'tcx> {
163
match *path {
164
QPath::Resolved(_, ref path) => path.segments.last().expect("A path must have at least one segment"),
165
QPath::TypeRelative(_, ref seg) => seg,
166
+ QPath::LangItem(..) => panic!("last_path_segment: lang item has no path segments"),
167
168
169
170
pub fn single_segment_path<'tcx>(path: &QPath<'tcx>) -> Option<&'tcx PathSegment<'tcx>> {
171
172
QPath::Resolved(_, ref path) => path.segments.get(0),
173
QPath::TypeRelative(_, ref seg) => Some(seg),
174
+ QPath::LangItem(..) => panic!("single_segment_path: lang item has no path segments"),
175
176
177
@@ -196,6 +198,7 @@ pub fn match_qpath(path: &QPath<'_>, segments: &[&str]) -> bool {
196
198
197
199
_ => false,
200
201
+ QPath::LangItem(..) => panic!("match_qpath: lang item has no path segments"),
202
203
204
@@ -277,7 +280,7 @@ pub fn path_to_res(cx: &LateContext<'_>, path: &[&str]) -> Option<def::Res> {
277
280
pub fn qpath_res(cx: &LateContext<'_>, qpath: &hir::QPath<'_>, id: hir::HirId) -> Res {
278
281
match qpath {
279
282
hir::QPath::Resolved(_, path) => path.res,
- hir::QPath::TypeRelative(..) => {
283
+ hir::QPath::TypeRelative(..) | hir::QPath::LangItem(..) => {
284
if cx.tcx.has_typeck_results(id.owner.to_def_id()) {
285
cx.tcx.typeck(id.owner.to_def_id().expect_local()).qpath_res(qpath, id)
286
} else {
0 commit comments