@@ -653,22 +653,26 @@ impl<'a> TyLoweringContext<'a> {
653
653
infer_args: bool,
654
654
) -> Substitution {
655
655
let last = path.segments().last().expect("path should have at least one segment");
656
- let generic_def = resolved.to_generic_def_id();
657
- let segment = match resolved {
658
- ValueTyDefId::EnumVariantId(_) => {
656
+ let (segment, generic_def) = match resolved {
657
+ ValueTyDefId::FunctionId(it) => (last, Some(it.into())),
658
+ ValueTyDefId::StructId(it) => (last, Some(it.into())),
659
+ ValueTyDefId::UnionId(it) => (last, Some(it.into())),
660
+ ValueTyDefId::ConstId(it) => (last, Some(it.into())),
661
+ ValueTyDefId::StaticId(_) => (last, None),
662
+ ValueTyDefId::EnumVariantId(var) => {
659
663
// the generic args for an enum variant may be either specified
660
664
// on the segment referring to the enum, or on the segment
661
665
// referring to the variant. So `Option::<T>::None` and
662
666
// `Option::None::<T>` are both allowed (though the former is
663
667
// preferred). See also `def_ids_for_path_segments` in rustc.
664
668
let len = path.segments().len();
665
669
let penultimate = len.checked_sub(2).and_then(|idx| path.segments().get(idx));
666
- match penultimate {
670
+ let segment = match penultimate {
667
671
Some(segment) if segment.args_and_bindings.is_some() => segment,
668
672
_ => last,
669
- }
673
+ };
674
+ (segment, Some(var.parent.into()))
670
675
}
671
- _ => last,
672
676
};
673
677
self.substs_from_path_segment(segment, generic_def, infer_args, None)
674
678
}
@@ -1660,7 +1664,7 @@ impl ValueTyDefId {
1660
1664
Self::FunctionId(id) => Some(id.into()),
1661
1665
Self::StructId(id) => Some(id.into()),
1662
1666
Self::UnionId(id) => Some(id.into()),
1663
- Self::EnumVariantId(var) => Some(var.parent. into()),
1667
+ Self::EnumVariantId(var) => Some(var.into()),
1664
1668
Self::ConstId(id) => Some(id.into()),
1665
1669
Self::StaticId(_) => None,
1666
1670
}
0 commit comments