Commit cdeba02
committed
Auto merge of rust-lang#88558 - fee1-dead:const-drop, r=oli-obk
Const drop
The changes are pretty primitive at this point. But at least it works. ^-^
Problems with the current change that I can think of now:
- [x] `~const Drop` shouldn't change anything in the non-const world.
- [x] types that do not have drop glues shouldn't fail to satisfy `~const Drop` in const contexts. `struct S { a: u8, b: u16 }` This might not fail for `needs_non_const_drop`, but it will fail in `rustc_trait_selection`.
- [x] The current change accepts types that have `const Drop` impls but have non-const `Drop` glue.
Fixes rust-lang#88424.
Significant Changes:
- `~const Drop` is no longer treated as a normal trait bound. In non-const contexts, this bound has no effect, but in const contexts, this restricts the input type and all of its transitive fields to either a) have a `const Drop` impl or b) can be trivially dropped (i.e. no drop glue)
- `T: ~const Drop` will not be linted like `T: Drop`.
- Instead of recursing and iterating through the type in `rustc_mir::transform::check_consts`, we use the trait system to special case `~const Drop`. See [`rustc_trait_selection::...::candidate_assembly#assemble_const_drop_candidates`](https://github.com/fee1-dead/rust/blob/const-drop/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs#L817) and others.
Changes not related to `const Drop`ping and/or changes that are insignificant:
- `Node.constness_for_typeck` no longer returns `hir::Constness::Const` for type aliases in traits. This was previously used to hack how we determine default bound constness for items. But because we now use an explicit opt-in, it is no longer needed.
- Removed `is_const_impl_raw` query. We have `impl_constness`, and the only existing use of that query uses `HirId`, which means we can just operate it with hir.
- `ty::Destructor` now has a field `constness`, which represents the constness of the destructor.
r? `@oli-obk`File tree
26 files changed
+552
-106
lines changed- compiler
- rustc_ast_passes/src
- rustc_const_eval/src
- const_eval
- transform
- check_consts
- rustc_hir/src
- rustc_lint/src
- rustc_middle/src
- query
- traits
- ty
- rustc_trait_selection/src/traits
- select
- rustc_ty_utils/src
- src/test/ui/rfc-2632-const-trait-impl
26 files changed
+552
-106
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1669 | 1669 | | |
1670 | 1670 | | |
1671 | 1671 | | |
1672 | | - | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + | |
1673 | 1675 | | |
1674 | 1676 | | |
1675 | 1677 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
38 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
39 | 45 | | |
40 | 46 | | |
41 | 47 | | |
| |||
70 | 76 | | |
71 | 77 | | |
72 | 78 | | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | 79 | | |
87 | 80 | | |
88 | 81 | | |
| |||
103 | 96 | | |
104 | 97 | | |
105 | 98 | | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
| 99 | + | |
112 | 100 | | |
Lines changed: 9 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | | - | |
| 83 | + | |
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
| 90 | + | |
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| |||
988 | 988 | | |
989 | 989 | | |
990 | 990 | | |
991 | | - | |
992 | | - | |
993 | | - | |
994 | | - | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
995 | 995 | | |
996 | | - | |
| 996 | + | |
997 | 997 | | |
998 | 998 | | |
999 | 999 | | |
| |||
Lines changed: 5 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| |||
Lines changed: 37 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
9 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
10 | 14 | | |
11 | 15 | | |
12 | 16 | | |
| |||
17 | 21 | | |
18 | 22 | | |
19 | 23 | | |
20 | | - | |
| 24 | + | |
21 | 25 | | |
22 | 26 | | |
23 | 27 | | |
| |||
97 | 101 | | |
98 | 102 | | |
99 | 103 | | |
100 | | - | |
| 104 | + | |
101 | 105 | | |
102 | | - | |
103 | | - | |
| 106 | + | |
| 107 | + | |
104 | 108 | | |
105 | 109 | | |
106 | 110 | | |
107 | 111 | | |
108 | 112 | | |
109 | 113 | | |
110 | 114 | | |
111 | | - | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
112 | 142 | | |
113 | 143 | | |
114 | 144 | | |
115 | | - | |
| 145 | + | |
116 | 146 | | |
117 | 147 | | |
118 | 148 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
231 | 231 | | |
232 | 232 | | |
233 | 233 | | |
234 | | - | |
| 234 | + | |
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3234 | 3234 | | |
3235 | 3235 | | |
3236 | 3236 | | |
3237 | | - | |
3238 | | - | |
3239 | | - | |
3240 | | - | |
3241 | | - | |
3242 | | - | |
| 3237 | + | |
3243 | 3238 | | |
3244 | 3239 | | |
3245 | 3240 | | |
| |||
3258 | 3253 | | |
3259 | 3254 | | |
3260 | 3255 | | |
3261 | | - | |
3262 | 3256 | | |
3263 | 3257 | | |
3264 | 3258 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
89 | 90 | | |
90 | 91 | | |
91 | 92 | | |
| |||
94 | 95 | | |
95 | 96 | | |
96 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
97 | 102 | | |
98 | 103 | | |
99 | 104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
552 | 552 | | |
553 | 553 | | |
554 | 554 | | |
555 | | - | |
556 | | - | |
557 | | - | |
558 | | - | |
559 | | - | |
560 | | - | |
561 | | - | |
562 | | - | |
563 | 555 | | |
564 | 556 | | |
565 | 557 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
529 | 529 | | |
530 | 530 | | |
531 | 531 | | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
532 | 535 | | |
533 | 536 | | |
534 | 537 | | |
| |||
543 | 546 | | |
544 | 547 | | |
545 | 548 | | |
546 | | - | |
| 549 | + | |
| 550 | + | |
547 | 551 | | |
548 | 552 | | |
549 | 553 | | |
| |||
560 | 564 | | |
561 | 565 | | |
562 | 566 | | |
563 | | - | |
| 567 | + | |
| 568 | + | |
564 | 569 | | |
565 | 570 | | |
566 | 571 | | |
| |||
621 | 626 | | |
622 | 627 | | |
623 | 628 | | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
624 | 632 | | |
625 | 633 | | |
626 | 634 | | |
| |||
712 | 720 | | |
713 | 721 | | |
714 | 722 | | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
715 | 726 | | |
716 | 727 | | |
717 | 728 | | |
| |||
0 commit comments