rust/src
bors df6ba0c4ac Auto merge of #53998 - eddyb:issue-53728, r=oli-obk
rustc_codegen_llvm: don't assume offsets are always aligned.

Fixes #53728 by taking into account not just overall type alignment and the field's alignment when determining whether a field is aligned or not ("packed"), but also the field's offset within the type.

Previously, rustc assumed that the offset was always at least as aligned as `min(struct.align, field.align)`. However, there's no real reason to have that assumption, and it obviously can't always be true after we implement `#[repr(align(N), pack(K))]`. There's also a case today where that assumption is not true, involving niche discriminants in enums:

Suppose that we have the code in #53728:
```Rust
#[repr(u16)]
enum DeviceKind {
    Nil = 0,
}

#[repr(packed)]
struct DeviceInfo {
    endianness: u8,
    device_kind: DeviceKind,
}

struct Wrapper {
    device_info: DeviceInfo,
    data: u32
}
```

Observe the layout of `Option<Wrapper>`. It has an alignment of 4 because of the `u32`. `device_info.device_kind` is a good niche field to use, which means the enum ends up with this layout:
```
size = 8
align = 4
fields = [
    { offset=1, type=u16 } // discriminant, .<Some>.device_info.device_kind
]
```

And here we have an discriminant with alignment 2 (`u16`) but offset 1.
2018-09-09 08:54:29 +00:00
..
bootstrap Rollup merge of #54050 - GabrielMajeri:fix-build-with-nightly, r=alexcrichton 2018-09-08 18:27:28 +08:00
build_helper
ci [RISCV] Add riscv32imc-unknown-none-elf target. 2018-08-30 16:03:37 +02:00
dlmalloc@c99638dc2e
doc Rollup merge of #54040 - steveklabnik:update-books, r=Mark-Simulacrum 2018-09-08 18:27:15 +08:00
etc Have rust-lldb look for the rust-enabled lldb 2018-09-07 09:13:47 -06:00
grammar
jemalloc@1f5a28755e
liballoc Auto merge of #51885 - GuillaumeGomez:trait-impl-show-docs, r=Mark-Simulacrum,QuietMisdreavus 2018-09-08 04:14:54 +00:00
liballoc_jemalloc Auto merge of #53441 - toidiu:ak-fix53419, r=nikomatsakis 2018-08-27 17:42:45 +00:00
liballoc_system Replace usages of 'bad_style' with 'nonstandard_style'. 2018-08-29 09:01:35 -05:00
libarena check that adding infer-outlives requirement to all crates works 2018-08-24 17:10:50 -04:00
libbacktrace@f4d02bbdbf
libcompiler_builtins@0703bfa725 Update the compiler-builtins submodule 2018-09-05 09:12:17 -07:00
libcore Auto merge of #51885 - GuillaumeGomez:trait-impl-show-docs, r=Mark-Simulacrum,QuietMisdreavus 2018-09-08 04:14:54 +00:00
libfmt_macros check that adding infer-outlives requirement to all crates works 2018-08-24 17:10:50 -04:00
libgraphviz check that adding infer-outlives requirement to all crates works 2018-08-24 17:10:50 -04:00
liblibc@1844a772b6 Update libc to include Fuchsia fixes 2018-08-24 11:52:49 -07:00
libpanic_abort Auto merge of #53441 - toidiu:ak-fix53419, r=nikomatsakis 2018-08-27 17:42:45 +00:00
libpanic_unwind Replace usages of 'bad_style' with 'nonstandard_style'. 2018-08-29 09:01:35 -05:00
libproc_macro check that adding infer-outlives requirement to all crates works 2018-08-24 17:10:50 -04:00
libprofiler_builtins check that adding infer-outlives requirement to all crates works 2018-08-24 17:10:50 -04:00
librustc Auto merge of #53909 - mikhail-m1:53643, r=nikomatsakis 2018-09-08 19:57:14 +00:00
librustc_allocator Auto merge of #53441 - toidiu:ak-fix53419, r=nikomatsakis 2018-08-27 17:42:45 +00:00
librustc_apfloat check that adding infer-outlives requirement to all crates works 2018-08-24 17:10:50 -04:00
librustc_asan check that adding infer-outlives requirement to all crates works 2018-08-24 17:10:50 -04:00
librustc_borrowck Rename hir::map::NodeKind to hir::Node 2018-08-27 21:46:23 +01:00
librustc_codegen_llvm Auto merge of #53998 - eddyb:issue-53728, r=oli-obk 2018-09-09 08:54:29 +00:00
librustc_codegen_utils Rename hir::map::NodeKind to hir::Node 2018-08-27 21:46:23 +01:00
librustc_cratesio_shim Breaking change upgrades 2018-09-04 13:22:08 -06:00
librustc_data_structures add const_fn feature 2018-09-07 13:28:23 -04:00
librustc_driver switch to using NonZeroU32 to represent indices 2018-09-07 11:37:47 -04:00
librustc_errors Breaking change upgrades 2018-09-04 13:22:08 -06:00
librustc_fs_util
librustc_incremental Breaking change upgrades 2018-09-04 13:22:08 -06:00
librustc_lint Auto merge of #53705 - ms2300:tmp, r=oli-obk 2018-09-08 14:16:37 +00:00
librustc_llvm check that adding infer-outlives requirement to all crates works 2018-08-24 17:10:50 -04:00
librustc_lsan check that adding infer-outlives requirement to all crates works 2018-08-24 17:10:50 -04:00
librustc_metadata crates that provide a panic_handler are exempt from unused_extern_crates 2018-09-06 21:24:33 +02:00
librustc_metadata_utils
librustc_mir Auto merge of #53909 - mikhail-m1:53643, r=nikomatsakis 2018-09-08 19:57:14 +00:00
librustc_msan check that adding infer-outlives requirement to all crates works 2018-08-24 17:10:50 -04:00
librustc_passes Auto merge of #53815 - F001:if-let-guard, r=petrochenkov 2018-09-01 20:31:29 +00:00
librustc_platform_intrinsics Replace usages of 'bad_style' with 'nonstandard_style'. 2018-08-29 09:01:35 -05:00
librustc_plugin Add deprecated_name argument to the register lint group functions 2018-08-31 00:46:55 -07:00
librustc_privacy Auto merge of #53705 - ms2300:tmp, r=oli-obk 2018-09-08 14:16:37 +00:00
librustc_resolve Auto merge of #53988 - eddyb:issue-53770, r=petrochenkov 2018-09-09 06:25:13 +00:00
librustc_save_analysis A few cleanups and minor improvements to save_analysis 2018-09-03 18:37:54 +02:00
librustc_target rustc_codegen_llvm: don't assume offsets are always aligned. 2018-09-06 20:56:20 +03:00
librustc_traits Changing TyAnon -> TyOpaque and relevant functions 2018-09-05 13:01:16 -06:00
librustc_tsan check that adding infer-outlives requirement to all crates works 2018-08-24 17:10:50 -04:00
librustc_typeck Auto merge of #53705 - ms2300:tmp, r=oli-obk 2018-09-08 14:16:37 +00:00
librustdoc Auto merge of #53705 - ms2300:tmp, r=oli-obk 2018-09-08 14:16:37 +00:00
libserialize rewrite constants to use NewType::MAX instead of u32::MAX 2018-09-07 11:37:47 -04:00
libstd Auto merge of #54051 - kennytm:rollup, r=kennytm 2018-09-08 11:53:21 +00:00
libsyntax Auto merge of #53949 - estebank:unclosed-delim, r=nikomatsakis 2018-09-09 01:36:58 +00:00
libsyntax_ext Move #[test_case] to a syntax extension 2018-09-04 22:33:23 -07:00
libsyntax_pos Use FxHash{Map,Set} instead of the default Hash{Map,Set} everywhere in rustc. 2018-08-28 17:04:04 +03:00
libterm check that adding infer-outlives requirement to all crates works 2018-08-24 17:10:50 -04:00
libtest Auto merge of #53867 - cwndrws:json-test-formatter-test-count-as-num, r=nrc 2018-09-05 09:57:56 +00:00
libunwind Replace usages of 'bad_style' with 'nonstandard_style'. 2018-08-29 09:01:35 -05:00
llvm@2a1cdeadd3 Update LLVM submodule 2018-08-31 16:00:41 -07:00
llvm-emscripten@2717444753
rtstartup
rustc
rustllvm Auto merge of #53673 - michaelwoerister:incr-thinlto-2000, r=alexcrichton 2018-09-03 13:59:57 +00:00
stdsimd@05c2f61c38
test Auto merge of #53998 - eddyb:issue-53728, r=oli-obk 2018-09-09 08:54:29 +00:00
tools Rollup merge of #54023 - matthiaskrgr:clippy, r=oli-obk 2018-09-07 18:14:28 +08:00
.gitignore move file-extension based .gitignore down to src/ 2018-08-28 20:04:52 +02:00
Cargo.lock Update petgraph dependency to 0.4.13 2018-09-08 09:04:29 +03:00
Cargo.toml
README.md
stage0.txt

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

  • rustc and its tests
  • libstd
  • Various submodules for tools, like rustdoc, rls, etc.

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

Their is also useful content in the following READMEs, which are gradually being moved over to the guide: