Skip to content

Traversal API#1162

Merged
micahscopes merged 69 commits intoargotorg:masterfrom
micahscopes:traversal-api-wow
Nov 26, 2025
Merged

Traversal API#1162
micahscopes merged 69 commits intoargotorg:masterfrom
micahscopes:traversal-api-wow

Conversation

@micahscopes
Copy link
Collaborator

@micahscopes micahscopes commented Nov 20, 2025

This is a start at flipping the internal API of the hir/hir-analysis crates inside-out, so that our hir analysis queries and program traversal logic can be nicely reused without requiring developers to have an intricate understanding of how to use each query, and without duplicating visitor logic.

The goal is support followups on language server features, code transformations, and hopefully even codegen for graph-based IRs.

It's sort of like a "virtually materialized HIR interface", since our middle layer is query based we don't have a concrete materialization of the HIR, so this is kind of like an in-between solution.

There's a bunch of stuff in here:

  • hir + hir-analysis have been merged
  • a new core module keeps syntactic hir accessors contained from analysis logic
    • provides a semantic-level public interface
  • the analysis::def_analyzer has been fully metabolized into this new interface (others ought to follow)
  • a new Diagnosable trait provides proof of concept for a pull-based diagnostic gathering pattern (which could be a really good model in designing interfaces to collect info for debugging/language server/graph output features)
  • lots of reworked/dissolved indirection layers from the old hir-analysis crate, more to come

Needs to be rebased due to rapid developments elsewhere in the codebase!

Will update this later today or tomorrow with more info.

Built from hard lessons learned in #1163 #1131 #1112

Copy link
Collaborator

Choose a reason for hiding this comment

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

defunct

Comment on lines 615 to 616
// TODO: Add semantic view for FuncParamListId and restrict visibility
pub params: Partial<FuncParamListId<'db>>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This TODO is partially addressed by Func::param_views, could be completed

Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be outside of hir::core, so that it can't use the hir-core-only fields? It seems like it should only rely on public accessors, not (semi-)private fields.


// Where-clause diagnostics (trait bounds and kind checks on where predicates)
{
let clause = WhereClauseView {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ugly pattern sneaking in because this file is inside hir::core. self.where_clause() should return a WhereClauseView.

type Diagnostic = TyDiagCollection<'db>;

fn diags(self, db: &'db dyn HirAnalysisDb) -> Vec<Self::Diagnostic> {
let mut out = self.analyze(db);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should just inline these analyze() functions and eliminate them; they're only called once, and it adds another jump to find the actual logic.

Comment on lines 825 to 831
pub(crate) fn diags_method_conformance(
self,
db: &'db dyn HirAnalysisDb,
implementor: Binder<ImplementorId<'db>>,
) -> Vec<TyDiagCollection<'db>> {
implementor.skip_binder().diags_method_conformance(db)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove?

@micahscopes micahscopes marked this pull request as ready for review November 25, 2025 23:02
Copy link
Collaborator

@sbillig sbillig left a comment

Choose a reason for hiding this comment

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

🥳

I think there's more cleanup we could do, but I'd be happy for this to be merged now.

@micahscopes micahscopes force-pushed the traversal-api-wow branch 4 times, most recently from a306907 to 4108521 Compare November 26, 2025 17:25
@micahscopes micahscopes merged commit 95fa423 into argotorg:master Nov 26, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants