Skip to content

Rename LocalInternedString and more - #65776

Merged
bors merged 7 commits into
rust-lang:masterfrom
nnethercote:rename-LocalInternedString-and-more
Nov 6, 2019
Merged

Rename LocalInternedString and more#65776
bors merged 7 commits into
rust-lang:masterfrom
nnethercote:rename-LocalInternedString-and-more

Conversation

@nnethercote

Copy link
Copy Markdown
Contributor

This PR renames LocalInternedString as SymbolStr, removes an unnecessary impl from it, improves comments, and cleans up some SymbolStr uses.

r? @estebank

@eddyb

Copy link
Copy Markdown
Contributor

I mentioned elsewhere my suggestion of SymbolContents (another one could be SymbolData), and I feel like SymbolStr isn't clear enough of a name.
But it's really just a bikeshed, and not that important.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should these be sym::s?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We can probably replace most string literals with valid literals in them, in the compiler, with sym::s.

I'd try this if I was in front of my laptop:

rg '"[_a-zA-Z][_a-zA-Z0-9]*"' src/lib*

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

rust_eh_personality already is a symbol. We could add the other two. For all potential static symbols there is a decision about whether the identifier is hot enough or frequently used enough for it to be worthwhile, and that decision is not always clear-cut.

"Intern all the static strings" is a possibility, but it would add a lot more due to functions like this one:

let n = &*name.as_str();
let human_readable = match(n, value){
("unix",None) => "Unix",
("windows",None) => "Windows",
("debug_assertions",None) => "debug-assertions enabled",
("target_os",Some(os)) => match&*os.as_str(){
"android" => "Android",
"dragonfly" => "DragonFly BSD",
"emscripten" => "Emscripten",
"freebsd" => "FreeBSD",
"fuchsia" => "Fuchsia",
"haiku" => "Haiku",
"ios" => "iOS",
"l4re" => "L4Re",
"linux" => "Linux",
"macos" => "macOS",
"netbsd" => "NetBSD",
"openbsd" => "OpenBSD",
"redox" => "Redox",
"solaris" => "Solaris",
"windows" => "Windows",
_ => "",
},
("target_arch",Some(arch)) => match&*arch.as_str(){
"aarch64" => "AArch64",
"arm" => "ARM",
"asmjs" => "JavaScript",
"mips" => "MIPS",
"mips64" => "MIPS-64",
"msp430" => "MSP430",
"powerpc" => "PowerPC",
"powerpc64" => "PowerPC-64",
"s390x" => "s390x",
"sparc64" => "SPARC64",
"wasm32" => "WebAssembly",
"x86" => "x86",
"x86_64" => "x86-64",
_ => "",
},
("target_vendor",Some(vendor)) => match&*vendor.as_str(){
"apple" => "Apple",
"pc" => "PC",
"rumprun" => "Rumprun",
"sun" => "Sun",
"fortanix" => "Fortanix",
_ => ""
},
("target_env",Some(env)) => match&*env.as_str(){
"gnu" => "GNU",
"msvc" => "MSVC",
"musl" => "musl",
"newlib" => "Newlib",
"uclibc" => "uClibc",
"sgx" => "SGX",
_ => "",
},
("target_endian",Some(endian)) => returnwrite!(fmt,"{}-endian", endian),
("target_pointer_width",Some(bits)) => returnwrite!(fmt,"{}-bit", bits),
("target_feature",Some(feat)) =>
ifself.1{
returnwrite!(fmt,"<code>{}</code>", feat);
}else{
returnwrite!(fmt,"target feature <code>{}</code>", feat);
},
_ => "",
};

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

(I should add: I have already converted all the static identifiers that I though were worth converting. Other people may reasonably think that more should be converted.)

Comment threadsrc/libsyntax/parse/literal.rs Outdated
Comment threadsrc/libsyntax_pos/symbol.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

cc @Manishearth could elsa have a FrozenIndexSet that is also thread-safe without a lock?
In this case, just a SyncFrozenVec might be enough.

@petrochenkovpetrochenkov added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 25, 2019
@petrochenkovpetrochenkov removed their assignment Oct 25, 2019
@nnethercote

Copy link
Copy Markdown
ContributorAuthor

