about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-11-27 17:36:00 +0000
committerbors <bors@rust-lang.org>2021-11-27 17:36:00 +0000
commit7e15b235f62dce8a21e51c2eff6b2c0cde9b018e (patch)
tree9b8500d228972307224f1818ca006ddf606546dc
parentef1a3b93491be53289ab6b8af235a9e100d771f2 (diff)
parent150bd8ba76722a46fd8a7aacb81c7072a8b677dc (diff)
downloadrust-7e15b235f62dce8a21e51c2eff6b2c0cde9b018e.tar.gz
rust-7e15b235f62dce8a21e51c2eff6b2c0cde9b018e.zip
Auto merge of #91263 - Mark-Simulacrum:beta-next, r=Mark-Simulacrum
[beta] backports

* relate lifetime in TypeOutlives bounds on drop impls #90840
*  [beta] [1.57] Disable LLVM newPM by default #91189

r? `@Mark-Simulacrum`
-rw-r--r--compiler/rustc_codegen_llvm/src/back/write.rs12
-rw-r--r--compiler/rustc_typeck/src/check/dropck.rs8
-rw-r--r--src/test/ui/dropck/relate_lt_in_type_outlives_bound.rs13
-rw-r--r--src/test/ui/dropck/relate_lt_in_type_outlives_bound.stderr17
4 files changed, 40 insertions, 10 deletions
diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs
index 380dfd38723..b6d682f2323 100644
--- a/compiler/rustc_codegen_llvm/src/back/write.rs
+++ b/compiler/rustc_codegen_llvm/src/back/write.rs
@@ -378,18 +378,14 @@ fn get_pgo_sample_use_path(config: &ModuleConfig) -> Option<CString> {
 }
 
 pub(crate) fn should_use_new_llvm_pass_manager(
-    cgcx: &CodegenContext<LlvmCodegenBackend>,
+    _cgcx: &CodegenContext<LlvmCodegenBackend>,
     config: &ModuleConfig,
 ) -> bool {
-    // The new pass manager is enabled by default for LLVM >= 13.
-    // This matches Clang, which also enables it since Clang 13.
-
-    // FIXME: There are some perf issues with the new pass manager
-    // when targeting s390x, so it is temporarily disabled for that
-    // arch, see https://github.com/rust-lang/rust/issues/89609
+    // The new pass manager is causing significant performance issues such as #91128, and is
+    // therefore disabled in stable versions of rustc by default.
     config
         .new_llvm_pass_manager
-        .unwrap_or_else(|| cgcx.target_arch != "s390x" && llvm_util::get_version() >= (13, 0, 0))
+        .unwrap_or(false)
 }
 
 pub(crate) unsafe fn optimize_with_new_llvm_pass_manager(
diff --git a/compiler/rustc_typeck/src/check/dropck.rs b/compiler/rustc_typeck/src/check/dropck.rs
index fd150978f00..9e2460b5700 100644
--- a/compiler/rustc_typeck/src/check/dropck.rs
+++ b/compiler/rustc_typeck/src/check/dropck.rs
@@ -239,8 +239,12 @@ 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()
+                (
+                    ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty_a, lt_a)),
+                    ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(ty_b, lt_b)),
+                ) => {
+                    relator.relate(predicate.rebind(ty_a), p.rebind(ty_b)).is_ok()
+                        && relator.relate(predicate.rebind(lt_a), p.rebind(lt_b)).is_ok()
                 }
                 _ => predicate == p,
             }
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 00000000000..42530d31730
--- /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 00000000000..5176684e153
--- /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`.