| Age | Commit message (Collapse) | Author | Lines |
|
std: Remove internal definitions of `cfg_if!` macro
This is duplicated in a few locations throughout the sysroot to work
around issues with not exporting a macro in libstd but still wanting it
available to sysroot crates to define blocks. Nowadays though we can
simply depend on the `cfg-if` crate on crates.io, allowing us to use it
from there!
|
|
Hygienize macros in the standard library
Same as https://github.com/rust-lang/rust/pull/55597, but for all macros in the standard library.
Nested macro calls will now call what they are intended to call rather than whatever is in the closest scope at call site.
Technically this is a breaking change, so crater run would probably be useful.
---
One exception that is not hygienized is calls to `panic!(...)`.
Macros defined in libcore do not want to call `core::panic`.
What they really want to call is either `std::panic` or `core::panic` depending on `no_std` settings.
EDIT: After some thought, recursive calls to `panic` from `panic` itself probably do want to use `$crate` (UPDATE: done).
Calling `std::panic` from macros defined in std and "whatever `panic` is in scope" from macros defined in libcore is probably even worse than always calling "whatever `panic` is in scope", so I kept the existing code.
The only way to do the std/core switch correctly that I'm aware of is to define a built-in panic macro that would dispatch to `std::panic` or `core::panic` using compiler magic.
Then standard library macros could delegate to this built-in macro.
The macro could be named `panic` too, that would fix https://github.com/rust-lang/rust/issues/61567.
(This PR doesn't do that.)
---
cc https://github.com/rust-lang/rust/issues/56389
cc https://github.com/rust-lang/rust/issues/61567
Fixes https://github.com/rust-lang/rust/issues/61699
r? @alexcrichton
|
|
Stabilize copy_within
Closes #54236.
|
|
Stabilize Option::xor
FCP done in https://github.com/rust-lang/rust/issues/50512#issuecomment-469527554 .
Closes #50512 .
|
|
|
|
implement nth_back for Range(Inclusive)
This is part of #54054.
|
|
Implement Clone::clone_from for Option and Result
See https://github.com/rust-lang/rust/issues/28481
|
|
Use `for_each` in `Iterator::partition`
We already use this for `unzip`, but `partition` is not much different.
|
|
core: use memcmp optimization for 128 bit integer slices
All other sized integer slices do this. From #61665.
|
|
make sure make_ascii_lowercase actually leaves upper-case non-ASCII characters alone
Cc https://github.com/rust-lang/rust/pull/61677 @napen123
|
|
We already use this for `unzip`, but `partition` is not much different.
|
|
Co-Authored-By: varkor <github@varkor.com>
|
|
This is duplicated in a few locations throughout the sysroot to work
around issues with not exporting a macro in libstd but still wanting it
available to sysroot crates to define blocks. Nowadays though we can
simply depend on the `cfg-if` crate on crates.io, allowing us to use it
from there!
|
|
|
|
get rid of real_intrinsics module
instead import intrinsics locally in their wrapper functions.
(These functions are wrapper functions as a preparation to fixing https://github.com/rust-lang/rust/issues/53871.)
|
|
alone
|
|
|
|
Miri: disable a slow test
|
|
|
|
|
|
Add examples for make_ascii_{uppercase, lowercase}
As the title says, this adds simple usage examples for make_ascii_uppercase and make_ascii_lowercase.
|
|
|
|
|
|
|
|
|
|
Because Eq types must be reflexively equal, an equal-length slice to the
same memory location must be equal.
|
|
Stabilize Cell::from_mut and as_slice_of_cells
FCP: https://github.com/rust-lang/rust/issues/43038#issuecomment-499900463
|
|
Make `i*::signum` a `const fn`.
Ticks a box in #53718.
This uses a well-known branchless implementation of `signum`: `(n > 0) as i32 - (n < 0) as i32`.
Here's a [playground](https://play.rust-lang.org/?version=nightly&mode=release&edition=2018&gist=747cf191c4974bf66c9d75e509ae6e6e) comparing the two techniques. On x86 in release mode, the branchless implementation is able to replace a `mov` and `cmov` with a `sar` and `add`, so this should be a bit faster as well.
~~This is marked as a draft since I think I'll need to add `#[rustc_const_unstable]` somewhere. Perhaps the reviewer can point me in the right direction.~~
|
|
This uses a well-known branchless implementation of `signum`.
Its `const`-ness is unstable and requires `#![feature(const_int_sign)]`.
|
|
Add std::mem::take as suggested in #61129
This PR implements #61129 by adding `std::mem::take`.
The added function is equivalent to:
```rust
std::mem::replace(dest, Default::default())
```
This particular pattern is fairly common, especially when implementing `Future::poll`, where you often need to yield an owned value in `Async::Ready`. This change allows you to write
```rust
return Async::Ready(std::mem::take(self.result));
```
instead of
```rust
return Async::Ready(std::mem::replace(self.result, Vec::new()));
```
EDIT: Changed name from `take` to `swap_default`.
EDIT: Changed name back to `take`.
|
|
libcore/pin: Minor grammar corrections for module documentation
This is by no means exhaustive, but I noticed a few grammatical errors
when reading the documentation, and decided just to push these.
Some standard rules/guidelines I followed:
* Do not split infinitives, ie "not to move" instead of "to not move"
* Do not use "since" when you want to say "because" or "as" - the word
"since" has a temporal meaning
In addition:
* Fix a small typo: "Similarily" should be "Similarly"
* Delete double-spaces after full stop
|
|
FCP: https://github.com/rust-lang/rust/issues/43038#issuecomment-499900463
|
|
This is by no means exhaustive, but I noticed a few grammatical errors
when reading the documentation, and decided just to push these.
Some standard rules/guidelines I followed:
* Do not split infinitives, ie "not to move" instead of "to not move"
* Do not use "since" when you want to say "because" or "as" - the word
"since" has a temporal meaning
In addition:
* Fix a small typo: "Similarily" should be "Similarly"
* Delete double-spaces after full stop
|
|
Use LLVM intrinsics for floating-point min/max
Resurrection of https://github.com/rust-lang/rust/pull/46926, now that the optimisation issues are fixed. I've confirmed locally that https://github.com/rust-lang/rust/pull/61384 solves the issues.
I'm not sure if we're allowed to move the `min`/`max` methods from libcore to libstd: I can't quite tell what the status is from https://github.com/rust-lang/rust/issues/50145. However, this is necessary to use the intrinsics.
Fixes https://github.com/rust-lang/rust/issues/18384.
r? @SimonSapin
cc @rkruppe @nikic
|
|
Add Bound::cloned()
Suggested by #61356
|
|
|
|
Rollup of 4 pull requests
Successful merges:
- #61556 (librustc_errors: Rename AnnotateRs -> AnnotateSnippet)
- #61557 (rustbuild: Include `rustfmt` in deduplicated dependencies)
- #61571 (Escape HashMap with backticks in needs_drop docs)
- #61582 (submodules: update clippy from 20da8f45 to 71be6f62)
Failed merges:
r? @ghost
|
|
r=Mark-Simulacrum
Escape HashMap with backticks in needs_drop docs
|
|
Utilize cfg(bootstrap) over cfg(stage0)
Also removes stage1, stage2 cfgs being passed to rustc to ensure that
stage1 and stage2 are only differentiated as a group (i.e., only through
not bootstrap).
Fixes #53582
r? @alexcrichton
|
|
Co-Authored-By: Steven Fackler <sfackler@gmail.com>
|
|
|
|
|
|
|
|
Also removes stage1, stage2 cfgs being passed to rustc to ensure that
stage1 and stage2 are only differentiated as a group (i.e., only through
not bootstrap).
|
|
|
|
|
|
|
|
instead import intrinsics locally in their wrapper functions
|
|
Co-Authored-By: Jack O'Connor <oconnor663@gmail.com>
|
|
|