Commit Graph

12254 Commits

Author SHA1 Message Date
Ralf Jung
396cbe6639 make unsetting env vars print as executable command 2023-08-24 08:08:46 +02:00
Ralf Jung
f2b139f23d Command: also print removed env vars 2023-08-24 08:08:46 +02:00
Mark Rousskov
0a916062aa Bump cfg(bootstrap) 2023-08-23 20:05:14 -04:00
bors
249595b752 Auto merge of #115112 - tmandry:backtrace-0369, r=compiler-errors
Bump backtrace to 0.3.69
2023-08-23 18:01:35 +00:00
Guillaume Gomez
128ff0897b
Rollup merge of #114696 - g0djan:godjan/fix_114610, r=Mark-Simulacrum
Fix a pthread_t handle leak #114610

https://github.com/rust-lang/rust/issues/114610

Ran the tests as described in https://github.com/rust-lang/rust/blob/master/src/doc/rustc/src/platform-support/wasm32-wasi-preview1-threads.md?plain=1#L125
2023-08-23 17:46:33 +02:00
Dylan DPC
7257e9c2de
Rollup merge of #115100 - Urgau:invalid_ref_casting-ptr-writes, r=est31
Add support for `ptr::write`s for the `invalid_reference_casting` lint

This PR adds support for `ptr::write` and others for the `invalid_reference_casting` lint.

Detecting instances where instead of using the deref (`*`) operator to assign someone uses `ptr::write`, `ptr::write_unaligned` or `ptr::write_volatile`.

```rust
let data_len = 5u64;

std::ptr::write(
    std::mem::transmute::<*const u64, *mut u64>(&data_len),
    new_data_len,
);
```

r? ``@est31``
2023-08-23 05:35:17 +00:00
Dylan DPC
21411c4db5
Rollup merge of #115053 - waywardmonkeys:augment-type-keyword-docs, r=cuviper
docs: Add example, reference link for `type` keyword.

Fixes #114281.
2023-08-23 05:35:16 +00:00
Tomoaki Kawada
65217a72b0 kmc-solid: Import std::sync::PoisonError in std::sys::solid::os 2023-08-23 11:44:18 +09:00
Tyler Mandry
4c14ca3141 Bump backtrace to 0.3.69 2023-08-22 15:01:14 -07:00
Urgau
7ee77b5d1b Add support for ptr::write for the invalid_reference_casting lint 2023-08-22 15:47:29 +02:00
Sean Cross
6c32a64962 std: enable feature(slice_ptr_len) on xous
Xous passes slice pointers around in order to manipulate memory.
This is feature-gated behind `slice_ptr_len`. Xous is currently
the only target to use this feature, so gate it behind an OS flag.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-08-22 20:25:39 +08:00
Sean Cross
6413844a22 std: xous: add support for locks
Add support for Condvar, Mutex, and RWLock. These are all backed by the
ticktimer server.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-08-22 20:25:38 +08:00
Sean Cross
46a4ec3a71 std: xous: add thread_local_key
Add an implementation of thread local storage. This uses a container
that is pointed to by the otherwise-unsed `$tp` register. This container
is allocated on-demand, so threads that use no TLS will not allocate
this extra memory.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-08-22 20:25:38 +08:00
Sean Cross
d36e516478 std: xous: add thread support
Add initial support for threads on Xous. This includes thread creation
and joining.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-08-22 20:25:38 +08:00
Sean Cross
efa470d0ae std: xous: add support for time
Add support for determining the current time. This connects to the
ticktimer server in order to get the system uptime.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-08-22 20:25:38 +08:00
Sean Cross
4af7d2cf8d std: xous: add output support for stdio
Add support for stdout. This enables basic console printing via
`println!()`. Output is written to the log server.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-08-22 20:25:38 +08:00
Sean Cross
10dad67f89 std: xous: add services support
Xous has a concept of `services` that provide various features.
Processes may connect to these services by name or by address. Most
services require a name server in order to connect.

Add a file with the most common services, and provide a way to connect
to a service by querying the name server.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-08-22 20:25:38 +08:00
Sean Cross
dfff5bf62f panic_abort: call __rust_abort on xous
Xous does not properly handle invalid instructions. Instead, call
`__rust_abort` and exit normally.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-08-22 20:25:38 +08:00
Sean Cross
823cba9cc8 std: xous: add alloc support
Basic alloc support on Xous is supported by the `dlmalloc` crate. This
necessitates bumping the dlmalloc version to 0.2.4.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-08-22 20:25:38 +08:00
Sean Cross
112d101f88 std: process: skip tests on xous
Xous does not yet support spawning processes.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-08-22 20:25:38 +08:00
Sean Cross
0b800577d1 std: fs: skip fs tests on xous
The xous filesystem support is not yet ready for merging.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-08-22 20:25:38 +08:00
Sean Cross
778e8038a2 std: net: skip tests on xous
Network functionality is not yet ready for merging.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-08-22 20:25:38 +08:00
Sean Cross
9afc1e958b std: xous: the basics of os
Add the basics to get the operating system running, including how to
exit the operating system.

Since Xous has no libc, there is no default entrypoint. Add a `_start`
entrypoint to the system-specific os module.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-08-22 20:25:38 +08:00
Sean Cross
7892cfb60e std: xous: add os-specific ffi calls
Xous has no C FFI. Instead, all FFI is done via syscalls that are
specified in Rust. Add these FFI calls to libstd, as well as some of the
currently-supported syscalls.

This enables Rust programs to interact with the Xous operating system
while avoiding adding an extra dependency to libstd.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-08-22 20:25:38 +08:00
Mark Rousskov
c8522adb97 Replace version placeholders with 1.73.0 2023-08-22 06:57:00 -04:00
Ralf Jung
6d65379e7a clarify what you cannot do 2023-08-22 09:00:07 +02:00
Ralf Jung
2cb9d3def2
typos and wording
Co-authored-by: Dan Gohman <dev@sunfishcode.online>
2023-08-22 08:57:38 +02:00
Sean Cross
61cfb1734a libstd: add xous to libstd
Add the `xous` target to libstd. Currently this defers everything to the
`unsupported` target.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-08-22 08:20:04 +08:00
bors
795ade084a Auto merge of #113365 - dima74:diralik/add-deprecated-suggestions, r=workingjubilee
Add `suggestion` for some `#[deprecated]` items

Consider code:
```rust
fn main() {
    let _ = ["a", "b"].connect(" ");
}
```

Currently it shows deprecated warning:
```rust
warning: use of deprecated method `std::slice::<impl [T]>::connect`: renamed to join
 --> src/main.rs:2:24
  |
2 |     let _ = ["a", "b"].connect(" ");
  |                        ^^^^^^^
  |
  = note: `#[warn(deprecated)]` on by default
```

This PR adds `suggestion` for `connect` and some other deprecated items, so the warning will be changed to this:
```rust
warning: use of deprecated method `std::slice::<impl [T]>::connect`: renamed to join
 --> src/main.rs:2:24
  |
2 |     let _ = ["a", "b"].connect(" ");
  |                        ^^^^^^^
  |
  = note: `#[warn(deprecated)]` on by default
help: replace the use of the deprecated method
  |
2 |     let _ = ["a", "b"].join(" ");
  |                        ^^^^
```
2023-08-22 00:02:50 +00:00
Michael Howell
88bd304a10 docs: add alias log1p to ln_1p
This is what the function is called in several other languages:

* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log1p
* https://numpy.org/doc/stable/reference/generated/numpy.log1p.html
* https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/log1p-log1pf-log1pl2?view=msvc-170

It also confused people at URLO: https://users.rust-lang.org/t/64-bit-trigonometry/98599/27
2023-08-21 10:45:47 -07:00
Bruce Mitchener
53245709f6 docs: Add example, reference link for type keyword.
Fixes #114281.
2023-08-21 20:00:43 +07:00
Ralf Jung
0188b9cbb4 try to clarify wording 2023-08-21 13:54:03 +02:00
Dmitry Murzin
07b57f9a7a
Add suggestion for some #[deprecated] items 2023-08-21 12:51:51 +03:00
ShE3py
f8a2f31ae4
Add data race test to std::env::{get, set} 2023-08-20 21:50:45 +02:00
Matthias Krüger
2bca4b5913
Rollup merge of #115000 - RalfJung:custom-mir-call, r=compiler-errors,JakobDegen
custom_mir: change Call() terminator syntax to something more readable

I find our current syntax very hard to read -- I cannot even remember the order of arguments, and having the "next block" *before* the actual function call is very counter-intuitive IMO. So I suggest we use `Call(ret_val = function(v), next_block)` instead.

r? `@JakobDegen`
2023-08-20 08:34:05 +02:00
Matthias Krüger
7b66abe5a2
Rollup merge of #114968 - ShE3py:unix-getsetenv-ub, r=thomcc
Fix UB in `std::sys::os::getenv()`

Fixes #114949.

Reduced the loops to 1k iterations (100k was taking way too long), Miri no longer shows any UB.

`@rustbot` label +A-process +C-bug +I-unsound +O-unix
2023-08-20 08:34:03 +02:00
bors
9c699a40cc Auto merge of #113167 - ChAoSUnItY:redundant_explicit_link, r=GuillaumeGomez
rustdoc: Add lint `redundant_explicit_links`

Closes #87799.
- Lint warns by default
- Reworks link parser to cache original link's display text

r? `@jyn514`
2023-08-20 01:04:22 +00:00
Matthias Krüger
d761a5fe11
Rollup merge of #114983 - crlf0710:formatmsg, r=ChrisDenton
Usage zero as language id for `FormatMessageW()`

This switches the language selection from using system language (note that this might be different than application language, typically stored as thread ui language) to use `FormatMessageW` default search strategy, which is `neutral` first, then `thread ui lang`, then `user language`, then `system language`, then `English`. (See https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-formatmessagew)

This allows the Rust program to take more control of `std::io::Error`'s message field, by setting up thread ui language themselves before hand (which many programs already do).
2023-08-20 00:28:32 +02:00
Matthias Krüger
cbcdf7580b
Rollup merge of #114973 - shepmaster:std-provide-value, r=Amanieu
Expose core::error::request_value in std

I think this was simply forgotten in #113464.

/cc ``@waynr``

r? ``@Amanieu``
2023-08-20 00:28:32 +02:00
Matthias Krüger
cad8f8cbff
Rollup merge of #114950 - xfix:inline-cstr-from-ptr, r=cuviper
Inline strlen_rt in CStr::from_ptr

This enables LLVM to optimize this function as if it was strlen (LLVM knows what it does, and can avoid calling it in certain situations) without having to enable std-aware LTO. This is essentially doing what https://github.com/rust-lang/rust/pull/90007 did, except updated for this function being `const`.

Pretty sure it's safe to roll-up, considering last time I did make this change it didn't affect performance (`CStr::from_ptr` isn't really used all that often in Rust code that is checked by rust-perf).
2023-08-20 00:28:31 +02:00
Matthias Krüger
0cc4b55a12
Rollup merge of #114605 - Easyoakland:hash-collection-doc, r=thomcc
Increase clarity about Hash - Eq consistency in HashMap and HashSet docs

As discussed [here](https://users.rust-lang.org/t/what-hapens-if-hash-and-partialeq-dont-match-when-using-hashmap/98052/13) the description of logic errors in `HashMap` and `HashSet` does not explicitly apply to
```text
k1 == k2 -> hash(k1) == hash(k2)
```
but this is likely what is intended.

This PR is a small doc change to correct this.

r? rust-lang/libs
2023-08-20 00:28:31 +02:00
Ralf Jung
7a6346660e custom_mir: change Call() terminator syntax to something more readable 2023-08-19 22:41:33 +02:00
Kevin Reid
3dde25edc4 Correct and expand documentation of handle_alloc_error and set_alloc_error_hook.
Add the following facts:

* `handle_alloc_error` may panic instead of aborting.
* What happens if a hook returns rather than diverging.
* A hook may panic. (This was already demonstrated in an example,
  but not stated in prose.)
* A hook must be sound to call — it cannot assume that it is only
  called by the runtime, since its function pointer can be retrieved by
  safe code.
2023-08-19 13:27:03 -07:00
Charles Lew
4504cc513f Usage zero as language id for FormatMessageW() 2023-08-19 14:32:15 +08:00
Matthias Krüger
8e0a8cdecb
Rollup merge of #114977 - kpreid:modulo, r=thomcc
Add `modulo` and `mod` as doc aliases for `rem_euclid`.

When I was learning Rust I looked for “a modulo function” and couldn’t find one, so thought I had to write my own; it wasn't at all obvious that a function with “rem” in the name was the function I wanted. Hopefully this will save the next learner from that.

However, it does have the disadvantage that the top results in rustdoc for “mod” are now these aliases instead of the Rust keyword, which probably isn't ideal.
2023-08-19 03:27:01 +02:00
Matthias Krüger
8d52b4d2f3
Rollup merge of #114971 - kpreid:trig, r=joshtriplett
Add doc aliases for trigonometry and other f32,f64 methods.

These are common alternate names, usually a less-abbreviated form, for the operation; e.g. `arctan` instead of `atan`. Prompted by <https://users.rust-lang.org/t/64-bit-trigonometry/98599>
2023-08-19 03:27:00 +02:00
Kevin Reid
2c21635382 Add modulo and mod as doc aliases for rem_euclid.
When I was learning Rust I looked for “a modulo function” and couldn’t
find one, so thought I had to write my own; it wasn't at all obvious
that a function with “rem” in the name was the function I wanted.
Hopefully this will save the next learner from that.

However, it does have the disadvantage that the top results in rustdoc
for “mod” are now these aliases instead of the Rust keyword, which
probably isn't ideal.
2023-08-18 12:28:27 -07:00
bors
d06ca0ffaf Auto merge of #114591 - joboet:thread_parking_ordering_fix, r=thomcc
Synchronize with all calls to `unpark` in id-based thread parker

[The documentation for `thread::park`](https://doc.rust-lang.org/nightly/std/thread/fn.park.html#memory-ordering) guarantees that "park synchronizes-with all prior unpark operations". In the id-based thread parking implementation, this is not implemented correctly, as the state variable is reset with a simple store, so there will not be a *synchronizes-with* edge if an `unpark` happens just before the reset. This PR corrects this, replacing the load-check-reset sequence with a single `compare_exchange`.
2023-08-18 19:03:38 +00:00
Jake Goulding
74942daf71 Expose core::error::request_value in std
I think this was simply forgotten in #113464.
2023-08-18 13:06:53 -04:00
Kevin Reid
c353dbd57f Add doc aliases for trigonometry and other f32,f64 methods.
These are common alternate names, usually a less-abbreviated form,
for the operation; e.g. `arctan` instead of `atan`. Prompted by
<https://users.rust-lang.org/t/64-bit-trigonometry/98599>
2023-08-18 08:08:35 -07:00
Kevin Reid
2bccf1e296 Go into more detail about panicking in drop. 2023-08-18 07:48:10 -07:00
ShE3py
83c713bff0
Fix UB in std::sys::os::getenv() 2023-08-18 16:04:53 +02:00
Jorge Aparicio
f58b2548dc QNX: pass a truncated thread name to the OS
The maximum length the thread name can have is `_NTO_THREAD_NAME_MAX`
2023-08-18 14:47:12 +02:00
Ben Schulz
a38ea96825 Remove Drop impl of mpsc Receiver and (Sync)Sender 2023-08-18 14:46:20 +02:00
Kyle Lin
23c9a4a1ca resolve conflicts 2023-08-18 15:31:58 +08:00
Kyle Lin
15ece93e34 relax redundancy constraint 2023-08-18 15:31:32 +08:00
Kyle Lin
4896fc0f59 resolve conflicts 2023-08-18 15:31:13 +08:00
Kyle Lin
c4afb8a868 resolve conflicts 2023-08-18 15:22:58 +08:00
Kyle Lin
2ec3e297ab tidy doc link 2023-08-18 15:19:23 +08:00
Kyle Lin
f0b2cca185 lint links 2023-08-18 15:19:23 +08:00
Konrad Borowski
e94ba4ae78 Inline strlen_rt in CStr::from_ptr
This enables LLVM to optimize this function as if it was strlen
without having to enable std-aware LTO.
2023-08-18 09:19:09 +02:00
Josh Stone
4f14451d7c
Rollup merge of #114897 - joshtriplett:partial-revert-ok-0, r=m-ou-se
Partially revert #107200

`Ok(0)` is indeed something the caller may interpret as an error, but
that's the *correct* thing to return if the writer can't accept any more
bytes.
2023-08-17 15:40:08 -07:00
bors
bd138e2ae1 Auto merge of #114799 - RalfJung:less-transmute, r=m-ou-se
avoid transmuting Box when we can just cast raw pointers instead

Always better to avoid a transmute, in particular when the layout assumptions it is making are not clearly documented. :)
2023-08-17 09:09:29 +00:00
Matthias Krüger
503a8fc92d
Rollup merge of #114881 - RalfJung:cstr, r=cuviper
clarify CStr lack of layout guarnatees

Follow-up to https://github.com/rust-lang/rust/pull/114800
r? `@cuviper`
2023-08-17 08:39:22 +02:00
Matthias Krüger
f4cd7a537b
Rollup merge of #114749 - gurry:issue-114722, r=thomcc
Update `mpsc::Sender` doc to reflect that it implements `Sync`

Fixes #114722
2023-08-17 08:39:21 +02:00
Manish Goregaokar
7cea69c9a2
Update library/alloc/src/vec/mod.rs
Co-authored-by: Ralf Jung <post@ralfj.de>
2023-08-16 20:36:21 +00:00
bors
27fb598d51 Auto merge of #114905 - matthiaskrgr:rollup-uxhhr7p, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #113115 (we are migrating to askama)
 - #114784 (Improve `invalid_reference_casting` lint)
 - #114822 (Improve code readability by moving fmt args directly into the string)
 - #114878 (rustc book: make more pleasant to search)
 - #114899 (Add missing Clone/Debug impls to SMIR Trait related tys)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-08-16 19:51:47 +00:00
Manish Goregaokar
6c6875d8ec
Update library/alloc/src/vec/mod.rs
Co-authored-by: Ralf Jung <post@ralfj.de>
2023-08-16 19:50:05 +00:00
Matthias Krüger
2667d853a6
Rollup merge of #114784 - Urgau:many-improve-invalid_reference_casting-lint, r=est31
Improve `invalid_reference_casting` lint

This PR improves the `invalid_reference_casting` lint:
 - by considering an unlimited number of casts instead only const to mut ptr
 - by also considering ptr-to-integer and integer-to-ptr casts
 - by also taking into account [`ptr::cast`](https://doc.rust-lang.org/std/primitive.pointer.html#method.cast), [`ptr::cast`](https://doc.rust-lang.org/std/primitive.pointer.html#method.cast-1) and [`ptr::cast_const`](https://doc.rust-lang.org/std/primitive.pointer.html#method.cast_const)

Most of this improvements comes from skimming Github Code Search result for [`&mut \*.*as \*const`](https://github.com/search?q=lang%3Arust+%2F%26mut+%5C*.*as+%5C*const%2F&type=code)

r? ``@est31`` (maybe)
2023-08-16 20:10:37 +02:00
bors
ce01f4d2e0 Auto merge of #114617 - petrochenkov:docspacing, r=Mark-Simulacrum
proc_macro: Update docs for `Spacing`

Brings the docs more in line with reality
2023-08-16 17:56:14 +00:00
Josh Triplett
5210f482d7 Partially revert #107200
`Ok(0)` is indeed something the caller may interpret as an error, but
that's the *correct* thing to return if the writer can't accept any more
bytes.
2023-08-16 09:00:16 -07:00
Vadim Petrochenkov
176a9392d1 proc_macro: Update docs for Spacing
Brings the docs more in line with reality
2023-08-16 19:00:51 +08:00
Georgii Rylov
9b00e5f06f address comments 2023-08-16 11:21:06 +01:00
Georgii Rylov
42a708083a Fix a pthread_t handle leak #114610 2023-08-16 11:21:05 +01:00
Ralf Jung
3e9679e861 clarify CStr lack of layout guarnatees 2023-08-16 09:37:06 +02:00
Ralf Jung
e7a1e4271d use mem::swap instead of ptr::swap_nonoverlapping 2023-08-16 08:47:06 +02:00
Matthias Krüger
6024ad1a05
Rollup merge of #114871 - schvv31n:fix-link-in-docs, r=scottmcm
Update the link in the docs of `std::intrinsics`

The previous link in that place, https://github.com/rust-lang/miri/blob/master/src/shims/intrinsics.rs, no longer points to an existing file.
2023-08-16 08:43:53 +02:00
Matthias Krüger
8201f0ffda
Rollup merge of #114867 - ttsugriy:ttsugriy-patch-1, r=scottmcm
[nit] Fix a comment typo.
2023-08-16 08:43:53 +02:00
Matthias Krüger
6f27032118
Rollup merge of #114861 - RalfJung:no-effect, r=wesleywiser
fix typo: affect -> effect

I just realized I made a silly typo when writing that comment...
2023-08-16 08:43:52 +02:00
Matthias Krüger
4b2d87d82c
Rollup merge of #114721 - danflapjax:bool-ord-optimization, r=cuviper
Optimizing the rest of bool's Ord implementation

After coming across issue #66780, I realized that the other functions provided by Ord (`min`, `max`, and `clamp`) were similarly inefficient for bool. This change provides implementations for them in terms of boolean operators, resulting in much simpler assembly and faster code.
Fixes issue #114653

[Comparison on Godbolt](https://rust.godbolt.org/z/5nb5P8e8j)

`max` assembly before:
```assembly
example::max:
        mov     eax, edi
        mov     ecx, eax
        neg     cl
        mov     edx, esi
        not     dl
        cmp     dl, cl
        cmove   eax, esi
        ret
```
`max` assembly after:
```assembly
example::max:
        mov     eax, edi
        or      eax, esi
        ret
```
`clamp` assembly before:
```assembly
example:🗜️
        mov     eax, esi
        sub     al, dl
        inc     al
        cmp     al, 2
        jae     .LBB1_1
        mov     eax, edi
        sub     al, sil
        movzx   ecx, dil
        sub     dil, dl
        cmp     dil, 1
        movzx   edx, dl
        cmovne  edx, ecx
        cmp     al, -1
        movzx   eax, sil
        cmovne  eax, edx
        ret
.LBB1_1:
        ; identical assert! code
```
`clamp` assembly after:
```assembly
example:🗜️
        test    edx, edx
        jne     .LBB1_2
        test    sil, sil
        jne     .LBB1_3
.LBB1_2:
        or      dil, sil
        and     dil, dl
        mov     eax, edi
        ret
.LBB1_3:
        ; identical assert! code
```
2023-08-16 08:43:49 +02:00
bors
656ee47db3 Auto merge of #114689 - m-ou-se:stabilize-thread-local-cell-methods, r=thomcc
Stabilize thread local cell methods.

Closes #92122.
2023-08-16 02:37:29 +00:00
bors
b531630f42 Auto merge of #111071 - nyurik:simpler-issue-94005, r=m-ou-se
Cleaner assert_eq! & assert_ne! panic messages

This PR finishes refactoring of the assert messages per #94005. The panic message format change #112849 used to be part of this PR, but has been factored out and just merged. It might be better to keep both changes in the same release once FCP vote completes.

Modify panic message for `assert_eq!`, `assert_ne!`, the currently unstable `assert_matches!`, as well as the corresponding `debug_assert_*` macros.

```rust
assert_eq!(1 + 1, 3);
assert_eq!(1 + 1, 3, "my custom message value={}!", 42);
```

#### Old messages
```plain
thread 'main' panicked at $DIR/main.rs:6:5:
assertion failed: `(left == right)`
  left: `2`,
 right: `3`
```
```plain
thread 'main' panicked at $DIR/main.rs:6:5:
assertion failed: `(left == right)`
  left: `2`,
 right: `3`: my custom message value=42!
```

#### New messages
```plain
thread 'main' panicked at $DIR/main.rs:6:5:
assertion `left == right` failed
  left: 2
 right: 3
```

```plain
thread 'main' panicked at $DIR/main.rs:6:5:
assertion `left == right` failed: my custom message value=42!
  left: 2
 right: 3
```

History of fixing #94005
* #94016 was a lengthy PR that was abandoned
* #111030 was similar, but it stringified left and right arguments, and thus caused compile time performance issues, thus closed
* #112849 factored out the two-line formatting of all panic messages

Fixes #94005

r? `@m-ou-se`
2023-08-15 22:45:57 +00:00
Manish Goregaokar
5bf1bfd784 other elements 2023-08-15 15:00:27 -07:00
Tim Kurdov
e6ab5f72a2
Update the link in the docs of std::intrinsics
The previous link in that place, https://github.com/rust-lang/miri/blob/master/src/shims/intrinsics.rs, no longer points to an existing file.
2023-08-15 22:37:48 +01:00
Yuri Astrakhan
950e3d9989 Cleaner assert_eq! & assert_ne! panic messages
Modify panic message for `assert_eq!`, `assert_ne!`, the currently unstable `assert_matches!`, as well as the corresponding `debug_assert_*` macros.

```rust
assert_eq!(1 + 1, 3);
assert_eq!(1 + 1, 3, "my custom message value={}!", 42);
```

```plain
thread 'main' panicked at $DIR/main.rs:6:5:
assertion failed: `(left == right)`
  left: `2`,
 right: `3`
```
```plain
thread 'main' panicked at $DIR/main.rs:6:5:
assertion failed: `(left == right)`
  left: `2`,
 right: `3`: my custom message value=42!
```

```plain
thread 'main' panicked at $DIR/main.rs:6:5:
assertion `left == right` failed
  left: 2
 right: 3
```

```plain
thread 'main' panicked at $DIR/main.rs:6:5:
assertion `left == right` failed: my custom message value=42!
  left: 2
 right: 3
```

This PR is a simpler subset of the #111030, but it does NOT stringify the original left and right source code assert expressions, thus should be faster to compile.
2023-08-15 16:53:10 -04:00
Taras Tsugrii
785ebd9b21
[nit] Fix a comment typo. 2023-08-15 14:26:14 -05:00
Matthias Krüger
a830834b9f
Rollup merge of #114837 - RalfJung:error_in_core, r=cuviper
add missing feature(error_in_core)

Needed to fix feature gate errors in https://github.com/rust-lang/miri-test-libstd/actions/runs/5862810459/job/15895203359. I don't know how doctests are passing in-tree without this feature gate...
2023-08-15 20:34:25 +02:00
Matthias Krüger
430e2e6772
Rollup merge of #114619 - g0djan:godjan/fix_#114608, r=m-ou-se
Fix pthread_attr_union layout on Wasi

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

Ran the tests as described in https://github.com/rust-lang/rust/blob/master/src/doc/rustc/src/platform-support/wasm32-wasi-preview1-threads.md?plain=1#L125
2023-08-15 20:34:23 +02:00
Matthias Krüger
0587893f6d
Rollup merge of #114588 - ijackson:exit-status-default-2, r=m-ou-se
Improve docs for impl Default for ExitStatus

This addresses a review comment in #106425 (which is on the way to being merged I think).

Some of the other followup work is more complicated so I'm going to do individual MRs.

~~Note this branch is on top of #106425~~
2023-08-15 20:34:23 +02:00
Ralf Jung
e1e6c002d8 fix typo: affect -> effect 2023-08-15 19:30:09 +02:00
bors
c57393e4f8 Auto merge of #114852 - GuillaumeGomez:rollup-vjagxjr, r=GuillaumeGomez
Rollup of 10 pull requests

Successful merges:

 - #114711 (Infer `Lld::No` linker hint when the linker stem is a generic compiler driver)
 - #114772 (Add `{Local}ModDefId` to more strongly type DefIds`)
 - #114800 (std: add some missing repr(transparent))
 - #114820 (Add test for unknown_lints from another file.)
 - #114825 (Upgrade std to gimli 0.28.0)
 - #114827 (Only consider object candidates for object-safe dyn types in new solver)
 - #114828 (Probe when assembling upcast candidates so they don't step on eachother's toes in new solver)
 - #114829 (Separate `consider_unsize_to_dyn_candidate` from other unsize candidates)
 - #114830 (Clean up some bad UI testing annotations)
 - #114831 (Check projection args before substitution in new solver)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-08-15 15:42:47 +00:00
Manish Goregaokar
10fc06fb81
Update library/alloc/src/vec/mod.rs
Co-authored-by: Ralf Jung <post@ralfj.de>
2023-08-15 15:06:06 +00:00
Manish Goregaokar
90642ad679
Update library/alloc/src/vec/mod.rs
Co-authored-by: Ralf Jung <post@ralfj.de>
2023-08-15 15:05:49 +00:00
Ian Jackson
a741a5ad16 Document Default for ExitStatus
This lets us put a version on the impl, too.
2023-08-15 15:17:42 +01:00
bors
4f4dae055b Auto merge of #112387 - clarfonthey:non-panicking-ceil-char-boundary, r=m-ou-se
Don't panic in ceil_char_boundary

Implementing the alternative mentioned in this comment: https://github.com/rust-lang/rust/issues/93743#issuecomment-1579935853

Since `floor_char_boundary` will always work (rounding down to the length of the string is possible), it feels best for `ceil_char_boundary` to not panic either. However, the semantics of "rounding up" past the length of the string aren't very great, which is why the method originally panicked in these cases.

Taking into account how people are using this method, it feels best to simply return the end of the string in these cases, so that the result is still a valid char boundary.
2023-08-15 13:49:24 +00:00
Mara Bos
2f75dd4e19
Fix typo.
Co-authored-by: Josh Stone <cuviper@gmail.com>
2023-08-15 15:11:55 +02:00
Guillaume Gomez
f527d56c08
Rollup merge of #114800 - RalfJung:transparent, r=cuviper
std: add some missing repr(transparent)

For some types we don't want to stably guarantee this, so hide the `repr` from rustdoc. This nice approach was suggested by `@thomcc.`
2023-08-15 14:29:46 +02:00
Ralf Jung
fb4ac63415 clarify that these assumtpions are for us, not all Rust code 2023-08-15 13:39:46 +02:00
Scott McMurray
107cd8e267 Add alignment to the NPO guarantee
As far as I know, this is always true already, but it's not in the text of the Option module docs, so I figured I'd bring this up to FCP it.
2023-08-15 02:37:34 -07:00
Urgau
6933848fbf Add diagnostic items for <*const _>::cast and <*mut _>::cast_const 2023-08-15 10:14:41 +02:00
Ralf Jung
fb07077fa4 add missing feature(error_in_core) 2023-08-15 08:21:41 +02:00
bors
180dffba14 Auto merge of #113658 - Dirreke:csky-unknown-linux-gunabiv2, r=bjorn3
add a csky-unknown-linux-gnuabiv2 target

This is the rustc side changes to support csky based Linux target(`csky-unknown-linux-gnuabiv2`).

Tier 3 policy:

> A tier 3 target must have a designated developer or developers (the "target maintainers") on record to be CCed when issues arise regarding the target. (The mechanism to track and CC such developers may evolve over time.)

I pledge to do my best maintaining it.

> Targets must use naming consistent with any existing targets; for instance, a target for the same CPU or OS as an existing Rust target should use the same name for that CPU or OS. Targets should normally use the same names and naming conventions as used elsewhere in the broader ecosystem beyond Rust (such as in other toolchains), unless they have a very good reason to diverge. Changing the name of a target can be highly disruptive, especially once the target reaches a higher tier, so getting the name right is important even for a tier 3 target.

This `csky`  section is the arch name and the `unknown-linux` section is the same as other linux target, and `gnuabiv2` is from the  cross-compile toolchain of  `gcc`

> Target names should not introduce undue confusion or ambiguity unless absolutely necessary to maintain ecosystem compatibility. For example, if the name of the target makes people extremely likely to form incorrect beliefs about what it targets, the name should be changed or augmented to disambiguate it.

I think the explanation in platform support doc is enough to make this aspect clear.

> Tier 3 targets may have unusual requirements to build or use, but must not create legal issues or impose onerous legal terms for the Rust project or for Rust developers or users.

It's using open source tools only.

> The target must not introduce license incompatibilities.

No new license

> Anything added to the Rust repository must be under the standard Rust license (MIT OR Apache-2.0).

Understood.

> The target must not cause the Rust tools or libraries built for any other host (even when supporting cross-compilation to the target) to depend on any new dependency less permissive than the Rust licensing policy. This applies whether the dependency is a Rust crate that would require adding new license exceptions (as specified by the tidy tool in the rust-lang/rust repository), or whether the dependency is a native library or binary. In other words, the introduction of the target must not cause a user installing or running a version of Rust or the Rust tools to be subject to any new license requirements.

There are no new dependencies/features required.

> Compiling, linking, and emitting functional binaries, libraries, or other code for the target (whether hosted on the target itself or cross-compiling from another target) must not depend on proprietary (non-FOSS) libraries. Host tools built for the target itself may depend on the ordinary runtime libraries supplied by the platform and commonly used by other applications built for the target, but those libraries must not be required for code generation for the target; cross-compilation to the target must not require such libraries at all. For instance, rustc built for the target may depend on a common proprietary C runtime library or console output library, but must not depend on a proprietary code generation library or code optimization library. Rust's license permits such combinations, but the Rust project has no interest in maintaining such combinations within the scope of Rust itself, even at tier 3.

As previously said it's using open source tools only.

> "onerous" here is an intentionally subjective term. At a minimum, "onerous" legal/licensing terms include but are not limited to: non-disclosure requirements, non-compete requirements, contributor license agreements (CLAs) or equivalent, "non-commercial"/"research-only"/etc terms, requirements conditional on the employer or employment of any particular Rust developers, revocable terms, any requirements that create liability for the Rust project or its developers or users, or any requirements that adversely affect the livelihood or prospects of the Rust project or its developers or users.

There are no such terms present/

> Neither this policy nor any decisions made regarding targets shall create any binding agreement or estoppel by any party. If any member of an approving Rust team serves as one of the maintainers of a target, or has any legal or employment requirement (explicit or implicit) that might affect their decisions regarding a target, they must recuse themselves from any approval decisions regarding the target's tier status, though they may otherwise participate in discussions.

I'm not the reviewer here.

> This requirement does not prevent part or all of this policy from being cited in an explicit contract or work agreement (e.g. to implement or maintain support for a target). This requirement exists to ensure that a developer or team responsible for reviewing and approving a target does not face any legal threats or obligations that would prevent them from freely exercising their judgment in such approval, even if such judgment involves subjective matters or goes beyond the letter of these requirements.

I'm not the reviewer here.

