Commit Graph

10459 Commits

Author SHA1 Message Date
Dylan DPC 188dd72b5f
Rollup merge of #107655 - notriddle:notriddle/small-url-encode, r=GuillaumeGomez
rustdoc: use the same URL escape rules for fragments as for examples

Carries over improvements from #107284
2023-02-09 23:18:34 +05:30
Michael Goulet aee4570adf
Rollup merge of #107429 - tgross35:from-bytes-until-null-stabilization, r=dtolnay
Stabilize feature `cstr_from_bytes_until_nul`

This PR seeks to stabilize `cstr_from_bytes_until_nul`.

Partially addresses #95027

This function has only been on nightly for about 10 months, but I think it is simple enough that there isn't harm discussing stabilization. It has also had at least a handful of mentions on both the user forum and the discord, so it seems like it's already in use or at least known.

This needs FCP still.

Comment on potential discussion points:
- eventual conversion of `CStr` to be a single thin pointer: this function will still be useful to provide a safe way to create a `CStr` after this change.
- should this return a length too, to address concerns about the `CStr` change? I don't see it as being particularly useful, and it seems less ergonomic (i.e. returning `Result<(&CStr, usize), FromBytesUntilNulError>`). I think users that also need this length without the additional `strlen` call are likely better off using a combination of other methods, but this is up for discussion
- `CString::from_vec_until_nul`: this is also useful, but it doesn't even have a nightly implementation merged yet. I propose feature gating that separately, as opposed to blocking this `CStr` implementation on that

Possible alternatives:

A user can use `from_bytes_with_nul` on a slice up to `my_slice[..my_slice.iter().find(|c| c == 0).unwrap()]`. However; that is significantly less ergonomic, and is a bit more work for the compiler to optimize compared the direct `memchr` call that this wraps.

## New stable API

```rs
// both in core::ffi

pub struct FromBytesUntilNulError(());

impl CStr {
    pub const fn from_bytes_until_nul(
        bytes: &[u8]
    ) -> Result<&CStr, FromBytesUntilNulError>
}
```

cc ```@ericseppanen``` original author, ```@Mark-Simulacrum``` original reviewer, ```@m-ou-se``` brought up some issues on the thin pointer CStr

```@rustbot``` modify labels: +T-libs-api +needs-fcp
2023-02-08 20:01:24 -08:00
Michael Goulet a478b836fa
Rollup merge of #107317 - ids1024:asfd-rc, r=dtolnay
Implement `AsFd` and `AsRawFd` for `Rc`

Fixes https://github.com/rust-lang/rust/issues/105931.
2023-02-08 20:01:24 -08:00
Matthias Krüger c7c66e1b12
Rollup merge of #107793 - joboet:raw_os_error_ty_tracking, r=Dylan-DPC
Add missing tracking issue for `RawOsError`

I forgot to add it in the original PR…

See #107792.

```@rustbot``` label +T-libs-api -T-libs
2023-02-08 18:32:44 +01:00
Matthias Krüger 562581c2db
Rollup merge of #105641 - Amanieu:btree_cursor, r=m-ou-se
Implement cursors for BTreeMap

See the ACP for an overview of the API: https://github.com/rust-lang/libs-team/issues/141

The implementation is split into 2 commits:
- The first changes the internal insertion functions to return a handle to the newly inserted element. The lifetimes involved are a bit hairy since we need a mutable handle to both the `BTreeMap` itself (which holds the root) and the nodes allocated in memory. I have tested that this passes the standard library testsuite under miri.
- The second commit implements the cursor API itself. This is more straightforward to follow but still involves some unsafe code to deal with simultaneous mutable borrows of the tree root and the node that is currently being iterated.
2023-02-08 18:32:41 +01:00
joboet 6a5331146c
std: add tracking issue for `RawOsError` 2023-02-08 12:35:27 +01:00
Matthias Krüger 5e467f5dfa
Rollup merge of #107776 - dbrgn:docs-string-reserve-headings, r=cuviper
Docs: Fix format of headings in String::reserve

