From 3bc42d5661d7e41885ef192bc2f4a5b8410a79f2 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Sun, 3 Jun 2012 07:34:10 -0700 Subject: [PATCH] distinguish by-val passes of pointer and non-pointer things --- src/rustc/middle/borrowck/gather_loans.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/rustc/middle/borrowck/gather_loans.rs b/src/rustc/middle/borrowck/gather_loans.rs index df16a50f8ff0..373488e55470 100644 --- a/src/rustc/middle/borrowck/gather_loans.rs +++ b/src/rustc/middle/borrowck/gather_loans.rs @@ -84,6 +84,12 @@ fn req_loans_in_expr(ex: @ast::expr, // the pointer to be borrowed as immutable even if it // is mutable in the caller's frame, thus effectively // passing the buck onto us to enforce this) + // + // FIXME---this handling is not really adequate. For + // example, if there is a type like, {f: [int]}, we + // will ignore it, but we ought to be requiring it to + // be immutable (whereas something like {f:int} would + // be fine). alt opt_deref_kind(arg_ty.ty) { some(deref_ptr(region_ptr)) | @@ -91,10 +97,11 @@ fn req_loans_in_expr(ex: @ast::expr, /* region pointers are (by induction) guaranteed */ /* unsafe pointers are the user's problem */ } + some(deref_comp(_)) | none { /* not a pointer, no worries */ } - some(_) { + some(deref_ptr(_)) { let arg_cmt = self.bccx.cat_borrow_of_expr(arg); self.guarantee_valid(arg_cmt, m_const, scope_r); }