Skip to content

Commit

Permalink
Rollup merge of rust-lang#26778 - jawline:master, r=pnkfelix
Browse files Browse the repository at this point in the history
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
  • Loading branch information
steveklabnik committed Jul 21, 2015
2 parents 5dbddfb + affbc72 commit e7b6e01
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/librustc/middle/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use metadata::csearch;
use middle;
use middle::cast;
use middle::check_const;
use middle::const_eval::{self, ConstVal};
use middle::const_eval::{self, ConstVal, ErrKind};
use middle::def::{self, DefMap, ExportMap};
use middle::dependency_format;
use middle::fast_reject;
Expand Down Expand Up @@ -6098,20 +6098,20 @@ impl<'tcx> ctxt<'tcx> {
found);
}
Err(err) => {
let err_description = err.description();
let found = match count_expr.node {
let err_msg = match count_expr.node {
ast::ExprPath(None, ast::Path {
global: false,
ref segments,
..
}) if segments.len() == 1 =>
format!("{}", "found variable"),
_ =>
format!("but {}", err_description),
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, {}",
found);
"expected constant integer for repeat count, {}", err_msg);
}
}
0
Expand Down

0 comments on commit e7b6e01

Please sign in to comment.