rust/compiler/rustc_middle/src
bors cdeba02ff7 Auto merge of #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 #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`
2021-09-15 03:51:03 +00:00
..
dep_graph Update DepNode's size 2021-07-10 21:46:31 +08:00
hir Rollup merge of #88677 - petrochenkov:exportid, r=davidtwco 2021-09-12 03:44:53 -07:00
ich Auto merge of #84373 - cjgillot:resolve-span, r=michaelwoerister,petrochenkov 2021-09-11 23:35:28 +00:00
infer Miscellaneous inlining improvements 2021-06-02 08:49:58 +02:00
middle Fix drop handling for if let expressions 2021-09-01 23:47:41 +01:00
mir Rollup merge of #88859 - RalfJung:size-helpers, r=oli-obk 2021-09-13 21:20:40 +02:00
query Auto merge of #88558 - fee1-dead:const-drop, r=oli-obk 2021-09-15 03:51:03 +00:00
thir add a CastKind to Node::Cast 2021-09-09 01:32:03 +01:00
traits Auto merge of #88558 - fee1-dead:const-drop, r=oli-obk 2021-09-15 03:51:03 +00:00
ty Auto merge of #88558 - fee1-dead:const-drop, r=oli-obk 2021-09-15 03:51:03 +00:00
util Make panic/assert calls in rustc compatible with Rust 2021. 2021-02-03 22:42:53 +01:00
arena.rs Remove unused arena macro args 2021-08-30 13:09:38 +02:00
lib.rs Bump stage0 compiler to 1.56 2021-09-08 20:51:05 -04:00
lint.rs Fix #88256, remove duplicated diagnostic 2021-09-04 19:26:25 +08:00
macros.rs
tests.rs
thir.rs rename mir -> thir around abstract consts 2021-09-09 01:32:03 +01:00