]> git.lizzy.rs Git - rust.git/commitdiff
Extend temporary lifetimes if there is a ref in an enum binding
authorNiko Matsakis <niko@alum.mit.edu>
Fri, 17 Jan 2014 13:10:42 +0000 (08:10 -0500)
committerNiko Matsakis <niko@alum.mit.edu>
Fri, 17 Jan 2014 13:10:42 +0000 (08:10 -0500)
too.

Previously I had omitted this case since function calls don't get the same
treatment on the RHS, but it's different on the pattern and is more consistent
-- the goal is to identify `let` statements where `ref` bindings create
interior pointers.

src/librustc/middle/region.rs

index a224a90a6a440f311b8ce94b257fce95fa7bc41b..c202684c7abff850b8bda193579a63158132bd70 100644 (file)
@@ -637,6 +637,7 @@ fn is_binding_pat(pat: &ast::Pat) -> bool {
          *
          *     P& = ref X
          *        | StructName { ..., P&, ... }
+         *        | VariantName(..., P&, ...)
          *        | [ ..., P&, ... ]
          *        | ( ..., P&, ... )
          *        | ~P&
@@ -656,6 +657,7 @@ fn is_binding_pat(pat: &ast::Pat) -> bool {
                 pats3.iter().any(|&p| is_binding_pat(p))
             }
 
+            ast::PatEnum(_, Some(ref subpats)) |
             ast::PatTup(ref subpats) => {
                 subpats.iter().any(|&p| is_binding_pat(p))
             }