Skip to content
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

internal: Fix VfsPath Display and Debug impls #15097

Merged
merged 1 commit into from Jun 20, 2023

Conversation

HKalbasi
Copy link
Member

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 20, 2023
@matklad
Copy link
Member

matklad commented Jun 20, 2023

@bors r+

@bors
Copy link
Collaborator

bors commented Jun 20, 2023

📌 Commit 10aba11 has been approved by matklad

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Jun 20, 2023

⌛ Testing commit 10aba11 with merge 2d64a0a...

@bors
Copy link
Collaborator

bors commented Jun 20, 2023

☀️ Test successful - checks-actions
Approved by: matklad
Pushing 2d64a0a to master...

@bors bors merged commit 2d64a0a into rust-lang:master Jun 20, 2023
10 checks passed
@@ -292,7 +292,7 @@ impl From<AbsPathBuf> for VfsPath {
impl fmt::Display for VfsPath {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match &self.0 {
VfsPathRepr::PathBuf(it) => fmt::Debug::fmt(&it, f),
VfsPathRepr::PathBuf(it) => fmt::Display::fmt(&it, f),
Copy link
Contributor

Choose a reason for hiding this comment

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

Could also replace all of these (including the ones in the Debug impl below) with it.fmt(f). Method resolution will prefer the right one.

Copy link
Member

Choose a reason for hiding this comment

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

I’d rather not. It’s is true that

Method resolution will prefer the right one

but this also is one of the least obvious rules in Rust.

no strong feelings here though!

Copy link
Member

Choose a reason for hiding this comment

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

Or maybe not! I think my main worry is that Debug&Disolay have a method with identical signature, which can be asily confused during method resolution.

However, given that we never import the traits directly, and only use them through fmt:: prefix, using .fmt should be OK.

@lnicola lnicola changed the title Fix VfsPath Display and Debug impls internal: Fix VfsPath Display and Debug impls Jun 21, 2023
bors added a commit that referenced this pull request Jun 21, 2023
internal: Simplify `VfsPath` `fmt` impls

Fixes #15097 (comment)
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants