rust/compiler/rustc_borrowck/src
bors 7b97a5ca84 Auto merge of #117511 - gurry:117406-err-packed-structs, r=compiler-errors
Emit explanatory note for move errors in packed struct derives

Derive expansions for packed structs with non-`Copy` fields cause move errors because they prefer copying over borrowing since borrowing the fields of a packed struct can result in unaligned access.

This underlying cause of the errors, however, is not apparent to the user. This PR adds a diagnostic note to make it clear to the user (the new note is on the second last line):

```
tests/ui/derives/deriving-with-repr-packed-move-errors.rs:13:16
   |
12 | #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Default)]
   |          ----- in this derive macro expansion
13 | struct StructA(String);
   |                ^^^^^^ move occurs because `self.0` has type `String`, which does not implement the `Copy` trait
   |
   = note: `#[derive(Debug)]` triggers a move because taking references to the fields of a packed struct is undefined behaviour
   = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)
```

Fixes #117406

Partially addresses #110777
2023-11-07 00:03:53 +00:00
..
constraints Split {Idx, IndexVec, IndexSlice} into their own modules 2023-04-24 13:53:35 +00:00
diagnostics Auto merge of #117511 - gurry:117406-err-packed-structs, r=compiler-errors 2023-11-07 00:03:53 +00:00
region_infer consider a loan escapes the function via applied member constraints 2023-10-20 20:59:20 +00:00
type_check prepopulate opaque ty storage before using it :> 2023-10-31 11:50:30 +01:00
util Move some utils out of rustc_const_eval 2023-04-16 12:05:54 +02:00
borrow_set.rs address most easy comments 2023-06-20 20:55:31 +08:00
borrowck_errors.rs Use targetted diagnostic for borrow across yield error 2023-10-27 13:05:49 +00:00
constraint_generation.rs refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
consumers.rs Fix redundant explicit link in rustc_borrowck 2023-08-19 02:22:13 +08:00
dataflow.rs consider a loan escapes the function via applied member constraints 2023-10-20 20:59:20 +00:00
def_use.rs s/generator/coroutine/ 2023-10-20 21:14:01 +00:00
facts.rs introduce Polonius enum for -Zpolonius 2023-10-04 16:16:12 +00:00
invalidation.rs s/Generator/Coroutine/ 2023-10-20 21:10:38 +00:00
lib.rs Remove redundant checks. 2023-10-21 12:10:30 +00:00
location.rs Split {Idx, IndexVec, IndexSlice} into their own modules 2023-04-24 13:53:35 +00:00
member_constraints.rs remove unused muts 2023-04-28 20:19:48 +02:00
nll.rs compute NLL loan scopes with liveness in -Zpolonius=next 2023-10-05 15:56:20 +00:00
path_utils.rs s/generator/coroutine/ 2023-10-20 21:14:01 +00:00
place_ext.rs use PlaceRef abstractions more consistently 2023-06-25 20:38:01 -04:00
places_conflict.rs Add docs, remove code, change subtyper code 2023-10-02 23:39:44 +03:00
prefixes.rs Add docs, remove code, change subtyper code 2023-10-02 23:39:44 +03:00
renumber.rs Avoid unnecessary renumbering 2023-10-16 14:29:36 +02:00
session_diagnostics.rs s/generator/coroutine/ 2023-10-20 21:14:01 +00:00
universal_regions.rs s/generator/coroutine/ 2023-10-20 21:14:01 +00:00
used_muts.rs Rollup merge of #108856 - Zeegomo:remove-drop-and-rep, r=tmiasko 2023-03-08 21:26:51 +01:00