@@ -2131,6 +2131,7 @@ pub fn type_is_scalar(ty: t) -> bool {
21312131 ty_bool | ty_char | ty_int( _) | ty_float( _) | ty_uint( _) |
21322132 ty_infer( IntVar ( _) ) | ty_infer( FloatVar ( _) ) |
21332133 ty_bare_fn( ..) | ty_ptr( _) => true ,
2134+ ty_tup( ref tys) if tys. is_empty ( ) => true ,
21342135 _ => false
21352136 }
21362137}
@@ -3777,6 +3778,7 @@ pub fn ty_sort_string(cx: &ctxt, t: t) -> String {
37773778 ty_uint( _) | ty_float( _) | ty_str => {
37783779 :: util:: ppaux:: ty_to_string ( cx, t)
37793780 }
3781+ ty_tup( ref tys) if tys. is_empty ( ) => :: util:: ppaux:: ty_to_string ( cx, t) ,
37803782
37813783 ty_enum( id, _) => format ! ( "enum {}" , item_path_str( cx, id) ) ,
37823784 ty_uniq( _) => "box" . to_string ( ) ,
@@ -4771,54 +4773,42 @@ pub fn normalize_ty(cx: &ctxt, t: t) -> t {
47714773// Returns the repeat count for a repeating vector expression.
47724774pub fn eval_repeat_count ( tcx : & ctxt , count_expr : & ast:: Expr ) -> uint {
47734775 match const_eval:: eval_const_expr_partial ( tcx, count_expr) {
4774- Ok ( ref const_val) => match * const_val {
4775- const_eval:: const_int( count) => if count < 0 {
4776- tcx. sess . span_err ( count_expr. span ,
4777- "expected positive integer for \
4778- repeat count, found negative integer") ;
4779- 0
4780- } else {
4781- count as uint
4782- } ,
4783- const_eval:: const_uint( count) => count as uint ,
4784- const_eval:: const_float( count) => {
4785- tcx. sess . span_err ( count_expr. span ,
4786- "expected positive integer for \
4787- repeat count, found float") ;
4788- count as uint
4789- }
4790- const_eval:: const_str( _) => {
4791- tcx. sess . span_err ( count_expr. span ,
4792- "expected positive integer for \
4793- repeat count, found string") ;
4794- 0
4795- }
4796- const_eval:: const_bool( _) => {
4797- tcx. sess . span_err ( count_expr. span ,
4798- "expected positive integer for \
4799- repeat count, found boolean") ;
4800- 0
4801- }
4802- const_eval:: const_binary( _) => {
4803- tcx. sess . span_err ( count_expr. span ,
4804- "expected positive integer for \
4805- repeat count, found binary array") ;
4806- 0
4807- }
4808- const_eval:: const_nil => {
4809- tcx. sess . span_err ( count_expr. span ,
4810- "expected positive integer for \
4811- repeat count, found ()") ;
4812- 0
4813- }
4814- } ,
4815- Err ( ..) => {
4816- tcx. sess . span_err ( count_expr. span ,
4817- "expected constant integer for repeat count, \
4818- found variable") ;
4819- 0
4820- }
4776+ Ok ( val) => {
4777+ let found = match val {
4778+ const_eval:: const_uint( count) => return count as uint ,
4779+ const_eval:: const_int( count) if count >= 0 => return count as uint ,
4780+ const_eval:: const_int( _) =>
4781+ "negative integer" ,
4782+ const_eval:: const_float( _) =>
4783+ "float" ,
4784+ const_eval:: const_str( _) =>
4785+ "string" ,
4786+ const_eval:: const_bool( _) =>
4787+ "boolean" ,
4788+ const_eval:: const_binary( _) =>
4789+ "binary array"
4790+ } ;
4791+ tcx. sess . span_err ( count_expr. span , format ! (
4792+ "expected positive integer for repeat count, found {}" ,
4793+ found) . as_slice ( ) ) ;
4794+ }
4795+ Err ( _) => {
4796+ let found = match count_expr. node {
4797+ ast:: ExprPath ( ast:: Path {
4798+ global : false ,
4799+ ref segments,
4800+ ..
4801+ } ) if segments. len ( ) == 1 =>
4802+ "variable" ,
4803+ _ =>
4804+ "non-constant expression"
4805+ } ;
4806+ tcx. sess . span_err ( count_expr. span , format ! (
4807+ "expected constant integer for repeat count, found {}" ,
4808+ found) . as_slice ( ) ) ;
4809+ }
48214810 }
4811+ 0
48224812}
48234813
48244814// Iterate over a type parameter's bounded traits and any supertraits
0 commit comments