Skip to content

[DRAFT] Change Symbol::as_str() to &self -> &str. #76460

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

Closed
wants to merge 1 commit into from

Conversation

nnethercote
Copy link
Contributor

This is based on an idea from @oli-obk. The code is incomplete for the moment, and I won't have time to work on it further, but somebody else might be interested in taking it over.

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.
  • I haven't yet eliminated SymbolStr entirely. The to_stable_hash_key() is the hardest case.

I'm totally ambivalent about whether this should land, but it seemed worth putting up here for others to look at.

r? @ghost

@jyn514 jyn514 added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 9, 2020
@petrochenkov
Copy link
Contributor

We can't mark &str as !Send and !Sync.

IIRC, this is 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.

@bors
Copy link
Collaborator

bors commented Sep 10, 2020

☔ The latest upstream changes (presumably #76574) made this pull request unmergeable. Please resolve the merge conflicts.

Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:

@rustbot modify labels: +S-waiting-on-review -S-waiting-on-author

@Dylan-DPC-zz Dylan-DPC-zz marked this pull request as draft September 30, 2020 00:01
@spastorino spastorino removed their assignment Feb 10, 2021
@Dylan-DPC-zz
Copy link

Closing this as I don't think it's being worked on at the moment

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.

6 participants