What's the status here? It's not clear to me if @eddyb or @Centril is the reviewer. There are some comments but none of them seem like show-stoppers.

@Centril

Copy link
Copy Markdown
Contributor

Can I please not be the reviewer? =D

It appears @estebank is. :)

@nnethercote

Copy link
Copy Markdown
ContributorAuthor

Indeed, I mixed up GitHub's "assignees" and "reviewers" fields. @estebank is the reviewer.

@estebank

Copy link
Copy Markdown
Contributor

@bors r+ rollup=never

@bors

bors commented Oct 31, 2019

Copy link
Copy Markdown
Collaborator

📌 Commit 7a466f070585c2f399b3980e1fe6b7e0c721c989 has been approved by estebank

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 31, 2019
@bors

bors commented Nov 1, 2019

Copy link
Copy Markdown
Collaborator

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

@borsbors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 1, 2019
It makes the relationship with `Symbol` clearer. The `Str` suffix
matches the existing `Symbol::as_str()` method nicely, and is also
consistent with it being a wrapper of `&str`.
Including removing a bunch of unnecessary `.as_str()` calls, and a bunch
of unnecessary sigils.
Because it's highly magical, which goes against the goal of keeping
`SymbolStr` simple. Plus it's only used in a handful of places that
only require minor changes.
@nnethercote
nnethercoteforce-pushed the rename-LocalInternedString-and-more branch from 7a466f0 to d0db290CompareNovember 1, 2019 22:05
@nnethercote

Copy link
Copy Markdown
ContributorAuthor

I rebased.

@bors r=estebank

@bors

bors commented Nov 1, 2019

Copy link
Copy Markdown
Collaborator

📌 Commit d0db290 has been approved by estebank

@borsbors removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Nov 1, 2019
@borsbors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Nov 1, 2019
@bors

bors commented Nov 3, 2019

Copy link
Copy Markdown
Collaborator

⌛ Testing commit d0db290 with merge 0afc234c654c32d457d73f5c454b89455918dfaa...

@rust-highfive

Copy link
Copy Markdown
Contributor

