Rollup merge of #115765 - asquared31415:cast_diag, r=WaffleLapkin
Add source type for invalid bool casts Also adds tests for casting various types to `bool` that were otherwise untested. r? `@WaffleLapkin`
This commit is contained in:
commit
32cf2c4b68
8 changed files with 103 additions and 14 deletions
|
@ -321,8 +321,13 @@ impl<'a, 'tcx> CastCheck<'tcx> {
|
|||
.emit();
|
||||
}
|
||||
CastError::CastToBool => {
|
||||
let mut err =
|
||||
struct_span_err!(fcx.tcx.sess, self.span, E0054, "cannot cast as `bool`");
|
||||
let mut err = struct_span_err!(
|
||||
fcx.tcx.sess,
|
||||
self.span,
|
||||
E0054,
|
||||
"cannot cast `{}` as `bool`",
|
||||
self.expr_ty
|
||||
);
|
||||
|
||||
if self.expr_ty.is_numeric() {
|
||||
match fcx.tcx.sess.source_map().span_to_snippet(self.expr_span) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue