Skip to content

Fix Ord, Eq and Hash implementation of panic::Location #144510

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 1 commit into from
Jul 30, 2025

Conversation

orlp
Copy link
Contributor

@orlp orlp commented Jul 26, 2025

Fixes #144486.

Now properly compares/hashes the filename rather than the pointer to the string.

@rustbot
Copy link
Collaborator

rustbot commented Jul 26, 2025

r? @ibraheemdev

rustbot has assigned @ibraheemdev.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 26, 2025
self.col.hash(state);
}
}

Copy link
Member

Choose a reason for hiding this comment

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

Can you add some test coverage for these? That would help prevent future accidental regressions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm actually not 100% sure if I can? In what little tests I've written for the standard library it's been single-file-per-test.

Copy link
Contributor

Choose a reason for hiding this comment

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

You should be able to easily add some tests into library/coretests somewhere, I believe. Although you will need to have some sort of perma-unstable method to construct these that's marked #[doc(hidden)], since these are private fields.

Copy link
Contributor

Choose a reason for hiding this comment

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

Location::internal_constructor does just that :) and there is an existing test file at library/coretests/tests/panic/___location.rs

Copy link
Contributor

Choose a reason for hiding this comment

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

It appears that the function you're referencing no longer exists and was removed when the file was converted to a non-null pointer instead of a real string. Specifically here: b541f93

Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting; I guess it could be brought back as a function taking a &CStr.

Copy link
Contributor Author

@orlp orlp Jul 29, 2025

Choose a reason for hiding this comment

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

I've added tests now using some extra helper modules in separate files, so the tests can remain integration rather than needing specific test-only hidden constructors.

@Mark-Simulacrum
Copy link
Member

#142708 landed in 1.90 and I think that's what introduced the bug, so presuming this doesn't land by ~Friday we should backport it to future beta. Not nominating yet since it'll cause confusion until we actually branch.

@rust-log-analyzer

This comment has been minimized.

@ibraheemdev
Copy link
Member

Thanks for the fix. @bors r+ rollup

@bors
Copy link
Collaborator

bors commented Jul 29, 2025

📌 Commit 0e6615d has been approved by ibraheemdev

It is now in the queue for this repository.

@bors bors 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 Jul 29, 2025
@tgross35
Copy link
Contributor

squash?

@ibraheemdev
Copy link
Member

@bors r- sorry, @orlp could you squash the commits? It's only a few commits so it's generally fine, but squashing makes things easier.

@bors bors 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 Jul 29, 2025
Faster equality compare

Add tests

Add missing files for tests
@orlp orlp force-pushed the fix-___location-ord branch from 0e6615d to 05da623 Compare July 29, 2025 20:16
@orlp
Copy link
Contributor Author

orlp commented Jul 29, 2025

@ibraheemdev Done.

@ibraheemdev
Copy link
Member

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Jul 29, 2025

📌 Commit 05da623 has been approved by ibraheemdev

It is now in the queue for this repository.

@bors bors 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 29, 2025
bors added a commit that referenced this pull request Jul 29, 2025
Rollup of 8 pull requests

Successful merges:

 - #144034 (tests: Test line number in debuginfo for diverging function calls)
 - #144510 (Fix Ord, Eq and Hash implementation of panic::Location)
 - #144583 (Enable T-compiler backport nomination)
 - #144586 (Update wasi-sdk to 27.0 in CI)
 - #144605 (Resolve: cachify `ExternPreludeEntry.binding` through a `Cell`)
 - #144632 (Update some tests for LLVM 21)
 - #144639 (Update rustc-perf submodule)
 - #144640 (Add support for the m68k architecture in 'object_architecture')

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 48dfddd into rust-lang:master Jul 30, 2025
10 checks passed
@rustbot rustbot added this to the 1.90.0 milestone Jul 30, 2025
rust-timer added a commit that referenced this pull request Jul 30, 2025
Rollup merge of #144510 - orlp:fix-___location-ord, r=ibraheemdev

Fix Ord, Eq and Hash implementation of panic::Location

Fixes #144486.

Now properly compares/hashes the filename rather than the pointer to the string.
github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this pull request Jul 31, 2025
Fix Ord, Eq and Hash implementation of panic::Location

Fixes rust-lang#144486.

Now properly compares/hashes the filename rather than the pointer to the string.
github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this pull request Jul 31, 2025
Rollup of 8 pull requests

Successful merges:

 - rust-lang#144034 (tests: Test line number in debuginfo for diverging function calls)
 - rust-lang#144510 (Fix Ord, Eq and Hash implementation of panic::Location)
 - rust-lang#144583 (Enable T-compiler backport nomination)
 - rust-lang#144586 (Update wasi-sdk to 27.0 in CI)
 - rust-lang#144605 (Resolve: cachify `ExternPreludeEntry.binding` through a `Cell`)
 - rust-lang#144632 (Update some tests for LLVM 21)
 - rust-lang#144639 (Update rustc-perf submodule)
 - rust-lang#144640 (Add support for the m68k architecture in 'object_architecture')

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

panic::Location ordering is defined by pointer ordering, not string ordering
8 participants