mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 07:00:55 +00:00
Store the laziness of type aliases in the DefKind
This commit is contained in:
parent
1589759334
commit
3ff6fd2ac7
3 changed files with 3 additions and 3 deletions
|
@ -50,7 +50,7 @@ impl<'tcx> LateLintPass<'tcx> for NumberedFields {
|
|||
&& fields
|
||||
.iter()
|
||||
.all(|f| f.ident.as_str().as_bytes().iter().all(u8::is_ascii_digit))
|
||||
&& !matches!(cx.qpath_res(path, e.hir_id), Res::Def(DefKind::TyAlias, ..))
|
||||
&& !matches!(cx.qpath_res(path, e.hir_id), Res::Def(DefKind::TyAlias { .. }, ..))
|
||||
{
|
||||
let expr_spans = fields
|
||||
.iter()
|
||||
|
|
|
@ -286,7 +286,7 @@ pub fn is_wild(pat: &Pat<'_>) -> bool {
|
|||
/// Checks if the given `QPath` belongs to a type alias.
|
||||
pub fn is_ty_alias(qpath: &QPath<'_>) -> bool {
|
||||
match *qpath {
|
||||
QPath::Resolved(_, path) => matches!(path.res, Res::Def(DefKind::TyAlias | DefKind::AssocTy, ..)),
|
||||
QPath::Resolved(_, path) => matches!(path.res, Res::Def(DefKind::TyAlias { .. } | DefKind::AssocTy, ..)),
|
||||
QPath::TypeRelative(ty, _) if let TyKind::Path(qpath) = ty.kind => { is_ty_alias(&qpath) },
|
||||
_ => false,
|
||||
}
|
||||
|
|
|
@ -219,7 +219,7 @@ fn path_segment_certainty(
|
|||
// See the comment preceding `qpath_certainty`. `def_id` could refer to a type or a value.
|
||||
let certainty = lhs.join_clearing_def_ids(rhs);
|
||||
if resolves_to_type {
|
||||
if cx.tcx.def_kind(def_id) == DefKind::TyAlias {
|
||||
if let DefKind::TyAlias { .. } = cx.tcx.def_kind(def_id) {
|
||||
adt_def_id(cx.tcx.type_of(def_id).instantiate_identity())
|
||||
.map_or(certainty, |def_id| certainty.with_def_id(def_id))
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue