rust/src
bors 20997f6ad8 Auto merge of #83698 - erikdesjardins:undefconst, r=RalfJung,oli-obk
Use undef for uninitialized bytes in constants

Fixes #83657

This generates good code when the const is fully uninit, e.g.

```rust
#[no_mangle]
pub const fn fully_uninit() -> MaybeUninit<[u8; 10]> {
    const M: MaybeUninit<[u8; 10]> = MaybeUninit::uninit();
    M
}
```
generates
```asm
fully_uninit:
	ret
```

as you would expect.

There is no improvement, however, when it's partially uninit, e.g.

```rust
pub struct PartiallyUninit {
    x: u64,
    y: MaybeUninit<[u8; 10]>
}

#[no_mangle]
pub const fn partially_uninit() -> PartiallyUninit {
    const X: PartiallyUninit = PartiallyUninit { x: 0xdeadbeefcafe, y: MaybeUninit::uninit() };
    X
}
```
generates
```asm
partially_uninit:
	mov	rax, rdi
	mov	rcx, qword ptr [rip + .L__unnamed_1+16]
	mov	qword ptr [rdi + 16], rcx
	movups	xmm0, xmmword ptr [rip + .L__unnamed_1]
	movups	xmmword ptr [rdi], xmm0
	ret

.L__unnamed_1:
	.asciz	"\376\312\357\276\255\336\000"
	.zero	16
	.size	.L__unnamed_1, 24
```
which copies a bunch of zeros in place of the undef bytes, the same as before this change.

Edit: generating partially-undef constants isn't viable at the moment anyways due to #84565, so it's disabled
2021-08-26 10:49:25 +00:00
..
bootstrap Auto merge of #88069 - Mark-Simulacrum:llvm-pgo, r=pietroalbini 2021-08-26 01:14:16 +00:00
build_helper rfc3052: Remove authors field from Cargo manifests 2021-07-29 14:56:05 -07:00
ci Bump sccache used in CI to v0.2.15 2021-08-25 16:26:45 -04:00
doc Rollup merge of #88277 - ehuss:update-books, r=ehuss 2021-08-25 15:48:57 +02:00
etc set the executable bit on pre-commit.sh 2021-08-11 15:06:33 -04:00
librustdoc Auto merge of #88222 - jyn514:shared-cache, r=GuillaumeGomez 2021-08-26 08:04:29 +00:00
llvm-project@e6c5dd473b Update to LLVM 13 2021-08-16 20:24:02 +02:00
rustdoc-json-types rfc3052: Remove authors field from Cargo manifests 2021-07-29 14:56:05 -07:00
test Auto merge of #83698 - erikdesjardins:undefconst, r=RalfJung,oli-obk 2021-08-26 10:49:25 +00:00
tools Auto merge of #83302 - camsteffen:write-piece-unchecked, r=dtolnay 2021-08-23 22:55:19 +00:00
README.md
stage0.txt bump bootstrap compiler to 1.55 2021-08-01 11:19:24 -04:00
version Bump to 1.56 2021-07-23 17:04:59 -04:00

This directory contains the source code of the rust project, including:

  • The test suite
  • The bootstrapping build system
  • Various submodules for tools, like rustdoc, rls, etc.

For more information on how various parts of the compiler work, see the rustc dev guide.