Commit 0146969
authored
Rollup merge of rust-lang#105611 - BoxyUwU:more_granular_placeholderification, r=wesleywiser
fold instead of obliterating args
Fixes rust-lang#105608
we call `const_eval_resolve` on the following constant:
```
def: playground::{impl#0}::and::{constant#0},
substs: [
ConstKind::Unevaluated {
def: playground::{impl#0}::and::{constant#0},
substs: [
ConstKind::Value(0x0),
_,
]
}
_,
],
```
when expanded out to `ConstKind::Expr` there are no infer vars so we attempt to evaluate it after replacing infer vars with garbage, however the current logic for replacing with garbage replaces _the whole arg containing the infer var_ rather than just the infer var. This means that after garbage replacement has occured we attempt to evaluate:
```
def: playground::{impl#0}::and::{constant#0},
substs: [
PLACEHOLDER,
PLACEHOLDER,
],
```
Which then leads to ctfe being unable to evaluate the const. With this PR we attempt to evaluate:
```
def: playground::{impl#0}::and::{constant#0},
substs: [
ConstKind::Unevaluated {
def: playground::{impl#0}::and::{constant#0},
substs: [
ConstKind::Value(0x0),
PLACEHOLDER,
]
}
PLACEHOLDER,
],
```
which ctfe _can_ handle.
I am not entirely sure why this function is supposed to replace params with placeholders rather than just inference vars 🤔File tree
3 files changed
+67
-15
lines changed- compiler/rustc_infer/src/infer
- src/test/ui/const-generics/generic_const_exprs
3 files changed
+67
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2014 | 2014 | | |
2015 | 2015 | | |
2016 | 2016 | | |
2017 | | - | |
2018 | | - | |
2019 | | - | |
2020 | | - | |
| 2017 | + | |
| 2018 | + | |
| 2019 | + | |
| 2020 | + | |
| 2021 | + | |
| 2022 | + | |
| 2023 | + | |
| 2024 | + | |
| 2025 | + | |
| 2026 | + | |
| 2027 | + | |
| 2028 | + | |
| 2029 | + | |
2021 | 2030 | | |
2022 | | - | |
| 2031 | + | |
| 2032 | + | |
| 2033 | + | |
| 2034 | + | |
| 2035 | + | |
2023 | 2036 | | |
2024 | | - | |
| 2037 | + | |
| 2038 | + | |
2025 | 2039 | | |
2026 | | - | |
2027 | | - | |
2028 | | - | |
| 2040 | + | |
| 2041 | + | |
| 2042 | + | |
| 2043 | + | |
| 2044 | + | |
| 2045 | + | |
2029 | 2046 | | |
2030 | | - | |
| 2047 | + | |
2031 | 2048 | | |
2032 | | - | |
| 2049 | + | |
2033 | 2050 | | |
2034 | 2051 | | |
2035 | | - | |
| 2052 | + | |
| 2053 | + | |
| 2054 | + | |
| 2055 | + | |
| 2056 | + | |
2036 | 2057 | | |
2037 | 2058 | | |
2038 | 2059 | | |
2039 | | - | |
| 2060 | + | |
| 2061 | + | |
2040 | 2062 | | |
2041 | | - | |
2042 | 2063 | | |
2043 | | - | |
| 2064 | + | |
| 2065 | + | |
| 2066 | + | |
2044 | 2067 | | |
Lines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
0 commit comments