Commit graph

7932 commits

Author SHA1 Message Date
Mark Rousskov b454991ac4 Finish bumping stage0
It looks like the last time had left some remaining cfg's -- which made me think
that the stage0 bump was actually successful. This brings us to a released 1.62
beta though.
2022-05-27 07:36:17 -04:00
bors f558990814 Auto merge of #97004 - nnethercote:proc-macro-tweaks, r=eddyb
Proc macro tweaks

Various improvements I spotted while looking through the proc macro code.

r? `@eddyb`
2022-05-27 06:09:45 +00:00
Nicholas Nethercote 41c10dde95 Cut down associated_item.
The part of it dealing with types obfuscates and makes the code less
concise. This commit removes that part.
2022-05-27 16:02:24 +10:00
Nicholas Nethercote e6fa19a3ce Remove unnecessary blank line. 2022-05-27 16:02:24 +10:00
Nicholas Nethercote f5c9c1215c Rename b as buf in several places.
Because it's easy to confuse with `bridge`.
2022-05-27 15:58:35 +10:00
Nicholas Nethercote c2c505737f Add some comments about _marker fields.
There is some non-obvious information required to understand them.
2022-05-27 15:58:35 +10:00
Nicholas Nethercote 9a785e0aa5 Clarify a comment.
`reverse_encode` isn't necessary to please the borrow checker, it's to
match the ordering done by `reverse_decode`.
2022-05-27 15:58:35 +10:00
Nicholas Nethercote 2ece157e17 Make Buffer<T> non-generic.
`u8` is the only type that makes sense for `T`, as demonstrated by the
fact that several impls and functions are hardwired to `Buffer<u8>`.
2022-05-27 15:58:35 +10:00
Nicholas Nethercote e02789c9f8 Improve formatting in associated_item! definition. 2022-05-27 15:58:35 +10:00
Nicholas Nethercote a61a85eb24 Add some comments. 2022-05-27 15:58:35 +10:00
Nicholas Nethercote 2469ed0142 Fix a typo in a comment. 2022-05-27 15:58:35 +10:00
bors 9a42c6509d Auto merge of #97444 - compiler-errors:rollup-2gvdav6, r=compiler-errors
Rollup of 3 pull requests

Successful merges:

 - #96051 (Use rounding in float to Duration conversion methods)
 - #97066 (rustdoc: Remove `ItemFragment(Kind)`)
 - #97436 (Update `triagebot.toml` for macos ping group)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-05-27 03:27:04 +00:00
Michael Goulet e3813e46a2
Rollup merge of #96051 - newpavlov:duration_rounding, r=nagisa,joshtriplett
Use rounding in float to Duration conversion methods

Closes #96045
2022-05-26 20:15:07 -07:00
Артём Павлов [Artyom Pavlov] 6495963d5a fmt 2022-05-27 05:15:22 +03:00
Артём Павлов [Artyom Pavlov] 38609cd8a9 fix nanos overflow for f64 2022-05-27 04:59:01 +03:00
Artyom Pavlov 06af3a63a5
add debug asserts 2022-05-27 00:22:56 +00:00
Vadim Petrochenkov 5bf23f64cc libcore: Add iter::from_generator which is like iter::from_fn, but for coroutines instead of functions 2022-05-27 01:51:31 +03:00
Matthias Krüger 82beeabf54
Rollup merge of #96033 - yaahc:expect-elaboration, r=scottmcm
Add section on common message styles for Result::expect

Based on a question from https://github.com/rust-lang/project-error-handling/issues/50#issuecomment-1092339937

~~One thing I haven't decided on yet, should I duplicate this section on `Option::expect`, link to this section, or move it somewhere else and link to that location from both docs?~~: I ended up moving the section to `std::error` and referencing it from both `Result::expect` and `Option::expect`'s docs.

