Skip to content

Commit 7875dae

Browse files
committed
ty.rs improve error feedback when const-eval errs during repeat count eval.
1 parent 2f7658a commit 7875dae

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/librustc/middle/ty.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6047,19 +6047,20 @@ pub fn eval_repeat_count(tcx: &ctxt, count_expr: &ast::Expr) -> usize {
60476047
"expected positive integer for repeat count, found {}",
60486048
found);
60496049
}
6050-
Err(_) => {
6050+
Err(err) => {
6051+
let err_description = err.description();
60516052
let found = match count_expr.node {
60526053
ast::ExprPath(None, ast::Path {
60536054
global: false,
60546055
ref segments,
60556056
..
60566057
}) if segments.len() == 1 =>
6057-
"variable",
6058+
format!("{}", "found variable"),
60586059
_ =>
6059-
"non-constant expression"
6060+
format!("but {}", err_description),
60606061
};
60616062
span_err!(tcx.sess, count_expr.span, E0307,
6062-
"expected constant integer for repeat count, found {}",
6063+
"expected constant integer for repeat count, {}",
60636064
found);
60646065
}
60656066
}

0 commit comments

Comments
 (0)