Commit Graph

9025 Commits

Author SHA1 Message Date
Kevin Reid f44d283770 Add the syntax of references to their documentation summary.
Without this change, in <https://doc.rust-lang.org/1.63.0/std/#primitives>,
`reference` is the only entry in that list which does not contain the
syntax by which the type is named in source code. With this change, it
contains them, in roughly the same way as the `pointer` entry does.
2022-08-26 10:47:03 -07:00
marmeladema 8bb4b5f44c Support parsing IP addresses from a byte string 2022-08-26 14:16:53 +02:00
Guillaume Gomez 7881e0576b
Rollup merge of #100128 - kpreid:waker-doc, r=thomcc
Document that `RawWakerVTable` functions must be thread-safe.

Also add some intra-doc links and more high-level explanation of how `Waker` is used, while I'm here.

Context: https://internals.rust-lang.org/t/thread-safety-of-rawwakervtables/17126
2022-08-26 14:08:45 +02:00
Guillaume Gomez ae838f7645
Rollup merge of #99742 - sigaloid:master, r=thomcc
Add comments about stdout locking

This is the source of some confusion regarding the `println!` macro:
* https://llogiq.github.io/2017/06/01/perf-pitfalls.html#unbuffered-io
* https://news.ycombinator.com/item?id=18794930
* https://reddit.com/r/rust/comments/5puyx2/why_is_println_so_slow/dcua5g5/
* https://reddit.com/r/rust/comments/ab7hsi/comparing_pythagorean_triples_in_c_d_and_rust/ecy7ql8/

In some of these cases it's not the locking behavior where the bottleneck lies, but it's still mentioned as a surprise when, eg, benchmarking a million `println!`'s in a very tight loop.

If there's any stylistic problems please feel free to correct me! This is my first contribution and I want to get it right 🦀
2022-08-26 14:08:44 +02:00
Guillaume Gomez e3148dc7c4
Rollup merge of #95005 - ssomers:btree_static_assert, r=thomcc
BTree: evaluate static type-related check at compile time

