From e10aa1586d49f5fce47cf46a3aaa00a95a50286d Mon Sep 17 00:00:00 2001 From: marmeladema Date: Tue, 19 Apr 2022 12:56:18 +0200 Subject: Use revisions instead of nll compare mode for `/regions/` ui tests --- src/test/ui/regions/issue-28848.base.stderr | 20 +++++ src/test/ui/regions/issue-28848.nll.stderr | 2 +- src/test/ui/regions/issue-28848.rs | 8 +- src/test/ui/regions/issue-28848.stderr | 20 ----- ...on-invariant-static-error-reporting.base.stderr | 25 ++++++ ...ion-invariant-static-error-reporting.nll.stderr | 2 +- .../region-invariant-static-error-reporting.rs | 12 ++- .../region-invariant-static-error-reporting.stderr | 25 ------ ...lifetime-bounds-on-fns-where-clause.base.stderr | 31 +++++++ ...-lifetime-bounds-on-fns-where-clause.nll.stderr | 8 +- .../region-lifetime-bounds-on-fns-where-clause.rs | 16 +++- ...gion-lifetime-bounds-on-fns-where-clause.stderr | 31 ------- ...lifetime-bounds-on-fns-where-clause.base.stderr | 42 ++++++++++ ...-lifetime-bounds-on-fns-where-clause.nll.stderr | 10 +-- ...time-bounds-on-fns-where-clause.polonius.stderr | 82 ------------------ ...multiple-lifetime-bounds-on-fns-where-clause.rs | 19 ++++- ...iple-lifetime-bounds-on-fns-where-clause.stderr | 42 ---------- .../regions/region-object-lifetime-2.base.stderr | 30 +++++++ .../ui/regions/region-object-lifetime-2.nll.stderr | 2 +- src/test/ui/regions/region-object-lifetime-2.rs | 8 +- .../ui/regions/region-object-lifetime-2.stderr | 30 ------- .../regions/region-object-lifetime-4.base.stderr | 30 +++++++ .../ui/regions/region-object-lifetime-4.nll.stderr | 2 +- src/test/ui/regions/region-object-lifetime-4.rs | 8 +- .../ui/regions/region-object-lifetime-4.stderr | 30 ------- .../region-object-lifetime-in-coercion.base.stderr | 98 ++++++++++++++++++++++ .../region-object-lifetime-in-coercion.nll.stderr | 8 +- .../regions/region-object-lifetime-in-coercion.rs | 20 ++++- .../region-object-lifetime-in-coercion.stderr | 98 ---------------------- .../ui/regions/regions-addr-of-self.base.stderr | 11 +++ .../ui/regions/regions-addr-of-self.nll.stderr | 2 +- src/test/ui/regions/regions-addr-of-self.rs | 8 +- src/test/ui/regions/regions-addr-of-self.stderr | 11 --- .../regions/regions-addr-of-upvar-self.base.stderr | 26 ++++++ .../regions/regions-addr-of-upvar-self.nll.stderr | 6 +- src/test/ui/regions/regions-addr-of-upvar-self.rs | 10 ++- .../ui/regions/regions-addr-of-upvar-self.stderr | 26 ------ ...s-bounded-by-trait-requiring-static.base.stderr | 75 +++++++++++++++++ ...ns-bounded-by-trait-requiring-static.nll.stderr | 12 +-- .../regions-bounded-by-trait-requiring-static.rs | 28 +++++-- ...egions-bounded-by-trait-requiring-static.stderr | 75 ----------------- ...-method-type-parameters-cross-crate.base.stderr | 12 +++ ...d-method-type-parameters-cross-crate.nll.stderr | 2 +- ...s-bounded-method-type-parameters-cross-crate.rs | 7 +- ...unded-method-type-parameters-cross-crate.stderr | 12 --- ...-method-type-parameters-trait-bound.base.stderr | 12 +++ ...d-method-type-parameters-trait-bound.nll.stderr | 2 +- ...s-bounded-method-type-parameters-trait-bound.rs | 8 +- ...unded-method-type-parameters-trait-bound.stderr | 12 --- ...ions-bounded-method-type-parameters.base.stderr | 15 ++++ ...gions-bounded-method-type-parameters.nll.stderr | 2 +- .../regions-bounded-method-type-parameters.rs | 7 +- .../regions-bounded-method-type-parameters.stderr | 15 ---- src/test/ui/regions/regions-bounds.base.stderr | 41 +++++++++ src/test/ui/regions/regions-bounds.nll.stderr | 4 +- src/test/ui/regions/regions-bounds.rs | 12 ++- src/test/ui/regions/regions-bounds.stderr | 41 --------- ...s-close-associated-type-into-object.base.stderr | 40 +++++++++ ...ns-close-associated-type-into-object.nll.stderr | 8 +- .../regions-close-associated-type-into-object.rs | 4 + ...egions-close-associated-type-into-object.stderr | 40 --------- .../regions-close-object-into-object-2.base.stderr | 27 ++++++ .../regions-close-object-into-object-2.nll.stderr | 4 +- .../regions/regions-close-object-into-object-2.rs | 9 +- .../regions-close-object-into-object-2.stderr | 27 ------ .../regions-close-object-into-object-4.base.stderr | 27 ++++++ .../regions-close-object-into-object-4.nll.stderr | 12 +-- .../regions/regions-close-object-into-object-4.rs | 14 +++- .../regions-close-object-into-object-4.stderr | 27 ------ .../regions-close-object-into-object-5.base.stderr | 84 +++++++++++++++++++ .../regions-close-object-into-object-5.nll.stderr | 10 +-- .../regions/regions-close-object-into-object-5.rs | 11 ++- .../regions-close-object-into-object-5.stderr | 84 ------------------- ...regions-close-over-type-parameter-1.base.stderr | 20 +++++ .../regions-close-over-type-parameter-1.nll.stderr | 4 +- .../regions/regions-close-over-type-parameter-1.rs | 3 + .../regions-close-over-type-parameter-1.stderr | 20 ----- ...-close-over-type-parameter-multiple.base.stderr | 32 +++++++ ...s-close-over-type-parameter-multiple.nll.stderr | 2 +- .../regions-close-over-type-parameter-multiple.rs | 7 +- ...gions-close-over-type-parameter-multiple.stderr | 32 ------- .../regions-close-param-into-object.base.stderr | 40 +++++++++ .../regions-close-param-into-object.nll.stderr | 8 +- .../ui/regions/regions-close-param-into-object.rs | 4 + .../regions/regions-close-param-into-object.stderr | 40 --------- .../ui/regions/regions-creating-enums3.base.stderr | 13 +++ .../ui/regions/regions-creating-enums3.nll.stderr | 2 +- src/test/ui/regions/regions-creating-enums3.rs | 8 +- src/test/ui/regions/regions-creating-enums3.stderr | 13 --- .../ui/regions/regions-creating-enums4.base.stderr | 34 ++++++++ .../ui/regions/regions-creating-enums4.nll.stderr | 2 +- src/test/ui/regions/regions-creating-enums4.rs | 8 +- src/test/ui/regions/regions-creating-enums4.stderr | 34 -------- .../regions-early-bound-error-method.base.stderr | 20 +++++ .../regions-early-bound-error-method.nll.stderr | 2 +- .../ui/regions/regions-early-bound-error-method.rs | 7 +- .../regions-early-bound-error-method.stderr | 20 ----- .../regions/regions-early-bound-error.base.stderr | 20 +++++ .../regions/regions-early-bound-error.nll.stderr | 2 +- src/test/ui/regions/regions-early-bound-error.rs | 7 +- .../ui/regions/regions-early-bound-error.stderr | 20 ----- ...ons-fn-subtyping-return-static-fail.base.stderr | 12 +++ ...ions-fn-subtyping-return-static-fail.nll.stderr | 2 +- .../regions-fn-subtyping-return-static-fail.rs | 4 + .../regions-fn-subtyping-return-static-fail.stderr | 12 --- ...regions-free-region-ordering-callee.base.stderr | 25 ++++++ .../regions-free-region-ordering-callee.nll.stderr | 4 +- .../regions/regions-free-region-ordering-callee.rs | 11 ++- .../regions-free-region-ordering-callee.stderr | 25 ------ ...ions-free-region-ordering-incorrect.base.stderr | 33 ++++++++ ...gions-free-region-ordering-incorrect.nll.stderr | 2 +- .../regions-free-region-ordering-incorrect.rs | 8 +- .../regions-free-region-ordering-incorrect.stderr | 33 -------- ...ons-implied-bounds-projection-gap-1.base.stderr | 12 +++ ...ions-implied-bounds-projection-gap-1.nll.stderr | 2 +- .../regions-implied-bounds-projection-gap-1.rs | 4 + .../regions-implied-bounds-projection-gap-1.stderr | 12 --- ...regions-infer-bound-from-trait-self.base.stderr | 17 ++++ .../regions-infer-bound-from-trait-self.nll.stderr | 2 +- .../regions/regions-infer-bound-from-trait-self.rs | 4 + .../regions-infer-bound-from-trait-self.stderr | 17 ---- .../regions-infer-bound-from-trait.base.stderr | 31 +++++++ .../regions-infer-bound-from-trait.nll.stderr | 4 +- .../ui/regions/regions-infer-bound-from-trait.rs | 4 + .../regions/regions-infer-bound-from-trait.stderr | 31 ------- ...ns-infer-contravariance-due-to-decl.base.stderr | 15 ++++ ...ons-infer-contravariance-due-to-decl.nll.stderr | 2 +- .../regions-infer-contravariance-due-to-decl.rs | 8 +- ...regions-infer-contravariance-due-to-decl.stderr | 15 ---- ...egions-infer-covariance-due-to-decl.base.stderr | 14 ++++ ...regions-infer-covariance-due-to-decl.nll.stderr | 2 +- .../regions-infer-covariance-due-to-decl.rs | 8 +- .../regions-infer-covariance-due-to-decl.stderr | 14 ---- ...egions-infer-invariance-due-to-decl.base.stderr | 18 ++++ ...regions-infer-invariance-due-to-decl.nll.stderr | 2 +- .../regions-infer-invariance-due-to-decl.rs | 8 +- .../regions-infer-invariance-due-to-decl.stderr | 18 ---- ...nfer-invariance-due-to-mutability-3.base.stderr | 18 ++++ ...infer-invariance-due-to-mutability-3.nll.stderr | 2 +- ...regions-infer-invariance-due-to-mutability-3.rs | 8 +- ...ons-infer-invariance-due-to-mutability-3.stderr | 18 ---- ...nfer-invariance-due-to-mutability-4.base.stderr | 18 ++++ ...infer-invariance-due-to-mutability-4.nll.stderr | 2 +- ...regions-infer-invariance-due-to-mutability-4.rs | 8 +- ...ons-infer-invariance-due-to-mutability-4.stderr | 18 ---- .../ui/regions/regions-infer-not-param.base.stderr | 60 +++++++++++++ .../ui/regions/regions-infer-not-param.nll.stderr | 6 +- src/test/ui/regions/regions-infer-not-param.rs | 23 +++-- src/test/ui/regions/regions-infer-not-param.stderr | 60 ------------- .../regions-infer-paramd-indirect.base.stderr | 22 +++++ .../regions-infer-paramd-indirect.nll.stderr | 2 +- .../ui/regions/regions-infer-paramd-indirect.rs | 13 ++- .../regions/regions-infer-paramd-indirect.stderr | 22 ----- .../regions-lifetime-bounds-on-fns.base.stderr | 31 +++++++ .../regions-lifetime-bounds-on-fns.nll.stderr | 8 +- .../ui/regions/regions-lifetime-bounds-on-fns.rs | 16 +++- .../regions/regions-lifetime-bounds-on-fns.stderr | 31 ------- src/test/ui/regions/regions-nested-fns.base.stderr | 78 +++++++++++++++++ src/test/ui/regions/regions-nested-fns.nll.stderr | 10 +-- src/test/ui/regions/regions-nested-fns.rs | 14 +++- src/test/ui/regions/regions-nested-fns.stderr | 70 ---------------- ...gions-outlives-projection-container.base.stderr | 71 ++++++++++++++++ ...egions-outlives-projection-container.nll.stderr | 8 +- .../regions-outlives-projection-container.rs | 17 +++- .../regions-outlives-projection-container.stderr | 71 ---------------- .../regions/regions-proc-bound-capture.base.stderr | 29 +++++++ .../regions/regions-proc-bound-capture.nll.stderr | 2 +- src/test/ui/regions/regions-proc-bound-capture.rs | 8 +- .../ui/regions/regions-proc-bound-capture.stderr | 29 ------- ...borrow-from-shorter-mut-ref-mut-ref.base.stderr | 13 +++ ...eborrow-from-shorter-mut-ref-mut-ref.nll.stderr | 2 +- ...egions-reborrow-from-shorter-mut-ref-mut-ref.rs | 8 +- ...ns-reborrow-from-shorter-mut-ref-mut-ref.stderr | 13 --- ...gions-reborrow-from-shorter-mut-ref.base.stderr | 13 +++ ...egions-reborrow-from-shorter-mut-ref.nll.stderr | 2 +- .../regions-reborrow-from-shorter-mut-ref.rs | 8 +- .../regions-reborrow-from-shorter-mut-ref.stderr | 13 --- .../ui/regions/regions-ret-borrowed-1.base.stderr | 32 +++++++ .../ui/regions/regions-ret-borrowed-1.nll.stderr | 2 +- src/test/ui/regions/regions-ret-borrowed-1.rs | 7 +- src/test/ui/regions/regions-ret-borrowed-1.stderr | 32 ------- .../ui/regions/regions-ret-borrowed.base.stderr | 32 +++++++ .../ui/regions/regions-ret-borrowed.nll.stderr | 2 +- src/test/ui/regions/regions-ret-borrowed.rs | 7 +- src/test/ui/regions/regions-ret-borrowed.stderr | 32 ------- .../ui/regions/regions-static-bound.base.stderr | 46 ++++++++++ .../ui/regions/regions-static-bound.nll.stderr | 8 +- src/test/ui/regions/regions-static-bound.rs | 16 +++- src/test/ui/regions/regions-static-bound.stderr | 46 ---------- .../regions-trait-object-subtyping.base.stderr | 69 +++++++++++++++ .../regions-trait-object-subtyping.nll.stderr | 4 +- .../ui/regions/regions-trait-object-subtyping.rs | 14 +++- .../regions/regions-trait-object-subtyping.stderr | 69 --------------- ...nt-use-covariant-in-second-position.base.stderr | 12 +++ ...ant-use-covariant-in-second-position.nll.stderr | 2 +- ...ntravariant-use-covariant-in-second-position.rs | 8 +- ...variant-use-covariant-in-second-position.stderr | 12 --- ...ariance-contravariant-use-covariant.base.stderr | 15 ++++ ...variance-contravariant-use-covariant.nll.stderr | 2 +- ...regions-variance-contravariant-use-covariant.rs | 8 +- ...ons-variance-contravariant-use-covariant.stderr | 15 ---- ...ariance-covariant-use-contravariant.base.stderr | 14 ++++ ...variance-covariant-use-contravariant.nll.stderr | 2 +- ...regions-variance-covariant-use-contravariant.rs | 8 +- ...ons-variance-covariant-use-contravariant.stderr | 14 ---- ...ariance-invariant-use-contravariant.base.stderr | 14 ++++ ...variance-invariant-use-contravariant.nll.stderr | 2 +- ...regions-variance-invariant-use-contravariant.rs | 8 +- ...ons-variance-invariant-use-contravariant.stderr | 14 ---- ...ns-variance-invariant-use-covariant.base.stderr | 18 ++++ ...ons-variance-invariant-use-covariant.nll.stderr | 2 +- .../regions-variance-invariant-use-covariant.rs | 8 +- ...regions-variance-invariant-use-covariant.stderr | 18 ---- 213 files changed, 2146 insertions(+), 1873 deletions(-) create mode 100644 src/test/ui/regions/issue-28848.base.stderr delete mode 100644 src/test/ui/regions/issue-28848.stderr create mode 100644 src/test/ui/regions/region-invariant-static-error-reporting.base.stderr delete mode 100644 src/test/ui/regions/region-invariant-static-error-reporting.stderr create mode 100644 src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.base.stderr delete mode 100644 src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.stderr create mode 100644 src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.base.stderr delete mode 100644 src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.polonius.stderr delete mode 100644 src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.stderr create mode 100644 src/test/ui/regions/region-object-lifetime-2.base.stderr delete mode 100644 src/test/ui/regions/region-object-lifetime-2.stderr create mode 100644 src/test/ui/regions/region-object-lifetime-4.base.stderr delete mode 100644 src/test/ui/regions/region-object-lifetime-4.stderr create mode 100644 src/test/ui/regions/region-object-lifetime-in-coercion.base.stderr delete mode 100644 src/test/ui/regions/region-object-lifetime-in-coercion.stderr create mode 100644 src/test/ui/regions/regions-addr-of-self.base.stderr delete mode 100644 src/test/ui/regions/regions-addr-of-self.stderr create mode 100644 src/test/ui/regions/regions-addr-of-upvar-self.base.stderr delete mode 100644 src/test/ui/regions/regions-addr-of-upvar-self.stderr create mode 100644 src/test/ui/regions/regions-bounded-by-trait-requiring-static.base.stderr delete mode 100644 src/test/ui/regions/regions-bounded-by-trait-requiring-static.stderr create mode 100644 src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.base.stderr delete mode 100644 src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.stderr create mode 100644 src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.base.stderr delete mode 100644 src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.stderr create mode 100644 src/test/ui/regions/regions-bounded-method-type-parameters.base.stderr delete mode 100644 src/test/ui/regions/regions-bounded-method-type-parameters.stderr create mode 100644 src/test/ui/regions/regions-bounds.base.stderr delete mode 100644 src/test/ui/regions/regions-bounds.stderr create mode 100644 src/test/ui/regions/regions-close-associated-type-into-object.base.stderr delete mode 100644 src/test/ui/regions/regions-close-associated-type-into-object.stderr create mode 100644 src/test/ui/regions/regions-close-object-into-object-2.base.stderr delete mode 100644 src/test/ui/regions/regions-close-object-into-object-2.stderr create mode 100644 src/test/ui/regions/regions-close-object-into-object-4.base.stderr delete mode 100644 src/test/ui/regions/regions-close-object-into-object-4.stderr create mode 100644 src/test/ui/regions/regions-close-object-into-object-5.base.stderr delete mode 100644 src/test/ui/regions/regions-close-object-into-object-5.stderr create mode 100644 src/test/ui/regions/regions-close-over-type-parameter-1.base.stderr delete mode 100644 src/test/ui/regions/regions-close-over-type-parameter-1.stderr create mode 100644 src/test/ui/regions/regions-close-over-type-parameter-multiple.base.stderr delete mode 100644 src/test/ui/regions/regions-close-over-type-parameter-multiple.stderr create mode 100644 src/test/ui/regions/regions-close-param-into-object.base.stderr delete mode 100644 src/test/ui/regions/regions-close-param-into-object.stderr create mode 100644 src/test/ui/regions/regions-creating-enums3.base.stderr delete mode 100644 src/test/ui/regions/regions-creating-enums3.stderr create mode 100644 src/test/ui/regions/regions-creating-enums4.base.stderr delete mode 100644 src/test/ui/regions/regions-creating-enums4.stderr create mode 100644 src/test/ui/regions/regions-early-bound-error-method.base.stderr delete mode 100644 src/test/ui/regions/regions-early-bound-error-method.stderr create mode 100644 src/test/ui/regions/regions-early-bound-error.base.stderr delete mode 100644 src/test/ui/regions/regions-early-bound-error.stderr create mode 100644 src/test/ui/regions/regions-fn-subtyping-return-static-fail.base.stderr delete mode 100644 src/test/ui/regions/regions-fn-subtyping-return-static-fail.stderr create mode 100644 src/test/ui/regions/regions-free-region-ordering-callee.base.stderr delete mode 100644 src/test/ui/regions/regions-free-region-ordering-callee.stderr create mode 100644 src/test/ui/regions/regions-free-region-ordering-incorrect.base.stderr delete mode 100644 src/test/ui/regions/regions-free-region-ordering-incorrect.stderr create mode 100644 src/test/ui/regions/regions-implied-bounds-projection-gap-1.base.stderr delete mode 100644 src/test/ui/regions/regions-implied-bounds-projection-gap-1.stderr create mode 100644 src/test/ui/regions/regions-infer-bound-from-trait-self.base.stderr delete mode 100644 src/test/ui/regions/regions-infer-bound-from-trait-self.stderr create mode 100644 src/test/ui/regions/regions-infer-bound-from-trait.base.stderr delete mode 100644 src/test/ui/regions/regions-infer-bound-from-trait.stderr create mode 100644 src/test/ui/regions/regions-infer-contravariance-due-to-decl.base.stderr delete mode 100644 src/test/ui/regions/regions-infer-contravariance-due-to-decl.stderr create mode 100644 src/test/ui/regions/regions-infer-covariance-due-to-decl.base.stderr delete mode 100644 src/test/ui/regions/regions-infer-covariance-due-to-decl.stderr create mode 100644 src/test/ui/regions/regions-infer-invariance-due-to-decl.base.stderr delete mode 100644 src/test/ui/regions/regions-infer-invariance-due-to-decl.stderr create mode 100644 src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.base.stderr delete mode 100644 src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.stderr create mode 100644 src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.base.stderr delete mode 100644 src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.stderr create mode 100644 src/test/ui/regions/regions-infer-not-param.base.stderr delete mode 100644 src/test/ui/regions/regions-infer-not-param.stderr create mode 100644 src/test/ui/regions/regions-infer-paramd-indirect.base.stderr delete mode 100644 src/test/ui/regions/regions-infer-paramd-indirect.stderr create mode 100644 src/test/ui/regions/regions-lifetime-bounds-on-fns.base.stderr delete mode 100644 src/test/ui/regions/regions-lifetime-bounds-on-fns.stderr create mode 100644 src/test/ui/regions/regions-nested-fns.base.stderr delete mode 100644 src/test/ui/regions/regions-nested-fns.stderr create mode 100644 src/test/ui/regions/regions-outlives-projection-container.base.stderr delete mode 100644 src/test/ui/regions/regions-outlives-projection-container.stderr create mode 100644 src/test/ui/regions/regions-proc-bound-capture.base.stderr delete mode 100644 src/test/ui/regions/regions-proc-bound-capture.stderr create mode 100644 src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.base.stderr delete mode 100644 src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.stderr create mode 100644 src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.base.stderr delete mode 100644 src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.stderr create mode 100644 src/test/ui/regions/regions-ret-borrowed-1.base.stderr delete mode 100644 src/test/ui/regions/regions-ret-borrowed-1.stderr create mode 100644 src/test/ui/regions/regions-ret-borrowed.base.stderr delete mode 100644 src/test/ui/regions/regions-ret-borrowed.stderr create mode 100644 src/test/ui/regions/regions-static-bound.base.stderr delete mode 100644 src/test/ui/regions/regions-static-bound.stderr create mode 100644 src/test/ui/regions/regions-trait-object-subtyping.base.stderr delete mode 100644 src/test/ui/regions/regions-trait-object-subtyping.stderr create mode 100644 src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.base.stderr delete mode 100644 src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.stderr create mode 100644 src/test/ui/regions/regions-variance-contravariant-use-covariant.base.stderr delete mode 100644 src/test/ui/regions/regions-variance-contravariant-use-covariant.stderr create mode 100644 src/test/ui/regions/regions-variance-covariant-use-contravariant.base.stderr delete mode 100644 src/test/ui/regions/regions-variance-covariant-use-contravariant.stderr create mode 100644 src/test/ui/regions/regions-variance-invariant-use-contravariant.base.stderr delete mode 100644 src/test/ui/regions/regions-variance-invariant-use-contravariant.stderr create mode 100644 src/test/ui/regions/regions-variance-invariant-use-covariant.base.stderr delete mode 100644 src/test/ui/regions/regions-variance-invariant-use-covariant.stderr (limited to 'src/test') diff --git a/src/test/ui/regions/issue-28848.base.stderr b/src/test/ui/regions/issue-28848.base.stderr new file mode 100644 index 00000000000..f10b19738c4 --- /dev/null +++ b/src/test/ui/regions/issue-28848.base.stderr @@ -0,0 +1,20 @@ +error[E0478]: lifetime bound not satisfied + --> $DIR/issue-28848.rs:14:5 + | +LL | Foo::<'a, 'b>::xmute(u) + | ^^^^^^^^^^^^^ + | +note: lifetime parameter instantiated with the lifetime `'b` as defined here + --> $DIR/issue-28848.rs:13:16 + | +LL | pub fn foo<'a, 'b>(u: &'b ()) -> &'a () { + | ^^ +note: but lifetime parameter must outlive the lifetime `'a` as defined here + --> $DIR/issue-28848.rs:13:12 + | +LL | pub fn foo<'a, 'b>(u: &'b ()) -> &'a () { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0478`. diff --git a/src/test/ui/regions/issue-28848.nll.stderr b/src/test/ui/regions/issue-28848.nll.stderr index a29dac4c9c8..f9de8948272 100644 --- a/src/test/ui/regions/issue-28848.nll.stderr +++ b/src/test/ui/regions/issue-28848.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/issue-28848.rs:10:5 + --> $DIR/issue-28848.rs:14:5 | LL | pub fn foo<'a, 'b>(u: &'b ()) -> &'a () { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/regions/issue-28848.rs b/src/test/ui/regions/issue-28848.rs index a6250239030..d8ab42a08d4 100644 --- a/src/test/ui/regions/issue-28848.rs +++ b/src/test/ui/regions/issue-28848.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Foo<'a, 'b: 'a>(&'a &'b ()); impl<'a, 'b> Foo<'a, 'b> { @@ -7,7 +11,9 @@ impl<'a, 'b> Foo<'a, 'b> { } pub fn foo<'a, 'b>(u: &'b ()) -> &'a () { - Foo::<'a, 'b>::xmute(u) //~ ERROR lifetime bound not satisfied + Foo::<'a, 'b>::xmute(u) + //[base]~^ ERROR lifetime bound not satisfied + //[nll]~^^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/regions/issue-28848.stderr b/src/test/ui/regions/issue-28848.stderr deleted file mode 100644 index afa0c9c76b2..00000000000 --- a/src/test/ui/regions/issue-28848.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0478]: lifetime bound not satisfied - --> $DIR/issue-28848.rs:10:5 - | -LL | Foo::<'a, 'b>::xmute(u) - | ^^^^^^^^^^^^^ - | -note: lifetime parameter instantiated with the lifetime `'b` as defined here - --> $DIR/issue-28848.rs:9:16 - | -LL | pub fn foo<'a, 'b>(u: &'b ()) -> &'a () { - | ^^ -note: but lifetime parameter must outlive the lifetime `'a` as defined here - --> $DIR/issue-28848.rs:9:12 - | -LL | pub fn foo<'a, 'b>(u: &'b ()) -> &'a () { - | ^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0478`. diff --git a/src/test/ui/regions/region-invariant-static-error-reporting.base.stderr b/src/test/ui/regions/region-invariant-static-error-reporting.base.stderr new file mode 100644 index 00000000000..ce21751a95a --- /dev/null +++ b/src/test/ui/regions/region-invariant-static-error-reporting.base.stderr @@ -0,0 +1,25 @@ +error[E0308]: `if` and `else` have incompatible types + --> $DIR/region-invariant-static-error-reporting.rs:21:9 + | +LL | let bad = if x.is_some() { + | _______________- +LL | | x.unwrap() + | | ---------- expected because of this +LL | | } else { +LL | | mk_static() + | | ^^^^^^^^^^^ lifetime mismatch +LL | | }; + | |_____- `if` and `else` have incompatible types + | + = note: expected struct `Invariant<'a>` + found struct `Invariant<'static>` +note: the lifetime `'a` as defined here... + --> $DIR/region-invariant-static-error-reporting.rs:17:10 + | +LL | fn unify<'a>(x: Option>, f: fn(Invariant<'a>)) { + | ^^ + = note: ...does not necessarily outlive the static lifetime + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/regions/region-invariant-static-error-reporting.nll.stderr b/src/test/ui/regions/region-invariant-static-error-reporting.nll.stderr index 6e7eb734a50..6905fd008c5 100644 --- a/src/test/ui/regions/region-invariant-static-error-reporting.nll.stderr +++ b/src/test/ui/regions/region-invariant-static-error-reporting.nll.stderr @@ -1,5 +1,5 @@ error[E0521]: borrowed data escapes outside of function - --> $DIR/region-invariant-static-error-reporting.rs:15:9 + --> $DIR/region-invariant-static-error-reporting.rs:19:9 | LL | fn unify<'a>(x: Option>, f: fn(Invariant<'a>)) { | -- - `x` is a reference that is only valid in the function body diff --git a/src/test/ui/regions/region-invariant-static-error-reporting.rs b/src/test/ui/regions/region-invariant-static-error-reporting.rs index 911904813d0..b81022ca4b4 100644 --- a/src/test/ui/regions/region-invariant-static-error-reporting.rs +++ b/src/test/ui/regions/region-invariant-static-error-reporting.rs @@ -3,8 +3,12 @@ // over time, but this test used to exhibit some pretty bogus messages // that were not remotely helpful. -// error-pattern:the lifetime `'a` -// error-pattern:the static lifetime +// revisions: base nll +// ignore-compare-mode-nll +//[base] error-pattern:the lifetime `'a` +//[base] error-pattern:the static lifetime +//[nll] compile-flags: -Z borrowck=mir +//[nll] error-pattern:argument requires that `'a` must outlive `'static` struct Invariant<'a>(Option<&'a mut &'a mut ()>); @@ -12,9 +16,9 @@ fn mk_static() -> Invariant<'static> { Invariant(None) } fn unify<'a>(x: Option>, f: fn(Invariant<'a>)) { let bad = if x.is_some() { - x.unwrap() + x.unwrap() //[nll]~ ERROR borrowed data escapes outside of function [E0521] } else { - mk_static() + mk_static() //[base]~ ERROR `if` and `else` have incompatible types [E0308] }; f(bad); } diff --git a/src/test/ui/regions/region-invariant-static-error-reporting.stderr b/src/test/ui/regions/region-invariant-static-error-reporting.stderr deleted file mode 100644 index 34287070eec..00000000000 --- a/src/test/ui/regions/region-invariant-static-error-reporting.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0308]: `if` and `else` have incompatible types - --> $DIR/region-invariant-static-error-reporting.rs:17:9 - | -LL | let bad = if x.is_some() { - | _______________- -LL | | x.unwrap() - | | ---------- expected because of this -LL | | } else { -LL | | mk_static() - | | ^^^^^^^^^^^ lifetime mismatch -LL | | }; - | |_____- `if` and `else` have incompatible types - | - = note: expected struct `Invariant<'a>` - found struct `Invariant<'static>` -note: the lifetime `'a` as defined here... - --> $DIR/region-invariant-static-error-reporting.rs:13:10 - | -LL | fn unify<'a>(x: Option>, f: fn(Invariant<'a>)) { - | ^^ - = note: ...does not necessarily outlive the static lifetime - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.base.stderr b/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.base.stderr new file mode 100644 index 00000000000..2ba4f4f5d9f --- /dev/null +++ b/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.base.stderr @@ -0,0 +1,31 @@ +error[E0623]: lifetime mismatch + --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:12:10 + | +LL | fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) { + | --------- --------- these two types are declared with different lifetimes... +LL | // Illegal now because there is no `'b:'a` declaration. +LL | *x = *y; + | ^^ ...but data from `y` flows into `x` here + +error[E0623]: lifetime mismatch + --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:20:7 + | +LL | fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) { + | --------- --------- these two types are declared with different lifetimes... +... +LL | a(x, y); + | ^ ...but data from `y` flows into `x` here + +error[E0308]: mismatched types + --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:28:43 + | +LL | let _: fn(&mut &isize, &mut &isize) = a; + | ^ one type is more general than the other + | + = note: expected fn pointer `for<'r, 's, 't0, 't1> fn(&'r mut &'s isize, &'t0 mut &'t1 isize)` + found fn pointer `for<'r, 's> fn(&'r mut &isize, &'s mut &isize)` + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0308, E0623. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.nll.stderr b/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.nll.stderr index 233a040491c..c6430974334 100644 --- a/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.nll.stderr +++ b/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:8:5 + --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:12:5 | LL | fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) { | -- -- lifetime `'b` defined here @@ -12,7 +12,7 @@ LL | *x = *y; = help: consider adding the following bound: `'b: 'a` error: lifetime may not live long enough - --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:14:5 + --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:20:5 | LL | fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) { | -- -- lifetime `'b` defined here @@ -28,7 +28,7 @@ LL | a(x, y); = help: see for more information about variance error[E0308]: mismatched types - --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:20:12 + --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:28:12 | LL | let _: fn(&mut &isize, &mut &isize) = a; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other @@ -37,7 +37,7 @@ LL | let _: fn(&mut &isize, &mut &isize) = a; found fn pointer `for<'r, 's> fn(&'r mut &isize, &'s mut &isize)` error[E0308]: mismatched types - --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:20:12 + --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:28:12 | LL | let _: fn(&mut &isize, &mut &isize) = a; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other diff --git a/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.rs b/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.rs index ab4c6d9cf91..ec91d179808 100644 --- a/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.rs +++ b/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn a<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) where 'b: 'a { // Note: this is legal because of the `'b:'a` declaration. *x = *y; @@ -5,19 +9,25 @@ fn a<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) where 'b: 'a { fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) { // Illegal now because there is no `'b:'a` declaration. - *x = *y; //~ ERROR E0623 + *x = *y; + //[base]~^ ERROR E0623 + //[nll]~^^ ERROR lifetime may not live long enough } fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) { // Here we try to call `foo` but do not know that `'a` and `'b` are // related as required. - a(x, y); //~ ERROR lifetime mismatch [E0623] + a(x, y); + //[base]~^ ERROR lifetime mismatch [E0623] + //[nll]~^^ ERROR lifetime may not live long enough } fn d() { // 'a and 'b are early bound in the function `a` because they appear // inconstraints: - let _: fn(&mut &isize, &mut &isize) = a; //~ ERROR mismatched types + let _: fn(&mut &isize, &mut &isize) = a; + //~^ ERROR mismatched types [E0308] + //[nll]~^^ ERROR mismatched types [E0308] } fn e() { diff --git a/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.stderr b/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.stderr deleted file mode 100644 index b83e07663fa..00000000000 --- a/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error[E0623]: lifetime mismatch - --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:8:10 - | -LL | fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) { - | --------- --------- these two types are declared with different lifetimes... -LL | // Illegal now because there is no `'b:'a` declaration. -LL | *x = *y; - | ^^ ...but data from `y` flows into `x` here - -error[E0623]: lifetime mismatch - --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:14:7 - | -LL | fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) { - | --------- --------- these two types are declared with different lifetimes... -... -LL | a(x, y); - | ^ ...but data from `y` flows into `x` here - -error[E0308]: mismatched types - --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:20:43 - | -LL | let _: fn(&mut &isize, &mut &isize) = a; - | ^ one type is more general than the other - | - = note: expected fn pointer `for<'r, 's, 't0, 't1> fn(&'r mut &'s isize, &'t0 mut &'t1 isize)` - found fn pointer `for<'r, 's> fn(&'r mut &isize, &'s mut &isize)` - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0308, E0623. -For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.base.stderr b/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.base.stderr new file mode 100644 index 00000000000..537a1fb98a5 --- /dev/null +++ b/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.base.stderr @@ -0,0 +1,42 @@ +error[E0623]: lifetime mismatch + --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:13:10 + | +LL | fn b<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { + | --------- --------- these two types are declared with different lifetimes... +LL | // Illegal now because there is no `'b:'a` declaration. +LL | *x = *y; + | ^^ ...but data from `y` flows into `x` here + +error[E0623]: lifetime mismatch + --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:16:10 + | +LL | fn b<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { + | --------- --------- + | | + | these two types are declared with different lifetimes... +... +LL | *z = *y; + | ^^ ...but data from `y` flows into `z` here + +error[E0623]: lifetime mismatch + --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:7 + | +LL | fn c<'a,'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { + | --------- --------- these two types are declared with different lifetimes... +... +LL | a(x, y, z); + | ^ ...but data from `y` flows into `x` here + +error[E0308]: mismatched types + --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:30:56 + | +LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; + | ^ one type is more general than the other + | + = note: expected fn pointer `for<'r, 's, 't0, 't1, 't2, 't3> fn(&'r mut &'s isize, &'t0 mut &'t1 isize, &'t2 mut &'t3 isize)` + found fn pointer `for<'r, 's, 't0> fn(&'r mut &isize, &'s mut &isize, &'t0 mut &isize)` + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0308, E0623. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.nll.stderr b/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.nll.stderr index 00119743acd..053078f58df 100644 --- a/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.nll.stderr +++ b/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:9:5 + --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:13:5 | LL | fn b<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { | -- -- lifetime `'b` defined here @@ -12,7 +12,7 @@ LL | *x = *y; = help: consider adding the following bound: `'b: 'a` error: lifetime may not live long enough - --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:16:5 + --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:5 | LL | fn c<'a,'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { | -- -- lifetime `'b` defined here @@ -28,7 +28,7 @@ LL | a(x, y, z); = help: see for more information about variance error[E0308]: mismatched types - --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:12 + --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:30:12 | LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other @@ -37,7 +37,7 @@ LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; found fn pointer `for<'r, 's, 't0> fn(&'r mut &isize, &'s mut &isize, &'t0 mut &isize)` error[E0308]: mismatched types - --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:12 + --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:30:12 | LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other @@ -46,7 +46,7 @@ LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; found fn pointer `for<'r, 's, 't0> fn(&'r mut &isize, &'s mut &isize, &'t0 mut &isize)` error[E0308]: mismatched types - --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:12 + --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:30:12 | LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other diff --git a/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.polonius.stderr b/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.polonius.stderr deleted file mode 100644 index 13741664ef2..00000000000 --- a/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.polonius.stderr +++ /dev/null @@ -1,82 +0,0 @@ -error: lifetime may not live long enough - --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:9:5 - | -LL | fn b<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -LL | // Illegal now because there is no `'b:'a` declaration. -LL | *x = *y; - | ^^^^^^^ assignment requires that `'b` must outlive `'a` - | - = help: consider adding the following bound: `'b: 'a` - -error: lifetime may not live long enough - --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:10:5 - | -LL | fn b<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { - | -- -- lifetime `'c` defined here - | | - | lifetime `'b` defined here -... -LL | *z = *y; - | ^^^^^^^ assignment requires that `'b` must outlive `'c` - | - = help: consider adding the following bound: `'b: 'c` - -help: add bound `'b: 'a + 'c` - -error: lifetime may not live long enough - --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:16:5 - | -LL | fn c<'a,'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -... -LL | a(x, y, z); - | ^^^^^^^^^^ argument requires that `'b` must outlive `'a` - | - = help: consider adding the following bound: `'b: 'a` - = note: requirement occurs because of a mutable reference to &isize - = note: mutable references are invariant over their type parameter - = help: see for more information about variance - -error: lifetime may not live long enough - --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:16:5 - | -LL | fn c<'a,'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { - | -- -- lifetime `'c` defined here - | | - | lifetime `'b` defined here -... -LL | a(x, y, z); - | ^^^^^^^^^^ argument requires that `'b` must outlive `'c` - | - = help: consider adding the following bound: `'b: 'c` - = note: requirement occurs because of a mutable reference to &isize - = note: mutable references are invariant over their type parameter - = help: see for more information about variance - -help: add bound `'b: 'a + 'c` - -error: higher-ranked subtype error - --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:12 - | -LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: higher-ranked subtype error - --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:12 - | -LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: higher-ranked subtype error - --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:12 - | -LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 7 previous errors - diff --git a/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.rs b/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.rs index 066522548ad..8b5c1d47ec6 100644 --- a/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.rs +++ b/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn a<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) where 'b: 'a + 'c { // Note: this is legal because of the `'b:'a` declaration. *x = *y; @@ -6,20 +10,27 @@ fn a<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) where fn b<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { // Illegal now because there is no `'b:'a` declaration. - *x = *y; //~ ERROR E0623 - *z = *y; //~ ERROR E0623 + *x = *y; + //[base]~^ ERROR E0623 + //[nll]~^^ ERROR lifetime may not live long enough + *z = *y; //[base]~ ERROR E0623 } fn c<'a,'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { // Here we try to call `foo` but do not know that `'a` and `'b` are // related as required. - a(x, y, z); //~ ERROR lifetime mismatch [E0623] + a(x, y, z); + //[base]~^ ERROR lifetime mismatch [E0623] + //[nll]~^^ ERROR lifetime may not live long enough } fn d() { // 'a and 'b are early bound in the function `a` because they appear // inconstraints: - let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; //~ ERROR E0308 + let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; + //~^ ERROR E0308 + //[nll]~^^ ERROR mismatched types [E0308] + //[nll]~| ERROR mismatched types [E0308] } fn e() { diff --git a/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.stderr b/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.stderr deleted file mode 100644 index c93f2890f11..00000000000 --- a/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.stderr +++ /dev/null @@ -1,42 +0,0 @@ -error[E0623]: lifetime mismatch - --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:9:10 - | -LL | fn b<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { - | --------- --------- these two types are declared with different lifetimes... -LL | // Illegal now because there is no `'b:'a` declaration. -LL | *x = *y; - | ^^ ...but data from `y` flows into `x` here - -error[E0623]: lifetime mismatch - --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:10:10 - | -LL | fn b<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { - | --------- --------- - | | - | these two types are declared with different lifetimes... -... -LL | *z = *y; - | ^^ ...but data from `y` flows into `z` here - -error[E0623]: lifetime mismatch - --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:16:7 - | -LL | fn c<'a,'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) { - | --------- --------- these two types are declared with different lifetimes... -... -LL | a(x, y, z); - | ^ ...but data from `y` flows into `x` here - -error[E0308]: mismatched types - --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:56 - | -LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; - | ^ one type is more general than the other - | - = note: expected fn pointer `for<'r, 's, 't0, 't1, 't2, 't3> fn(&'r mut &'s isize, &'t0 mut &'t1 isize, &'t2 mut &'t3 isize)` - found fn pointer `for<'r, 's, 't0> fn(&'r mut &isize, &'s mut &isize, &'t0 mut &isize)` - -error: aborting due to 4 previous errors - -Some errors have detailed explanations: E0308, E0623. -For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/regions/region-object-lifetime-2.base.stderr b/src/test/ui/regions/region-object-lifetime-2.base.stderr new file mode 100644 index 00000000000..118fe476500 --- /dev/null +++ b/src/test/ui/regions/region-object-lifetime-2.base.stderr @@ -0,0 +1,30 @@ +error[E0495]: cannot infer an appropriate lifetime for autoref due to conflicting requirements + --> $DIR/region-object-lifetime-2.rs:14:7 + | +LL | x.borrowed() + | ^^^^^^^^ + | +note: first, the lifetime cannot outlive the lifetime `'a` as defined here... + --> $DIR/region-object-lifetime-2.rs:13:42 + | +LL | fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a dyn Foo) -> &'b () { + | ^^ +note: ...so that reference does not outlive borrowed content + --> $DIR/region-object-lifetime-2.rs:14:5 + | +LL | x.borrowed() + | ^ +note: but, the lifetime must be valid for the lifetime `'b` as defined here... + --> $DIR/region-object-lifetime-2.rs:13:45 + | +LL | fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a dyn Foo) -> &'b () { + | ^^ +note: ...so that reference does not outlive borrowed content + --> $DIR/region-object-lifetime-2.rs:14:5 + | +LL | x.borrowed() + | ^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/regions/region-object-lifetime-2.nll.stderr b/src/test/ui/regions/region-object-lifetime-2.nll.stderr index d95289f3f9d..c0b09ebb6f5 100644 --- a/src/test/ui/regions/region-object-lifetime-2.nll.stderr +++ b/src/test/ui/regions/region-object-lifetime-2.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/region-object-lifetime-2.rs:10:5 + --> $DIR/region-object-lifetime-2.rs:14:5 | LL | fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a dyn Foo) -> &'b () { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/regions/region-object-lifetime-2.rs b/src/test/ui/regions/region-object-lifetime-2.rs index 42798487893..e12b9822f60 100644 --- a/src/test/ui/regions/region-object-lifetime-2.rs +++ b/src/test/ui/regions/region-object-lifetime-2.rs @@ -1,13 +1,19 @@ // Various tests related to testing how region inference works // with respect to the object receivers. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait Foo { fn borrowed<'a>(&'a self) -> &'a (); } // Borrowed receiver but two distinct lifetimes, we get an error. fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a dyn Foo) -> &'b () { - x.borrowed() //~ ERROR cannot infer + x.borrowed() + //[base]~^ ERROR cannot infer + //[nll]~^^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/regions/region-object-lifetime-2.stderr b/src/test/ui/regions/region-object-lifetime-2.stderr deleted file mode 100644 index 380e27ab0e0..00000000000 --- a/src/test/ui/regions/region-object-lifetime-2.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error[E0495]: cannot infer an appropriate lifetime for autoref due to conflicting requirements - --> $DIR/region-object-lifetime-2.rs:10:7 - | -LL | x.borrowed() - | ^^^^^^^^ - | -note: first, the lifetime cannot outlive the lifetime `'a` as defined here... - --> $DIR/region-object-lifetime-2.rs:9:42 - | -LL | fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a dyn Foo) -> &'b () { - | ^^ -note: ...so that reference does not outlive borrowed content - --> $DIR/region-object-lifetime-2.rs:10:5 - | -LL | x.borrowed() - | ^ -note: but, the lifetime must be valid for the lifetime `'b` as defined here... - --> $DIR/region-object-lifetime-2.rs:9:45 - | -LL | fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a dyn Foo) -> &'b () { - | ^^ -note: ...so that reference does not outlive borrowed content - --> $DIR/region-object-lifetime-2.rs:10:5 - | -LL | x.borrowed() - | ^^^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/regions/region-object-lifetime-4.base.stderr b/src/test/ui/regions/region-object-lifetime-4.base.stderr new file mode 100644 index 00000000000..3765076a9c5 --- /dev/null +++ b/src/test/ui/regions/region-object-lifetime-4.base.stderr @@ -0,0 +1,30 @@ +error[E0495]: cannot infer an appropriate lifetime for autoref due to conflicting requirements + --> $DIR/region-object-lifetime-4.rs:16:7 + | +LL | x.borrowed() + | ^^^^^^^^ + | +note: first, the lifetime cannot outlive the lifetime `'a` as defined here... + --> $DIR/region-object-lifetime-4.rs:15:41 + | +LL | fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (dyn Foo + 'b)) -> &'b () { + | ^^ +note: ...so that reference does not outlive borrowed content + --> $DIR/region-object-lifetime-4.rs:16:5 + | +LL | x.borrowed() + | ^ +note: but, the lifetime must be valid for the lifetime `'b` as defined here... + --> $DIR/region-object-lifetime-4.rs:15:44 + | +LL | fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (dyn Foo + 'b)) -> &'b () { + | ^^ +note: ...so that reference does not outlive borrowed content + --> $DIR/region-object-lifetime-4.rs:16:5 + | +LL | x.borrowed() + | ^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/regions/region-object-lifetime-4.nll.stderr b/src/test/ui/regions/region-object-lifetime-4.nll.stderr index fda66a2412c..a2a958f90b2 100644 --- a/src/test/ui/regions/region-object-lifetime-4.nll.stderr +++ b/src/test/ui/regions/region-object-lifetime-4.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/region-object-lifetime-4.rs:12:5 + --> $DIR/region-object-lifetime-4.rs:16:5 | LL | fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (dyn Foo + 'b)) -> &'b () { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/regions/region-object-lifetime-4.rs b/src/test/ui/regions/region-object-lifetime-4.rs index 4fe12b2acfc..aad9c2c9521 100644 --- a/src/test/ui/regions/region-object-lifetime-4.rs +++ b/src/test/ui/regions/region-object-lifetime-4.rs @@ -1,6 +1,10 @@ // Various tests related to testing how region inference works // with respect to the object receivers. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait Foo { fn borrowed<'a>(&'a self) -> &'a (); } @@ -9,7 +13,9 @@ trait Foo { // with the longer lifetime when (from the signature) we only know // that it lives as long as the shorter lifetime. Therefore, error. fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (dyn Foo + 'b)) -> &'b () { - x.borrowed() //~ ERROR cannot infer + x.borrowed() + //[base]~^ ERROR cannot infer + //[nll]~^^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/regions/region-object-lifetime-4.stderr b/src/test/ui/regions/region-object-lifetime-4.stderr deleted file mode 100644 index b59163ef13b..00000000000 --- a/src/test/ui/regions/region-object-lifetime-4.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error[E0495]: cannot infer an appropriate lifetime for autoref due to conflicting requirements - --> $DIR/region-object-lifetime-4.rs:12:7 - | -LL | x.borrowed() - | ^^^^^^^^ - | -note: first, the lifetime cannot outlive the lifetime `'a` as defined here... - --> $DIR/region-object-lifetime-4.rs:11:41 - | -LL | fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (dyn Foo + 'b)) -> &'b () { - | ^^ -note: ...so that reference does not outlive borrowed content - --> $DIR/region-object-lifetime-4.rs:12:5 - | -LL | x.borrowed() - | ^ -note: but, the lifetime must be valid for the lifetime `'b` as defined here... - --> $DIR/region-object-lifetime-4.rs:11:44 - | -LL | fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (dyn Foo + 'b)) -> &'b () { - | ^^ -note: ...so that reference does not outlive borrowed content - --> $DIR/region-object-lifetime-4.rs:12:5 - | -LL | x.borrowed() - | ^^^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/regions/region-object-lifetime-in-coercion.base.stderr b/src/test/ui/regions/region-object-lifetime-in-coercion.base.stderr new file mode 100644 index 00000000000..85bfa16b3d3 --- /dev/null +++ b/src/test/ui/regions/region-object-lifetime-in-coercion.base.stderr @@ -0,0 +1,98 @@ +error[E0759]: `v` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement + --> $DIR/region-object-lifetime-in-coercion.rs:12:46 + | +LL | fn a(v: &[u8]) -> Box { + | ----- this data with an anonymous lifetime `'_`... +LL | let x: Box = Box::new(v); + | ^ ...is used and required to live as long as `'static` here + | +help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v` + | +LL | fn a(v: &[u8]) -> Box { + | ~~ +help: alternatively, add an explicit `'static` bound to this reference + | +LL | fn a(v: &'static [u8]) -> Box { + | ~~~~~~~~~~~~~ + +error[E0759]: `v` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement + --> $DIR/region-object-lifetime-in-coercion.rs:19:14 + | +LL | fn b(v: &[u8]) -> Box { + | ----- this data with an anonymous lifetime `'_`... +LL | Box::new(v) + | ^ ...is used and required to live as long as `'static` here + | +note: `'static` lifetime requirement introduced by the return type + --> $DIR/region-object-lifetime-in-coercion.rs:18:33 + | +LL | fn b(v: &[u8]) -> Box { + | ^^^^^^^ `'static` requirement introduced here +LL | Box::new(v) + | ----------- because of this returned expression +help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v` + | +LL | fn b(v: &[u8]) -> Box { + | ~~ +help: alternatively, add an explicit `'static` bound to this reference + | +LL | fn b(v: &'static [u8]) -> Box { + | ~~~~~~~~~~~~~ + +error[E0759]: `v` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement + --> $DIR/region-object-lifetime-in-coercion.rs:27:14 + | +LL | fn c(v: &[u8]) -> Box { + | ----- this data with an anonymous lifetime `'_`... +... +LL | Box::new(v) + | ^ ...is used and required to live as long as `'static` here + | +note: `'static` lifetime requirement introduced by the return type + --> $DIR/region-object-lifetime-in-coercion.rs:24:23 + | +LL | fn c(v: &[u8]) -> Box { + | ^^^^^^^ `'static` requirement introduced here +... +LL | Box::new(v) + | ----------- because of this returned expression +help: to declare that the trait object captures data from argument `v`, you can add an explicit `'_` lifetime bound + | +LL | fn c(v: &[u8]) -> Box { + | ++++ + +error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements + --> $DIR/region-object-lifetime-in-coercion.rs:33:14 + | +LL | Box::new(v) + | ^ + | +note: first, the lifetime cannot outlive the lifetime `'a` as defined here... + --> $DIR/region-object-lifetime-in-coercion.rs:32:6 + | +LL | fn d<'a,'b>(v: &'a [u8]) -> Box { + | ^^ +note: ...so that the expression is assignable + --> $DIR/region-object-lifetime-in-coercion.rs:33:14 + | +LL | Box::new(v) + | ^ + = note: expected `&[u8]` + found `&'a [u8]` +note: but, the lifetime must be valid for the lifetime `'b` as defined here... + --> $DIR/region-object-lifetime-in-coercion.rs:32:9 + | +LL | fn d<'a,'b>(v: &'a [u8]) -> Box { + | ^^ +note: ...so that the types are compatible + --> $DIR/region-object-lifetime-in-coercion.rs:33:5 + | +LL | Box::new(v) + | ^^^^^^^^^^^ + = note: expected `Box<(dyn Foo + 'b)>` + found `Box` + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0495, E0759. +For more information about an error, try `rustc --explain E0495`. diff --git a/src/test/ui/regions/region-object-lifetime-in-coercion.nll.stderr b/src/test/ui/regions/region-object-lifetime-in-coercion.nll.stderr index 92588819076..4d72724586e 100644 --- a/src/test/ui/regions/region-object-lifetime-in-coercion.nll.stderr +++ b/src/test/ui/regions/region-object-lifetime-in-coercion.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/region-object-lifetime-in-coercion.rs:8:12 + --> $DIR/region-object-lifetime-in-coercion.rs:12:12 | LL | fn a(v: &[u8]) -> Box { | - let's call the lifetime of this reference `'1` @@ -7,7 +7,7 @@ LL | let x: Box = Box::new(v); | ^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'1` must outlive `'static` error: lifetime may not live long enough - --> $DIR/region-object-lifetime-in-coercion.rs:13:5 + --> $DIR/region-object-lifetime-in-coercion.rs:19:5 | LL | fn b(v: &[u8]) -> Box { | - let's call the lifetime of this reference `'1` @@ -15,7 +15,7 @@ LL | Box::new(v) | ^^^^^^^^^^^ returning this value requires that `'1` must outlive `'static` error: lifetime may not live long enough - --> $DIR/region-object-lifetime-in-coercion.rs:19:5 + --> $DIR/region-object-lifetime-in-coercion.rs:27:5 | LL | fn c(v: &[u8]) -> Box { | - let's call the lifetime of this reference `'1` @@ -24,7 +24,7 @@ LL | Box::new(v) | ^^^^^^^^^^^ returning this value requires that `'1` must outlive `'static` error: lifetime may not live long enough - --> $DIR/region-object-lifetime-in-coercion.rs:23:5 + --> $DIR/region-object-lifetime-in-coercion.rs:33:5 | LL | fn d<'a,'b>(v: &'a [u8]) -> Box { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/regions/region-object-lifetime-in-coercion.rs b/src/test/ui/regions/region-object-lifetime-in-coercion.rs index 9d3f485e314..ed28d6c0ff1 100644 --- a/src/test/ui/regions/region-object-lifetime-in-coercion.rs +++ b/src/test/ui/regions/region-object-lifetime-in-coercion.rs @@ -1,26 +1,38 @@ // Test that attempts to implicitly coerce a value into an // object respect the lifetime bound on the object type. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait Foo {} impl<'a> Foo for &'a [u8] {} fn a(v: &[u8]) -> Box { - let x: Box = Box::new(v); //~ ERROR E0759 + let x: Box = Box::new(v); + //[base]~^ ERROR E0759 + //[nll]~^^ ERROR lifetime may not live long enough x } fn b(v: &[u8]) -> Box { - Box::new(v) //~ ERROR E0759 + Box::new(v) + //[base]~^ ERROR E0759 + //[nll]~^^ ERROR lifetime may not live long enough } fn c(v: &[u8]) -> Box { // same as previous case due to RFC 599 - Box::new(v) //~ ERROR E0759 + Box::new(v) + //[base]~^ ERROR E0759 + //[nll]~^^ ERROR lifetime may not live long enough } fn d<'a,'b>(v: &'a [u8]) -> Box { - Box::new(v) //~ ERROR cannot infer an appropriate lifetime due to conflicting + Box::new(v) + //[base]~^ ERROR cannot infer an appropriate lifetime due to conflicting + //[nll]~^^ ERROR lifetime may not live long enough } fn e<'a:'b,'b>(v: &'a [u8]) -> Box { diff --git a/src/test/ui/regions/region-object-lifetime-in-coercion.stderr b/src/test/ui/regions/region-object-lifetime-in-coercion.stderr deleted file mode 100644 index d8932c067ac..00000000000 --- a/src/test/ui/regions/region-object-lifetime-in-coercion.stderr +++ /dev/null @@ -1,98 +0,0 @@ -error[E0759]: `v` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/region-object-lifetime-in-coercion.rs:8:46 - | -LL | fn a(v: &[u8]) -> Box { - | ----- this data with an anonymous lifetime `'_`... -LL | let x: Box = Box::new(v); - | ^ ...is used and required to live as long as `'static` here - | -help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v` - | -LL | fn a(v: &[u8]) -> Box { - | ~~ -help: alternatively, add an explicit `'static` bound to this reference - | -LL | fn a(v: &'static [u8]) -> Box { - | ~~~~~~~~~~~~~ - -error[E0759]: `v` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/region-object-lifetime-in-coercion.rs:13:14 - | -LL | fn b(v: &[u8]) -> Box { - | ----- this data with an anonymous lifetime `'_`... -LL | Box::new(v) - | ^ ...is used and required to live as long as `'static` here - | -note: `'static` lifetime requirement introduced by the return type - --> $DIR/region-object-lifetime-in-coercion.rs:12:33 - | -LL | fn b(v: &[u8]) -> Box { - | ^^^^^^^ `'static` requirement introduced here -LL | Box::new(v) - | ----------- because of this returned expression -help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v` - | -LL | fn b(v: &[u8]) -> Box { - | ~~ -help: alternatively, add an explicit `'static` bound to this reference - | -LL | fn b(v: &'static [u8]) -> Box { - | ~~~~~~~~~~~~~ - -error[E0759]: `v` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/region-object-lifetime-in-coercion.rs:19:14 - | -LL | fn c(v: &[u8]) -> Box { - | ----- this data with an anonymous lifetime `'_`... -... -LL | Box::new(v) - | ^ ...is used and required to live as long as `'static` here - | -note: `'static` lifetime requirement introduced by the return type - --> $DIR/region-object-lifetime-in-coercion.rs:16:23 - | -LL | fn c(v: &[u8]) -> Box { - | ^^^^^^^ `'static` requirement introduced here -... -LL | Box::new(v) - | ----------- because of this returned expression -help: to declare that the trait object captures data from argument `v`, you can add an explicit `'_` lifetime bound - | -LL | fn c(v: &[u8]) -> Box { - | ++++ - -error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements - --> $DIR/region-object-lifetime-in-coercion.rs:23:14 - | -LL | Box::new(v) - | ^ - | -note: first, the lifetime cannot outlive the lifetime `'a` as defined here... - --> $DIR/region-object-lifetime-in-coercion.rs:22:6 - | -LL | fn d<'a,'b>(v: &'a [u8]) -> Box { - | ^^ -note: ...so that the expression is assignable - --> $DIR/region-object-lifetime-in-coercion.rs:23:14 - | -LL | Box::new(v) - | ^ - = note: expected `&[u8]` - found `&'a [u8]` -note: but, the lifetime must be valid for the lifetime `'b` as defined here... - --> $DIR/region-object-lifetime-in-coercion.rs:22:9 - | -LL | fn d<'a,'b>(v: &'a [u8]) -> Box { - | ^^ -note: ...so that the types are compatible - --> $DIR/region-object-lifetime-in-coercion.rs:23:5 - | -LL | Box::new(v) - | ^^^^^^^^^^^ - = note: expected `Box<(dyn Foo + 'b)>` - found `Box` - -error: aborting due to 4 previous errors - -Some errors have detailed explanations: E0495, E0759. -For more information about an error, try `rustc --explain E0495`. diff --git a/src/test/ui/regions/regions-addr-of-self.base.stderr b/src/test/ui/regions/regions-addr-of-self.base.stderr new file mode 100644 index 00000000000..3167c2f2107 --- /dev/null +++ b/src/test/ui/regions/regions-addr-of-self.base.stderr @@ -0,0 +1,11 @@ +error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement + --> $DIR/regions-addr-of-self.rs:11:37 + | +LL | pub fn chase_cat(&mut self) { + | --------- this data with an anonymous lifetime `'_`... +LL | let p: &'static mut usize = &mut self.cats_chased; + | ^^^^^^^^^^^^^^^^^^^^^ ...is used and required to live as long as `'static` here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0759`. diff --git a/src/test/ui/regions/regions-addr-of-self.nll.stderr b/src/test/ui/regions/regions-addr-of-self.nll.stderr index 3d7aac74bd4..1f720520f6b 100644 --- a/src/test/ui/regions/regions-addr-of-self.nll.stderr +++ b/src/test/ui/regions/regions-addr-of-self.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-addr-of-self.rs:7:16 + --> $DIR/regions-addr-of-self.rs:11:16 | LL | pub fn chase_cat(&mut self) { | - let's call the lifetime of this reference `'1` diff --git a/src/test/ui/regions/regions-addr-of-self.rs b/src/test/ui/regions/regions-addr-of-self.rs index 4eb1b275f16..698433c71b3 100644 --- a/src/test/ui/regions/regions-addr-of-self.rs +++ b/src/test/ui/regions/regions-addr-of-self.rs @@ -1,10 +1,16 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Dog { cats_chased: usize, } impl Dog { pub fn chase_cat(&mut self) { - let p: &'static mut usize = &mut self.cats_chased; //~ ERROR E0759 + let p: &'static mut usize = &mut self.cats_chased; + //[base]~^ ERROR E0759 + //[nll]~^^ ERROR lifetime may not live long enough *p += 1; } diff --git a/src/test/ui/regions/regions-addr-of-self.stderr b/src/test/ui/regions/regions-addr-of-self.stderr deleted file mode 100644 index 3453c6458f1..00000000000 --- a/src/test/ui/regions/regions-addr-of-self.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/regions-addr-of-self.rs:7:37 - | -LL | pub fn chase_cat(&mut self) { - | --------- this data with an anonymous lifetime `'_`... -LL | let p: &'static mut usize = &mut self.cats_chased; - | ^^^^^^^^^^^^^^^^^^^^^ ...is used and required to live as long as `'static` here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0759`. diff --git a/src/test/ui/regions/regions-addr-of-upvar-self.base.stderr b/src/test/ui/regions/regions-addr-of-upvar-self.base.stderr new file mode 100644 index 00000000000..42d0638e8b7 --- /dev/null +++ b/src/test/ui/regions/regions-addr-of-upvar-self.base.stderr @@ -0,0 +1,26 @@ +error[E0495]: cannot infer an appropriate lifetime for borrow expression due to conflicting requirements + --> $DIR/regions-addr-of-upvar-self.rs:12:41 + | +LL | let p: &'static mut usize = &mut self.food; + | ^^^^^^^^^^^^^^ + | +note: first, the lifetime cannot outlive the lifetime `'_` as defined here... + --> $DIR/regions-addr-of-upvar-self.rs:11:18 + | +LL | let _f = || { + | ^^ +note: ...so that closure can access `self` + --> $DIR/regions-addr-of-upvar-self.rs:12:41 + | +LL | let p: &'static mut usize = &mut self.food; + | ^^^^^^^^^^^^^^ + = note: but, the lifetime must be valid for the static lifetime... +note: ...so that reference does not outlive borrowed content + --> $DIR/regions-addr-of-upvar-self.rs:12:41 + | +LL | let p: &'static mut usize = &mut self.food; + | ^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/regions/regions-addr-of-upvar-self.nll.stderr b/src/test/ui/regions/regions-addr-of-upvar-self.nll.stderr index c16a6f8585b..b8e37e92316 100644 --- a/src/test/ui/regions/regions-addr-of-upvar-self.nll.stderr +++ b/src/test/ui/regions/regions-addr-of-upvar-self.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-addr-of-upvar-self.rs:8:20 + --> $DIR/regions-addr-of-upvar-self.rs:12:20 | LL | let _f = || { | -- lifetime `'1` represents this closure's body @@ -9,7 +9,7 @@ LL | let p: &'static mut usize = &mut self.food; = note: closure implements `FnMut`, so references to captured variables can't escape the closure error: lifetime may not live long enough - --> $DIR/regions-addr-of-upvar-self.rs:8:20 + --> $DIR/regions-addr-of-upvar-self.rs:12:20 | LL | pub fn chase_cat(&mut self) { | - let's call the lifetime of this reference `'1` @@ -18,7 +18,7 @@ LL | let p: &'static mut usize = &mut self.food; | ^^^^^^^^^^^^^^^^^^ type annotation requires that `'1` must outlive `'static` error[E0597]: `self` does not live long enough - --> $DIR/regions-addr-of-upvar-self.rs:8:46 + --> $DIR/regions-addr-of-upvar-self.rs:12:46 | LL | let _f = || { | -- value captured here diff --git a/src/test/ui/regions/regions-addr-of-upvar-self.rs b/src/test/ui/regions/regions-addr-of-upvar-self.rs index 6159ab02d3d..36cc592d47c 100644 --- a/src/test/ui/regions/regions-addr-of-upvar-self.rs +++ b/src/test/ui/regions/regions-addr-of-upvar-self.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Dog { food: usize, } @@ -5,7 +9,11 @@ struct Dog { impl Dog { pub fn chase_cat(&mut self) { let _f = || { - let p: &'static mut usize = &mut self.food; //~ ERROR cannot infer + let p: &'static mut usize = &mut self.food; + //[base]~^ ERROR cannot infer + //[nll]~^^ ERROR lifetime may not live long enough + //[nll]~^^^ ERROR lifetime may not live long enough + //[nll]~^^^^ ERROR E0597 *p = 3; }; } diff --git a/src/test/ui/regions/regions-addr-of-upvar-self.stderr b/src/test/ui/regions/regions-addr-of-upvar-self.stderr deleted file mode 100644 index f638064ef83..00000000000 --- a/src/test/ui/regions/regions-addr-of-upvar-self.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error[E0495]: cannot infer an appropriate lifetime for borrow expression due to conflicting requirements - --> $DIR/regions-addr-of-upvar-self.rs:8:41 - | -LL | let p: &'static mut usize = &mut self.food; - | ^^^^^^^^^^^^^^ - | -note: first, the lifetime cannot outlive the lifetime `'_` as defined here... - --> $DIR/regions-addr-of-upvar-self.rs:7:18 - | -LL | let _f = || { - | ^^ -note: ...so that closure can access `self` - --> $DIR/regions-addr-of-upvar-self.rs:8:41 - | -LL | let p: &'static mut usize = &mut self.food; - | ^^^^^^^^^^^^^^ - = note: but, the lifetime must be valid for the static lifetime... -note: ...so that reference does not outlive borrowed content - --> $DIR/regions-addr-of-upvar-self.rs:8:41 - | -LL | let p: &'static mut usize = &mut self.food; - | ^^^^^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/regions/regions-bounded-by-trait-requiring-static.base.stderr b/src/test/ui/regions/regions-bounded-by-trait-requiring-static.base.stderr new file mode 100644 index 00000000000..9b45dcfd95a --- /dev/null +++ b/src/test/ui/regions/regions-bounded-by-trait-requiring-static.base.stderr @@ -0,0 +1,75 @@ +error[E0477]: the type `&'a isize` does not fulfill the required lifetime + --> $DIR/regions-bounded-by-trait-requiring-static.rs:26:5 + | +LL | assert_send::<&'a isize>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: type must satisfy the static lifetime as required by this binding + --> $DIR/regions-bounded-by-trait-requiring-static.rs:10:18 + | +LL | fn assert_send() { } + | ^^^^^^^ + +error[E0477]: the type `&'a str` does not fulfill the required lifetime + --> $DIR/regions-bounded-by-trait-requiring-static.rs:32:5 + | +LL | assert_send::<&'a str>(); + | ^^^^^^^^^^^^^^^^^^^^^^ + | +note: type must satisfy the static lifetime as required by this binding + --> $DIR/regions-bounded-by-trait-requiring-static.rs:10:18 + | +LL | fn assert_send() { } + | ^^^^^^^ + +error[E0477]: the type `&'a [isize]` does not fulfill the required lifetime + --> $DIR/regions-bounded-by-trait-requiring-static.rs:38:5 + | +LL | assert_send::<&'a [isize]>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: type must satisfy the static lifetime as required by this binding + --> $DIR/regions-bounded-by-trait-requiring-static.rs:10:18 + | +LL | fn assert_send() { } + | ^^^^^^^ + +error[E0477]: the type `Box<&'a isize>` does not fulfill the required lifetime + --> $DIR/regions-bounded-by-trait-requiring-static.rs:54:5 + | +LL | assert_send::>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: type must satisfy the static lifetime as required by this binding + --> $DIR/regions-bounded-by-trait-requiring-static.rs:10:18 + | +LL | fn assert_send() { } + | ^^^^^^^ + +error[E0477]: the type `*const &'a isize` does not fulfill the required lifetime + --> $DIR/regions-bounded-by-trait-requiring-static.rs:67:5 + | +LL | assert_send::<*const &'a isize>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: type must satisfy the static lifetime as required by this binding + --> $DIR/regions-bounded-by-trait-requiring-static.rs:10:18 + | +LL | fn assert_send() { } + | ^^^^^^^ + +error[E0477]: the type `*mut &'a isize` does not fulfill the required lifetime + --> $DIR/regions-bounded-by-trait-requiring-static.rs:73:5 + | +LL | assert_send::<*mut &'a isize>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: type must satisfy the static lifetime as required by this binding + --> $DIR/regions-bounded-by-trait-requiring-static.rs:10:18 + | +LL | fn assert_send() { } + | ^^^^^^^ + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0477`. diff --git a/src/test/ui/regions/regions-bounded-by-trait-requiring-static.nll.stderr b/src/test/ui/regions/regions-bounded-by-trait-requiring-static.nll.stderr index 86bd100538d..558a77516bb 100644 --- a/src/test/ui/regions/regions-bounded-by-trait-requiring-static.nll.stderr +++ b/src/test/ui/regions/regions-bounded-by-trait-requiring-static.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-bounded-by-trait-requiring-static.rs:22:5 + --> $DIR/regions-bounded-by-trait-requiring-static.rs:26:5 | LL | fn param_not_ok<'a>(x: &'a isize) { | -- lifetime `'a` defined here @@ -7,7 +7,7 @@ LL | assert_send::<&'a isize>(); | ^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` error: lifetime may not live long enough - --> $DIR/regions-bounded-by-trait-requiring-static.rs:26:5 + --> $DIR/regions-bounded-by-trait-requiring-static.rs:32:5 | LL | fn param_not_ok1<'a>(_: &'a isize) { | -- lifetime `'a` defined here @@ -15,7 +15,7 @@ LL | assert_send::<&'a str>(); | ^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` error: lifetime may not live long enough - --> $DIR/regions-bounded-by-trait-requiring-static.rs:30:5 + --> $DIR/regions-bounded-by-trait-requiring-static.rs:38:5 | LL | fn param_not_ok2<'a>(_: &'a isize) { | -- lifetime `'a` defined here @@ -23,7 +23,7 @@ LL | assert_send::<&'a [isize]>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` error: lifetime may not live long enough - --> $DIR/regions-bounded-by-trait-requiring-static.rs:44:5 + --> $DIR/regions-bounded-by-trait-requiring-static.rs:54:5 | LL | fn box_with_region_not_ok<'a>() { | -- lifetime `'a` defined here @@ -31,7 +31,7 @@ LL | assert_send::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` error: lifetime may not live long enough - --> $DIR/regions-bounded-by-trait-requiring-static.rs:55:5 + --> $DIR/regions-bounded-by-trait-requiring-static.rs:67:5 | LL | fn unsafe_ok2<'a>(_: &'a isize) { | -- lifetime `'a` defined here @@ -39,7 +39,7 @@ LL | assert_send::<*const &'a isize>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` error: lifetime may not live long enough - --> $DIR/regions-bounded-by-trait-requiring-static.rs:59:5 + --> $DIR/regions-bounded-by-trait-requiring-static.rs:73:5 | LL | fn unsafe_ok3<'a>(_: &'a isize) { | -- lifetime `'a` defined here diff --git a/src/test/ui/regions/regions-bounded-by-trait-requiring-static.rs b/src/test/ui/regions/regions-bounded-by-trait-requiring-static.rs index c583f43638a..37dc1300d39 100644 --- a/src/test/ui/regions/regions-bounded-by-trait-requiring-static.rs +++ b/src/test/ui/regions/regions-bounded-by-trait-requiring-static.rs @@ -2,6 +2,10 @@ // in this file all test region bound and lifetime violations that are // detected during type check. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait Dummy : 'static { } fn assert_send() { } @@ -19,15 +23,21 @@ fn static_lifime_ok<'a,T,U:Send>(_: &'a isize) { // otherwise lifetime pointers are not ok fn param_not_ok<'a>(x: &'a isize) { - assert_send::<&'a isize>(); //~ ERROR does not fulfill the required lifetime + assert_send::<&'a isize>(); + //[base]~^ ERROR does not fulfill the required lifetime + //[nll]~^^ ERROR lifetime may not live long enough } fn param_not_ok1<'a>(_: &'a isize) { - assert_send::<&'a str>(); //~ ERROR does not fulfill the required lifetime + assert_send::<&'a str>(); + //[base]~^ ERROR does not fulfill the required lifetime + //[nll]~^^ ERROR lifetime may not live long enough } fn param_not_ok2<'a>(_: &'a isize) { - assert_send::<&'a [isize]>(); //~ ERROR does not fulfill the required lifetime + assert_send::<&'a [isize]>(); + //[base]~^ ERROR does not fulfill the required lifetime + //[nll]~^^ ERROR lifetime may not live long enough } // boxes are ok @@ -41,7 +51,9 @@ fn box_ok() { // but not if they own a bad thing fn box_with_region_not_ok<'a>() { - assert_send::>(); //~ ERROR does not fulfill the required lifetime + assert_send::>(); + //[base]~^ ERROR does not fulfill the required lifetime + //[nll]~^^ ERROR lifetime may not live long enough } // raw pointers are ok unless they point at unsendable things @@ -52,11 +64,15 @@ fn unsafe_ok1<'a>(_: &'a isize) { } fn unsafe_ok2<'a>(_: &'a isize) { - assert_send::<*const &'a isize>(); //~ ERROR does not fulfill the required lifetime + assert_send::<*const &'a isize>(); + //[base]~^ ERROR does not fulfill the required lifetime + //[nll]~^^ ERROR lifetime may not live long enough } fn unsafe_ok3<'a>(_: &'a isize) { - assert_send::<*mut &'a isize>(); //~ ERROR does not fulfill the required lifetime + assert_send::<*mut &'a isize>(); + //[base]~^ ERROR does not fulfill the required lifetime + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/regions/regions-bounded-by-trait-requiring-static.stderr b/src/test/ui/regions/regions-bounded-by-trait-requiring-static.stderr deleted file mode 100644 index 68b90eee72d..00000000000 --- a/src/test/ui/regions/regions-bounded-by-trait-requiring-static.stderr +++ /dev/null @@ -1,75 +0,0 @@ -error[E0477]: the type `&'a isize` does not fulfill the required lifetime - --> $DIR/regions-bounded-by-trait-requiring-static.rs:22:5 - | -LL | assert_send::<&'a isize>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: type must satisfy the static lifetime as required by this binding - --> $DIR/regions-bounded-by-trait-requiring-static.rs:6:18 - | -LL | fn assert_send() { } - | ^^^^^^^ - -error[E0477]: the type `&'a str` does not fulfill the required lifetime - --> $DIR/regions-bounded-by-trait-requiring-static.rs:26:5 - | -LL | assert_send::<&'a str>(); - | ^^^^^^^^^^^^^^^^^^^^^^ - | -note: type must satisfy the static lifetime as required by this binding - --> $DIR/regions-bounded-by-trait-requiring-static.rs:6:18 - | -LL | fn assert_send() { } - | ^^^^^^^ - -error[E0477]: the type `&'a [isize]` does not fulfill the required lifetime - --> $DIR/regions-bounded-by-trait-requiring-static.rs:30:5 - | -LL | assert_send::<&'a [isize]>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: type must satisfy the static lifetime as required by this binding - --> $DIR/regions-bounded-by-trait-requiring-static.rs:6:18 - | -LL | fn assert_send() { } - | ^^^^^^^ - -error[E0477]: the type `Box<&'a isize>` does not fulfill the required lifetime - --> $DIR/regions-bounded-by-trait-requiring-static.rs:44:5 - | -LL | assert_send::>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: type must satisfy the static lifetime as required by this binding - --> $DIR/regions-bounded-by-trait-requiring-static.rs:6:18 - | -LL | fn assert_send() { } - | ^^^^^^^ - -error[E0477]: the type `*const &'a isize` does not fulfill the required lifetime - --> $DIR/regions-bounded-by-trait-requiring-static.rs:55:5 - | -LL | assert_send::<*const &'a isize>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: type must satisfy the static lifetime as required by this binding - --> $DIR/regions-bounded-by-trait-requiring-static.rs:6:18 - | -LL | fn assert_send() { } - | ^^^^^^^ - -error[E0477]: the type `*mut &'a isize` does not fulfill the required lifetime - --> $DIR/regions-bounded-by-trait-requiring-static.rs:59:5 - | -LL | assert_send::<*mut &'a isize>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: type must satisfy the static lifetime as required by this binding - --> $DIR/regions-bounded-by-trait-requiring-static.rs:6:18 - | -LL | fn assert_send() { } - | ^^^^^^^ - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0477`. diff --git a/src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.base.stderr b/src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.base.stderr new file mode 100644 index 00000000000..e031f0db412 --- /dev/null +++ b/src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.base.stderr @@ -0,0 +1,12 @@ +error[E0623]: lifetime mismatch + --> $DIR/regions-bounded-method-type-parameters-cross-crate.rs:23:7 + | +LL | fn call_bigger_region<'x, 'y>(a: Inv<'x>, b: Inv<'y>) { + | ------- ------- these two types are declared with different lifetimes... +LL | // Here the value provided for 'y is 'y, and hence 'y:'x does not hold. +LL | a.bigger_region(b) + | ^^^^^^^^^^^^^ ...but data from `b` flows into `a` here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.nll.stderr b/src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.nll.stderr index 6193bf02f6d..4f5d747be71 100644 --- a/src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.nll.stderr +++ b/src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-bounded-method-type-parameters-cross-crate.rs:20:5 + --> $DIR/regions-bounded-method-type-parameters-cross-crate.rs:23:5 | LL | fn call_bigger_region<'x, 'y>(a: Inv<'x>, b: Inv<'y>) { | -- -- lifetime `'y` defined here diff --git a/src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.rs b/src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.rs index a7987d0e1fe..e0965613f1d 100644 --- a/src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.rs +++ b/src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.rs @@ -1,4 +1,7 @@ // aux-build:rbmtp_cross_crate_lib.rs +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir // Check explicit region bounds on methods in the cross crate case. @@ -17,7 +20,9 @@ fn call_into_maybe_owned<'x,F:IntoMaybeOwned<'x>>(f: F) { fn call_bigger_region<'x, 'y>(a: Inv<'x>, b: Inv<'y>) { // Here the value provided for 'y is 'y, and hence 'y:'x does not hold. - a.bigger_region(b) //~ ERROR lifetime mismatch [E0623] + a.bigger_region(b) + //[base]~^ ERROR lifetime mismatch [E0623] + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { } diff --git a/src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.stderr b/src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.stderr deleted file mode 100644 index eb205a303db..00000000000 --- a/src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0623]: lifetime mismatch - --> $DIR/regions-bounded-method-type-parameters-cross-crate.rs:20:7 - | -LL | fn call_bigger_region<'x, 'y>(a: Inv<'x>, b: Inv<'y>) { - | ------- ------- these two types are declared with different lifetimes... -LL | // Here the value provided for 'y is 'y, and hence 'y:'x does not hold. -LL | a.bigger_region(b) - | ^^^^^^^^^^^^^ ...but data from `b` flows into `a` here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.base.stderr b/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.base.stderr new file mode 100644 index 00000000000..0a213e3f779 --- /dev/null +++ b/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.base.stderr @@ -0,0 +1,12 @@ +error[E0623]: lifetime mismatch + --> $DIR/regions-bounded-method-type-parameters-trait-bound.rs:24:7 + | +LL | fn caller2<'a,'b,F:Foo<'a>>(a: Inv<'a>, b: Inv<'b>, f: F) { + | ------- ------- these two types are declared with different lifetimes... +LL | // Here the value provided for 'y is 'b, and hence 'b:'a does not hold. +LL | f.method(b); + | ^^^^^^ ...but data from `b` flows into `a` here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.nll.stderr b/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.nll.stderr index 0e0086be9ea..1c2f46a5fc1 100644 --- a/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.nll.stderr +++ b/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-bounded-method-type-parameters-trait-bound.rs:20:5 + --> $DIR/regions-bounded-method-type-parameters-trait-bound.rs:24:5 | LL | fn caller2<'a,'b,F:Foo<'a>>(a: Inv<'a>, b: Inv<'b>, f: F) { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.rs b/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.rs index 8adf496b230..8a52a1549ab 100644 --- a/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.rs +++ b/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.rs @@ -2,6 +2,10 @@ // nominal types (but not on other types) and that they are type // checked. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Inv<'a> { // invariant w/r/t 'a x: &'a mut &'a isize } @@ -17,7 +21,9 @@ fn caller1<'a,'b,F:Foo<'a>>(a: Inv<'a>, b: Inv<'b>, f: F) { fn caller2<'a,'b,F:Foo<'a>>(a: Inv<'a>, b: Inv<'b>, f: F) { // Here the value provided for 'y is 'b, and hence 'b:'a does not hold. - f.method(b); //~ ERROR lifetime mismatch [E0623] + f.method(b); + //[base]~^ ERROR lifetime mismatch [E0623] + //[nll]~^^ ERROR lifetime may not live long enough } fn caller3<'a,'b:'a,F:Foo<'a>>(a: Inv<'a>, b: Inv<'b>, f: F) { diff --git a/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.stderr b/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.stderr deleted file mode 100644 index de1073cd1d9..00000000000 --- a/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0623]: lifetime mismatch - --> $DIR/regions-bounded-method-type-parameters-trait-bound.rs:20:7 - | -LL | fn caller2<'a,'b,F:Foo<'a>>(a: Inv<'a>, b: Inv<'b>, f: F) { - | ------- ------- these two types are declared with different lifetimes... -LL | // Here the value provided for 'y is 'b, and hence 'b:'a does not hold. -LL | f.method(b); - | ^^^^^^ ...but data from `b` flows into `a` here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/regions/regions-bounded-method-type-parameters.base.stderr b/src/test/ui/regions/regions-bounded-method-type-parameters.base.stderr new file mode 100644 index 00000000000..3d37a1ba47b --- /dev/null +++ b/src/test/ui/regions/regions-bounded-method-type-parameters.base.stderr @@ -0,0 +1,15 @@ +error[E0477]: the type `&'a isize` does not fulfill the required lifetime + --> $DIR/regions-bounded-method-type-parameters.rs:16:9 + | +LL | Foo.some_method::<&'a isize>(); + | ^^^^^^^^^^^ + | +note: type must satisfy the static lifetime as required by this binding + --> $DIR/regions-bounded-method-type-parameters.rs:12:22 + | +LL | fn some_method(self) { } + | ^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0477`. diff --git a/src/test/ui/regions/regions-bounded-method-type-parameters.nll.stderr b/src/test/ui/regions/regions-bounded-method-type-parameters.nll.stderr index b6d7b8aac5f..05c3fa58ea3 100644 --- a/src/test/ui/regions/regions-bounded-method-type-parameters.nll.stderr +++ b/src/test/ui/regions/regions-bounded-method-type-parameters.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-bounded-method-type-parameters.rs:12:9 + --> $DIR/regions-bounded-method-type-parameters.rs:16:9 | LL | fn caller<'a>(x: &isize) { | -- lifetime `'a` defined here diff --git a/src/test/ui/regions/regions-bounded-method-type-parameters.rs b/src/test/ui/regions/regions-bounded-method-type-parameters.rs index 90af120f052..06bc1544a38 100644 --- a/src/test/ui/regions/regions-bounded-method-type-parameters.rs +++ b/src/test/ui/regions/regions-bounded-method-type-parameters.rs @@ -2,6 +2,10 @@ // nominal types (but not on other types) and that they are type // checked. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Foo; impl Foo { @@ -10,7 +14,8 @@ impl Foo { fn caller<'a>(x: &isize) { Foo.some_method::<&'a isize>(); - //~^ ERROR does not fulfill the required lifetime + //[base]~^ ERROR does not fulfill the required lifetime + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { } diff --git a/src/test/ui/regions/regions-bounded-method-type-parameters.stderr b/src/test/ui/regions/regions-bounded-method-type-parameters.stderr deleted file mode 100644 index 318e9d006a1..00000000000 --- a/src/test/ui/regions/regions-bounded-method-type-parameters.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0477]: the type `&'a isize` does not fulfill the required lifetime - --> $DIR/regions-bounded-method-type-parameters.rs:12:9 - | -LL | Foo.some_method::<&'a isize>(); - | ^^^^^^^^^^^ - | -note: type must satisfy the static lifetime as required by this binding - --> $DIR/regions-bounded-method-type-parameters.rs:8:22 - | -LL | fn some_method(self) { } - | ^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0477`. diff --git a/src/test/ui/regions/regions-bounds.base.stderr b/src/test/ui/regions/regions-bounds.base.stderr new file mode 100644 index 00000000000..d853cdde336 --- /dev/null +++ b/src/test/ui/regions/regions-bounds.base.stderr @@ -0,0 +1,41 @@ +error[E0308]: mismatched types + --> $DIR/regions-bounds.rs:13:12 + | +LL | return e; + | ^ lifetime mismatch + | + = note: expected struct `TupleStruct<'b>` + found struct `TupleStruct<'a>` +note: the lifetime `'a` as defined here... + --> $DIR/regions-bounds.rs:12:10 + | +LL | fn a_fn1<'a,'b>(e: TupleStruct<'a>) -> TupleStruct<'b> { + | ^^ +note: ...does not necessarily outlive the lifetime `'b` as defined here + --> $DIR/regions-bounds.rs:12:13 + | +LL | fn a_fn1<'a,'b>(e: TupleStruct<'a>) -> TupleStruct<'b> { + | ^^ + +error[E0308]: mismatched types + --> $DIR/regions-bounds.rs:19:12 + | +LL | return e; + | ^ lifetime mismatch + | + = note: expected struct `Struct<'b>` + found struct `Struct<'a>` +note: the lifetime `'a` as defined here... + --> $DIR/regions-bounds.rs:18:10 + | +LL | fn a_fn3<'a,'b>(e: Struct<'a>) -> Struct<'b> { + | ^^ +note: ...does not necessarily outlive the lifetime `'b` as defined here + --> $DIR/regions-bounds.rs:18:13 + | +LL | fn a_fn3<'a,'b>(e: Struct<'a>) -> Struct<'b> { + | ^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/regions/regions-bounds.nll.stderr b/src/test/ui/regions/regions-bounds.nll.stderr index 84226a57553..7109220165f 100644 --- a/src/test/ui/regions/regions-bounds.nll.stderr +++ b/src/test/ui/regions/regions-bounds.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-bounds.rs:9:12 + --> $DIR/regions-bounds.rs:13:12 | LL | fn a_fn1<'a,'b>(e: TupleStruct<'a>) -> TupleStruct<'b> { | -- -- lifetime `'b` defined here @@ -11,7 +11,7 @@ LL | return e; = help: consider adding the following bound: `'a: 'b` error: lifetime may not live long enough - --> $DIR/regions-bounds.rs:13:12 + --> $DIR/regions-bounds.rs:19:12 | LL | fn a_fn3<'a,'b>(e: Struct<'a>) -> Struct<'b> { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/regions/regions-bounds.rs b/src/test/ui/regions/regions-bounds.rs index d3e4e6e8712..b13dac49f8c 100644 --- a/src/test/ui/regions/regions-bounds.rs +++ b/src/test/ui/regions/regions-bounds.rs @@ -2,15 +2,23 @@ // nominal types (but not on other types) and that they are type // checked. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct TupleStruct<'a>(&'a isize); struct Struct<'a> { x:&'a isize } fn a_fn1<'a,'b>(e: TupleStruct<'a>) -> TupleStruct<'b> { - return e; //~ ERROR mismatched types + return e; + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR lifetime may not live long enough } fn a_fn3<'a,'b>(e: Struct<'a>) -> Struct<'b> { - return e; //~ ERROR mismatched types + return e; + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { } diff --git a/src/test/ui/regions/regions-bounds.stderr b/src/test/ui/regions/regions-bounds.stderr deleted file mode 100644 index 90227e574ad..00000000000 --- a/src/test/ui/regions/regions-bounds.stderr +++ /dev/null @@ -1,41 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/regions-bounds.rs:9:12 - | -LL | return e; - | ^ lifetime mismatch - | - = note: expected struct `TupleStruct<'b>` - found struct `TupleStruct<'a>` -note: the lifetime `'a` as defined here... - --> $DIR/regions-bounds.rs:8:10 - | -LL | fn a_fn1<'a,'b>(e: TupleStruct<'a>) -> TupleStruct<'b> { - | ^^ -note: ...does not necessarily outlive the lifetime `'b` as defined here - --> $DIR/regions-bounds.rs:8:13 - | -LL | fn a_fn1<'a,'b>(e: TupleStruct<'a>) -> TupleStruct<'b> { - | ^^ - -error[E0308]: mismatched types - --> $DIR/regions-bounds.rs:13:12 - | -LL | return e; - | ^ lifetime mismatch - | - = note: expected struct `Struct<'b>` - found struct `Struct<'a>` -note: the lifetime `'a` as defined here... - --> $DIR/regions-bounds.rs:12:10 - | -LL | fn a_fn3<'a,'b>(e: Struct<'a>) -> Struct<'b> { - | ^^ -note: ...does not necessarily outlive the lifetime `'b` as defined here - --> $DIR/regions-bounds.rs:12:13 - | -LL | fn a_fn3<'a,'b>(e: Struct<'a>) -> Struct<'b> { - | ^^ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/regions/regions-close-associated-type-into-object.base.stderr b/src/test/ui/regions/regions-close-associated-type-into-object.base.stderr new file mode 100644 index 00000000000..fbbb5980401 --- /dev/null +++ b/src/test/ui/regions/regions-close-associated-type-into-object.base.stderr @@ -0,0 +1,40 @@ +error[E0310]: the associated type `::Item` may not live long enough + --> $DIR/regions-close-associated-type-into-object.rs:19:5 + | +LL | Box::new(item) + | ^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `::Item: 'static`... + = note: ...so that the type `::Item` will meet its required lifetime bounds + +error[E0310]: the associated type `::Item` may not live long enough + --> $DIR/regions-close-associated-type-into-object.rs:26:5 + | +LL | Box::new(item) + | ^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `::Item: 'static`... + = note: ...so that the type `Box<::Item>` will meet its required lifetime bounds + +error[E0309]: the associated type `::Item` may not live long enough + --> $DIR/regions-close-associated-type-into-object.rs:32:5 + | +LL | Box::new(item) + | ^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `::Item: 'a`... + = note: ...so that the type `::Item` will meet its required lifetime bounds + +error[E0309]: the associated type `::Item` may not live long enough + --> $DIR/regions-close-associated-type-into-object.rs:39:5 + | +LL | Box::new(item) + | ^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `::Item: 'a`... + = note: ...so that the type `Box<::Item>` will meet its required lifetime bounds + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0309, E0310. +For more information about an error, try `rustc --explain E0309`. diff --git a/src/test/ui/regions/regions-close-associated-type-into-object.nll.stderr b/src/test/ui/regions/regions-close-associated-type-into-object.nll.stderr index f7dcaa9d97e..dd4b97aa562 100644 --- a/src/test/ui/regions/regions-close-associated-type-into-object.nll.stderr +++ b/src/test/ui/regions/regions-close-associated-type-into-object.nll.stderr @@ -1,5 +1,5 @@ error[E0310]: the associated type `::Item` may not live long enough - --> $DIR/regions-close-associated-type-into-object.rs:15:5 + --> $DIR/regions-close-associated-type-into-object.rs:19:5 | LL | Box::new(item) | ^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | Box::new(item) = note: ...so that the type `::Item` will meet its required lifetime bounds error[E0310]: the associated type `::Item` may not live long enough - --> $DIR/regions-close-associated-type-into-object.rs:22:5 + --> $DIR/regions-close-associated-type-into-object.rs:26:5 | LL | Box::new(item) | ^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | Box::new(item) = note: ...so that the type `::Item` will meet its required lifetime bounds error[E0309]: the associated type `::Item` may not live long enough - --> $DIR/regions-close-associated-type-into-object.rs:28:5 + --> $DIR/regions-close-associated-type-into-object.rs:32:5 | LL | Box::new(item) | ^^^^^^^^^^^^^^ @@ -26,7 +26,7 @@ LL | Box::new(item) = note: ...so that the type `::Item` will meet its required lifetime bounds error[E0309]: the associated type `::Item` may not live long enough - --> $DIR/regions-close-associated-type-into-object.rs:35:5 + --> $DIR/regions-close-associated-type-into-object.rs:39:5 | LL | Box::new(item) | ^^^^^^^^^^^^^^ diff --git a/src/test/ui/regions/regions-close-associated-type-into-object.rs b/src/test/ui/regions/regions-close-associated-type-into-object.rs index 428477e2489..94199f56212 100644 --- a/src/test/ui/regions/regions-close-associated-type-into-object.rs +++ b/src/test/ui/regions/regions-close-associated-type-into-object.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait X {} diff --git a/src/test/ui/regions/regions-close-associated-type-into-object.stderr b/src/test/ui/regions/regions-close-associated-type-into-object.stderr deleted file mode 100644 index 536a1b5e359..00000000000 --- a/src/test/ui/regions/regions-close-associated-type-into-object.stderr +++ /dev/null @@ -1,40 +0,0 @@ -error[E0310]: the associated type `::Item` may not live long enough - --> $DIR/regions-close-associated-type-into-object.rs:15:5 - | -LL | Box::new(item) - | ^^^^^^^^^^^^^^ - | - = help: consider adding an explicit lifetime bound `::Item: 'static`... - = note: ...so that the type `::Item` will meet its required lifetime bounds - -error[E0310]: the associated type `::Item` may not live long enough - --> $DIR/regions-close-associated-type-into-object.rs:22:5 - | -LL | Box::new(item) - | ^^^^^^^^^^^^^^ - | - = help: consider adding an explicit lifetime bound `::Item: 'static`... - = note: ...so that the type `Box<::Item>` will meet its required lifetime bounds - -error[E0309]: the associated type `::Item` may not live long enough - --> $DIR/regions-close-associated-type-into-object.rs:28:5 - | -LL | Box::new(item) - | ^^^^^^^^^^^^^^ - | - = help: consider adding an explicit lifetime bound `::Item: 'a`... - = note: ...so that the type `::Item` will meet its required lifetime bounds - -error[E0309]: the associated type `::Item` may not live long enough - --> $DIR/regions-close-associated-type-into-object.rs:35:5 - | -LL | Box::new(item) - | ^^^^^^^^^^^^^^ - | - = help: consider adding an explicit lifetime bound `::Item: 'a`... - = note: ...so that the type `Box<::Item>` will meet its required lifetime bounds - -error: aborting due to 4 previous errors - -Some errors have detailed explanations: E0309, E0310. -For more information about an error, try `rustc --explain E0309`. diff --git a/src/test/ui/regions/regions-close-object-into-object-2.base.stderr b/src/test/ui/regions/regions-close-object-into-object-2.base.stderr new file mode 100644 index 00000000000..ddf168ffd10 --- /dev/null +++ b/src/test/ui/regions/regions-close-object-into-object-2.base.stderr @@ -0,0 +1,27 @@ +error[E0759]: `v` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement + --> $DIR/regions-close-object-into-object-2.rs:13:16 + | +LL | fn g<'a, T: 'static>(v: Box + 'a>) -> Box { + | ------------------ this data with lifetime `'a`... +LL | Box::new(B(&*v)) as Box + | ^^^ ...is used and required to live as long as `'static` here + | +note: `'static` lifetime requirement introduced by the return type + --> $DIR/regions-close-object-into-object-2.rs:12:60 + | +LL | fn g<'a, T: 'static>(v: Box + 'a>) -> Box { + | ^^^^^^^ `'static` requirement introduced here +LL | Box::new(B(&*v)) as Box + | ------------------------------ because of this returned expression +help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v` + | +LL | fn g<'a, T: 'static>(v: Box + 'a>) -> Box { + | ~~ +help: alternatively, add an explicit `'static` bound to this reference + | +LL | fn g<'a, T: 'static>(v: Box<(dyn A + 'static)>) -> Box { + | ~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0759`. diff --git a/src/test/ui/regions/regions-close-object-into-object-2.nll.stderr b/src/test/ui/regions/regions-close-object-into-object-2.nll.stderr index 6a0e9586161..1a79da2776b 100644 --- a/src/test/ui/regions/regions-close-object-into-object-2.nll.stderr +++ b/src/test/ui/regions/regions-close-object-into-object-2.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-close-object-into-object-2.rs:9:5 + --> $DIR/regions-close-object-into-object-2.rs:13:5 | LL | fn g<'a, T: 'static>(v: Box + 'a>) -> Box { | -- lifetime `'a` defined here @@ -7,7 +7,7 @@ LL | Box::new(B(&*v)) as Box | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` error[E0515]: cannot return value referencing local data `*v` - --> $DIR/regions-close-object-into-object-2.rs:9:5 + --> $DIR/regions-close-object-into-object-2.rs:13:5 | LL | Box::new(B(&*v)) as Box | ^^^^^^^^^^^---^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/regions/regions-close-object-into-object-2.rs b/src/test/ui/regions/regions-close-object-into-object-2.rs index 9c41174e24d..33ea03f061e 100644 --- a/src/test/ui/regions/regions-close-object-into-object-2.rs +++ b/src/test/ui/regions/regions-close-object-into-object-2.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait A { } struct B<'a, T:'a>(&'a (dyn A + 'a)); @@ -6,7 +10,10 @@ trait X { } impl<'a, T> X for B<'a, T> {} fn g<'a, T: 'static>(v: Box + 'a>) -> Box { - Box::new(B(&*v)) as Box //~ ERROR E0759 + Box::new(B(&*v)) as Box + //[base]~^ ERROR E0759 + //[nll]~^^ ERROR lifetime may not live long enough + //[nll]~| ERROR cannot return value referencing local data `*v` [E0515] } fn main() { } diff --git a/src/test/ui/regions/regions-close-object-into-object-2.stderr b/src/test/ui/regions/regions-close-object-into-object-2.stderr deleted file mode 100644 index 4153f4f29bc..00000000000 --- a/src/test/ui/regions/regions-close-object-into-object-2.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error[E0759]: `v` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/regions-close-object-into-object-2.rs:9:16 - | -LL | fn g<'a, T: 'static>(v: Box + 'a>) -> Box { - | ------------------ this data with lifetime `'a`... -LL | Box::new(B(&*v)) as Box - | ^^^ ...is used and required to live as long as `'static` here - | -note: `'static` lifetime requirement introduced by the return type - --> $DIR/regions-close-object-into-object-2.rs:8:60 - | -LL | fn g<'a, T: 'static>(v: Box + 'a>) -> Box { - | ^^^^^^^ `'static` requirement introduced here -LL | Box::new(B(&*v)) as Box - | ------------------------------ because of this returned expression -help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v` - | -LL | fn g<'a, T: 'static>(v: Box + 'a>) -> Box { - | ~~ -help: alternatively, add an explicit `'static` bound to this reference - | -LL | fn g<'a, T: 'static>(v: Box<(dyn A + 'static)>) -> Box { - | ~~~~~~~~~~~~~~~~~~~~~~~~~ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0759`. diff --git a/src/test/ui/regions/regions-close-object-into-object-4.base.stderr b/src/test/ui/regions/regions-close-object-into-object-4.base.stderr new file mode 100644 index 00000000000..33d4df3d194 --- /dev/null +++ b/src/test/ui/regions/regions-close-object-into-object-4.base.stderr @@ -0,0 +1,27 @@ +error[E0759]: `v` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement + --> $DIR/regions-close-object-into-object-4.rs:13:16 + | +LL | fn i<'a, T, U>(v: Box+'a>) -> Box { + | ---------------- this data with lifetime `'a`... +LL | Box::new(B(&*v)) as Box + | ^^^ ...is used and required to live as long as `'static` here + | +note: `'static` lifetime requirement introduced by the return type + --> $DIR/regions-close-object-into-object-4.rs:12:52 + | +LL | fn i<'a, T, U>(v: Box+'a>) -> Box { + | ^^^^^^^ `'static` requirement introduced here +LL | Box::new(B(&*v)) as Box + | ------------------------------ because of this returned expression +help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v` + | +LL | fn i<'a, T, U>(v: Box+'a>) -> Box { + | ~~ +help: alternatively, add an explicit `'static` bound to this reference + | +LL | fn i<'a, T, U>(v: Box<(dyn A + 'static)>) -> Box { + | ~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0759`. diff --git a/src/test/ui/regions/regions-close-object-into-object-4.nll.stderr b/src/test/ui/regions/regions-close-object-into-object-4.nll.stderr index 6a2429e51ec..993b13ddbf8 100644 --- a/src/test/ui/regions/regions-close-object-into-object-4.nll.stderr +++ b/src/test/ui/regions/regions-close-object-into-object-4.nll.stderr @@ -1,5 +1,5 @@ error[E0310]: the parameter type `U` may not live long enough - --> $DIR/regions-close-object-into-object-4.rs:9:5 + --> $DIR/regions-close-object-into-object-4.rs:13:5 | LL | fn i<'a, T, U>(v: Box+'a>) -> Box { | - help: consider adding an explicit lifetime bound...: `U: 'static` @@ -7,7 +7,7 @@ LL | Box::new(B(&*v)) as Box | ^^^^^^^^ ...so that the type `U` will meet its required lifetime bounds error[E0310]: the parameter type `U` may not live long enough - --> $DIR/regions-close-object-into-object-4.rs:9:5 + --> $DIR/regions-close-object-into-object-4.rs:13:5 | LL | fn i<'a, T, U>(v: Box+'a>) -> Box { | - help: consider adding an explicit lifetime bound...: `U: 'static` @@ -15,7 +15,7 @@ LL | Box::new(B(&*v)) as Box | ^^^^^^^^^^^^^^^^ ...so that the type `U` will meet its required lifetime bounds error[E0310]: the parameter type `U` may not live long enough - --> $DIR/regions-close-object-into-object-4.rs:9:5 + --> $DIR/regions-close-object-into-object-4.rs:13:5 | LL | fn i<'a, T, U>(v: Box+'a>) -> Box { | - help: consider adding an explicit lifetime bound...: `U: 'static` @@ -23,7 +23,7 @@ LL | Box::new(B(&*v)) as Box | ^^^^^^^^^^^^^^^^ ...so that the type `U` will meet its required lifetime bounds error: lifetime may not live long enough - --> $DIR/regions-close-object-into-object-4.rs:9:5 + --> $DIR/regions-close-object-into-object-4.rs:13:5 | LL | fn i<'a, T, U>(v: Box+'a>) -> Box { | -- lifetime `'a` defined here @@ -31,7 +31,7 @@ LL | Box::new(B(&*v)) as Box | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` error[E0515]: cannot return value referencing local data `*v` - --> $DIR/regions-close-object-into-object-4.rs:9:5 + --> $DIR/regions-close-object-into-object-4.rs:13:5 | LL | Box::new(B(&*v)) as Box | ^^^^^^^^^^^---^^^^^^^^^^^^^^^^ @@ -40,7 +40,7 @@ LL | Box::new(B(&*v)) as Box | returns a value referencing data owned by the current function error[E0310]: the parameter type `U` may not live long enough - --> $DIR/regions-close-object-into-object-4.rs:9:14 + --> $DIR/regions-close-object-into-object-4.rs:13:14 | LL | fn i<'a, T, U>(v: Box+'a>) -> Box { | - help: consider adding an explicit lifetime bound...: `U: 'static` diff --git a/src/test/ui/regions/regions-close-object-into-object-4.rs b/src/test/ui/regions/regions-close-object-into-object-4.rs index 2a06a2b7c05..5a852b7329a 100644 --- a/src/test/ui/regions/regions-close-object-into-object-4.rs +++ b/src/test/ui/regions/regions-close-object-into-object-4.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait A { } struct B<'a, T:'a>(&'a (dyn A + 'a)); @@ -6,7 +10,15 @@ trait X { } impl<'a, T> X for B<'a, T> {} fn i<'a, T, U>(v: Box+'a>) -> Box { - Box::new(B(&*v)) as Box //~ ERROR E0759 + Box::new(B(&*v)) as Box + //[base]~^ ERROR E0759 + //[nll]~^^ ERROR the parameter type `U` may not live long enough [E0310] + //[nll]~| ERROR the parameter type `U` may not live long enough [E0310] + //[nll]~| ERROR the parameter type `U` may not live long enough [E0310] + //[nll]~| ERROR lifetime may not live long enough + //[nll]~| ERROR cannot return value referencing local data `*v` [E0515] + //[nll]~| ERROR the parameter type `U` may not live long enough [E0310] + } fn main() {} diff --git a/src/test/ui/regions/regions-close-object-into-object-4.stderr b/src/test/ui/regions/regions-close-object-into-object-4.stderr deleted file mode 100644 index 2ea4b431b38..00000000000 --- a/src/test/ui/regions/regions-close-object-into-object-4.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error[E0759]: `v` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/regions-close-object-into-object-4.rs:9:16 - | -LL | fn i<'a, T, U>(v: Box+'a>) -> Box { - | ---------------- this data with lifetime `'a`... -LL | Box::new(B(&*v)) as Box - | ^^^ ...is used and required to live as long as `'static` here - | -note: `'static` lifetime requirement introduced by the return type - --> $DIR/regions-close-object-into-object-4.rs:8:52 - | -LL | fn i<'a, T, U>(v: Box+'a>) -> Box { - | ^^^^^^^ `'static` requirement introduced here -LL | Box::new(B(&*v)) as Box - | ------------------------------ because of this returned expression -help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v` - | -LL | fn i<'a, T, U>(v: Box+'a>) -> Box { - | ~~ -help: alternatively, add an explicit `'static` bound to this reference - | -LL | fn i<'a, T, U>(v: Box<(dyn A + 'static)>) -> Box { - | ~~~~~~~~~~~~~~~~~~~~~~~~~ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0759`. diff --git a/src/test/ui/regions/regions-close-object-into-object-5.base.stderr b/src/test/ui/regions/regions-close-object-into-object-5.base.stderr new file mode 100644 index 00000000000..8b5a06bab71 --- /dev/null +++ b/src/test/ui/regions/regions-close-object-into-object-5.base.stderr @@ -0,0 +1,84 @@ +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/regions-close-object-into-object-5.rs:21:5 + | +LL | fn f<'a, T, U>(v: Box + 'static>) -> Box { + | - help: consider adding an explicit lifetime bound...: `T: 'static` +LL | // oh dear! +LL | Box::new(B(&*v)) as Box + | ^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds... + | +note: ...that is required by this bound + --> $DIR/regions-close-object-into-object-5.rs:13:17 + | +LL | struct B<'a, T: 'a>(&'a (A + 'a)); + | ^^ + +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/regions-close-object-into-object-5.rs:21:5 + | +LL | fn f<'a, T, U>(v: Box + 'static>) -> Box { + | - help: consider adding an explicit lifetime bound...: `T: 'static` +LL | // oh dear! +LL | Box::new(B(&*v)) as Box + | ^^^^^^^^^^^^^^^^ ...so that the type `B<'_, T>` will meet its required lifetime bounds + +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/regions-close-object-into-object-5.rs:21:14 + | +LL | fn f<'a, T, U>(v: Box + 'static>) -> Box { + | - help: consider adding an explicit lifetime bound...: `T: 'static` +LL | // oh dear! +LL | Box::new(B(&*v)) as Box + | ^ ...so that the type `T` will meet its required lifetime bounds... + | +note: ...that is required by this bound + --> $DIR/regions-close-object-into-object-5.rs:13:17 + | +LL | struct B<'a, T: 'a>(&'a (A + 'a)); + | ^^ + +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/regions-close-object-into-object-5.rs:21:14 + | +LL | fn f<'a, T, U>(v: Box + 'static>) -> Box { + | - help: consider adding an explicit lifetime bound...: `T: 'static` +LL | // oh dear! +LL | Box::new(B(&*v)) as Box + | ^^^^^^ ...so that the type `T` will meet its required lifetime bounds... + | +note: ...that is required by this bound + --> $DIR/regions-close-object-into-object-5.rs:13:17 + | +LL | struct B<'a, T: 'a>(&'a (A + 'a)); + | ^^ + +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/regions-close-object-into-object-5.rs:21:16 + | +LL | fn f<'a, T, U>(v: Box + 'static>) -> Box { + | - help: consider adding an explicit lifetime bound...: `T: 'static` +LL | // oh dear! +LL | Box::new(B(&*v)) as Box + | ^^^ ...so that the reference type `&dyn A` does not outlive the data it points at + +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/regions-close-object-into-object-5.rs:21:16 + | +LL | fn f<'a, T, U>(v: Box + 'static>) -> Box { + | - help: consider adding an explicit lifetime bound...: `T: 'static` +LL | // oh dear! +LL | Box::new(B(&*v)) as Box + | ^^^ ...so that the type `(dyn A + 'static)` is not borrowed for too long + +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/regions-close-object-into-object-5.rs:21:16 + | +LL | fn f<'a, T, U>(v: Box + 'static>) -> Box { + | - help: consider adding an explicit lifetime bound...: `T: 'static` +LL | // oh dear! +LL | Box::new(B(&*v)) as Box + | ^^^ ...so that the type `(dyn A + 'static)` is not borrowed for too long + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0310`. diff --git a/src/test/ui/regions/regions-close-object-into-object-5.nll.stderr b/src/test/ui/regions/regions-close-object-into-object-5.nll.stderr index 54302cc6dca..f4e3809e916 100644 --- a/src/test/ui/regions/regions-close-object-into-object-5.nll.stderr +++ b/src/test/ui/regions/regions-close-object-into-object-5.nll.stderr @@ -1,5 +1,5 @@ error[E0310]: the parameter type `T` may not live long enough - --> $DIR/regions-close-object-into-object-5.rs:17:5 + --> $DIR/regions-close-object-into-object-5.rs:21:5 | LL | fn f<'a, T, U>(v: Box + 'static>) -> Box { | - help: consider adding an explicit lifetime bound...: `T: 'static` @@ -8,7 +8,7 @@ LL | Box::new(B(&*v)) as Box | ^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds error[E0310]: the parameter type `T` may not live long enough - --> $DIR/regions-close-object-into-object-5.rs:17:5 + --> $DIR/regions-close-object-into-object-5.rs:21:5 | LL | fn f<'a, T, U>(v: Box + 'static>) -> Box { | - help: consider adding an explicit lifetime bound...: `T: 'static` @@ -17,7 +17,7 @@ LL | Box::new(B(&*v)) as Box | ^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds error[E0310]: the parameter type `T` may not live long enough - --> $DIR/regions-close-object-into-object-5.rs:17:5 + --> $DIR/regions-close-object-into-object-5.rs:21:5 | LL | fn f<'a, T, U>(v: Box + 'static>) -> Box { | - help: consider adding an explicit lifetime bound...: `T: 'static` @@ -26,7 +26,7 @@ LL | Box::new(B(&*v)) as Box | ^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds error[E0515]: cannot return value referencing local data `*v` - --> $DIR/regions-close-object-into-object-5.rs:17:5 + --> $DIR/regions-close-object-into-object-5.rs:21:5 | LL | Box::new(B(&*v)) as Box | ^^^^^^^^^^^---^^^^^^^^^^^^^^^^ @@ -35,7 +35,7 @@ LL | Box::new(B(&*v)) as Box | returns a value referencing data owned by the current function error[E0310]: the parameter type `T` may not live long enough - --> $DIR/regions-close-object-into-object-5.rs:17:14 + --> $DIR/regions-close-object-into-object-5.rs:21:14 | LL | fn f<'a, T, U>(v: Box + 'static>) -> Box { | - help: consider adding an explicit lifetime bound...: `T: 'static` diff --git a/src/test/ui/regions/regions-close-object-into-object-5.rs b/src/test/ui/regions/regions-close-object-into-object-5.rs index 5471c375b49..0e5fec28d19 100644 --- a/src/test/ui/regions/regions-close-object-into-object-5.rs +++ b/src/test/ui/regions/regions-close-object-into-object-5.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + #![allow(warnings)] @@ -19,9 +23,10 @@ fn f<'a, T, U>(v: Box + 'static>) -> Box { //~| ERROR the parameter type `T` may not live long enough //~| ERROR the parameter type `T` may not live long enough //~| ERROR the parameter type `T` may not live long enough - //~| ERROR the parameter type `T` may not live long enough - //~| ERROR the parameter type `T` may not live long enough - //~| ERROR the parameter type `T` may not live long enough + //[base]~| ERROR the parameter type `T` may not live long enough + //[base]~| ERROR the parameter type `T` may not live long enough + //[base]~| ERROR the parameter type `T` may not live long enough + //[nll]~| ERROR cannot return value referencing local data `*v` [E0515] } fn main() {} diff --git a/src/test/ui/regions/regions-close-object-into-object-5.stderr b/src/test/ui/regions/regions-close-object-into-object-5.stderr deleted file mode 100644 index 512a7ab35fb..00000000000 --- a/src/test/ui/regions/regions-close-object-into-object-5.stderr +++ /dev/null @@ -1,84 +0,0 @@ -error[E0310]: the parameter type `T` may not live long enough - --> $DIR/regions-close-object-into-object-5.rs:17:5 - | -LL | fn f<'a, T, U>(v: Box + 'static>) -> Box { - | - help: consider adding an explicit lifetime bound...: `T: 'static` -LL | // oh dear! -LL | Box::new(B(&*v)) as Box - | ^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds... - | -note: ...that is required by this bound - --> $DIR/regions-close-object-into-object-5.rs:9:17 - | -LL | struct B<'a, T: 'a>(&'a (A + 'a)); - | ^^ - -error[E0310]: the parameter type `T` may not live long enough - --> $DIR/regions-close-object-into-object-5.rs:17:5 - | -LL | fn f<'a, T, U>(v: Box + 'static>) -> Box { - | - help: consider adding an explicit lifetime bound...: `T: 'static` -LL | // oh dear! -LL | Box::new(B(&*v)) as Box - | ^^^^^^^^^^^^^^^^ ...so that the type `B<'_, T>` will meet its required lifetime bounds - -error[E0310]: the parameter type `T` may not live long enough - --> $DIR/regions-close-object-into-object-5.rs:17:14 - | -LL | fn f<'a, T, U>(v: Box + 'static>) -> Box { - | - help: consider adding an explicit lifetime bound...: `T: 'static` -LL | // oh dear! -LL | Box::new(B(&*v)) as Box - | ^ ...so that the type `T` will meet its required lifetime bounds... - | -note: ...that is required by this bound - --> $DIR/regions-close-object-into-object-5.rs:9:17 - | -LL | struct B<'a, T: 'a>(&'a (A + 'a)); - | ^^ - -error[E0310]: the parameter type `T` may not live long enough - --> $DIR/regions-close-object-into-object-5.rs:17:14 - | -LL | fn f<'a, T, U>(v: Box + 'static>) -> Box { - | - help: consider adding an explicit lifetime bound...: `T: 'static` -LL | // oh dear! -LL | Box::new(B(&*v)) as Box - | ^^^^^^ ...so that the type `T` will meet its required lifetime bounds... - | -note: ...that is required by this bound - --> $DIR/regions-close-object-into-object-5.rs:9:17 - | -LL | struct B<'a, T: 'a>(&'a (A + 'a)); - | ^^ - -error[E0310]: the parameter type `T` may not live long enough - --> $DIR/regions-close-object-into-object-5.rs:17:16 - | -LL | fn f<'a, T, U>(v: Box + 'static>) -> Box { - | - help: consider adding an explicit lifetime bound...: `T: 'static` -LL | // oh dear! -LL | Box::new(B(&*v)) as Box - | ^^^ ...so that the reference type `&dyn A` does not outlive the data it points at - -error[E0310]: the parameter type `T` may not live long enough - --> $DIR/regions-close-object-into-object-5.rs:17:16 - | -LL | fn f<'a, T, U>(v: Box + 'static>) -> Box { - | - help: consider adding an explicit lifetime bound...: `T: 'static` -LL | // oh dear! -LL | Box::new(B(&*v)) as Box - | ^^^ ...so that the type `(dyn A + 'static)` is not borrowed for too long - -error[E0310]: the parameter type `T` may not live long enough - --> $DIR/regions-close-object-into-object-5.rs:17:16 - | -LL | fn f<'a, T, U>(v: Box + 'static>) -> Box { - | - help: consider adding an explicit lifetime bound...: `T: 'static` -LL | // oh dear! -LL | Box::new(B(&*v)) as Box - | ^^^ ...so that the type `(dyn A + 'static)` is not borrowed for too long - -error: aborting due to 7 previous errors - -For more information about this error, try `rustc --explain E0310`. diff --git a/src/test/ui/regions/regions-close-over-type-parameter-1.base.stderr b/src/test/ui/regions/regions-close-over-type-parameter-1.base.stderr new file mode 100644 index 00000000000..41dc03e86dd --- /dev/null +++ b/src/test/ui/regions/regions-close-over-type-parameter-1.base.stderr @@ -0,0 +1,20 @@ +error[E0310]: the parameter type `A` may not live long enough + --> $DIR/regions-close-over-type-parameter-1.rs:15:5 + | +LL | fn make_object1(v: A) -> Box { + | -- help: consider adding an explicit lifetime bound...: `A: 'static +` +LL | Box::new(v) as Box + | ^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds + +error[E0309]: the parameter type `A` may not live long enough + --> $DIR/regions-close-over-type-parameter-1.rs:24:5 + | +LL | fn make_object3<'a, 'b, A: SomeTrait + 'a>(v: A) -> Box { + | -- help: consider adding an explicit lifetime bound...: `A: 'b +` +LL | Box::new(v) as Box + | ^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0309, E0310. +For more information about an error, try `rustc --explain E0309`. diff --git a/src/test/ui/regions/regions-close-over-type-parameter-1.nll.stderr b/src/test/ui/regions/regions-close-over-type-parameter-1.nll.stderr index 063c3b19a19..41dc03e86dd 100644 --- a/src/test/ui/regions/regions-close-over-type-parameter-1.nll.stderr +++ b/src/test/ui/regions/regions-close-over-type-parameter-1.nll.stderr @@ -1,5 +1,5 @@ error[E0310]: the parameter type `A` may not live long enough - --> $DIR/regions-close-over-type-parameter-1.rs:12:5 + --> $DIR/regions-close-over-type-parameter-1.rs:15:5 | LL | fn make_object1(v: A) -> Box { | -- help: consider adding an explicit lifetime bound...: `A: 'static +` @@ -7,7 +7,7 @@ LL | Box::new(v) as Box | ^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds error[E0309]: the parameter type `A` may not live long enough - --> $DIR/regions-close-over-type-parameter-1.rs:21:5 + --> $DIR/regions-close-over-type-parameter-1.rs:24:5 | LL | fn make_object3<'a, 'b, A: SomeTrait + 'a>(v: A) -> Box { | -- help: consider adding an explicit lifetime bound...: `A: 'b +` diff --git a/src/test/ui/regions/regions-close-over-type-parameter-1.rs b/src/test/ui/regions/regions-close-over-type-parameter-1.rs index 52d18c5d7a6..cf425bcd4f3 100644 --- a/src/test/ui/regions/regions-close-over-type-parameter-1.rs +++ b/src/test/ui/regions/regions-close-over-type-parameter-1.rs @@ -2,6 +2,9 @@ // an object. This should yield errors unless `A` (and the object) // both have suitable bounds. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir trait SomeTrait { fn get(&self) -> isize; diff --git a/src/test/ui/regions/regions-close-over-type-parameter-1.stderr b/src/test/ui/regions/regions-close-over-type-parameter-1.stderr deleted file mode 100644 index 063c3b19a19..00000000000 --- a/src/test/ui/regions/regions-close-over-type-parameter-1.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0310]: the parameter type `A` may not live long enough - --> $DIR/regions-close-over-type-parameter-1.rs:12:5 - | -LL | fn make_object1(v: A) -> Box { - | -- help: consider adding an explicit lifetime bound...: `A: 'static +` -LL | Box::new(v) as Box - | ^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds - -error[E0309]: the parameter type `A` may not live long enough - --> $DIR/regions-close-over-type-parameter-1.rs:21:5 - | -LL | fn make_object3<'a, 'b, A: SomeTrait + 'a>(v: A) -> Box { - | -- help: consider adding an explicit lifetime bound...: `A: 'b +` -LL | Box::new(v) as Box - | ^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0309, E0310. -For more information about an error, try `rustc --explain E0309`. diff --git a/src/test/ui/regions/regions-close-over-type-parameter-multiple.base.stderr b/src/test/ui/regions/regions-close-over-type-parameter-multiple.base.stderr new file mode 100644 index 00000000000..171203897d7 --- /dev/null +++ b/src/test/ui/regions/regions-close-over-type-parameter-multiple.base.stderr @@ -0,0 +1,32 @@ +error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements + --> $DIR/regions-close-over-type-parameter-multiple.rs:23:5 + | +LL | Box::new(v) as Box + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: first, the lifetime cannot outlive the lifetime `'a` as defined here... + --> $DIR/regions-close-over-type-parameter-multiple.rs:21:20 + | +LL | fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box { + | ^^ +note: ...so that the declared lifetime parameter bounds are satisfied + --> $DIR/regions-close-over-type-parameter-multiple.rs:23:5 + | +LL | Box::new(v) as Box + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: but, the lifetime must be valid for the lifetime `'c` as defined here... + --> $DIR/regions-close-over-type-parameter-multiple.rs:21:26 + | +LL | fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box { + | ^^ +note: ...so that the types are compatible + --> $DIR/regions-close-over-type-parameter-multiple.rs:23:5 + | +LL | Box::new(v) as Box + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: expected `Box<(dyn SomeTrait + 'c)>` + found `Box` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/regions/regions-close-over-type-parameter-multiple.nll.stderr b/src/test/ui/regions/regions-close-over-type-parameter-multiple.nll.stderr index 25566742099..66459957ed4 100644 --- a/src/test/ui/regions/regions-close-over-type-parameter-multiple.nll.stderr +++ b/src/test/ui/regions/regions-close-over-type-parameter-multiple.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-close-over-type-parameter-multiple.rs:20:5 + --> $DIR/regions-close-over-type-parameter-multiple.rs:23:5 | LL | fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box { | -- -- lifetime `'c` defined here diff --git a/src/test/ui/regions/regions-close-over-type-parameter-multiple.rs b/src/test/ui/regions/regions-close-over-type-parameter-multiple.rs index fc7696e7e03..3d5f4e12665 100644 --- a/src/test/ui/regions/regions-close-over-type-parameter-multiple.rs +++ b/src/test/ui/regions/regions-close-over-type-parameter-multiple.rs @@ -1,6 +1,9 @@ // Various tests where we over type parameters with multiple lifetime // bounds. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir trait SomeTrait { fn get(&self) -> isize; } @@ -17,7 +20,9 @@ fn make_object_good2<'a,'b,A:SomeTrait+'a+'b>(v: A) -> Box { fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box { // A outlives 'a AND 'b...but not 'c. - Box::new(v) as Box //~ ERROR cannot infer an appropriate lifetime + Box::new(v) as Box + //[base]~^ ERROR cannot infer an appropriate lifetime + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/regions/regions-close-over-type-parameter-multiple.stderr b/src/test/ui/regions/regions-close-over-type-parameter-multiple.stderr deleted file mode 100644 index aa22fd96deb..00000000000 --- a/src/test/ui/regions/regions-close-over-type-parameter-multiple.stderr +++ /dev/null @@ -1,32 +0,0 @@ -error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements - --> $DIR/regions-close-over-type-parameter-multiple.rs:20:5 - | -LL | Box::new(v) as Box - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: first, the lifetime cannot outlive the lifetime `'a` as defined here... - --> $DIR/regions-close-over-type-parameter-multiple.rs:18:20 - | -LL | fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box { - | ^^ -note: ...so that the declared lifetime parameter bounds are satisfied - --> $DIR/regions-close-over-type-parameter-multiple.rs:20:5 - | -LL | Box::new(v) as Box - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: but, the lifetime must be valid for the lifetime `'c` as defined here... - --> $DIR/regions-close-over-type-parameter-multiple.rs:18:26 - | -LL | fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box { - | ^^ -note: ...so that the types are compatible - --> $DIR/regions-close-over-type-parameter-multiple.rs:20:5 - | -LL | Box::new(v) as Box - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: expected `Box<(dyn SomeTrait + 'c)>` - found `Box` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/regions/regions-close-param-into-object.base.stderr b/src/test/ui/regions/regions-close-param-into-object.base.stderr new file mode 100644 index 00000000000..7e135c65450 --- /dev/null +++ b/src/test/ui/regions/regions-close-param-into-object.base.stderr @@ -0,0 +1,40 @@ +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/regions-close-param-into-object.rs:10:5 + | +LL | fn p1(v: T) -> Box + | - help: consider adding an explicit lifetime bound...: `T: 'static` +... +LL | Box::new(v) + | ^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/regions-close-param-into-object.rs:16:5 + | +LL | fn p2(v: Box) -> Box + | - help: consider adding an explicit lifetime bound...: `T: 'static` +... +LL | Box::new(v) + | ^^^^^^^^^^^ ...so that the type `Box` will meet its required lifetime bounds + +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regions-close-param-into-object.rs:22:5 + | +LL | fn p3<'a,T>(v: T) -> Box + | - help: consider adding an explicit lifetime bound...: `T: 'a` +... +LL | Box::new(v) + | ^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds + +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regions-close-param-into-object.rs:28:5 + | +LL | fn p4<'a,T>(v: Box) -> Box + | - help: consider adding an explicit lifetime bound...: `T: 'a` +... +LL | Box::new(v) + | ^^^^^^^^^^^ ...so that the type `Box` will meet its required lifetime bounds + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0309, E0310. +For more information about an error, try `rustc --explain E0309`. diff --git a/src/test/ui/regions/regions-close-param-into-object.nll.stderr b/src/test/ui/regions/regions-close-param-into-object.nll.stderr index f0464e299bb..3fbc1022631 100644 --- a/src/test/ui/regions/regions-close-param-into-object.nll.stderr +++ b/src/test/ui/regions/regions-close-param-into-object.nll.stderr @@ -1,5 +1,5 @@ error[E0310]: the parameter type `T` may not live long enough - --> $DIR/regions-close-param-into-object.rs:6:5 + --> $DIR/regions-close-param-into-object.rs:10:5 | LL | fn p1(v: T) -> Box | - help: consider adding an explicit lifetime bound...: `T: 'static` @@ -8,7 +8,7 @@ LL | Box::new(v) | ^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds error[E0310]: the parameter type `T` may not live long enough - --> $DIR/regions-close-param-into-object.rs:12:5 + --> $DIR/regions-close-param-into-object.rs:16:5 | LL | fn p2(v: Box) -> Box | - help: consider adding an explicit lifetime bound...: `T: 'static` @@ -17,7 +17,7 @@ LL | Box::new(v) | ^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-close-param-into-object.rs:18:5 + --> $DIR/regions-close-param-into-object.rs:22:5 | LL | fn p3<'a,T>(v: T) -> Box | - help: consider adding an explicit lifetime bound...: `T: 'a` @@ -26,7 +26,7 @@ LL | Box::new(v) | ^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-close-param-into-object.rs:24:5 + --> $DIR/regions-close-param-into-object.rs:28:5 | LL | fn p4<'a,T>(v: Box) -> Box | - help: consider adding an explicit lifetime bound...: `T: 'a` diff --git a/src/test/ui/regions/regions-close-param-into-object.rs b/src/test/ui/regions/regions-close-param-into-object.rs index 2760e5eed95..aab3ad202e6 100644 --- a/src/test/ui/regions/regions-close-param-into-object.rs +++ b/src/test/ui/regions/regions-close-param-into-object.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait X { fn foo(&self) {} } fn p1(v: T) -> Box diff --git a/src/test/ui/regions/regions-close-param-into-object.stderr b/src/test/ui/regions/regions-close-param-into-object.stderr deleted file mode 100644 index 5c355bbb734..00000000000 --- a/src/test/ui/regions/regions-close-param-into-object.stderr +++ /dev/null @@ -1,40 +0,0 @@ -error[E0310]: the parameter type `T` may not live long enough - --> $DIR/regions-close-param-into-object.rs:6:5 - | -LL | fn p1(v: T) -> Box - | - help: consider adding an explicit lifetime bound...: `T: 'static` -... -LL | Box::new(v) - | ^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds - -error[E0310]: the parameter type `T` may not live long enough - --> $DIR/regions-close-param-into-object.rs:12:5 - | -LL | fn p2(v: Box) -> Box - | - help: consider adding an explicit lifetime bound...: `T: 'static` -... -LL | Box::new(v) - | ^^^^^^^^^^^ ...so that the type `Box` will meet its required lifetime bounds - -error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-close-param-into-object.rs:18:5 - | -LL | fn p3<'a,T>(v: T) -> Box - | - help: consider adding an explicit lifetime bound...: `T: 'a` -... -LL | Box::new(v) - | ^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds - -error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-close-param-into-object.rs:24:5 - | -LL | fn p4<'a,T>(v: Box) -> Box - | - help: consider adding an explicit lifetime bound...: `T: 'a` -... -LL | Box::new(v) - | ^^^^^^^^^^^ ...so that the type `Box` will meet its required lifetime bounds - -error: aborting due to 4 previous errors - -Some errors have detailed explanations: E0309, E0310. -For more information about an error, try `rustc --explain E0309`. diff --git a/src/test/ui/regions/regions-creating-enums3.base.stderr b/src/test/ui/regions/regions-creating-enums3.base.stderr new file mode 100644 index 00000000000..68a7b473695 --- /dev/null +++ b/src/test/ui/regions/regions-creating-enums3.base.stderr @@ -0,0 +1,13 @@ +error[E0623]: lifetime mismatch + --> $DIR/regions-creating-enums3.rs:11:5 + | +LL | fn mk_add_bad1<'a,'b>(x: &'a Ast<'a>, y: &'b Ast<'b>) -> Ast<'a> { + | ----------- ------- + | | + | this parameter and the return type are declared with different lifetimes... +LL | Ast::Add(x, y) + | ^^^^^^^^^^^^^^ ...but data from `y` is returned here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/regions/regions-creating-enums3.nll.stderr b/src/test/ui/regions/regions-creating-enums3.nll.stderr index 41d609b56d2..8334dc77687 100644 --- a/src/test/ui/regions/regions-creating-enums3.nll.stderr +++ b/src/test/ui/regions/regions-creating-enums3.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-creating-enums3.rs:7:5 + --> $DIR/regions-creating-enums3.rs:11:5 | LL | fn mk_add_bad1<'a,'b>(x: &'a Ast<'a>, y: &'b Ast<'b>) -> Ast<'a> { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/regions/regions-creating-enums3.rs b/src/test/ui/regions/regions-creating-enums3.rs index 3da0cb4cb81..dcea761d33f 100644 --- a/src/test/ui/regions/regions-creating-enums3.rs +++ b/src/test/ui/regions/regions-creating-enums3.rs @@ -1,10 +1,16 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + enum Ast<'a> { Num(usize), Add(&'a Ast<'a>, &'a Ast<'a>) } fn mk_add_bad1<'a,'b>(x: &'a Ast<'a>, y: &'b Ast<'b>) -> Ast<'a> { - Ast::Add(x, y) //~ ERROR lifetime mismatch [E0623] + Ast::Add(x, y) + //[base]~^ ERROR lifetime mismatch [E0623] + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/regions/regions-creating-enums3.stderr b/src/test/ui/regions/regions-creating-enums3.stderr deleted file mode 100644 index 2fc1fc3f681..00000000000 --- a/src/test/ui/regions/regions-creating-enums3.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0623]: lifetime mismatch - --> $DIR/regions-creating-enums3.rs:7:5 - | -LL | fn mk_add_bad1<'a,'b>(x: &'a Ast<'a>, y: &'b Ast<'b>) -> Ast<'a> { - | ----------- ------- - | | - | this parameter and the return type are declared with different lifetimes... -LL | Ast::Add(x, y) - | ^^^^^^^^^^^^^^ ...but data from `y` is returned here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/regions/regions-creating-enums4.base.stderr b/src/test/ui/regions/regions-creating-enums4.base.stderr new file mode 100644 index 00000000000..445a4291f27 --- /dev/null +++ b/src/test/ui/regions/regions-creating-enums4.base.stderr @@ -0,0 +1,34 @@ +error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements + --> $DIR/regions-creating-enums4.rs:11:5 + | +LL | Ast::Add(x, y) + | ^^^^^^^^ + | +note: first, the lifetime cannot outlive the lifetime `'a` as defined here... + --> $DIR/regions-creating-enums4.rs:10:16 + | +LL | fn mk_add_bad2<'a,'b>(x: &'a Ast<'a>, y: &'a Ast<'a>, z: &Ast) -> Ast<'b> { + | ^^ +note: ...so that the expression is assignable + --> $DIR/regions-creating-enums4.rs:11:14 + | +LL | Ast::Add(x, y) + | ^ + = note: expected `&Ast<'_>` + found `&Ast<'a>` +note: but, the lifetime must be valid for the lifetime `'b` as defined here... + --> $DIR/regions-creating-enums4.rs:10:19 + | +LL | fn mk_add_bad2<'a,'b>(x: &'a Ast<'a>, y: &'a Ast<'a>, z: &Ast) -> Ast<'b> { + | ^^ +note: ...so that the types are compatible + --> $DIR/regions-creating-enums4.rs:11:5 + | +LL | Ast::Add(x, y) + | ^^^^^^^^^^^^^^ + = note: expected `Ast<'b>` + found `Ast<'_>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/regions/regions-creating-enums4.nll.stderr b/src/test/ui/regions/regions-creating-enums4.nll.stderr index 91cf57e099d..e215c63d39d 100644 --- a/src/test/ui/regions/regions-creating-enums4.nll.stderr +++ b/src/test/ui/regions/regions-creating-enums4.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-creating-enums4.rs:7:5 + --> $DIR/regions-creating-enums4.rs:11:5 | LL | fn mk_add_bad2<'a,'b>(x: &'a Ast<'a>, y: &'a Ast<'a>, z: &Ast) -> Ast<'b> { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/regions/regions-creating-enums4.rs b/src/test/ui/regions/regions-creating-enums4.rs index 11d3d831151..18bd592b1c3 100644 --- a/src/test/ui/regions/regions-creating-enums4.rs +++ b/src/test/ui/regions/regions-creating-enums4.rs @@ -1,10 +1,16 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + enum Ast<'a> { Num(usize), Add(&'a Ast<'a>, &'a Ast<'a>) } fn mk_add_bad2<'a,'b>(x: &'a Ast<'a>, y: &'a Ast<'a>, z: &Ast) -> Ast<'b> { - Ast::Add(x, y) //~ ERROR cannot infer + Ast::Add(x, y) + //[base]~^ ERROR cannot infer + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/regions/regions-creating-enums4.stderr b/src/test/ui/regions/regions-creating-enums4.stderr deleted file mode 100644 index 8b1b90f5b1a..00000000000 --- a/src/test/ui/regions/regions-creating-enums4.stderr +++ /dev/null @@ -1,34 +0,0 @@ -error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements - --> $DIR/regions-creating-enums4.rs:7:5 - | -LL | Ast::Add(x, y) - | ^^^^^^^^ - | -note: first, the lifetime cannot outlive the lifetime `'a` as defined here... - --> $DIR/regions-creating-enums4.rs:6:16 - | -LL | fn mk_add_bad2<'a,'b>(x: &'a Ast<'a>, y: &'a Ast<'a>, z: &Ast) -> Ast<'b> { - | ^^ -note: ...so that the expression is assignable - --> $DIR/regions-creating-enums4.rs:7:14 - | -LL | Ast::Add(x, y) - | ^ - = note: expected `&Ast<'_>` - found `&Ast<'a>` -note: but, the lifetime must be valid for the lifetime `'b` as defined here... - --> $DIR/regions-creating-enums4.rs:6:19 - | -LL | fn mk_add_bad2<'a,'b>(x: &'a Ast<'a>, y: &'a Ast<'a>, z: &Ast) -> Ast<'b> { - | ^^ -note: ...so that the types are compatible - --> $DIR/regions-creating-enums4.rs:7:5 - | -LL | Ast::Add(x, y) - | ^^^^^^^^^^^^^^ - = note: expected `Ast<'b>` - found `Ast<'_>` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/regions/regions-early-bound-error-method.base.stderr b/src/test/ui/regions/regions-early-bound-error-method.base.stderr new file mode 100644 index 00000000000..9e1f2b0e5bd --- /dev/null +++ b/src/test/ui/regions/regions-early-bound-error-method.base.stderr @@ -0,0 +1,20 @@ +error[E0312]: lifetime of reference outlives lifetime of borrowed content... + --> $DIR/regions-early-bound-error-method.rs:24:9 + | +LL | g2.get() + | ^^^^^^^^ + | +note: ...the reference is valid for the lifetime `'a` as defined here... + --> $DIR/regions-early-bound-error-method.rs:22:6 + | +LL | impl<'a> Box<'a> { + | ^^ +note: ...but the borrowed content is only valid for the lifetime `'b` as defined here + --> $DIR/regions-early-bound-error-method.rs:23:11 + | +LL | fn or<'b,G:GetRef<'b>>(&self, g2: G) -> &'a isize { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0312`. diff --git a/src/test/ui/regions/regions-early-bound-error-method.nll.stderr b/src/test/ui/regions/regions-early-bound-error-method.nll.stderr index 7f10c051f29..98389ed0ca5 100644 --- a/src/test/ui/regions/regions-early-bound-error-method.nll.stderr +++ b/src/test/ui/regions/regions-early-bound-error-method.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-early-bound-error-method.rs:20:9 + --> $DIR/regions-early-bound-error-method.rs:24:9 | LL | impl<'a> Box<'a> { | -- lifetime `'a` defined here diff --git a/src/test/ui/regions/regions-early-bound-error-method.rs b/src/test/ui/regions/regions-early-bound-error-method.rs index 32428143ef9..44ee19fa898 100644 --- a/src/test/ui/regions/regions-early-bound-error-method.rs +++ b/src/test/ui/regions/regions-early-bound-error-method.rs @@ -1,6 +1,10 @@ // Tests that you can use a fn lifetime parameter as part of // the value for a type parameter in a bound. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait GetRef<'a> { fn get(&self) -> &'a isize; } @@ -18,7 +22,8 @@ impl<'a> GetRef<'a> for Box<'a> { impl<'a> Box<'a> { fn or<'b,G:GetRef<'b>>(&self, g2: G) -> &'a isize { g2.get() - //~^ ERROR E0312 + //[base]~^ ERROR E0312 + //[nll]~^^ ERROR lifetime may not live long enough } } diff --git a/src/test/ui/regions/regions-early-bound-error-method.stderr b/src/test/ui/regions/regions-early-bound-error-method.stderr deleted file mode 100644 index 99a5f0ce4cd..00000000000 --- a/src/test/ui/regions/regions-early-bound-error-method.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0312]: lifetime of reference outlives lifetime of borrowed content... - --> $DIR/regions-early-bound-error-method.rs:20:9 - | -LL | g2.get() - | ^^^^^^^^ - | -note: ...the reference is valid for the lifetime `'a` as defined here... - --> $DIR/regions-early-bound-error-method.rs:18:6 - | -LL | impl<'a> Box<'a> { - | ^^ -note: ...but the borrowed content is only valid for the lifetime `'b` as defined here - --> $DIR/regions-early-bound-error-method.rs:19:11 - | -LL | fn or<'b,G:GetRef<'b>>(&self, g2: G) -> &'a isize { - | ^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0312`. diff --git a/src/test/ui/regions/regions-early-bound-error.base.stderr b/src/test/ui/regions/regions-early-bound-error.base.stderr new file mode 100644 index 00000000000..e1b60536d29 --- /dev/null +++ b/src/test/ui/regions/regions-early-bound-error.base.stderr @@ -0,0 +1,20 @@ +error[E0312]: lifetime of reference outlives lifetime of borrowed content... + --> $DIR/regions-early-bound-error.rs:23:5 + | +LL | g1.get() + | ^^^^^^^^ + | +note: ...the reference is valid for the lifetime `'b` as defined here... + --> $DIR/regions-early-bound-error.rs:22:11 + | +LL | fn get<'a,'b,G:GetRef<'a, isize>>(g1: G, b: &'b isize) -> &'b isize { + | ^^ +note: ...but the borrowed content is only valid for the lifetime `'a` as defined here + --> $DIR/regions-early-bound-error.rs:22:8 + | +LL | fn get<'a,'b,G:GetRef<'a, isize>>(g1: G, b: &'b isize) -> &'b isize { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0312`. diff --git a/src/test/ui/regions/regions-early-bound-error.nll.stderr b/src/test/ui/regions/regions-early-bound-error.nll.stderr index eb4cd5ca72e..f57249e4e8f 100644 --- a/src/test/ui/regions/regions-early-bound-error.nll.stderr +++ b/src/test/ui/regions/regions-early-bound-error.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-early-bound-error.rs:19:5 + --> $DIR/regions-early-bound-error.rs:23:5 | LL | fn get<'a,'b,G:GetRef<'a, isize>>(g1: G, b: &'b isize) -> &'b isize { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/regions/regions-early-bound-error.rs b/src/test/ui/regions/regions-early-bound-error.rs index 78dad4f2649..372596cd5f4 100644 --- a/src/test/ui/regions/regions-early-bound-error.rs +++ b/src/test/ui/regions/regions-early-bound-error.rs @@ -1,6 +1,10 @@ // Tests that you can use a fn lifetime parameter as part of // the value for a type parameter in a bound. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait GetRef<'a, T> { fn get(&self) -> &'a T; } @@ -17,7 +21,8 @@ impl<'a,T:Clone> GetRef<'a,T> for Box<'a,T> { fn get<'a,'b,G:GetRef<'a, isize>>(g1: G, b: &'b isize) -> &'b isize { g1.get() - //~^ ERROR E0312 + //[base]~^ ERROR E0312 + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/regions/regions-early-bound-error.stderr b/src/test/ui/regions/regions-early-bound-error.stderr deleted file mode 100644 index df9e979eacf..00000000000 --- a/src/test/ui/regions/regions-early-bound-error.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0312]: lifetime of reference outlives lifetime of borrowed content... - --> $DIR/regions-early-bound-error.rs:19:5 - | -LL | g1.get() - | ^^^^^^^^ - | -note: ...the reference is valid for the lifetime `'b` as defined here... - --> $DIR/regions-early-bound-error.rs:18:11 - | -LL | fn get<'a,'b,G:GetRef<'a, isize>>(g1: G, b: &'b isize) -> &'b isize { - | ^^ -note: ...but the borrowed content is only valid for the lifetime `'a` as defined here - --> $DIR/regions-early-bound-error.rs:18:8 - | -LL | fn get<'a,'b,G:GetRef<'a, isize>>(g1: G, b: &'b isize) -> &'b isize { - | ^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0312`. diff --git a/src/test/ui/regions/regions-fn-subtyping-return-static-fail.base.stderr b/src/test/ui/regions/regions-fn-subtyping-return-static-fail.base.stderr new file mode 100644 index 00000000000..2182d8f661f --- /dev/null +++ b/src/test/ui/regions/regions-fn-subtyping-return-static-fail.base.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/regions-fn-subtyping-return-static-fail.rs:52:12 + | +LL | want_G(baz); + | ^^^ one type is more general than the other + | + = note: expected fn pointer `for<'cx> fn(&'cx S) -> &'static S` + found fn pointer `for<'r> fn(&'r S) -> &'r S` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/regions/regions-fn-subtyping-return-static-fail.nll.stderr b/src/test/ui/regions/regions-fn-subtyping-return-static-fail.nll.stderr index c2956cd8958..0bca2cfbefd 100644 --- a/src/test/ui/regions/regions-fn-subtyping-return-static-fail.nll.stderr +++ b/src/test/ui/regions/regions-fn-subtyping-return-static-fail.nll.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/regions-fn-subtyping-return-static-fail.rs:48:5 + --> $DIR/regions-fn-subtyping-return-static-fail.rs:52:5 | LL | want_G(baz); | ^^^^^^^^^^^ one type is more general than the other diff --git a/src/test/ui/regions/regions-fn-subtyping-return-static-fail.rs b/src/test/ui/regions/regions-fn-subtyping-return-static-fail.rs index 539221b5a04..05c6ac0cb1a 100644 --- a/src/test/ui/regions/regions-fn-subtyping-return-static-fail.rs +++ b/src/test/ui/regions/regions-fn-subtyping-return-static-fail.rs @@ -6,6 +6,10 @@ // This can safely be considered to be an instance of `F` because all // lifetimes are sublifetimes of 'static. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + #![allow(dead_code)] #![allow(unused_variables)] diff --git a/src/test/ui/regions/regions-fn-subtyping-return-static-fail.stderr b/src/test/ui/regions/regions-fn-subtyping-return-static-fail.stderr deleted file mode 100644 index c9ce936c7d4..00000000000 --- a/src/test/ui/regions/regions-fn-subtyping-return-static-fail.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/regions-fn-subtyping-return-static-fail.rs:48:12 - | -LL | want_G(baz); - | ^^^ one type is more general than the other - | - = note: expected fn pointer `for<'cx> fn(&'cx S) -> &'static S` - found fn pointer `for<'r> fn(&'r S) -> &'r S` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/regions/regions-free-region-ordering-callee.base.stderr b/src/test/ui/regions/regions-free-region-ordering-callee.base.stderr new file mode 100644 index 00000000000..ae6d95dd469 --- /dev/null +++ b/src/test/ui/regions/regions-free-region-ordering-callee.base.stderr @@ -0,0 +1,25 @@ +error[E0623]: lifetime mismatch + --> $DIR/regions-free-region-ordering-callee.rs:17:5 + | +LL | fn ordering2<'a, 'b>(x: &'a &'b usize, y: &'a usize) -> &'b usize { + | ------------- --------- + | | + | this parameter and the return type are declared with different lifetimes... +LL | // However, it is not safe to assume that 'b <= 'a +LL | &*y + | ^^^ ...but data from `x` is returned here + +error[E0623]: lifetime mismatch + --> $DIR/regions-free-region-ordering-callee.rs:24:24 + | +LL | fn ordering3<'a, 'b>(x: &'a usize, y: &'b usize) -> &'a &'b usize { + | --------- ------------- + | | + | this parameter and the return type are declared with different lifetimes... +LL | // Do not infer an ordering from the return value. +LL | let z: &'b usize = &*x; + | ^^^ ...but data from `x` is returned here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/regions/regions-free-region-ordering-callee.nll.stderr b/src/test/ui/regions/regions-free-region-ordering-callee.nll.stderr index f61f068a486..7dfff2bb060 100644 --- a/src/test/ui/regions/regions-free-region-ordering-callee.nll.stderr +++ b/src/test/ui/regions/regions-free-region-ordering-callee.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-free-region-ordering-callee.rs:13:5 + --> $DIR/regions-free-region-ordering-callee.rs:17:5 | LL | fn ordering2<'a, 'b>(x: &'a &'b usize, y: &'a usize) -> &'b usize { | -- -- lifetime `'b` defined here @@ -12,7 +12,7 @@ LL | &*y = help: consider adding the following bound: `'a: 'b` error: lifetime may not live long enough - --> $DIR/regions-free-region-ordering-callee.rs:18:12 + --> $DIR/regions-free-region-ordering-callee.rs:24:12 | LL | fn ordering3<'a, 'b>(x: &'a usize, y: &'b usize) -> &'a &'b usize { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/regions/regions-free-region-ordering-callee.rs b/src/test/ui/regions/regions-free-region-ordering-callee.rs index ee9a977a74f..eca863f2e79 100644 --- a/src/test/ui/regions/regions-free-region-ordering-callee.rs +++ b/src/test/ui/regions/regions-free-region-ordering-callee.rs @@ -2,6 +2,10 @@ // that appear in their parameter list. See also // regions-free-region-ordering-caller.rs +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn ordering1<'a, 'b>(x: &'a &'b usize) -> &'a usize { // It is safe to assume that 'a <= 'b due to the type of x let y: &'b usize = &**x; @@ -10,13 +14,16 @@ fn ordering1<'a, 'b>(x: &'a &'b usize) -> &'a usize { fn ordering2<'a, 'b>(x: &'a &'b usize, y: &'a usize) -> &'b usize { // However, it is not safe to assume that 'b <= 'a - &*y //~ ERROR lifetime mismatch [E0623] + &*y + //[base]~^ ERROR lifetime mismatch [E0623] + //[nll]~^^ ERROR lifetime may not live long enough } fn ordering3<'a, 'b>(x: &'a usize, y: &'b usize) -> &'a &'b usize { // Do not infer an ordering from the return value. let z: &'b usize = &*x; - //~^ ERROR lifetime mismatch [E0623] + //[base]~^ ERROR lifetime mismatch [E0623] + //[nll]~^^ ERROR lifetime may not live long enough panic!(); } diff --git a/src/test/ui/regions/regions-free-region-ordering-callee.stderr b/src/test/ui/regions/regions-free-region-ordering-callee.stderr deleted file mode 100644 index 4648bf046bc..00000000000 --- a/src/test/ui/regions/regions-free-region-ordering-callee.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0623]: lifetime mismatch - --> $DIR/regions-free-region-ordering-callee.rs:13:5 - | -LL | fn ordering2<'a, 'b>(x: &'a &'b usize, y: &'a usize) -> &'b usize { - | ------------- --------- - | | - | this parameter and the return type are declared with different lifetimes... -LL | // However, it is not safe to assume that 'b <= 'a -LL | &*y - | ^^^ ...but data from `x` is returned here - -error[E0623]: lifetime mismatch - --> $DIR/regions-free-region-ordering-callee.rs:18:24 - | -LL | fn ordering3<'a, 'b>(x: &'a usize, y: &'b usize) -> &'a &'b usize { - | --------- ------------- - | | - | this parameter and the return type are declared with different lifetimes... -LL | // Do not infer an ordering from the return value. -LL | let z: &'b usize = &*x; - | ^^^ ...but data from `x` is returned here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/regions/regions-free-region-ordering-incorrect.base.stderr b/src/test/ui/regions/regions-free-region-ordering-incorrect.base.stderr new file mode 100644 index 00000000000..eb4ffce89a3 --- /dev/null +++ b/src/test/ui/regions/regions-free-region-ordering-incorrect.base.stderr @@ -0,0 +1,33 @@ +error[E0495]: cannot infer an appropriate lifetime for borrow expression due to conflicting requirements + --> $DIR/regions-free-region-ordering-incorrect.rs:21:21 + | +LL | None => &self.val + | ^^^^^^^^^ + | +note: first, the lifetime cannot outlive the lifetime `'a` as defined here... + --> $DIR/regions-free-region-ordering-incorrect.rs:18:12 + | +LL | fn get<'a>(&'a self) -> &'b T { + | ^^ +note: ...so that reference does not outlive borrowed content + --> $DIR/regions-free-region-ordering-incorrect.rs:21:21 + | +LL | None => &self.val + | ^^^^^^^^^ +note: but, the lifetime must be valid for the lifetime `'b` as defined here... + --> $DIR/regions-free-region-ordering-incorrect.rs:17:6 + | +LL | impl<'b, T> Node<'b, T> { + | ^^ +note: ...so that reference does not outlive borrowed content + --> $DIR/regions-free-region-ordering-incorrect.rs:19:9 + | +LL | / match self.next { +LL | | Some(ref next) => next.get(), +LL | | None => &self.val +LL | | } + | |_________^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/regions/regions-free-region-ordering-incorrect.nll.stderr b/src/test/ui/regions/regions-free-region-ordering-incorrect.nll.stderr index f7c75033c04..336cfd3e6c5 100644 --- a/src/test/ui/regions/regions-free-region-ordering-incorrect.nll.stderr +++ b/src/test/ui/regions/regions-free-region-ordering-incorrect.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-free-region-ordering-incorrect.rs:15:9 + --> $DIR/regions-free-region-ordering-incorrect.rs:19:9 | LL | impl<'b, T> Node<'b, T> { | -- lifetime `'b` defined here diff --git a/src/test/ui/regions/regions-free-region-ordering-incorrect.rs b/src/test/ui/regions/regions-free-region-ordering-incorrect.rs index 65e3f52609e..43427d13ffa 100644 --- a/src/test/ui/regions/regions-free-region-ordering-incorrect.rs +++ b/src/test/ui/regions/regions-free-region-ordering-incorrect.rs @@ -5,6 +5,10 @@ // // This test began its life as a test for issue #4325. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Node<'b, T: 'b> { val: T, next: Option<&'b Node<'b, T>> @@ -12,9 +16,9 @@ struct Node<'b, T: 'b> { impl<'b, T> Node<'b, T> { fn get<'a>(&'a self) -> &'b T { - match self.next { + match self.next { //[nll]~ ERROR lifetime may not live long enough Some(ref next) => next.get(), - None => &self.val //~ ERROR cannot infer + None => &self.val //[base]~ ERROR cannot infer } } } diff --git a/src/test/ui/regions/regions-free-region-ordering-incorrect.stderr b/src/test/ui/regions/regions-free-region-ordering-incorrect.stderr deleted file mode 100644 index b0a8f4af397..00000000000 --- a/src/test/ui/regions/regions-free-region-ordering-incorrect.stderr +++ /dev/null @@ -1,33 +0,0 @@ -error[E0495]: cannot infer an appropriate lifetime for borrow expression due to conflicting requirements - --> $DIR/regions-free-region-ordering-incorrect.rs:17:21 - | -LL | None => &self.val - | ^^^^^^^^^ - | -note: first, the lifetime cannot outlive the lifetime `'a` as defined here... - --> $DIR/regions-free-region-ordering-incorrect.rs:14:12 - | -LL | fn get<'a>(&'a self) -> &'b T { - | ^^ -note: ...so that reference does not outlive borrowed content - --> $DIR/regions-free-region-ordering-incorrect.rs:17:21 - | -LL | None => &self.val - | ^^^^^^^^^ -note: but, the lifetime must be valid for the lifetime `'b` as defined here... - --> $DIR/regions-free-region-ordering-incorrect.rs:13:6 - | -LL | impl<'b, T> Node<'b, T> { - | ^^ -note: ...so that reference does not outlive borrowed content - --> $DIR/regions-free-region-ordering-incorrect.rs:15:9 - | -LL | / match self.next { -LL | | Some(ref next) => next.get(), -LL | | None => &self.val -LL | | } - | |_________^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/regions/regions-implied-bounds-projection-gap-1.base.stderr b/src/test/ui/regions/regions-implied-bounds-projection-gap-1.base.stderr new file mode 100644 index 00000000000..ef68674a18f --- /dev/null +++ b/src/test/ui/regions/regions-implied-bounds-projection-gap-1.base.stderr @@ -0,0 +1,12 @@ +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regions-implied-bounds-projection-gap-1.rs:20:10 + | +LL | fn func<'x, T:Trait1<'x>>(t: &'x T::Foo) + | -- help: consider adding an explicit lifetime bound...: `T: 'x +` +LL | { +LL | wf::<&'x T>(); + | ^^^^^ ...so that the reference type `&'x T` does not outlive the data it points at + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0309`. diff --git a/src/test/ui/regions/regions-implied-bounds-projection-gap-1.nll.stderr b/src/test/ui/regions/regions-implied-bounds-projection-gap-1.nll.stderr index 0e1db8acf1f..6d63de6d6bd 100644 --- a/src/test/ui/regions/regions-implied-bounds-projection-gap-1.nll.stderr +++ b/src/test/ui/regions/regions-implied-bounds-projection-gap-1.nll.stderr @@ -1,5 +1,5 @@ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-implied-bounds-projection-gap-1.rs:16:5 + --> $DIR/regions-implied-bounds-projection-gap-1.rs:20:5 | LL | fn func<'x, T:Trait1<'x>>(t: &'x T::Foo) | -- help: consider adding an explicit lifetime bound...: `T: 'x +` diff --git a/src/test/ui/regions/regions-implied-bounds-projection-gap-1.rs b/src/test/ui/regions/regions-implied-bounds-projection-gap-1.rs index 38fc9c462da..f11fc207b91 100644 --- a/src/test/ui/regions/regions-implied-bounds-projection-gap-1.rs +++ b/src/test/ui/regions/regions-implied-bounds-projection-gap-1.rs @@ -3,6 +3,10 @@ // there might be other ways for the caller of `func` to show that // `T::Foo: 'x` holds (e.g., where-clause). +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait Trait1<'x> { type Foo; } diff --git a/src/test/ui/regions/regions-implied-bounds-projection-gap-1.stderr b/src/test/ui/regions/regions-implied-bounds-projection-gap-1.stderr deleted file mode 100644 index ea59ea11a14..00000000000 --- a/src/test/ui/regions/regions-implied-bounds-projection-gap-1.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-implied-bounds-projection-gap-1.rs:16:10 - | -LL | fn func<'x, T:Trait1<'x>>(t: &'x T::Foo) - | -- help: consider adding an explicit lifetime bound...: `T: 'x +` -LL | { -LL | wf::<&'x T>(); - | ^^^^^ ...so that the reference type `&'x T` does not outlive the data it points at - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0309`. diff --git a/src/test/ui/regions/regions-infer-bound-from-trait-self.base.stderr b/src/test/ui/regions/regions-infer-bound-from-trait-self.base.stderr new file mode 100644 index 00000000000..faa638aa281 --- /dev/null +++ b/src/test/ui/regions/regions-infer-bound-from-trait-self.base.stderr @@ -0,0 +1,17 @@ +error[E0309]: the parameter type `Self` may not live long enough + --> $DIR/regions-infer-bound-from-trait-self.rs:50:9 + | +LL | check_bound(x, self) + | ^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `Self: 'a`... + = note: ...so that the type `Self` will meet its required lifetime bounds... +note: ...that is required by this bound + --> $DIR/regions-infer-bound-from-trait-self.rs:16:21 + | +LL | fn check_bound<'a,A:'a>(x: Inv<'a>, a: A) { } + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0309`. diff --git a/src/test/ui/regions/regions-infer-bound-from-trait-self.nll.stderr b/src/test/ui/regions/regions-infer-bound-from-trait-self.nll.stderr index e88f79a3a8c..9c886c42c72 100644 --- a/src/test/ui/regions/regions-infer-bound-from-trait-self.nll.stderr +++ b/src/test/ui/regions/regions-infer-bound-from-trait-self.nll.stderr @@ -1,5 +1,5 @@ error[E0309]: the parameter type `Self` may not live long enough - --> $DIR/regions-infer-bound-from-trait-self.rs:46:9 + --> $DIR/regions-infer-bound-from-trait-self.rs:50:9 | LL | check_bound(x, self) | ^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/regions/regions-infer-bound-from-trait-self.rs b/src/test/ui/regions/regions-infer-bound-from-trait-self.rs index d15bfffe9d9..ef8be05b2d2 100644 --- a/src/test/ui/regions/regions-infer-bound-from-trait-self.rs +++ b/src/test/ui/regions/regions-infer-bound-from-trait-self.rs @@ -1,6 +1,10 @@ // Test that we can derive lifetime bounds on `Self` from trait // inheritance. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait Static : 'static { } trait Is<'a> : 'a { } diff --git a/src/test/ui/regions/regions-infer-bound-from-trait-self.stderr b/src/test/ui/regions/regions-infer-bound-from-trait-self.stderr deleted file mode 100644 index 97a3947bc0a..00000000000 --- a/src/test/ui/regions/regions-infer-bound-from-trait-self.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0309]: the parameter type `Self` may not live long enough - --> $DIR/regions-infer-bound-from-trait-self.rs:46:9 - | -LL | check_bound(x, self) - | ^^^^^^^^^^^ - | - = help: consider adding an explicit lifetime bound `Self: 'a`... - = note: ...so that the type `Self` will meet its required lifetime bounds... -note: ...that is required by this bound - --> $DIR/regions-infer-bound-from-trait-self.rs:12:21 - | -LL | fn check_bound<'a,A:'a>(x: Inv<'a>, a: A) { } - | ^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0309`. diff --git a/src/test/ui/regions/regions-infer-bound-from-trait.base.stderr b/src/test/ui/regions/regions-infer-bound-from-trait.base.stderr new file mode 100644 index 00000000000..6a7e8ba1347 --- /dev/null +++ b/src/test/ui/regions/regions-infer-bound-from-trait.base.stderr @@ -0,0 +1,31 @@ +error[E0309]: the parameter type `A` may not live long enough + --> $DIR/regions-infer-bound-from-trait.rs:37:5 + | +LL | fn bar1<'a,A>(x: Inv<'a>, a: A) { + | - help: consider adding an explicit lifetime bound...: `A: 'a` +LL | check_bound(x, a) + | ^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds... + | +note: ...that is required by this bound + --> $DIR/regions-infer-bound-from-trait.rs:16:21 + | +LL | fn check_bound<'a,A:'a>(x: Inv<'a>, a: A) { } + | ^^ + +error[E0309]: the parameter type `A` may not live long enough + --> $DIR/regions-infer-bound-from-trait.rs:41:5 + | +LL | fn bar2<'a,'b,A:Is<'b>>(x: Inv<'a>, y: Inv<'b>, a: A) { + | -- help: consider adding an explicit lifetime bound...: `A: 'a +` +LL | check_bound(x, a) + | ^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds... + | +note: ...that is required by this bound + --> $DIR/regions-infer-bound-from-trait.rs:16:21 + | +LL | fn check_bound<'a,A:'a>(x: Inv<'a>, a: A) { } + | ^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0309`. diff --git a/src/test/ui/regions/regions-infer-bound-from-trait.nll.stderr b/src/test/ui/regions/regions-infer-bound-from-trait.nll.stderr index fe077499544..4aa4b468eaa 100644 --- a/src/test/ui/regions/regions-infer-bound-from-trait.nll.stderr +++ b/src/test/ui/regions/regions-infer-bound-from-trait.nll.stderr @@ -1,5 +1,5 @@ error[E0309]: the parameter type `A` may not live long enough - --> $DIR/regions-infer-bound-from-trait.rs:33:5 + --> $DIR/regions-infer-bound-from-trait.rs:37:5 | LL | fn bar1<'a,A>(x: Inv<'a>, a: A) { | - help: consider adding an explicit lifetime bound...: `A: 'a` @@ -7,7 +7,7 @@ LL | check_bound(x, a) | ^^^^^^^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds error[E0309]: the parameter type `A` may not live long enough - --> $DIR/regions-infer-bound-from-trait.rs:37:5 + --> $DIR/regions-infer-bound-from-trait.rs:41:5 | LL | fn bar2<'a,'b,A:Is<'b>>(x: Inv<'a>, y: Inv<'b>, a: A) { | -- help: consider adding an explicit lifetime bound...: `A: 'a +` diff --git a/src/test/ui/regions/regions-infer-bound-from-trait.rs b/src/test/ui/regions/regions-infer-bound-from-trait.rs index 610452182f8..96f9125313b 100644 --- a/src/test/ui/regions/regions-infer-bound-from-trait.rs +++ b/src/test/ui/regions/regions-infer-bound-from-trait.rs @@ -1,6 +1,10 @@ // Test that we can derive lifetime bounds on type parameters // from trait inheritance. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait Static : 'static { } trait Is<'a> : 'a { } diff --git a/src/test/ui/regions/regions-infer-bound-from-trait.stderr b/src/test/ui/regions/regions-infer-bound-from-trait.stderr deleted file mode 100644 index fd1090d2dbd..00000000000 --- a/src/test/ui/regions/regions-infer-bound-from-trait.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error[E0309]: the parameter type `A` may not live long enough - --> $DIR/regions-infer-bound-from-trait.rs:33:5 - | -LL | fn bar1<'a,A>(x: Inv<'a>, a: A) { - | - help: consider adding an explicit lifetime bound...: `A: 'a` -LL | check_bound(x, a) - | ^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds... - | -note: ...that is required by this bound - --> $DIR/regions-infer-bound-from-trait.rs:12:21 - | -LL | fn check_bound<'a,A:'a>(x: Inv<'a>, a: A) { } - | ^^ - -error[E0309]: the parameter type `A` may not live long enough - --> $DIR/regions-infer-bound-from-trait.rs:37:5 - | -LL | fn bar2<'a,'b,A:Is<'b>>(x: Inv<'a>, y: Inv<'b>, a: A) { - | -- help: consider adding an explicit lifetime bound...: `A: 'a +` -LL | check_bound(x, a) - | ^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds... - | -note: ...that is required by this bound - --> $DIR/regions-infer-bound-from-trait.rs:12:21 - | -LL | fn check_bound<'a,A:'a>(x: Inv<'a>, a: A) { } - | ^^ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0309`. diff --git a/src/test/ui/regions/regions-infer-contravariance-due-to-decl.base.stderr b/src/test/ui/regions/regions-infer-contravariance-due-to-decl.base.stderr new file mode 100644 index 00000000000..fbe2c0da6e2 --- /dev/null +++ b/src/test/ui/regions/regions-infer-contravariance-due-to-decl.base.stderr @@ -0,0 +1,15 @@ +error[E0623]: lifetime mismatch + --> $DIR/regions-infer-contravariance-due-to-decl.rs:29:35 + | +LL | fn use_<'short,'long>(c: Contravariant<'short>, + | --------------------- these two types are declared with different lifetimes... +LL | s: &'short isize, +LL | l: &'long isize, + | ------------ +... +LL | let _: Contravariant<'long> = c; + | ^ ...but data from `c` flows into `l` here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/regions/regions-infer-contravariance-due-to-decl.nll.stderr b/src/test/ui/regions/regions-infer-contravariance-due-to-decl.nll.stderr index 94b80852d01..0b1bf5271a7 100644 --- a/src/test/ui/regions/regions-infer-contravariance-due-to-decl.nll.stderr +++ b/src/test/ui/regions/regions-infer-contravariance-due-to-decl.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-infer-contravariance-due-to-decl.rs:25:12 + --> $DIR/regions-infer-contravariance-due-to-decl.rs:29:12 | LL | fn use_<'short,'long>(c: Contravariant<'short>, | ------ ----- lifetime `'long` defined here diff --git a/src/test/ui/regions/regions-infer-contravariance-due-to-decl.rs b/src/test/ui/regions/regions-infer-contravariance-due-to-decl.rs index 84161388a6e..233f72fd296 100644 --- a/src/test/ui/regions/regions-infer-contravariance-due-to-decl.rs +++ b/src/test/ui/regions/regions-infer-contravariance-due-to-decl.rs @@ -4,6 +4,10 @@ // Note: see variance-regions-*.rs for the tests that check that the // variance inference works in the first place. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + use std::marker; // This is contravariant with respect to 'a, meaning that @@ -22,7 +26,9 @@ fn use_<'short,'long>(c: Contravariant<'short>, // 'short <= 'long, this would be true if the Contravariant type were // covariant with respect to its parameter 'a. - let _: Contravariant<'long> = c; //~ ERROR E0623 + let _: Contravariant<'long> = c; + //[base]~^ ERROR E0623 + //[nll]~^^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/regions/regions-infer-contravariance-due-to-decl.stderr b/src/test/ui/regions/regions-infer-contravariance-due-to-decl.stderr deleted file mode 100644 index f3a0358b90f..00000000000 --- a/src/test/ui/regions/regions-infer-contravariance-due-to-decl.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0623]: lifetime mismatch - --> $DIR/regions-infer-contravariance-due-to-decl.rs:25:35 - | -LL | fn use_<'short,'long>(c: Contravariant<'short>, - | --------------------- these two types are declared with different lifetimes... -LL | s: &'short isize, -LL | l: &'long isize, - | ------------ -... -LL | let _: Contravariant<'long> = c; - | ^ ...but data from `c` flows into `l` here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/regions/regions-infer-covariance-due-to-decl.base.stderr b/src/test/ui/regions/regions-infer-covariance-due-to-decl.base.stderr new file mode 100644 index 00000000000..bb22e15af69 --- /dev/null +++ b/src/test/ui/regions/regions-infer-covariance-due-to-decl.base.stderr @@ -0,0 +1,14 @@ +error[E0623]: lifetime mismatch + --> $DIR/regions-infer-covariance-due-to-decl.rs:26:32 + | +LL | fn use_<'short,'long>(c: Covariant<'long>, + | ---------------- +LL | s: &'short isize, + | ------------- these two types are declared with different lifetimes... +... +LL | let _: Covariant<'short> = c; + | ^ ...but data from `s` flows into `c` here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/regions/regions-infer-covariance-due-to-decl.nll.stderr b/src/test/ui/regions/regions-infer-covariance-due-to-decl.nll.stderr index f44a0fad59b..4d72b8471dc 100644 --- a/src/test/ui/regions/regions-infer-covariance-due-to-decl.nll.stderr +++ b/src/test/ui/regions/regions-infer-covariance-due-to-decl.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-infer-covariance-due-to-decl.rs:22:12 + --> $DIR/regions-infer-covariance-due-to-decl.rs:26:12 | LL | fn use_<'short,'long>(c: Covariant<'long>, | ------ ----- lifetime `'long` defined here diff --git a/src/test/ui/regions/regions-infer-covariance-due-to-decl.rs b/src/test/ui/regions/regions-infer-covariance-due-to-decl.rs index b5079206578..c4225e76967 100644 --- a/src/test/ui/regions/regions-infer-covariance-due-to-decl.rs +++ b/src/test/ui/regions/regions-infer-covariance-due-to-decl.rs @@ -4,6 +4,10 @@ // Note: see variance-regions-*.rs for the tests that check that the // variance inference works in the first place. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + use std::marker; struct Covariant<'a> { @@ -19,7 +23,9 @@ fn use_<'short,'long>(c: Covariant<'long>, // 'short <= 'long, this would be true if the Covariant type were // contravariant with respect to its parameter 'a. - let _: Covariant<'short> = c; //~ ERROR E0623 + let _: Covariant<'short> = c; + //[base]~^ ERROR E0623 + //[nll]~^^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/regions/regions-infer-covariance-due-to-decl.stderr b/src/test/ui/regions/regions-infer-covariance-due-to-decl.stderr deleted file mode 100644 index c3e2075fbc3..00000000000 --- a/src/test/ui/regions/regions-infer-covariance-due-to-decl.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0623]: lifetime mismatch - --> $DIR/regions-infer-covariance-due-to-decl.rs:22:32 - | -LL | fn use_<'short,'long>(c: Covariant<'long>, - | ---------------- -LL | s: &'short isize, - | ------------- these two types are declared with different lifetimes... -... -LL | let _: Covariant<'short> = c; - | ^ ...but data from `s` flows into `c` here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/regions/regions-infer-invariance-due-to-decl.base.stderr b/src/test/ui/regions/regions-infer-invariance-due-to-decl.base.stderr new file mode 100644 index 00000000000..dc7d0005ca2 --- /dev/null +++ b/src/test/ui/regions/regions-infer-invariance-due-to-decl.base.stderr @@ -0,0 +1,18 @@ +error[E0308]: mismatched types + --> $DIR/regions-infer-invariance-due-to-decl.rs:16:5 + | +LL | b_isize + | ^^^^^^^ lifetime mismatch + | + = note: expected struct `Invariant<'static>` + found struct `Invariant<'r>` +note: the lifetime `'r` as defined here... + --> $DIR/regions-infer-invariance-due-to-decl.rs:15:23 + | +LL | fn to_longer_lifetime<'r>(b_isize: Invariant<'r>) -> Invariant<'static> { + | ^^ + = note: ...does not necessarily outlive the static lifetime + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/regions/regions-infer-invariance-due-to-decl.nll.stderr b/src/test/ui/regions/regions-infer-invariance-due-to-decl.nll.stderr index c8c7808e06c..d7b7f9883a7 100644 --- a/src/test/ui/regions/regions-infer-invariance-due-to-decl.nll.stderr +++ b/src/test/ui/regions/regions-infer-invariance-due-to-decl.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-infer-invariance-due-to-decl.rs:12:5 + --> $DIR/regions-infer-invariance-due-to-decl.rs:16:5 | LL | fn to_longer_lifetime<'r>(b_isize: Invariant<'r>) -> Invariant<'static> { | -- lifetime `'r` defined here diff --git a/src/test/ui/regions/regions-infer-invariance-due-to-decl.rs b/src/test/ui/regions/regions-infer-invariance-due-to-decl.rs index e0fa904e8fe..6433773b2d1 100644 --- a/src/test/ui/regions/regions-infer-invariance-due-to-decl.rs +++ b/src/test/ui/regions/regions-infer-invariance-due-to-decl.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + use std::marker; struct Invariant<'a> { @@ -9,7 +13,9 @@ fn to_same_lifetime<'r>(b_isize: Invariant<'r>) { } fn to_longer_lifetime<'r>(b_isize: Invariant<'r>) -> Invariant<'static> { - b_isize //~ ERROR mismatched types + b_isize + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/regions/regions-infer-invariance-due-to-decl.stderr b/src/test/ui/regions/regions-infer-invariance-due-to-decl.stderr deleted file mode 100644 index afd522aa003..00000000000 --- a/src/test/ui/regions/regions-infer-invariance-due-to-decl.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/regions-infer-invariance-due-to-decl.rs:12:5 - | -LL | b_isize - | ^^^^^^^ lifetime mismatch - | - = note: expected struct `Invariant<'static>` - found struct `Invariant<'r>` -note: the lifetime `'r` as defined here... - --> $DIR/regions-infer-invariance-due-to-decl.rs:11:23 - | -LL | fn to_longer_lifetime<'r>(b_isize: Invariant<'r>) -> Invariant<'static> { - | ^^ - = note: ...does not necessarily outlive the static lifetime - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.base.stderr b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.base.stderr new file mode 100644 index 00000000000..b2530d7b6cd --- /dev/null +++ b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.base.stderr @@ -0,0 +1,18 @@ +error[E0308]: mismatched types + --> $DIR/regions-infer-invariance-due-to-mutability-3.rs:14:5 + | +LL | b_isize + | ^^^^^^^ lifetime mismatch + | + = note: expected struct `Invariant<'static>` + found struct `Invariant<'r>` +note: the lifetime `'r` as defined here... + --> $DIR/regions-infer-invariance-due-to-mutability-3.rs:13:23 + | +LL | fn to_longer_lifetime<'r>(b_isize: Invariant<'r>) -> Invariant<'static> { + | ^^ + = note: ...does not necessarily outlive the static lifetime + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.nll.stderr b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.nll.stderr index 1165011c1f4..37fa5e3bf44 100644 --- a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.nll.stderr +++ b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-infer-invariance-due-to-mutability-3.rs:10:5 + --> $DIR/regions-infer-invariance-due-to-mutability-3.rs:14:5 | LL | fn to_longer_lifetime<'r>(b_isize: Invariant<'r>) -> Invariant<'static> { | -- lifetime `'r` defined here diff --git a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.rs b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.rs index 5843598ab48..4690f9d8b08 100644 --- a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.rs +++ b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Invariant<'a> { f: Box, } @@ -7,7 +11,9 @@ fn to_same_lifetime<'r>(b_isize: Invariant<'r>) { } fn to_longer_lifetime<'r>(b_isize: Invariant<'r>) -> Invariant<'static> { - b_isize //~ ERROR mismatched types + b_isize + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.stderr b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.stderr deleted file mode 100644 index bb594f3676e..00000000000 --- a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/regions-infer-invariance-due-to-mutability-3.rs:10:5 - | -LL | b_isize - | ^^^^^^^ lifetime mismatch - | - = note: expected struct `Invariant<'static>` - found struct `Invariant<'r>` -note: the lifetime `'r` as defined here... - --> $DIR/regions-infer-invariance-due-to-mutability-3.rs:9:23 - | -LL | fn to_longer_lifetime<'r>(b_isize: Invariant<'r>) -> Invariant<'static> { - | ^^ - = note: ...does not necessarily outlive the static lifetime - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.base.stderr b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.base.stderr new file mode 100644 index 00000000000..12774ca92e2 --- /dev/null +++ b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.base.stderr @@ -0,0 +1,18 @@ +error[E0308]: mismatched types + --> $DIR/regions-infer-invariance-due-to-mutability-4.rs:14:5 + | +LL | b_isize + | ^^^^^^^ lifetime mismatch + | + = note: expected struct `Invariant<'static>` + found struct `Invariant<'r>` +note: the lifetime `'r` as defined here... + --> $DIR/regions-infer-invariance-due-to-mutability-4.rs:13:23 + | +LL | fn to_longer_lifetime<'r>(b_isize: Invariant<'r>) -> Invariant<'static> { + | ^^ + = note: ...does not necessarily outlive the static lifetime + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.nll.stderr b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.nll.stderr index f3973a93bad..1b3ef7bc028 100644 --- a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.nll.stderr +++ b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-infer-invariance-due-to-mutability-4.rs:10:5 + --> $DIR/regions-infer-invariance-due-to-mutability-4.rs:14:5 | LL | fn to_longer_lifetime<'r>(b_isize: Invariant<'r>) -> Invariant<'static> { | -- lifetime `'r` defined here diff --git a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.rs b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.rs index f0af18cf618..8e257c4fd0e 100644 --- a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.rs +++ b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Invariant<'a> { f: Box *mut &'a isize + 'static>, } @@ -7,7 +11,9 @@ fn to_same_lifetime<'r>(b_isize: Invariant<'r>) { } fn to_longer_lifetime<'r>(b_isize: Invariant<'r>) -> Invariant<'static> { - b_isize //~ ERROR mismatched types + b_isize + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.stderr b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.stderr deleted file mode 100644 index 04d11b5b7c7..00000000000 --- a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/regions-infer-invariance-due-to-mutability-4.rs:10:5 - | -LL | b_isize - | ^^^^^^^ lifetime mismatch - | - = note: expected struct `Invariant<'static>` - found struct `Invariant<'r>` -note: the lifetime `'r` as defined here... - --> $DIR/regions-infer-invariance-due-to-mutability-4.rs:9:23 - | -LL | fn to_longer_lifetime<'r>(b_isize: Invariant<'r>) -> Invariant<'static> { - | ^^ - = note: ...does not necessarily outlive the static lifetime - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/regions/regions-infer-not-param.base.stderr b/src/test/ui/regions/regions-infer-not-param.base.stderr new file mode 100644 index 00000000000..f43274163d0 --- /dev/null +++ b/src/test/ui/regions/regions-infer-not-param.base.stderr @@ -0,0 +1,60 @@ +error[E0308]: mismatched types + --> $DIR/regions-infer-not-param.rs:19:54 + | +LL | fn take_direct<'a,'b>(p: Direct<'a>) -> Direct<'b> { p } + | ^ lifetime mismatch + | + = note: expected struct `Direct<'b>` + found struct `Direct<'a>` +note: the lifetime `'a` as defined here... + --> $DIR/regions-infer-not-param.rs:19:16 + | +LL | fn take_direct<'a,'b>(p: Direct<'a>) -> Direct<'b> { p } + | ^^ +note: ...does not necessarily outlive the lifetime `'b` as defined here + --> $DIR/regions-infer-not-param.rs:19:19 + | +LL | fn take_direct<'a,'b>(p: Direct<'a>) -> Direct<'b> { p } + | ^^ + +error[E0308]: mismatched types + --> $DIR/regions-infer-not-param.rs:25:63 + | +LL | fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } + | ^ lifetime mismatch + | + = note: expected struct `Indirect2<'b>` + found struct `Indirect2<'a>` +note: the lifetime `'a` as defined here... + --> $DIR/regions-infer-not-param.rs:25:19 + | +LL | fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } + | ^^ +note: ...does not necessarily outlive the lifetime `'b` as defined here + --> $DIR/regions-infer-not-param.rs:25:22 + | +LL | fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } + | ^^ + +error[E0308]: mismatched types + --> $DIR/regions-infer-not-param.rs:25:63 + | +LL | fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } + | ^ lifetime mismatch + | + = note: expected struct `Indirect2<'b>` + found struct `Indirect2<'a>` +note: the lifetime `'b` as defined here... + --> $DIR/regions-infer-not-param.rs:25:22 + | +LL | fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } + | ^^ +note: ...does not necessarily outlive the lifetime `'a` as defined here + --> $DIR/regions-infer-not-param.rs:25:19 + | +LL | fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } + | ^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/regions/regions-infer-not-param.nll.stderr b/src/test/ui/regions/regions-infer-not-param.nll.stderr index f4875e49c3d..95e6b03c350 100644 --- a/src/test/ui/regions/regions-infer-not-param.nll.stderr +++ b/src/test/ui/regions/regions-infer-not-param.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-infer-not-param.rs:15:54 + --> $DIR/regions-infer-not-param.rs:19:54 | LL | fn take_direct<'a,'b>(p: Direct<'a>) -> Direct<'b> { p } | -- -- lifetime `'b` defined here ^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` @@ -9,7 +9,7 @@ LL | fn take_direct<'a,'b>(p: Direct<'a>) -> Direct<'b> { p } = help: consider adding the following bound: `'a: 'b` error: lifetime may not live long enough - --> $DIR/regions-infer-not-param.rs:19:63 + --> $DIR/regions-infer-not-param.rs:25:63 | LL | fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } | -- -- lifetime `'b` defined here ^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b` @@ -22,7 +22,7 @@ LL | fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } = help: see for more information about variance error: lifetime may not live long enough - --> $DIR/regions-infer-not-param.rs:19:63 + --> $DIR/regions-infer-not-param.rs:25:63 | LL | fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } | -- -- lifetime `'b` defined here ^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` diff --git a/src/test/ui/regions/regions-infer-not-param.rs b/src/test/ui/regions/regions-infer-not-param.rs index 7643be64d5b..0b8af5bc152 100644 --- a/src/test/ui/regions/regions-infer-not-param.rs +++ b/src/test/ui/regions/regions-infer-not-param.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Direct<'a> { f: &'a isize } @@ -12,15 +16,20 @@ struct Indirect2<'a> { g: Box) + 'static> } -fn take_direct<'a,'b>(p: Direct<'a>) -> Direct<'b> { p } //~ ERROR mismatched types +fn take_direct<'a,'b>(p: Direct<'a>) -> Direct<'b> { p } +//[base]~^ ERROR mismatched types +//[nll]~^^ ERROR lifetime may not live long enough fn take_indirect1(p: Indirect1) -> Indirect1 { p } -fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } //~ ERROR mismatched types -//~| expected struct `Indirect2<'b>` -//~| found struct `Indirect2<'a>` -//~| ERROR mismatched types -//~| expected struct `Indirect2<'b>` -//~| found struct `Indirect2<'a>` +fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } +//[base]~^ ERROR mismatched types +//[base]~| expected struct `Indirect2<'b>` +//[base]~| found struct `Indirect2<'a>` +//[base]~| ERROR mismatched types +//[base]~| expected struct `Indirect2<'b>` +//[base]~| found struct `Indirect2<'a>` +//[nll]~^^^^^^^ ERROR lifetime may not live long enough +//[nll]~| ERROR lifetime may not live long enough fn main() {} diff --git a/src/test/ui/regions/regions-infer-not-param.stderr b/src/test/ui/regions/regions-infer-not-param.stderr deleted file mode 100644 index a23bdeb834f..00000000000 --- a/src/test/ui/regions/regions-infer-not-param.stderr +++ /dev/null @@ -1,60 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/regions-infer-not-param.rs:15:54 - | -LL | fn take_direct<'a,'b>(p: Direct<'a>) -> Direct<'b> { p } - | ^ lifetime mismatch - | - = note: expected struct `Direct<'b>` - found struct `Direct<'a>` -note: the lifetime `'a` as defined here... - --> $DIR/regions-infer-not-param.rs:15:16 - | -LL | fn take_direct<'a,'b>(p: Direct<'a>) -> Direct<'b> { p } - | ^^ -note: ...does not necessarily outlive the lifetime `'b` as defined here - --> $DIR/regions-infer-not-param.rs:15:19 - | -LL | fn take_direct<'a,'b>(p: Direct<'a>) -> Direct<'b> { p } - | ^^ - -error[E0308]: mismatched types - --> $DIR/regions-infer-not-param.rs:19:63 - | -LL | fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } - | ^ lifetime mismatch - | - = note: expected struct `Indirect2<'b>` - found struct `Indirect2<'a>` -note: the lifetime `'a` as defined here... - --> $DIR/regions-infer-not-param.rs:19:19 - | -LL | fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } - | ^^ -note: ...does not necessarily outlive the lifetime `'b` as defined here - --> $DIR/regions-infer-not-param.rs:19:22 - | -LL | fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } - | ^^ - -error[E0308]: mismatched types - --> $DIR/regions-infer-not-param.rs:19:63 - | -LL | fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } - | ^ lifetime mismatch - | - = note: expected struct `Indirect2<'b>` - found struct `Indirect2<'a>` -note: the lifetime `'b` as defined here... - --> $DIR/regions-infer-not-param.rs:19:22 - | -LL | fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } - | ^^ -note: ...does not necessarily outlive the lifetime `'a` as defined here - --> $DIR/regions-infer-not-param.rs:19:19 - | -LL | fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } - | ^^ - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/regions/regions-infer-paramd-indirect.base.stderr b/src/test/ui/regions/regions-infer-paramd-indirect.base.stderr new file mode 100644 index 00000000000..1d4471f910d --- /dev/null +++ b/src/test/ui/regions/regions-infer-paramd-indirect.base.stderr @@ -0,0 +1,22 @@ +error[E0308]: mismatched types + --> $DIR/regions-infer-paramd-indirect.rs:26:18 + | +LL | self.f = b; + | ^ lifetime mismatch + | + = note: expected struct `Box>` + found struct `Box>` +note: the anonymous lifetime defined here... + --> $DIR/regions-infer-paramd-indirect.rs:25:36 + | +LL | fn set_f_bad(&mut self, b: Box) { + | ^ +note: ...does not necessarily outlive the lifetime `'a` as defined here + --> $DIR/regions-infer-paramd-indirect.rs:20:6 + | +LL | impl<'a> SetF<'a> for C<'a> { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/regions/regions-infer-paramd-indirect.nll.stderr b/src/test/ui/regions/regions-infer-paramd-indirect.nll.stderr index afabdc1de1c..96377cbdab4 100644 --- a/src/test/ui/regions/regions-infer-paramd-indirect.nll.stderr +++ b/src/test/ui/regions/regions-infer-paramd-indirect.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-infer-paramd-indirect.rs:22:9 + --> $DIR/regions-infer-paramd-indirect.rs:26:9 | LL | impl<'a> SetF<'a> for C<'a> { | -- lifetime `'a` defined here diff --git a/src/test/ui/regions/regions-infer-paramd-indirect.rs b/src/test/ui/regions/regions-infer-paramd-indirect.rs index 3b18bbf1df3..060306f611e 100644 --- a/src/test/ui/regions/regions-infer-paramd-indirect.rs +++ b/src/test/ui/regions/regions-infer-paramd-indirect.rs @@ -1,6 +1,10 @@ // Check that we correctly infer that b and c must be region // parameterized because they reference a which requires a region. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + type A<'a> = &'a isize; type B<'a> = Box>; @@ -20,10 +24,11 @@ impl<'a> SetF<'a> for C<'a> { fn set_f_bad(&mut self, b: Box) { self.f = b; - //~^ ERROR mismatched types - //~| expected struct `Box>` - //~| found struct `Box>` - //~| lifetime mismatch + //[base]~^ ERROR mismatched types + //[base]~| expected struct `Box>` + //[base]~| found struct `Box>` + //[base]~| lifetime mismatch + //[nll]~^^^^^ ERROR lifetime may not live long enough } } diff --git a/src/test/ui/regions/regions-infer-paramd-indirect.stderr b/src/test/ui/regions/regions-infer-paramd-indirect.stderr deleted file mode 100644 index d2b369fb07b..00000000000 --- a/src/test/ui/regions/regions-infer-paramd-indirect.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/regions-infer-paramd-indirect.rs:22:18 - | -LL | self.f = b; - | ^ lifetime mismatch - | - = note: expected struct `Box>` - found struct `Box>` -note: the anonymous lifetime defined here... - --> $DIR/regions-infer-paramd-indirect.rs:21:36 - | -LL | fn set_f_bad(&mut self, b: Box) { - | ^ -note: ...does not necessarily outlive the lifetime `'a` as defined here - --> $DIR/regions-infer-paramd-indirect.rs:16:6 - | -LL | impl<'a> SetF<'a> for C<'a> { - | ^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/regions/regions-lifetime-bounds-on-fns.base.stderr b/src/test/ui/regions/regions-lifetime-bounds-on-fns.base.stderr new file mode 100644 index 00000000000..e57b06aac39 --- /dev/null +++ b/src/test/ui/regions/regions-lifetime-bounds-on-fns.base.stderr @@ -0,0 +1,31 @@ +error[E0623]: lifetime mismatch + --> $DIR/regions-lifetime-bounds-on-fns.rs:12:10 + | +LL | fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) { + | --------- --------- these two types are declared with different lifetimes... +LL | // Illegal now because there is no `'b:'a` declaration. +LL | *x = *y; + | ^^ ...but data from `y` flows into `x` here + +error[E0623]: lifetime mismatch + --> $DIR/regions-lifetime-bounds-on-fns.rs:20:7 + | +LL | fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) { + | --------- --------- these two types are declared with different lifetimes... +... +LL | a(x, y); + | ^ ...but data from `y` flows into `x` here + +error[E0308]: mismatched types + --> $DIR/regions-lifetime-bounds-on-fns.rs:28:43 + | +LL | let _: fn(&mut &isize, &mut &isize) = a; + | ^ one type is more general than the other + | + = note: expected fn pointer `for<'r, 's, 't0, 't1> fn(&'r mut &'s isize, &'t0 mut &'t1 isize)` + found fn pointer `for<'r, 's> fn(&'r mut &isize, &'s mut &isize)` + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0308, E0623. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/regions/regions-lifetime-bounds-on-fns.nll.stderr b/src/test/ui/regions/regions-lifetime-bounds-on-fns.nll.stderr index ee3dcef1cb5..7fe8b4bf57f 100644 --- a/src/test/ui/regions/regions-lifetime-bounds-on-fns.nll.stderr +++ b/src/test/ui/regions/regions-lifetime-bounds-on-fns.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-lifetime-bounds-on-fns.rs:8:5 + --> $DIR/regions-lifetime-bounds-on-fns.rs:12:5 | LL | fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) { | -- -- lifetime `'b` defined here @@ -12,7 +12,7 @@ LL | *x = *y; = help: consider adding the following bound: `'b: 'a` error: lifetime may not live long enough - --> $DIR/regions-lifetime-bounds-on-fns.rs:14:5 + --> $DIR/regions-lifetime-bounds-on-fns.rs:20:5 | LL | fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) { | -- -- lifetime `'b` defined here @@ -28,7 +28,7 @@ LL | a(x, y); = help: see for more information about variance error[E0308]: mismatched types - --> $DIR/regions-lifetime-bounds-on-fns.rs:20:12 + --> $DIR/regions-lifetime-bounds-on-fns.rs:28:12 | LL | let _: fn(&mut &isize, &mut &isize) = a; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other @@ -37,7 +37,7 @@ LL | let _: fn(&mut &isize, &mut &isize) = a; found fn pointer `for<'r, 's> fn(&'r mut &isize, &'s mut &isize)` error[E0308]: mismatched types - --> $DIR/regions-lifetime-bounds-on-fns.rs:20:12 + --> $DIR/regions-lifetime-bounds-on-fns.rs:28:12 | LL | let _: fn(&mut &isize, &mut &isize) = a; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other diff --git a/src/test/ui/regions/regions-lifetime-bounds-on-fns.rs b/src/test/ui/regions/regions-lifetime-bounds-on-fns.rs index 7d7f62e1979..97c08d8ab0e 100644 --- a/src/test/ui/regions/regions-lifetime-bounds-on-fns.rs +++ b/src/test/ui/regions/regions-lifetime-bounds-on-fns.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn a<'a, 'b:'a>(x: &mut &'a isize, y: &mut &'b isize) { // Note: this is legal because of the `'b:'a` declaration. *x = *y; @@ -5,19 +9,25 @@ fn a<'a, 'b:'a>(x: &mut &'a isize, y: &mut &'b isize) { fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) { // Illegal now because there is no `'b:'a` declaration. - *x = *y; //~ ERROR E0623 + *x = *y; + //[base]~^ ERROR lifetime mismatch [E0623] + //[nll]~^^ ERROR lifetime may not live long enough } fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) { // Here we try to call `foo` but do not know that `'a` and `'b` are // related as required. - a(x, y); //~ ERROR lifetime mismatch [E0623] + a(x, y); + //[base]~^ ERROR lifetime mismatch [E0623] + //[nll]~^^ ERROR lifetime may not live long enough } fn d() { // 'a and 'b are early bound in the function `a` because they appear // inconstraints: - let _: fn(&mut &isize, &mut &isize) = a; //~ ERROR E0308 + let _: fn(&mut &isize, &mut &isize) = a; + //~^ ERROR mismatched types [E0308] + //[nll]~^^ ERROR mismatched types [E0308] } fn e() { diff --git a/src/test/ui/regions/regions-lifetime-bounds-on-fns.stderr b/src/test/ui/regions/regions-lifetime-bounds-on-fns.stderr deleted file mode 100644 index 2b2dd0dbbf2..00000000000 --- a/src/test/ui/regions/regions-lifetime-bounds-on-fns.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error[E0623]: lifetime mismatch - --> $DIR/regions-lifetime-bounds-on-fns.rs:8:10 - | -LL | fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) { - | --------- --------- these two types are declared with different lifetimes... -LL | // Illegal now because there is no `'b:'a` declaration. -LL | *x = *y; - | ^^ ...but data from `y` flows into `x` here - -error[E0623]: lifetime mismatch - --> $DIR/regions-lifetime-bounds-on-fns.rs:14:7 - | -LL | fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) { - | --------- --------- these two types are declared with different lifetimes... -... -LL | a(x, y); - | ^ ...but data from `y` flows into `x` here - -error[E0308]: mismatched types - --> $DIR/regions-lifetime-bounds-on-fns.rs:20:43 - | -LL | let _: fn(&mut &isize, &mut &isize) = a; - | ^ one type is more general than the other - | - = note: expected fn pointer `for<'r, 's, 't0, 't1> fn(&'r mut &'s isize, &'t0 mut &'t1 isize)` - found fn pointer `for<'r, 's> fn(&'r mut &isize, &'s mut &isize)` - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0308, E0623. -For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/regions/regions-nested-fns.base.stderr b/src/test/ui/regions/regions-nested-fns.base.stderr new file mode 100644 index 00000000000..37ce569e761 --- /dev/null +++ b/src/test/ui/regions/regions-nested-fns.base.stderr @@ -0,0 +1,78 @@ +error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements + --> $DIR/regions-nested-fns.rs:9:18 + | +LL | let mut ay = &y; + | ^^ + | +note: first, the lifetime cannot outlive the anonymous lifetime #1 defined here... + --> $DIR/regions-nested-fns.rs:13:58 + | +LL | ignore:: FnMut(&'z isize)>>(Box::new(|z| { + | __________________________________________________________^ +LL | | ay = x; +LL | | ay = &y; +LL | | +LL | | ay = z; +LL | | +LL | | })); + | |_____^ +note: ...so that reference does not outlive borrowed content + --> $DIR/regions-nested-fns.rs:17:14 + | +LL | ay = z; + | ^ +note: but, the lifetime must be valid for the anonymous lifetime #1 defined here... + --> $DIR/regions-nested-fns.rs:21:72 + | +LL | ignore::< Box FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { + | ________________________________________________________________________^ +LL | | if false { return x; } +LL | | +LL | | +LL | | if false { return ay; } +LL | | return z; +LL | | })); + | |_____^ +note: ...so that the types are compatible + --> $DIR/regions-nested-fns.rs:21:76 + | +LL | ignore::< Box FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { + | ____________________________________________________________________________^ +LL | | if false { return x; } +LL | | +LL | | +LL | | if false { return ay; } +LL | | return z; +LL | | })); + | |_____^ + = note: expected `&isize` + found `&isize` + +error[E0312]: lifetime of reference outlives lifetime of borrowed content... + --> $DIR/regions-nested-fns.rs:22:27 + | +LL | if false { return x; } + | ^ + | +note: ...the reference is valid for the anonymous lifetime #1 defined here... + --> $DIR/regions-nested-fns.rs:21:72 + | +LL | ignore::< Box FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { + | ________________________________________________________________________^ +LL | | if false { return x; } +LL | | +LL | | +LL | | if false { return ay; } +LL | | return z; +LL | | })); + | |_____^ +note: ...but the borrowed content is only valid for the lifetime `'x` as defined here + --> $DIR/regions-nested-fns.rs:7:11 + | +LL | fn nested<'x>(x: &'x isize) { + | ^^ + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0312, E0495. +For more information about an error, try `rustc --explain E0312`. diff --git a/src/test/ui/regions/regions-nested-fns.nll.stderr b/src/test/ui/regions/regions-nested-fns.nll.stderr index a0cfa362472..6f2a89994b0 100644 --- a/src/test/ui/regions/regions-nested-fns.nll.stderr +++ b/src/test/ui/regions/regions-nested-fns.nll.stderr @@ -1,9 +1,9 @@ error[E0521]: borrowed data escapes outside of closure - --> $DIR/regions-nested-fns.rs:10:9 + --> $DIR/regions-nested-fns.rs:17:9 | LL | let mut ay = &y; | ------ `ay` declared here, outside of the closure body -LL | +... LL | ignore:: FnMut(&'z isize)>>(Box::new(|z| { | - `z` is a reference that is only valid in the closure body ... @@ -11,7 +11,7 @@ LL | ay = z; | ^^^^^^ `z` escapes the closure body here error[E0597]: `y` does not live long enough - --> $DIR/regions-nested-fns.rs:5:18 + --> $DIR/regions-nested-fns.rs:9:18 | LL | let mut ay = &y; | ^^ borrowed value does not live long enough @@ -23,7 +23,7 @@ LL | } | - `y` dropped here while still borrowed error[E0597]: `y` does not live long enough - --> $DIR/regions-nested-fns.rs:9:15 + --> $DIR/regions-nested-fns.rs:15:15 | LL | ignore:: FnMut(&'z isize)>>(Box::new(|z| { | --- value captured here @@ -38,7 +38,7 @@ LL | } | - `y` dropped here while still borrowed error: lifetime may not live long enough - --> $DIR/regions-nested-fns.rs:14:27 + --> $DIR/regions-nested-fns.rs:22:27 | LL | fn nested<'x>(x: &'x isize) { | -- lifetime `'x` defined here diff --git a/src/test/ui/regions/regions-nested-fns.rs b/src/test/ui/regions/regions-nested-fns.rs index c02d4e0ce45..8cc39792bd9 100644 --- a/src/test/ui/regions/regions-nested-fns.rs +++ b/src/test/ui/regions/regions-nested-fns.rs @@ -1,17 +1,27 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn ignore(t: T) {} fn nested<'x>(x: &'x isize) { let y = 3; - let mut ay = &y; //~ ERROR E0495 + let mut ay = &y; + //[base]~^ ERROR E0495 + //[nll]~^^ ERROR `y` does not live long enough [E0597] ignore:: FnMut(&'z isize)>>(Box::new(|z| { ay = x; ay = &y; + //[nll]~^ ERROR `y` does not live long enough ay = z; + //[nll]~^ ERROR borrowed data escapes outside of closure [E0521] })); ignore::< Box FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { - if false { return x; } //~ ERROR E0312 + if false { return x; } + //[base]~^ ERROR E0312 + //[nll]~^^ ERROR lifetime may not live long enough if false { return ay; } return z; })); diff --git a/src/test/ui/regions/regions-nested-fns.stderr b/src/test/ui/regions/regions-nested-fns.stderr deleted file mode 100644 index 11affcaaa79..00000000000 --- a/src/test/ui/regions/regions-nested-fns.stderr +++ /dev/null @@ -1,70 +0,0 @@ -error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements - --> $DIR/regions-nested-fns.rs:5:18 - | -LL | let mut ay = &y; - | ^^ - | -note: first, the lifetime cannot outlive the anonymous lifetime #1 defined here... - --> $DIR/regions-nested-fns.rs:7:58 - | -LL | ignore:: FnMut(&'z isize)>>(Box::new(|z| { - | __________________________________________________________^ -LL | | ay = x; -LL | | ay = &y; -LL | | ay = z; -LL | | })); - | |_____^ -note: ...so that reference does not outlive borrowed content - --> $DIR/regions-nested-fns.rs:10:14 - | -LL | ay = z; - | ^ -note: but, the lifetime must be valid for the anonymous lifetime #1 defined here... - --> $DIR/regions-nested-fns.rs:13:72 - | -LL | ignore::< Box FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { - | ________________________________________________________________________^ -LL | | if false { return x; } -LL | | if false { return ay; } -LL | | return z; -LL | | })); - | |_____^ -note: ...so that the types are compatible - --> $DIR/regions-nested-fns.rs:13:76 - | -LL | ignore::< Box FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { - | ____________________________________________________________________________^ -LL | | if false { return x; } -LL | | if false { return ay; } -LL | | return z; -LL | | })); - | |_____^ - = note: expected `&isize` - found `&isize` - -error[E0312]: lifetime of reference outlives lifetime of borrowed content... - --> $DIR/regions-nested-fns.rs:14:27 - | -LL | if false { return x; } - | ^ - | -note: ...the reference is valid for the anonymous lifetime #1 defined here... - --> $DIR/regions-nested-fns.rs:13:72 - | -LL | ignore::< Box FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { - | ________________________________________________________________________^ -LL | | if false { return x; } -LL | | if false { return ay; } -LL | | return z; -LL | | })); - | |_____^ -note: ...but the borrowed content is only valid for the lifetime `'x` as defined here - --> $DIR/regions-nested-fns.rs:3:11 - | -LL | fn nested<'x>(x: &'x isize) { - | ^^ - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0312, E0495. -For more information about an error, try `rustc --explain E0312`. diff --git a/src/test/ui/regions/regions-outlives-projection-container.base.stderr b/src/test/ui/regions/regions-outlives-projection-container.base.stderr new file mode 100644 index 00000000000..9a66f67ea6e --- /dev/null +++ b/src/test/ui/regions/regions-outlives-projection-container.base.stderr @@ -0,0 +1,71 @@ +error[E0491]: in type `&'a WithAssoc>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-projection-container.rs:40:13 + | +LL | let _x: &'a WithAssoc> = loop { }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime `'a` as defined here + --> $DIR/regions-outlives-projection-container.rs:32:15 + | +LL | fn with_assoc<'a,'b>() { + | ^^ +note: but the referenced data is only valid for the lifetime `'b` as defined here + --> $DIR/regions-outlives-projection-container.rs:32:18 + | +LL | fn with_assoc<'a,'b>() { + | ^^ + +error[E0491]: in type `&'a WithoutAssoc>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-projection-container.rs:59:13 + | +LL | let _x: &'a WithoutAssoc> = loop { }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime `'a` as defined here + --> $DIR/regions-outlives-projection-container.rs:55:18 + | +LL | fn without_assoc<'a,'b>() { + | ^^ +note: but the referenced data is only valid for the lifetime `'b` as defined here + --> $DIR/regions-outlives-projection-container.rs:55:21 + | +LL | fn without_assoc<'a,'b>() { + | ^^ + +error[E0491]: in type `&'a WithAssoc>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-projection-container.rs:69:12 + | +LL | call::<&'a WithAssoc>>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime `'a` as defined here + --> $DIR/regions-outlives-projection-container.rs:64:20 + | +LL | fn call_with_assoc<'a,'b>() { + | ^^ +note: but the referenced data is only valid for the lifetime `'b` as defined here + --> $DIR/regions-outlives-projection-container.rs:64:23 + | +LL | fn call_with_assoc<'a,'b>() { + | ^^ + +error[E0491]: in type `&'a WithoutAssoc>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-projection-container.rs:77:12 + | +LL | call::<&'a WithoutAssoc>>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime `'a` as defined here + --> $DIR/regions-outlives-projection-container.rs:74:23 + | +LL | fn call_without_assoc<'a,'b>() { + | ^^ +note: but the referenced data is only valid for the lifetime `'b` as defined here + --> $DIR/regions-outlives-projection-container.rs:74:26 + | +LL | fn call_without_assoc<'a,'b>() { + | ^^ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/regions/regions-outlives-projection-container.nll.stderr b/src/test/ui/regions/regions-outlives-projection-container.nll.stderr index 073a3190022..d93eef9ce0b 100644 --- a/src/test/ui/regions/regions-outlives-projection-container.nll.stderr +++ b/src/test/ui/regions/regions-outlives-projection-container.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-outlives-projection-container.rs:36:13 + --> $DIR/regions-outlives-projection-container.rs:40:13 | LL | fn with_assoc<'a,'b>() { | -- -- lifetime `'b` defined here @@ -12,7 +12,7 @@ LL | let _x: &'a WithAssoc> = loop { }; = help: consider adding the following bound: `'b: 'a` error: lifetime may not live long enough - --> $DIR/regions-outlives-projection-container.rs:54:13 + --> $DIR/regions-outlives-projection-container.rs:59:13 | LL | fn without_assoc<'a,'b>() { | -- -- lifetime `'b` defined here @@ -25,7 +25,7 @@ LL | let _x: &'a WithoutAssoc> = loop { }; = help: consider adding the following bound: `'b: 'a` error: lifetime may not live long enough - --> $DIR/regions-outlives-projection-container.rs:63:5 + --> $DIR/regions-outlives-projection-container.rs:69:5 | LL | fn call_with_assoc<'a,'b>() { | -- -- lifetime `'b` defined here @@ -38,7 +38,7 @@ LL | call::<&'a WithAssoc>>(); = help: consider adding the following bound: `'b: 'a` error: lifetime may not live long enough - --> $DIR/regions-outlives-projection-container.rs:70:5 + --> $DIR/regions-outlives-projection-container.rs:77:5 | LL | fn call_without_assoc<'a,'b>() { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/regions/regions-outlives-projection-container.rs b/src/test/ui/regions/regions-outlives-projection-container.rs index 3afc600becb..ccfd2213b6f 100644 --- a/src/test/ui/regions/regions-outlives-projection-container.rs +++ b/src/test/ui/regions/regions-outlives-projection-container.rs @@ -2,6 +2,10 @@ // type of a bound that appears in the where clause on a struct must // outlive the location in which the type appears. Issue #22246. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + #![allow(dead_code)] #![feature(rustc_attrs)] @@ -34,7 +38,8 @@ fn with_assoc<'a,'b>() { // FIXME (#54943) NLL doesn't enforce WF condition in unreachable code if // `_x` is changed to `_` let _x: &'a WithAssoc> = loop { }; - //~^ ERROR reference has a longer lifetime + //[base]~^ ERROR reference has a longer lifetime + //[nll]~^^ ERROR lifetime may not live long enough } fn with_assoc1<'a,'b>() where 'b : 'a { @@ -52,7 +57,8 @@ fn without_assoc<'a,'b>() { // that `'b:'a` holds because the `'b` appears in `TheType<'b>`. let _x: &'a WithoutAssoc> = loop { }; - //~^ ERROR reference has a longer lifetime + //[base]~^ ERROR reference has a longer lifetime + //[nll]~^^ ERROR lifetime may not live long enough } fn call_with_assoc<'a,'b>() { @@ -61,13 +67,16 @@ fn call_with_assoc<'a,'b>() { // no data. call::<&'a WithAssoc>>(); - //~^ ERROR reference has a longer lifetime + //[base]~^ ERROR reference has a longer lifetime + //[nll]~^^ ERROR lifetime may not live long enough } fn call_without_assoc<'a,'b>() { // As `without_assoc`, but in a distinct scenario. - call::<&'a WithoutAssoc>>(); //~ ERROR reference has a longer lifetime + call::<&'a WithoutAssoc>>(); + //[base]~^ ERROR reference has a longer lifetime + //[nll]~^^ ERROR lifetime may not live long enough } fn call() { } diff --git a/src/test/ui/regions/regions-outlives-projection-container.stderr b/src/test/ui/regions/regions-outlives-projection-container.stderr deleted file mode 100644 index 8c2b2c1e24a..00000000000 --- a/src/test/ui/regions/regions-outlives-projection-container.stderr +++ /dev/null @@ -1,71 +0,0 @@ -error[E0491]: in type `&'a WithAssoc>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-projection-container.rs:36:13 - | -LL | let _x: &'a WithAssoc> = loop { }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime `'a` as defined here - --> $DIR/regions-outlives-projection-container.rs:28:15 - | -LL | fn with_assoc<'a,'b>() { - | ^^ -note: but the referenced data is only valid for the lifetime `'b` as defined here - --> $DIR/regions-outlives-projection-container.rs:28:18 - | -LL | fn with_assoc<'a,'b>() { - | ^^ - -error[E0491]: in type `&'a WithoutAssoc>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-projection-container.rs:54:13 - | -LL | let _x: &'a WithoutAssoc> = loop { }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime `'a` as defined here - --> $DIR/regions-outlives-projection-container.rs:50:18 - | -LL | fn without_assoc<'a,'b>() { - | ^^ -note: but the referenced data is only valid for the lifetime `'b` as defined here - --> $DIR/regions-outlives-projection-container.rs:50:21 - | -LL | fn without_assoc<'a,'b>() { - | ^^ - -error[E0491]: in type `&'a WithAssoc>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-projection-container.rs:63:12 - | -LL | call::<&'a WithAssoc>>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime `'a` as defined here - --> $DIR/regions-outlives-projection-container.rs:58:20 - | -LL | fn call_with_assoc<'a,'b>() { - | ^^ -note: but the referenced data is only valid for the lifetime `'b` as defined here - --> $DIR/regions-outlives-projection-container.rs:58:23 - | -LL | fn call_with_assoc<'a,'b>() { - | ^^ - -error[E0491]: in type `&'a WithoutAssoc>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-projection-container.rs:70:12 - | -LL | call::<&'a WithoutAssoc>>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime `'a` as defined here - --> $DIR/regions-outlives-projection-container.rs:67:23 - | -LL | fn call_without_assoc<'a,'b>() { - | ^^ -note: but the referenced data is only valid for the lifetime `'b` as defined here - --> $DIR/regions-outlives-projection-container.rs:67:26 - | -LL | fn call_without_assoc<'a,'b>() { - | ^^ - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/regions/regions-proc-bound-capture.base.stderr b/src/test/ui/regions/regions-proc-bound-capture.base.stderr new file mode 100644 index 00000000000..427c6f4ec8c --- /dev/null +++ b/src/test/ui/regions/regions-proc-bound-capture.base.stderr @@ -0,0 +1,29 @@ +error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement + --> $DIR/regions-proc-bound-capture.rs:13:14 + | +LL | fn static_proc(x: &isize) -> Box (isize) + 'static> { + | ------ this data with an anonymous lifetime `'_`... +LL | // This is illegal, because the region bound on `proc` is 'static. +LL | Box::new(move || { *x }) + | ^^^^^^^^^^^^^^ ...is used and required to live as long as `'static` here + | +note: `'static` lifetime requirement introduced by the return type + --> $DIR/regions-proc-bound-capture.rs:11:59 + | +LL | fn static_proc(x: &isize) -> Box (isize) + 'static> { + | ^^^^^^^ `'static` requirement introduced here +LL | // This is illegal, because the region bound on `proc` is 'static. +LL | Box::new(move || { *x }) + | ------------------------ because of this returned expression +help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `x` + | +LL | fn static_proc(x: &isize) -> Box (isize) + '_> { + | ~~ +help: alternatively, add an explicit `'static` bound to this reference + | +LL | fn static_proc(x: &'static isize) -> Box (isize) + 'static> { + | ~~~~~~~~~~~~~~ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0759`. diff --git a/src/test/ui/regions/regions-proc-bound-capture.nll.stderr b/src/test/ui/regions/regions-proc-bound-capture.nll.stderr index 75890b85815..6120a53eb09 100644 --- a/src/test/ui/regions/regions-proc-bound-capture.nll.stderr +++ b/src/test/ui/regions/regions-proc-bound-capture.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-proc-bound-capture.rs:9:5 + --> $DIR/regions-proc-bound-capture.rs:13:5 | LL | fn static_proc(x: &isize) -> Box (isize) + 'static> { | - let's call the lifetime of this reference `'1` diff --git a/src/test/ui/regions/regions-proc-bound-capture.rs b/src/test/ui/regions/regions-proc-bound-capture.rs index 55d964ac534..1033163c8dd 100644 --- a/src/test/ui/regions/regions-proc-bound-capture.rs +++ b/src/test/ui/regions/regions-proc-bound-capture.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn borrowed_proc<'a>(x: &'a isize) -> Box(isize) + 'a> { // This is legal, because the region bound on `proc` // states that it captures `x`. @@ -6,7 +10,9 @@ fn borrowed_proc<'a>(x: &'a isize) -> Box(isize) + 'a> { fn static_proc(x: &isize) -> Box (isize) + 'static> { // This is illegal, because the region bound on `proc` is 'static. - Box::new(move || { *x }) //~ ERROR E0759 + Box::new(move || { *x }) + //[base]~^ ERROR E0759 + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { } diff --git a/src/test/ui/regions/regions-proc-bound-capture.stderr b/src/test/ui/regions/regions-proc-bound-capture.stderr deleted file mode 100644 index 2ebe874da93..00000000000 --- a/src/test/ui/regions/regions-proc-bound-capture.stderr +++ /dev/null @@ -1,29 +0,0 @@ -error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/regions-proc-bound-capture.rs:9:14 - | -LL | fn static_proc(x: &isize) -> Box (isize) + 'static> { - | ------ this data with an anonymous lifetime `'_`... -LL | // This is illegal, because the region bound on `proc` is 'static. -LL | Box::new(move || { *x }) - | ^^^^^^^^^^^^^^ ...is used and required to live as long as `'static` here - | -note: `'static` lifetime requirement introduced by the return type - --> $DIR/regions-proc-bound-capture.rs:7:59 - | -LL | fn static_proc(x: &isize) -> Box (isize) + 'static> { - | ^^^^^^^ `'static` requirement introduced here -LL | // This is illegal, because the region bound on `proc` is 'static. -LL | Box::new(move || { *x }) - | ------------------------ because of this returned expression -help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `x` - | -LL | fn static_proc(x: &isize) -> Box (isize) + '_> { - | ~~ -help: alternatively, add an explicit `'static` bound to this reference - | -LL | fn static_proc(x: &'static isize) -> Box (isize) + 'static> { - | ~~~~~~~~~~~~~~ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0759`. diff --git a/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.base.stderr b/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.base.stderr new file mode 100644 index 00000000000..7ecdb0cd15e --- /dev/null +++ b/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.base.stderr @@ -0,0 +1,13 @@ +error[E0623]: lifetime mismatch + --> $DIR/regions-reborrow-from-shorter-mut-ref-mut-ref.rs:8:5 + | +LL | fn copy_borrowed_ptr<'a, 'b, 'c>(p: &'a mut &'b mut &'c mut isize) -> &'b mut isize { + | ----------------------------- ------------- + | | + | this parameter and the return type are declared with different lifetimes... +LL | &mut ***p + | ^^^^^^^^^ ...but data from `p` is returned here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.nll.stderr b/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.nll.stderr index dc905d076bb..519ada7bdfc 100644 --- a/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.nll.stderr +++ b/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-reborrow-from-shorter-mut-ref-mut-ref.rs:4:5 + --> $DIR/regions-reborrow-from-shorter-mut-ref-mut-ref.rs:8:5 | LL | fn copy_borrowed_ptr<'a, 'b, 'c>(p: &'a mut &'b mut &'c mut isize) -> &'b mut isize { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.rs b/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.rs index 35aca8be25b..c4ad05010fb 100644 --- a/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.rs +++ b/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.rs @@ -1,7 +1,13 @@ // Issue #8624. Test for reborrowing with 3 levels, not just two. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn copy_borrowed_ptr<'a, 'b, 'c>(p: &'a mut &'b mut &'c mut isize) -> &'b mut isize { - &mut ***p //~ ERROR lifetime mismatch [E0623] + &mut ***p + //[base]~^ ERROR lifetime mismatch [E0623] + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.stderr b/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.stderr deleted file mode 100644 index aca3a1ed057..00000000000 --- a/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0623]: lifetime mismatch - --> $DIR/regions-reborrow-from-shorter-mut-ref-mut-ref.rs:4:5 - | -LL | fn copy_borrowed_ptr<'a, 'b, 'c>(p: &'a mut &'b mut &'c mut isize) -> &'b mut isize { - | ----------------------------- ------------- - | | - | this parameter and the return type are declared with different lifetimes... -LL | &mut ***p - | ^^^^^^^^^ ...but data from `p` is returned here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.base.stderr b/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.base.stderr new file mode 100644 index 00000000000..3cb7de15850 --- /dev/null +++ b/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.base.stderr @@ -0,0 +1,13 @@ +error[E0623]: lifetime mismatch + --> $DIR/regions-reborrow-from-shorter-mut-ref.rs:10:5 + | +LL | fn copy_borrowed_ptr<'a, 'b>(p: &'a mut &'b mut isize) -> &'b mut isize { + | --------------------- ------------- + | | + | this parameter and the return type are declared with different lifetimes... +LL | &mut **p + | ^^^^^^^^ ...but data from `p` is returned here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.nll.stderr b/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.nll.stderr index c98ec477417..4dd2a83739c 100644 --- a/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.nll.stderr +++ b/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-reborrow-from-shorter-mut-ref.rs:6:5 + --> $DIR/regions-reborrow-from-shorter-mut-ref.rs:10:5 | LL | fn copy_borrowed_ptr<'a, 'b>(p: &'a mut &'b mut isize) -> &'b mut isize { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.rs b/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.rs index 77041ab4f05..c41e76e4d2a 100644 --- a/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.rs +++ b/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.rs @@ -2,8 +2,14 @@ // pointer which is backed by another `&'a mut` can only be done // for `'a` (which must be a sublifetime of `'b`). +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn copy_borrowed_ptr<'a, 'b>(p: &'a mut &'b mut isize) -> &'b mut isize { - &mut **p //~ ERROR lifetime mismatch [E0623] + &mut **p + //[base]~^ ERROR lifetime mismatch [E0623] + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.stderr b/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.stderr deleted file mode 100644 index a9916dbe4f5..00000000000 --- a/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0623]: lifetime mismatch - --> $DIR/regions-reborrow-from-shorter-mut-ref.rs:6:5 - | -LL | fn copy_borrowed_ptr<'a, 'b>(p: &'a mut &'b mut isize) -> &'b mut isize { - | --------------------- ------------- - | | - | this parameter and the return type are declared with different lifetimes... -LL | &mut **p - | ^^^^^^^^ ...but data from `p` is returned here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/regions/regions-ret-borrowed-1.base.stderr b/src/test/ui/regions/regions-ret-borrowed-1.base.stderr new file mode 100644 index 00000000000..d102f93a647 --- /dev/null +++ b/src/test/ui/regions/regions-ret-borrowed-1.base.stderr @@ -0,0 +1,32 @@ +error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements + --> $DIR/regions-ret-borrowed-1.rs:14:14 + | +LL | with(|o| o) + | ^ + | +note: first, the lifetime cannot outlive the anonymous lifetime #1 defined here... + --> $DIR/regions-ret-borrowed-1.rs:14:10 + | +LL | with(|o| o) + | ^^^^^ +note: ...so that the types are compatible + --> $DIR/regions-ret-borrowed-1.rs:14:14 + | +LL | with(|o| o) + | ^ + = note: expected `&isize` + found `&isize` +note: but, the lifetime must be valid for the lifetime `'a` as defined here... + --> $DIR/regions-ret-borrowed-1.rs:13:14 + | +LL | fn return_it<'a>() -> &'a isize { + | ^^ +note: ...so that reference does not outlive borrowed content + --> $DIR/regions-ret-borrowed-1.rs:14:5 + | +LL | with(|o| o) + | ^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/regions/regions-ret-borrowed-1.nll.stderr b/src/test/ui/regions/regions-ret-borrowed-1.nll.stderr index 0784e894ea9..4fdadccab15 100644 --- a/src/test/ui/regions/regions-ret-borrowed-1.nll.stderr +++ b/src/test/ui/regions/regions-ret-borrowed-1.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-ret-borrowed-1.rs:10:14 + --> $DIR/regions-ret-borrowed-1.rs:14:14 | LL | with(|o| o) | -- ^ returning this value requires that `'1` must outlive `'2` diff --git a/src/test/ui/regions/regions-ret-borrowed-1.rs b/src/test/ui/regions/regions-ret-borrowed-1.rs index 1be5edee599..fed631320b4 100644 --- a/src/test/ui/regions/regions-ret-borrowed-1.rs +++ b/src/test/ui/regions/regions-ret-borrowed-1.rs @@ -2,13 +2,18 @@ // some point regions-ret-borrowed reported an error but this file did // not, due to special hardcoding around the anonymous region. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn with(f: F) -> R where F: for<'a> FnOnce(&'a isize) -> R { f(&3) } fn return_it<'a>() -> &'a isize { with(|o| o) - //~^ ERROR cannot infer + //[base]~^ ERROR cannot infer an appropriate lifetime due to conflicting requirements [E0495] + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/regions/regions-ret-borrowed-1.stderr b/src/test/ui/regions/regions-ret-borrowed-1.stderr deleted file mode 100644 index 86df7bfeb70..00000000000 --- a/src/test/ui/regions/regions-ret-borrowed-1.stderr +++ /dev/null @@ -1,32 +0,0 @@ -error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements - --> $DIR/regions-ret-borrowed-1.rs:10:14 - | -LL | with(|o| o) - | ^ - | -note: first, the lifetime cannot outlive the anonymous lifetime #1 defined here... - --> $DIR/regions-ret-borrowed-1.rs:10:10 - | -LL | with(|o| o) - | ^^^^^ -note: ...so that the types are compatible - --> $DIR/regions-ret-borrowed-1.rs:10:14 - | -LL | with(|o| o) - | ^ - = note: expected `&isize` - found `&isize` -note: but, the lifetime must be valid for the lifetime `'a` as defined here... - --> $DIR/regions-ret-borrowed-1.rs:9:14 - | -LL | fn return_it<'a>() -> &'a isize { - | ^^ -note: ...so that reference does not outlive borrowed content - --> $DIR/regions-ret-borrowed-1.rs:10:5 - | -LL | with(|o| o) - | ^^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/regions/regions-ret-borrowed.base.stderr b/src/test/ui/regions/regions-ret-borrowed.base.stderr new file mode 100644 index 00000000000..62b42b5dd11 --- /dev/null +++ b/src/test/ui/regions/regions-ret-borrowed.base.stderr @@ -0,0 +1,32 @@ +error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements + --> $DIR/regions-ret-borrowed.rs:17:14 + | +LL | with(|o| o) + | ^ + | +note: first, the lifetime cannot outlive the anonymous lifetime #1 defined here... + --> $DIR/regions-ret-borrowed.rs:17:10 + | +LL | with(|o| o) + | ^^^^^ +note: ...so that the types are compatible + --> $DIR/regions-ret-borrowed.rs:17:14 + | +LL | with(|o| o) + | ^ + = note: expected `&isize` + found `&isize` +note: but, the lifetime must be valid for the lifetime `'a` as defined here... + --> $DIR/regions-ret-borrowed.rs:16:14 + | +LL | fn return_it<'a>() -> &'a isize { + | ^^ +note: ...so that reference does not outlive borrowed content + --> $DIR/regions-ret-borrowed.rs:17:5 + | +LL | with(|o| o) + | ^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/regions/regions-ret-borrowed.nll.stderr b/src/test/ui/regions/regions-ret-borrowed.nll.stderr index d9be5ef89cc..d3ea5bd875f 100644 --- a/src/test/ui/regions/regions-ret-borrowed.nll.stderr +++ b/src/test/ui/regions/regions-ret-borrowed.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-ret-borrowed.rs:13:14 + --> $DIR/regions-ret-borrowed.rs:17:14 | LL | with(|o| o) | -- ^ returning this value requires that `'1` must outlive `'2` diff --git a/src/test/ui/regions/regions-ret-borrowed.rs b/src/test/ui/regions/regions-ret-borrowed.rs index 5fca92d68b6..2b6855d1c71 100644 --- a/src/test/ui/regions/regions-ret-borrowed.rs +++ b/src/test/ui/regions/regions-ret-borrowed.rs @@ -5,13 +5,18 @@ // used to successfully compile because we failed to account for the // fact that fn(x: &isize) rebound the region &. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn with(f: F) -> R where F: FnOnce(&isize) -> R { f(&3) } fn return_it<'a>() -> &'a isize { with(|o| o) - //~^ ERROR cannot infer + //[base]~^ ERROR cannot infer an appropriate lifetime due to conflicting requirements [E0495] + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/regions/regions-ret-borrowed.stderr b/src/test/ui/regions/regions-ret-borrowed.stderr deleted file mode 100644 index b9a06d97433..00000000000 --- a/src/test/ui/regions/regions-ret-borrowed.stderr +++ /dev/null @@ -1,32 +0,0 @@ -error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements - --> $DIR/regions-ret-borrowed.rs:13:14 - | -LL | with(|o| o) - | ^ - | -note: first, the lifetime cannot outlive the anonymous lifetime #1 defined here... - --> $DIR/regions-ret-borrowed.rs:13:10 - | -LL | with(|o| o) - | ^^^^^ -note: ...so that the types are compatible - --> $DIR/regions-ret-borrowed.rs:13:14 - | -LL | with(|o| o) - | ^ - = note: expected `&isize` - found `&isize` -note: but, the lifetime must be valid for the lifetime `'a` as defined here... - --> $DIR/regions-ret-borrowed.rs:12:14 - | -LL | fn return_it<'a>() -> &'a isize { - | ^^ -note: ...so that reference does not outlive borrowed content - --> $DIR/regions-ret-borrowed.rs:13:5 - | -LL | with(|o| o) - | ^^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/regions/regions-static-bound.base.stderr b/src/test/ui/regions/regions-static-bound.base.stderr new file mode 100644 index 00000000000..b37ce1e76bd --- /dev/null +++ b/src/test/ui/regions/regions-static-bound.base.stderr @@ -0,0 +1,46 @@ +error[E0312]: lifetime of reference outlives lifetime of borrowed content... + --> $DIR/regions-static-bound.rs:10:5 + | +LL | t + | ^ + | + = note: ...the reference is valid for the static lifetime... +note: ...but the borrowed content is only valid for the lifetime `'a` as defined here + --> $DIR/regions-static-bound.rs:9:24 + | +LL | fn static_id_wrong_way<'a>(t: &'a ()) -> &'static () where 'static: 'a { + | ^^ + +error[E0759]: `u` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement + --> $DIR/regions-static-bound.rs:16:5 + | +LL | fn error(u: &(), v: &()) { + | --- this data with an anonymous lifetime `'_`... +LL | static_id(&u); + | ^^^^^^^^^ -- ...is used here... + | +note: ...and is required to live as long as `'static` here + --> $DIR/regions-static-bound.rs:16:5 + | +LL | static_id(&u); + | ^^^^^^^^^ + +error[E0759]: `v` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement + --> $DIR/regions-static-bound.rs:19:5 + | +LL | fn error(u: &(), v: &()) { + | --- this data with an anonymous lifetime `'_`... +... +LL | static_id_indirect(&v); + | ^^^^^^^^^^^^^^^^^^ -- ...is used here... + | +note: ...and is required to live as long as `'static` here + --> $DIR/regions-static-bound.rs:19:5 + | +LL | static_id_indirect(&v); + | ^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0312, E0759. +For more information about an error, try `rustc --explain E0312`. diff --git a/src/test/ui/regions/regions-static-bound.nll.stderr b/src/test/ui/regions/regions-static-bound.nll.stderr index 699638c7ef9..d228c42f995 100644 --- a/src/test/ui/regions/regions-static-bound.nll.stderr +++ b/src/test/ui/regions/regions-static-bound.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-static-bound.rs:6:5 + --> $DIR/regions-static-bound.rs:10:5 | LL | fn static_id_wrong_way<'a>(t: &'a ()) -> &'static () where 'static: 'a { | -- lifetime `'a` defined here @@ -7,7 +7,7 @@ LL | t | ^ returning this value requires that `'a` must outlive `'static` error[E0521]: borrowed data escapes outside of function - --> $DIR/regions-static-bound.rs:10:5 + --> $DIR/regions-static-bound.rs:16:5 | LL | fn error(u: &(), v: &()) { | - - let's call the lifetime of this reference `'1` @@ -20,13 +20,13 @@ LL | static_id(&u); | argument requires that `'1` must outlive `'static` error[E0521]: borrowed data escapes outside of function - --> $DIR/regions-static-bound.rs:11:5 + --> $DIR/regions-static-bound.rs:19:5 | LL | fn error(u: &(), v: &()) { | - - let's call the lifetime of this reference `'2` | | | `v` is a reference that is only valid in the function body -LL | static_id(&u); +... LL | static_id_indirect(&v); | ^^^^^^^^^^^^^^^^^^^^^^ | | diff --git a/src/test/ui/regions/regions-static-bound.rs b/src/test/ui/regions/regions-static-bound.rs index a977a8b36d0..058b717c95d 100644 --- a/src/test/ui/regions/regions-static-bound.rs +++ b/src/test/ui/regions/regions-static-bound.rs @@ -1,14 +1,24 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + fn static_id<'a,'b>(t: &'a ()) -> &'static () where 'a: 'static { t } fn static_id_indirect<'a,'b>(t: &'a ()) -> &'static () where 'a: 'b, 'b: 'static { t } fn static_id_wrong_way<'a>(t: &'a ()) -> &'static () where 'static: 'a { - t //~ ERROR E0312 + t + //[base]~^ ERROR E0312 + //[nll]~^^ ERROR lifetime may not live long enough } fn error(u: &(), v: &()) { - static_id(&u); //~ ERROR `u` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759] - static_id_indirect(&v); //~ ERROR `v` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759] + static_id(&u); + //[base]~^ ERROR `u` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759] + //[nll]~^^ ERROR borrowed data escapes outside of function [E0521] + static_id_indirect(&v); + //[base]~^ ERROR `v` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759] + //[nll]~^^ ERROR borrowed data escapes outside of function [E0521] } fn main() {} diff --git a/src/test/ui/regions/regions-static-bound.stderr b/src/test/ui/regions/regions-static-bound.stderr deleted file mode 100644 index b8e69e02609..00000000000 --- a/src/test/ui/regions/regions-static-bound.stderr +++ /dev/null @@ -1,46 +0,0 @@ -error[E0312]: lifetime of reference outlives lifetime of borrowed content... - --> $DIR/regions-static-bound.rs:6:5 - | -LL | t - | ^ - | - = note: ...the reference is valid for the static lifetime... -note: ...but the borrowed content is only valid for the lifetime `'a` as defined here - --> $DIR/regions-static-bound.rs:5:24 - | -LL | fn static_id_wrong_way<'a>(t: &'a ()) -> &'static () where 'static: 'a { - | ^^ - -error[E0759]: `u` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/regions-static-bound.rs:10:5 - | -LL | fn error(u: &(), v: &()) { - | --- this data with an anonymous lifetime `'_`... -LL | static_id(&u); - | ^^^^^^^^^ -- ...is used here... - | -note: ...and is required to live as long as `'static` here - --> $DIR/regions-static-bound.rs:10:5 - | -LL | static_id(&u); - | ^^^^^^^^^ - -error[E0759]: `v` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement - --> $DIR/regions-static-bound.rs:11:5 - | -LL | fn error(u: &(), v: &()) { - | --- this data with an anonymous lifetime `'_`... -LL | static_id(&u); -LL | static_id_indirect(&v); - | ^^^^^^^^^^^^^^^^^^ -- ...is used here... - | -note: ...and is required to live as long as `'static` here - --> $DIR/regions-static-bound.rs:11:5 - | -LL | static_id_indirect(&v); - | ^^^^^^^^^^^^^^^^^^ - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0312, E0759. -For more information about an error, try `rustc --explain E0312`. diff --git a/src/test/ui/regions/regions-trait-object-subtyping.base.stderr b/src/test/ui/regions/regions-trait-object-subtyping.base.stderr new file mode 100644 index 00000000000..9f52136f0c0 --- /dev/null +++ b/src/test/ui/regions/regions-trait-object-subtyping.base.stderr @@ -0,0 +1,69 @@ +error[E0478]: lifetime bound not satisfied + --> $DIR/regions-trait-object-subtyping.rs:19:5 + | +LL | x + | ^ + | +note: lifetime parameter instantiated with the lifetime `'a` as defined here + --> $DIR/regions-trait-object-subtyping.rs:17:9 + | +LL | fn foo3<'a,'b>(x: &'a mut dyn Dummy) -> &'b mut dyn Dummy { + | ^^ +note: but lifetime parameter must outlive the lifetime `'b` as defined here + --> $DIR/regions-trait-object-subtyping.rs:17:12 + | +LL | fn foo3<'a,'b>(x: &'a mut dyn Dummy) -> &'b mut dyn Dummy { + | ^^ + +error[E0495]: cannot infer an appropriate lifetime for automatic coercion due to conflicting requirements + --> $DIR/regions-trait-object-subtyping.rs:19:5 + | +LL | x + | ^ + | +note: first, the lifetime cannot outlive the lifetime `'a` as defined here... + --> $DIR/regions-trait-object-subtyping.rs:17:9 + | +LL | fn foo3<'a,'b>(x: &'a mut dyn Dummy) -> &'b mut dyn Dummy { + | ^^ +note: ...so that reference does not outlive borrowed content + --> $DIR/regions-trait-object-subtyping.rs:19:5 + | +LL | x + | ^ +note: but, the lifetime must be valid for the lifetime `'b` as defined here... + --> $DIR/regions-trait-object-subtyping.rs:17:12 + | +LL | fn foo3<'a,'b>(x: &'a mut dyn Dummy) -> &'b mut dyn Dummy { + | ^^ +note: ...so that the types are compatible + --> $DIR/regions-trait-object-subtyping.rs:19:5 + | +LL | x + | ^ + = note: expected `&'b mut (dyn Dummy + 'b)` + found `&mut (dyn Dummy + 'b)` + +error[E0308]: mismatched types + --> $DIR/regions-trait-object-subtyping.rs:28:5 + | +LL | x + | ^ lifetime mismatch + | + = note: expected struct `Wrapper<&'b mut (dyn Dummy + 'b)>` + found struct `Wrapper<&'a mut (dyn Dummy + 'a)>` +note: the lifetime `'b` as defined here... + --> $DIR/regions-trait-object-subtyping.rs:26:15 + | +LL | fn foo4<'a:'b,'b>(x: Wrapper<&'a mut dyn Dummy>) -> Wrapper<&'b mut dyn Dummy> { + | ^^ +note: ...does not necessarily outlive the lifetime `'a` as defined here + --> $DIR/regions-trait-object-subtyping.rs:26:9 + | +LL | fn foo4<'a:'b,'b>(x: Wrapper<&'a mut dyn Dummy>) -> Wrapper<&'b mut dyn Dummy> { + | ^^ + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0308, E0478, E0495. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/regions/regions-trait-object-subtyping.nll.stderr b/src/test/ui/regions/regions-trait-object-subtyping.nll.stderr index 1b3a116d508..c8cec3bd377 100644 --- a/src/test/ui/regions/regions-trait-object-subtyping.nll.stderr +++ b/src/test/ui/regions/regions-trait-object-subtyping.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-trait-object-subtyping.rs:15:5 + --> $DIR/regions-trait-object-subtyping.rs:19:5 | LL | fn foo3<'a,'b>(x: &'a mut dyn Dummy) -> &'b mut dyn Dummy { | -- -- lifetime `'b` defined here @@ -15,7 +15,7 @@ LL | x = help: see for more information about variance error: lifetime may not live long enough - --> $DIR/regions-trait-object-subtyping.rs:22:5 + --> $DIR/regions-trait-object-subtyping.rs:28:5 | LL | fn foo4<'a:'b,'b>(x: Wrapper<&'a mut dyn Dummy>) -> Wrapper<&'b mut dyn Dummy> { | -- -- lifetime `'b` defined here diff --git a/src/test/ui/regions/regions-trait-object-subtyping.rs b/src/test/ui/regions/regions-trait-object-subtyping.rs index 5b36194870e..f108fc81cea 100644 --- a/src/test/ui/regions/regions-trait-object-subtyping.rs +++ b/src/test/ui/regions/regions-trait-object-subtyping.rs @@ -1,3 +1,7 @@ +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + trait Dummy { fn dummy(&self); } fn foo1<'a:'b,'b>(x: &'a mut (dyn Dummy+'a)) -> &'b mut (dyn Dummy+'b) { @@ -12,14 +16,18 @@ fn foo2<'a:'b,'b>(x: &'b mut (dyn Dummy+'a)) -> &'b mut (dyn Dummy+'b) { fn foo3<'a,'b>(x: &'a mut dyn Dummy) -> &'b mut dyn Dummy { // Without knowing 'a:'b, we can't coerce - x //~ ERROR lifetime bound not satisfied - //~^ ERROR cannot infer an appropriate lifetime + x + //[base]~^ ERROR lifetime bound not satisfied + //[base]~| ERROR cannot infer an appropriate lifetime + //[nll]~^^^ ERROR lifetime may not live long enough } struct Wrapper(T); fn foo4<'a:'b,'b>(x: Wrapper<&'a mut dyn Dummy>) -> Wrapper<&'b mut dyn Dummy> { // We can't coerce because it is packed in `Wrapper` - x //~ ERROR mismatched types + x + //[base]~^ ERROR mismatched types + //[nll]~^^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/regions/regions-trait-object-subtyping.stderr b/src/test/ui/regions/regions-trait-object-subtyping.stderr deleted file mode 100644 index d45ca94ad27..00000000000 --- a/src/test/ui/regions/regions-trait-object-subtyping.stderr +++ /dev/null @@ -1,69 +0,0 @@ -error[E0478]: lifetime bound not satisfied - --> $DIR/regions-trait-object-subtyping.rs:15:5 - | -LL | x - | ^ - | -note: lifetime parameter instantiated with the lifetime `'a` as defined here - --> $DIR/regions-trait-object-subtyping.rs:13:9 - | -LL | fn foo3<'a,'b>(x: &'a mut dyn Dummy) -> &'b mut dyn Dummy { - | ^^ -note: but lifetime parameter must outlive the lifetime `'b` as defined here - --> $DIR/regions-trait-object-subtyping.rs:13:12 - | -LL | fn foo3<'a,'b>(x: &'a mut dyn Dummy) -> &'b mut dyn Dummy { - | ^^ - -error[E0495]: cannot infer an appropriate lifetime for automatic coercion due to conflicting requirements - --> $DIR/regions-trait-object-subtyping.rs:15:5 - | -LL | x - | ^ - | -note: first, the lifetime cannot outlive the lifetime `'a` as defined here... - --> $DIR/regions-trait-object-subtyping.rs:13:9 - | -LL | fn foo3<'a,'b>(x: &'a mut dyn Dummy) -> &'b mut dyn Dummy { - | ^^ -note: ...so that reference does not outlive borrowed content - --> $DIR/regions-trait-object-subtyping.rs:15:5 - | -LL | x - | ^ -note: but, the lifetime must be valid for the lifetime `'b` as defined here... - --> $DIR/regions-trait-object-subtyping.rs:13:12 - | -LL | fn foo3<'a,'b>(x: &'a mut dyn Dummy) -> &'b mut dyn Dummy { - | ^^ -note: ...so that the types are compatible - --> $DIR/regions-trait-object-subtyping.rs:15:5 - | -LL | x - | ^ - = note: expected `&'b mut (dyn Dummy + 'b)` - found `&mut (dyn Dummy + 'b)` - -error[E0308]: mismatched types - --> $DIR/regions-trait-object-subtyping.rs:22:5 - | -LL | x - | ^ lifetime mismatch - | - = note: expected struct `Wrapper<&'b mut (dyn Dummy + 'b)>` - found struct `Wrapper<&'a mut (dyn Dummy + 'a)>` -note: the lifetime `'b` as defined here... - --> $DIR/regions-trait-object-subtyping.rs:20:15 - | -LL | fn foo4<'a:'b,'b>(x: Wrapper<&'a mut dyn Dummy>) -> Wrapper<&'b mut dyn Dummy> { - | ^^ -note: ...does not necessarily outlive the lifetime `'a` as defined here - --> $DIR/regions-trait-object-subtyping.rs:20:9 - | -LL | fn foo4<'a:'b,'b>(x: Wrapper<&'a mut dyn Dummy>) -> Wrapper<&'b mut dyn Dummy> { - | ^^ - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0308, E0478, E0495. -For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.base.stderr b/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.base.stderr new file mode 100644 index 00000000000..23b3dea885d --- /dev/null +++ b/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.base.stderr @@ -0,0 +1,12 @@ +error[E0623]: lifetime mismatch + --> $DIR/regions-variance-contravariant-use-covariant-in-second-position.rs:29:30 + | +LL | fn use_<'short,'long>(c: S<'long, 'short>, + | ---------------- this type is declared with multiple lifetimes... +... +LL | let _: S<'long, 'long> = c; + | ^ ...but data with one lifetime flows into the other here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.nll.stderr b/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.nll.stderr index 5352be430fb..f364f423f4e 100644 --- a/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.nll.stderr +++ b/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-variance-contravariant-use-covariant-in-second-position.rs:25:12 + --> $DIR/regions-variance-contravariant-use-covariant-in-second-position.rs:29:12 | LL | fn use_<'short,'long>(c: S<'long, 'short>, | ------ ----- lifetime `'long` defined here diff --git a/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.rs b/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.rs index 8ddd041d457..4bf32ec3082 100644 --- a/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.rs +++ b/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.rs @@ -4,6 +4,10 @@ // Note: see variance-regions-*.rs for the tests that check that the // variance inference works in the first place. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // `S` is contravariant with respect to both parameters. struct S<'a, 'b> { f: &'a isize, @@ -22,7 +26,9 @@ fn use_<'short,'long>(c: S<'long, 'short>, // 'short <= 'long, this would be true if the Contravariant type were // covariant with respect to its parameter 'a. - let _: S<'long, 'long> = c; //~ ERROR E0623 + let _: S<'long, 'long> = c; + //[base]~^ ERROR E0623 + //[nll]~^^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.stderr b/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.stderr deleted file mode 100644 index 98f7a8136da..00000000000 --- a/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0623]: lifetime mismatch - --> $DIR/regions-variance-contravariant-use-covariant-in-second-position.rs:25:30 - | -LL | fn use_<'short,'long>(c: S<'long, 'short>, - | ---------------- this type is declared with multiple lifetimes... -... -LL | let _: S<'long, 'long> = c; - | ^ ...but data with one lifetime flows into the other here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/regions/regions-variance-contravariant-use-covariant.base.stderr b/src/test/ui/regions/regions-variance-contravariant-use-covariant.base.stderr new file mode 100644 index 00000000000..8eca0d4d121 --- /dev/null +++ b/src/test/ui/regions/regions-variance-contravariant-use-covariant.base.stderr @@ -0,0 +1,15 @@ +error[E0623]: lifetime mismatch + --> $DIR/regions-variance-contravariant-use-covariant.rs:27:35 + | +LL | fn use_<'short,'long>(c: Contravariant<'short>, + | --------------------- these two types are declared with different lifetimes... +LL | s: &'short isize, +LL | l: &'long isize, + | ------------ +... +LL | let _: Contravariant<'long> = c; + | ^ ...but data from `c` flows into `l` here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/regions/regions-variance-contravariant-use-covariant.nll.stderr b/src/test/ui/regions/regions-variance-contravariant-use-covariant.nll.stderr index 22c9b915bb9..bc6dd6e69ed 100644 --- a/src/test/ui/regions/regions-variance-contravariant-use-covariant.nll.stderr +++ b/src/test/ui/regions/regions-variance-contravariant-use-covariant.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-variance-contravariant-use-covariant.rs:23:12 + --> $DIR/regions-variance-contravariant-use-covariant.rs:27:12 | LL | fn use_<'short,'long>(c: Contravariant<'short>, | ------ ----- lifetime `'long` defined here diff --git a/src/test/ui/regions/regions-variance-contravariant-use-covariant.rs b/src/test/ui/regions/regions-variance-contravariant-use-covariant.rs index cbdf62ecb61..ea08a709230 100644 --- a/src/test/ui/regions/regions-variance-contravariant-use-covariant.rs +++ b/src/test/ui/regions/regions-variance-contravariant-use-covariant.rs @@ -4,6 +4,10 @@ // Note: see variance-regions-*.rs for the tests that check that the // variance inference works in the first place. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // This is contravariant with respect to 'a, meaning that // Contravariant<'long> <: Contravariant<'short> iff // 'short <= 'long @@ -20,7 +24,9 @@ fn use_<'short,'long>(c: Contravariant<'short>, // 'short <= 'long, this would be true if the Contravariant type were // covariant with respect to its parameter 'a. - let _: Contravariant<'long> = c; //~ ERROR E0623 + let _: Contravariant<'long> = c; + //[base]~^ ERROR E0623 + //[nll]~^^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/regions/regions-variance-contravariant-use-covariant.stderr b/src/test/ui/regions/regions-variance-contravariant-use-covariant.stderr deleted file mode 100644 index e7c106cbbe3..00000000000 --- a/src/test/ui/regions/regions-variance-contravariant-use-covariant.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0623]: lifetime mismatch - --> $DIR/regions-variance-contravariant-use-covariant.rs:23:35 - | -LL | fn use_<'short,'long>(c: Contravariant<'short>, - | --------------------- these two types are declared with different lifetimes... -LL | s: &'short isize, -LL | l: &'long isize, - | ------------ -... -LL | let _: Contravariant<'long> = c; - | ^ ...but data from `c` flows into `l` here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/regions/regions-variance-covariant-use-contravariant.base.stderr b/src/test/ui/regions/regions-variance-covariant-use-contravariant.base.stderr new file mode 100644 index 00000000000..565de38ee11 --- /dev/null +++ b/src/test/ui/regions/regions-variance-covariant-use-contravariant.base.stderr @@ -0,0 +1,14 @@ +error[E0623]: lifetime mismatch + --> $DIR/regions-variance-covariant-use-contravariant.rs:27:32 + | +LL | fn use_<'short,'long>(c: Covariant<'long>, + | ---------------- +LL | s: &'short isize, + | ------------- these two types are declared with different lifetimes... +... +LL | let _: Covariant<'short> = c; + | ^ ...but data from `s` flows into `c` here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/regions/regions-variance-covariant-use-contravariant.nll.stderr b/src/test/ui/regions/regions-variance-covariant-use-contravariant.nll.stderr index a07181ad553..9d3cebc9a4d 100644 --- a/src/test/ui/regions/regions-variance-covariant-use-contravariant.nll.stderr +++ b/src/test/ui/regions/regions-variance-covariant-use-contravariant.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-variance-covariant-use-contravariant.rs:23:12 + --> $DIR/regions-variance-covariant-use-contravariant.rs:27:12 | LL | fn use_<'short,'long>(c: Covariant<'long>, | ------ ----- lifetime `'long` defined here diff --git a/src/test/ui/regions/regions-variance-covariant-use-contravariant.rs b/src/test/ui/regions/regions-variance-covariant-use-contravariant.rs index 9aa0c819271..748ad84840a 100644 --- a/src/test/ui/regions/regions-variance-covariant-use-contravariant.rs +++ b/src/test/ui/regions/regions-variance-covariant-use-contravariant.rs @@ -4,6 +4,10 @@ // Note: see variance-regions-*.rs for the tests that check that the // variance inference works in the first place. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + // This is covariant with respect to 'a, meaning that // Covariant<'foo> <: Covariant<'static> because // 'foo <= 'static @@ -20,7 +24,9 @@ fn use_<'short,'long>(c: Covariant<'long>, // 'short <= 'long, this would be true if the Covariant type were // contravariant with respect to its parameter 'a. - let _: Covariant<'short> = c; //~ ERROR E0623 + let _: Covariant<'short> = c; + //[base]~^ ERROR E0623 + //[nll]~^^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/regions/regions-variance-covariant-use-contravariant.stderr b/src/test/ui/regions/regions-variance-covariant-use-contravariant.stderr deleted file mode 100644 index e5e5261ba99..00000000000 --- a/src/test/ui/regions/regions-variance-covariant-use-contravariant.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0623]: lifetime mismatch - --> $DIR/regions-variance-covariant-use-contravariant.rs:23:32 - | -LL | fn use_<'short,'long>(c: Covariant<'long>, - | ---------------- -LL | s: &'short isize, - | ------------- these two types are declared with different lifetimes... -... -LL | let _: Covariant<'short> = c; - | ^ ...but data from `s` flows into `c` here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/regions/regions-variance-invariant-use-contravariant.base.stderr b/src/test/ui/regions/regions-variance-invariant-use-contravariant.base.stderr new file mode 100644 index 00000000000..e2e8958f53e --- /dev/null +++ b/src/test/ui/regions/regions-variance-invariant-use-contravariant.base.stderr @@ -0,0 +1,14 @@ +error[E0623]: lifetime mismatch + --> $DIR/regions-variance-invariant-use-contravariant.rs:24:32 + | +LL | fn use_<'short,'long>(c: Invariant<'long>, + | ---------------- +LL | s: &'short isize, + | ------------- these two types are declared with different lifetimes... +... +LL | let _: Invariant<'short> = c; + | ^ ...but data from `s` flows into `c` here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/regions/regions-variance-invariant-use-contravariant.nll.stderr b/src/test/ui/regions/regions-variance-invariant-use-contravariant.nll.stderr index b35a2cb905d..b4ccb1693a7 100644 --- a/src/test/ui/regions/regions-variance-invariant-use-contravariant.nll.stderr +++ b/src/test/ui/regions/regions-variance-invariant-use-contravariant.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-variance-invariant-use-contravariant.rs:20:12 + --> $DIR/regions-variance-invariant-use-contravariant.rs:24:12 | LL | fn use_<'short,'long>(c: Invariant<'long>, | ------ ----- lifetime `'long` defined here diff --git a/src/test/ui/regions/regions-variance-invariant-use-contravariant.rs b/src/test/ui/regions/regions-variance-invariant-use-contravariant.rs index 663b23b37d4..788f9b1b4d0 100644 --- a/src/test/ui/regions/regions-variance-invariant-use-contravariant.rs +++ b/src/test/ui/regions/regions-variance-invariant-use-contravariant.rs @@ -4,6 +4,10 @@ // Note: see variance-regions-*.rs for the tests that check that the // variance inference works in the first place. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Invariant<'a> { f: &'a mut &'a isize } @@ -17,7 +21,9 @@ fn use_<'short,'long>(c: Invariant<'long>, // 'short <= 'long, this would be true if the Invariant type were // contravariant with respect to its parameter 'a. - let _: Invariant<'short> = c; //~ ERROR E0623 + let _: Invariant<'short> = c; + //[base]~^ ERROR E0623 + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { } diff --git a/src/test/ui/regions/regions-variance-invariant-use-contravariant.stderr b/src/test/ui/regions/regions-variance-invariant-use-contravariant.stderr deleted file mode 100644 index 2a2d5d019a1..00000000000 --- a/src/test/ui/regions/regions-variance-invariant-use-contravariant.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0623]: lifetime mismatch - --> $DIR/regions-variance-invariant-use-contravariant.rs:20:32 - | -LL | fn use_<'short,'long>(c: Invariant<'long>, - | ---------------- -LL | s: &'short isize, - | ------------- these two types are declared with different lifetimes... -... -LL | let _: Invariant<'short> = c; - | ^ ...but data from `s` flows into `c` here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0623`. diff --git a/src/test/ui/regions/regions-variance-invariant-use-covariant.base.stderr b/src/test/ui/regions/regions-variance-invariant-use-covariant.base.stderr new file mode 100644 index 00000000000..da91db1b918 --- /dev/null +++ b/src/test/ui/regions/regions-variance-invariant-use-covariant.base.stderr @@ -0,0 +1,18 @@ +error[E0308]: mismatched types + --> $DIR/regions-variance-invariant-use-covariant.rs:21:33 + | +LL | let _: Invariant<'static> = c; + | ^ lifetime mismatch + | + = note: expected struct `Invariant<'static>` + found struct `Invariant<'b>` +note: the lifetime `'b` as defined here... + --> $DIR/regions-variance-invariant-use-covariant.rs:15:9 + | +LL | fn use_<'b>(c: Invariant<'b>) { + | ^^ + = note: ...does not necessarily outlive the static lifetime + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/regions/regions-variance-invariant-use-covariant.nll.stderr b/src/test/ui/regions/regions-variance-invariant-use-covariant.nll.stderr index 761e78d179e..7b05c357589 100644 --- a/src/test/ui/regions/regions-variance-invariant-use-covariant.nll.stderr +++ b/src/test/ui/regions/regions-variance-invariant-use-covariant.nll.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/regions-variance-invariant-use-covariant.rs:17:12 + --> $DIR/regions-variance-invariant-use-covariant.rs:21:12 | LL | fn use_<'b>(c: Invariant<'b>) { | -- lifetime `'b` defined here diff --git a/src/test/ui/regions/regions-variance-invariant-use-covariant.rs b/src/test/ui/regions/regions-variance-invariant-use-covariant.rs index 07482e6fd19..4b7da4493ac 100644 --- a/src/test/ui/regions/regions-variance-invariant-use-covariant.rs +++ b/src/test/ui/regions/regions-variance-invariant-use-covariant.rs @@ -4,6 +4,10 @@ // Note: see variance-regions-*.rs for the tests that check that the // variance inference works in the first place. +// revisions: base nll +// ignore-compare-mode-nll +//[nll] compile-flags: -Z borrowck=mir + struct Invariant<'a> { f: &'a mut &'a isize } @@ -14,7 +18,9 @@ fn use_<'b>(c: Invariant<'b>) { // Since 'b <= 'static, this would be true if Invariant were covariant // with respect to its parameter 'a. - let _: Invariant<'static> = c; //~ ERROR mismatched types + let _: Invariant<'static> = c; + //[base]~^ ERROR mismatched types [E0308] + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { } diff --git a/src/test/ui/regions/regions-variance-invariant-use-covariant.stderr b/src/test/ui/regions/regions-variance-invariant-use-covariant.stderr deleted file mode 100644 index 7801517595d..00000000000 --- a/src/test/ui/regions/regions-variance-invariant-use-covariant.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/regions-variance-invariant-use-covariant.rs:17:33 - | -LL | let _: Invariant<'static> = c; - | ^ lifetime mismatch - | - = note: expected struct `Invariant<'static>` - found struct `Invariant<'b>` -note: the lifetime `'b` as defined here... - --> $DIR/regions-variance-invariant-use-covariant.rs:11:9 - | -LL | fn use_<'b>(c: Invariant<'b>) { - | ^^ - = note: ...does not necessarily outlive the static lifetime - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. -- cgit 1.4.1-3-g733a5