]> git.lizzy.rs Git - rust.git/commit - src/tools/clippy
Auto merge of #52972 - RalfJung:from_raw_parts_align, r=alexcrichton
authorbors <bors@rust-lang.org>
Sun, 19 Aug 2018 09:40:36 +0000 (09:40 +0000)
committerbors <bors@rust-lang.org>
Sun, 19 Aug 2018 09:40:36 +0000 (09:40 +0000)
commit8928de74394f320d1109da6731b12638a2167945
tree61910bae0095a09ecba3eee2331e8abbe7bae010
parenta9fe312b98d5a6b194c4ad1a17dcf258ba9941ea
parent1001b2beee595db76ae9d612134271e4a971fed8
Auto merge of #52972 - RalfJung:from_raw_parts_align, r=alexcrichton

debug_assert to ensure that from_raw_parts is only used properly aligned

This does not help nearly as much as I would hope because everybody uses the distributed libstd which is compiled without debug assertions. For this reason, I am not sure if this is even worth it. OTOH, this would have caught the misalignment fixed by https://github.com/rust-lang/rust/issues/42789 *if* there had been any tests actually using ZSTs with alignment >1 (we have a CI runner which has debug assertions in libstd enabled), and it seems to currently [fail in the rg testsuite](https://ci.appveyor.com/project/rust-lang/rust/build/1.0.8403/job/v7dfdcgn8ay5j6sb). So maybe it is worth it, after all.

I have seen the attribute `#[rustc_inherit_overflow_checks]` in some places, does that make it so that the *caller's* debug status is relevant? Is there a similar attribute for `debug_assert!`? That could even subsume `rustc_inherit_overflow_checks`: Something like `rustc_inherit_debug_flag` could affect *all* places that change the generated code depending on whether we are in debug or release mode. In fact, given that we have to keep around the MIR for generic functions anyway, is there ever a reason *not* to handle the debug flag that way? I guess currently we apply debug flags like `cfg` so this is dropped early during the MIR pipeline?

EDIT: I learned from @eddyb that because of how `debug_assert!` works, this is not realistic. Well, we could still have it for the rustc CI runs and then maybe, eventually, when libstd gets compiled client-side and there is both a debug and a release build... then this will also benefit users.^^
.travis.yml
src/libcore/slice/mod.rs