From 1376c5a617be5c25655d0d7cb63e3beaa5a6e026 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:20:39 +0200 Subject: Merging upstream version 1.70.0+dfsg1. Signed-off-by: Daniel Baumann --- compiler/rustc_borrowck/src/constraints/graph.rs | 32 +++++++++++++----------- compiler/rustc_borrowck/src/constraints/mod.rs | 6 +++-- 2 files changed, 21 insertions(+), 17 deletions(-) (limited to 'compiler/rustc_borrowck/src/constraints') diff --git a/compiler/rustc_borrowck/src/constraints/graph.rs b/compiler/rustc_borrowck/src/constraints/graph.rs index c780d0479..f5a34cb05 100644 --- a/compiler/rustc_borrowck/src/constraints/graph.rs +++ b/compiler/rustc_borrowck/src/constraints/graph.rs @@ -13,7 +13,7 @@ use crate::{ /// The construct graph organizes the constraints by their end-points. /// It can be used to view a `R1: R2` constraint as either an edge `R1 /// -> R2` or `R2 -> R1` depending on the direction type `D`. -pub(crate) struct ConstraintGraph { +pub(crate) struct ConstraintGraph { _direction: D, first_constraints: IndexVec>, next_constraints: IndexVec>, @@ -25,7 +25,7 @@ pub(crate) type ReverseConstraintGraph = ConstraintGraph; /// Marker trait that controls whether a `R1: R2` constraint /// represents an edge `R1 -> R2` or `R2 -> R1`. -pub(crate) trait ConstraintGraphDirecton: Copy + 'static { +pub(crate) trait ConstraintGraphDirection: Copy + 'static { fn start_region(c: &OutlivesConstraint<'_>) -> RegionVid; fn end_region(c: &OutlivesConstraint<'_>) -> RegionVid; fn is_normal() -> bool; @@ -38,7 +38,7 @@ pub(crate) trait ConstraintGraphDirecton: Copy + 'static { #[derive(Copy, Clone, Debug)] pub(crate) struct Normal; -impl ConstraintGraphDirecton for Normal { +impl ConstraintGraphDirection for Normal { fn start_region(c: &OutlivesConstraint<'_>) -> RegionVid { c.sup } @@ -59,7 +59,7 @@ impl ConstraintGraphDirecton for Normal { #[derive(Copy, Clone, Debug)] pub(crate) struct Reverse; -impl ConstraintGraphDirecton for Reverse { +impl ConstraintGraphDirection for Reverse { fn start_region(c: &OutlivesConstraint<'_>) -> RegionVid { c.sub } @@ -73,7 +73,7 @@ impl ConstraintGraphDirecton for Reverse { } } -impl ConstraintGraph { +impl ConstraintGraph { /// Creates a "dependency graph" where each region constraint `R1: /// R2` is treated as an edge `R1 -> R2`. We use this graph to /// construct SCCs for region inference but also for error @@ -133,7 +133,7 @@ impl ConstraintGraph { } } -pub(crate) struct Edges<'s, 'tcx, D: ConstraintGraphDirecton> { +pub(crate) struct Edges<'s, 'tcx, D: ConstraintGraphDirection> { graph: &'s ConstraintGraph, constraints: &'s OutlivesConstraintSet<'tcx>, pointer: Option, @@ -141,7 +141,7 @@ pub(crate) struct Edges<'s, 'tcx, D: ConstraintGraphDirecton> { static_region: RegionVid, } -impl<'s, 'tcx, D: ConstraintGraphDirecton> Iterator for Edges<'s, 'tcx, D> { +impl<'s, 'tcx, D: ConstraintGraphDirection> Iterator for Edges<'s, 'tcx, D> { type Item = OutlivesConstraint<'tcx>; fn next(&mut self) -> Option { @@ -174,13 +174,13 @@ impl<'s, 'tcx, D: ConstraintGraphDirecton> Iterator for Edges<'s, 'tcx, D> { /// This struct brings together a constraint set and a (normal, not /// reverse) constraint graph. It implements the graph traits and is /// usd for doing the SCC computation. -pub(crate) struct RegionGraph<'s, 'tcx, D: ConstraintGraphDirecton> { +pub(crate) struct RegionGraph<'s, 'tcx, D: ConstraintGraphDirection> { set: &'s OutlivesConstraintSet<'tcx>, constraint_graph: &'s ConstraintGraph, static_region: RegionVid, } -impl<'s, 'tcx, D: ConstraintGraphDirecton> RegionGraph<'s, 'tcx, D> { +impl<'s, 'tcx, D: ConstraintGraphDirection> RegionGraph<'s, 'tcx, D> { /// Creates a "dependency graph" where each region constraint `R1: /// R2` is treated as an edge `R1 -> R2`. We use this graph to /// construct SCCs for region inference but also for error @@ -202,11 +202,11 @@ impl<'s, 'tcx, D: ConstraintGraphDirecton> RegionGraph<'s, 'tcx, D> { } } -pub(crate) struct Successors<'s, 'tcx, D: ConstraintGraphDirecton> { +pub(crate) struct Successors<'s, 'tcx, D: ConstraintGraphDirection> { edges: Edges<'s, 'tcx, D>, } -impl<'s, 'tcx, D: ConstraintGraphDirecton> Iterator for Successors<'s, 'tcx, D> { +impl<'s, 'tcx, D: ConstraintGraphDirection> Iterator for Successors<'s, 'tcx, D> { type Item = RegionVid; fn next(&mut self) -> Option { @@ -214,23 +214,25 @@ impl<'s, 'tcx, D: ConstraintGraphDirecton> Iterator for Successors<'s, 'tcx, D> } } -impl<'s, 'tcx, D: ConstraintGraphDirecton> graph::DirectedGraph for RegionGraph<'s, 'tcx, D> { +impl<'s, 'tcx, D: ConstraintGraphDirection> graph::DirectedGraph for RegionGraph<'s, 'tcx, D> { type Node = RegionVid; } -impl<'s, 'tcx, D: ConstraintGraphDirecton> graph::WithNumNodes for RegionGraph<'s, 'tcx, D> { +impl<'s, 'tcx, D: ConstraintGraphDirection> graph::WithNumNodes for RegionGraph<'s, 'tcx, D> { fn num_nodes(&self) -> usize { self.constraint_graph.first_constraints.len() } } -impl<'s, 'tcx, D: ConstraintGraphDirecton> graph::WithSuccessors for RegionGraph<'s, 'tcx, D> { +impl<'s, 'tcx, D: ConstraintGraphDirection> graph::WithSuccessors for RegionGraph<'s, 'tcx, D> { fn successors(&self, node: Self::Node) -> >::Iter { self.outgoing_regions(node) } } -impl<'s, 'tcx, D: ConstraintGraphDirecton> graph::GraphSuccessors<'_> for RegionGraph<'s, 'tcx, D> { +impl<'s, 'tcx, D: ConstraintGraphDirection> graph::GraphSuccessors<'_> + for RegionGraph<'s, 'tcx, D> +{ type Item = RegionVid; type Iter = Successors<'s, 'tcx, D>; } diff --git a/compiler/rustc_borrowck/src/constraints/mod.rs b/compiler/rustc_borrowck/src/constraints/mod.rs index f370c0216..d2d9779db 100644 --- a/compiler/rustc_borrowck/src/constraints/mod.rs +++ b/compiler/rustc_borrowck/src/constraints/mod.rs @@ -2,7 +2,7 @@ #![deny(rustc::diagnostic_outside_of_impl)] use rustc_data_structures::graph::scc::Sccs; -use rustc_index::vec::IndexVec; +use rustc_index::vec::{IndexSlice, IndexVec}; use rustc_middle::mir::ConstraintCategory; use rustc_middle::ty::{RegionVid, VarianceDiagInfo}; use rustc_span::Span; @@ -60,7 +60,9 @@ impl<'tcx> OutlivesConstraintSet<'tcx> { Sccs::new(region_graph) } - pub(crate) fn outlives(&self) -> &IndexVec> { + pub(crate) fn outlives( + &self, + ) -> &IndexSlice> { &self.outlives } } -- cgit v1.2.3