New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Utilize inband lifetimes across librustc_mir #52736
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -58,7 +58,7 @@ enum GroupedMoveError<'tcx> { | ||
| }, | ||
| } | ||
|
|
||
| impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> { | ||
| impl MirBorrowckCtxt<'a, 'gcx, 'tcx> { | ||
| pub(crate) fn report_move_errors(&mut self, move_errors: Vec<MoveError<'tcx>>) { | ||
| let grouped_errors = self.group_move_errors(move_errors); | ||
| for error in grouped_errors { | ||
| @@ -293,7 +293,7 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> { | ||
| fn add_move_hints( | ||
| &self, | ||
| error: GroupedMoveError<'tcx>, | ||
| err: &mut DiagnosticBuilder<'a>, | ||
| err: &mut DiagnosticBuilder<'_>, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like an actual change since There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably, yes -- however, arguably, it's a "correct" change as this branch compiles. If we don't need to constrain the lifetime, it's easier to understand the code if we're not doing so. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And yet, if it compiles, seems fine. |
||
| span: Span, | ||
| ) { | ||
| match error { | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -51,12 +51,12 @@ impl ConstraintGraph { | ||
| } | ||
| } | ||
|
|
||
| crate struct Edges<'s> { | ||
| graph: &'s ConstraintGraph, | ||
| crate struct Edges<'graph> { | ||
| graph: &'graph ConstraintGraph, | ||
| pointer: Option<ConstraintIndex>, | ||
| } | ||
|
|
||
| impl<'s> Iterator for Edges<'s> { | ||
| impl Iterator for Edges<'graph> { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you need to use a named lifetime here? I don't see the lifetime used in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure. Part of me wants to use |
||
| type Item = ConstraintIndex; | ||
|
|
||
| fn next(&mut self) -> Option<Self::Item> { | ||
| @@ -74,7 +74,7 @@ crate struct RegionGraph<'s> { | ||
| constraint_graph: &'s ConstraintGraph, | ||
| } | ||
|
|
||
| impl<'s> RegionGraph<'s> { | ||
| impl RegionGraph<'s> { | ||
| /// Create 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 | ||
| @@ -101,34 +101,34 @@ crate struct Successors<'s> { | ||
| edges: Edges<'s>, | ||
| } | ||
|
|
||
| impl<'s> Iterator for Successors<'s> { | ||
| impl Iterator for Successors<'s> { | ||
| type Item = RegionVid; | ||
|
|
||
| fn next(&mut self) -> Option<Self::Item> { | ||
| self.edges.next().map(|c| self.set[c].sub) | ||
| } | ||
| } | ||
|
|
||
| impl<'s> graph::DirectedGraph for RegionGraph<'s> { | ||
| impl graph::DirectedGraph for RegionGraph<'_> { | ||
| type Node = RegionVid; | ||
| } | ||
|
|
||
| impl<'s> graph::WithNumNodes for RegionGraph<'s> { | ||
| impl graph::WithNumNodes for RegionGraph<'_> { | ||
| fn num_nodes(&self) -> usize { | ||
| self.constraint_graph.first_constraints.len() | ||
| } | ||
| } | ||
|
|
||
| impl<'s> graph::WithSuccessors for RegionGraph<'s> { | ||
| fn successors<'graph>( | ||
| impl graph::WithSuccessors for RegionGraph<'_> { | ||
| fn successors( | ||
| &'graph self, | ||
| node: Self::Node, | ||
| ) -> <Self as graph::GraphSuccessors<'graph>>::Iter { | ||
| self.sub_regions(node) | ||
| } | ||
| } | ||
|
|
||
| impl<'s, 'graph> graph::GraphSuccessors<'graph> for RegionGraph<'s> { | ||
| impl graph::GraphSuccessors<'graph> for RegionGraph<'s> { | ||
| type Item = RegionVid; | ||
| type Iter = Successors<'graph>; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any particular reason for the rename here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the policy I tried to follow is to avoid single character lifetimes when they're used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, ok. This is exactly the case where I would prefer a single-character lifetime -- if the point is just to connect a variable and a return value, then a single-character lifetime expresses that (versus trying to tie to some "outer" lifetime).
I think the way I think of it is this:
gcxandtcxare conceptually global; and within a given context, there may be other such namesNot sure if this is the best policy or not but it's the one I was contemplating.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see how that makes sense; I can switch this case back.