From f9ee681181798d5183e78d5ffff813cba40b44a7 Mon Sep 17 00:00:00 2001 From: Ellen Date: Fri, 12 Nov 2021 20:50:25 +0000 Subject: [PATCH] variant of PR 90840 with limited scope for backport. --- compiler/rustc_typeck/src/check/dropck.rs | 3 --- .../generic_const_exprs/drop_impl.rs | 16 ---------------- .../dropck/relate_lt_in_type_outlives_bound.rs | 13 +++++++++++++ .../relate_lt_in_type_outlives_bound.stderr | 17 +++++++++++++++++ 4 files changed, 30 insertions(+), 19 deletions(-) delete mode 100644 src/test/ui/const-generics/generic_const_exprs/drop_impl.rs create mode 100644 src/test/ui/dropck/relate_lt_in_type_outlives_bound.rs create mode 100644 src/test/ui/dropck/relate_lt_in_type_outlives_bound.stderr diff --git a/compiler/rustc_typeck/src/check/dropck.rs b/compiler/rustc_typeck/src/check/dropck.rs index fd150978f0074..8eeb8c315ec40 100644 --- a/compiler/rustc_typeck/src/check/dropck.rs +++ b/compiler/rustc_typeck/src/check/dropck.rs @@ -239,9 +239,6 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>( ty::PredicateKind::ConstEvaluatable(a), ty::PredicateKind::ConstEvaluatable(b), ) => tcx.try_unify_abstract_consts((a, b)), - (ty::PredicateKind::TypeOutlives(a), ty::PredicateKind::TypeOutlives(b)) => { - relator.relate(predicate.rebind(a.0), p.rebind(b.0)).is_ok() - } _ => predicate == p, } }; diff --git a/src/test/ui/const-generics/generic_const_exprs/drop_impl.rs b/src/test/ui/const-generics/generic_const_exprs/drop_impl.rs deleted file mode 100644 index 077f77aa0f404..0000000000000 --- a/src/test/ui/const-generics/generic_const_exprs/drop_impl.rs +++ /dev/null @@ -1,16 +0,0 @@ -//check-pass -#![feature(generic_const_exprs)] -#![allow(incomplete_features)] - -struct Foo -where - [(); N + 1]: ; - -impl Drop for Foo -where - [(); N + 1]: , -{ - fn drop(&mut self) {} -} - -fn main() {} diff --git a/src/test/ui/dropck/relate_lt_in_type_outlives_bound.rs b/src/test/ui/dropck/relate_lt_in_type_outlives_bound.rs new file mode 100644 index 0000000000000..42530d317308a --- /dev/null +++ b/src/test/ui/dropck/relate_lt_in_type_outlives_bound.rs @@ -0,0 +1,13 @@ +struct Wrapper<'a, T>(&'a T) +where + T: 'a; + +impl<'a, T> Drop for Wrapper<'a, T> +where + T: 'static, + //~^ error: `Drop` impl requires `T: 'static` but the struct it is implemented for does not +{ + fn drop(&mut self) {} +} + +fn main() {} diff --git a/src/test/ui/dropck/relate_lt_in_type_outlives_bound.stderr b/src/test/ui/dropck/relate_lt_in_type_outlives_bound.stderr new file mode 100644 index 0000000000000..5176684e15340 --- /dev/null +++ b/src/test/ui/dropck/relate_lt_in_type_outlives_bound.stderr @@ -0,0 +1,17 @@ +error[E0367]: `Drop` impl requires `T: 'static` but the struct it is implemented for does not + --> $DIR/relate_lt_in_type_outlives_bound.rs:7:8 + | +LL | T: 'static, + | ^^^^^^^ + | +note: the implementor must specify the same requirement + --> $DIR/relate_lt_in_type_outlives_bound.rs:1:1 + | +LL | / struct Wrapper<'a, T>(&'a T) +LL | | where +LL | | T: 'a; + | |__________^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0367`.