about summary refs log tree commit diff
path: root/compiler/rustc_builtin_macros/src
diff options
context:
space:
mode:
authorJacob Pratt <jacob@jhpratt.dev>2025-02-11 01:02:44 -0500
committerGitHub <noreply@github.com>2025-02-11 01:02:44 -0500
commit21303103c3eef60e027630cd2aea5f54f868c734 (patch)
tree9c702c0f98cd21cc499eca556eaae3cbf7fb6e43 /compiler/rustc_builtin_macros/src
parent4ae214b846655d5132b352b294a806a5aba796e5 (diff)
parentc1da4f1d3c4fc4beb5edcfa8a303a1dcbe27b65e (diff)
downloadrust-21303103c3eef60e027630cd2aea5f54f868c734.tar.gz
rust-21303103c3eef60e027630cd2aea5f54f868c734.zip
Rollup merge of #136839 - lukas-code:actually-monomorphic-enough, r=compiler-errors
fix ensure_monomorphic_enough

When polymorphization was still a thing, the visitor was used to only recurse into *used generic parameters* of function/closure/coroutine types and allow unused parameters (i.e. the polymorphized parameters) to remain generic.

When polymorphization got removed, this got changed to always treat all parameters as polymorphic and never recurse into them: https://github.com/rust-lang/rust/pull/133883/files#diff-210c59e321070d0ca4625c04e9fb064bf43ddc34082e7e33a7ee8a6c577e95afL44-L62

This is clearly wrong and can cause MIR opts to misbehave, for example this currently prints "false" in release mode:

```rust
#![feature(core_intrinsics)]

fn generic<T>() {}

const fn type_id_of_val<T: 'static>(_: &T) -> u128 {
    std::intrinsics::type_id::<T>()
}

fn cursed_is_i32<T: 'static>() -> bool {
    (const { type_id_of_val(&generic::<T>) } == const { type_id_of_val(&generic::<i32>) })
}

fn main() {
    dbg!(cursed_is_i32::<i32>());
}
```

This PR reverts to the old behavior of always treating all types that contain type parameters as too generic, like we used to do without `-Zpolymorphize` before.

~~I'm not including the above as a test case here, because I think there is little value in testing code paths that have been removed and this seems unlikely to regress in a way that would be caught by a regression test, but let me know if you disagree and want me to add a test anyway.~~
Diffstat (limited to 'compiler/rustc_builtin_macros/src')
0 files changed, 0 insertions, 0 deletions