Skip to content

Commit 08f9001

Browse files
committed
Rollup merge of rust-lang#26778 - jawline:master, r=pnkfelix
Print the error message and then what is expected by the repeat count so the output makes more sense when there is an error in the const expression
2 parents d33cab1 + affbc72 commit 08f9001

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/librustc/middle/ty.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use metadata::csearch;
4444
use middle;
4545
use middle::cast;
4646
use middle::check_const;
47-
use middle::const_eval::{self, ConstVal};
47+
use middle::const_eval::{self, ConstVal, ErrKind};
4848
use middle::def::{self, DefMap, ExportMap};
4949
use middle::dependency_format;
5050
use middle::fast_reject;
@@ -6098,20 +6098,20 @@ impl<'tcx> ctxt<'tcx> {
60986098
found);
60996099
}
61006100
Err(err) => {
6101-
let err_description = err.description();
6102-
let found = match count_expr.node {
6101+
let err_msg = match count_expr.node {
61036102
ast::ExprPath(None, ast::Path {
61046103
global: false,
61056104
ref segments,
61066105
..
61076106
}) if segments.len() == 1 =>
6108-
format!("{}", "found variable"),
6109-
_ =>
6110-
format!("but {}", err_description),
6107+
format!("found variable"),
6108+
_ => match err.kind {
6109+
ErrKind::MiscCatchAll => format!("but found {}", err.description()),
6110+
_ => format!("but {}", err.description())
6111+
}
61116112
};
61126113
span_err!(self.sess, count_expr.span, E0307,
6113-
"expected constant integer for repeat count, {}",
6114-
found);
6114+
"expected constant integer for repeat count, {}", err_msg);
61156115
}
61166116
}
61176117
0

0 commit comments

Comments
 (0)