Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit e81e09a

Browse files
committed
change to a struct variant
1 parent 9cdefd7 commit e81e09a

File tree

27 files changed

+68
-57
lines changed

27 files changed

+68
-57
lines changed

compiler/rustc_hir/src/def.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -313,12 +313,12 @@ pub enum Res<Id = hir::HirId> {
313313
/// which already works on stable while causing the `const_evaluatable_unchecked` future compat lint.
314314
///
315315
/// FIXME(generic_const_exprs): Remove this bodge once that feature is stable.
316-
SelfTy(
316+
SelfTy {
317317
/// Optionally, the trait associated with this `Self` type.
318-
Option<DefId>,
319-
/// Optionally, the impl associated with this `Self` type.
320-
Option<(DefId, bool)>,
321-
),
318+
trait_: Option<DefId>,
319+
/// Optionally, the impl or adt associated with this `Self` type.
320+
alias_to: Option<(DefId, bool)>,
321+
},
322322
/// A tool attribute module; e.g., the `rustfmt` in `#[rustfmt::skip]`.
323323
///
324324
/// **Belongs to the type namespace.**
@@ -550,7 +550,7 @@ impl<Id> Res<Id> {
550550

551551
Res::Local(..)
552552
| Res::PrimTy(..)
553-
| Res::SelfTy(..)
553+
| Res::SelfTy { .. }
554554
| Res::SelfCtor(..)
555555
| Res::ToolMod
556556
| Res::NonMacroAttr(..)
@@ -573,7 +573,7 @@ impl<Id> Res<Id> {
573573
Res::SelfCtor(..) => "self constructor",
574574
Res::PrimTy(..) => "builtin type",
575575
Res::Local(..) => "local variable",
576-
Res::SelfTy(..) => "self type",
576+
Res::SelfTy { .. } => "self type",
577577
Res::ToolMod => "tool module",
578578
Res::NonMacroAttr(attr_kind) => attr_kind.descr(),
579579
Res::Err => "unresolved item",
@@ -596,7 +596,7 @@ impl<Id> Res<Id> {
596596
Res::SelfCtor(id) => Res::SelfCtor(id),
597597
Res::PrimTy(id) => Res::PrimTy(id),
598598
Res::Local(id) => Res::Local(map(id)),
599-
Res::SelfTy(a, b) => Res::SelfTy(a, b),
599+
Res::SelfTy { trait_, alias_to } => Res::SelfTy { trait_, alias_to },
600600
Res::ToolMod => Res::ToolMod,
601601
Res::NonMacroAttr(attr_kind) => Res::NonMacroAttr(attr_kind),
602602
Res::Err => Res::Err,
@@ -620,7 +620,7 @@ impl<Id> Res<Id> {
620620
pub fn ns(&self) -> Option<Namespace> {
621621
match self {
622622
Res::Def(kind, ..) => kind.ns(),
623-
Res::PrimTy(..) | Res::SelfTy(..) | Res::ToolMod => Some(Namespace::TypeNS),
623+
Res::PrimTy(..) | Res::SelfTy { .. } | Res::ToolMod => Some(Namespace::TypeNS),
624624
Res::SelfCtor(..) | Res::Local(..) => Some(Namespace::ValueNS),
625625
Res::NonMacroAttr(..) => Some(Namespace::MacroNS),
626626
Res::Err => None,

compiler/rustc_hir/src/hir.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -640,9 +640,8 @@ impl<'hir> WhereBoundPredicate<'hir> {
640640
_ => return false,
641641
};
642642
match path.res {
643-
Res::Def(DefKind::TyParam, def_id) | Res::SelfTy(Some(def_id), None) => {
644-
def_id == param_def_id
645-
}
643+
Res::Def(DefKind::TyParam, def_id)
644+
| Res::SelfTy { trait_: Some(def_id), alias_to: None } => def_id == param_def_id,
646645
_ => false,
647646
}
648647
}

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/trait_impl_difference.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,8 @@ impl<'tcx> Visitor<'tcx> for TypeParamSpanVisitor<'tcx> {
203203
.map(|res| {
204204
matches!(
205205
res,
206-
Res::SelfTy(_, _) | Res::Def(hir::def::DefKind::TyParam, _)
206+
Res::SelfTy { trait_: _, alias_to: _ }
207+
| Res::Def(hir::def::DefKind::TyParam, _)
207208
)
208209
})
209210
.unwrap_or(false) =>

compiler/rustc_lint/src/internal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ fn is_ty_or_ty_ctxt(cx: &LateContext<'_>, ty: &Ty<'_>) -> Option<String> {
202202
}
203203
}
204204
// Only lint on `&Ty` and `&TyCtxt` if it is used outside of a trait.
205-
Res::SelfTy(None, Some((did, _))) => {
205+
Res::SelfTy { trait_: None, alias_to: Some((did, _)) } => {
206206
if let ty::Adt(adt, substs) = cx.tcx.type_of(did).kind() {
207207
if let Some(name @ (sym::Ty | sym::TyCtxt)) =
208208
cx.tcx.get_diagnostic_name(adt.did)

compiler/rustc_lint/src/pass_by_value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ fn path_for_pass_by_value(cx: &LateContext<'_>, ty: &hir::Ty<'_>) -> Option<Stri
5454
let path_segment = path.segments.last().unwrap();
5555
return Some(format!("{}{}", name, gen_args(cx, path_segment)));
5656
}
57-
Res::SelfTy(None, Some((did, _))) => {
57+
Res::SelfTy { trait_: None, alias_to: Some((did, _)) } => {
5858
if let ty::Adt(adt, substs) = cx.tcx.type_of(did).kind() {
5959
if cx.tcx.has_attr(adt.did, sym::rustc_pass_by_value) {
6060
return Some(cx.tcx.def_path_str_with_substs(adt.did, substs));

compiler/rustc_middle/src/ty/adt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ impl<'tcx> AdtDef {
395395
| Res::Def(DefKind::Union, _)
396396
| Res::Def(DefKind::TyAlias, _)
397397
| Res::Def(DefKind::AssocTy, _)
398-
| Res::SelfTy(..)
398+
| Res::SelfTy { .. }
399399
| Res::SelfCtor(..) => self.non_enum_variant(),
400400
_ => bug!("unexpected res {:?} in variant_of_res", res),
401401
}

compiler/rustc_mir_build/src/thir/pattern/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
417417
| DefKind::AssocTy,
418418
_,
419419
)
420-
| Res::SelfTy(..)
420+
| Res::SelfTy { .. }
421421
| Res::SelfCtor(..) => PatKind::Leaf { subpatterns },
422422
_ => {
423423
let pattern_error = match res {

compiler/rustc_passes/src/dead.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
104104
self.check_def_id(variant_id);
105105
}
106106
}
107-
Res::SelfTy(t, i) => {
107+
Res::SelfTy { trait_: t, alias_to: i } => {
108108
if let Some(t) = t {
109109
self.check_def_id(t);
110110
}

compiler/rustc_privacy/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1350,7 +1350,7 @@ struct ObsoleteCheckTypeForPrivatenessVisitor<'a, 'b, 'tcx> {
13501350
impl<'a, 'tcx> ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
13511351
fn path_is_private_type(&self, path: &hir::Path<'_>) -> bool {
13521352
let did = match path.res {
1353-
Res::PrimTy(..) | Res::SelfTy(..) | Res::Err => return false,
1353+
Res::PrimTy(..) | Res::SelfTy { .. } | Res::Err => return false,
13541354
res => res.def_id(),
13551355
};
13561356

compiler/rustc_resolve/src/build_reduced_graph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
991991
_,
992992
)
993993
| Res::Local(..)
994-
| Res::SelfTy(..)
994+
| Res::SelfTy { .. }
995995
| Res::SelfCtor(..)
996996
| Res::Err => bug!("unexpected resolution: {:?}", res),
997997
}

0 commit comments

Comments
 (0)