I think this section, when combined with the similar update I made on [`std::panic!`](https://doc.rust-lang.org/nightly/std/macro.panic.html#when-to-use-panic-vs-result) implies that we should possibly more aggressively encourage and support the "expect as precondition" style described in this section. The consensus among the libs team seems to be that panic should be used for bugs, not expected potential failure modes. The "expect as error message" style seems to align better with the panic for unrecoverable errors style where they're seen as normal errors where the only difference is a desire to kill the current execution unit (aka erlang style error handling). I'm wondering if we should be providing a panic hook similar to `human-panic` or more strongly recommending the "expect as precondition" style of expect message.
2022-05-26 20:59:40 +02:00
bors 1851f0802e Auto merge of #97046 - conradludgate:faster-ascii-case-conv-path, r=thomcc
improve case conversion happy path

Someone shared the source code for [Go's string case conversion](19156a5474/src/strings/strings.go (L558-L616)).

It features a hot path for ascii-only strings (although I assume for reasons specific to go, they've opted for a read safe hot loop).

I've borrowed these ideas and also kept our existing code to provide a fast path + seamless utf-8 correct path fallback.

(Naive) Benchmarks can be found here https://github.com/conradludgate/case-conv

For the cases where non-ascii is found near the start, the performance of this algorithm does fall back to original speeds and has not had any measurable speed loss
2022-05-26 15:29:01 +00:00
Conrad Ludgate d0f9930709 improve case conversion happy path 2022-05-26 13:18:57 +01:00
bors 9e26dc71fd Auto merge of #96742 - m-ou-se:bsd-no-ancillary, r=joshtriplett
Disable unix::net::ancillary on BSD.

See https://github.com/rust-lang/rust/issues/76915#issuecomment-1118954474
2022-05-26 08:50:33 +00:00
Mara Bos 8b9f8e25ba Disable unix::net::ancillary on BSD. 2022-05-25 20:09:59 -07:00
Jane Lusby ef879c680e fix broken doctest 2022-05-25 12:20:48 -07:00
Jane Lusby 720e987ac0 update option and result references to expect message docs 2022-05-25 11:37:39 -07:00
Jane Lusby b6b621ec85 fix links 2022-05-25 10:46:56 -07:00
bors 9fed13030c Auto merge of #94954 - SimonSapin:null-thin3, r=yaahc
Extend ptr::null and null_mut to all thin (including extern) types

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

This change was accepted in https://rust-lang.github.io/rfcs/2580-ptr-meta.html

Note that this changes the signature of **stable** functions. The change should be backward-compatible, but it is **insta-stable** since it cannot (easily, at all?) be made available only through a `#![feature(…)]` opt-in.

The RFC also proposed the same change for `NonNull::dangling`, which makes sense it terms of its signature but not in terms of its implementation. `dangling` uses `align_of()` as an address. But what `align_of()` should be for extern types or whether it should be allowed at all remains an open question.

This commit depends on https://github.com/rust-lang/rust/pull/93977, which is not yet part of the bootstrap compiler. So `#[cfg]` is used to only apply the change in stage 1+. As far a I know bounds cannot be made conditional with `#[cfg]`, so the entire functions are duplicated. This is unfortunate but temporary.

Since this duplication makes it less obvious in the diff, the new definitions differ in:

* More permissive bounds (`Thin` instead of implied `Sized`)
* Different implementation
* Having `rustc_allow_const_fn_unstable(const_fn_trait_bound)`
* Having `rustc_allow_const_fn_unstable(ptr_metadata)`
2022-05-25 13:58:51 +00:00
Dylan DPC ca269b1e79
Rollup merge of #97233 - c410-f3r:assert-lib, r=scottmcm
[RFC 2011] Library code

CC https://github.com/rust-lang/rust/pull/96496

Based on https://github.com/dtolnay/case-studies/tree/master/autoref-specialization.

Basically creates two traits with the same method name. One trait is generic over any `T` and the other is specialized to any `T: Printable`.

The compiler will then call the corresponding trait method through auto reference.

```rust
fn main() {
    let mut a = Capture::new();
    let mut b = Capture::new();

    (&Wrapper(&1i32)).try_capture(&mut a); // `try_capture` from `TryCapturePrintable`
    (&Wrapper(&vec![1i32])).try_capture(&mut b); // `try_capture` from `TryCaptureGeneric`

    assert_eq!(format!("{:?}", a), "1");
    assert_eq!(format!("{:?}", b), "N/A");
}
```

r? `@scottmcm`
2022-05-25 10:48:29 +02:00
Dylan DPC 70bdfc1d79
Rollup merge of #97379 - ear7h:master, r=thomcc
Add aliases for `current_dir`

Aliases were added for the equivalent C/C++ APIs for POSIX and Windows. Also, I added one for `pwd` which users may be more familiar with, from the command line.
2022-05-25 07:31:45 +02:00
Dylan DPC fbb17777fe
Rollup merge of #97026 - Nilstrieb:make-atomic-debug-relaxed, r=scottmcm
Change orderings of `Debug` for the Atomic types to `Relaxed`.

This reduces synchronization between threads when debugging the atomic types.  Reducing the synchronization means that executions with and without the debug calls will be more consistent, making it easier to debug.

We discussed this on the Rust Community Discord with `@ibraheemdev` before.
2022-05-25 07:31:42 +02:00
julio 84c80e7348 add aliases for current_dir 2022-05-24 19:41:40 -07:00
Артём Павлов [Artyom Pavlov] 26f859463e tweak doctests 2022-05-25 05:14:30 +03:00
Артём Павлов [Artyom Pavlov] c2d8445cde implement tie to even 2022-05-25 05:01:11 +03:00
Jane Losare-Lusby 9a9dafcca4 explained unwrap vs expect 2022-05-24 22:52:30 +00:00
Yuki Okushi c3fea09208
Rollup merge of #97364 - notriddle:continue-keyword, r=JohnTitor
Fix weird indentation in continue_keyword docs

This format was causing every line in the code examples to have a space at the start.
2022-05-25 07:08:45 +09:00
Yuki Okushi 7ed7f65bac
Rollup merge of #97363 - wackbyte:sliceindex-doc-typo, r=JohnTitor
Fix a small mistake in `SliceIndex`'s documentation

Originally, it said "`get_(mut_)unchecked`," but the method's actual name is `get_unchecked_mut`.
2022-05-25 07:08:44 +09:00
Yuki Okushi 33f45b167e
Rollup merge of #93966 - rkuhn:patch-1, r=tmandry
document expectations for Waker::wake

fixes #93961

Opened PR for a discussion on the precise wording.
2022-05-25 07:08:41 +09:00
Michael Howell 1d19462a45 Fix weird indentation in continue_keyword docs
This format was causing every line in the code examples to have a space
at the start.
2022-05-24 11:10:56 -07:00
wackbyte ce947735c0
Fix a mistake in SliceIndex's documentation 2022-05-24 13:22:41 -04:00
Dylan DPC 4bd40186db
Rollup merge of #97321 - RalfJung:int-to-fnptr, r=Dylan-DPC
explain how to turn integers into fn ptrs

(with an intermediate raw ptr, not a direct transmute)
Direct int2ptr transmute, under the semantics I am imagining, will produce a ptr with "invalid" provenance that is invalid to deref or call. We cannot give it the same semantics as int2ptr casts since those do [something complicated](https://www.ralfj.de/blog/2022/04/11/provenance-exposed.html).

To my great surprise, that is already what the example in the `transmute` docs does. :)  I still added a comment to say that that part is important, and I added a section explicitly talking about this to the `fn()` type docs.

With https://github.com/rust-lang/miri/pull/2151, Miri will start complaining about direct int-to-fnptr transmutes (in the sense that it is UB to call the resulting pointer).
2022-05-24 15:58:26 +02:00
Dylan DPC af15e45e28
Rollup merge of #97308 - JohnTitor:stabilize-cell-filter-map, r=Mark-Simulacrum
Stabilize `cell_filter_map`

FCP has been completed: https://github.com/rust-lang/rust/issues/81061#issuecomment-1081806326
Closes #81061
2022-05-24 15:58:25 +02:00
Tobias Bucher 328c84327b Fix stabilization version of Ipv6Addr::to_ipv4_mapped 2022-05-24 01:05:06 +02:00
Ralf Jung 5137d15f91 sync primitive_docs 2022-05-23 19:09:23 +02:00
Ralf Jung cec6dfcd67 explain how to turn integers into fn ptrs
(with an intermediate raw ptr, not a direct transmute)
2022-05-23 18:47:08 +02:00
bors 7f997f589f Auto merge of #97315 - Dylan-DPC:rollup-2wee2oz, r=Dylan-DPC
Rollup of 4 pull requests

Successful merges:

 - #96129 (Document rounding for floating-point primitive operations and string parsing)
 - #97286 (Add new eslint rule to prevent whitespace before function call paren)
 - #97292 (Lifetime variance fixes for rustc)
 - #97309 (Add some regression tests for #90400)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-05-23 15:45:44 +00:00
Dylan DPC 98a8035bed
Rollup merge of #96129 - mattheww:2022-04_float_rounding, r=Dylan-DPC
Document rounding for floating-point primitive operations and string parsing

The docs for floating point don't have much to say at present about either the precision of their results or rounding behaviour.

As I understand it[^1][^2], Rust doesn't support operating with non-default rounding directions, so we need only describe roundTiesToEven.

[^1]: https://github.com/rust-lang/rust/issues/41753#issuecomment-299322887
[^2]: https://github.com/llvm/llvm-project/issues/8472#issuecomment-980888781

This PR makes a start by documenting that for primitive operations and `from_str()`.
2022-05-23 15:11:02 +02:00
bors ef9b49881b Auto merge of #92461 - rust-lang:const_tls_local_panic_count, r=Mark-Simulacrum
Use const initializer for LOCAL_PANIC_COUNT

This reduces the size of the __getit function for LOCAL_PANIC_COUNT and should speed up accesses of LOCAL_PANIC_COUNT a bit.
2022-05-23 13:04:59 +00:00
Yuki Okushi 65242592c9
Stabilize cell_filter_map 2022-05-23 18:04:53 +09:00
bors 9e2f655863 Auto merge of #97304 - Dylan-DPC:rollup-qxrfddc, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #97087 (Clarify slice and Vec iteration order)
 - #97254 (Remove feature: `crate` visibility modifier)
 - #97271 (Add regression test for #91949)
 - #97294 (std::time : fix variable name in the doc)
 - #97303 (Fix some typos in arg checking algorithm)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-05-23 07:57:15 +00:00
Dylan DPC 06e89fdcfd
Rollup merge of #97294 - jersou:patch-1, r=Dylan-DPC
std::time : fix variable name in the doc
2022-05-23 07:43:51 +02:00
Dylan DPC e5cf3cb97d
Rollup merge of #97087 - Nilstrieb:clarify-slice-iteration-order, r=dtolnay
Clarify slice and Vec iteration order

While already being inferable from the doc examples, it wasn't fully specified. This is the only logical way to do a slice iterator, so I think this should be uncontroversial. It also improves the `Vec::into_iter` example to better show the order and that the iterator returns owned values.
2022-05-23 07:43:49 +02:00