about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-11-06 20:31:56 +0100
committerGitHub <noreply@github.com>2023-11-06 20:31:56 +0100
commit9efe60b1eb1b11b3f0d53220746fa86281debbf6 (patch)
treef9cdb390fc8c3021c875dc994d6c58faa2fd1266
parent2a1f8bccee18f7397343cd94fde76680bc90ee1e (diff)
parent58351ae03f19520a586e7c3c1b13e74a9613d1d5 (diff)
Rollup merge of #117637 - lqd:trivial-bounds-with-binder-vars, r=compiler-errors
Check binders with bound vars for global bounds that don't hold

This fixes `soa_derive-0.13.0` from #117589's crater run.

r? `@compiler-errors`
-rw-r--r--compiler/rustc_hir_analysis/src/check/wfcheck.rs3
-rw-r--r--tests/ui/late-bound-lifetimes/predicate-is-global.rs8
2 files changed, 10 insertions, 1 deletions
diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs
index 046983e90f7..eb4491b89bf 100644
--- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs
+++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs
@@ -32,6 +32,7 @@ use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _
 use rustc_trait_selection::traits::{
     self, ObligationCause, ObligationCauseCode, ObligationCtxt, WellFormedLoc,
 };
+use rustc_type_ir::TypeFlags;
 
 use std::cell::LazyCell;
 use std::ops::{ControlFlow, Deref};
@@ -1877,7 +1878,7 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
                 continue;
             }
             // Match the existing behavior.
-            if pred.is_global() && !pred.has_late_bound_vars() {
+            if pred.is_global() && !pred.has_type_flags(TypeFlags::HAS_BINDER_VARS) {
                 let pred = self.normalize(span, None, pred);
                 let hir_node = tcx.hir().find_by_def_id(self.body_def_id);
 
diff --git a/tests/ui/late-bound-lifetimes/predicate-is-global.rs b/tests/ui/late-bound-lifetimes/predicate-is-global.rs
index ee4c4706005..be017a3f94f 100644
--- a/tests/ui/late-bound-lifetimes/predicate-is-global.rs
+++ b/tests/ui/late-bound-lifetimes/predicate-is-global.rs
@@ -29,4 +29,12 @@ impl Inherent {
     fn inherent(&self) {}
 }
 
+// This trivial bound doesn't hold, but the unused lifetime tripped up that check after #117589, and
+// showed up in its crater results (in `soa-derive 0.13.0`).
+fn do_it()
+where
+    for<'a> Inherent: Clone,
+{
+}
+
 fn main() {}