mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-15 01:55:03 +00:00
ty.rs improve error feedback when const-eval errs during repeat count eval.
This commit is contained in:
parent
2f7658a528
commit
7875dae83f
@ -6047,19 +6047,20 @@ pub fn eval_repeat_count(tcx: &ctxt, count_expr: &ast::Expr) -> usize {
|
||||
"expected positive integer for repeat count, found {}",
|
||||
found);
|
||||
}
|
||||
Err(_) => {
|
||||
Err(err) => {
|
||||
let err_description = err.description();
|
||||
let found = match count_expr.node {
|
||||
ast::ExprPath(None, ast::Path {
|
||||
global: false,
|
||||
ref segments,
|
||||
..
|
||||
}) if segments.len() == 1 =>
|
||||
"variable",
|
||||
format!("{}", "found variable"),
|
||||
_ =>
|
||||
"non-constant expression"
|
||||
format!("but {}", err_description),
|
||||
};
|
||||
span_err!(tcx.sess, count_expr.span, E0307,
|
||||
"expected constant integer for repeat count, found {}",
|
||||
"expected constant integer for repeat count, {}",
|
||||
found);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user