Skip to content

Stop using Key trait unnecessarily #143441

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 6, 2025
Merged

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Jul 4, 2025

Few places where the Key trait was being used but not really for a useful reason. This fixes those usages.

Namely, <Ty as Key>::default_span() is DUMMY_SP anyways.

@rustbot
Copy link
Collaborator

rustbot commented Jul 4, 2025

r? @petrochenkov

rustbot has assigned @petrochenkov.
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-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 4, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 4, 2025

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

@@ -71,8 +71,7 @@ pub fn tag_for_variant_provider<'tcx>(
let (ty, variant_index) = key.value;
assert!(ty.is_enum());

let ecx =
InterpCx::new(tcx, ty.default_span(tcx), key.typing_env, crate::const_eval::DummyMachine);
let ecx = InterpCx::new(tcx, DUMMY_SP, key.typing_env, crate::const_eval::DummyMachine);
Copy link
Member Author

Choose a reason for hiding this comment

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

We don't need this span anyways, and even if we did, it would be nice to use a relevant def span since it's just an enum anyways.

@@ -69,7 +68,7 @@ impl<'tcx> LateLintPass<'tcx> for MapUnitFn {
.span_of_impl(*id)
.unwrap_or(default_span),
argument_label: args[0].span,
map_label: arg_ty.default_span(cx.tcx),
Copy link
Member Author

Choose a reason for hiding this comment

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

This was DUMMY_SP, but dummy span labels fall back to the primary span coincidentally (lol)

@compiler-errors compiler-errors changed the title Stop using Key trait randomly Stop using Key trait unnecessarily Jul 4, 2025
@rust-log-analyzer

This comment has been minimized.

@petrochenkov
Copy link
Contributor

r=me after updating the test outputs.
@rustbot author

@rustbot rustbot 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-review Status: Awaiting review from the assignee but also interested parties. labels Jul 5, 2025
@compiler-errors
Copy link
Member Author

@bors r=petrochenkov rollup

@bors
Copy link
Collaborator

bors commented Jul 5, 2025

📌 Commit 8eb9f70 has been approved by petrochenkov

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 5, 2025
bors added a commit that referenced this pull request Jul 5, 2025
Rollup of 6 pull requests

Successful merges:

 - #143238 (Port `#[ignore]` to the new attribute parsing infrastructure)
 - #143441 (Stop using `Key` trait unnecessarily)
 - #143478 (Miri subtree update)
 - #143486 (remove armv5te-unknown-linux-gnueabi target maintainer)
 - #143489 (Complete rustc_ast::mut_visit for spans.)
 - #143494 (Remove yields_in_scope from the scope tree.)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Jul 6, 2025
Rollup of 6 pull requests

Successful merges:

 - #143238 (Port `#[ignore]` to the new attribute parsing infrastructure)
 - #143441 (Stop using `Key` trait unnecessarily)
 - #143478 (Miri subtree update)
 - #143486 (remove armv5te-unknown-linux-gnueabi target maintainer)
 - #143489 (Complete rustc_ast::mut_visit for spans.)
 - #143494 (Remove yields_in_scope from the scope tree.)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 0311159 into rust-lang:master Jul 6, 2025
11 checks passed
@rustbot rustbot added this to the 1.90.0 milestone Jul 6, 2025
rust-timer added a commit that referenced this pull request Jul 6, 2025
Rollup merge of #143441 - compiler-errors:no-key, r=petrochenkov

Stop using `Key` trait unnecessarily

Few places where the `Key` trait was being used but not really for a useful reason. This fixes those usages.

Namely, `<Ty as Key>::default_span()` is `DUMMY_SP` anyways.
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-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.

5 participants