Skip to content

Commit fecd216

Browse files
committed
Auto merge of rust-lang#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
2 parents 9f75aff + 7c94736 commit fecd216

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

clippy_lints/src/trait_bounds.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl<'tcx> LateLintPass<'tcx> for TraitBounds {
9898
if let WherePredicate::BoundPredicate(ref bound_predicate) = predicate;
9999
if !bound_predicate.span.from_expansion();
100100
if let TyKind::Path(QPath::Resolved(_, Path { segments, .. })) = bound_predicate.bounded_ty.kind;
101-
if let Some(PathSegment { res: Some(Res::SelfTy(Some(def_id), _)), .. }) = segments.first();
101+
if let Some(PathSegment { res: Some(Res::SelfTy{ trait_: Some(def_id), alias_to: _ }), .. }) = segments.first();
102102

103103
if let Some(
104104
Node::Item(

clippy_lints/src/use_self.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ impl<'tcx> LateLintPass<'tcx> for UseSelf {
204204
ref types_to_skip,
205205
}) = self.stack.last();
206206
if let TyKind::Path(QPath::Resolved(_, path)) = hir_ty.kind;
207-
if !matches!(path.res, Res::SelfTy(..) | Res::Def(DefKind::TyParam, _));
207+
if !matches!(path.res, Res::SelfTy { .. } | Res::Def(DefKind::TyParam, _));
208208
if !types_to_skip.contains(&hir_ty.hir_id);
209209
let ty = if in_body > 0 {
210210
cx.typeck_results().node_type(hir_ty.hir_id)
@@ -231,7 +231,7 @@ impl<'tcx> LateLintPass<'tcx> for UseSelf {
231231
}
232232
match expr.kind {
233233
ExprKind::Struct(QPath::Resolved(_, path), ..) => match path.res {
234-
Res::SelfTy(..) => (),
234+
Res::SelfTy { .. } => (),
235235
Res::Def(DefKind::Variant, _) => lint_path_to_variant(cx, path),
236236
_ => span_lint(cx, path.span),
237237
},

clippy_utils/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1460,7 +1460,7 @@ pub fn is_self(slf: &Param<'_>) -> bool {
14601460

14611461
pub fn is_self_ty(slf: &hir::Ty<'_>) -> bool {
14621462
if let TyKind::Path(QPath::Resolved(None, path)) = slf.kind {
1463-
if let Res::SelfTy(..) = path.res {
1463+
if let Res::SelfTy { .. } = path.res {
14641464
return true;
14651465
}
14661466
}

0 commit comments

Comments
 (0)