| Age | Commit message (Collapse) | Author | Lines |
|
|
|
|
|
|
|
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.
|
|
Fixes error count display is different when there's only one error left
Supersedes #114759
### What did I do?
I did the small change in `rustc_errors` by hand. Then I did the other changes in `/compiler` by hand, those were just find replace on `*.rs` in the workspace. The changes in run-make are find replace for `run-make` in the workspace.
All other changes are blessed using `x test TEST --bless`. I blessed the tests that were blessed in #114759.
### how to review this nightmare
ping bors with an `r+`. You should check that my logic is sound and maybe quickly scroll through the diff, but fully verifying it seems fairly hard to impossible. I did my best to do this correctly.
Thank you `@adrianEffe` for bringing this up and your initial implementation.
cc `@flip1995,` you said you want to do a subtree sync asap
cc `@RalfJung` maybe you want to do a quick subtree sync afterwards as well for Miri
r? `@WaffleLapkin`
|
|
|
|
|
|
|
|
|
|
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
|
|
memcpy assumptions: update GCC link
GCC now has this documented on an official website, not just in the bugtracker.
|
|
Indicate that multiplication in Layout::array cannot overflow
Since https://github.com/rust-lang/rust/pull/113113, we have added a check that skips calling into the allocator at all if `capacity == 0`. The global, default allocator will not actually try to allocate though; it returns a dangling pointer explicitly. However, these two checks are not merged/deduplicated by LLVM and so we're comparing to zero twice whenever vectors are allocated/grown. Probably cheap, but also potentially expensive in code size and seems like an unfortunate miss.
This removes that extra check by telling LLVM that the multiplication as part of Layout::array can't overflow, turning the original non-zero value into a zero value afterwards. In my checks locally this successfully drops the duplicate comparisons.
See https://rust.godbolt.org/z/b6nPP9dcK for a code example.
```rust
pub fn foo(elements: usize) -> Vec<u32> {
Vec::with_capacity(elements)
}
```
r? `@scottmcm` since you touched this in a32305a80fd1409b054e97836321bd0621b142fd - curious if you have thoughts on doing this / can confirm my model of this being correct.
|
|
|
|
|
|
Rollup of 6 pull requests
Successful merges:
- #116807 (Improve rewind documentation)
- #117656 (Update windows-bindgen and define `INVALID_HANDLE_VALUE` ourselves)
- #117940 (chore: remove unnecessary drop)
- #118028 (Document behavior of `<dyn Any as Any>::type_id()`)
- #118060 (Use an absolute path to the NUL device)
- #118224 (Sort unstable items last in rustdoc, instead of first)
r? `@ghost`
`@rustbot` modify labels: rollup
|
|
|
|
|
|
Document behavior of `<dyn Any as Any>::type_id()`
See also #57893
`@rustbot` label A-docs T-libs
|
|
chore: remove unnecessary drop
No need to manually drop since it's implicit.
|
|
Refactor `binary_search_by` to use conditional moves
Refactor the if/else checking on `cmp::Ordering` variants to a "branchless" reassignment of left and right.
This change results in fewer branches and instructions.
https://rust.godbolt.org/z/698eYffTx
---
I saw consistent benchmark improvements locally. Performance of worst case seems about the same, maybe slightly faster for the L3 test.
Current
```
slice::binary_search_l1 43.00ns/iter +/- 3.00ns
slice::binary_search_l1_with_dups 25.00ns/iter +/- 0.00ns
slice::binary_search_l1_worst_case 10.00ns/iter +/- 0.00ns
slice::binary_search_l2 64.00ns/iter +/- 1.00ns
slice::binary_search_l2_with_dups 42.00ns/iter +/- 0.00ns
slice::binary_search_l2_worst_case 16.00ns/iter +/- 0.00ns
slice::binary_search_l3 132.00ns/iter +/- 2.00ns
slice::binary_search_l3_with_dups 108.00ns/iter +/- 2.00ns
slice::binary_search_l3_worst_case 33.00ns/iter +/- 3.00ns
```
This PR
```
slice::binary_search_l1 21.00ns/iter +/- 0.00ns
slice::binary_search_l1_with_dups 14.00ns/iter +/- 0.00ns
slice::binary_search_l1_worst_case 9.00ns/iter +/- 0.00ns
slice::binary_search_l2 34.00ns/iter +/- 0.00ns
slice::binary_search_l2_with_dups 23.00ns/iter +/- 0.00ns
slice::binary_search_l2_worst_case 16.00ns/iter +/- 0.00ns
slice::binary_search_l3 92.00ns/iter +/- 3.00ns
slice::binary_search_l3_with_dups 63.00ns/iter +/- 1.00ns
slice::binary_search_l3_worst_case 29.00ns/iter +/- 0.00ns
```
|
|
This allows LLVM to optimize comparisons to zero before & after the
multiplication into one, saving on code size and eliminating an (always
true) branch from most Vec allocations.
|
|
|
|
|
|
|
|
Add `Duration::abs_diff`
This adds a `Duration::abs_diff` method analogous to the existing one on the primitive integers.
ACP: https://github.com/rust-lang/libs-team/issues/291
Tracking Issue: https://github.com/rust-lang/rust/issues/117618
|
|
Remove option_payload_ptr; redundant to offset_of
The `option_payload_ptr` intrinsic is no longer required as `offset_of` supports traversing enums (#114208). This PR removes it in order to dogfood offset_of (as suggested at https://github.com/rust-lang/rust/issues/106655#issuecomment-1790907626). However, it will not build until those changes reach beta (which I think is within the next 8 days?) so I've opened it as a draft.
|
|
|
|
Expose tests for {f32,f64}.total_cmp in docs
Expose tests for {f32,f64}.total_cmp in docs
Uncomment the helpful `assert_eq!` line, which is stripped out completely in docs, and leaves the reader to mentally play through the algorithm, or go to the playground and add a println!, to see what the result will be.
(If these tests are known to fail on some platforms, is there some mechanism to conditionalize this or escape the test so the `assert_eq!` source will be visible on the web? I am a newbie, which is why I was reading docs ;)
|
|
|
|
impl more traits for ptr::Alignment, add mask method
Changes:
* Adds `rustc_const_unstable` attributes where missing
* Makes `log2` method const
* Adds `mask` method
* Implements `Default`, which is equivalent to `Alignment::MIN`
No longer included in PR:
* Removes indirection of `AlignmentEnum` type alias (this was intentional)
* Implements `Display`, `Binary`, `Octal`, `LowerHex`, and `UpperHex` (should go through libs-api instead)
* Controversially implements `LowerExp` and `UpperExp` using `p` instead of `e` to indicate a power of 2 (also should go through libs-api)
Tracking issue for `ptr::Alignment`: #102070
|
|
|
|
Reenable effects in libcore
With #116670, #117531, and #117171, I think we would be comfortable with re-enabling the effects feature for more testing in libcore.
r? `@oli-obk`
cc `@fmease`
cc #110395
|
|
See also #57893
|
|
clarify `fn discriminant` guarantees: only free lifetimes may get erased
cc https://github.com/rust-lang/rust/pull/104299/files#r1397082347
don't think this necessitates a backport by itself, but should imo be included if one were to exist.
r? types
|
|
Use `copied` instead of manual `map`
|
|
Remove asmjs
Fulfills [MCP 668](https://github.com/rust-lang/compiler-team/issues/668).
`asmjs-unknown-emscripten` does not work as-specified, and lacks essential upstream support for generating asm.js, so it should not exist at all.
|
|
feat: implement `DoubleEndedSearcher` for `CharArray[Ref]Searcher`
This PR implements `DoubleEndedSearcher` for both `CharArraySearcher` and `CharArrayRefSearcher`. I'm not sure whether this was just overlooked or if there is a reason for it, but since it behaves exactly like `CharSliceSearcher`, I think the implementations should be appropriate.
|
|
|
|
|
|
document ABI compatibility
I don't think we have any central place where we document our ABI compatibility rules, so let's create one. The `fn()` pointer type seems like a good place since ABI questions can only become relevant when invoking a function through a function pointer.
This will likely need T-lang FCP.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Custom MIR: Support cleanup blocks
Cleanup blocks are declared with `bb (cleanup) = { ... }`.
`Call` and `Drop` terminators take an additional argument describing the unwind action, which is one of the following:
* `UnwindContinue()`
* `UnwindUnreachable()`
* `UnwindTerminate(reason)`, where reason is `ReasonAbi` or `ReasonInCleanup`
* `UnwindCleanup(block)`
Also support unwind resume and unwind terminate terminators:
* `UnwindResume()`
* `UnwindTerminate(reason)`
|
|
Cleanup blocks are declared with `bb (cleanup) = { ... }`.
`Call` and `Drop` terminators take an additional argument describing the
unwind action, which is one of the following:
* `UnwindContinue()`
* `UnwindUnreachable()`
* `UnwindTerminate(reason)`, where reason is `ReasonAbi` or `ReasonInCleanup`
* `UnwindCleanup(block)`
Also support unwind resume and unwind terminate terminators:
* `UnwindResume()`
* `UnwindTerminate(reason)`
|
|
fix rounding issue with exponents in fmt
fixes issue #115737 , where the decimal places are rounded incorrectly when formatting scientific notation
|