Skip to content

Commit

Permalink
Auto merge of #134122 - oli-obk:push-zqnyznxtpnll, r=petrochenkov
Browse files Browse the repository at this point in the history
Move impl constness into impl trait header

This PR is kind of the opposite of the rejected rust-lang/rust#134114

Instead of moving more things into the `constness` query, we want to keep them where their corresponding hir nodes are lowered. So I gave this a spin for impls, which have an obvious place to be (the impl trait header). And surprisingly it's also a perf improvement (likely just slightly better query & cache usage).

The issue was that removing anything from the `constness` query makes it just return `NotConst`, which is wrong. So I had to change it to `bug!` out if used wrongly, and only then remove the impl blocks from the `constness` query. I think this change is good in general, because it makes using `constness` more robust (as can be seen by how few sites that had to be changed, so it was almost solely used specifically for the purpose of asking for functions' constness). The main thing where this change was not great was in clippy, which was using the `constness` query as a general DefId -> constness map. I added a `DefKind` filter in front of that. If it becomes a more common pattern we can always move that helper into rustc.
  • Loading branch information
bors committed Dec 13, 2024
2 parents ee97de7 + 430edc8 commit d613c11
Showing 0 changed files with 0 additions and 0 deletions.

0 comments on commit d613c11

Please sign in to comment.