about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDavid Wood <david@davidtw.co>2018-07-20 12:32:58 +0100
committerDavid Wood <david@davidtw.co>2018-07-22 12:23:53 +0100
commit24c5751197f4971c7f7e387c035cac3565f2f629 (patch)
tree7c21f3a2fe43c61c5eda4da6b4d2081b1a9ae550
parentaeca042f8464a98e1821756849f062eeede71e28 (diff)
downloadrust-24c5751197f4971c7f7e387c035cac3565f2f629.tar.gz
rust-24c5751197f4971c7f7e387c035cac3565f2f629.zip
Classify aggregate rvalues as assignments.
-rw-r--r--src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs8
-rw-r--r--src/test/ui/borrowck/issue-45983.nll.stderr2
-rw-r--r--src/test/ui/borrowck/regions-escape-bound-fn-2.nll.stderr2
-rw-r--r--src/test/ui/borrowck/regions-escape-bound-fn.nll.stderr2
-rw-r--r--src/test/ui/borrowck/regions-escape-unboxed-closure.nll.stderr2
-rw-r--r--src/test/ui/closure-expected-type/expect-region-supply-region.nll.stderr6
6 files changed, 14 insertions, 8 deletions
diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs
index c1b73fac893..9b478cd85bb 100644
--- a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs
+++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs
@@ -132,6 +132,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
         mir: &Mir<'tcx>,
     ) -> (ConstraintCategory, Span) {
         let constraint = self.constraints[index];
+        debug!("classify_constraint: constraint={:?}", constraint);
         let span = constraint.locations.span(mir);
         let location = constraint.locations.from_location().unwrap_or(Location::START);
 
@@ -140,8 +141,10 @@ impl<'tcx> RegionInferenceContext<'tcx> {
         }
 
         let data = &mir[location.block];
+        debug!("classify_constraint: location={:?} data={:?}", location, data);
         let category = if location.statement_index == data.statements.len() {
             if let Some(ref terminator) = data.terminator {
+                debug!("classify_constraint: terminator.kind={:?}", terminator.kind);
                 match terminator.kind {
                     TerminatorKind::DropAndReplace { .. } => ConstraintCategory::Assignment,
                     TerminatorKind::Call { .. } => ConstraintCategory::CallArgument,
@@ -152,14 +155,17 @@ impl<'tcx> RegionInferenceContext<'tcx> {
             }
         } else {
             let statement = &data.statements[location.statement_index];
+            debug!("classify_constraint: statement.kind={:?}", statement.kind);
             match statement.kind {
                 StatementKind::Assign(ref place, ref rvalue) => {
+                    debug!("classify_constraint: place={:?} rvalue={:?}", place, rvalue);
                     if *place == Place::Local(mir::RETURN_PLACE) {
                         ConstraintCategory::Return
                     } else {
                         match rvalue {
                             Rvalue::Cast(..) => ConstraintCategory::Cast,
-                            Rvalue::Use(..) => ConstraintCategory::Assignment,
+                            Rvalue::Use(..) |
+                            Rvalue::Aggregate(..) => ConstraintCategory::Assignment,
                             _ => ConstraintCategory::Other,
                         }
                     }
diff --git a/src/test/ui/borrowck/issue-45983.nll.stderr b/src/test/ui/borrowck/issue-45983.nll.stderr
index 5a1f1986fcf..4edec568737 100644
--- a/src/test/ui/borrowck/issue-45983.nll.stderr
+++ b/src/test/ui/borrowck/issue-45983.nll.stderr
@@ -10,7 +10,7 @@ error: unsatisfied lifetime constraints
 LL |     let x = None;
    |         - lifetime `'2` appears in the type of `x`
 LL |     give_any(|y| x = Some(y));
-   |               -  ^^^^^^^^^^^ free region requires that `'1` must outlive `'2`
+   |               -  ^^^^^^^^^^^ assignment requires that `'1` must outlive `'2`
    |               |
    |               lifetime `'1` appears in this argument
 
diff --git a/src/test/ui/borrowck/regions-escape-bound-fn-2.nll.stderr b/src/test/ui/borrowck/regions-escape-bound-fn-2.nll.stderr
index 4f7843b7248..a162d9ea7f1 100644
--- a/src/test/ui/borrowck/regions-escape-bound-fn-2.nll.stderr
+++ b/src/test/ui/borrowck/regions-escape-bound-fn-2.nll.stderr
@@ -10,7 +10,7 @@ error: unsatisfied lifetime constraints
 LL |     let mut x = None;
    |         ----- lifetime `'2` appears in the type of `x`
 LL |     with_int(|y| x = Some(y));
-   |               -  ^^^^^^^^^^^ free region requires that `'1` must outlive `'2`
+   |               -  ^^^^^^^^^^^ assignment requires that `'1` must outlive `'2`
    |               |
    |               lifetime `'1` appears in this argument
 
diff --git a/src/test/ui/borrowck/regions-escape-bound-fn.nll.stderr b/src/test/ui/borrowck/regions-escape-bound-fn.nll.stderr
index 9b107ae08b4..af5db0e3ff6 100644
--- a/src/test/ui/borrowck/regions-escape-bound-fn.nll.stderr
+++ b/src/test/ui/borrowck/regions-escape-bound-fn.nll.stderr
@@ -10,7 +10,7 @@ error: unsatisfied lifetime constraints
 LL |     let mut x: Option<&isize> = None;
    |         ----- lifetime `'2` appears in the type of `x`
 LL |     with_int(|y| x = Some(y));
-   |               -  ^^^^^^^^^^^ free region requires that `'1` must outlive `'2`
+   |               -  ^^^^^^^^^^^ assignment requires that `'1` must outlive `'2`
    |               |
    |               lifetime `'1` appears in this argument
 
diff --git a/src/test/ui/borrowck/regions-escape-unboxed-closure.nll.stderr b/src/test/ui/borrowck/regions-escape-unboxed-closure.nll.stderr
index 8095330154d..df93a1204b2 100644
--- a/src/test/ui/borrowck/regions-escape-unboxed-closure.nll.stderr
+++ b/src/test/ui/borrowck/regions-escape-unboxed-closure.nll.stderr
@@ -10,7 +10,7 @@ error: unsatisfied lifetime constraints
 LL |     let mut x: Option<&isize> = None;
    |         ----- lifetime `'2` appears in the type of `x`
 LL |     with_int(&mut |y| x = Some(y));
-   |                    -  ^^^^^^^^^^^ free region requires that `'1` must outlive `'2`
+   |                    -  ^^^^^^^^^^^ assignment requires that `'1` must outlive `'2`
    |                    |
    |                    lifetime `'1` appears in this argument
 
diff --git a/src/test/ui/closure-expected-type/expect-region-supply-region.nll.stderr b/src/test/ui/closure-expected-type/expect-region-supply-region.nll.stderr
index c8c8ef8215a..1559b35c446 100644
--- a/src/test/ui/closure-expected-type/expect-region-supply-region.nll.stderr
+++ b/src/test/ui/closure-expected-type/expect-region-supply-region.nll.stderr
@@ -30,7 +30,7 @@ LL |     let mut f: Option<&u32> = None;
 LL |     closure_expecting_bound(|x| {
    |                              - lifetime `'1` appears in this argument
 LL |         f = Some(x); //~ ERROR borrowed data cannot be stored outside of its closure
-   |         ^^^^^^^^^^^ free region requires that `'1` must outlive `'2`
+   |         ^^^^^^^^^^^ assignment requires that `'1` must outlive `'2`
 
 error: unsatisfied lifetime constraints
   --> $DIR/expect-region-supply-region.rs:38:9
@@ -40,7 +40,7 @@ LL |     let mut f: Option<&u32> = None;
 LL |     closure_expecting_bound(|x: &u32| {
    |                                 - let's call the lifetime of this reference `'1`
 LL |         f = Some(x); //~ ERROR borrowed data cannot be stored outside of its closure
-   |         ^^^^^^^^^^^ free region requires that `'1` must outlive `'2`
+   |         ^^^^^^^^^^^ assignment requires that `'1` must outlive `'2`
 
 error: unsatisfied lifetime constraints
   --> $DIR/expect-region-supply-region.rs:52:9
@@ -52,7 +52,7 @@ LL |     closure_expecting_bound(|x: &'x u32| {
    |                                 - let's call the lifetime of this reference `'1`
 ...
 LL |         f = Some(x);
-   |         ^^^^^^^^^^^ free region requires that `'1` must outlive `'2`
+   |         ^^^^^^^^^^^ assignment requires that `'1` must outlive `'2`
 
 error: aborting due to 3 previous errors