@@ -22,6 +22,7 @@ use rustc::ty::subst::{Kind, Subst, Substs};
22
22
use rustc:: traits;
23
23
use rustc:: ty:: { self , Ty , TyCtxt , ToPredicate , TypeFoldable } ;
24
24
use rustc:: ty:: wf:: object_region_bounds;
25
+ use rustc:: lint:: builtin:: PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES ;
25
26
use rustc_back:: slice;
26
27
use require_c_abi_if_variadic;
27
28
use util:: common:: { ErrorReported , FN_OUTPUT_NAME } ;
@@ -161,7 +162,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
161
162
match item_segment. parameters {
162
163
hir:: AngleBracketedParameters ( _) => { }
163
164
hir:: ParenthesizedParameters ( ..) => {
164
- self . prohibit_parenthesized_params ( item_segment) ;
165
+ self . prohibit_parenthesized_params ( item_segment, true ) ;
165
166
166
167
return Substs :: for_item ( tcx, def_id, |_, _| {
167
168
tcx. types . re_static
@@ -957,7 +958,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
957
958
pub fn prohibit_type_params ( & self , segments : & [ hir:: PathSegment ] ) {
958
959
for segment in segments {
959
960
if let hir:: ParenthesizedParameters ( _) = segment. parameters {
960
- self . prohibit_parenthesized_params ( segment) ;
961
+ self . prohibit_parenthesized_params ( segment, false ) ;
961
962
break ;
962
963
}
963
964
for typ in segment. parameters . types ( ) {
@@ -982,12 +983,18 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
982
983
}
983
984
}
984
985
985
- pub fn prohibit_parenthesized_params ( & self , segment : & hir:: PathSegment ) {
986
+ pub fn prohibit_parenthesized_params ( & self , segment : & hir:: PathSegment , emit_error : bool ) {
986
987
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
+ }
991
998
}
992
999
}
993
1000
0 commit comments