提交 f2df1857 编写于 作者: M Michael Woerister

Mark closures return via impl-trait as reachable.

上级 bae4fafd
......@@ -296,6 +296,9 @@ fn propagate_node(&mut self, node: &hir_map::Node<'tcx>,
hir::ImplItemKind::Type(_) => {}
}
}
hir_map::NodeExpr(&hir::Expr { node: hir::ExprClosure(.., body, _), .. }) => {
self.visit_nested_body(body);
}
// Nothing to recurse on for these
hir_map::NodeForeignItem(_) |
hir_map::NodeVariant(_) |
......
......@@ -448,6 +448,7 @@ fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool {
ty::TyDynamic(ref obj, ..) => obj.principal().map(|p| p.def_id()),
ty::TyProjection(ref proj) => Some(proj.item_def_id),
ty::TyFnDef(def_id, ..) |
ty::TyClosure(def_id, ..) |
ty::TyAnon(def_id, _) => Some(def_id),
_ => None
};
......
......@@ -13,3 +13,14 @@
pub fn fourway_add(a: i32) -> impl Fn(i32) -> impl Fn(i32) -> impl Fn(i32) -> i32 {
move |b| move |c| move |d| a + b + c + d
}
fn some_internal_fn() -> u32 {
1
}
// See #40839
pub fn return_closure_accessing_internal_fn() -> impl Fn() -> u32 {
|| {
some_internal_fn() + 1
}
}
......@@ -14,4 +14,5 @@
fn main() {
assert_eq!(xcrate::fourway_add(1)(2)(3)(4), 10);
xcrate::return_closure_accessing_internal_fn()();
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册