Ralf Jung
1a2bc1102d
Rust is a proper name: rust → Rust
2024-03-07 07:49:22 +01:00
Matthias Krüger
327842b4ab
Rollup merge of #121894 - RalfJung:const_eval_select, r=oli-obk
...
const_eval_select: make it safe but be careful with what we expose on stable for now
As this is all still nightly-only I think `````@rust-lang/wg-const-eval````` can do that without involving t-lang.
r? `````@oli-obk`````
Cc `````@Nilstrieb````` -- the updated version of your RFC would basically say that we can remove these comments about not making behavior differences visible in stable `const fn`
2024-03-05 22:10:01 +01:00
Ralf Jung
d579caf384
library/ptr: mention that ptr::without_provenance is equivalent to deriving from the null ptr
2024-03-03 12:34:38 +01:00
Matthias Krüger
3e59b7834a
Rollup merge of #121759 - RalfJung:addr_of, r=the8472
...
attempt to further clarify addr_of docs
2024-03-02 16:53:15 +01:00
Ralf Jung
374607d6b9
const_eval_select: make it safe but be careful with what we expose on stable for now
2024-03-02 16:09:31 +01:00
Ralf Jung
ec5e2dc241
attempt to further clarify addr_of docs
2024-03-02 10:12:02 +01:00
r0cky
61fcdf6655
Add proper cfg
2024-02-29 09:25:28 +08:00
Pavel Grigorenko
ff187a92d8
library: use addr_of!
2024-02-24 16:02:17 +03:00
bors
b6a23b8537
Auto merge of #121454 - reitermarkus:generic-nonzero-library, r=dtolnay
...
Use generic `NonZero` everywhere in `library`.
Tracking issue: https://github.com/rust-lang/rust/issues/120257
Use generic `NonZero` everywhere (except stable examples).
r? `@dtolnay`
2024-02-23 14:27:33 +00:00
Markus Reiter
14ed426eec
Use generic NonZero everywhere in core.
2024-02-22 15:17:33 +01:00
Johannes Rudolph
c276af2373
Fix typo in metadata.rs doc comment
2024-02-22 09:30:03 +01:00
Ralf Jung
b58f647d54
rename ptr::invalid -> ptr::without_provenance
...
also introduce ptr::dangling matching NonNull::dangling
2024-02-21 20:15:52 +01:00
Ben Kimock
581e171773
Convert debug_assert_nounwind to intrinsics::debug_assertions
2024-02-19 20:38:09 -05:00
Markus Reiter
a90cc05233
Replace NonZero::<_>::new with NonZero::new.
2024-02-15 08:09:42 +01:00
Markus Reiter
746a58d435
Use generic NonZero internally.
2024-02-15 08:09:42 +01:00
Matthias Krüger
d71154f80f
Rollup merge of #120888 - saethlin:unsafe-precondition-cleanup, r=RalfJung
...
assert_unsafe_precondition cleanup
I moved the polymorphic `is_nonoverlapping` into the `Cell` function that uses it and renamed `intrinsics::is_nonoverlapping_mono` to just `intrinsics::is_nonoverlapping`.
We now also have some docs for `intrinsics::debug_assertions`.
r? RalfJung
2024-02-11 23:19:10 +01:00
Matthias Krüger
3d7d709925
Rollup merge of #120880 - RalfJung:vtable-fnptr-partialeq, r=cuviper
...
add note on comparing vtables / function pointers
Fixes https://github.com/rust-lang/rust/issues/99388
Fixes https://github.com/rust-lang/rust/issues/117047
2024-02-11 23:19:09 +01:00
Ben Kimock
f0de10039c
Cleanup around the new assert_unsafe_precondition
...
Make the polymorphic is_nonoverlapping private
Fix assert_unsafe_precondition doc typos
Add docs for intrinsics::debug_assertions
2024-02-11 12:35:44 -05:00
Matthias Krüger
0c5d8d3d3e
Rollup merge of #119449 - Nilstrieb:library-clippy, r=cuviper
...
Fix `clippy::correctness` in the library
needs https://github.com/rust-lang/backtrace-rs/pull/579 to be complete
for https://github.com/rust-lang/compiler-team/issues/709
2024-02-11 08:25:42 +01:00
Ralf Jung
1383657a46
add note on comparing vtables / function pointers
2024-02-10 14:58:37 +01:00
Ben Kimock
dbf817bae1
Add and use Unique::as_non_null_ptr
2024-02-08 19:56:30 -05:00
Ben Kimock
88d6e9f868
Reduce use of NonNull::new_unchecked in library/
2024-02-08 11:52:16 -05:00
Ben Kimock
61118ffd04
Rewrite assert_unsafe_precondition around the new intrinsic
2024-02-08 11:52:14 -05:00
Ralf Jung
0184ca695b
revert stabilization of const_intrinsic_copy
2024-02-05 20:58:31 +01:00
Ralf Jung
b4e1c569fe
raw pointer metadata API: data address -> data pointer
2024-01-29 07:56:38 +01:00
Frank Steffahn
6a81ec3c13
Fix links to [strict|exposed] provenance sections of [std|core]::ptr
2024-01-25 11:55:07 +00:00
Nilstrieb
e55716e20e
Fix clippy::correctness in the library
2024-01-21 14:14:10 +01:00
Pietro Albini
f9f5840eb4
update cfg(bootstrap)s
2023-12-22 11:14:11 +01:00
Pietro Albini
c00486c9bb
update version placeholders
2023-12-22 11:01:42 +01:00
Maybe Waffle
b863e9ba57
Stabilize ptr::{from_ref, from_mut}
2023-12-15 08:34:59 -08:00
bors
8a3765582c
Auto merge of #117758 - Urgau:lint_pointer_trait_comparisons, r=davidtwco
...
Add lint against ambiguous wide pointer comparisons
This PR is the resolution of https://github.com/rust-lang/rust/issues/106447 decided in https://github.com/rust-lang/rust/issues/117717 by T-lang.
## `ambiguous_wide_pointer_comparisons`
*warn-by-default*
The `ambiguous_wide_pointer_comparisons` lint checks comparison of `*const/*mut ?Sized` as the operands.
### Example
```rust
let ab = (A, B);
let a = &ab.0 as *const dyn T;
let b = &ab.1 as *const dyn T;
let _ = a == b;
```
### Explanation
The comparison includes metadata which may not be expected.
-------
This PR also drops `clippy::vtable_address_comparisons` which is superseded by this one.
~~One thing: is the current naming right? `invalid` seems a bit too much.~~
Fixes https://github.com/rust-lang/rust/issues/117717
2023-12-11 14:33:16 +00:00
surechen
40ae34194c
remove redundant imports
...
detects redundant imports that can be eliminated.
for #117772 :
In order to facilitate review and modification, split the checking code and
removing redundant imports code into two PR.
2023-12-10 10:56:22 +08:00
Urgau
30c7b18d25
Allow ambiguous_wide_pointer_comparisons lint for std methods
2023-12-06 09:03:48 +01:00
Ralf Jung
2a3fcc0a57
move calling miri_promise_symbolic_alignment to a shared helper
2023-12-03 21:51:14 +01:00
Ralf Jung
bebba4f6e0
miri: support 'promising' alignment for symbolic alignment check
2023-12-03 21:51:14 +01:00
Ralf Jung
f2dc18d0a1
update addr docs
2023-12-01 08:35:23 +01:00
Ralf Jung
dbea549d80
move exposed-provenance APIs into separate feature gate and explain the relationship of Exposed Provenance and Strict Provenance
2023-11-30 22:49:13 +01:00
Matthias Krüger
afe2d7392f
Rollup merge of #118231 - RalfJung:const-raw-slice-empty, r=cuviper
...
also add is_empty to const raw slices
We have this on mutable raw slices but not const raw slices, which makes little sense.
Cc https://github.com/rust-lang/rust/issues/71146
2023-11-29 12:34:49 +01:00
Maybe Waffle
e1b4e8a257
Add is_aligned{,_to} convenience methods to NonNull
2023-11-26 16:01:31 +00:00
Maybe Waffle
2bcaa9760e
Add align_offset convenience method to NonNull
2023-11-26 16:01:30 +00:00
Maybe Waffle
4cc46df98c
Add replace and swap convenience methods to NonNull
2023-11-26 16:01:30 +00:00
Maybe Waffle
4bcdd3bd92
Add offset_from-ish convenience methods to NonNull
2023-11-26 16:01:30 +00:00
Maybe Waffle
ebdc79497f
Add offset-ish convenience methods to NonNull
2023-11-26 16:01:30 +00:00
Maybe Waffle
36a587fb62
Add read/write/copy convenience methods to NonNull
2023-11-26 15:57:01 +00:00
bors
9529a5d265
Auto merge of #110303 - nbdd0121:master, r=Mark-Simulacrum
...
Add `debug_assert_nounwind` and convert `assert_unsafe_precondition`
`assert_unsafe_precondition` checks non-CTFE-evaluable conditions in runtime and performs no-op in compile time, while many of its current usage can be checked during const eval.
2023-11-26 06:44:03 +00:00
Gary Guo
97c1502066
Convert many assert_unsafe_precondition to debug_assert_nounwind
2023-11-25 23:58:51 +00:00
Michael Goulet
fcb9fcc28c
Rollup merge of #117968 - Urgau:stabilize-ptr-addr-eq, r=dtolnay
...
Stabilize `ptr::addr_eq`
This PR stabilize the `ptr_addr_eq` library feature, representing:
```rust
// core::ptr
pub fn addr_eq<T: ?Sized, U: ?Sized>(p: *const T, q: *const U) -> bool;
```
FCP has already started [on the tracking issue](https://github.com/rust-lang/rust/issues/116324#issuecomment-1813008697 ) and is waiting on the final period comment.
Note: stabilizing this feature is somewhat of requirement for a new T-lang lint, cf. https://github.com/rust-lang/rust/pull/117758#issuecomment-1813183686 .
2023-11-25 17:23:33 -05:00
Ralf Jung
a8162673e3
also add is_empty to const raw slices
2023-11-24 08:25:01 +01:00
ltdk
114873dc19
impl more traits for ptr::Alignment, add mask method
2023-11-18 00:05:28 -05:00
Urgau
8d91d6662f
Stabilize ptr_addr_eq library feature
2023-11-16 11:35:59 +01:00