`assert`s like the ones replaced here would only go off when you run the right test cases, if the code were ever incorrectly changed such that rhey would trigger. But [inspired on a nice forum question](https://users.rust-lang.org/t/compile-time-const-generic-parameter-check/69202), they can be checked at compile time.
2022-08-26 14:08:43 +02:00
bors 13a6aaffdf Auto merge of #101017 - JohnTitor:rollup-73f2fhb, r=JohnTitor
Rollup of 8 pull requests

Successful merges:

 - #99064 (distinguish the method and associated function diagnostic information)
 - #99920 (Custom allocator support in `rustc_serialize`)
 - #100034 ( Elaborate all box dereferences in `ElaborateBoxDerefs`)
 - #100076 (make slice::{split_at,split_at_unchecked} const functions)
 - #100604 (Remove unstable Result::into_ok_or_err)
 - #100933 (Reduce code size of `assert_matches_failed`)
 - #100978 (Handle `Err` in `ast::LitKind::to_token_lit`.)
 - #101010 (rustdoc: remove unused CSS for `.multi-column`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-08-26 03:23:54 +00:00
Yuki Okushi 684955591c
Rollup merge of #100933 - a1phyr:cheap_assert_match_failed, r=JoshTriplett
Reduce code size of `assert_matches_failed`

Using `write_str` instead of `<str as Display>::fmt` avoids the `pad` function which is very expensive to have in size-constrained code.
2022-08-26 09:51:45 +09:00
Yuki Okushi ba31a9b505
Rollup merge of #100604 - dtolnay:okorerr, r=m-ou-se
Remove unstable Result::into_ok_or_err

Pending FCP: https://github.com/rust-lang/rust/issues/82223#issuecomment-1214920203

```@rustbot``` label +waiting-on-fcp
2022-08-26 09:51:44 +09:00
Yuki Okushi e193f4697f
Rollup merge of #100076 - tspiteri:const_slice_split_at, r=oli-obk
make slice::{split_at,split_at_unchecked} const functions

Now that `slice::from_raw_parts` is const in stable 1.64, it makes sense to have `split_at` const as well, otherwise unsafe code is required to achieve a const equivalent.
2022-08-26 09:51:43 +09:00
bors 76f3b891a0 Auto merge of #99487 - bmacnaughton:is_whitespace_updates, r=thomcc
is_whitespace() performance improvements

This is my first rust PR, so if I miss anything obvious please let me know and I'll do my best to fix it.

This was a bit more of a challenge than I realized because, while I made working code locally and tested it against the native `is_whitespace()`, this PR required changing `src/tools/unicode-table-generator`, the code that generated the code.

I have benchmarked this locally, using criterion, and have seen meaningful performance improvements. I can add those outputs to this if you'd like, but am guessing that the perf run that `@fmease` recommended is what's needed.

I have run ` ./x.py test --stage 0 library/std` after building it locally after executing `./x.py build library`. I didn't try to build the whole compiler, but maybe I should have - any guidance would be appreciated.

If this general approach makes sense, I'll take a look at some other candidate categories, e.g., `Cc`, in the future.

Oh, and I wasn't sure whether the generated code should be included in this PR or not. I did include it.
2022-08-26 00:42:40 +00:00
BlackHoleFox 3fc35b5b93 Use getentropy when possible on all Apple platforms 2022-08-25 15:55:04 -05:00
bors 7480389611 Auto merge of #100911 - tmiasko:update-stdarch, r=Amanieu
Update stdarch submodule

Changes from stdarch:

* Fix links in documentation of cmpxchg16b
* Use load intrinsic and loop for intrinsic-test programs. Add --release flag back to intrinsic-test programs.
* Properly fix vext intrinsic tests
* Replace some calls to `pointer::offset` with `add` and `sub`
* Allow internal use of stdsimd from detect_feature
* fix target name in contributing.md
* Tweak constant for ARM vext instruction tests
* Use `llvm.ppc.altivec.lvx` intrinsic for `vec_ld`
*  Adding doc links for arm neon intrinsics
* Adding doc links for arm crypto and aes intrinsics
* Remove instruction tests for `__mmask*` intrinsics
* Update ubuntu 21.10 docker containers to 22.04
* Adding documentation links for arm crc32 intrinsics
* Remove restrictions on compare-exchange memory ordering.
* Fix a typo in the document.
* Allow mapping a runtime feature to a set of target_features
* Update atomic intrinsics
* Fully qualify recursive macro calls
* Ensure the neon vector aggregates like `float32x4x4_t` are `#[repr(C)]`
* Remove useless conditional compilation
* Fix ARM vbsl* NEON intrinsics

r? `@Amanieu`
2022-08-25 18:17:42 +00:00
Trevor Spiteri bc3d7199e1 review 2022-08-25 12:54:30 +02:00
Nick Cameron 9372c4f6ac error::Error: remove some comments
Signed-off-by: Nick Cameron <nrc@ncameron.org>
2022-08-25 07:42:07 +01:00
Deadbeef 69ad634808 Do not include `const_ptr_sub_ptr` in this stabilization 2022-08-25 06:03:28 +00:00
Deadbeef ad93272627 Stabilize `const_ptr_offset_from`.
Stabilization has been completed [here](https://github.com/rust-lang/rust/issues/92980#issuecomment-1065644848)
with a FCP.
2022-08-25 06:03:28 +00:00
Yuki Okushi df354f5cf6
Rollup merge of #100921 - ChayimFriedman2:and-eager-eval, r=JohnTitor
Add a warning about `Option/Result::and()` being eagerly evaluated

Copied from `or()`.

Inspired by [this StackOverflow question](https://stackoverflow.com/questions/73461846/why-is-in-rust-the-expression-in-option-and-evaluated-if-option-is-none).

[The PR for `or()`](https://github.com/rust-lang/rust/pull/46548) mentions the Clippy lint `or_fun_call` which doesn't exist for `and()` (although there is `unnecessary_lazy_evaluations`). I still think this warning is also good for `and()`. Feel free to close if you disagree.
2022-08-25 08:50:59 +09:00
Yuki Okushi f4550a6edf
Rollup merge of #99332 - jyn514:stabilize-label-break-value, r=petrochenkov
Stabilize `#![feature(label_break_value)]`

See the stabilization report in https://github.com/rust-lang/rust/issues/48594#issuecomment-1186213313.
2022-08-25 08:50:54 +09:00
Josh Triplett ae937cc347 Clarify comment to fit `as _` better 2022-08-25 00:22:40 +02:00
Matthias Krüger fe1f1f1282
Rollup merge of #100922 - GuillaumeGomez:rewrite-error-index, r=notriddle
Rewrite error index generator to greatly reduce the size of the pages

Fixes https://github.com/rust-lang/rust/issues/100736.

Instead of having all error codes in a same page (making the DOM way too big), I split the output into multiple files and generated a list of links (if there is an explanation) to the error codes' explanation into the already existing file.

I also used this opportunity to greatly simplify the code. Instead of needing a `build.rs`, I simply imported the file we want and wrote the macro which generates a function containing everything we need. We just need to call it to get the error codes and their explanation (if any). Also, considering the implementations between markdown and HTML formats differed even further, the `Formatter` trait was becoming too problematic so I removed it too.

You can test it [here](https://rustdoc.crud.net/imperio/rewrite-error-index/error-index.html).

cc ``@jsha``
r? ``@notriddle``
2022-08-24 18:20:16 +02:00
Matthias Krüger e802df9e8b
Rollup merge of #100855 - IsaacCloos:master, r=joshtriplett
Extra documentation for new formatting feature

Documentation of this feature was added in #90473 and released in Rust 1.58. However, high traffic macros did not receive new examples. Namely `println!()` and `format!()`.

The doc comments included in Rust are super important to the community- especially newcomers. I have met several other newbies like myself who are unaware of this recent (well about 7 months old now) update to the language allowing for convenient intra-string identifiers.

Bringing small examples of this feature to the doc comments of `println!()` and `format!()` would be helpful to everyone learning the language.

[Blog Post Announcing Feature](https://blog.rust-lang.org/2022/01/13/Rust-1.58.0.html)
[Feature PR](https://github.com/rust-lang/rust/pull/90473) - includes several instances of documentation of the feature- minus the macros in question for this PR

*This is my first time contributing to a project this large. Feedback would mean the world to me 😄*

---

*Recreated; I violated the [No-Merge Policy](https://rustc-dev-guide.rust-lang.org/git.html#no-merge-policy)*
2022-08-24 18:20:10 +02:00
Matthias Krüger 6deca5f067
Rollup merge of #100220 - scottmcm:fix-by-ref-sized, r=joshtriplett
Properly forward `ByRefSized::fold` to the inner iterator

cc ``@timvermeulen,`` who noticed this mistake in https://github.com/rust-lang/rust/pull/100214#issuecomment-1207317625
2022-08-24 18:20:08 +02:00
Nick Cameron b556a5be5a error::Error: rename the Demand arguments from req to demand
Signed-off-by: Nick Cameron <nrc@ncameron.org>
2022-08-24 15:35:51 +01:00
Nick Cameron 80442f375a error::Error: rename the chain method to sources
Signed-off-by: Nick Cameron <nrc@ncameron.org>
2022-08-24 15:35:51 +01:00
Josh Triplett 589db1f73a Expand example to show how to implement qualified trait names 2022-08-24 15:38:21 +02:00
Josh Triplett 3c8618fd82 Update `write!` docs: can now import traits as `_` to avoid conflicts 2022-08-24 14:42:25 +02:00
Josh Triplett a7886506ad Remove some documentation duplicated between `writeln!` and `write!`
`writeln!` already includes a reference to `write!` for more
information, so remove duplicated information.
2022-08-24 14:41:22 +02:00
Joshua Nelson 31e39446ec Stabilize `#![feature(label_break_value)]`
# Stabilization proposal

The feature was implemented in https://github.com/rust-lang/rust/pull/50045 by est31 and has been in nightly since 2018-05-16 (over 4 years now).
There are [no open issues][issue-label] other than the tracking issue. There is a strong consensus that `break` is the right keyword and we should not use `return`.

There have been several concerns raised about this feature on the tracking issue (other than the one about tests, which has been fixed, and an interaction with try blocks, which has been fixed).
1. nrc's original comment about cost-benefit analysis: https://github.com/rust-lang/rust/issues/48594#issuecomment-422235234
2. joshtriplett's comments about seeing use cases: https://github.com/rust-lang/rust/issues/48594#issuecomment-422281176
3. withoutboats's comments that Rust does not need more control flow constructs: https://github.com/rust-lang/rust/issues/48594#issuecomment-450050630

Many different examples of code that's simpler using this feature have been provided:
- A lexer by rpjohnst which must repeat code without label-break-value: https://github.com/rust-lang/rust/issues/48594#issuecomment-422502014
- A snippet by SergioBenitez which avoids using a new function and adding several new return points to a function: https://github.com/rust-lang/rust/issues/48594#issuecomment-427628251. This particular case would also work if `try` blocks were stabilized (at the cost of making the code harder to optimize).
- Several examples by JohnBSmith: https://github.com/rust-lang/rust/issues/48594#issuecomment-434651395
- Several examples by Centril: https://github.com/rust-lang/rust/issues/48594#issuecomment-440154733
- An example by petrochenkov where this is used in the compiler itself to avoid duplicating error checking code: https://github.com/rust-lang/rust/issues/48594#issuecomment-443557569
- Amanieu recently provided another example related to complex conditions, where try blocks would not have helped: https://github.com/rust-lang/rust/issues/48594#issuecomment-1184213006

Additionally, petrochenkov notes that this is strictly more powerful than labelled loops due to macros which accidentally exit a loop instead of being consumed by the macro matchers: https://github.com/rust-lang/rust/issues/48594#issuecomment-450246249

nrc later resolved their concern, mostly because of the aforementioned macro problems.
joshtriplett suggested that macros could be able to generate IR directly
(https://github.com/rust-lang/rust/issues/48594#issuecomment-451685983) but there are no open RFCs,
and the design space seems rather speculative.

joshtriplett later resolved his concerns, due to a symmetry between this feature and existing labelled break: https://github.com/rust-lang/rust/issues/48594#issuecomment-632960804

withoutboats has regrettably left the language team.

joshtriplett later posted that the lang team would consider starting an FCP given a stabilization report: https://github.com/rust-lang/rust/issues/48594#issuecomment-1111269353

[issue-label]: https://github.com/rust-lang/rust/issues?q=is%3Aissue+is%3Aopen+label%3AF-label_break_value+

 ## Report

+ Feature gate:
    - d695a497bb/src/test/ui/feature-gates/feature-gate-label_break_value.rs
+ Diagnostics:
    - 6b2d3d5f3c/compiler/rustc_parse/src/parser/diagnostics.rs (L2629)
    - f65bf0b2bb/compiler/rustc_resolve/src/diagnostics.rs (L749)
    - f65bf0b2bb/compiler/rustc_resolve/src/diagnostics.rs (L1001)
    - 111df9e6ed/compiler/rustc_passes/src/loops.rs (L254)
    - d695a497bb/compiler/rustc_parse/src/parser/expr.rs (L2079)
    - d695a497bb/compiler/rustc_parse/src/parser/expr.rs (L1569)
+ Tests:
    - https://github.com/rust-lang/rust/blob/master/src/test/ui/label/label_break_value_continue.rs
    - https://github.com/rust-lang/rust/blob/master/src/test/ui/label/label_break_value_unlabeled_break.rs
    - https://github.com/rust-lang/rust/blob/master/src/test/ui/label/label_break_value_illegal_uses.rs
    - https://github.com/rust-lang/rust/blob/master/src/test/ui/lint/unused_labels.rs
    - https://github.com/rust-lang/rust/blob/master/src/test/ui/run-pass/for-loop-while/label_break_value.rs

 ## Interactions with other features

Labels follow the hygiene of local variables.

label-break-value is permitted within `try` blocks:
```rust
let _: Result<(), ()> = try {
    'foo: {
        Err(())?;
        break 'foo;
    }
};
```

label-break-value is disallowed within closures, generators, and async blocks:
```rust
'a: {
    || break 'a
    //~^ ERROR use of unreachable label `'a`
    //~| ERROR `break` inside of a closure
}
```

label-break-value is disallowed on [_BlockExpression_]; it can only occur as a [_LoopExpression_]:
```rust
fn labeled_match() {
    match false 'b: { //~ ERROR block label not supported here
        _ => {}
    }
}

macro_rules! m {
    ($b:block) => {
        'lab: $b; //~ ERROR cannot use a `block` macro fragment here
        unsafe $b; //~ ERROR cannot use a `block` macro fragment here
        |x: u8| -> () $b; //~ ERROR cannot use a `block` macro fragment here
    }
}

fn foo() {
    m!({});
}
```

[_BlockExpression_]: https://doc.rust-lang.org/nightly/reference/expressions/block-expr.html
[_LoopExpression_]: https://doc.rust-lang.org/nightly/reference/expressions/loop-expr.html
2022-08-23 21:14:12 -05:00
bors 25ea5a36c6 Auto merge of #96869 - sunfishcode:main, r=joshtriplett
Optimize `Wtf8Buf::into_string` for the case where it contains UTF-8.

Add a `is_known_utf8` flag to `Wtf8Buf`, which tracks whether the
string is known to contain UTF-8. This is efficiently computed in many
common situations, such as when a `Wtf8Buf` is constructed from a `String`
or `&str`, or with `Wtf8Buf::from_wide` which is already doing UTF-16
decoding and already checking for surrogates.

This makes `OsString::into_string` O(1) rather than O(N) on Windows in
common cases.

And, it eliminates the need to scan through the string for surrogates in
`Args::next` and `Vars::next`, because the strings are already being
translated with `Wtf8Buf::from_wide`.

Many things on Windows construct `OsString`s with `Wtf8Buf::from_wide`,
such as `DirEntry::file_name` and `fs::read_link`, so with this patch,
users of those functions can subsequently call `.into_string()` without
paying for an extra scan through the string for surrogates.

r? `@ghost`
2022-08-24 01:17:52 +00:00
Benoît du Garreau 3aa6fe376d Remove a packing branch from `fmt::builders::PadAdapter` 2022-08-24 01:21:40 +02:00
Benoît du Garreau 289d7cca1d Reduce code size of `assert_matches_failed` 2022-08-24 00:56:04 +02:00
bors 060e47f74a Auto merge of #99917 - yaahc:error-in-core-move, r=thomcc
Move Error trait into core

This PR moves the error trait from the standard library into a new unstable `error` module within the core library. The goal of this PR is to help unify error reporting across the std and no_std ecosystems, as well as open the door to integrating the error trait into the panic reporting system when reporting panics whose source is an errors (such as via `expect`).

This PR is a rewrite of https://github.com/rust-lang/rust/pull/90328 using new compiler features that have been added to support error in core.
2022-08-23 19:48:55 +00:00
Guillaume Gomez 4398d9229a Fix links to error codes 2022-08-23 21:47:31 +02:00
Chayim Refael Friedman eb2fdd917e Add a warning about `Option/Result::and()` being eagerly evaluated
Copied from `or()`.
2022-08-23 16:15:09 +00:00
Maybe Waffle 53565b23ac Make use of `[wrapping_]byte_{add,sub}`
...replacing `.cast().wrapping_offset().cast()` & similar code.
2022-08-23 19:32:37 +04:00
Dylan DPC a163659b1b
Rollup merge of #100835 - devnexen:listener_followups, r=devnexen
net listen backlog update, follow-up from #97963.

FreeBSD and using system limit instead for others.
2022-08-23 20:40:05 +05:30
Jake Goulding 260ec93478 Add `Provider::{would_be_satisfied_by_value_of,would_be_satisfied_by_ref_of}`
While the `provide_*` methods already short-circuit when a value has
been provided, there are times where an expensive computation is
needed to determine if the `provide_*` method can even be called.
2022-08-23 10:48:59 -04:00
Tomasz Miąsko 5f4d23dd14 Remove aliases for old atomic intrinsics names 2022-08-23 16:24:59 +02:00
Tomasz Miąsko f5db0c7110 Use renamed atomic intrinsics in panic_unwind 2022-08-23 16:24:59 +02:00
Tomasz Miąsko 3bc5e322cf Update stdarch submodule 2022-08-23 16:24:59 +02:00
Jake Goulding 38de102cff Support eager and lazy methods for providing references and values
There are times where computing a value may be cheap, or where
computing a reference may be expensive, so this fills out the
possibilities.
2022-08-23 09:58:50 -04:00
Amanieu d'Antras a54ddd494f Update comment about personalities in panic_abort 2022-08-23 16:12:58 +08:00
Amanieu d'Antras c110329f25 Remove custom frame info registration on i686-pc-windows-gnu
The indirection is no longer needed since we always link to libgcc
even when the panic_abort runtime is used. Instead we can just call
the libgcc functions directly.
2022-08-23 16:12:58 +08:00
Amanieu d'Antras 5ff0876694 Move personality functions to std
These were previously in the panic_unwind crate with dummy stubs in the
panic_abort crate. However it turns out that this is insufficient: we
still need a proper personality function even with -C panic=abort to
handle the following cases:

1) `extern "C-unwind"` still needs to catch foreign exceptions with -C
panic=abort to turn them into aborts. This requires landing pads and a
personality function.

2) ARM EHABI uses the personality function when creating backtraces.
The dummy personality function in panic_abort was causing backtrace
generation to get stuck in a loop since the personality function is
responsible for advancing the unwind state to the next frame.
2022-08-23 16:12:58 +08:00
bors 1cff564203 Auto merge of #100782 - thomcc:fix-android-sigaddset, r=Mark-Simulacrum
Align android `sigaddset` impl with the reference impl from Bionic

In https://github.com/rust-lang/rust/pull/100737 I noticed we were treating the sigset_t as an array of bytes, while referencing code from android (ad8dcd6023/libc/include/android/legacy_signal_inlines.h) which treats it as an array of unsigned long.

That said, the behavior difference is so subtle here that it's not hard to see why nobody noticed. This fixes the implementation to be equivalent to the one in bionic.
2022-08-23 08:09:19 +00:00
Amanieu d'Antras db94dbc597 Fix comment on the SEH personality function 2022-08-23 11:14:40 +08:00
Thiago Trannin 3d2b61c1af Remove out-of-context comment in `mem::MaybeUninit` documentation 2022-08-22 20:03:53 -03:00
Dan Gohman 2efe6b0d3d Add `AsFd` implementations for stdio types on WASI.
This mirrors the implementations on Unix platforms, and also mirrors the
existing `AsRawFd` impls.
2022-08-22 15:46:41 -07:00
Jane Losare-Lusby bf7611d55e Move error trait into core 2022-08-22 13:28:25 -07:00
Jack Wrenn f46fffc276 safe transmute: use `Assume` struct to provide analysis options
This was left as a TODO in #92268, and brings the trait more in
line with what was defined in MCP411.

`Assume::visibility` has been renamed to `Assume::safety`, as
library safety is what's actually being assumed; visibility is
just the mechanism by which it is currently checked (this may
change).

ref: https://github.com/rust-lang/compiler-team/issues/411
ref: https://github.com/rust-lang/rust/issues/99571
2022-08-22 18:37:54 +00:00
Mohsen Zohrevandi 85b3df2630 Export Cancel from std::os::fortanix_sgx::usercalls::raw
This was missed in https://github.com/rust-lang/rust/pull/100642
2022-08-22 08:54:50 -07:00
David CARLIER 15c8e55601 net listen backlog update, follow-up from #97963.
FreeBSD and using system limit instead for others.
2022-08-22 16:27:37 +01:00
Dylan DPC 4ed8fa4759
Rollup merge of #100872 - JanBeh:PR_vec_default_alloc_doc, r=fee1-dead
Add guarantee that Vec::default() does not alloc

Currently `Vec::new()` is guaranteed to not allocate until elements are pushed onto the `Vec`, but such a guarantee is missing for `Vec`'s implementation of `Default::default`.

This adds such a guarantee for `Vec::default()` to the API reference.

See also [this discussion on URLO](https://users.rust-lang.org/t/guarantee-that-vec-default-does-not-allocate/79903).
2022-08-22 20:34:16 +05:30
Dylan DPC 58d23737a6
Rollup merge of #100820 - WaffleLapkin:use_ptr_is_aligned_methods, r=scottmcm
Use pointer `is_aligned*` methods

This PR replaces some manual alignment checks with calls to `pointer::{is_aligned, is_aligned_to}` and removes a useless pointer cast.

r? `@scottmcm`

_split off from #100746_
2022-08-22 20:34:15 +05:30
Dylan DPC 382ba73062
Rollup merge of #100331 - lo48576:try-reserve-preserve-on-failure, r=thomcc
Guarantee `try_reserve` preserves the contents on error

Update doc comments to make the guarantee explicit. However, some
implementations does not have the statement though.

* `HashMap`, `HashSet`: require guarantees on hashbrown side.
* `PathBuf`: simply redirecting to `OsString`.

Fixes #99606.
2022-08-22 20:34:12 +05:30
Dylan DPC c1a5ec7faf
Rollup merge of #99957 - chotchki:ip-globally-reachable_rebase, r=Mark-Simulacrum
Rework Ipv6Addr::is_global to check for global reachability rather than global scope - rebase

Rebasing of pull request #86634 off of master to try and get the feature "ip" stabilized.

I also found a test failure in the rebase that is_global was considering the benchmark space to be globally reachable.

This is related to my other rebasing pull request #99947
2022-08-22 20:34:10 +05:30
Ralf Jung d13699d0be update and extend some comments, and cfg-out some unused code 2022-08-22 09:14:33 -04:00
Ralf Jung 138375a74c std: use realstd fast key when building tests 2022-08-22 09:14:33 -04:00
Jan Behrens 0227b71865 Add guarantee that Vec::default() does not alloc
Currently `Vec::new()` is guaranteed to not allocate until elements are
pushed onto the `Vec`, but such a guarantee is missing for `Vec`'s
implementation of `Default::default`. This adds such a guarantee for
`Vec::default()` to the API reference.
2022-08-22 12:36:44 +02:00
Dylan DPC 33b5ce6433
Rollup merge of #99386 - AngelicosPhosphoros:add_retain_test_maybeuninit, r=JohnTitor
Add tests that check `Vec::retain` predicate execution order.

This behaviour is documented for `Vec::retain` which means that there is code that rely on that but there weren't tests about that.
2022-08-22 11:45:41 +05:30
Dylan DPC a4950ef7eb
Rollup merge of #93162 - camsteffen:std-prim-docs, r=Mark-Simulacrum
Std module docs improvements

My primary goal is to create a cleaner separation between primitive types and primitive type helper modules (fixes #92777). I also changed a few header lines in other top-level std modules (seen at https://doc.rust-lang.org/std/) for consistency.

Some conventions used/established:

 * "The \`Box\<T>` type for heap allocation." - if a module mainly provides a single type, name it and summarize its purpose in the module header
 * "Utilities for the _ primitive type." - this wording is used for the header of helper modules
 * Documentation for primitive types themselves are removed from helper modules
 * provided-by-core functionality of primitive types is documented in the primitive type instead of the helper module (such as the "Iteration" section in the slice docs)

I wonder if some content in `std::ptr` should be in `pointer` but I did not address this.
2022-08-22 11:45:40 +05:30
Isaac Cloos acca4b8f86 Extra documentation for new formatting feature
High traffic macros should detail this helpful addition.
2022-08-21 15:28:27 -04:00
Matthias Krüger 5e761f3f03
Rollup merge of #100839 - nelsonjchen:consistent_child_stdin_field_desc, r=thomcc
Make doc for stdin field of process consistent

The other fields use this format and example.
2022-08-21 16:54:08 +02:00
Matthias Krüger a45f69f27d
Rollup merge of #100822 - WaffleLapkin:no_offset_question_mark, r=scottmcm
Replace most uses of `pointer::offset` with `add` and `sub`

As PR title says, it replaces `pointer::offset` in compiler and standard library with `pointer::add` and `pointer::sub`. This generally makes code cleaner, easier to grasp and removes (or, well, hides) integer casts.

This is generally trivially correct, `.offset(-constant)` is just `.sub(constant)`, `.offset(usized as isize)` is just `.add(usized)`, etc. However in some cases we need to be careful with signs of things.

r? ````@scottmcm````

_split off from #100746_
2022-08-21 16:54:07 +02:00
Matthias Krüger fd403f5d17
Rollup merge of #100821 - WaffleLapkin:ptr_add_docs, r=scottmcm
Make some docs nicer wrt pointer offsets

This PR replaces `pointer::offset` with `pointer::add` and similarly `.cast().wrapping_add().cast()` with `.wrapping_byte_add()` **in docs**.

r? ``````@scottmcm``````

_split off from #100746_
2022-08-21 16:54:06 +02:00
Matthias Krüger 1cdcf508bb
Rollup merge of #100663 - clarfonthey:const-reverse, r=scottmcm
Make slice::reverse const

I remember this not being doable for some reason before, but decided to try it again and everything worked out in the tests.
2022-08-21 16:54:01 +02:00
Matthias Krüger a5c16a5381
Rollup merge of #100556 - Alex-Velez:patch-1, r=scottmcm
Clamp Function for f32 and f64

I thought the clamp function could use a little improvement for readability purposes. The function now returns early in order to skip the extra bound checks.

If there was a reason for binding `self` to `x` or if this code is incorrect, please correct me :)
2022-08-21 16:54:01 +02:00
Maybe Waffle efef211876 Make use of `pointer::is_aligned[_to]` 2022-08-21 15:46:03 +04:00
Nelson Chen 7abbfa8c41 Make doc for stdin field of process consistent
The other fields use this format and example.
2022-08-21 01:56:26 -07:00
Thom Chiovoloni 4ecf87619c
Fix redundant comparison 2022-08-21 01:08:33 -07:00
Maybe Waffle b2625e24b9 fix nitpicks from review 2022-08-21 06:36:11 +04:00
Maybe Waffle 168a837975 fill in tracking issue for `feature(ptr_mask)` 2022-08-21 05:27:14 +04:00
Maybe Waffle 10270f4b44 Add pointer masking convenience functions
This commit adds the following functions all of which have a signature
`pointer, usize -> pointer`:
- `<*mut T>::mask`
- `<*const T>::mask`
- `intrinsics::ptr_mask`

These functions are equivalent to `.map_addr(|a| a & mask)` but they
utilize `llvm.ptrmask` llvm intrinsic.

*masks your pointers*
2022-08-21 05:27:14 +04:00
Maybe Waffle 3ba393465f Make some docs nicer wrt pointer offsets 2022-08-21 02:22:20 +04:00
Maybe Waffle e4720e1cf2 Replace most uses of `pointer::offset` with `add` and `sub` 2022-08-21 02:21:41 +04:00
Cameron Steffen 17ddcb434b Improve primitive/std docs separation and headers 2022-08-20 16:50:29 -05:00
Maybe Waffle ed084ba292 Remove useless pointer cast 2022-08-21 01:32:40 +04:00
bors 878aef79dc Auto merge of #100810 - matthiaskrgr:rollup-xep778s, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #97963 (net listen backlog set to negative on Linux.)
 - #99935 (Reenable disabled early syntax gates as future-incompatibility lints)
 - #100129 (add miri-test-libstd support to libstd)
 - #100500 (Ban references to `Self` in trait object substs for projection predicates too.)
 - #100636 (Revert "Revert "Allow dynamic linking for iOS/tvOS targets."")
 - #100718 ([rustdoc] Fix item info display)
 - #100769 (Suggest adding a reference to a trait assoc item)
 - #100777 (elaborate how revisions work with FileCheck stuff in src/test/codegen)
 - #100796 (Refactor: remove unnecessary string searchings)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-08-20 20:08:26 +00:00
Matthias Krüger e93edf3335
Rollup merge of #100129 - RalfJung:miri-test-libstd, r=thomcc
add miri-test-libstd support to libstd

- The first commit mirrors what we already have in liballoc.
- The second commit adds some regression tests that only really make sense to be run in Miri, since they rely on Miri's extra checks to detect anything.
- The third commit makes the MPSC tests work in reasonable time in Miri by reducing iteration counts.
- The fourth commit silences some warnings due to code being disabled with `cfg(miri)`
2022-08-20 19:45:11 +02:00
Matthias Krüger d9789b6903
Rollup merge of #97963 - devnexen:net_listener_neg, r=the8472
net listen backlog set to negative on Linux.

it will be 4076 (from 5.4) or 128.
2022-08-20 19:45:09 +02:00
Matthias Krüger 77db317eed
Rollup merge of #100710 - ChrisDenton:load-library, r=thomcc
Windows: Load synch functions together

Attempt to load all the required sync functions and fail if any one of them fails.

This fixes a FIXME by going back to optional loading of `WakeByAddressSingle`.

Also reintroduces a macro for optional loading of functions but keeps it separate from the fallback macro rather than having that do two different jobs.

r? `@thomcc`
2022-08-20 19:32:13 +02:00
Matthias Krüger c4fa35bb41
Rollup merge of #100642 - mzohreva:mz/update-sgx-abi-cancel-queue, r=Mark-Simulacrum
Update fortanix-sgx-abi and export some useful SGX usercall traits

Update `fortanix-sgx-abi` to 0.5.0 to add support for cancel queue (see https://github.com/fortanix/rust-sgx/pull/405 and https://github.com/fortanix/rust-sgx/pull/404).

Export some useful traits for processing SGX usercall. This is needed for https://github.com/fortanix/rust-sgx/pull/404 to avoid duplication.

cc `@raoulstrackx` and `@jethrogb`
2022-08-20 19:32:10 +02:00
Matthias Krüger bd4a63cda2
Rollup merge of #100585 - wooorm:patch-1, r=Mark-Simulacrum
Fix trailing space showing up in example

The current text is rendered as: U+005B ..= U+0060 ``[ \ ] ^ _ ` ``, or (**note the final space!**)
This patch changes that to render as: U+005B ..= U+0060 `` [ \ ] ^ _ ` ``, or (**note no final space!**)

The reason for that, is that CommonMark has a solution for starting or ending inline code with a backtick/grave accent: padding both sides with a space, makes that padding disappear.
2022-08-20 19:32:08 +02:00
Matthias Krüger d49906519b
Rollup merge of #99544 - dylni:expose-utf8lossy, r=Mark-Simulacrum
Expose `Utf8Lossy` as `Utf8Chunks`

This PR changes the feature for `Utf8Lossy` from `str_internals` to `utf8_lossy` and improves the API. This is done to eventually expose the API as stable.

Proposal: rust-lang/libs-team#54
Tracking Issue: #99543
2022-08-20 19:32:07 +02:00
dylni e8ee0b7b2b Expose `Utf8Lossy` as `Utf8Chunks` 2022-08-20 12:49:20 -04:00
Matthias Krüger 1e47e8a9ee
Rollup merge of #100729 - thomcc:less-initialized, r=ChrisDenton
Avoid zeroing a 1kb stack buffer on every call to `std::sys::windows::fill_utf16_buf`

I've also tried to be slightly more careful about integer overflows, although in practice this is likely still not handled ideally.

r? `@ChrisDenton`
2022-08-20 07:09:04 +02:00
Matthias Krüger 368f08a65f
Rollup merge of #100383 - fortanix:raoul/aepic_leak_mitigation, r=cuviper
Mitigate stale data reads on SGX platform

Intel disclosed the Stale Data Read vulnerability yesterday. In order to mitigate this issue completely, reading userspace from an SGX enclave must be aligned and in 8-bytes chunks. This PR implements this mitigation

References:
 - https://www.intel.com/content/www/us/en/security-center/advisory/intel-sa-00657.html
 - https://www.intel.com/content/www/us/en/developer/articles/technical/software-security-guidance/advisory-guidance/stale-data-read-from-xapic.html

cc: ``@jethrogb``
2022-08-20 07:08:58 +02:00
Chris Denton 625e7e9579
Use const instead of static 2022-08-20 04:15:47 +01:00
Chris Denton efd305e0ec
Simplify load/store 2022-08-20 04:15:46 +01:00
ltdk ae2b1dbc89 Tracking issue for const_reverse 2022-08-19 20:38:32 -04:00
Thom Chiovoloni f506656876
Align android `sigaddset` impl with the reference impl from Bionic 2022-08-19 16:02:48 -07:00
Thom Chiovoloni d4cba61099
Fix comment typo 2022-08-19 08:45:21 -07:00
bors 6c943bad02 Auto merge of #99541 - timvermeulen:flatten_cleanup, r=the8472
Refactor iteration logic in the `Flatten` and `FlatMap` iterators

The `Flatten` and `FlatMap` iterators both delegate to `FlattenCompat`:
```rust
struct FlattenCompat<I, U> {
    iter: Fuse<I>,
    frontiter: Option<U>,
    backiter: Option<U>,
}
```
Every individual iterator method that `FlattenCompat` implements needs to carefully manage this state, checking whether the `frontiter` and `backiter` are present, and storing the current iterator appropriately if iteration is aborted. This has led to methods such as `next`, `advance_by`, and `try_fold` all having similar code for managing the iterator's state.

I have extracted this common logic of iterating the inner iterators with the option to exit early into a `iter_try_fold` method:
```rust
impl<I, U> FlattenCompat<I, U>
where
    I: Iterator<Item: IntoIterator<IntoIter = U>>,
{
    fn iter_try_fold<Acc, Fold, R>(&mut self, acc: Acc, fold: Fold) -> R
    where
        Fold: FnMut(Acc, &mut U) -> R,
        R: Try<Output = Acc>,
    { ... }
}
```
It passes each of the inner iterators to the given function as long as it keep succeeding. It takes care of managing `FlattenCompat`'s state, so that the actual `Iterator` methods don't need to. The resulting code that makes use of this abstraction is much more straightforward:
```rust
fn next(&mut self) -> Option<U::Item> {
    #[inline]
    fn next<U: Iterator>((): (), iter: &mut U) -> ControlFlow<U::Item> {
        match iter.next() {
            None => ControlFlow::CONTINUE,
            Some(x) => ControlFlow::Break(x),
        }
    }

    self.iter_try_fold((), next).break_value()
}
```
Note that despite being implemented in terms of `iter_try_fold`, `next` is still able to benefit from `U`'s `next` method. It therefore does not take the performance hit that implementing `next` directly in terms of `Self::try_fold` causes (in some benchmarks).

This PR also adds `iter_try_rfold` which captures the shared logic of `try_rfold` and `advance_back_by`, as well as `iter_fold` and `iter_rfold` for folding without early exits (used by `fold`, `rfold`, `count`, and `last`).

Benchmark results:
```
                                             before                after
bench_flat_map_sum                       423,255 ns/iter      414,338 ns/iter
bench_flat_map_ref_sum                 1,942,139 ns/iter    2,216,643 ns/iter
bench_flat_map_chain_sum               1,616,840 ns/iter    1,246,445 ns/iter
bench_flat_map_chain_ref_sum           4,348,110 ns/iter    3,574,775 ns/iter
bench_flat_map_chain_option_sum          780,037 ns/iter      780,679 ns/iter
bench_flat_map_chain_option_ref_sum    2,056,458 ns/iter      834,932 ns/iter
```

I added the last two benchmarks specifically to demonstrate an extreme case where `FlatMap::next` can benefit from custom internal iteration of the outer iterator, so take it with a grain of salt. We should probably do a perf run to see if the changes to `next` are worth it in practice.
2022-08-19 02:34:30 +00:00
Ralf Jung fbcdf2a383 clarify lib.rs attribute structure 2022-08-18 18:07:39 -04:00
Ralf Jung 438e49c1cb silence some unused-fn warnings in miri std builds 2022-08-18 18:07:39 -04:00
Ralf Jung 8c8dc125b1 make many std tests work in Miri 2022-08-18 18:07:39 -04:00
Ralf Jung 27b0444333 add some Miri-only tests 2022-08-18 18:07:39 -04:00
Ralf Jung ac66baad1a add miri-test-libstd support to libstd 2022-08-18 18:07:39 -04:00
Thom Chiovoloni f50f8782fe
Avoid zeroing a 1kb stack buffer on every call to `std::sys::windows::fill_utf16_buf` 2022-08-18 15:04:28 -07:00
bors 361c599fee Auto merge of #98655 - nnethercote:dont-derive-PartialEq-ne, r=dtolnay
Don't derive `PartialEq::ne`.

Currently we skip deriving `PartialEq::ne` for C-like (fieldless) enums
and empty structs, thus reyling on the default `ne`. This behaviour is
unnecessarily conservative, because the `PartialEq` docs say this:

> Implementations must ensure that eq and ne are consistent with each other:
>
> `a != b` if and only if `!(a == b)` (ensured by the default
> implementation).

This means that the default implementation (`!(a == b)`) is always good
enough. So this commit changes things such that `ne` is never derived.

The motivation for this change is that not deriving `ne` reduces compile
times and binary sizes.

Observable behaviour may change if a user has defined a type `A` with an
inconsistent `PartialEq` and then defines a type `B` that contains an
`A` and also derives `PartialEq`. Such code is already buggy and
preserving bug-for-bug compatibility isn't necessary.

Two side-effects of the change:
- There is only one error message produced for types where `PartialEq`
  cannot be derived, instead of two.
- For coverage reports, some warnings about generated `ne` methods not
  being executed have disappeared.

Both side-effects seem fine, and possibly preferable.
2022-08-18 10:11:11 +00:00
Nick Cameron ac70aea985 Address reviewer comments
Signed-off-by: Nick Cameron <nrc@ncameron.org>
2022-08-18 10:34:40 +01:00
Chris Denton b631ca0c2f
Windows: Load synch functions together
Attempt to load all the required sync functions and fail if any one of them fails.

This reintroduces a macro for optional loading of functions but keeps it separate from the fallback macro rather than having that do two different jobs.
2022-08-18 07:39:14 +01:00
David Tolnay 83f081fc01
Remove unstable Result::into_ok_or_err 2022-08-17 17:20:42 -07:00
Matthias Krüger 1199dbdcf5
Rollup merge of #100661 - PunkyMunky64:patch-1, r=thomcc
Fixed a few documentation errors

Quick pull request; IEEE-754, not IEEE-745. May save someone a quick second some time.
2022-08-17 12:33:02 +02:00
Matthias Krüger bd8aa6dffe
Rollup merge of #100660 - PunkyMunky64:patch-2, r=thomcc
Fixed a few documentation errors

Quick pull request; IEEE-754, not IEEE-745. May save someone a quick second some time.
2022-08-17 12:33:01 +02:00
Matthias Krüger 56b02b2137
Rollup merge of #100532 - RalfJung:unwind-miri, r=Mark-Simulacrum
unwind: don't build dependency when building for Miri

This is basically re-submitting https://github.com/rust-lang/rust/pull/94813.

In that PR there was a suggestion to instead have bootstrap set a `RUST_CHECK` env var and use that rather than doing something Miri-specific. However, such an env var would mean that when switching between `./x.py check` and `./x.py build`, the build script gets re-run each time, which doesn't seem good. So I think for now checking for Miri probably causes fewer problems.

r? ````@Mark-Simulacrum````
2022-08-17 12:32:53 +02:00
Raoul Strackx 2a23d08aae Mitigate Stale Data Read for xAPIC vulnerability
In order to mitigate the Stale Data Read for xAPIC vulnerability completely, reading userspace from an SGX enclave must be aligned and in 8-bytes chunks.

References:

 - https://www.intel.com/content/www/us/en/security-center/advisory/intel-sa-00657.html
 - https://www.intel.com/content/www/us/en/developer/articles/technical/software-security-guidance/advisory-guidance/stale-data-read-from-xapic.html
2022-08-17 09:51:03 +02:00
ltdk 5e1730fd17 Make slice::reverse const 2022-08-17 02:01:32 -04:00
PunkyMunky64 683b3f4e6e
Fixed a few documentation errors
Quick pull request; IEEE-754, not IEEE-745. May save someone a quick second some time.
2022-08-16 22:29:14 -07:00
PunkyMunky64 89d9a35b3e
Fixed a few documentation errors
IEEE-754, not IEEE-745. May save someone a second sometime
2022-08-16 22:28:11 -07:00
Alex 0ff8f0b578 Update src/test/assembly/x86_64-floating-point-clamp.rs
Simple Clamp Function

I thought this was more robust and easier to read. I also allowed this function to return early in order to skip the extra bound check (I'm sure the difference is negligible). I'm not sure if there was a reason for binding `self` to `x`; if so, please correct me.

Simple Clamp Function for f64

I thought this was more robust and easier to read. I also allowed this function to return early in order to skip the extra bound check (I'm sure the difference is negligible). I'm not sure if there was a reason for binding `self` to `x`; if so, please correct me.

Floating point clamp test

f32 clamp using mut self

f64 clamp using mut self

Update library/core/src/num/f32.rs

Update f64.rs

Update x86_64-floating-point-clamp.rs

Update src/test/assembly/x86_64-floating-point-clamp.rs

Update x86_64-floating-point-clamp.rs

Co-Authored-By: scottmcm <scottmcm@users.noreply.github.com>
2022-08-16 19:45:44 -04:00
Mohsen Zohrevandi 70dd980c8d Update fortanix-sgx-abi and export some useful SGX usercall traits
Update fortanix-sgx-abi to 0.5.0 to add support for cancel queue (see
https://github.com/fortanix/rust-sgx/pull/405 and
https://github.com/fortanix/rust-sgx/pull/404).

Export some useful traits for processing SGX usercall. This is needed
for https://github.com/fortanix/rust-sgx/pull/404 to avoid duplication.
2022-08-16 11:01:53 -07:00
Markus Reiter 44d62425b9
Simplify `IpDisplayBuffer` API. 2022-08-16 19:32:00 +02:00
Markus Reiter 31540f5e15
Use `MaybeUninit<u8>` for `IpDisplayBuffer`. 2022-08-16 18:12:06 +02:00
Markus Reiter 033e9d66ff
Move `IpDisplayBuffer` into submodule. 2022-08-16 17:57:46 +02:00
Markus Reiter 5a11b814d4
Add `IpDisplayBuffer` helper struct. 2022-08-16 17:54:55 +02:00
Raoul Strackx 25de53f768 Refactor copying data to userspace 2022-08-16 15:01:18 +02:00
Matthias Krüger 0b19a185db
Rollup merge of #100460 - cuviper:drop-llvm-12, r=nagisa
Update the minimum external LLVM to 13

With this change, we'll have stable support for LLVM 13 through 15 (pending release).
For reference, the previous increase to LLVM 12 was #90175.

r? `@nagisa`
2022-08-16 06:05:57 +02:00
bors 3694b7d307 Auto merge of #100007 - ChrisDenton:dtor-inline-never, r=michaelwoerister
Never inline Windows dtor access

Inlining can cause problem If used in a Rust dylib. See #44391.

r? `@Mark-Simulacrum`
2022-08-15 23:57:44 +00:00
Ralf Jung 63113c8b0c unwind: don't build dependency when building for Miri 2022-08-15 12:54:12 -04:00
Titus 8e80c39d2d
Fix trailing space showing up in example
The current text is rendered as: U+005B ..= U+0060 ``[ \ ] ^ _ ` ``, or.
This patch changes that to render as: U+005B ..= U+0060 `` [ \ ] ^ _ ` ``, or

The reason for that, is that CommonMark has a solution for starting or ending inline code with a backtick/grave accent: padding both sides with a space, makes that padding disappear.
2022-08-15 16:18:00 +02:00
Urgau 3f10e6c86d Say that the identity holds only for all finite numbers (aka not NaN) 2022-08-15 12:47:05 +02:00
Orson Peters a1e251024d Semicolon after macro_rules definition. 2022-08-15 12:33:00 +02:00
Orson Peters 85d5171dea Float biteq macros can be unused if test is skipped. 2022-08-15 12:33:00 +02:00
Orson Peters 18d61bfbf4 Skip next_up/down tests entirely on x87. 2022-08-15 12:33:00 +02:00
Orson Peters fbe215af53 Conditionally do not compile NaN roundtrip tests on x87 fp. 2022-08-15 12:33:00 +02:00
Orson Peters 712bf2a07a Added tracking issue numbers for float_next_up_down. 2022-08-15 12:33:00 +02:00
Orson Peters de757e8a98 Ensure NaN references values go through function boundary for next_up/down. 2022-08-15 12:33:00 +02:00
Orson Peters 3241bbcbc7 Fixed float next_up/down 32-bit x87 float NaN roundtrip test case. 2022-08-15 12:33:00 +02:00
Orson Peters 04681898f0 Added next_up and next_down for f32/f64. 2022-08-15 12:32:53 +02:00
Scott McMurray 7680c8b690 Properly forward `ByRefSized::fold` to the inner iterator 2022-08-14 22:55:30 -07:00
bors 80ed61fbd6 Auto merge of #96350 - austinabell:skip_optimization, r=Mark-Simulacrum
fix(iter::skip): Optimize `next` and `nth` implementations of `Skip`

This avoids calling nth/next or nth/nth to first skip elements and then get the next one (unless necessary due to usize overflow).
2022-08-15 03:09:20 +00:00
Josh Stone 2970ad8aee Update the minimum external LLVM to 13 2022-08-14 13:46:51 -07:00
Matthias Krüger b8b3ead67a
Rollup merge of #100249 - Meziu:master, r=joshtriplett
Fix HorizonOS regression in FileTimes

The changes in #98246 caused a regression for multiple Newlib-based systems. This is just a fix including HorizonOS to the list of  targets which require a workaround.

``@AzureMarker`` ``@ian-h-chamberlain``
r? ``@nagisa``
2022-08-14 20:16:00 +02:00
austinabell 00bc9e8ac4
fix(iter::skip): Optimize `next` and `nth` implementations of `Skip` 2022-08-14 13:25:13 -04:00
Dylan DPC 482a6eaf10
Rollup merge of #100026 - WaffleLapkin:array-chunks, r=scottmcm
Add `Iterator::array_chunks` (take N+1)

A revival of https://github.com/rust-lang/rust/pull/92393.

r? `@Mark-Simulacrum`
cc `@rossmacarthur` `@scottmcm` `@the8472`

I've tried to address most of the review comments on the previous attempt. The only thing I didn't address is `try_fold` implementation, I've left the "custom" one for now, not sure what exactly should it use.
2022-08-14 17:09:14 +05:30
Jakub Dąbek 8509936e8f
Add mention of `BufReader` in `Read::bytes` docs 2022-08-14 11:01:04 +02:00
Michael Goulet f8bdd9c680
Rollup merge of #100501 - RalfJung:miri-from-exposed-addr, r=Mark-Simulacrum
nicer Miri backtraces for from_exposed_addr

Miri by default warns about using from_exposed_addr; this makes the span for that a bit nicer.
2022-08-13 14:10:14 -07:00
Michael Goulet ea42f3cfd7
Rollup merge of #100407 - RalfJung:no-int2ptr, r=Mark-Simulacrum
avoid some int2ptr casts in thread_local_key tests
2022-08-13 14:10:05 -07:00
Ralf Jung 2dc9bf0fa0 nicer Miri backtraces for from_exposed_addr 2022-08-13 12:55:43 -04:00
Berend-Jan Lange 786e8755e7 created tcpstream quickack trait
for linux and android
2022-08-13 17:38:01 +02:00
Mark Rousskov 1c40ef70a1 Apply changes from rustfmt bump 2022-08-12 16:28:16 -04:00
Mark Rousskov 154a09dd91 Adjust cfgs 2022-08-12 16:28:15 -04:00
Dylan DPC da3b89d0bf
Rollup merge of #100255 - thedanvail:issue-98861-fix, r=joshtriplett
Adding more verbose documentation for `std::fmt::Write`

Attempts to address #98861
2022-08-12 20:39:13 +05:30
Dylan DPC 51eed00ca9
Rollup merge of #100030 - WaffleLapkin:nice_pointer_sis, r=scottmcm
cleanup code w/ pointers in std a little

Use pointer methods (`byte_add`, `null_mut`, etc) to make code in std a little nicer.
2022-08-12 20:39:10 +05:30
Dylan DPC a8c799a6a0
Rollup merge of #100022 - joboet:faster_threadid, r=joshtriplett
Optimize thread ID generation

By using atomics where available, thread IDs can be generated without locking while still enforcing uniqueness.
2022-08-12 20:39:09 +05:30
Maybe Waffle 5fbcde1b55 fill-in tracking issue for `feature(iter_array_chunks)` 2022-08-12 15:04:29 +04:00
Maybe Waffle eb6b729545 address review comments 2022-08-12 14:57:15 +04:00
bors 569788e47e Auto merge of #99624 - vincenzopalazzo:macros/unix_error, r=Amanieu
promote debug_assert to assert when possible and useful

This PR fixed a very old issue https://github.com/rust-lang/rust/issues/94705 to clarify and improve the POSIX error checking, and some of the checks are skipped because can have no benefit, but I'm sure that this can open some interesting discussion.

Fixes https://github.com/rust-lang/rust/issues/94705

cc: `@tavianator`
cc: `@cuviper`
2022-08-12 09:49:55 +00:00
Matthias Krüger c7578b4e65
Rollup merge of #100418 - tbodt:stabilize-backtrace, r=dtolnay
Add stability attributes to BacktraceStatus variants

Fixes #100399
2022-08-11 22:53:10 +02:00