// Returns the repeat count for a repeating vector expression.
Returns the repeat count for a repeating vector expression.
Returns the repeat count for a repeating vector expression .
pub fn eval_repeat_count(&self, count_expr: &hir::Expr) -> usize {
        let hint = UncheckedExprHint(self.types.usize);
        match const_eval::eval_const_expr_partial(self, count_expr, hint) {
            Ok(val) => {
                let found = match val {
                    ConstVal::Uint(count) => return count as usize,
                    ConstVal::Int(count) if count >= 0 => return count as usize,
                    const_val => const_val.description(),
                };
                span_err!(self.sess, count_expr.span, E0306,
                    "expected positive integer for repeat count, found {}",
                    found);
            }
            Err(err) => {
                let err_msg = match count_expr.node {
                    hir::ExprPath(None, hir::Path {
                        global: false,
                        ref segments,
                        ..
                    }) if segments.len() == 1 =>
                        format!("found variable"),
                    _ => match err.kind {
                        ErrKind::MiscCatchAll => format!("but found {}", err.description()),
                        _ => format!("but {}", err.description())
                    }
                };
                span_err!(self.sess, count_expr.span, E0307,
                    "expected constant integer for repeat count, {}", err_msg);
            }
        }
        0
    }
pub fn eval_repeat_count ( & self , count_expr : & hir :: Expr ) -> usize { let hint = UncheckedExprHint ( self . types . usize ) ; match const_eval :: eval_const_expr_partial ( self , count_expr , hint ) { Ok ( val ) => { let found = match val { ConstVal :: Uint ( count ) => return count as usize , ConstVal :: Int ( count ) if count >= 0 => return count as usize , const_val => const_val . description ( ) , } ; span_err ! ( self sess count_expr span E0306 " " found ) ; } Err ( err ) => { let err_msg = match count_expr . node { hir :: ExprPath ( None , hir :: Path { global : false , ref segments , .. } ) if segments . len ( ) == 1 => format ! ( " " ) , _ => match err . kind { ErrKind :: MiscCatchAll => format ! ( " " err description ( ) ) , _ => format ! ( " " err description ( ) ) } } ; span_err ! ( self sess count_expr span E0307 " " err_msg ) ; } } 0 }
Returns the repeat count for a repeating vector expression.
Returns the repeat count for a repeating vector expression .
&self
count_expr
&hir::Expr