@@ -1307,11 +1307,12 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
1307
1307
self . probe_traits_that_match_assoc_ty ( qself_ty, assoc_ident) ;
1308
1308
1309
1309
// Don't print `ty::Error` to the user.
1310
- self . report_ambiguous_assoc_ty (
1310
+ self . report_ambiguous_assoc (
1311
1311
span,
1312
1312
& [ qself_ty. to_string ( ) ] ,
1313
1313
& traits,
1314
1314
assoc_ident. name ,
1315
+ ty:: AssocKind :: Type ,
1315
1316
)
1316
1317
} ;
1317
1318
return Err ( reported) ;
@@ -1392,13 +1393,11 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
1392
1393
1393
1394
// In contexts that have no inference context, just make a new one.
1394
1395
// We do need a local variable to store it, though.
1395
- let infcx_;
1396
1396
let infcx = match self . infcx ( ) {
1397
1397
Some ( infcx) => infcx,
1398
1398
None => {
1399
1399
assert ! ( !self_ty. has_infer( ) ) ;
1400
- infcx_ = tcx. infer_ctxt ( ) . ignoring_regions ( ) . build ( TypingMode :: non_body_analysis ( ) ) ;
1401
- & infcx_
1400
+ & tcx. infer_ctxt ( ) . ignoring_regions ( ) . build ( TypingMode :: non_body_analysis ( ) )
1402
1401
}
1403
1402
} ;
1404
1403
@@ -1649,7 +1648,13 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
1649
1648
debug ! ( ?trait_def_id) ;
1650
1649
1651
1650
let Some ( self_ty) = opt_self_ty else {
1652
- return self . error_missing_qpath_self_ty ( trait_def_id, span, item_segment) ;
1651
+ let guar = self . error_missing_qpath_self_ty (
1652
+ trait_def_id,
1653
+ span,
1654
+ item_segment,
1655
+ ty:: AssocKind :: Type ,
1656
+ ) ;
1657
+ return Ty :: new_error ( tcx, guar) ;
1653
1658
} ;
1654
1659
debug ! ( ?self_ty) ;
1655
1660
@@ -1669,7 +1674,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
1669
1674
fn lower_qpath_const (
1670
1675
& self ,
1671
1676
span : Span ,
1672
- self_ty : Ty < ' tcx > ,
1677
+ opt_self_ty : Option < Ty < ' tcx > > ,
1673
1678
item_def_id : DefId ,
1674
1679
trait_segment : & hir:: PathSegment < ' tcx > ,
1675
1680
item_segment : & hir:: PathSegment < ' tcx > ,
@@ -1679,6 +1684,15 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
1679
1684
let trait_def_id = tcx. parent ( item_def_id) ;
1680
1685
debug ! ( ?trait_def_id) ;
1681
1686
1687
+ let Some ( self_ty) = opt_self_ty else {
1688
+ let guar = self . error_missing_qpath_self_ty (
1689
+ trait_def_id,
1690
+ span,
1691
+ item_segment,
1692
+ ty:: AssocKind :: Const ,
1693
+ ) ;
1694
+ return Const :: new_error ( tcx, guar) ;
1695
+ } ;
1682
1696
debug ! ( ?self_ty) ;
1683
1697
1684
1698
let ( item_def_id, item_args) = self . lower_qpath_shared (
@@ -1718,7 +1732,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
1718
1732
trait_def_id : DefId ,
1719
1733
span : Span ,
1720
1734
item_segment : & hir:: PathSegment < ' tcx > ,
1721
- ) -> Ty < ' tcx > {
1735
+ kind : ty:: AssocKind ,
1736
+ ) -> ErrorGuaranteed {
1722
1737
let tcx = self . tcx ( ) ;
1723
1738
let path_str = tcx. def_path_str ( trait_def_id) ;
1724
1739
@@ -1755,9 +1770,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
1755
1770
// FIXME: also look at `tcx.generics_of(self.item_def_id()).params` any that
1756
1771
// references the trait. Relevant for the first case in
1757
1772
// `src/test/ui/associated-types/associated-types-in-ambiguous-context.rs`
1758
- let reported =
1759
- self . report_ambiguous_assoc_ty ( span, & type_names, & [ path_str] , item_segment. ident . name ) ;
1760
- Ty :: new_error ( tcx, reported)
1773
+ self . report_ambiguous_assoc ( span, & type_names, & [ path_str] , item_segment. ident . name , kind)
1761
1774
}
1762
1775
1763
1776
pub fn prohibit_generic_args < ' a > (
@@ -2232,11 +2245,9 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
2232
2245
path. segments [ ..path. segments . len ( ) - 2 ] . iter ( ) ,
2233
2246
GenericsArgsErrExtend :: None ,
2234
2247
) ;
2235
- // FIXME(mgca): maybe needs proper error reported
2236
- let Some ( self_ty) = opt_self_ty else { span_bug ! ( span, "{path:?}" ) } ;
2237
2248
self . lower_qpath_const (
2238
2249
span,
2239
- self_ty ,
2250
+ opt_self_ty ,
2240
2251
did,
2241
2252
& path. segments [ path. segments . len ( ) - 2 ] ,
2242
2253
path. segments . last ( ) . unwrap ( ) ,
0 commit comments