change to a struct variant
This commit is contained in:
parent
9cdefd763b
commit
e81e09a24e
27 changed files with 68 additions and 57 deletions
|
@ -1805,7 +1805,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
// Find the type of the associated item, and the trait where the associated
|
||||
// item is declared.
|
||||
let bound = match (&qself_ty.kind(), qself_res) {
|
||||
(_, Res::SelfTy(Some(_), Some((impl_def_id, _)))) => {
|
||||
(_, Res::SelfTy { trait_: Some(_), alias_to: Some((impl_def_id, _)) }) => {
|
||||
// `Self` in an impl of a trait -- we have a concrete self type and a
|
||||
// trait reference.
|
||||
let trait_ref = match tcx.impl_trait_ref(impl_def_id) {
|
||||
|
@ -1826,7 +1826,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
}
|
||||
(
|
||||
&ty::Param(_),
|
||||
Res::SelfTy(Some(param_did), None) | Res::Def(DefKind::TyParam, param_did),
|
||||
Res::SelfTy { trait_: Some(param_did), alias_to: None }
|
||||
| Res::Def(DefKind::TyParam, param_did),
|
||||
) => self.find_bound_for_assoc_item(param_did.expect_local(), assoc_ident, span)?,
|
||||
_ => {
|
||||
if variant_resolution.is_some() {
|
||||
|
@ -2270,13 +2271,13 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
let index = generics.param_def_id_to_index[&def_id];
|
||||
tcx.mk_ty_param(index, tcx.hir().name(hir_id))
|
||||
}
|
||||
Res::SelfTy(Some(_), None) => {
|
||||
Res::SelfTy { trait_: Some(_), alias_to: None } => {
|
||||
// `Self` in trait or type alias.
|
||||
assert_eq!(opt_self_ty, None);
|
||||
self.prohibit_generics(path.segments);
|
||||
tcx.types.self_param
|
||||
}
|
||||
Res::SelfTy(_, Some((def_id, forbid_generic))) => {
|
||||
Res::SelfTy { trait_: _, alias_to: Some((def_id, forbid_generic)) } => {
|
||||
// `Self` in impl (we know the concrete type).
|
||||
assert_eq!(opt_self_ty, None);
|
||||
self.prohibit_generics(path.segments);
|
||||
|
|
|
@ -522,7 +522,12 @@ pub(super) fn check_opaque_for_inheriting_lifetimes<'tcx>(
|
|||
fn visit_ty(&mut self, arg: &'tcx hir::Ty<'tcx>) {
|
||||
match arg.kind {
|
||||
hir::TyKind::Path(hir::QPath::Resolved(None, path)) => match &path.segments {
|
||||
[PathSegment { res: Some(Res::SelfTy(_, impl_ref)), .. }] => {
|
||||
[
|
||||
PathSegment {
|
||||
res: Some(Res::SelfTy { trait_: _, alias_to: impl_ref }),
|
||||
..
|
||||
},
|
||||
] => {
|
||||
let impl_ty_name =
|
||||
impl_ref.map(|(def_id, _)| self.tcx.def_path_str(def_id));
|
||||
self.selftys.push((path.span, impl_ty_name));
|
||||
|
|
|
@ -578,7 +578,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
_ => bug!("unexpected type: {:?}", ty),
|
||||
},
|
||||
Res::Def(DefKind::Struct | DefKind::Union | DefKind::TyAlias | DefKind::AssocTy, _)
|
||||
| Res::SelfTy(..) => match ty.kind() {
|
||||
| Res::SelfTy { .. } => match ty.kind() {
|
||||
ty::Adt(adt, substs) if !adt.is_enum() => {
|
||||
Some((adt.non_enum_variant(), adt.did, substs))
|
||||
}
|
||||
|
|
|
@ -562,7 +562,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
|||
Res::Def(DefKind::Ctor(CtorOf::Struct, ..), _)
|
||||
| Res::Def(DefKind::Struct | DefKind::Union | DefKind::TyAlias | DefKind::AssocTy, _)
|
||||
| Res::SelfCtor(..)
|
||||
| Res::SelfTy(..) => {
|
||||
| Res::SelfTy { .. } => {
|
||||
// Structs and Unions have only have one variant.
|
||||
Ok(VariantIdx::new(0))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue