From 3cc2641fc389dcdf8b348c1a9dbc6dfe48c5547a Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sun, 13 Nov 2011 13:55:08 -0800 Subject: [PATCH] Make various binops not typecheck for unsafe pointers. Closes #1173 --- src/comp/middle/ty.rs | 1 - src/test/compile-fail/binop-add-ptr.rs | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 src/test/compile-fail/binop-add-ptr.rs diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs index d20544e48e8..bae7f84d4ae 100644 --- a/src/comp/middle/ty.rs +++ b/src/comp/middle/ty.rs @@ -2902,7 +2902,6 @@ fn is_binopable(cx: ctxt, ty: t, op: ast::binop) -> bool { ty_machine(ast::ty_f32.) { tycat_float } ty_machine(ast::ty_f64.) { tycat_float } ty_char. { tycat_int } - ty_ptr(_) { tycat_int } ty_str. { tycat_str } ty_vec(_) { tycat_vec } ty_rec(_) { tycat_struct } diff --git a/src/test/compile-fail/binop-add-ptr.rs b/src/test/compile-fail/binop-add-ptr.rs new file mode 100644 index 00000000000..e21f6a97fc2 --- /dev/null +++ b/src/test/compile-fail/binop-add-ptr.rs @@ -0,0 +1,4 @@ +// error-pattern:binary operation + cannot be applied to type `*i` + +fn die() -> *int { (0 as *int) + (0 as *int) } +fn main() { } \ No newline at end of file