Auto merge of #45033 - eddyb:capture-me-not, r=nikomatsakis

rustc_trans: do not set NoCapture for anonymous lifetime &T arguments.

This was both unsound (due to lifetime elision & unsafe code) and dead code (we erase lifetimes).

r? @nikomatsakis
This commit is contained in:
bors 2017-10-09 00:18:51 +00:00
commit 97554e4b28

View File

@ -751,9 +751,7 @@ impl<'a, 'tcx> FnType<'tcx> {
Some(ty.boxed_ty())
}
ty::TyRef(b, mt) => {
use rustc::ty::{BrAnon, ReLateBound};
ty::TyRef(_, mt) => {
// `&mut` pointer parameters never alias other parameters, or mutable global data
//
// `&T` where `T` contains no `UnsafeCell<U>` is immutable, and can be marked as
@ -779,13 +777,6 @@ impl<'a, 'tcx> FnType<'tcx> {
arg.attrs.set(ArgAttribute::ReadOnly);
}
// When a reference in an argument has no named lifetime, it's
// impossible for that reference to escape this function
// (returned or stored beyond the call by a closure).
if let ReLateBound(_, BrAnon(_)) = *b {
arg.attrs.set(ArgAttribute::NoCapture);
}
Some(mt.ty)
}
_ => None