It was inconsistent with other doc comments in the same module (and the rest of the rust std docs).
2023-02-08 07:13:28 +01:00
Matthias Krüger fabefe3f31
Rollup merge of #107769 - compiler-errors:pointer-like, r=eholk
Rename `PointerSized` to `PointerLike`

The old name was unnecessarily vague. This PR renames a nightly language feature that I added, so I don't think it needs any additional approval, though anyone can feel free to speak up if you dislike the rename.

It's still unsatisfying that we don't the user which of {size, alignment} is wrong, but this trait really is just a stepping stone for a more generalized mechanism to create `dyn*`, just meant for nightly testing, so I don't think it really deserves additional diagnostic machinery for now.

Fixes #107696, cc ``@RalfJung``
r? ``@eholk``
2023-02-08 07:13:26 +01:00
Danilo Bargen 4f36673e15 Docs: Fix format of headings in String::reserve 2023-02-07 21:32:28 +01:00
Michael Goulet 2b70cbb8a5 Rename PointerSized to PointerLike 2023-02-07 19:05:53 +00:00
Matthias Krüger e45984b774
Rollup merge of #107706 - tgross35:atomic-as-mut-ptr, r=m-ou-se
Mark 'atomic_mut_ptr' methods const

There's nothing that would block these methods from being const (just an UnsafeCell get), and it would be helpful for FFI interfaces in static contexts

Related tracking issue: #66893
2023-02-07 17:57:16 +01:00
Matthias Krüger 7343f748cb
Rollup merge of #107720 - tshepang:consistency, r=Mark-Simulacrum
end entry paragraph with a period (.)
2023-02-06 21:16:42 +01:00
Matthias Krüger 7c4e6edb05
Rollup merge of #107714 - Wilfred:round_docs, r=m-ou-se
Clarify wording on f64::round() and f32::round()

"Round half-way cases" is a little confusing (it's a 'garden path sentence' as it's not immediately clear whether round is an adjective or verb).

Make this sentence longer and clearer.
2023-02-06 21:16:41 +01:00
bors 044a28a409 Auto merge of #103761 - chenyukang:yukang/fix-103320-must-use, r=compiler-errors
Add explanatory message for [#must_use] in ops

Fixes #103320
2023-02-06 12:57:37 +00:00
Tshepang Mbambo c58202eb9b end entry paragprah with a period (.) 2023-02-06 11:22:44 +02:00
Wilfred Hughes 4a7a9b4e74 Clarify wording on f64::round() and f32::round()
"Round half-way cases" is a little confusing (it's a 'garden path
sentence' as it's not immediately clear whether round is an adjective
or verb).

Make this sentence longer and clearer.
2023-02-05 19:44:21 -08:00
Trevor Gross b51d3b9443 Mark 'atomic_mut_ptr' methods const 2023-02-05 17:03:46 -05:00
Kiran Shila f5c45ad284
Fix typo in HashMap::with_capacity 2023-02-05 10:13:30 -08:00
Michael Howell fa6c3a2d2a docs: update fragment for Result impls 2023-02-03 19:03:17 -07:00
Michael Goulet 13bd75f425
Rollup merge of #107632 - ameknite:issue-107622-fix, r=jyn514
Clarifying that .map() returns None if None.

Fix #107622
2023-02-03 14:15:24 -08:00
Michael Goulet e99e05d135
Rollup merge of #107551 - fee1-dead-contrib:rm_const_fnmut_helper, r=oli-obk
Replace `ConstFnMutClosure` with const closures

Also fixes a parser bug. cc `@oli-obk` for compiler changes
2023-02-03 14:15:22 -08:00
Michael Goulet beb5cc9cf7
Rollup merge of #107519 - joboet:raw_os_error_ty, r=Amanieu
Add type alias for raw OS errors

Implement rust-lang/libs-team#173.

`@rustbot` label +S-waiting-on-ACP +T-libs-api
2023-02-03 14:15:21 -08:00
Ame b384692f4c nit fixed 2023-02-03 13:57:53 -06:00
Ame c2b65ffe29 Clarifying that .map() returns None if None. 2023-02-03 13:57:53 -06:00
yukang cb55d10eb2 Fix #103320, add explanatory message for [#must_use] 2023-02-04 00:27:03 +08:00
Deadbeef b886a4de15 Replace `ConstFnMutClosure` with const closures 2023-02-03 14:43:13 +00:00
Matthias Krüger 86015515b5
Rollup merge of #107598 - chenyukang:yukang/fix-core-bench, r=thomcc
Fix benchmarks in library/core with black_box

Fixes #107590
2023-02-03 06:30:24 +01:00
yukang fe84cecf60 fix #107590, Fix benchmarks in library/core with black_box 2023-02-03 00:33:36 +08:00
Trevor Gross 877e9f5d3a Change 'from_bytes_until_nul' to const stable 2023-02-01 02:14:07 -05:00
Trevor Gross 83b05ef0ee Stabilize feature 'cstr_from_bytes_until_nul' 2023-02-01 02:14:07 -05:00
Matthias Krüger 1dbb5efff3
Rollup merge of #107442 - lukas-code:slice-panics, r=cuviper
improve panic message for slice windows and chunks

before:
```text
thread 'main' panicked at 'size is zero', /rustc/1e225413a21fa69570bd3fefea9eb05e33f8b917/library/core/src/slice/mod.rs:809:44
```
```text
thread 'main' panicked at 'assertion failed: `(left != right)`
  left: `0`,
 right: `0`: chunks cannot have a size of zero', /rustc/1e225413a21fa69570bd3fefea9eb05e33f8b917/library/core/src/slice/mod.rs:843:9
```

after:
```text
thread 'main' panicked at 'chunk size must be non-zero', src/main.rs:4:22
```

fixes https://github.com/rust-lang/rust/issues/107437
2023-02-01 05:54:38 +01:00
Matthias Krüger 0d2ab67742
Rollup merge of #107389 - zvavybir:master, r=estebank
Fixing confusion between mod and remainder

Like many programming languages, rust too confuses remainder and modulus.  The `%` operator and the associated `Rem` trait is (as the trait name suggests) the remainder, but since most people are linguistically more familiar with the modulus the documentation sometimes claims otherwise.  This PR tries to fix this problem in rustc.
2023-02-01 05:54:37 +01:00
Amanieu d'Antras 36831b3ccb BTreeMap: Add Cursor and CursorMut 2023-02-01 00:16:15 +00:00
Amanieu d'Antras eb70c82d29 BTreeMap: Change internal insert function to return a handle
This is a prerequisite for cursor support for `BTreeMap`.
2023-02-01 00:08:59 +00:00
Lukas Markeffsky 2fbe9274aa improve panic message for slice windows and chunks 2023-01-31 23:49:42 +01:00
Guillaume Gomez adc3f8a44b
Rollup merge of #107535 - dcompoze:tcp-doc-unwrap, r=cuviper
Replace unwrap with ? in TcpListener doc

The example in TcpListener doc returns `std::io::Result<()>` but the code inside the function uses `unwrap()` instead of `?`.
2023-01-31 23:38:55 +01:00
Daniel Chmielewski 943f833314
Replace unwrap with ? in TcpListener doc 2023-01-31 21:04:49 +00:00
bors dc1d9d50fb Auto merge of #107297 - Mark-Simulacrum:bump-bootstrap, r=pietroalbini
Bump bootstrap compiler to 1.68

This also changes our stage0.json to include the rustc component for the rustfmt pinned nightly toolchain, which is currently necessary due to rustfmt dynamically linking to that toolchain's librustc_driver and libstd.

r? `@pietroalbini`
2023-01-31 19:24:29 +00:00
joboet 42cc28ac8b
std: add type alias for raw OS errors
Implement rust-lang/libs-team#173.
2023-01-31 17:23:35 +01:00
Yuki Okushi 150340bafd
Rollup merge of #107494 - lebensterben:patch-1, r=JohnTitor
fix link in std::path::Path::display()

The link `Debug` points to should be the trait `Debug`, not the macro `Debug`.
2023-01-31 11:46:26 +09:00
Yuki Okushi 39d2639f81
Rollup merge of #107445 - Swatinem:rm-genfuture, r=cuviper
Remove `GenFuture` from core

The handling of async constructs in the compiler does not rely on `GenFuture` anymore since `1.67`, so this code can now be removed from `core`.
2023-01-31 11:46:23 +09:00
Lucius Hu 3c408d82a3
fix link in std::path::Path::display()
The link `Debug` points to should be the trait `Debug`, not the macro `Debug`.
2023-01-31 00:20:27 +00:00
Matthias Kaak 8d7b092a11
Improved wording of error messages of missing remainder implementations 2023-01-30 19:54:33 +00:00
Mark Rousskov 5b08c9f397 stage-step cfgs 2023-01-30 13:09:09 -05:00
Matthias Krüger b3b9383f8d
Rollup merge of #107424 - bpeel:clone-into-from-share-code, r=scottmcm
Make Vec::clone_from and slice::clone_into share the same code

In the past, `Vec::clone_from` was implemented using `slice::clone_into`. The code from `clone_into` was later duplicated into `clone_from` in 8725e4c337, which is the commit that adds custom allocator support to Vec. Presumably this was done because the `slice::clone_into` method only works for vecs with the default allocator so it would have the wrong type to clone into `Vec<T, A>`.

Later on in 361398009b the code for the two methods diverged because the `Vec::clone_from` version gained a specialization to optimize the case when T is Copy. In order to reduce code duplication and make them both be able to take advantage of this specialization, this PR moves the specialization into the slice module and makes vec use it again.
2023-01-30 17:50:10 +01:00
bors 006ca9b14d Auto merge of #107080 - Urgau:cleanup-bootstrap-extra-check-cfgs, r=Mark-Simulacrum
bootstrap: cleanup the list of extra check cfgs

This PR performs some cleanups on the `EXTRA_CHECK_CFGS` list in bootstrap.

- `target_os=watchos`: no longer relevant because there are now proper targets `*-apple-watchos`
 - `target_arch=nvptx64`: target `nvptx64-nvidia-cuda` makes it useless
 - `target_arch=le32`: target was removed (https://github.com/rust-lang/rust/pull/45041)
 - `release`: was removed from rustfmt (https://github.com/rust-lang/rustfmt/pull/5375 and https://github.com/rust-lang/rustfmt/pull/5449)
 - `dont_compile_me`: was removed from stdarch (https://github.com/rust-lang/stdarch/pull/1308)

Also made some external cfg exception mode clear and only activated for rustc and rustc tools (as to not have the Standard Library unintentionally depend on them).
2023-01-30 13:56:40 +00:00
Dylan DPC da56c44ba2
Rollup merge of #107459 - tshepang:cosistency, r=WaffleLapkin
end entry paragraph with a period (.)
2023-01-30 15:11:47 +05:30
Dylan DPC f01b8f5cf4
Rollup merge of #107452 - y21:get-mut-unchecked-typo, r=Mark-Simulacrum
Fix typo in `{Rc, Arc}::get_mut_unchecked` docs

Just a correction in the documentation of `{Rc, Arc}::get_mut_unchecked`.
2023-01-30 15:11:46 +05:30
Dylan DPC 28340bab88
Rollup merge of #101569 - m-ou-se:alloc-no-rexport-argumentv1, r=thomcc
Don't re-export private/unstable ArgumentV1 from `alloc`.

The `alloc::fmt::ArgumentV1` re-export was marked as `#[stable]` even though the original `core::fmt::ArgumentV1` is `#[unstable]` (and `#[doc(hidden)]`).

(It wasn't usable though:

```
error[E0658]: use of unstable library feature 'fmt_internals': internal to format_args!
 --> src/main.rs:4:12
  |
4 |     let _: alloc::fmt::ArgumentV1 = todo!();
  |            ^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: add `#![feature(fmt_internals)]` to the crate attributes to enable
```
)

Part of #99012
2023-01-30 15:11:44 +05:30
Tshepang Mbambo 72360191f1 end entry paragraph with a period (.) 2023-01-30 07:37:02 +02:00