diff options
| author | bors <bors@rust-lang.org> | 2022-02-14 12:26:43 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-02-14 12:26:43 +0000 |
| commit | fecd21682bcaaa8a9c9f6347480ae05609e6902a (patch) | |
| tree | f75e3b7dc951a97985417f421c38295795cf9a35 | |
| parent | 9f75aff3919122b5657650930c38095731d2dbba (diff) | |
| parent | 7c94736953097fb78bd211ae8d493f2fb8bad072 (diff) | |
| download | rust-fecd21682bcaaa8a9c9f6347480ae05609e6902a.tar.gz rust-fecd21682bcaaa8a9c9f6347480ae05609e6902a.zip | |
Auto merge of #93938 - BoxyUwU:fix_res_self_ty, r=lcnr
Make `Res::SelfTy` a struct variant and update docs I found pattern matching on a `(Option<DefId>, Option<(DefId, bool)>)` to not be super readable, additionally the doc comments on the types in a tuple variant aren't visible anywhere at use sites as far as I can tell (using rust analyzer + vscode) The docs incorrectly assumed that the `DefId` in `Option<(DefId, bool)>` would only ever be for an impl item and I also found the code examples to be somewhat unclear about which `DefId` was being talked about. r? `@lcnr` since you reviewed the last PR changing these docs
| -rw-r--r-- | clippy_lints/src/trait_bounds.rs | 2 | ||||
| -rw-r--r-- | clippy_lints/src/use_self.rs | 4 | ||||
| -rw-r--r-- | clippy_utils/src/lib.rs | 2 |
3 files changed, 4 insertions, 4 deletions
diff --git a/clippy_lints/src/trait_bounds.rs b/clippy_lints/src/trait_bounds.rs index 5257f5302cd..bca95b7f256 100644 --- a/clippy_lints/src/trait_bounds.rs +++ b/clippy_lints/src/trait_bounds.rs @@ -98,7 +98,7 @@ impl<'tcx> LateLintPass<'tcx> for TraitBounds { if let WherePredicate::BoundPredicate(ref bound_predicate) = predicate; if !bound_predicate.span.from_expansion(); if let TyKind::Path(QPath::Resolved(_, Path { segments, .. })) = bound_predicate.bounded_ty.kind; - if let Some(PathSegment { res: Some(Res::SelfTy(Some(def_id), _)), .. }) = segments.first(); + if let Some(PathSegment { res: Some(Res::SelfTy{ trait_: Some(def_id), alias_to: _ }), .. }) = segments.first(); if let Some( Node::Item( diff --git a/clippy_lints/src/use_self.rs b/clippy_lints/src/use_self.rs index be20282b3b8..80164c59ba7 100644 --- a/clippy_lints/src/use_self.rs +++ b/clippy_lints/src/use_self.rs @@ -204,7 +204,7 @@ impl<'tcx> LateLintPass<'tcx> for UseSelf { ref types_to_skip, }) = self.stack.last(); if let TyKind::Path(QPath::Resolved(_, path)) = hir_ty.kind; - if !matches!(path.res, Res::SelfTy(..) | Res::Def(DefKind::TyParam, _)); + if !matches!(path.res, Res::SelfTy { .. } | Res::Def(DefKind::TyParam, _)); if !types_to_skip.contains(&hir_ty.hir_id); let ty = if in_body > 0 { cx.typeck_results().node_type(hir_ty.hir_id) @@ -231,7 +231,7 @@ impl<'tcx> LateLintPass<'tcx> for UseSelf { } match expr.kind { ExprKind::Struct(QPath::Resolved(_, path), ..) => match path.res { - Res::SelfTy(..) => (), + Res::SelfTy { .. } => (), Res::Def(DefKind::Variant, _) => lint_path_to_variant(cx, path), _ => span_lint(cx, path.span), }, diff --git a/clippy_utils/src/lib.rs b/clippy_utils/src/lib.rs index 42955080c96..f775cdd3bc2 100644 --- a/clippy_utils/src/lib.rs +++ b/clippy_utils/src/lib.rs @@ -1460,7 +1460,7 @@ pub fn is_self(slf: &Param<'_>) -> bool { pub fn is_self_ty(slf: &hir::Ty<'_>) -> bool { if let TyKind::Path(QPath::Resolved(None, path)) = slf.kind { - if let Res::SelfTy(..) = path.res { + if let Res::SelfTy { .. } = path.res { return true; } } |