> Tier 3 targets should attempt to implement as much of the standard libraries as possible and appropriate (core for most targets, alloc for targets that can support dynamic memory allocation, std for targets with an operating system or equivalent layer of system-provided functionality), but may leave some code unimplemented (either unavailable or stubbed out as appropriate), whether because the target makes it impossible to implement or challenging to implement. The authors of pull requests are not obligated to avoid calling any portions of the standard library on the basis of a tier 3 target not implementing those portions.

It supports for std

> The target must provide documentation for the Rust community explaining how to build for the target, using cross-compilation if possible. If the target supports running binaries, or running tests (even if they do not pass), the documentation must explain how to run such binaries or tests for the target, using emulation if possible or dedicated hardware if necessary.

I have added the documentation, and I think it's clear.

> Tier 3 targets must not impose burden on the authors of pull requests, or other developers in the community, to maintain the target. In particular, do not post comments (automated or manual) on a PR that derail or suggest a block on the PR based on a tier 3 target. Do not send automated messages or notifications (via any medium, including via `@)` to a PR author or others involved with a PR regarding a tier 3 target, unless they have opted into such messages.

Understood.

> Backlinks such as those generated by the issue/PR tracker when linking to an issue or PR are not considered a violation of this policy, within reason. However, such messages (even on a separate repository) must not generate notifications to anyone involved with a PR who has not requested such notifications.

Understood.

> Patches adding or updating tier 3 targets must not break any existing tier 2 or tier 1 target, and must not knowingly break another tier 3 target without approval of either the compiler team or the maintainers of the other tier 3 target.

I believe I didn't break any other target.

> In particular, this may come up when working on closely related targets, such as variations of the same architecture with different features. Avoid introducing unconditional uses of features that another variation of the target may not have; use conditional compilation or runtime detection, as appropriate, to let each target run code supported by that target.

I think there are no such problems in this PR.
2023-08-14 21:53:27 +00:00
Ralf Jung
fe1a034f16 actually this doesn't even affect doctests. nice. 2023-08-14 22:55:29 +02:00
bors
4cea2bc339 Auto merge of #113464 - waynr:remove-provider-trait, r=Amanieu
core/any: remove Provider trait, rename Demand to Request

This touches on two WIP features:

* `error_generic_member_access`
  * tracking issue: https://github.com/rust-lang/rust/issues/99301
  * RFC (WIP): https://github.com/rust-lang/rfcs/pull/2895
* `provide_any`
  * tracking issue: https://github.com/rust-lang/rust/issues/96024
  * RFC: https://github.com/rust-lang/rfcs/pull/3192

The changes in this PR are intended to address libs meeting feedback summarized by `@Amanieu` in https://github.com/rust-lang/rust/issues/96024#issuecomment-1554773172

The specific items this PR addresses so far are:

> We feel that the names "demand" and "request" are somewhat synonymous and would like only one of those to be used for better consistency.

I went with `Request` here since it sounds nicer, but I'm mildly concerned that at first glance it could be confused with the use of the word in networking context.

> The Provider trait should be deleted and its functionality should be merged into Error. We are happy to only provide an API that is only usable with Error. If there is demand for other uses then this can be provided through an external crate.

The net impact this PR has is that examples which previously looked like
```
    core::any::request_ref::<String>(&err).unwramp()
```

now look like
```
    (&err as &dyn core::error::Error).request_value::<String>().unwrap()
```

These are methods that based on the type hint when called return an `Option<T>` of that type. I'll admit I don't fully understand how that's done, but it involves `core::any::tags::Type` and `core::any::TaggedOption`, neither of which are exposed in the public API, to construct a `Request` which is then passed to the `Error.provide` method.

Something that I'm curious about is whether or not they are essential to the use of `Request` types (prior to this PR referred to as `Demand`) and if so does the fact that they are kept private imply that `Request`s are only meant to be constructed privately within the standard library? That's what it looks like to me.

These methods ultimately call into code that looks like:
```
/// Request a specific value by tag from the `Error`.
fn request_by_type_tag<'a, I>(err: &'a (impl Error + ?Sized)) -> Option<I::Reified>
where
    I: tags::Type<'a>,
{
    let mut tagged = core::any::TaggedOption::<'a, I>(None);
    err.provide(tagged.as_request());
    tagged.0
}
```

As far as the `Request` API is concerned, one suggestion I would like to make is that the previous example should look more like this:
```
/// Request a specific value by tag from the `Error`.
fn request_by_type_tag<'a, I>(err: &'a (impl Error + ?Sized)) -> Option<I::Reified>
where
    I: tags::Type<'a>,
{
    let tagged_request = core::any::Request<I>::new_tagged();
    err.provide(tagged_request);
    tagged.0
}
```
This makes it possible for anyone to construct a `Request` for use in their own projects without exposing an implementation detail like `TaggedOption` in the API surface.

Otherwise noteworthy is that I had to add `pub(crate)` on both `core::any::TaggedOption` and `core::any::tags` since `Request`s now need to be constructed in the `core::error` module. I considered moving `TaggedOption` into the `core::error` module but again I figured it's an implementation detail of `Request` and belongs closer to that.

At the time I am opening this PR, I have not yet looked into the following bit of feedback:

> We took a look at the generated code and found that LLVM is unable to optimize multiple .provide_* calls into a switch table because each call fetches the type id from Erased::type_id separately each time and the compiler doesn't know that these calls all return the same value. This should be fixed.

This is what I'll focus on next while waiting for feedback on the progress so far. I suspect that learning more about the type IDs will help me understand the need for `TaggedOption` a little better.
2023-08-14 18:18:03 +00:00
dirreke
74817b7053 Upgrade Object and related deps 2023-08-14 23:05:45 +08:00
Dirreke
d16409fe22 add a csky-unknown-linux-gnuabiv2 target 2023-08-14 23:02:36 +08:00
Ralf Jung
e9eca7cda4 reference-counting analogy 2023-08-14 16:53:08 +02:00
Ralf Jung
b4714a8f00 explain why we can mutate the FPU control word 2023-08-14 16:10:56 +02:00
Ralf Jung
85e6e82f93 reword the paragraph on file description ownership 2023-08-14 13:55:16 +02:00
Ralf Jung
03c28d5626 don't link to RFCs, they are not up-to-date docs 2023-08-14 13:28:51 +02:00
Ralf Jung
f887f5a9c6 std: add some missing repr(transparent) 2023-08-14 10:40:59 +02:00
Ralf Jung
f2172ea4e2 avoid transmuting Box when we can just cast raw pointers instead 2023-08-14 10:15:25 +02:00
Ralf Jung
26cfd211fb simplify is_nonoverlapping a bit 2023-08-14 09:53:53 +02:00
Ralf Jung
4cb4013464 make Cell::swap panic if the Cells partially overlap 2023-08-14 09:49:33 +02:00
Ralf Jung
b9c15c5d3b clarify safety documentation of ptr::swap and ptr::copy 2023-08-14 09:40:09 +02:00
Ralf Jung
4da0811513 mention /proc/self/fd with /proc/self/mem 2023-08-14 09:16:08 +02:00
Ralf Jung
55f18beddd wording; and explain some of the possible consequences of violating io-safety 2023-08-14 08:59:37 +02:00
Ralf Jung
334a54cd83 typos 2023-08-14 08:50:32 +02:00
Ralf Jung
b2b225e1d1 sync the various FromRawFd trait docs, and remove 'valid' 2023-08-14 08:49:40 +02:00
ltdk
ef3305449b Implement Step for AsciiChar 2023-08-14 01:34:47 -04:00
wayne warren
a646b39965 core/any: remove Provider trait
* remove `impl Provider for Error`
* rename `Demand` to `Request`
* update docstrings to focus on the conceptual API provided by `Request`
* move `core::any::{request_ref, request_value}` functions into `core::error`
* move `core::any::tag`, `core::any::Request`, an `core::any::TaggedOption` into `core::error`
* replace `provide_any` feature name w/ `error_generic_member_access`
* move `core::error::request_{ref,value} tests into core::tests::error module
* update unit and doc tests
2023-08-13 13:07:53 -06:00
Guillaume Gomez
99144c3f04
Rollup merge of #114069 - cuviper:profiler-path, r=Mark-Simulacrum
Allow using external builds of the compiler-rt profile lib

This changes the bootstrap config `target.*.profiler` from a plain bool
to also allow a string, which will be used as a path to the pre-built
profiling runtime for that target. Then `profiler_builtins/build.rs`
reads that in a `LLVM_PROFILER_RT_LIB` environment variable.
2023-08-13 21:00:45 +02:00
Guillaume Gomez
7f787e397c
Rollup merge of #94667 - frank-king:feature/iter_map_windows, r=Mark-Simulacrum
Add `Iterator::map_windows`

Tracking issue:  #87155.

This is inherited from the old PR  #82413.

Unlike #82413, this PR implements the `MapWindows` to be lazy: only when pulling from the outer iterator, `.next()` of the inner iterator will be called.

## Implementaion Steps
- [x] Implement `MapWindows` to keep the iterators' [*Laziness*](https://doc.rust-lang.org/std/iter/index.html#laziness) contract.
- [x] Fix the known bug of memory access error.
- [ ] Full specialization of iterator-related traits for `MapWindows`.
    - [x] `Iterator::size_hint`,
    - [x] ~`Iterator::count`~,
    - [x] `ExactSizeIterator` (when `I: ExactSizeIterator`),
    - [x] ~`TrustedLen` (when `I: TrustedLen`)~,
    - [x] `FusedIterator`,
    - [x] ~`Iterator::advance_by`~,
    - [x] ~`Iterator::nth`~,
    - [ ] ...
- [ ] More tests and docs.

## Unresolved Questions:
- [ ] Is there any more iterator-related traits should be specialized?
- [ ] Is the double-space buffer worth?
- [ ] Should there be `rmap_windows` or something else?
- [ ] Taking GAT for consideration, should the mapper function be `FnMut(&[I::Item; N]) -> R` or something like `FnMut(ArrayView<'_, I::Item, N>) -> R`? Where `ArrayView` is mentioned in https://github.com/rust-lang/generic-associated-types-initiative/issues/2.
    - It can save memory, only the same size as the array window is needed,
    - It is more efficient, which requires less data copies,
    - It is possibly compatible with the GATified version of `LendingIterator::windows`.
    - But it prevents the array pattern matching like `iter.map_windows(|_arr: [_; N]| ())`, unless we extend the array pattern to allow matching the `ArrayView`.
2023-08-13 21:00:44 +02:00
Ralf Jung
a473e95786 add more explicit I/O safety documentation 2023-08-13 15:07:57 +02:00
Manish Goregaokar
3809c091fc aliasing guarantee 2023-08-12 09:19:23 -07:00
Matthias Krüger
8a997b159c
Rollup merge of #114132 - tamird:better-env-debug-impls, r=Amanieu
Better Debug for Vars and VarsOs

Display actual vars instead of two dots.

The same was done for Args and ArgsOs in 275f9a04af.
2023-08-12 12:06:35 +02:00
Jubilee Young
90dc2f839b Name what ln_gamma does
The previous description omitted some important details.
2023-08-12 02:13:41 -07:00
Jacob Pratt
62ca5aa8e4
Remove unnecessary feature gates 2023-08-12 00:21:04 -04:00
Jacob Pratt
7f08376964
Partially stabilize #![feature(int_roundings)] 2023-08-12 00:12:11 -04:00
Gurinder Singh
0af9dfc0a3 Update Sender documentation for Sync 2023-08-12 09:20:56 +05:30
bors
b08dd92552 Auto merge of #114720 - scottmcm:better-sub, r=workingjubilee
Tell LLVM that the negation in `<*const T>::sub` cannot overflow

Today it's just `sub` <https://rust.godbolt.org/z/8EzEPnMr5>; with this PR it's `sub nsw`.
2023-08-11 23:40:33 +00:00
bors
08691f0c92 Auto merge of #113432 - klensy:ms-cut-backtrace, r=ChrisDenton
reduce deps for windows-msvc targets for backtrace

(eventually) mirrors https://github.com/rust-lang/backtrace-rs/pull/543

Some dependencies of backtrace don't used on windows-msvc targets, so exclude them:

    miniz_oxide (+ adler)
    addr2line (+ gimli)
    object (+ memchr)

This saves about 30kb of std.dll + 17.5mb of rlibs
2023-08-11 12:07:04 +00:00
Scott McMurray
ab6e2bc3d0 Tell LLVM that the negation in <*const T>::sub cannot overflow
Today it's just `sub` <https://rust.godbolt.org/z/8EzEPnMr5>; with this PR it's `sub nsw`.
2023-08-10 23:00:39 -07:00
danflapjax
b75351e98e
Optimized implementations of max, min, and clamp for bool 2023-08-10 22:38:30 -07:00
Michael Goulet
9546d7140e
Rollup merge of #114402 - tifv:tifv-fix-rc-doc, r=cuviper
Fix documentation of impl From<Vec<T>> for Rc<[T]>

The example in the documentation of `impl From<Vec<T>> for <Rc<[T]>` is irrelevant (likely was copied from `impl From<Box<T>> for <Rc<T>`). I suggest taking corresponding example from the documentation of `Arc` and replacing `Arc` with `Rc`.
2023-08-10 21:17:37 -07:00
Michael Goulet
5da7f36485
Rollup merge of #114359 - ttsugriy:barrier-simpl, r=cuviper
[library/std] Replace condv while loop with `cvar.wait_while`.

`wait_while` takes care of spurious wake-ups in centralized place, reducing chances for mistakes and potential future optimizations (who knows, maybe in future there will be no spurious wake-ups? :)
2023-08-10 21:17:37 -07:00
Michael Goulet
3791f6dded
Rollup merge of #114257 - rytheo:linked-list-avoid-unique, r=cuviper
Avoid using `ptr::Unique` in `LinkedList` code

Addresses a [comment](https://github.com/rust-lang/rust/pull/103093#discussion_r1268506747) by `@RalfJung` about avoiding use of `core::ptr::Unique` in the standard library.
2023-08-10 21:17:36 -07:00
Michael Goulet
0c241e6bdb
Rollup merge of #114194 - thomcc:flushinline, r=cuviper
Inline trivial (noop) flush calls

At work I noticed that `writer.flush()?` didn't get optimized away in cases where the flush is obviously a no-op, which I had expected (well, desired).

I went through and added `#[inline]` to a bunch of cases that were obviously noops, or delegated to ones that were obviously noops. I omitted platforms I don't have access to (some tier3). I didn't do this very scientifically, in cases where it was non-obvious I left `#[inline]` off.
2023-08-10 21:17:36 -07:00
Frank King
97c953f561 Add Iterator::map_windows
This is inherited from the old PR.

This method returns an iterator over mapped windows of the starting
iterator. Adding the more straight-forward `Iterator::windows` is not
easily possible right now as the items are stored in the iterator type,
meaning the `next` call would return references to `self`. This is not
allowed by the current `Iterator` trait design. This might change once
GATs have landed.

The idea has been brought up by @m-ou-se here:
https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Iterator.3A.3A.7Bpairwise.2C.20windows.7D/near/224587771

Co-authored-by: Lukas Kalbertodt <lukas.kalbertodt@gmail.com>
2023-08-11 07:26:51 +08:00
Mara Bos
dc3cbc1e56 Stabilize thread local cell methods. 2023-08-10 17:33:40 +02:00
Matthias Krüger
128cc06515
Rollup merge of #114377 - Enselic:test_get_dbpath_for_term-utf-8, r=thomcc
test_get_dbpath_for_term(): handle non-utf8 paths (fix FIXME)

Removes a FIXME for #9639

Part of #44366 which is E-help-wanted

The remaining two FIXMEs for #9639 are considerably more complicated, so I will create separate PRs for them.
2023-08-09 22:59:58 +02:00
Esteban Kuber
9de1a472b6 Suggest using Arc on !Send/!Sync types 2023-08-09 14:04:10 +00:00
bors
19a647d6d8 Auto merge of #114646 - matthiaskrgr:rollup-xf7qnmn, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #113939 (open pidfd in child process and send to the parent via SOCK_SEQPACKET+CMSG)
 - #114548 (Migrate a trait selection error to use diagnostic translation)
 - #114606 (fix: not insert missing lifetime for `ConstParamTy`)
 - #114634 (Mention riscv64-linux-android support in Android documentation)
 - #114638 (Remove old RPITIT tests (revisions were removed))
 - #114641 (Rename copying `ascii::Char` methods from `as_` to `to_`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-08-09 05:50:12 +00:00
Matthias Krüger
83da317e07
Rollup merge of #114641 - kupiakos:ascii-char-to-not-as, r=scottmcm
Rename copying `ascii::Char` methods from `as_` to `to_`

Tracking issue: #110998.

The [API guidelines][naming] describe `as_` as used for borrowed -> borrowed operations, and `to_` for
owned -> owned operations on `Copy` types.

[naming]: https://rust-lang.github.io/api-guidelines/naming.html
2023-08-09 06:32:27 +02:00
Matthias Krüger
3feab00093
Rollup merge of #113939 - the8472:pidfd-from-child, r=Mark-Simulacrum
open pidfd in child process and send to the parent via SOCK_SEQPACKET+CMSG

This avoids using `clone3` when a pidfd is requested while still getting it in a 100% race-free manner by passing it up from the child process.
This should solve most concerns in #82971
2023-08-09 06:32:24 +02:00
bors
8838c73e86 Auto merge of #99747 - ankane:float_gamma, r=workingjubilee
Add gamma function to f32 and f64

Adds the [gamma function](https://en.wikipedia.org/wiki/Gamma_function) to `f32` and `f64` (`tgamma` and `tgammaf` from C).

Refs:
- https://github.com/rust-lang/rfcs/issues/864
- https://github.com/rust-lang/rust/issues/18271
2023-08-09 03:14:31 +00:00
Alyssa Haroldsen
a22b9bf2e6 Rename copying ascii::Char methods from as_ to to_
Tracking issue: #110998.

The [API guidelines][naming] describe `as` as used for
borrowed -> borrowed operations, and `to_` for
owned -> owned operations on `Copy` types.

[naming]: https://rust-lang.github.io/api-guidelines/naming.html
2023-08-08 16:03:47 -07:00
The 8472
8d349c1598 open pidfd in child process and send to the parent via SOCK_SEQPACKET+CMSG
This is a 100% race-free way to obtain a child's pidfd while
avoiding `clone3`.
2023-08-08 22:05:32 +02:00
Matthias Krüger
b3550891e8
Rollup merge of #106425 - ijackson:exit-status-default, r=dtolnay
Make ExitStatus implement Default

And, necessarily, make it inhabited even on platforms without processes.

I noticed while preparing https://github.com/rust-lang/rfcs/pull/3362 that there was no way for anyone to construct an `ExitStatus`.

This would be insta-stable so needs an FCP.
2023-08-08 21:44:41 +02:00
Georgii Rylov
971427e5f1 Fix #114608 2023-08-08 11:07:48 +01:00
Easyoakland
98e434a01e Increase clarity about Hash - Eq consistency in HashMap and HashSet docs 2023-08-07 20:31:49 -06:00
Andrew Kane
a75e2284fb Bump compiler_builtins to 0.1.100 2023-08-07 16:38:09 -07:00
Arthur Cohen
f1776250eb core: Remove #[macro_export] from debug_assert_matches
The `debug_assert_matches` macro was marked with the `#[macro_export]` attribute,
despite being a declarative macro/macro 2.0, for which the exporting rules are similar
to items. In fact, `#[macro_export]` on a decl macro has no effect on its visibility.
2023-08-07 21:13:55 +02:00
joboet
fd9fcc580a
std: synchronize with all calls to unpark in id-based thread parker 2023-08-07 19:13:34 +02:00
Tamir Duberstein
35c0c03a3c
Better Debug for Vars and VarsOs
Display actual vars instead of two dots.

The same was done for Args and ArgsOs in 275f9a04af.
2023-08-07 12:18:27 -04:00
Matthias Krüger
06daa9e263
Rollup merge of #114562 - Trolldemorted:thiscall, r=oli-obk
stabilize abi_thiscall

Closes https://github.com/rust-lang/rust/issues/42202, stabilizing the use of the "thiscall" ABI.

FCP was substituted by a poll, and the poll has been accepted.
2023-08-07 16:47:57 +02:00
Ian Jackson
c4bc16c5d6 Adjust the duration_since(UNIX_EPOCH) docs
* Make the description primary, not the definition in terms of time_t
 * Remove the list of Internet protocols

As per
  https://github.com/rust-lang/rust/pull/109660#pullrequestreview-1414613118
2023-08-07 15:45:47 +01:00
Ian Jackson
1f1d49a2b7 impl Default for ExitStatus 2023-08-07 15:24:55 +01:00
Ian Jackson
36295fad12 std::process: impl From<io::Stdout> (etc.) for Stdio
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2023-08-07 15:18:58 +01:00
Ian Jackson
1bab95bf7f std::process (windows): Implement From<io::Stdout> etc. for imp::Stdio
This involves a new variant `imp;::Stdio::InheritSpecific`.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2023-08-07 15:18:58 +01:00
Ian Jackson
deda7d3301 std::process (windows): refactor Stdio::to_handle slightly
We're going to want to reuse this bit of code.
2023-08-07 15:18:58 +01:00
Ian Jackson
fb7f1a8127 std::process (unix): Implement From<io::Stdout> etc. for imp::Stdio
This involves adding a new variant `imp::Stdio::StaticFd`.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2023-08-07 15:18:58 +01:00
Benedikt Radtke
3f3262e592 stabilize abi_thiscall 2023-08-07 14:11:03 +02:00
Matthias Krüger
cbe2522652
Rollup merge of #114382 - scottmcm:compare-bytes-intrinsic, r=cjgillot
Add a new `compare_bytes` intrinsic instead of calling `memcmp` directly

As discussed in #113435, this lets the backends be the place that can have the "don't call the function if n == 0" logic, if it's needed for the target.  (I didn't actually *add* those checks, though, since as I understood it we didn't actually need them on known targets?)

Doing this also let me make it `const` (unstable), which I don't think `extern "C" fn memcmp` can be.

cc `@RalfJung` `@Amanieu`
2023-08-07 05:29:12 +02:00
Matthias Krüger
f5df519fe7
Rollup merge of #114365 - tshepang:patch-6, r=Mark-Simulacrum
str.rs: remove "Basic usage" text

Only one example is given
2023-08-07 05:29:12 +02:00
Matthias Krüger
59d2a4b1e5
Rollup merge of #114362 - tshepang:patch-1, r=Mark-Simulacrum
string.rs: remove "Basic usage" text

Only a single example is given
2023-08-07 05:29:11 +02:00
Matthias Krüger
bab20b410e
Rollup merge of #98935 - kellerkindt:option_retain, r=Mark-Simulacrum
Implement `Option::take_if`

Tracking issue: #98934
ACP: rust-lang/libs-team#70 [accepted]
2023-08-07 05:29:09 +02:00
Scott McMurray
502af03445 Add a new compare_bytes intrinsic instead of calling memcmp directly 2023-08-06 15:47:40 -07:00
Matthias Krüger
3d1c36e917
Rollup merge of #114519 - the8472:dirent-offset-of, r=dtolnay
use offset_of! to calculate dirent64 field offsets

r? `@dtolnay`
2023-08-06 17:26:30 +02:00
est31
8faac74e54 Remove ptr_from_mut diagnostic item
It was added by #113657 for its purposes.
Now it is not used any more, remove it,
as we use the attr now.
2023-08-06 00:20:29 +02:00
est31
33970db8c6 Add #[rustc_never_returns_null_ptr] to std functions
Add the attribute to standard library functions that
are guaranteed to never return null pointers, as their
originating data wouldn't allow it.
2023-08-06 00:20:28 +02:00
bors
eb088b8b9d Auto merge of #111200 - a1phyr:spec_sized_iterators, r=the8472
Optimize `Iterator` implementation for `&mut impl Iterator + Sized`

This adds a specialization trait to forward `fold`, `try_fold`,... to the inner iterator where possible
2023-08-05 17:38:26 +00:00
The 8472
20c25d6c31 use offset_of! to calculate dirent64 field offsets 2023-08-05 15:53:09 +02:00
Matthias Krüger
bedadffe60
Rollup merge of #114029 - Enselic:clone-doc, r=scottmcm
Explain more clearly why `fn() -> T` can't be `#[derive(Clone)]`

Closes #73480

The derived impls were generated with `rustc -Z unpretty=expanded main.rs` and the raw output is:

```rust
struct Generate<T>(fn() -> T);
#[automatically_derived]
impl<T: ::core::marker::Copy> ::core::marker::Copy for Generate<T> { }
#[automatically_derived]
impl<T: ::core::clone::Clone> ::core::clone::Clone for Generate<T> {
    #[inline]
    fn clone(&self) -> Generate<T> {
        Generate(::core::clone::Clone::clone(&self.0))
    }
}
```
2023-08-05 14:00:16 +02:00
David CARLIER
c3116c5045 std/tests: disable ancillary tests on freebsd since the feature itself is. 2023-08-05 12:19:15 +01:00
Ralf Jung
dfee1ba4c4 document our assumptions about symbols provided by the libc 2023-08-04 08:16:41 +02:00
Matthias Krüger
539fecb882
Rollup merge of #114373 - xstaticxgpx:dev, r=the8472
unix/kernel_copy.rs: copy_file_range_candidate allows empty output files

This is for https://github.com/rust-lang/rust/issues/114341

The `meta.len() > 0` condition here is intended for inputs only, ie. when input is in the `/proc` filesystem as documented.

That inaccurately included empty output files which are then shunted to the sendfile() routine leading to higher than nescessary IO util in some cases, specifically with CoW filesystems like btrfs.

Simply, determine what is input or output given the passed boolean.
2023-08-04 07:25:46 +02:00
xstaticxgpx
2232fe8da3 unix/kernel_copy.rs: copy_file_range_candidate allows empty output files
This is for https://github.com/rust-lang/rust/issues/114341

The `meta.len() > 0` condition here is intended for inputs only,
ie. when input is in the `/proc` filesystem as documented.

That inaccurately included empty output files which are then shunted to
the sendfile() routine leading to higher than nescessary IO util in some
cases, specifically with CoW filesystems like btrfs.

Further, `NoneObtained` is not relevant in this context, so remove it.

Simply, determine what is input or output given the passed enum Unit.
2023-08-03 19:27:45 -04:00
bors
1fe384649a Auto merge of #108955 - Nilstrieb:dont-use-me-pls, r=oli-obk
Add `internal_features` lint

Implements https://github.com/rust-lang/compiler-team/issues/596

Also requires some more test blessing for codegen tests etc

`@jyn514` had the idea of just `allow`ing the lint by default in the test suite. I'm not sure whether this is a good idea, but it's definitely one worth considering. Additional input encouraged.
2023-08-03 22:58:02 +00:00
Matthias Krüger
7518ae566e
Rollup merge of #113657 - Urgau:expand-incorrect_fn_null_check-lint, r=cjgillot
Expand, rename and improve `incorrect_fn_null_checks` lint

This PR,

 - firstly, expand the lint by now linting on references
 - secondly, it renames the lint `incorrect_fn_null_checks` -> `useless_ptr_null_checks`
 - and thirdly it improves the lint by catching `ptr::from_mut`, `ptr::from_ref`, as well as `<*mut _>::cast` and `<*const _>::cast_mut`

Fixes https://github.com/rust-lang/rust/issues/113601
cc ```@est31```
2023-08-03 17:29:06 +02:00
Nilstrieb
5830ca216d Add internal_features lint
It lints against features that are inteded to be internal to the
compiler and standard library. Implements MCP #596.

We allow `internal_features` in the standard library and compiler as those
use many features and this _is_ the standard library from the "internal to the compiler and
standard library" after all.

Marking some features as internal wasn't exactly the most scientific approach, I just marked some
mostly obvious features. While there is a categorization in the macro,
it's not very well upheld (should probably be fixed in another PR).

We always pass `-Ainternal_features` in the testsuite
About 400 UI tests and several other tests use internal features.
Instead of throwing the attribute on each one, just always allow them.
There's nothing wrong with testing internal features^^
2023-08-03 14:50:50 +02:00
July Tikhonov
f1fc871ce6
Fix documentation of Rc as From<Vec<T>> 2023-08-03 10:44:23 +03:00
Michael Watzko
5419abd400 Implement Option::take_if 2023-08-03 09:34:18 +02:00
bors
d8bbef50bb Auto merge of #113220 - tgross35:cstr-bytes-docs, r=workingjubilee
Clarify documentation for `CStr`

* Better differentiate summaries for `from_bytes_until_nul` and `from_bytes_with_nul`
* Add some links where they may be helpful
2023-08-03 02:40:19 +00:00
Martin Nordholts
d1940912e5 test_get_dbpath_for_term(): handle non-utf8 paths 2023-08-02 20:57:05 +02:00
Martin Nordholts
54a6bb7f0d test_get_dbpath_for_term(): Use assert_eq!()
For better failure messages.
2023-08-02 20:57:05 +02:00
onestacked
dc4e0267f0 Document soundness of Integer -> Pointer -> Integer conversions in const contexts.
see this [zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/Soundness.20of.20Integer.20-.3E.20Pointer.20-.3E.20Integer.20conversions)
2023-08-02 12:05:39 +00:00
bors
d170833431 Auto merge of #112431 - Urgau:cast_ref_to_mut_improvments, r=Nilstrieb
Improve `invalid_reference_casting` lint

This PR is a follow-up to https://github.com/rust-lang/rust/pull/111567 and https://github.com/rust-lang/rust/pull/113422.

This PR does multiple things:
 - First it adds support for deferred de-reference, the goal is to support code like this, where the casting and de-reference are not done on the same expression
    ```rust
    let myself = self as *const Self as *mut Self;
    *myself = Self::Ready(value);
    ```
 - Second it does not lint anymore on SB/TB UB code by only checking assignments (`=`, `+=`, ...) and creation of mutable references `&mut *`
 - Thirdly it greatly improves the diagnostics in particular for cast from `&mut` to `&mut` or assignments
 - ~~And lastly it renames the lint from `cast_ref_to_mut` to `invalid_reference_casting` which is more consistent with the ["rules"](https://github.com/rust-lang/rust-clippy/issues/2845) and also more consistent with what the lint checks~~ *https://github.com/rust-lang/rust/pull/113422*

This PR is best reviewed commit by commit.

r? compiler
2023-08-02 11:25:13 +00:00
Tshepang Mbambo
60e43bcf57
str.rs: remove "Basic usage" text
Only one example is given
2023-08-02 12:14:43 +02:00
Tshepang Mbambo
e47cd2f250
string.rs: remove "Basic usage" text
Only a single example is given
2023-08-02 11:17:57 +02:00
Trevor Gross
c94dc72a1c Clarify documentation for CStr
* Better differentiate summaries for `from_bytes_until_nul` and
  `from_bytes_with_nul`
* Add some links where they may be helpful
2023-08-02 03:58:51 -04:00
Taras Tsugrii
a090e97f68 [library/std] Replace condv while loop with cvar.wait_while.
`wait_while` takes care of spurious wake-ups in centralized place,
reducing chances for mistakes and potential future optimizations
(who knows, maybe in future there will be no spurious wake-ups? :)
2023-08-01 22:10:40 -07:00
bors
aa8462b6df Auto merge of #112922 - g0djan:godjan/wasi-threads, r=wesleywiser
WASI threads, implementation of wasm32-wasi-preview1-threads target

This PR adds a target proposed in https://github.com/rust-lang/compiler-team/issues/574 by `@abrown` and implementation of `std:🧵:spawn` for the target `wasm32-wasi-preview1-threads`

### Tier 3 Target Policy
As tier 3 targets, the new targets are required to adhere to [the tier 3 target policy](https://doc.rust-lang.org/nightly/rustc/target-tier-policy.html#tier-3-target-policy) requirements. This section quotes each requirement in entirety and describes how they are met.
> - A tier 3 target must have a designated developer or developers (the "target maintainers") on record to be CCed when issues arise regarding the target. (The mechanism to track and CC such developers may evolve over time.)

See [src/doc/rustc/src/platform-support/wasm32-wasi-preview1-threads.md](https://github.com/rust-lang/rust/pull/112922/files#diff-a48ee9d94f13e12be24eadd08eb47b479c153c340eeea4ef22276d876dfd4f3e).
> - Targets must use naming consistent with any existing targets; for instance, a target for the same CPU or OS as an existing Rust target should use the same name for that CPU or OS. Targets should normally use the same names and naming conventions as used elsewhere in the broader ecosystem beyond Rust (such as in other toolchains), unless they have a very good reason to diverge. Changing the name of a target can be highly disruptive, especially once the target reaches a higher tier, so getting the name right is important even for a tier 3 target.
> - Target names should not introduce undue confusion or ambiguity unless absolutely necessary to maintain ecosystem compatibility. For example, if the name of the target makes people extremely likely to form incorrect beliefs about what it targets, the name should be changed or augmented to disambiguate it.
If possible, use only letters, numbers, dashes and underscores for the name. Periods (.) are known to cause issues in Cargo.

The target is using the same name for $ARCH=wasm32 and $OS=wasi as existing Rust targets. The suffix `preview1` introduced to accurately set expectations because eventually this target will be deprecated and follows [MCP 607](https://github.com/rust-lang/compiler-team/issues/607). The suffix `threads` indicates that it’s an extension that enables threads to the existing target and it follows [MCP 574](https://github.com/rust-lang/compiler-team/issues/574) which describes the rationale behind introducing a separate target.

> - Tier 3 targets may have unusual requirements to build or use, but must not create legal issues or impose onerous legal terms for the Rust project or for Rust developers or users.
> - The target must not introduce license incompatibilities.
> - Anything added to the Rust repository must be under the standard Rust license (MIT OR Apache-2.0).
> - The target must not cause the Rust tools or libraries built for any other host (even when supporting cross-compilation to the target) to depend on any new dependency less permissive than the Rust licensing policy. This applies whether the dependency is a Rust crate that would require adding new license exceptions (as specified by the tidy tool in the rust-lang/rust repository), or whether the dependency is a native library or binary. In other words, the introduction of the target must not cause a user installing or running a version of Rust or the Rust tools to be subject to any new license requirements.
> - Compiling, linking, and emitting functional binaries, libraries, or other code for the target (whether hosted on the target itself or cross-compiling from another target) must not depend on proprietary (non-FOSS) libraries. Host tools built for the target itself may depend on the ordinary runtime libraries supplied by the platform and commonly used by other applications built for the target, but those libraries must not be required for code generation for the target; cross-compilation to the target must not require such libraries at all. For instance, rustc built for the target may depend on a common proprietary C runtime library or console output library, but must not depend on a proprietary code generation library or code optimization library. Rust's license permits such combinations, but the Rust project has no interest in maintaining such combinations within the scope of Rust itself, even at tier 3.
> - "onerous" here is an intentionally subjective term. At a minimum, "onerous" legal/licensing terms include but are not limited to: non-disclosure requirements, non-compete requirements, contributor license agreements (CLAs) or equivalent, "non-commercial"/"research-only"/etc terms, requirements conditional on the employer or employment of any particular Rust developers, revocable terms, any requirements that create liability for the Rust project or its developers or users, or any requirements that adversely affect the livelihood or prospects of the Rust project or its developers or users.

This PR does not introduce any new dependency.
The new target doesn’t support building host tools.
> Tier 3 targets should attempt to implement as much of the standard libraries as possible and appropriate (core for most targets, alloc for targets that can support dynamic memory allocation, std for targets with an operating system or equivalent layer of system-provided functionality), but may leave some code unimplemented (either unavailable or stubbed out as appropriate), whether because the target makes it impossible to implement or challenging to implement. The authors of pull requests are not obligated to avoid calling any portions of the standard library on the basis of a tier 3 target not implementing those portions.

The full standard library is available for this target as it’s an extension to an existing target that has already supported it.
> The target must provide documentation for the Rust community explaining how to build for the target, using cross-compilation if possible. If the target supports running binaries, or running tests (even if they do not pass), the documentation must explain how to run such binaries or tests for the target, using emulation if possible or dedicated hardware if necessary.

Only manual test running is supported at the moment with some tweaks in the test runner codebase. For build and running tests see [src/doc/rustc/src/platform-support/wasm32-wasi-preview1-threads.md](https://github.com/rust-lang/rust/pull/112922/files#diff-a48ee9d94f13e12be24eadd08eb47b479c153c340eeea4ef22276d876dfd4f3e).
> - Neither this policy nor any decisions made regarding targets shall create any binding agreement or estoppel by any party. If any member of an approving Rust team serves as one of the maintainers of a target, or has any legal or employment requirement (explicit or implicit) that might affect their decisions regarding a target, they must recuse themselves from any approval decisions regarding the target's tier status, though they may otherwise participate in discussions.
> - This requirement does not prevent part or all of this policy from being cited in an explicit contract or work agreement (e.g. to implement or maintain support for a target). This requirement exists to ensure that a developer or team responsible for reviewing and approving a target does not face any legal threats or obligations that would prevent them from freely exercising their judgment in such approval, even if such judgment involves subjective matters or goes beyond the letter of these requirements.
> - Tier 3 targets must not impose burden on the authors of pull requests, or other developers in the community, to maintain the target. In particular, do not post comments (automated or manual) on a PR that derail or suggest a block on the PR based on a tier 3 target. Do not send automated messages or notifications (via any medium, including via `@)` to a PR author or others involved with a PR regarding a tier 3 target, unless they have opted into such messages.
> - Backlinks such as those generated by the issue/PR tracker when linking to an issue or PR are not considered a violation of this policy, within reason. However, such messages (even on a separate repository) must not generate notifications to anyone involved with a PR who has not requested such notifications.
> - Patches adding or updating tier 3 targets must not break any existing tier 2 or tier 1 target, and must not knowingly break another tier 3 target without approval of either the compiler team or the maintainers of the other tier 3 target.
> - In particular, this may come up when working on closely related targets, such as variations of the same architecture with different features. Avoid introducing unconditional uses of features that another variation of the target may not have; use conditional compilation or runtime detection, as appropriate, to let each target run code supported by that target.

I acknowledge these requirements and intend to ensure they are met.
2023-08-02 01:01:48 +00:00
Urgau
0b9529cca3 Add diagnostic items for <*const _>::cast and ptr::from_mut 2023-08-01 20:04:01 +02:00
bors
4896daa398 Auto merge of #114331 - matthiaskrgr:rollup-rnrmwcx, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #100455 (Implement RefUnwindSafe for Backtrace)
 - #113428 (coverage: Replace `ExpressionOperandId` with enum `Operand`)
 - #114283 (Use parking lot's rwlock even without parallel-rustc)
 - #114288 (Improve diagnostic for wrong borrow on binary operations)
 - #114296 (interpret: fix alignment handling for Repeat expressions)
 - #114306 ([rustc_data_structures][perf] Simplify base_n::push_str.)
 - #114320 (Cover statements for stable_mir)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-08-01 16:09:13 +00:00
Matthias Krüger
c97af34de1
Rollup merge of #100455 - xfix:backtrace-ref-unwind-safe, r=dtolnay
Implement RefUnwindSafe for Backtrace

Backtrace doesn't have visible mutable state.

See also https://internals.rust-lang.org/t/should-backtrace-be-refunwindsafe/17169?u=xfix
2023-08-01 17:39:09 +02:00
bors
828bdc2c26 Auto merge of #112849 - m-ou-se:panic-message-format, r=thomcc
Change default panic handler message format.

This changes the default panic hook's message format from:

```
thread '{thread}' panicked at '{message}', {location}
```

to

```
thread '{thread}' panicked at {location}:
{message}
```

This puts the message on its own line without surrounding quotes, making it easiser to read. For example:

Before:
```
thread 'main' panicked at 'env variable `IMPORTANT_PATH` should be set by `wrapper_script.sh`', src/main.rs:4:6
```
After:
```
thread 'main' panicked at src/main.rs:4:6:
env variable `IMPORTANT_PATH` should be set by `wrapper_script.sh`
```

---

See this PR by `@nyurik,` which does that for only multi-line messages (specifically because of `assert_eq`): https://github.com/rust-lang/rust/pull/111071

This is the change that does that for *all* panic messages.
2023-08-01 14:15:09 +00:00
Matthias Krüger
14a5dc52c7
Rollup merge of #111081 - mattfbacon:master, r=workingjubilee
impl SliceIndex<str> for (Bound<usize>, Bound<usize>)

This impl is conspicuously missing.
2023-08-01 06:55:52 +02:00
bors
706a4d9a4e Auto merge of #114308 - matthiaskrgr:rollup-m64bkm7, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #109318 (Make `Debug` representations of `[Lazy, Once]*[Cell, Lock]` consistent with `Mutex` and `RwLock`)
 - #113701 (Re-export core::ffi::FromBytesUntilNulError in std::ffi)
 - #113804 (Resolve correct archive version name in `opt-dist`)
 - #114165 (Add missing rvalues to smir)
 - #114182 (clean up after 113312)
 - #114193 (Update lexer emoji diagnostics to Unicode 15.0)
 - #114200 (Detect trait upcasting through struct tail unsizing in new solver select)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-07-31 23:30:28 +00:00
Matthias Krüger
efd68db768
Rollup merge of #113701 - aswild:std-ffi-frombytesuntilnul, r=dtolnay
Re-export core::ffi::FromBytesUntilNulError in std::ffi

Like the other CStr and CString error types, make a re-export for std::ffi::FromBytesUntilNulError.

This seems to have slipped through the cracks in the cstr_from_bytes_until_nul implementation and core_c_str migration.

Tracking Issue: #95027
2023-07-31 22:51:13 +02:00
Matthias Krüger
bcfa49f162
Rollup merge of #109318 - joboet:better_fmt_placeholder, r=dtolnay
Make `Debug` representations of `[Lazy, Once]*[Cell, Lock]` consistent with `Mutex` and `RwLock`

`Mutex` prints `<locked>` as a field value when its inner value cannot be accessed, but the lazy types print a fixed string like "`OnceCell(Uninit)`". This could cause confusion if the inner type is a unit type named `Uninit` and does not respect the pretty-printing flag. With this change, the format message is now "`OnceCell(<uninit>)`", consistent with `Mutex`.
2023-07-31 22:51:12 +02:00
Matthias Krüger
e981db05b5
Rollup merge of #114111 - allaboutevemirolive:add-test-case-string, r=Mark-Simulacrum
Improve test case for experimental API remove_matches

## Add Test Cases for `remove_matches` Function

### Motivation

After reading the discussion in [this GitHub thread](https://github.com/rust-lang/rust/pull/71780), I'm trying to redesign the current API to use less memory when working with `String` and to make it simpler. I've discovered that some test cases are very helpful in ensuring that the new API behaves as intended. I'm still in the process of redesigning the current API, and these test cases have proven to be very useful.

### Testing

The current test has been tested with the command `./x test --stage 0 library/alloc`.

### Overview

This pull request adds several new test cases for the `remove_matches` function to make sure it works correctly in different situations. The `remove_matches` function is used to get rid of all instances of a specific pattern from a given text. These test cases thoroughly check how the function behaves in various scenarios.

### Test Cases

1. **Single Pattern Occurrence** (`test_single_pattern_occurrence`):
   - Description: Tests the removal of a single pattern occurrence from the text.
   - Input: Text: "abc", Pattern: 'b'
   - Expected Output: "ac"

2. **Repeat Test Single Pattern Occurrence** (`repeat_test_single_pattern_occurrence`):
   - Description: Repeats the previous test case to ensure consecutive removal of the same pattern.
   - Input: Text: "ac", Pattern: 'b'
   - Expected Output: "ac"

3. **Single Character Pattern** (`test_single_character_pattern`):
   - Description: Tests the removal of a single character pattern.
   - Input: Text: "abcb", Pattern: 'b'
   - Expected Output: "ac"

4. **Pattern with Special Characters** (`test_pattern_with_special_characters`):
   - Description: Tests the removal of a pattern containing special characters.
   - Input: Text: "ศไทย中华Việt Nam; foobarศ", Pattern: 'ศ'
   - Expected Output: "ไทย中华Việt Nam; foobar"

5. **Pattern Empty Text and Pattern** (`test_pattern_empty_text_and_pattern`):
   - Description: Tests the removal of an empty pattern from an empty text.
   - Input: Text: "", Pattern: ""
   - Expected Output: ""

6. **Pattern Empty Text** (`test_pattern_empty_text`):
   - Description: Tests the removal of a pattern from an empty text.
   - Input: Text: "", Pattern: "something"
   - Expected Output: ""

7. **Empty Pattern** (`test_empty_pattern`):
   - Description: Tests the behavior of removing an empty pattern from the text.
   - Input: Text: "Testing with empty pattern.", Pattern: ""
   - Expected Output: "Testing with empty pattern."

8. **Multiple Consecutive Patterns 1** (`test_multiple_consecutive_patterns_1`):
   - Description: Tests the removal of multiple consecutive occurrences of a pattern.
   - Input: Text: "aaaaa", Pattern: 'a'
   - Expected Output: ""

9. **Multiple Consecutive Patterns 2** (`test_multiple_consecutive_patterns_2`):
   - Description: Tests the removal of a longer pattern that occurs consecutively.
   - Input: Text: "Hello **world****today!**", Pattern: "**"
   - Expected Output: "Hello worldtoday!"

10. **Case Insensitive Pattern** (`test_case_insensitive_pattern`):
    - Description: Tests the removal of a case-insensitive pattern from the text.
    - Input: Text: "CASE ** SeNsItIvE ** PaTtErN.", Pattern: "sEnSiTiVe"
    - Expected Output: "CASE ** SeNsItIvE ** PaTtErN."
2023-07-31 22:49:51 +02:00
Matthias Krüger
58f963fb65
Rollup merge of #113717 - cuishuang:master, r=Nilstrieb
remove repetitive words
2023-07-31 22:49:47 +02:00
Matthias Krüger
d0ae0b31a8
Rollup merge of #112858 - chriswailes:riscv64-android, r=Mark-Simulacrum
Update Android system definitions and add riscv-linux-android as tier 3 target

This PR includes the following:
* Corrected Android system definitions for some types
* Support for the riscv64-linux-android target

The authoritative types for the system definitions can be found here: https://cs.android.com/android/platform/superproject/+/master:bionic/libc/include/sys/stat.h

Fixes rust-lang/compiler-team#640
2023-07-31 22:49:46 +02:00
ltdk
9fce8abe0b I'm mathematically challenged 2023-07-31 15:08:52 -04:00
Matt Fellenz
f189d00d40
Work around missing <*str>::len 2023-07-31 11:42:14 -07:00
Matt Fellenz
e12e7fcc50
impl SliceIndex<str> for (Bound<usize>, Bound<usize>) 2023-07-31 11:32:40 -07:00
ltdk
bd6ccf31de Can't compare usize and u32 2023-07-31 13:24:30 -04:00
ltdk
0165a4cf5f Use u32::from for MIN/MAX examples 2023-07-31 13:22:16 -04:00
ltdk
b64f3c7181 Add note on gap for MIN/MAX 2023-07-31 13:21:42 -04:00
ltdk
f65fbe9517 Add char::MIN 2023-07-31 12:34:55 -04:00
Andrew Kane
fcecaff16e Add gamma and ln_gamma functions to f32 and f64 2023-07-31 07:41:50 -07:00
Konrad Borowski
0f06b07552 Implement UnwindSafe and RefUnwindSafe for Backtrace
Backtrace doesn't have visible mutable state.
2023-07-31 10:38:24 +02:00
cui fliter
88c7b16e03 remove repetitive words
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-07-31 16:13:02 +08:00
Jubilee
495e6577c8
Rollup merge of #114268 - SUPERCILEX:empty, r=workingjubilee
Fix empty_write since rust version attribute

Fixup of https://github.com/rust-lang/rust/pull/98154 for the rust version.

r? ``@workingjubilee``
2023-07-30 17:50:49 -07:00
Jubilee
0ad8d6adc5
Rollup merge of #109075 - joboet:lazylock_backtrace, r=workingjubilee
Use `LazyLock` to lazily resolve backtraces

By using TAIT to name the initializing closure, `LazyLock` can be used to replace the current `LazilyResolvedCapture`.
2023-07-30 17:50:47 -07:00
Jubilee
e5a6e5c90d
Rollup merge of #95965 - CAD97:const-weak-new, r=workingjubilee
Stabilize const-weak-new

This is a fairly uncontroversial library stabilization, so I'm going ahead and proposing it to ride the trains to stable.

This stabilizes the following APIs, which are defined to be non-allocating constructors.

```rust
// alloc::rc
impl<T> Weak<T> {
    pub const fn new() -> Weak<T>;
}

// alloc::sync
impl<T> Weak<T> {
    pub const fn new() -> Weak<T>;
}
```

Closes #95091

``@rustbot`` modify labels: +needs-fcp
2023-07-30 17:50:46 -07:00
CAD97
ee29d2fd0a Stabilize const-weak-new
Bump its stabilization version several times along
the way to accommodate changes in release processes.

Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
Co-authored-by: Trevor Gross <t.gross35@gmail.com>
2023-07-30 17:07:59 -07:00
bors
d4145eeef4 Auto merge of #112843 - chenyukang:yukang-more-on-backtrace, r=workingjubilee
Print omitted frames count for short backtrace mode

Fixes #111730
2023-07-30 22:31:52 +00:00
Alex Saveau
0b4a80f417
Fix empty_write since rust version attribute 2023-07-30 22:53:32 +01:00
Matthias Krüger
e3ca397593
Rollup merge of #102198 - lukas-code:nonnull_as_ref, r=Amanieu
`const`-stablilize `NonNull::as_ref`

A bunch of pointer to reference methods have been made unstably const some time ago in #91823 under the feature gate `const_ptr_as_ref`.
Out of these, `NonNull::as_ref` can be implemented as a `const fn` in stable rust today, so i hereby propose to const stabilize this function only.

Tracking issue: #91822

``@rustbot`` label +T-libs-api -T-libs
2023-07-30 20:36:34 +02:00
Matthias Krüger
27e3a740ae
Rollup merge of #98154 - vidhanio:master, r=workingjubilee
merge functionality of `io::Sink` into `io::Empty`

Many times, there is a need for a simple dummy `io::Read`er + `io::Write`r, but currently the only options are `io::Empty` and `io::Sink` respectively. Having both of their functionality together requires writing your own boilerplate for something that makes sense to have in the standard library. This PR adds the functionality of `io::Sink` to `io::Empty`, making `io::Empty` be able to perform the tasks of both of the previous structs. (This idea was first mentioned in #24235)

Note: I also updated some doc comments in `io::utils` in this pull request to fix inconsistencies between `io::Sink` and `io::Empty`.

API Change Proposal: https://github.com/rust-lang/libs-team/issues/49
2023-07-30 20:36:33 +02:00
Martin Nordholts
c6566a8037 Explain more clearly why fn() -> T can't be #[derive(Clone)] 2023-07-30 18:04:38 +02:00
Ryan Lowe
80277dd8f2 Avoid using ptr::Unique in LinkedList code 2023-07-30 11:21:24 -04:00
Matthias Krüger
de6caffe3a
Rollup merge of #114223 - ryanoneill:vec-indexing-doc-language, r=workingjubilee
Documentation: Fix Stilted Language in Vec->Indexing

Problem

Language in the Vec->Indexing documentation sounds stilted due to incorrect word ordering: "... type allows to access values by index."

Solution

Reorder words in the Vec->Indexing documentation to flow better: "... type allows access to values by index." The phrase "allows access to" also matches other existing documentation.
2023-07-30 14:25:10 +02:00
Matthias Krüger
e3bf088fb5
Rollup merge of #112655 - WaffleLapkin:must_use_map_or, r=workingjubilee
Mark `map_or` as `#[must_use]`

I don't know what else to say.

r? libs
2023-07-30 14:25:08 +02:00
Matthias Krüger
e517ee02b2
Rollup merge of #110056 - chenyukang:yukang/fix-110045, r=workingjubilee
Fix the example in document for WaitTimeoutResult::timed_out

Fixes #110045
2023-07-30 14:25:08 +02:00
Maybe Waffle
90f9640528 Mark map_or as #[must_use] 2023-07-30 10:22:23 +00:00
yukang
d67d9890ae Fix the example in document for WaitTimeoutResult::timed_out 2023-07-30 16:39:33 +08:00
Jacob Pratt
f1d4e48c9c
Fix implementation of Duration::checked_div 2023-07-30 04:00:02 -04:00
bors
4c9ac1e93b Auto merge of #114236 - fee1-dead-contrib:rollup-m92j7q1, r=fee1-dead
Rollup of 3 pull requests

Successful merges:

 - #112151 (Clarify behavior of inclusive bounds in BTreeMap::{lower,upper}_bound)
 - #113512 (Updated lines doc to include trailing carriage return note)
 - #114203 (Effects: don't print `host` param in diagnostics)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-07-30 07:57:13 +00:00
fee1-dead
b97da75156
Rollup merge of #113512 - vallentin:lines-doc, r=workingjubilee
Updated lines doc to include trailing carriage return note

Updated `str::lines` doc to include explicit info about (trailing) carriage returns.

Reference: #100311
2023-07-30 07:13:02 +00:00
fee1-dead
3143030cda
Rollup merge of #112151 - chloekek:patch-1, r=workingjubilee
Clarify behavior of inclusive bounds in BTreeMap::{lower,upper}_bound

It wasn’t quite clear to me how these methods would interpret inclusive bounds so I added examples for those.
2023-07-30 07:13:01 +00:00
bors
2e0136a131 Auto merge of #112280 - zica87:master, r=workingjubilee
Remove redundant example of `BTreeSet::iter`

The usage and that `Values returned by the iterator are returned in ascending order` are already demonstrated by the other example and the description, so I removed the useless one.
2023-07-30 06:12:03 +00:00
Ryan O'Neill
9a01a23b9c Documentation: Fix Stilted Language in Vec->Indexing
Problem

Language in the Vec->Indexing documentation sounds stilted due to
incorrect word ordering: "... type allows to access values by index."

Solution

Reorder words in the Vec->Indexing documentation to flow better:
"... type allows access to values by index." The phrase "allows access to"
also matches other existing documentation.
2023-07-29 13:20:45 -07:00
Georgii Rylov
5697f1620d Add wasm32-wasi-threads target + WASI threads 2023-07-29 16:37:50 +01:00
yukang
90db98d074 print omitted frames count for short backtrace mode 2023-07-29 20:36:05 +08:00
Urgau
507d497cfa Adjust some tests for invalid_reference_casting improvements 2023-07-29 12:20:59 +02:00
Mara Bos
0e729404da Change default panic handler message format. 2023-07-29 11:42:50 +02:00
bors
2dc661037d Auto merge of #113099 - bvanjoi:fix-112713-2, r=petrochenkov
fix(resolve): update the ambiguity glob binding as warning recursively

Fixes #47525
Fixes #56593, but `issue-56593-2.rs` is not fixed to ensure backward compatibility.
Fixes #98467
Fixes #105235
Fixes #112713

This PR had added a field called `warn_ambiguous` in `NameBinding` which is only for back compatibly reason and used for lint.

More details: https://github.com/rust-lang/rust/pull/112743

r? `@petrochenkov`
2023-07-29 06:04:41 +00:00
bors
5ed61a4378 Auto merge of #114197 - matthiaskrgr:rollup-iluf7u4, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #113773 (Don't attempt to compute layout of type referencing error)
 - #114107 (Prevent people from assigning me as a PR reviewer)
 - #114124 (tests/ui/proc-macro/*: Migrate FIXMEs to check-pass)
 - #114171 (Fix switch-stdout test for none unix/windows platforms)
 - #114172 (Fix issue_15149 test for the SGX target)
 - #114173 (btree/map.rs: remove "Basic usage" text)
 - #114174 (doc: replace wrong punctuation mark)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-07-29 04:18:46 +00:00
Matthias Krüger
c6c1008b18
Rollup merge of #114174 - tshepang:patch-6, r=workingjubilee
doc: replace wrong punctuation mark
2023-07-29 06:13:08 +02:00
Matthias Krüger
c528bddd6d
Rollup merge of #114173 - tshepang:patch-1, r=workingjubilee
btree/map.rs: remove "Basic usage" text

Not useful, for there is just a single example
2023-07-29 06:13:07 +02:00
Matthias Krüger
68dc159241
Rollup merge of #114172 - fortanix:raoul/fix_process-spawning_test, r=workingjubilee
Fix issue_15149 test for the SGX target

PR https://github.com/rust-lang/rust/pull/112390 moved tests to std. Unfortunately, this caused the `issue_15149` test to be enabled for the SGX target. This is incorrect as the SGX target does not support the `env::current_exe()` call.
2023-07-29 06:13:07 +02:00
Matthias Krüger
5df97c6bb9
Rollup merge of #114171 - fortanix:raoul/fix_switch-stdout_test, r=workingjubilee
Fix switch-stdout test for none unix/windows platforms

PR #112390 moved tests to std. Unfortunately, there is a typo which causes issues on platforms other than unix and windows.
2023-07-29 06:13:06 +02:00
bors
4734ac0943 Auto merge of #111916 - fee1-dead-contrib:noop-method-call-warn, r=compiler-errors
make `noop_method_call` warn by default

r? `@compiler-errors`
2023-07-29 01:40:50 +00:00
Thom Chiovoloni
558f49d7aa
inline trivial (noop) flush calls 2023-07-28 18:09:12 -07:00
Matthias Krüger
02f1e2ada7
Rollup merge of #114128 - estebank:delayed-span-bug-dump, r=davidtwco
When flushing delayed span bugs, write to the ICE dump file even if it doesn't exist

Fix #113881.
2023-07-28 19:51:15 +02:00
bohan
771c832338 library: allow ambiguous_glob_reexports for core_arch 2023-07-29 00:19:59 +08:00
Raoul Strackx
8548689af2 Fix issue_15149 test for the SGX target 2023-07-28 14:48:06 +02:00