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

This commit is contained in:
Eduard-Mihai Burtescu 2017-10-05 01:02:25 +03:00
parent 417ffc98df
commit ac25a4ac32

View File

@ -750,9 +750,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
@ -768,13 +766,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