about summary refs log tree commit diff
path: root/src/libcore/mem/maybe_uninit.rs
AgeCommit message (Collapse)AuthorLines
2020-07-27mv std libs to library/mark-806/+0
2020-06-30Deny unsafe ops in unsafe fns, part 2LeSeulArtichaut-10/+32
2020-06-01Remove allow missing_debug_implementations for MaybeUninitKonrad Borowski-1/+0
It already has a Debug implementation.
2020-05-23add warning sign to UB examplesRalf Jung-13/+13
2020-04-25Bump bootstrap compilerMark Rousskov-12/+0
2020-03-12rename panic_if_ intrinsics to assert_Ralf Jung-0/+12
2020-02-22Fix doc example for `MaybeUninit::get_mut()`Daniel Henry-Mantilla-1/+1
Suggested by @ametisf in https://github.com/rust-lang/rust/pull/65948#issuecomment-589988183 Co-Authored-By: Frantisek Fladung <fladufra@fel.cvut.cz>
2019-12-22Format the worldMark Rousskov-5/+6
2019-12-21Require issue = "none" over issue = "0" in unstable attributesRoss MacArthur-4/+4
2019-12-18Propagate cfg bootstrapMark Rousskov-11/+5
2019-12-13Require stable/unstable annotations for the constness of all stable ↵Oliver Scherer-0/+8
functions with a `const` modifier
2019-11-28Auto merge of #65013 - petertodd:2019-maybeuninit-debug, r=sfacklerbors-0/+9
Implement Debug for MaybeUninit Precedent: `UnsafeCell` implements `Debug` even though it can't actually display the value. I noticed this omission while writing the following: ``` #[derive(Debug)] pub struct SliceInitializer<'a, T> { marker: PhantomData<&'a mut T>, uninit: &'a mut [MaybeUninit<T>], written: usize, } ``` ...which currently unergonomically fails to compile. `UnsafeCell` does require `T: Debug`. Because of things like the above I think it'd be better to leave that requirement off. In fact, I'd also suggest removing that requirement for `UnsafeCell` too, which again I noticed in some low-level real world code.
2019-11-10Rollup merge of #66217 - RalfJung:diagnostic-items, r=CentrilYuki Okushi-0/+2
invalid_value lint: use diagnostic items This adjusts the invalid_value lint to use diagnostic items. @Centril @oli-obk For some reason, this fails to recognize `transmute` -- somehow the diagnostic item is not found. Any idea why? r? @Centril Cc https://github.com/rust-lang/rust/issues/66075
2019-11-09partially port invalid_value lint to diagnostic itemsRalf Jung-0/+2
2019-11-08Rollup merge of #65580 - SimonSapin:maybeuninit-array, r=AmanieuYuki Okushi-0/+63
Add `MaybeUninit` methods `uninit_array`, `slice_get_ref`, `slice_get_mut` Eventually these will hopefully become the idiomatic way to work with partially-initialized stack buffers. All methods are unstable. Note that `uninit_array` takes a type-level `const usize` parameter, so it is blocked (at least in its current form) on const generics. Example: ```rust use std::mem::MaybeUninit; let input = b"Foo"; let f = u8::to_ascii_uppercase; let mut buffer: [MaybeUninit<u8>; 32] = MaybeUninit::uninit_array(); let vec; let output = if let Some(buffer) = buffer.get_mut(..input.len()) { buffer.iter_mut().zip(input).for_each(|(a, b)| { a.write(f(b)); }); unsafe { MaybeUninit::slice_get_ref(buffer) } } else { vec = input.iter().map(f).collect::<Vec<u8>>(); &vec }; assert_eq!(output, b"FOO"); ```
2019-11-07Implement Debug for MaybeUninitPeter Todd-0/+9
Precedent: UnsafeCell implements Debug even though it can't actually display the value.
2019-11-07Rollup merge of #63793 - oli-obk:🧹, r=dtolnayMazdak Farrokhzad-0/+2
Have tidy ensure that we document all `unsafe` blocks in libcore cc @rust-lang/libs I documented a few and added ignore flags on the other files. We can incrementally document the files, but won't regress any files this way.
2019-11-07MaybeUninit::uninit_array docs: better exampleSimon Sapin-14/+20
2019-11-07Apply docs suggestions from reviewSimon Sapin-4/+4
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2019-11-07Add `MaybeUninit` methods `uninit_array`, `slice_get_ref`, `slice_get_mut`Simon Sapin-0/+57
2019-11-07Rollup merge of #66044 - RalfJung:uninit-lint, r=oli-obkYuki Okushi-0/+1
Improve uninit/zeroed lint * Also warn when creating a raw pointer with a NULL vtable. * Also identify `MaybeUninit::uninit().assume_init()` and `MaybeUninit::zeroed().assume_init()` as dangerous.
2019-11-06Have tidy ensure that we document all `unsafe` blocks in libcoreOliver Scherer-0/+2
2019-11-04Minor style improvementsDaniel Henry-Mantilla-13/+7
Co-Authored-By: Ralf Jung <post@ralfj.de>
2019-11-04more robust method checking through DefId and diagnostic_itemRalf Jung-0/+1
2019-10-30Added a panic-on-uninhabited guard on get_ref and get_mutDaniel Henry-Mantilla-0/+2
2019-10-30Fix doctestsDaniel Henry-Mantilla-7/+19
2019-10-29Improved MaybeUninit::get_{ref,mut} documentationDaniel Henry-Mantilla-8/+151
2019-09-28Improve wording in documentation of MaybeUninitNils Liberg-6/+6
2019-08-15Auto merge of #63575 - Centril:rollup-anlv9g5, r=Centrilbors-6/+6
Rollup of 11 pull requests Successful merges: - #62984 (Add lint for excess trailing semicolons) - #63075 (Miri: Check that a ptr is aligned and inbounds already when evaluating `*`) - #63490 (libsyntax: cleanup and refactor `pat.rs`) - #63507 (When needing type annotations in local bindings, account for impl Trait and closures) - #63509 (Point at the right enclosing scope when using `await` in non-async fn) - #63528 (syntax: Remove `DummyResult::expr_only`) - #63537 (expand: Unimplement `MutVisitor` on `MacroExpander`) - #63542 (Add NodeId for Arm, Field and FieldPat) - #63543 (Merge Variant and Variant_) - #63560 (move test that shouldn't be in test/run-pass/) - #63570 (Adjust tracking issues for `MaybeUninit<T>` gates) Failed merges: r? @ghost
2019-08-14Adjust tracking issues for `MaybeUninit<T>` gatesMazdak Farrokhzad-6/+6
2019-08-14Handle cfg(bootstrap) throughoutMark Rousskov-1/+1
2019-08-11allow the lint if a few UB-demonstrating doc testsRalf Jung-0/+3
2019-08-07Rollup merge of #63034 - tmandry:reduce-generator-size-regressions, r=cramertjMazdak Farrokhzad-0/+2
Fix generator size regressions due to optimization I tested the generator optimizations in #60187 and #61922 on the Fuchsia build, and noticed that some small generators (about 8% of the async fns in our build) increased in size slightly. This is because in #60187 we split the fields into two groups, a "prefix" non-overlap region and an overlap region, and lay them out separately. This can introduce unnecessary padding bytes between the two groups. In every single case in the Fuchsia build, it was due to there being only a single variant being used in the overlap region. This means that we aren't doing any overlapping, period. So it's better to combine the two regions into one and lay out all the fields at once, which is what this change does. r? @cramertj cc @eddyb @Zoxc
2019-08-06clarifyRalf Jung-2/+2
2019-08-06be clear that 1-init Vec being valid (but not safe) is not a stable guaranteeRalf Jung-2/+4
2019-08-05assume_init: warn about valid != safeRalf Jung-0/+7
2019-08-02Fix typos in doc comments.Bruce Mitchener-1/+1
2019-07-29Wrap promoted generator fields in MaybeUninitTyler Mandry-0/+2
This prevents uninhabited fields from "infecting" the abi and largest_niche of the generator layout. This fixes a latent bug, where an uninhabited field could be promoted to the generator prefix and cause the entire generator to become uninhabited.
2019-07-21tidy is being sillyRalf Jung-5/+2
2019-07-21use a const to hack around promotion limitationsRalf Jung-1/+8
2019-07-19use const array repeat expressions for uninit_arrayRalf Jung-0/+1
2019-07-14Less unsafe in the array example of MaybeUninit docsAndre Bogus-5/+7
2019-07-04Switch master to 1.38Mark Rousskov-1/+1
2019-06-18Make MaybeUninit #[repr(transparent)]Michael Bradshaw-1/+15
Tracking issue: #60405
2019-05-29split libcore::mem into multiple filesRalf Jung-0/+519