@@ -161,10 +161,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
161161 match item_segment. parameters {
162162 hir:: AngleBracketedParameters ( _) => { }
163163 hir:: ParenthesizedParameters ( ..) => {
164- struct_span_err ! ( tcx. sess, span, E0214 ,
165- "parenthesized parameters may only be used with a trait" )
166- . span_label ( span, "only traits may use parentheses" )
167- . emit ( ) ;
164+ self . prohibit_parenthesized_params ( item_segment) ;
168165
169166 return Substs :: for_item ( tcx, def_id, |_, _| {
170167 tcx. types . re_static
@@ -948,6 +945,10 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
948945
949946 pub fn prohibit_type_params ( & self , segments : & [ hir:: PathSegment ] ) {
950947 for segment in segments {
948+ if let hir:: ParenthesizedParameters ( _) = segment. parameters {
949+ self . prohibit_parenthesized_params ( segment) ;
950+ break ;
951+ }
951952 for typ in segment. parameters . types ( ) {
952953 struct_span_err ! ( self . tcx( ) . sess, typ. span, E0109 ,
953954 "type parameters are not allowed on this type" )
@@ -970,6 +971,15 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
970971 }
971972 }
972973
974+ pub fn prohibit_parenthesized_params ( & self , segment : & hir:: PathSegment ) {
975+ if let hir:: ParenthesizedParameters ( ref data) = segment. parameters {
976+ struct_span_err ! ( self . tcx( ) . sess, data. span, E0214 ,
977+ "parenthesized parameters may only be used with a trait" )
978+ . span_label ( data. span , "only traits may use parentheses" )
979+ . emit ( ) ;
980+ }
981+ }
982+
973983 pub fn prohibit_projection ( & self , span : Span ) {
974984 let mut err = struct_span_err ! ( self . tcx( ) . sess, span, E0229 ,
975985 "associated type bindings are not allowed here" ) ;
0 commit comments