diff options
| author | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-10-03 16:34:14 -0700 |
|---|---|---|
| committer | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-10-03 16:34:36 -0700 |
| commit | 53906bb4fb9b2a99878fc6a5cc5cc174ffdea25c (patch) | |
| tree | 5e323144cacb2e867a1b9170876b5aceaa65a323 /src/rustc | |
| parent | a1ab0cd6a836a762632ebb67027d5fd9f349681d (diff) | |
| download | rust-53906bb4fb9b2a99878fc6a5cc5cc174ffdea25c.tar.gz rust-53906bb4fb9b2a99878fc6a5cc5cc174ffdea25c.zip | |
Change default mode for fns to be by-copy, except for fn&
Diffstat (limited to 'src/rustc')
| -rw-r--r-- | src/rustc/middle/ty.rs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/rustc/middle/ty.rs b/src/rustc/middle/ty.rs index 5afc60f58ac..109db9ace09 100644 --- a/src/rustc/middle/ty.rs +++ b/src/rustc/middle/ty.rs @@ -1093,12 +1093,15 @@ pure fn mach_sty(cfg: @session::config, t: t) -> sty { } fn default_arg_mode_for_ty(tcx: ctxt, ty: ty::t) -> ast::rmode { - return if type_is_fn(ty) { - // ^^^^^^^^^^^^^^ - // FIXME(#2202) --- We retain by-ref by default to workaround a memory - // leak that otherwise results when @fn is upcast to &fn. - ast::by_ref - } else if tcx.legacy_modes { + // FIXME(#2202) --- We retain by-ref for fn& things to workaround a + // memory leak that otherwise results when @fn is upcast to &fn. + if type_is_fn(ty) { + match ty_fn_proto(ty) { + proto_vstore(vstore_slice(_)) => return ast::by_ref, + _ => () + } + } + return if tcx.legacy_modes { if type_is_borrowed(ty) { // the old mode default was ++ for things like &ptr, but to be // forward-compatible with non-legacy, we should use + |
