@@ -23,6 +23,7 @@ use middle::astconv_util::ast_ty_to_prim_ty;
23
23
24
24
use syntax:: ast:: { self , Expr } ;
25
25
use syntax:: codemap:: Span ;
26
+ use syntax:: feature_gate;
26
27
use syntax:: parse:: token:: InternedString ;
27
28
use syntax:: ptr:: P ;
28
29
use syntax:: { ast_map, ast_util, codemap} ;
@@ -594,7 +595,16 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>,
594
595
match try!( eval_const_expr_partial ( tcx, & * * inner, ety) ) {
595
596
const_float( f) => const_float ( -f) ,
596
597
const_int( n) => try!( const_int_checked_neg ( n, e, expr_int_type) ) ,
597
- const_uint( n) => try!( const_uint_checked_neg ( n, e, expr_uint_type) ) ,
598
+ const_uint( i) => {
599
+ if !tcx. sess . features . borrow ( ) . negate_unsigned {
600
+ feature_gate:: emit_feature_err (
601
+ & tcx. sess . parse_sess . span_diagnostic ,
602
+ "negate_unsigned" ,
603
+ e. span ,
604
+ "unary negation of unsigned integers may be removed in the future" ) ;
605
+ }
606
+ const_uint ( n) => try!( const_uint_checked_neg ( n, e, expr_uint_type) ) ,
607
+ }
598
608
const_str( _) => signal ! ( e, NegateOnString ) ,
599
609
const_bool( _) => signal ! ( e, NegateOnBoolean ) ,
600
610
const_binary( _) => signal ! ( e, NegateOnBinary ) ,
0 commit comments