@@ -13,7 +13,7 @@ use crate::astconv::{
13
13
AstConv , ConvertedBinding , ConvertedBindingKind , OnlySelfBounds , PredicateFilter ,
14
14
} ;
15
15
use crate :: bounds:: Bounds ;
16
- use crate :: errors:: { MultipleRelaxedDefaultBounds , ValueOfAssociatedStructAlreadySpecified } ;
16
+ use crate :: errors;
17
17
18
18
impl < ' tcx > dyn AstConv < ' tcx > + ' _ {
19
19
/// Sets `implicitly_sized` to true on `Bounds` if necessary
@@ -35,7 +35,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
35
35
if unbound. is_none ( ) {
36
36
unbound = Some ( & ptr. trait_ref ) ;
37
37
} else {
38
- tcx. sess . emit_err ( MultipleRelaxedDefaultBounds { span } ) ;
38
+ tcx. sess . emit_err ( errors :: MultipleRelaxedDefaultBounds { span } ) ;
39
39
}
40
40
}
41
41
}
@@ -326,7 +326,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
326
326
dup_bindings
327
327
. entry ( assoc_item. def_id )
328
328
. and_modify ( |prev_span| {
329
- tcx. sess . emit_err ( ValueOfAssociatedStructAlreadySpecified {
329
+ tcx. sess . emit_err ( errors :: ValueOfAssociatedStructAlreadySpecified {
330
330
span : binding. span ,
331
331
prev_span : * prev_span,
332
332
item_name : binding. item_name ,
@@ -488,6 +488,8 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
488
488
}
489
489
}
490
490
491
+ let assoc_item_def_id = projection_ty. skip_binder ( ) . def_id ;
492
+ let def_kind = tcx. def_kind ( assoc_item_def_id) ;
491
493
match binding. kind {
492
494
ConvertedBindingKind :: Equality ( ..) if return_type_notation => {
493
495
return Err ( self . tcx ( ) . sess . emit_err (
@@ -499,11 +501,9 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
499
501
// the "projection predicate" for:
500
502
//
501
503
// `<T as Iterator>::Item = u32`
502
- let assoc_item_def_id = projection_ty. skip_binder ( ) . def_id ;
503
- let def_kind = tcx. def_kind ( assoc_item_def_id) ;
504
504
match ( def_kind, term. unpack ( ) ) {
505
- ( hir :: def :: DefKind :: AssocTy , ty:: TermKind :: Ty ( _) )
506
- | ( hir :: def :: DefKind :: AssocConst , ty:: TermKind :: Const ( _) ) => ( ) ,
505
+ ( DefKind :: AssocTy , ty:: TermKind :: Ty ( _) )
506
+ | ( DefKind :: AssocConst , ty:: TermKind :: Const ( _) ) => ( ) ,
507
507
( _, _) => {
508
508
let got = if let Some ( _) = term. ty ( ) { "type" } else { "constant" } ;
509
509
let expected = tcx. def_descr ( assoc_item_def_id) ;
@@ -516,7 +516,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
516
516
format ! ( "{expected} defined here" ) ,
517
517
) ;
518
518
519
- if let hir :: def :: DefKind :: AssocConst = def_kind
519
+ if let DefKind :: AssocConst = def_kind
520
520
&& let Some ( t) = term. ty ( ) && ( t. is_enum ( ) || t. references_error ( ) )
521
521
&& tcx. features ( ) . associated_const_equality {
522
522
err. span_suggestion (
@@ -528,8 +528,8 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
528
528
}
529
529
let reported = err. emit ( ) ;
530
530
term = match def_kind {
531
- hir :: def :: DefKind :: AssocTy => Ty :: new_error ( tcx, reported) . into ( ) ,
532
- hir :: def :: DefKind :: AssocConst => ty:: Const :: new_error (
531
+ DefKind :: AssocTy => Ty :: new_error ( tcx, reported) . into ( ) ,
532
+ DefKind :: AssocConst => ty:: Const :: new_error (
533
533
tcx,
534
534
reported,
535
535
tcx. type_of ( assoc_item_def_id)
@@ -548,6 +548,15 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
548
548
) ;
549
549
}
550
550
ConvertedBindingKind :: Constraint ( ast_bounds) => {
551
+ match def_kind {
552
+ DefKind :: AssocTy => { }
553
+ _ => {
554
+ return Err ( tcx. sess . emit_err ( errors:: AssocBoundOnConst {
555
+ span : assoc_ident. span ,
556
+ descr : tcx. def_descr ( assoc_item_def_id) ,
557
+ } ) ) ;
558
+ }
559
+ }
551
560
// "Desugar" a constraint like `T: Iterator<Item: Debug>` to
552
561
//
553
562
// `<T as Iterator>::Item: Debug`
0 commit comments