Change default mode for fns to be by-copy, except for fn&
This commit is contained in:
parent
a1ab0cd6a8
commit
53906bb4fb
1 changed files with 9 additions and 6 deletions
|
@ -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 {
|
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 for fn& things to workaround a
|
||||||
// ^^^^^^^^^^^^^^
|
// memory leak that otherwise results when @fn is upcast to &fn.
|
||||||
// FIXME(#2202) --- We retain by-ref by default to workaround a memory
|
if type_is_fn(ty) {
|
||||||
// leak that otherwise results when @fn is upcast to &fn.
|
match ty_fn_proto(ty) {
|
||||||
ast::by_ref
|
proto_vstore(vstore_slice(_)) => return ast::by_ref,
|
||||||
} else if tcx.legacy_modes {
|
_ => ()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return if tcx.legacy_modes {
|
||||||
if type_is_borrowed(ty) {
|
if type_is_borrowed(ty) {
|
||||||
// the old mode default was ++ for things like &ptr, but to be
|
// the old mode default was ++ for things like &ptr, but to be
|
||||||
// forward-compatible with non-legacy, we should use +
|
// forward-compatible with non-legacy, we should use +
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue