Skip to content

Change Symbol::as_str to &self -> &str #83295

Closed
@oli-obk

Description

@oli-obk

#76460 experimented with this, but it was never finished. We should figure out whether we actually want this

Pros:

  • &str is nicer to work with than SymbolStr, e.g. avoids the need for some & and &* occurrences.
  • It would be nice to eliminate SymbolStr.
  • It avoids the lie that SymbolStr strings have a static lifetime, replacing it with a smaller lie that the strings have a lifetime tied to the lifetime of the input Symbol.

Cons:

  • That lifetime is still a lie, and it's possible to cause crashes with this.
  • The lie is less obvious in a vanilla &str than it is within a SymbolStr.
  • We can't mark &str as !Send and !Sync.
    • this may be why SymbolStr (or what it was called previously) was introduced in the first place, because Zoxc did it together with the work on compiler parallelization.
  • I haven't yet eliminated SymbolStr entirely. The to_stable_hash_key() is the hardest case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-cleanupCategory: PRs that clean code up or issues documenting cleanup.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions