Skip to content

Commit 14cef9f

Browse files
committed
---
yaml --- r: 24011 b: refs/heads/master c: 53abb5e h: refs/heads/master i: 24009: 49e27cd 24007: eb78e7e v: v3
1 parent 37cc1d9 commit 14cef9f

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 8d4928f7808813de62fefcb89139bfb7382b250b
2+
refs/heads/master: 53abb5edbd2079fdcc1c2887cf0a89aad75d6ea1
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be

trunk/src/rustc/middle/ty.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,12 +1090,22 @@ pure fn mach_sty(cfg: @session::config, t: t) -> sty {
10901090
}
10911091

10921092
fn default_arg_mode_for_ty(tcx: ctxt, ty: ty::t) -> ast::rmode {
1093-
if ty::type_is_immediate(ty) {
1093+
return if ty::type_is_immediate(ty) {
10941094
ast::by_val
1095-
} else if tcx.legacy_modes {
1095+
} else if tcx.legacy_modes || type_is_fn(ty) {
1096+
// ^^^^^^^^^^^^^^
1097+
// FIXME(#2202) --- We retain by-ref by default to workaround a memory
1098+
// leak that otherwise results when @fn is upcast to &fn.
10961099
ast::by_ref
10971100
} else {
10981101
ast::by_copy
1102+
};
1103+
1104+
fn type_is_fn(ty: t) -> bool {
1105+
match get(ty).sty {
1106+
ty_fn(*) => true,
1107+
_ => false
1108+
}
10991109
}
11001110
}
11011111

0 commit comments

Comments
 (0)