diff options
| author | Matthew Jasper <mjjasper1@gmail.com> | 2025-04-10 10:57:55 +0000 |
|---|---|---|
| committer | Matthew Jasper <mjjasper1@gmail.com> | 2025-04-14 10:00:28 +0000 |
| commit | 2d5e80b8cb89e9d809e569426d948e4f1fa6002d (patch) | |
| tree | 225c4df46a01ed2d5ebf8dcd6f721955190c1c57 /compiler/rustc_data_structures/src | |
| parent | f836ae4e663b6e8938096b8559e094d18361be55 (diff) | |
| download | rust-2d5e80b8cb89e9d809e569426d948e4f1fa6002d.tar.gz rust-2d5e80b8cb89e9d809e569426d948e4f1fa6002d.zip | |
Handle regions equivalent to 'static in non_local_bounds
`non_local_bounds` would only find non local bounds that strictly bound a given region, but it's possible that a local region is equated to 'static when showing a type referencing a locally bound lifetime, such as `dyn Any + 'a` in the tests added, is well-formed. In this case we should return 'static.
Diffstat (limited to 'compiler/rustc_data_structures/src')
| -rw-r--r-- | compiler/rustc_data_structures/src/transitive_relation.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/compiler/rustc_data_structures/src/transitive_relation.rs b/compiler/rustc_data_structures/src/transitive_relation.rs index 33ac279f3e0..31abea93819 100644 --- a/compiler/rustc_data_structures/src/transitive_relation.rs +++ b/compiler/rustc_data_structures/src/transitive_relation.rs @@ -354,6 +354,20 @@ impl<T: Eq + Hash + Copy> TransitiveRelation<T> { .collect() } + /// Given an element A, elements B with the lowest index such that `A R B` + /// and `B R A`, or `A` if no such element exists. + pub fn minimal_scc_representative(&self, a: T) -> T { + match self.index(a) { + Some(a_i) => self.with_closure(|closure| { + closure + .iter(a_i.0) + .find(|i| closure.contains(*i, a_i.0)) + .map_or(a, |i| self.elements[i]) + }), + None => a, + } + } + fn with_closure<OP, R>(&self, op: OP) -> R where OP: FnOnce(&BitMatrix<usize, usize>) -> R, |
