@@ -13,7 +13,7 @@ use crate::astconv::{
1313 AstConv , ConvertedBinding , ConvertedBindingKind , OnlySelfBounds , PredicateFilter ,
1414} ;
1515use crate :: bounds:: Bounds ;
16- use crate :: errors:: { MultipleRelaxedDefaultBounds , ValueOfAssociatedStructAlreadySpecified } ;
16+ use crate :: errors;
1717
1818impl < ' tcx > dyn AstConv < ' tcx > + ' _ {
1919 /// Sets `implicitly_sized` to true on `Bounds` if necessary
@@ -35,7 +35,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
3535 if unbound. is_none ( ) {
3636 unbound = Some ( & ptr. trait_ref ) ;
3737 } else {
38- tcx. sess . emit_err ( MultipleRelaxedDefaultBounds { span } ) ;
38+ tcx. sess . emit_err ( errors :: MultipleRelaxedDefaultBounds { span } ) ;
3939 }
4040 }
4141 }
@@ -326,7 +326,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
326326 dup_bindings
327327 . entry ( assoc_item. def_id )
328328 . and_modify ( |prev_span| {
329- tcx. sess . emit_err ( ValueOfAssociatedStructAlreadySpecified {
329+ tcx. sess . emit_err ( errors :: ValueOfAssociatedStructAlreadySpecified {
330330 span : binding. span ,
331331 prev_span : * prev_span,
332332 item_name : binding. item_name ,
@@ -488,6 +488,8 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
488488 }
489489 }
490490
491+ let assoc_item_def_id = projection_ty. skip_binder ( ) . def_id ;
492+ let def_kind = tcx. def_kind ( assoc_item_def_id) ;
491493 match binding. kind {
492494 ConvertedBindingKind :: Equality ( ..) if return_type_notation => {
493495 return Err ( self . tcx ( ) . sess . emit_err (
@@ -499,11 +501,9 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
499501 // the "projection predicate" for:
500502 //
501503 // `<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) ;
504504 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 ( _) ) => ( ) ,
507507 ( _, _) => {
508508 let got = if let Some ( _) = term. ty ( ) { "type" } else { "constant" } ;
509509 let expected = tcx. def_descr ( assoc_item_def_id) ;
@@ -516,7 +516,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
516516 format ! ( "{expected} defined here" ) ,
517517 ) ;
518518
519- if let hir :: def :: DefKind :: AssocConst = def_kind
519+ if let DefKind :: AssocConst = def_kind
520520 && let Some ( t) = term. ty ( ) && ( t. is_enum ( ) || t. references_error ( ) )
521521 && tcx. features ( ) . associated_const_equality {
522522 err. span_suggestion (
@@ -528,8 +528,8 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
528528 }
529529 let reported = err. emit ( ) ;
530530 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 (
533533 tcx,
534534 reported,
535535 tcx. type_of ( assoc_item_def_id)
@@ -548,6 +548,15 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
548548 ) ;
549549 }
550550 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+ }
551560 // "Desugar" a constraint like `T: Iterator<Item: Debug>` to
552561 //
553562 // `<T as Iterator>::Item: Debug`
0 commit comments