Skip to content

Commit 53906bb

Browse files
committed
Change default mode for fns to be by-copy, except for fn&
1 parent a1ab0cd commit 53906bb

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/rustc/middle/ty.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,12 +1093,15 @@ pure fn mach_sty(cfg: @session::config, t: t) -> sty {
10931093
}
10941094

10951095
fn default_arg_mode_for_ty(tcx: ctxt, ty: ty::t) -> ast::rmode {
1096-
return if type_is_fn(ty) {
1097-
// ^^^^^^^^^^^^^^
1098-
// FIXME(#2202) --- We retain by-ref by default to workaround a memory
1099-
// leak that otherwise results when @fn is upcast to &fn.
1100-
ast::by_ref
1101-
} else if tcx.legacy_modes {
1096+
// FIXME(#2202) --- We retain by-ref for fn& things to workaround a
1097+
// memory leak that otherwise results when @fn is upcast to &fn.
1098+
if type_is_fn(ty) {
1099+
match ty_fn_proto(ty) {
1100+
proto_vstore(vstore_slice(_)) => return ast::by_ref,
1101+
_ => ()
1102+
}
1103+
}
1104+
return if tcx.legacy_modes {
11021105
if type_is_borrowed(ty) {
11031106
// the old mode default was ++ for things like &ptr, but to be
11041107
// forward-compatible with non-legacy, we should use +

0 commit comments

Comments
 (0)