Skip to content

Commit d12130b

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 90a3692 + affbc72 commit d12130b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/librustc/middle/ty.rs

Lines changed: 8 additions & 8 deletions
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;
@@ -6104,20 +6104,20 @@ impl<'tcx> ctxt<'tcx> {
61046104
found);
61056105
}
61066106
Err(err) => {
6107-
let err_description = err.description();
6108-
let found = match count_expr.node {
6107+
let err_msg = match count_expr.node {
61096108
ast::ExprPath(None, ast::Path {
61106109
global: false,
61116110
ref segments,
61126111
..
61136112
}) if segments.len() == 1 =>
6114-
format!("{}", "found variable"),
6115-
_ =>
6116-
format!("but {}", err_description),
6113+
format!("found variable"),
6114+
_ => match err.kind {
6115+
ErrKind::MiscCatchAll => format!("but found {}", err.description()),
6116+
_ => format!("but {}", err.description())
6117+
}
61176118
};
61186119
span_err!(self.sess, count_expr.span, E0307,
6119-
"expected constant integer for repeat count, {}",
6120-
found);
6120+
"expected constant integer for repeat count, {}", err_msg);
61216121
}
61226122
}
61236123
0

0 commit comments

Comments
 (0)