Commit f9989d0
committed
Always make ptr->ptr casts explicit in THIR
THIR building doesn't produce `ExprKind::Cast` for trivial casts.
This is all fine and good on its own but causes problems with raw pointers.
Region-unaware HIR typeck considers casting `*const Foo<'short>` to
`*const Foo<'long>` to be a trivial cast because they're the same type
modulo regions, but borrowck disagrees, emitting errors.
We now force all raw pointer casts to go through `ExprKind::Cast`, which
allows MIR building to pick the right casts that make borrowck blissfully
unaware of our lifetime crimes.1 parent 5633798 commit f9989d0
File tree
3 files changed
+40
-12
lines changed- compiler/rustc_mir_build/src/thir/cx
- tests
- mir-opt
- ui/cast
3 files changed
+40
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
175 | | - | |
| 175 | + | |
| 176 | + | |
176 | 177 | | |
177 | 178 | | |
178 | 179 | | |
179 | 180 | | |
180 | 181 | | |
| 182 | + | |
181 | 183 | | |
182 | 184 | | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
187 | 194 | | |
188 | 195 | | |
189 | | - | |
| 196 | + | |
190 | 197 | | |
191 | 198 | | |
192 | 199 | | |
| |||
755 | 762 | | |
756 | 763 | | |
757 | 764 | | |
758 | | - | |
| 765 | + | |
759 | 766 | | |
760 | 767 | | |
761 | 768 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | | - | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
20 | 24 | | |
| 25 | + | |
21 | 26 | | |
22 | 27 | | |
23 | 28 | | |
| |||
| 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 | + | |
| 16 | + | |
0 commit comments