Skip to content

[red-knot] Reduce usage of From<Type> implementations when working with Symbols #16076

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

Merged
merged 2 commits into from
Feb 11, 2025

Conversation

AlexWaygood
Copy link
Member

Summary

This PR removes the From<Type> implementations for Symbol and SymbolAndQualifiers, replacing them with smart constructors. This has a few advantages:

  • It's easier to see when reading the code what (Rust) type the variable is being turned into, compared to a .into() call
  • It's more explicit that we're creating symbols with Boundness::Bound
  • In some cases, it's more concise

Test Plan

@AlexWaygood AlexWaygood added the ty Multi-file analysis & type inference label Feb 10, 2025
Copy link
Contributor

@carljm carljm left a comment

Choose a reason for hiding this comment

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

I agree this is a bit clearer for the reader.

@AlexWaygood AlexWaygood enabled auto-merge (squash) February 11, 2025 11:06
@AlexWaygood AlexWaygood merged commit df1d430 into main Feb 11, 2025
20 checks passed
@AlexWaygood AlexWaygood deleted the alex/simplify-symbol-usage branch February 11, 2025 11:09
dcreager added a commit that referenced this pull request Feb 11, 2025
* main:
  add diagnostic `Span` (couples `File` and `TextRange`) (#16101)
  Remove `Hash` and `Eq` from `AstNodeRef` for types not implementing `Eq` or `Hash` (#16100)
  Fix release build warning about unused todo type message (#16102)
  [`pydocstyle`] Handle arguments with the same names as sections (`D417`) (#16011)
  [red-knot] Reduce usage of `From<Type>` implementations when working with `Symbol`s (#16076)
  Transition to salsa coarse-grained tracked structs (#15763)
  [`pyupgrade`] Handle micro version numbers correctly (`UP036`) (#16091)
  [red-knot] `T | object == object` (#16088)
  [`ruff`] Skip singleton starred expressions for `incorrectly-parenthesized-tuple-in-subscript` (`RUF031`) (#16083)
  Delete left-over `verbosity.rs (#16081)
  [red-knot] User-level configuration (#16021)
  Add `user_configuration_directory` to `System` (#16020)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ty Multi-file analysis & type inference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants