提交 97554e4b 编写于 作者: B bors

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
......@@ -751,9 +751,7 @@ pub fn unadjusted(ccx: &CrateContext<'a, '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 @@ pub fn unadjusted(ccx: &CrateContext<'a, '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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册