rust/compiler/rustc_lint/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
..
nonstandard_style mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
array_into_iter.rs Don't give invalid suggestions in array_into_iter. 2021-08-30 23:43:38 +02:00
builtin.rs rustc_target: move LayoutOf to ty::layout. 2021-09-02 01:17:14 +03:00
context.rs ty::layout: split LayoutOf into required and (blanket) provided halves. 2021-09-02 01:17:14 +03:00
early.rs Add additional missing lint handling logic 2021-07-17 23:03:58 -05:00
internal.rs Auto merge of #86827 - camsteffen:hash-lint-resolved, r=oli-obk 2021-07-13 15:06:10 +00:00
late.rs Rename walk_crate. 2021-09-02 19:23:11 +02:00
levels.rs Rename walk_crate. 2021-09-02 19:23:11 +02:00
lib.rs Warn when [T; N].into_iter() is ambiguous in the new edition. 2021-08-30 21:27:31 +02:00
methods.rs Fix doctest 2020-10-26 18:19:49 -04:00
non_ascii_idents.rs Stablize non_ascii_idents feature. 2021-04-08 02:52:00 +08:00
non_fmt_panic.rs Auto merge of #88083 - m-ou-se:non-fmt-panics-suggest-debug, r=estebank 2021-08-17 16:43:40 +00:00
nonstandard_style.rs Fix more “a”/“an” typos 2021-08-22 17:27:18 +02:00
noop_method_call.rs review 2021-08-26 11:14:31 +02:00
passes.rs Add inferred args to typeck 2021-07-25 07:28:51 +00:00
redundant_semicolon.rs Lint on redundant trailing semicolon after item 2020-12-29 16:30:02 -05:00
tests.rs Update to last upstream version 2021-07-08 17:14:28 +02:00
traits.rs fmt 2021-09-09 05:21:30 +00:00
types.rs Make abi::Abi Copy and remove a *lot* of refs 2021-09-09 10:41:19 +02:00
unused.rs Use more accurate spans for "unused delimiter" lint 2021-09-09 14:24:33 +00:00