@@ -22,6 +22,7 @@ use rustc::ty::subst::{Kind, Subst, Substs};
2222use rustc:: traits;
2323use rustc:: ty:: { self , Ty , TyCtxt , ToPredicate , TypeFoldable } ;
2424use rustc:: ty:: wf:: object_region_bounds;
25+ use rustc:: lint:: builtin:: PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES ;
2526use rustc_back:: slice;
2627use require_c_abi_if_variadic;
2728use util:: common:: { ErrorReported , FN_OUTPUT_NAME } ;
@@ -161,7 +162,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
161162 match item_segment. parameters {
162163 hir:: AngleBracketedParameters ( _) => { }
163164 hir:: ParenthesizedParameters ( ..) => {
164- self . prohibit_parenthesized_params ( item_segment) ;
165+ self . prohibit_parenthesized_params ( item_segment, true ) ;
165166
166167 return Substs :: for_item ( tcx, def_id, |_, _| {
167168 tcx. types . re_static
@@ -957,7 +958,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
957958 pub fn prohibit_type_params ( & self , segments : & [ hir:: PathSegment ] ) {
958959 for segment in segments {
959960 if let hir:: ParenthesizedParameters ( _) = segment. parameters {
960- self . prohibit_parenthesized_params ( segment) ;
961+ self . prohibit_parenthesized_params ( segment, false ) ;
961962 break ;
962963 }
963964 for typ in segment. parameters . types ( ) {
@@ -982,12 +983,18 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
982983 }
983984 }
984985
985- pub fn prohibit_parenthesized_params ( & self , segment : & hir:: PathSegment ) {
986+ pub fn prohibit_parenthesized_params ( & self , segment : & hir:: PathSegment , emit_error : bool ) {
986987 if let hir:: ParenthesizedParameters ( ref data) = segment. parameters {
987- struct_span_err ! ( self . tcx( ) . sess, data. span, E0214 ,
988- "parenthesized parameters may only be used with a trait" )
989- . span_label ( data. span , "only traits may use parentheses" )
990- . emit ( ) ;
988+ if emit_error {
989+ struct_span_err ! ( self . tcx( ) . sess, data. span, E0214 ,
990+ "parenthesized parameters may only be used with a trait" )
991+ . span_label ( data. span , "only traits may use parentheses" )
992+ . emit ( ) ;
993+ } else {
994+ let msg = "parenthesized parameters may only be used with a trait" . to_string ( ) ;
995+ self . tcx ( ) . sess . add_lint ( PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES ,
996+ ast:: CRATE_NODE_ID , data. span , msg) ;
997+ }
991998 }
992999 }
9931000
0 commit comments