mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 06:22:00 +00:00
parent
e8d170beae
commit
de4b383a0f
@ -1842,7 +1842,15 @@ fn check_expr_with_unifier(fcx: &@fn_ctxt, expr: &@ast::expr,
|
||||
ty_to_str(tcx, oper_t)));
|
||||
}
|
||||
}
|
||||
_ { oper_t = do_autoderef(fcx, expr.span, oper_t); }
|
||||
ast::neg. {
|
||||
oper_t = structurally_resolved_type
|
||||
(fcx, oper.span, do_autoderef(fcx, expr.span, oper_t));
|
||||
if !(ty::type_is_integral(tcx, oper_t) ||
|
||||
ty::type_is_fp(tcx, oper_t)) {
|
||||
tcx.sess.span_fatal(expr.span, "applying unary minus to \
|
||||
non-numeric type " + ty_to_str(tcx, oper_t));
|
||||
}
|
||||
}
|
||||
}
|
||||
write::ty_only_fixup(fcx, id, oper_t);
|
||||
}
|
||||
|
5
src/test/compile-fail/minus-string.rs
Normal file
5
src/test/compile-fail/minus-string.rs
Normal file
@ -0,0 +1,5 @@
|
||||
// error-pattern:applying unary minus to non-numeric type str
|
||||
|
||||
fn main() {
|
||||
-"foo";
|
||||
}
|
Loading…
Reference in New Issue
Block a user