Skip to content

Move placeholder handling to a proper preprocessing step #140466

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

amandasystems
Copy link
Contributor

@amandasystems amandasystems commented Apr 29, 2025

This commit breaks out the logic of placheolder rewriting into its own preprocessing step. It's one of the more boring
parts of #130227.

The only functional change from this is that the preprocessing step (where extra r: 'static constraints are added) is performed upstream of Polonius legacy, finally affecting Polonius. That is mostly a by-product, though.

This should be reviewable by anyone in the compiler team, so
r? rust-lang/compiler

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 29, 2025
@lcnr
Copy link
Contributor

lcnr commented Apr 30, 2025

r? lcnr

@rustbot rustbot assigned lcnr and unassigned estebank Apr 30, 2025
This commit breaks out the logic of placheolder rewriting
into its own preprocessing step. It's one of the more boring
parts of rust-lang#130227.

The only functional change from this is that the preprocessing
step (where extra `r: 'static` constraints are added) is
performed upstream of Polonius legacy, finally affecting
Polonius. That is mostly a by-product, though.
@amandasystems amandasystems force-pushed the move-to-preprocessing-step branch from 8b2cab2 to af75e13 Compare May 2, 2025 08:53
@amandasystems amandasystems changed the title [WIP] Move placeholder handling to a proper preprocessing step Move placeholder handling to a proper preprocessing step May 2, 2025
@amandasystems
Copy link
Contributor Author

Ok; revised SCC annotations have landed and I think I addressed all of your concerns so far @lcnr?

@amandasystems amandasystems force-pushed the move-to-preprocessing-step branch from af75e13 to ef9cb23 Compare May 15, 2025 20:05
@amandasystems
Copy link
Contributor Author

@lcnr Fixed all the code review stuff now, I think! I amended it into the second commit.

max_placeholder_universe_reached: UniverseIndex,

/// The smallest universe index reachable form the nodes of this SCC.
min_reachable_universe: UniverseIndex,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
min_reachable_universe: UniverseIndex,
max_nameable_universe: UniverseIndex,

:3

}

/// The smallest-indexed universe reachable from and/or in this SCC.
pub(crate) fn min_universe(self) -> UniverseIndex {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub(crate) fn min_universe(self) -> UniverseIndex {
pub(crate) fn max_nameable_universe(self) -> UniverseIndex {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also update comment :>

}

/// Determines if the region variable definitions contain
/// placeholers, and compute them for later use.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// placeholers, and compute them for later use.
/// placeholders, and compute them for later use.

sup: annotation.representative.rvid(),
sub: fr_static,
category: ConstraintCategory::IllegalUniverse,
locations: Locations::All(rustc_span::DUMMY_SP),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we track a span related to the placeholder in the scc annotation and use that here?

pub(crate) definitions: Frozen<IndexVec<RegionVid, RegionDefinition<'tcx>>>,
pub(crate) scc_annotations: IndexVec<ConstraintSccIndex, RegionTracker>,
pub(crate) member_constraints: MemberConstraintSet<'tcx, RegionVid>,
pub(crate) outlives_constraints: OutlivesConstraintSet<'tcx>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub(crate) outlives_constraints: OutlivesConstraintSet<'tcx>,
pub(crate) outlives_constraints: Frozen<OutlivesConstraintSet<'tcx>>,

outlives_constraints.push(scc_representative_outlives_static);
}
}
outlives_static
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feel like this can just return a bool? and we add a debug! stmtm when adding an outlives constraint here

/// Since universes can also be involved in errors (if one placeholder
/// transitively outlives another), this function also flags those.
///
/// Additionally, it similarly rewrites type-tests.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no :> generally, this comment isn't applicable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants