| Age | Commit message (Collapse) | Author | Lines |
|
|
|
rename-unique: Change calls and doc in raw_vec.rs
rename-unique: Change empty() -> dangling() in const-ptr-unique-rpass.rs
|
|
r=Mark-Simulacrum
Document unsafety in core::ptr
Contributes to #66219
I have yet to document all the `unsafe` blocks in the lib and would like to know if I'm headed in the right direction
r? @steveklabnik
|
|
Add documentation example to slice_from_raw_parts_mut()
Add SAFETY explanations to some unsafe blocks in libcore/ptr
* libcore/ptr/mod.rs
* libcore/ptr/unique.rs
* libcore/ptr/non_null.rs
safety-mod.rs: Add SAFETY to slice_from_raw_parts(),
slice_from_raw_parts_mut()
slice_from_raw_parts_mut: Add documentation example
safety-ptr-unique.rs: Add SAFETY to new() and cast()
safety-ptr-non_null.rs: Add SAFETY to new()
safety-ptr-non_null.rs: Add SAFETY to cast()
safety-ptr-non_null.rs: Add SAFETY to from() impls
safety-ptr-unique.rs: Add SAFETY to from() impls
safety-ptr-non_null.rs: Add SAFETY to new()
safety-ptr-unique.rs: Add SAFETY to new()
safety-ptr-mod.rs: Fix safety explanation
https://github.com/rust-lang/rust/pull/71507#discussion_r414488884
safety-prt-non_null.rs: Fix SAFETY comment syntax
safety-ptr-unique.rs: Fix syntax for empty()
safety-ptr-non_null.rs: Fix misuse of non-null for align_of()
safety-ptr-non_null.rs: Remove incorrect SAFETY comment
safety-ptr-unique.rs: Remove unsound SAFETY comment
safety-ptr-mod.rs: Add std comment on slice_from_raw_parts guarantee
safety-ptr-unique.rs: Remove incorrect safety comment
Creating a Unique from a NonNull has strict guarantees that the current
implementation does not guarantee
https://github.com/rust-lang/rust/pull/71507#discussion_r415035952
safety-ptr: Re-adding ignore-tidy directive
|
|
|
|
|
|
Changed raw pointer name from ptr to raw_pointer to avoid confusion with
the `use std::ptr` statement a few lines above. This way the crate name
and pointer name are well differenciated.
|
|
|
|
|
|
It is already possible to extract the pointer part of a raw slice by a
simple cast, but retrieving the length is not possible without relying
on the representation of the raw slice when it is not valid to convert
the raw slice into a slice reference (i.e. the pointer is null or
unaligned).
Introduce a len() method on raw slices to add this missing feature.
|
|
|
|
|
|
|
|
|
|
debug_assert a few more raw pointer methods
Makes progress for https://github.com/rust-lang/rust/issues/53871
|
|
|
|
|
|
Added missing conditions:
- Valid for writes
- Valid for destructing
|
|
For all methods which read a value of type T, `read`, `read_unaligned`,
`read_volatile` and `replace`, added missing
constraint:
The value they point to must be properly initialized
|
|
Added missing condition:
`dst` must be readable
|
|
s/for reads and writes/for both ...
|
|
- As explained in the comment inside mod_inv, it is valid to work mod
`usize::max_value()` right until the end.
|
|
- When calculating the inverse, it's enough to work `mod a/g` instead
of `mod a`.
|
|
- Stopping condition inside mod_inv can be >= instead of >
- Remove intrinsics::unchecked_rem, we are working modulu powers-of-2 so
we can simply mask
|
|
Stabilize ptr::slice_from_raw_parts[_mut]
Closes #36925, the tracking issue.
Initial impl: #60667
r? @rust-lang/libs
In addition to stabilizing, I've adjusted the example of `ptr::slice_from_raw_parts` to use `slice_from_raw_parts` instead of `slice_from_raw_parts_mut`, which was unnecessary for the example as written.
|
|
|
|
|
|
|
|
The as_ref method already has a Null-unchecked version section, its
example is a modification of the example in the main as_ref section.
Similarly the example in this commit is a modification of the example
in main as_mut section.
|
|
|
|
|
|
Require issue = "none" over issue = "0" in unstable attributes
These changes make the use of `issue = "none"` required in unstable attributes throughout the compiler.
Notes:
- #66299 is now in beta so `issue = "none"` is accepted.
- The `tidy` tool now fails on `issue = "0"`.
- Tests that used `issue = "0"` were changed to use `issue = "none"`, except for _one_ that asserts `issue = "0"` can still be used.
- The compiler still allows `issue = "0"` because some submodules require it, this could be disallowed once these are updated.
Resolves #41260
r? @varkor
|
|
Make ptr::slice_from_raw_parts a const fn available under a feature flag
A first step in the direction of https://github.com/rust-lang/rust/issues/67456 .
This makes `ptr::slice_from_raw_parts` and `ptr::slice_from_raw_parts_mut` available as a const fn under a feature flag.
|
|
|
|
|
|
and the other with mut ptr
|
|
|
|
functions with a `const` modifier
|
|
|
|
|
|
Rephrase docs in for ptr
These methods can be supplied with NULL just fine, this is the whole point of `Option<&T>` return type.
|
|
|
|
|
|
This commit applies rustfmt with default settings to files in
src/libcore *that are not involved in any currently open PR* to minimize
merge conflicts. The list of files involved in open PRs was determined
by querying GitHub's GraphQL API with this script:
https://gist.github.com/dtolnay/aa9c34993dc051a4f344d1b10e4487e8
With the list of files from the script in `outstanding_files`, the
relevant commands were:
$ find src/libcore -name '*.rs' | xargs rustfmt --edition=2018
$ rg libcore outstanding_files | xargs git checkout --
Repeating this process several months apart should get us coverage of
most of the rest of libcore.
|
|
|
|
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.
|
|
|
|
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
|
|
|
|
|