Skip to content

Commit 66409e0

Browse files
author
Alexander Regueiro
committed
Fixed issues raised in review.
1 parent 248dbbd commit 66409e0

File tree

1 file changed

+18
-31
lines changed
  • src/librustc_typeck/check

1 file changed

+18
-31
lines changed

src/librustc_typeck/check/mod.rs

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5057,7 +5057,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
50575057
// Luckily, we can (at least for now) deduce the intermediate steps
50585058
// just from the end-point.
50595059
//
5060-
// There are basically four cases to consider:
5060+
// There are basically five cases to consider:
50615061
//
50625062
// 1. Reference to a constructor of a struct:
50635063
//
@@ -5119,37 +5119,27 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
51195119

51205120
// Case 2. Reference to a variant constructor.
51215121
Def::VariantCtor(def_id, ..) => {
5122-
if self.tcx.features().type_alias_enum_variants {
5123-
let adt_def = self_ty.and_then(|t| t.ty_adt_def());
5124-
let (generics_def_id, index) = if let Some(adt_def) = adt_def {
5125-
debug_assert!(adt_def.is_enum());
5126-
(adt_def.did, last)
5127-
} else if last >= 1 && segments[last - 1].args.is_some() {
5128-
// Everything but the penultimate segment should have no
5129-
// parameters at all.
5130-
let enum_def_id = self.tcx.parent_def_id(def_id).unwrap();
5131-
(enum_def_id, last - 1)
5132-
} else {
5133-
// FIXME: lint here suggesting `Enum::<...>::Variant` form
5134-
// instead of `Enum::Variant::<...>` form.
5135-
5136-
// Everything but the final segment should have no
5137-
// parameters at all.
5138-
let generics = self.tcx.generics_of(def_id);
5139-
// Variant and struct constructors use the
5140-
// generics of their parent type definition.
5141-
(generics.parent.unwrap_or(def_id), last)
5142-
};
5143-
path_segs.push(PathSeg(generics_def_id, index));
5122+
let adt_def = self_ty.and_then(|t| t.ty_adt_def());
5123+
let (generics_def_id, index) = if let Some(adt_def) = adt_def {
5124+
debug_assert!(adt_def.is_enum());
5125+
(adt_def.did, last)
5126+
} else if last >= 1 && segments[last - 1].args.is_some() {
5127+
// Everything but the penultimate segment should have no
5128+
// parameters at all.
5129+
let enum_def_id = self.tcx.parent_def_id(def_id).unwrap();
5130+
(enum_def_id, last - 1)
51445131
} else {
5132+
// FIXME: lint here suggesting `Enum::<...>::Variant` form
5133+
// instead of `Enum::Variant::<...>` form.
5134+
51455135
// Everything but the final segment should have no
51465136
// parameters at all.
51475137
let generics = self.tcx.generics_of(def_id);
51485138
// Variant and struct constructors use the
51495139
// generics of their parent type definition.
5150-
let generics_def_id = generics.parent.unwrap_or(def_id);
5151-
path_segs.push(PathSeg(generics_def_id, last));
5152-
}
5140+
(generics.parent.unwrap_or(def_id), last)
5141+
};
5142+
path_segs.push(PathSeg(generics_def_id, index));
51535143
}
51545144

51555145
// Case 3. Reference to a top-level value.
@@ -5234,14 +5224,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
52345224
// provided (if any) into their appropriate spaces. We'll also report
52355225
// errors if type parameters are provided in an inappropriate place.
52365226

5237-
let is_alias_variant_ctor = if tcx.features().type_alias_enum_variants {
5227+
let is_alias_variant_ctor =
52385228
match def {
52395229
Def::VariantCtor(_, _) if self_ty.is_some() => true,
52405230
_ => false,
5241-
}
5242-
} else {
5243-
false
5244-
};
5231+
};
52455232

52465233
let generic_segs: FxHashSet<_> = path_segs.iter().map(|PathSeg(_, index)| index).collect();
52475234
AstConv::prohibit_generics(self, segments.iter().enumerate().filter_map(|(index, seg)| {

0 commit comments

Comments
 (0)