Skip to content

chore: simplify associated constants lookup#9133

Closed
asterite wants to merge 3 commits intomasterfrom
ab/remove-definition-kind-associated-constant
Closed

chore: simplify associated constants lookup#9133
asterite wants to merge 3 commits intomasterfrom
ab/remove-definition-kind-associated-constant

Conversation

@asterite
Copy link
Collaborator

@asterite asterite commented Jul 7, 2025

Description

Problem

No issue, just something I noticed.

Summary

After #9041 there were a couple of code paths that were no longer needed. That is, #9041 was the correct way to implement associated constants, the other code wasn't a workaround but it didn't account for all cases.

Additional Context

Documentation

Check one:

  • No documentation needed.
  • Documentation included in this PR.
  • [For Experimental Features] Documentation to be submitted in a separate PR.

PR Checklist

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

let named = vecmap(&self.associated_types, |generic| {
let name = Ident::new(generic.name.to_string(), location);
NamedType { name, typ: generic.clone().as_named_generic() }
NamedType { name, typ: Type::TypeVariable(generic.type_var.clone()) }
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@jfecher When I initially started this PR some tests were failing. Comparing with master I noticed that when we elaborate AsTraitPath the TraitGenerics we produce there have type variables for named arguments. Here we were returning NamedGeneric and that didn't work (they don't unify the same way as type variables). Given that the AsTraitPath was working well, I decided to change this code to also return TypeVariable. That fixed the issue but I'm not 100% sure this is fine.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Execution Time'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20.

Benchmark suite Current: 92c2c61 Previous: d31ebb9 Ratio
semaphore-depth-10 0.028 s 0.022 s 1.27

This comment was automatically generated by workflow using github-action-benchmark.

CC: @TomAFrench

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.

1 participant