The job x86_64-gnu-tools of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-11-03T07:10:04.2092474Z Caused By: "https://rust-lang.github.io/chalk/doc/chalk_parse/index.html" returned 404 Not Found
2019-11-03T07:10:04.2092993Z Caused By: "https://rust-lang.github.io/chalk/doc/chalk/index.html" returned 404 Not Found
2019-11-03T07:10:04.2093349Z Caused By: "https://rust-lang.github.io/chalk/doc/chalki/index.html" returned 404 Not Found
2019-11-03T07:10:04.2093753Z Caused By: "https://doc.rust-lang.org/nightly/nightly-rustc/syntax/parse/struct.ParseSess.html" returned 404 Not Found
2019-11-03T07:10:04.2093937Z Caused By: There was an error while fetching "http://www.cs.rice.edu/%7Eyguo/pubs/PID824943.pdf", http://www.cs.rice.edu/%7Eyguo/pubs/PID824943.pdf: timed out
2019-11-03T07:10:04.2094114Z 2019-11-03T07:10:04.2097005Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/rustbook" "linkcheck" "/checkout/src/doc/rustc-guide"
2019-11-03T07:10:04.2098340Z expected success, got: exit code: 101
2019-11-03T07:10:04.2098741Z ---
2019-11-03T07:16:38.3107307Z 2019-11-03T07:16:43.1579761Z error[E0277]: the trait bound `syntax_pos::symbol::SymbolStr: std::convert::AsRef<std::ffi::OsStr>` is not satisfied
2019-11-03T07:16:43.1581114Z --> src/tools/clippy/clippy_lints/src/path_buf_push_overwrite.rs:53:44
2019-11-03T07:16:43.1581796Z |
2019-11-03T07:16:43.1582827Z 53 | if let pushed_path = Path::new(&path_lit.as_str());
2019-11-03T07:16:43.1583837Z | ^^^^^^^^^^^^^^^^^^ the trait `std::convert::AsRef<std::ffi::OsStr>` is not implemented for `syntax_pos::symbol::SymbolStr`
2019-11-03T07:16:43.1585151Z ::: /checkout/src/libstd/path.rs:1814:19
2019-11-03T07:16:43.1585719Z |
2019-11-03T07:16:43.1585719Z |
2019-11-03T07:16:43.1586396Z 1814 | pub fn new<S: AsRef<OsStr> + ?Sized>(s: &S) -> &Path {
2019-11-03T07:16:43.1587769Z 2019-11-03T07:16:44.0585621Z error: aborting due to 5 previous errors
2019-11-03T07:16:44.0585803Z 2019-11-03T07:16:44.0592176Z Some errors have detailed explanations: E0277, E0432.
---
2019-11-03T07:55:01.6353394Z local time: Sun Nov 3 07:55:01 UTC 2019
2019-11-03T07:55:01.9051349Z network time: Sun, 03 Nov 2019 07:55:01 GMT
2019-11-03T07:55:01.9055246Z == end clock drift check ==
2019-11-03T07:55:02.9035817Z 2019-11-03T07:55:02.9162598Z ##[error]Bash exited with code '1'.
2019-11-03T07:55:02.9203954Z ##[section]Starting: Checkout
2019-11-03T07:55:02.9206104Z ==============================================================================
2019-11-03T07:55:02.9206207Z Task : Get sources
2019-11-03T07:55:02.9206319Z Description : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@bors

bors commented Nov 3, 2019

Copy link
Copy Markdown
Collaborator

💔 Test failed - checks-azure

@borsbors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 3, 2019
@nnethercote

Copy link
Copy Markdown
ContributorAuthor

No Tools Breakage Week is over, or close enough that by the time this gets through the queue it will be.

@bors r=estebank

@bors

bors commented Nov 5, 2019

Copy link
Copy Markdown
Collaborator

💡 This pull request was already approved, no need to approve it again.

  • This pull request previously failed. You should add more commits to fix the bug, or use retry to trigger a build again.
  • There's another pull request that is currently being tested, blocking this pull request: Rollup of 8 pull requests #66121

@bors

bors commented Nov 5, 2019

Copy link
Copy Markdown
Collaborator

📌 Commit d0db290 has been approved by estebank

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 5, 2019
Centril added a commit to Centril/rust that referenced this pull request Nov 6, 2019
…ing-and-more, r=estebank
Rename `LocalInternedString` and more
This PR renames `LocalInternedString` as `SymbolStr`, removes an unnecessary `impl` from it, improves comments, and cleans up some `SymbolStr` uses.
r? @estebank
@CentrilCentril mentioned this pull request Nov 6, 2019
bors added a commit that referenced this pull request Nov 6, 2019
Rollup of 9 pull requests
Successful merges:
- #65776 (Rename `LocalInternedString` and more)
- #65973 (caller_location: point to macro invocation sites, like file!/line!, and use in core::panic!.)
- #66015 (librustc_lexer: Refactor the module)
- #66062 (Configure LLVM module PIC level)
- #66086 (bump smallvec to 1.0)
- #66092 (Use KERN_ARND syscall for random numbers on NetBSD, same as FreeBSD.)
- #66103 (Add target thumbv7neon-unknown-linux-musleabihf)
- #66133 (Update the bundled `wasi-libc` repository)
- #66139 (use American spelling for `pluralize!`)
Failed merges:
r? @ghost
@Centril

Copy link
Copy Markdown
Contributor

@bors rollup=maybe

@bors

bors commented Nov 6, 2019

Copy link
Copy Markdown
Collaborator

⌛ Testing commit d0db290 with merge e8b190a...

@bors
bors merged commit d0db290 into rust-lang:masterNov 6, 2019
tesuji added a commit to tesuji/rust-clippy that referenced this pull request Nov 6, 2019
tesuji added a commit to tesuji/rust-clippy that referenced this pull request Nov 6, 2019
bors added a commit to rust-lang/rust-clippy that referenced this pull request Nov 6, 2019
@nnethercote
nnethercote deleted the rename-LocalInternedString-and-more branch November 6, 2019 22:43
calebcartwright added a commit to calebcartwright/rustfmt that referenced this pull request Jan 16, 2020
AFAICT these changes are required based on the changes `LocalInternedString` and `SymbolStr` in
rust-lang/rust#65776
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@nnethercote@eddyb@Centril@estebank@bors@rust-highfive@petrochenkov