This repository was archived by the owner on May 28, 2025. It is now read-only.
Commit ed49386
committed
Auto merge of rust-lang#136539 - matthewjasper:late-normalize-errors, r=compiler-errors
Emit dropck normalization errors in borrowck
Borrowck generally assumes that any queries it runs for type checking will succeed, thinking that HIR typeck will have errored first if there was a problem. However as of rust-lang#98641, dropck isn't run on HIR, so there's no direct guarantee that it doesn't error. While a type being well-formed might be expected to ensure that its fields are well-formed, this is not the case for types containing a type projection:
```rust
pub trait AuthUser {
type Id;
}
pub trait AuthnBackend {
type User: AuthUser;
}
pub struct AuthSession<Backend: AuthnBackend> {
data: Option<<<Backend as AuthnBackend>::User as AuthUser>::Id>,
}
pub trait Authz: Sized {
type AuthnBackend: AuthnBackend<User = Self>;
}
pub fn run_query<User: Authz>(auth: AuthSession<User::AuthnBackend>) {}
// ^ No User: AuthUser bound is required or inferred.
```
While improvements to trait solving might fix this in the future, for now we go for a pragmatic solution of emitting an error from borrowck (by rerunning dropck outside of a query) and making drop elaboration check if an error has been emitted previously before panicking for a failed normalization.
Closes rust-lang#103899
Closes rust-lang#135039
r? `@compiler-errors` (feel free to re-assign)File tree
20 files changed
+262
-109
lines changed- compiler
- rustc_borrowck/src/type_check/liveness
- rustc_middle/src/query
- rustc_mir_transform/src
- rustc_trait_selection/src/traits/query
- rustc_traits/src
- tests
- crashes
- ui
- dropck
- typeck
- wf
20 files changed
+262
-109
lines changedLines changed: 44 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
15 | 19 | | |
16 | 20 | | |
17 | 21 | | |
| |||
162 | 166 | | |
163 | 167 | | |
164 | 168 | | |
| 169 | + | |
165 | 170 | | |
166 | 171 | | |
167 | | - | |
| 172 | + | |
168 | 173 | | |
169 | 174 | | |
170 | 175 | | |
| |||
522 | 527 | | |
523 | 528 | | |
524 | 529 | | |
| 530 | + | |
525 | 531 | | |
526 | 532 | | |
527 | | - | |
| 533 | + | |
528 | 534 | | |
529 | 535 | | |
530 | 536 | | |
| |||
589 | 595 | | |
590 | 596 | | |
591 | 597 | | |
592 | | - | |
593 | | - | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
594 | 606 | | |
595 | | - | |
596 | | - | |
597 | | - | |
598 | | - | |
599 | | - | |
600 | | - | |
| 607 | + | |
601 | 608 | | |
602 | 609 | | |
603 | 610 | | |
604 | | - | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
605 | 636 | | |
606 | 637 | | |
607 | 638 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
802 | 802 | | |
803 | 803 | | |
804 | 804 | | |
805 | | - | |
| 805 | + | |
806 | 806 | | |
807 | 807 | | |
808 | 808 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
266 | 266 | | |
267 | 267 | | |
268 | 268 | | |
269 | | - | |
270 | | - | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
271 | 284 | | |
272 | 285 | | |
273 | 286 | | |
| |||
Lines changed: 44 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | | - | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
93 | 94 | | |
94 | 95 | | |
95 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
96 | 111 | | |
97 | 112 | | |
98 | 113 | | |
| |||
149 | 164 | | |
150 | 165 | | |
151 | 166 | | |
152 | | - | |
| 167 | + | |
153 | 168 | | |
154 | 169 | | |
155 | 170 | | |
156 | | - | |
| 171 | + | |
157 | 172 | | |
158 | 173 | | |
159 | 174 | | |
| |||
173 | 188 | | |
174 | 189 | | |
175 | 190 | | |
176 | | - | |
177 | | - | |
178 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
179 | 200 | | |
180 | | - | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
181 | 205 | | |
182 | 206 | | |
183 | 207 | | |
| |||
213 | 237 | | |
214 | 238 | | |
215 | 239 | | |
216 | | - | |
| 240 | + | |
217 | 241 | | |
218 | 242 | | |
219 | | - | |
| 243 | + | |
220 | 244 | | |
221 | 245 | | |
222 | 246 | | |
223 | | - | |
| 247 | + | |
224 | 248 | | |
225 | 249 | | |
226 | 250 | | |
| |||
244 | 268 | | |
245 | 269 | | |
246 | 270 | | |
247 | | - | |
| 271 | + | |
248 | 272 | | |
249 | 273 | | |
250 | 274 | | |
251 | 275 | | |
252 | | - | |
| 276 | + | |
253 | 277 | | |
254 | | - | |
255 | | - | |
| 278 | + | |
256 | 279 | | |
257 | 280 | | |
258 | 281 | | |
259 | | - | |
| 282 | + | |
260 | 283 | | |
261 | | - | |
262 | | - | |
| 284 | + | |
263 | 285 | | |
264 | 286 | | |
265 | 287 | | |
| |||
271 | 293 | | |
272 | 294 | | |
273 | 295 | | |
274 | | - | |
| 296 | + | |
275 | 297 | | |
276 | | - | |
277 | | - | |
| 298 | + | |
278 | 299 | | |
279 | 300 | | |
280 | 301 | | |
| |||
313 | 334 | | |
314 | 335 | | |
315 | 336 | | |
316 | | - | |
| 337 | + | |
317 | 338 | | |
318 | 339 | | |
319 | 340 | | |
| |||
346 | 367 | | |
347 | 368 | | |
348 | 369 | | |
349 | | - | |
| 370 | + | |
350 | 371 | | |
351 | 372 | | |
352 | | - | |
353 | | - | |
354 | 373 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
| 33 | + | |
37 | 34 | | |
38 | 35 | | |
39 | 36 | | |
| |||
52 | 49 | | |
53 | 50 | | |
54 | 51 | | |
55 | | - | |
| 52 | + | |
56 | 53 | | |
57 | 54 | | |
58 | 55 | | |
59 | 56 | | |
60 | 57 | | |
61 | | - | |
| 58 | + | |
62 | 59 | | |
63 | 60 | | |
64 | 61 | | |
65 | 62 | | |
66 | 63 | | |
67 | 64 | | |
68 | | - | |
| 65 | + | |
69 | 66 | | |
70 | 67 | | |
71 | 68 | | |
| |||
This file was deleted.
This file was deleted.
| 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 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
0 commit comments