Commit Graph

16252 Commits

Author SHA1 Message Date
Kevin Mehall 2dc75148ee Stabilize waker_getters 2024-09-02 18:51:59 -06:00
Kevin Mehall 8d3e5fa0ae Move the `data` and `vtable` methods from `RawWaker` to `Waker`
Per the `waker_getters` FCP:
https://github.com/rust-lang/rust/issues/96992#issuecomment-1941998046
2024-09-02 18:51:26 -06:00
Tshepang Mbambo 0a89f72065 process.rs: remove "Basic usage" text where not useful
Is not useful because just a single example is given.
2024-09-02 22:36:25 +02:00
Matthias Krüger d6298d3736
Rollup merge of #129907 - saethlin:solid-io-error, r=WaffleLapkin
Fix compile error in solid's remove_dir_all

Before this PR, `x check library/std --target=aarch64-kmc-solid_asp3` will fail with:
```
error[E0382]: use of partially moved value: `result`
   --> std/src/sys/pal/solid/fs.rs:544:20
    |
541 |         if let Err(err) = result
    |                    --- value partially moved here
...
544 |             return result;
    |                    ^^^^^^ value used here after partial move
    |
    = note: partial move occurs because value has type `io::error::Error`, which does not implement the `Copy` trait
help: borrow this binding in the pattern to avoid moving the value
    |
541 |         if let Err(ref err) = result
    |                    +++

```

cc `@kawadakk` I think this will clear up https://solid-rs.github.io/toolstate/ :)
2024-09-02 22:35:23 +02:00
Matthias Krüger 9dad90a22a
Rollup merge of #129892 - oskgo:clarify-slice-from-raw, r=RalfJung
Clarify language around ptrs in slice::raw

More specifically we explicitly mention that the pointer should be non-null as a top level requirement. Nullptrs are always valid for zero sized operations, so just validity (and alignment) does not guarantee non-nullness as implied in the existing docs.

We also explicitly call out ZSTs as an additional example where perhaps unintuitively alignment and non-nullness still have to hold.

Finally we change `data` in the range functions to `start`, which seems like a typo to me.

Touches docs for #89792

r? RalfJung
2024-09-02 22:35:22 +02:00
Matthias Krüger 3ddf061926
Rollup merge of #129890 - alex:patch-1, r=workingjubilee
Remove stray word in a comment
2024-09-02 22:35:22 +02:00
Matthias Krüger f0072bf274
Rollup merge of #129856 - RalfJung:compiler_fence, r=thomcc
compiler_fence documentation: emphasize synchronization, not reordering

Our `fence` docs have at some point been update to explain that they are about synchronization, not about "preventing reordering". This updates the `compiler_fence` docs n the same vein, mostly by referring to the `fence` docs.

The old docs make it sound like I can put a compiler_fence in the middle of a bunch of non-atomic operations and that would achieve any kind of guarantee. It does not, atomic operations are still required to do synchronization.

I also slightly tweaked the `fence` docs, to put the synchronization first and the "prevent reordering" second.

Cc `@rust-lang/opsem` `@chorman0773` `@m-ou-se`

Fixes https://github.com/rust-lang/rust/issues/129189
Fixes https://github.com/rust-lang/rust/issues/54962
2024-09-02 22:35:19 +02:00
Matthias Krüger 003ddec7a6
Rollup merge of #129748 - RalfJung:box-validity, r=workingjubilee
Box validity: update for new zero-sized rules

Fixes https://github.com/rust-lang/unsafe-code-guidelines/issues/529

Cc `@joshlf` `@rust-lang/opsem`
2024-09-02 22:35:18 +02:00
Ben Kimock fcb7d3fdf3 Add missing read_buf stub for x86_64-unknown-l5re-uclibc 2024-09-02 16:14:28 -04:00
Ben Kimock 8be9fed672 Fix compile error in solid's remove_dir_all 2024-09-02 14:58:00 -04:00
oskgo 7494224e74 clarify language around non-null ptrs in slice::raw 2024-09-02 15:49:18 +02:00
Alex Gaynor 06e3552ad0
Remove stray word in a comment 2024-09-02 09:44:03 -04:00
bors a4601859ae Auto merge of #129873 - matthiaskrgr:rollup-bv849ud, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #127474 (doc: Make block of inline Deref methods foldable)
 - #129678 (Deny imports of `rustc_type_ir::inherent` outside of type ir + new trait solver)
 - #129738 (`rustc_mir_transform` cleanups)
 - #129793 (add extra linebreaks so rustdoc can identify the first sentence)
 - #129804 (Fixed some typos in the standard library documentation/comments)
 - #129837 (Actually parse stdout json, instead of using hacky contains logic.)
 - #129842 (Fix LLVM ABI NAME for riscv64imac-unknown-nuttx-elf)
 - #129843 (Mark myself as on vacation for triagebot)
 - #129858 (Replace walk with visit so we dont skip outermost expr kind in def collector)

Failed merges:

 - #129777 (Add `unreachable_pub`, round 4)
 - #129868 (Remove kobzol vacation status)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-09-02 13:41:42 +00:00
cuishuang 25c4aa8979 chore: remove repetitive words
Signed-off-by: cuishuang <imcusg@gmail.com>
2024-09-02 19:02:28 +08:00
Matthias Krüger 820540aaa0
Rollup merge of #129804 - ranger-ross:fixed-documentation-typos, r=Noratrieb
Fixed some typos in the standard library documentation/comments

I spent some time to fix a few typos in `library/std` and `library/core`
2024-09-02 04:19:29 +02:00
Matthias Krüger 8c2898989f
Rollup merge of #129793 - lolbinarycat:doc-missing-newlines, r=workingjubilee
add extra linebreaks so rustdoc can identify the first sentence

there should probably be a lint against this in rustdoc, it causes too many lines to be shown in the short documentation overviews

expecially noticable for the slice primative type: https://doc.rust-lang.org/std/index.html
2024-09-02 04:19:29 +02:00
bors e71f952912 Auto merge of #129063 - the8472:cold-opt-size, r=Amanieu
Apply size optimizations to panic machinery and some cold functions

* std dependencies gimli and addr2line are now built with opt-level=s
* various panic-related methods and `#[cold]` methods are now marked `#[optimize(size)]`

Panics should be cold enough that it doesn't make sense to optimize them for speed. The only tradeoff here is if someone does a lot of backtrace captures (without panics) and printing then the opt-level change might impact their perf.

Seems to be the first use of the optimize attribute. Tracking issue #54882
2024-09-02 00:58:50 +00:00
binarycat 0064bd1b99 add extra linebreaks so rustdoc can identify the first sentence
there should probably be a lint against this in rustdoc, it causes
too many lines to be shown in the short documentation overviews

expecially noticable for the slice primative type:
https://doc.rust-lang.org/std/index.html
2024-09-01 14:22:50 -07:00
Ralf Jung 32a30dd005 compiler_fence documentation: emphasize synchronization, not reordering 2024-09-01 16:58:44 +02:00
Ralf Jung 19908ff7a3 stabilize const_float_bits_conv 2024-09-01 12:38:59 +02:00
Ralf Jung 0e5628d7de tweak wording regarding Box validity 2024-09-01 11:21:37 +02:00
bors 1a1cc050d8 Auto merge of #127897 - nyurik:add-qnx-70-target, r=saethlin
add `aarch64_unknown_nto_qnx700` target - QNX 7.0 support for aarch64le

This backports the QNX 7.1 aarch64 implementation to 7.0.

* [x] required `-lregex` disabled, see https://github.com/rust-lang/libc/pull/3775 (released in libc 0.2.156)
* [x] uses `libgcc.a` instead of `libgcc_s.so` (7.0 used ancient GCC 5.4 which didn't have gcc_s)
* [x] a fix in `backtrace` crate to support stack traces https://github.com/rust-lang/backtrace-rs/pull/648

This PR bumps libc dependency to 0.2.158

CC: to the folks who did the [initial implementation](https://doc.rust-lang.org/rustc/platform-support/nto-qnx.html): `@flba-eb,` `@gh-tr,` `@jonathanpallant,` `@japaric`

# Compile target

```bash
# Configure qcc build environment
source _path_/_to_/qnx7.0/qnxsdp-env.sh

# Tell rust to use qcc when building QNX 7.0 targets
export build_env='
    CC_aarch64-unknown-nto-qnx700=qcc
    CFLAGS_aarch64-unknown-nto-qnx700=-Vgcc_ntoaarch64le_cxx
    CXX_aarch64-unknown-nto-qnx700=qcc
    AR_aarch64_unknown_nto_qnx700=ntoaarch64-ar'

# Build rust compiler, libs, and the remote test server
env $build_env ./x.py build \
  --target x86_64-unknown-linux-gnu,aarch64-unknown-nto-qnx700 \
  rustc library/core library/alloc library/std src/tools/remote-test-server

rustup toolchain link stage1 build/host/stage1
```

# Compile "hello world"

```bash
source _path_/_to_/qnx7.0/qnxsdp-env.sh

cargo new hello_world
cd hello_world
cargo +stage1 build --release --target aarch64-unknown-nto-qnx700
```

# Configure a remote for testing

Do this from a new shell - we will need to run more commands in the previous one.  I ran into these two issues, and found some workarounds.

* Temporary dir might not work properly
* Default `remote-test-server` has issues binding to an address

```
# ./remote-test-server
starting test server
thread 'main' panicked at src/tools/remote-test-server/src/main.rs:175:29:
called `Result::unwrap()` on an `Err` value: Os { code: 249, kind: AddrNotAvailable, message: "Can't assign requested address" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```

Specifying `--bind` param actually fixes that, and so does setting `TMPDIR` properly.

```bash
# Copy remote-test-server to remote device. You may need to use sftp instead.
# ATTENTION: Note that the path is different from the one in the remote testing documentation for some reason
scp ./build/x86_64-unknown-linux-gnu/stage1-tools-bin/remote-test-server  qnxdevice:/path/

# Run ssh with port forwarding - so that rust tester can connect to the local port instead
ssh -L 12345:127.0.0.1:12345 qnxdevice

# on the device, run
rm -rf tmp && mkdir -p tmp && TMPDIR=$PWD/tmp ./remote-test-server --bind 0.0.0.0:12345
```

# Run test suit

Assume all previous environment variables are still set, or re-init them

```bash
export TEST_DEVICE_ADDR="localhost:12345"

# tidy needs to be skipped due to using un-published libc dependency
export exclude_tests='
    --exclude src/bootstrap
    --exclude src/tools/error_index_generator
    --exclude src/tools/linkchecker
    --exclude src/tools/tidy
    --exclude tests/ui-fulldeps
    --exclude rustc
    --exclude rustdoc
    --exclude tests/run-make-fulldeps'

env $build_env ./x.py test  $exclude_tests --stage 1 --target aarch64-unknown-nto-qnx700
```

try-job: dist-x86_64-msvc
2024-09-01 08:00:25 +00:00
Matthias Krüger 2261ffa19f
Rollup merge of #129832 - eduardosm:stray-dot, r=jhpratt
Remove stray dot in `std::char::from_u32_unchecked` documentation
2024-09-01 03:58:06 +02:00
Matthias Krüger 1063c0dd37
Rollup merge of #129207 - GrigorenkoPV:elided-is-named, r=cjgillot
Lint that warns when an elided lifetime ends up being a named lifetime

As suggested in https://github.com/rust-lang/rust/issues/48686#issuecomment-1817334575

Fixes #48686
2024-09-01 03:58:03 +02:00
Matthias Krüger da65b9064f
Rollup merge of #128641 - Konippi:standardize-duplicate-processes-in-parser, r=scottmcm
refactor: standardize duplicate processes in parser

## Summary
This PR refactors the `read_number` function to standardize duplicate code, improve readability, and enhance efficiency.

## Changes
- Merged the logic for both `max_digits` cases into a single `read_atomically` closure
- Simplified control flow and reduced code duplication
2024-09-01 03:58:03 +02:00
Matthias Krüger a073004484
Rollup merge of #128495 - joboet:more_memcmp, r=scottmcm
core: use `compare_bytes` for more slice element types

`bool`, `NonZero<u8>`, `Option<NonZero<u8>>` and `ascii::Char` can be compared the same way as `u8`.
2024-09-01 03:58:02 +02:00
The 8472 e3169f76e6 when -Zrandomize-layout is enabled disable alloc test testing internal struct sizes 2024-08-31 23:56:45 +02:00
bors a7399ba69d Auto merge of #129831 - matthiaskrgr:rollup-befq6zx, r=matthiaskrgr
Rollup of 11 pull requests

Successful merges:

 - #128523 (Add release notes for 1.81.0)
 - #129605 (Add missing `needs-llvm-components` directives for run-make tests that need target-specific codegen)
 - #129650 (Clean up `library/profiler_builtins/build.rs`)
 - #129651 (skip stage 0 target check if `BOOTSTRAP_SKIP_TARGET_SANITY` is set)
 - #129684 (Enable Miri to pass pointers through FFI)
 - #129762 (Update the `wasm-component-ld` binary dependency)
 - #129782 (couple more crash tests)
 - #129816 (tidy: say which feature gate has a stability issue mismatch)
 - #129818 (make the const-unstable-in-stable error more clear)
 - #129824 (Fix code examples buttons not appearing on click on mobile)
 - #129826 (library: Fix typo in `core::mem`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-31 20:59:27 +00:00
Eduardo Sánchez Muñoz d4e708f1bc Remove stray dot in `std::char::from_u32_unchecked` documentation 2024-08-31 21:54:29 +02:00
Matthias Krüger 4151fd407e
Rollup merge of #129826 - Alcaro:patch-1, r=workingjubilee
library: Fix typo in `core::mem`

This typo looks unnecessary
2024-08-31 20:36:28 +02:00
Matthias Krüger 6a96e7a255
Rollup merge of #129650 - Zalathar:profiler-builtins, r=Mark-Simulacrum
Clean up `library/profiler_builtins/build.rs`

This PR makes a series of improvements to the long-neglected build script for `profiler_builtins`.

Most notably:
- The logic that silently skips missing source files has been removed, since it is currently unnecessary and makes build errors more confusing.
- The script now emits `cargo::rerun-if-changed` directives for the `compiler-rt` source and include directories.

Compiler behaviour and user programs should be unaffected by these changes.
2024-08-31 20:36:24 +02:00
Alcaro 7d728e54d9
Update mod.rs
This typo looks unnecessary
2024-08-31 19:09:41 +02:00
Matthias Krüger 6ab726c342
Rollup merge of #129730 - RalfJung:float-arithmetic, r=workingjubilee
f32 docs: define 'arithmetic' operations

r? ````@workingjubilee````
Fixes https://github.com/rust-lang/rust/issues/129699
2024-08-31 14:46:08 +02:00
Pavel Grigorenko f7b0b22137 Fix `elided_named_lifetimes` in code 2024-08-31 15:35:41 +03:00
Chris Denton bb9d5c4658
Move remove_dir_all impl into a module 2024-08-31 12:19:42 +00:00
Matthias Krüger 25e3b66410
Rollup merge of #129754 - alexcrichton:fix-wasi-long-sleep, r=workingjubilee
wasi: Fix sleeping for `Duration::MAX`

This commit fixes an assert in the WASI-specific implementation of thread sleep to ensure that sleeping for a very large period of time blocks instead of panicking. This can come up when testing programs that sleep "forever", for example.

I'll note that I haven't included a test for this since it's sort of difficult to test. I've tested this locally though that long sleeps do indeed block and short sleeps still only sleep for a short amount of time.
2024-08-31 10:08:59 +02:00
Matthias Krüger 10fb626958
Rollup merge of #129675 - lolbinarycat:bufreader_peek_unsized, r=workingjubilee
allow BufReader::peek to be called on unsized types

#128405
2024-08-31 10:08:55 +02:00
Matthias Krüger fbf74dfb00
Rollup merge of #129642 - workingjubilee:bump-backtrace-fc37b22, r=workingjubilee
Bump backtrace to 0.3.74~ish

Commit: https://github.com/rust-lang/backtrace-rs/commit/230570f

This should help with backtraces on Android, QNX NTO 7.0, and Windows.
It addresses a case of backtrace incurring undefined behavior on Android.
2024-08-31 10:08:55 +02:00
Matthias Krüger 385ffaedbf
Rollup merge of #129640 - saethlin:unignore-android-in-alloc, r=tgross35
Re-enable android tests/benches in alloc/core

This is basically a revert of https://github.com/rust-lang/rust/pull/73729. These tests better work on android now; it's been 4 years and we don't use dlmalloc on that target anymore.

And I've validated that they should pass now with a try-build :)
2024-08-31 10:08:54 +02:00
ranger-ross cbf92fcf39
Fixed more typos in library/core 2024-08-31 14:57:38 +09:00
ranger-ross 92f45900bb
Fixed typos in btree map docs 2024-08-31 14:50:37 +09:00
ranger-ross 24ad26db3b
Fixed some typos in the standard library documentation/comments 2024-08-31 14:41:01 +09:00
Ralf Jung f6b7727605 enumerate the two parts of the NaN rules 2024-08-30 11:31:36 +02:00
Ralf Jung 08fadfd8d8 add hyphen in floating-point 2024-08-30 08:23:12 +02:00
Yuri Astrakhan f41e0bb41d Squashed `aarch64_unknown_nto_qnx700` support 2024-08-30 01:19:55 -04:00
Jubilee Young 518b41c2bd Try latest backtrace 2024-08-29 12:13:19 -07:00
Alex Crichton c824c1ada7 wasi: Fix sleeping for `Duration::MAX`
This commit fixes an assert in the WASI-specific implementation of
thread sleep to ensure that sleeping for a very large period of time
blocks instead of panicking. This can come up when testing programs that
sleep "forever", for example.
2024-08-29 10:31:17 -07:00
Guillaume Gomez 4b08b2e400
Rollup merge of #128166 - ChaiTRex:isqrt, r=tgross35
Improved `checked_isqrt` and `isqrt` methods

### Improved tests of `isqrt` and `checked_isqrt` implementations

* Inputs chosen more thoroughly and systematically.
* Checks that `isqrt` and `checked_isqrt` have equivalent results for signed types, either equivalent numerically or equivalent as a panic and a `None`.
* Checks that `isqrt` has numerically-equivalent results for unsigned types and their `NonZero` counterparts.

### Added benchmarks for `isqrt` implementations

### Greatly sped up `checked_isqrt` and `isqrt` methods

* Uses a lookup table for 8-bit integers and then the Karatsuba square root algorithm for larger integers.
* Includes optimization hints that give the compiler the exact numeric range of results.

### Feature tracking issue

`isqrt` is an unstable feature tracked at #116226.

<details><summary>Benchmarked improvements</summary>

### Command used to benchmark

    ./x bench library/core -- int_sqrt

### Before

    benchmarks:
        num::int_sqrt::i128::isqrt           439591.65/iter  +/- 6652.70
        num::int_sqrt::i16::isqrt              5302.97/iter   +/- 160.93
        num::int_sqrt::i32::isqrt             62999.11/iter  +/- 2022.05
        num::int_sqrt::i64::isqrt            125248.81/iter  +/- 1674.43
        num::int_sqrt::i8::isqrt                123.56/iter     +/- 1.87
        num::int_sqrt::isize::isqrt          125356.56/iter  +/- 1017.03
        num::int_sqrt::non_zero_u128::isqrt  437443.75/iter  +/- 3535.43
        num::int_sqrt::non_zero_u16::isqrt     8604.58/iter    +/- 94.76
        num::int_sqrt::non_zero_u32::isqrt    62933.33/iter   +/- 517.30
        num::int_sqrt::non_zero_u64::isqrt   125076.38/iter +/- 11340.61
        num::int_sqrt::non_zero_u8::isqrt       221.51/iter     +/- 1.58
        num::int_sqrt::non_zero_usize::isqrt 136005.21/iter  +/- 2020.35
        num::int_sqrt::u128::isqrt           439014.55/iter  +/- 3920.45
        num::int_sqrt::u16::isqrt              8575.08/iter   +/- 148.06
        num::int_sqrt::u32::isqrt             63008.89/iter   +/- 803.67
        num::int_sqrt::u64::isqrt            125088.09/iter   +/- 879.29
        num::int_sqrt::u8::isqrt                230.18/iter     +/- 2.04
        num::int_sqrt::usize::isqrt          125237.51/iter  +/- 4747.83
### After

    benchmarks:
        num::int_sqrt::i128::isqrt           105184.89/iter +/- 1171.38
        num::int_sqrt::i16::isqrt              1910.26/iter   +/- 78.50
        num::int_sqrt::i32::isqrt             34260.34/iter  +/- 960.84
        num::int_sqrt::i64::isqrt             45939.19/iter +/- 2525.65
        num::int_sqrt::i8::isqrt                 22.87/iter    +/- 0.45
        num::int_sqrt::isize::isqrt           45884.17/iter  +/- 595.49
        num::int_sqrt::non_zero_u128::isqrt  106344.27/iter  +/- 780.99
        num::int_sqrt::non_zero_u16::isqrt     2790.19/iter   +/- 53.43
        num::int_sqrt::non_zero_u32::isqrt    33613.99/iter  +/- 362.96
        num::int_sqrt::non_zero_u64::isqrt    46235.42/iter  +/- 429.69
        num::int_sqrt::non_zero_u8::isqrt        31.78/iter    +/- 0.75
        num::int_sqrt::non_zero_usize::isqrt  46208.75/iter  +/- 375.27
        num::int_sqrt::u128::isqrt           106385.94/iter +/- 1649.95
        num::int_sqrt::u16::isqrt              2747.69/iter   +/- 28.72
        num::int_sqrt::u32::isqrt             33627.09/iter  +/- 475.68
        num::int_sqrt::u64::isqrt             46182.29/iter  +/- 311.16
        num::int_sqrt::u8::isqrt                 33.10/iter    +/- 0.30
        num::int_sqrt::usize::isqrt           46165.00/iter  +/- 388.41

</details>

Tracking Issue for {u8,i8,...}::isqrt #116226

try-job: test-various
2024-08-29 16:21:46 +02:00
Guillaume Gomez 015e9371e0
Rollup merge of #123940 - kornelski:remove-derived-debug, r=Urgau
debug-fmt-detail option

I'd like to propose a new option that makes `#[derive(Debug)]` generate no-op implementations that don't print anything, and makes `{:?}` in format strings a no-op.

There are a couple of motivations for this:

1. A more thorough stripping of debug symbols. Binaries stripped of debug symbols still retain some of them through `Debug` implementations. It's hard to avoid that without compiler's help, because debug formatting can be used in many places, including dependencies, and their loggers, asserts, panics, etc.
   * In my testing it gives about 2% binary size reduction on top of all other binary-minimizing best practices (including `panic_immediate_abort`). There are targets like Web WASM or embedded where users pay attention to binary sizes.
   * Users distributing closed-source binaries may not want to "leak" any symbol names as a matter of principle.
2. Adds ability to test whether code depends on specifics of the `Debug` format implementation in unwise ways (e.g. trying to get data unavailable via public interface, or using it as a serialization format). Because current Rust's debug implementation doesn't change, there's a risk of it becoming a fragile de-facto API that [won't be possible to change in the future](https://www.hyrumslaw.com/). An option that "breaks" it can act as a [grease](https://www.rfc-editor.org/rfc/rfc8701.html).

This implementation is a `-Z fmt-debug=opt` flag that takes:

* `full` — the default, current state.
* `none` — makes derived `Debug` and `{:?}` no-ops. Explicit `impl Debug for T` implementations are left unharmed, but `{:?}` format won't use them, so they may get dead-code eliminated if they aren't invoked directly.
* `shallow` — makes derived `Debug` print only the type's name, without recursing into fields. Fieldless enums print their variant names. `{:?}` works.

The `shallow` option is a compromise between minimizing the `Debug` code, and compatibility. There are popular proc-macro crates that use `Debug::fmt` as a way to convert enum values into their Rust source code.

There's a corresponding `cfg` flag: `#[cfg(fmt_debug = "none")]` that can be used in user code to react to this setting to minimize custom `Debug` implementations or remove unnecessary formatting helper functions.
2024-08-29 16:21:46 +02:00
Ralf Jung 05ffd446a9 Box validity: update for new zero-sized rules 2024-08-29 16:06:20 +02:00
Ralf Jung eb8e78f624 f32 docs: define 'arithmetic' operations 2024-08-29 08:55:37 +02:00
Chai T. Rex 7af8e218da Speed up `checked_isqrt` and `isqrt` methods
* Use a lookup table for 8-bit integers and the Karatsuba square root
  algorithm for larger integers.
* Include optimization hints that give the compiler the exact numeric
  range of results.
2024-08-28 23:07:04 -04:00
Chai T. Rex 0cac915211 Improve `isqrt` tests and add benchmarks
* Choose test inputs more thoroughly and systematically.
* Check that `isqrt` and `checked_isqrt` have equivalent results for
  signed types, either equivalent numerically or equivalent as a panic
  and a `None`.
* Check that `isqrt` has numerically-equivalent results for unsigned
  types and their `NonZero` counterparts.
* Reuse `ilog10` benchmarks, plus benchmarks that use a uniform
  distribution.
2024-08-28 23:06:54 -04:00
Jubilee bd66fadd79
Rollup merge of #129715 - Amjad50:update-compiler-builtins, r=tgross35
Update `compiler_builtins` to `0.1.123`

Includes https://github.com/rust-lang/compiler-builtins/pull/680 and fixes https://github.com/rust-lang/rust/issues/128386.

Fixed by not including math symbols of `compiler_builtins` into any `unix` target or `wasi`, old behavior is restored

r? tgross35
2024-08-28 19:12:56 -07:00
Jubilee dfe66cf529
Rollup merge of #129683 - RalfJung:copysign, r=thomcc
copysign with sign being a NaN can have non-portable results

Follow-up to https://github.com/rust-lang/rust/pull/129559.
Cc ```@tgross35``` ```@beetrees```

There's no portable variant we can recommend instead here, is there? Something with a semantics like "if `sign` is a NaN, then return `self` unaltered, otherwise return `self` with the sign changed to that of `sign`"?
2024-08-28 19:12:54 -07:00
Jubilee 9ddb45e81a
Rollup merge of #129673 - matthewpipie:arc-weak-debug-trait, r=dtolnay
Add fmt::Debug to sync::Weak<T, A>

Currently, `sync::Weak<T>` implements `Debug`, but `sync::Weak<T, A>` does not. This appears to be an oversight, as `rc::Weak<T, A>` implements `Debug`. (Note: `sync::Weak` is the weak for `Arc`, and `rc::Weak` is the weak for `Rc`.)

This PR adds the Debug trait for `sync::Weak<T, A>`. The issue was initially brought up here: https://github.com/rust-lang/wg-allocators/issues/131
2024-08-28 19:12:54 -07:00
Jubilee 9d5f794312
Rollup merge of #129401 - workingjubilee:partial-initialization-of-stabilization, r=dtolnay,joboet
Partially stabilize `feature(new_uninit)`

Finished comment period: https://github.com/rust-lang/rust/issues/63291#issuecomment-2183022955

The following API has been stabilized from https://github.com/rust-lang/rust/issues/63291

```rust
impl<T> Box<T> { pub fn new_uninit() -> Box<MaybeUninit<T>> {…} }
impl<T> Rc<T> { pub fn new_uninit() -> Rc<MaybeUninit<T>> {…} }
impl<T> Arc<T> { pub fn new_uninit() -> Arc<MaybeUninit<T>> {…} }

impl<T> Box<[T]> { pub fn new_uninit_slice(len: usize) -> Box<[MaybeUninit<T>]> {…} }
impl<T> Rc<[T]> { pub fn new_uninit_slice(len: usize) -> Rc<[MaybeUninit<T>]> {…} }
impl<T> Arc<[T]> { pub fn new_uninit_slice(len: usize) -> Arc<[MaybeUninit<T>]> {…} }

impl<T> Box<MaybeUninit<T>> { pub unsafe fn assume_init(self) -> Box<T> {…} }
impl<T> Box<[MaybeUninit<T>]> { pub unsafe fn assume_init(self) -> Box<[T]> {…} }
impl<T> Rc<MaybeUninit<T>> { pub unsafe fn assume_init(self) -> Rc<T> {…} }
impl<T> Rc<[MaybeUninit<T>]> { pub unsafe fn assume_init(self) -> Rc<[T]> {…} }
impl<T> Arc<MaybeUninit<T>> { pub unsafe fn assume_init(self) -> Arc<T> {…} }
impl<T> Arc<[MaybeUninit<T>]> { pub unsafe fn assume_init(self) -> Arc<[T]> {…} }
```

The remaining API is split between new issues
- `new_zeroed_alloc`: https://github.com/rust-lang/rust/issues/129396
- `box_uninit_write`: https://github.com/rust-lang/rust/issues/129397

All relevant code is thus either stabilized or split out of that issue, so this closes #63291 as, with the FCP concluded, that issue has served its purpose.

try-job: x86_64-rust-for-linux
2024-08-28 19:12:52 -07:00
Jubilee fcb6b7792d
Rollup merge of #129378 - goffrie:patch-3, r=ChrisDenton
Clean up cfg-gating of ProcessPrng extern

This removes a bit of duplication and is consistent with how `api-ms-win-core-synch-l1-2-0` externs are imported.
2024-08-28 19:12:51 -07:00
Jubilee 4c8c9e092d
Rollup merge of #128192 - mrkajetanp:feature-detect, r=Amanieu
rustc_target: Add various aarch64 features

Add various aarch64 features already supported by LLVM and Linux.
Additionally include some comment fixes to ensure consistency of feature names with the Arm ARM.
Compiler support for features added to stdarch by https://github.com/rust-lang/stdarch/pull/1614.
Tracking issue for unstable aarch64 features is https://github.com/rust-lang/rust/issues/127764.

List of added features:

- FEAT_CSSC
- FEAT_ECV
- FEAT_FAMINMAX
- FEAT_FLAGM2
- FEAT_FP8
- FEAT_FP8DOT2
- FEAT_FP8DOT4
- FEAT_FP8FMA
- FEAT_HBC
- FEAT_LSE128
- FEAT_LSE2
- FEAT_LUT
- FEAT_MOPS
- FEAT_LRCPC3
- FEAT_SVE_B16B16
- FEAT_SVE2p1
- FEAT_WFxT
- FEAT_SME
- FEAT_SME_F16F16
- FEAT_SME_F64F64
- FEAT_SME_F8F16
- FEAT_SME_F8F32
- FEAT_SME_FA64
- FEAT_SME_I16I64
- FEAT_SME_LUTv2
- FEAT_SME2
- FEAT_SME2p1
- FEAT_SSVE_FP8DOT2
- FEAT_SSVE_FP8DOT4
- FEAT_SSVE_FP8FMA

FEAT_FPMR is added in the first commit and then removed in a separate one to highlight it being removed from upstream LLVM 19. The intention is for it to be detectable at runtime through stdarch but not have a corresponding Rust compile-time feature.
2024-08-28 19:12:49 -07:00
Amjad Alsharafi 555414e683
Update `compiler_builtins` to `0.1.123`
Signed-off-by: Amjad Alsharafi <26300843+Amjad50@users.noreply.github.com>
2024-08-29 08:38:19 +08:00
Kornel 88b9edc9db
fmt-debug option
Allows disabling `fmt::Debug` derive and debug formatting.
2024-08-28 23:32:40 +01:00
binarycat ae6f8a7764 allow BufReader::peek to be called on unsized types 2024-08-28 13:56:44 -04:00
bors 100fde5246 Auto merge of #129691 - matthiaskrgr:rollup-owlcr3m, r=matthiaskrgr
Rollup of 11 pull requests

Successful merges:

 - #129421 (add repr to the allowlist for naked functions)
 - #129480 (docs: correct panic conditions for rem_euclid and similar functions)
 - #129551 (ub_checks intrinsics: fall back to cfg(ub_checks))
 - #129608 (const-eval: do not make UbChecks behavior depend on current crate's flags)
 - #129613 (interpret: do not make const-eval query result depend on tcx.sess)
 - #129641 (rustdoc: fix missing resource suffix on `crates.js`)
 - #129657 (Rename `BikeshedIntrinsicFrom` to `TransmuteFrom`)
 - #129666 (interpret: add missing alignment check in raw_eq)
 - #129667 (Rustc driver cleanup)
 - #129668 (Fix Pin::set bounds regression)
 - #129686 (coverage: Rename `CodeRegion` to `SourceRegion`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-28 17:53:22 +00:00
Matthias Krüger 27d7fb0cfa
Rollup merge of #129668 - coolreader18:fix-pin-set-regr, r=dtolnay
Fix Pin::set bounds regression

Fixes #129601

Fixes the regression from #129449, where changing the bounds of the impl block containing `Pin::set` changed the method resolution behavior.

```rust
struct A;
impl A {
    fn set(&self) {}
}

let a: Pin<&A>;
a.set();
// before:
// - checks <impl<Ptr: DerefMut> Pin<Ptr>>::set(): `&A` doesn't impl `DerefMut`
// - autorefs -> &A: resolves to A::set()
// now:
// - checks <impl<Ptr: Deref> Pin<Ptr>>::set(): `&A` impls `Deref`! resolves to Pin::set()
// - check method bounds: `&A` doesn't impl DerefMut: error
```

r? `@dtolnay`
2024-08-28 17:12:20 +02:00
Matthias Krüger 29188a54b3
Rollup merge of #129657 - jswrenn:transmute-name, r=compiler-errors
Rename `BikeshedIntrinsicFrom` to `TransmuteFrom`

As our implementation of MCP411 nears completion and we begin to solicit testing, it's no longer reasonable to expect testers to type or remember `BikeshedIntrinsicFrom`. The name degrades the ease-of-reading of documentation, and the overall experience of using compiler safe transmute.

Tentatively, we'll instead adopt `TransmuteFrom`.

This name seems to be the one most likely to be stabilized, after discussion on Zulip [1]. We may want to revisit the ordering of `Src` and `Dst` before stabilization, at which point we'd likely consider `TransmuteInto` or `Transmute`.

[1] https://rust-lang.zulipchat.com/#narrow/stream/216762-project-safe-transmute/topic/What.20should.20.60BikeshedIntrinsicFrom.60.20be.20named.3F

Tracking Issue: https://github.com/rust-lang/rust/issues/99571

r​? `@compiler-errors`
2024-08-28 17:12:18 +02:00
Matthias Krüger 015620869d
Rollup merge of #129551 - RalfJung:ub-checks-fallback, r=saethlin
ub_checks intrinsics: fall back to cfg(ub_checks)

Not sure why the fallback body uses `debug_assertions`, probably a leftover from when `cfg!(ub_checks)` did not exist yet?

r? `@saethlin`
2024-08-28 17:12:12 +02:00
Matthias Krüger 56ca2e23fe
Rollup merge of #129480 - lolbinarycat:euclid-docs, r=joboet
docs: correct panic conditions for rem_euclid and similar functions

fixes https://github.com/rust-lang/rust/issues/128857

also fixes the documentation for functions behind the `int_roundings` feature (#88581)
2024-08-28 17:12:12 +02:00
Ben Kimock 83de14c4ff Enable some ilog2 tests as well 2024-08-28 10:45:30 -04:00
Ben Kimock ee05de8e5e Re-enable android tests/benches in alloc 2024-08-28 10:45:30 -04:00
bors ac77e88f7a Auto merge of #129589 - saethlin:improve-panic-immediate-abort, r=tgross35
Tweak some attributes to improve panic_immediate_abort

This is similar to https://github.com/rust-lang/rust/pull/117332; I did the same approach as before where I build a really big project with `-Zbuild-std -Zbuild-std-features=panic_immediate_abort` and grep its symbols for things that look panic-related.
2024-08-28 13:13:09 +00:00
Ralf Jung 0589dc75d3 copysign with sign being a NaN is non-portable 2024-08-28 12:06:28 +02:00
Ralf Jung b5bd0fe48a addr_of on places derived from raw pointers should preserve permissions 2024-08-28 10:32:31 +02:00
Matthew Giordano c11d46f045 Add fmt::Debug to sync::Weak<T, A> 2024-08-27 17:38:51 -07:00
Noa 0d6c9152fa
Fix Pin::set bounds regression 2024-08-27 16:32:46 -05:00
Jubilee Young 169b2f0e6d library: Stabilize new_uninit for Box, Rc, and Arc
A partial stabilization that only affects:
- AllocType<T>::new_uninit
- AllocType<T>::assume_init
- AllocType<[T]>::new_uninit_slice
- AllocType<[T]>::assume_init
where "AllocType" is Box, Rc, or Arc
2024-08-27 10:17:05 -07:00
Matthias Krüger ac0cc709c3
Rollup merge of #129652 - RalfJung:ptr-to-ref, r=traviscross
fix Pointer to reference conversion docs

The aliasing rules documented in https://github.com/rust-lang/rust/pull/128157 are wrong, this fixes them.
2024-08-27 18:59:30 +02:00
Matthias Krüger 02491259c2
Rollup merge of #129645 - beetrees:fix-float-docs, r=tgross35
Fix typos in floating-point primitive type docs

Fixes a few typos. Also reflows the text of a couple of paragraphs in the source code to the standard line width to make the source easier to read (will have no effect on the rendered documentation).
2024-08-27 18:59:29 +02:00
Matthias Krüger 6ab180577f
Rollup merge of #129581 - RalfJung:exit, r=joshtriplett
exit: explain our expectations for the exit handlers registered in a Rust program

This documents the position of ``@Amanieu`` and others in https://github.com/rust-lang/rust/issues/126600: a library with an atexit handler that destroys state that other threads could still be working on is buggy. We do not consider it acceptable for a library to say "you must call the following cleanup function before exiting from `main` or calling `exit`". I don't know if this is established ``@rust-lang/libs-api``  consensus so I presume this will have to go through FCP.

Given that Rust supports concurrency, I don't think there is any way to write a sound Rust wrapper around a library that has such a required cleanup function: even if we made `exit` unsafe, and the Rust wrapper used the scope-with-callback approach to ensure it can run cleanup code before returning from the wrapper (like `thread::scope`), one could still call this wrapper in a second thread and then return from `main` while the wrapper runs. Making this sound would require `std` to provide a way to "block" returning from `main`, so that while the wrapper runs returning from `main` waits until the wrapper is done... that just doesn't seem feasible.

The `exit` docs do not seem like the best place to document this, but I also couldn't think of a better one.
2024-08-27 18:59:27 +02:00
Jack Wrenn 1ad218f3af safe transmute: Rename `BikeshedIntrinsicFrom` to `TransmuteFrom`
As our implementation of MCP411 nears completion and we begin to
solicit testing, it's no longer reasonable to expect testers to
type or remember `BikeshedIntrinsicFrom`. The name degrades the
ease-of-reading of documentation, and the overall experience of
using compiler safe transmute.

Tentatively, we'll instead adopt `TransmuteFrom`.

This name seems to be the one most likely to be stabilized, after
discussion on Zulip [1]. We may want to revisit the ordering of
`Src` and `Dst` before stabilization, at which point we'd likely
consider `TransmuteInto` or `Transmute`.

[1] https://rust-lang.zulipchat.com/#narrow/stream/216762-project-safe-transmute/topic/What.20should.20.60BikeshedIntrinsicFrom.60.20be.20named.3F
2024-08-27 14:05:54 +00:00
bors 600edc948a Auto merge of #128134 - joboet:move_pal_alloc, r=cupiver
std: move allocators to `sys`

Part of #117276.
2024-08-27 13:51:39 +00:00
Ralf Jung ab4a743a38 fix Pointer to reference conversion docs 2024-08-27 12:28:43 +02:00
Ralf Jung 1ef4f5d924 clarify that addr_of creates read-only pointers 2024-08-27 12:21:35 +02:00
Kajetan Puchalski c3518067c7 rustc_target: Add SME aarch64 features
Add SME aarch64 features already supported by LLVM and Linux.

This commit adds compiler support for the following features:

- FEAT_SME
- FEAT_SME_F16F16
- FEAT_SME_F64F64
- FEAT_SME_F8F16
- FEAT_SME_F8F32
- FEAT_SME_FA64
- FEAT_SME_I16I64
- FEAT_SME_LUTv2
- FEAT_SME2
- FEAT_SME2p1
- FEAT_SSVE_FP8DOT2
- FEAT_SSVE_FP8DOT4
- FEAT_SSVE_FP8FMA
2024-08-27 11:11:47 +01:00
Kajetan Puchalski 4f847bd326 rustc_target: Add various aarch64 features
Add various aarch64 features already supported by LLVM and Linux.

The features are marked as unstable using a newly added symbol, i.e.
aarch64_unstable_target_feature.

Additionally include some comment fixes to ensure consistency of
feature names with the Arm ARM and support for architecture version
target features up to v9.5a.

This commit adds compiler support for the following features:

- FEAT_CSSC
- FEAT_ECV
- FEAT_FAMINMAX
- FEAT_FLAGM2
- FEAT_FP8
- FEAT_FP8DOT2
- FEAT_FP8DOT4
- FEAT_FP8FMA
- FEAT_FPMR
- FEAT_HBC
- FEAT_LSE128
- FEAT_LSE2
- FEAT_LUT
- FEAT_MOPS
- FEAT_LRCPC3
- FEAT_SVE_B16B16
- FEAT_SVE2p1
- FEAT_WFxT
2024-08-27 11:11:47 +01:00
joboet d456814842
std: move allocators to `sys` 2024-08-27 11:58:19 +02:00
Zalathar 5b6ff4fe18 Don't skip nonexistent source files
This behaviour was introduced during the upgrade to LLVM 11. Now that the list
of source files has been cleaned up, we can reasonably expect _all_ of the
listed source files to be present.
2024-08-27 17:30:42 +10:00
Zalathar 7f90aa5538 Add `cargo::rerun-if-changed` directives for source directories 2024-08-27 17:30:25 +10:00
Zalathar 842cda6865 Always include `WindowsMMap.c` in the list of source files
The whole file is surrounded by `#if defined(_WIN32)`, so there's no need to
have separate logic to exclue it from non-Windows builds.
2024-08-27 17:30:25 +10:00
Zalathar 25ca8a283f Sort the list of source files 2024-08-27 17:30:19 +10:00
Zalathar b6dba995b4 Remove `InstrProfilingBiasVar.c` from the list of source files
This file was introduced in LLVM 11, but was then removed in LLVM 13.
2024-08-27 17:30:06 +10:00
Zalathar fcce75e9a6 Use helper functions to read environment variables
This also migrates from legacy `cargo:` directives to the newer `cargo::`
prefix.
2024-08-27 17:29:47 +10:00
Trevor Gross 75ae913ec0
Rollup merge of #129559 - RalfJung:float-nan-semantics, r=thomcc
float types: document NaN bit pattern guarantees

Part of https://github.com/rust-lang/rust/issues/128288: document the guarantees we make for NaN bit patterns.

Cc ``@tgross35``
2024-08-27 01:46:53 -05:00
Trevor Gross d2ff033302
Rollup merge of #128731 - RalfJung:simd-shuffle-vector, r=workingjubilee
simd_shuffle intrinsic: allow argument to be passed as vector

See https://github.com/rust-lang/rust/issues/128738 for context.

I'd like to get rid of [this hack](6c0b89dfac/compiler/rustc_codegen_ssa/src/mir/block.rs (L922-L935)). https://github.com/rust-lang/rust/pull/128537 almost lets us do that since constant SIMD vectors will then be passed as immediate arguments. However, simd_shuffle for some reason actually takes an *array* as argument, not a vector, so the hack is still required to ensure that the array becomes an immediate (which then later stages of codegen convert into a vector, as that's what LLVM needs).

This PR prepares simd_shuffle to also support a vector as the `idx` argument. Once this lands, stdarch can hopefully be updated to pass `idx` as a vector, and then support for arrays can be removed, which finally lets us get rid of that hack.
2024-08-27 01:46:50 -05:00
Zalathar 2c141a4542 Update old comment referring to `libcompiler_builtins` 2024-08-27 15:22:35 +10:00
beetrees d0548359b5
Reflow a couple of paragraphs in floating-point primitive docs 2024-08-27 05:26:28 +01:00
beetrees 969f9702da
Fix typos in floating-point primitive type docs 2024-08-27 05:25:34 +01:00
Jubilee Young 0763a3afc8 Bump backtrace to rust-lang/backtrace@fc37b22
It should be 0.3.74~ish.

This should help with backtraces on Android, QNX NTO 7.0, and Windows.
2024-08-26 20:15:20 -07:00
Matthias Krüger 29923b6801
Rollup merge of #129032 - jswrenn:transmute-method, r=compiler-errors
Document & implement the transmutation modeled by `BikeshedIntrinsicFrom`

Documents that `BikeshedIntrinsicFrom` models transmute-via-union, which is slightly more expressive than the transmute-via-cast implemented by `transmute_copy`. Additionally, we provide an implementation of transmute-via-union as a method on the `BikeshedIntrinsicFrom` trait with additional documentation on the boundary between trait invariants and caller obligations.

Whether or not transmute-via-union is the right kind of transmute to model remains up for discussion [1]. Regardless, it seems wise to document the present behavior.

[1] https://rust-lang.zulipchat.com/#narrow/stream/216762-project-safe-transmute/topic/What.20'kind'.20of.20transmute.20to.20model.3F/near/426331967

Tracking Issue: https://github.com/rust-lang/rust/issues/99571

r? `@compiler-errors`

cc `@scottmcm,` `@Lokathor`
2024-08-27 00:41:59 +02:00
Matthias Krüger c6ceb5be24
Rollup merge of #128157 - lolbinarycat:unify-ptr-ref-docs, r=cuviper
deduplicate and clarify rules for converting pointers to references

part of #124669
2024-08-27 00:41:58 +02:00
Josh Stone b11e0a883b
Apply suggestions from code review 2024-08-26 12:36:58 -07:00
Matthias Krüger b9dfb4d6f8
Rollup merge of #129592 - saethlin:core-cfg-test, r=tgross35
Remove cfg(test) from library/core

The diff here is very small with the ignore whitespace option.

`core` doesn't/can't have unit tests. All of its tests are just modules under `tests/`, so it has no use for `cfg(test)`, because the entire contents of `library/core/src` are only ever compiled with that cfg off, and the entire contents of `library/core/tests` are only ever compiled with that cfg on.

You can tell this is what's happening because we had `#[cfg(test)]` on a module declaration that has no source file.

I also deleted the extra `mod tests {` layer of nesting; there's no need to mention again in the module path that this is a module of tests. This exposes a name collision between the `u128` module of tests and `core::u128`. Fixed that by using `<u128>::MAX` like is done in the `check!` macro, which is what avoids this name ambiguity for the other types.
2024-08-26 17:25:33 +02:00
Matthias Krüger d0b3c3a110
Rollup merge of #129588 - hermit-os:sleep-micros, r=workingjubilee
pal/hermit: correctly round up microseconds in `Thread::sleep`

This fixes the Hermit-related part of https://github.com/rust-lang/rust/issues/129212 and thus the whole issue, since ESP-IDF is already fixed, as far as I understand.

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

r? `@workingjubilee`

CC: `@stlankes`
2024-08-26 17:25:32 +02:00
Matthias Krüger b1c9064071
Rollup merge of #129539 - oconnor663:poll_link, r=tgross35
link to Future::poll from the Poll docs

The most important thing about Poll is that Future::poll returns it, but previously the docs didn't emphasize this.
2024-08-26 17:25:32 +02:00
Matthias Krüger 68aff290fd
Rollup merge of #129377 - chorman0773:unbounded-shifts-impl, r=scottmcm
Add implementations for `unbounded_shl`/`unbounded_shr`

Tracking Issue: https://github.com/rust-lang/rust/issues/129375

This implements `unbounded_shl` and `unbounded_shr` under the feature gate `unbounded_shifts`
2024-08-26 17:25:31 +02:00
Ralf Jung 0c7d6c45e6 also update copysign docs 2024-08-26 17:25:24 +02:00
Ralf Jung 53d4544628 move per-target NaN info into a table 2024-08-26 17:20:40 +02:00
Ralf Jung fe2975076f float types: document NaN bit pattern guarantees 2024-08-26 17:20:40 +02:00
bors f48062e7d0 Auto merge of #129595 - matthiaskrgr:rollup-4udn7nn, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #129288 (Use subtyping for `UnsafeFnPointer` coercion, too)
 - #129405 (Fixing span manipulation and indentation of the suggestion introduced by #126187)
 - #129518 (gitignore: ignore ICE reports regardless of directory)
 - #129519 (Remove redundant flags from `lower_ty_common` that can be inferred from the HIR)
 - #129525 (rustdoc: clean up tuple <-> primitive conversion docs)
 - #129526 (Use `FxHasher` on new solver unconditionally)
 - #129544 (Removes dead code from the compiler)
 - #129553 (add back test for stable-const-can-only-call-stable-const)
 - #129590 (Avoid taking reference of &TyKind)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-26 05:45:40 +00:00
Ben Kimock 4f3ef2ac90 Remove cfg(test) from library/core 2024-08-25 20:04:26 -04:00
Matthias Krüger c6e00680ac
Rollup merge of #129544 - mu001999-contrib:dead-code/clean, r=compiler-errors
Removes dead code from the compiler

Detected by #128637
2024-08-26 01:49:03 +02:00
Matthias Krüger aa26e1ad97
Rollup merge of #129525 - notriddle:notriddle/fake-variadic-tuple-array, r=GuillaumeGomez
rustdoc: clean up tuple <-> primitive conversion docs

This adds a minor missing feature to `fake_variadic`, so that it can render `impl From<(T,)> for [T; 1]` correctly.
2024-08-26 01:49:02 +02:00
bors 3f121b9461 Auto merge of #129488 - saethlin:alignment-precondition, r=workingjubilee
Enable Alignment::new_unchecked precondition check

Similar to what happened with https://github.com/rust-lang/rust/pull/126556, I think this has become palatable since https://github.com/rust-lang/rust/pull/126793.
2024-08-25 23:45:25 +00:00
Martin Kröning edeefc532f
pal/hermit: saturate `usleep` microseconds at `u64::MAX`
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2024-08-26 00:04:00 +02:00
bors c6db1ca3c9 Auto merge of #129563 - matthiaskrgr:rollup-t6bai2d, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #129091 (add Box::as_ptr and Box::as_mut_ptr methods)
 - #129134 (bootstrap: improve error recovery flags to curl)
 - #129416 (library: Move unstable API of new_uninit to new features)
 - #129459 (handle stage0 `cargo` and `rustc` separately)
 - #129487 (repr_transparent_external_private_fields: special-case some std types)
 - #129511 (Update minifier to 0.3.1)
 - #129523 (Make `rustc_type_ir` build on stable)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-25 20:29:33 +00:00
Ben Kimock b1c2c78d29 Tweak some attributes to improve panic_immediate_abort 2024-08-25 14:52:53 -04:00
Martin Kröning 687c8a1eab
pal/hermit: correctly round up microseconds in `Thread::sleep`
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2024-08-25 20:49:23 +02:00
Ralf Jung 21dd88f963 exit: explain our expectations for the exit handlers registered in a Rust program 2024-08-25 17:46:26 +02:00
Jack O'Connor 3153b7d7b4 link to Future::poll from the Poll docs
The most important thing about Poll is that Future::poll returns it, but
previously the docs didn't emphasize this.
2024-08-25 08:35:06 -07:00
Matthias Krüger 9c59e97ded
Rollup merge of #129487 - GrigorenkoPV:repr_transparent_external_private_fields, r=compiler-errors
repr_transparent_external_private_fields: special-case some std types

Fixes #129470

```@rustbot``` label +A-lint +L-repr_transparent_external_private_fields
2024-08-25 16:51:05 +02:00
Matthias Krüger 0e2523eaf8
Rollup merge of #129416 - workingjubilee:partial-move-from-stabilization, r=dtolnay
library: Move unstable API of new_uninit to new features

- `new_zeroed` variants move to `new_zeroed_alloc`
- the `write` fn moves to `box_uninit_write`

The remainder will be stabilized in upcoming patches, as it was decided to only stabilize `uninit*` and `assume_init`.
2024-08-25 16:51:04 +02:00
Matthias Krüger 7edbd6353b
Rollup merge of #129091 - RalfJung:box_as_ptr, r=Amanieu
add Box::as_ptr and Box::as_mut_ptr methods

Unstably implements https://github.com/rust-lang/libs-team/issues/355. Tracking issue: https://github.com/rust-lang/rust/issues/129090.

r? libs-api
2024-08-25 16:51:03 +02:00
bors 1a94d839be Auto merge of #129295 - Zalathar:profiler-builtins, r=Kobzol
Build `library/profiler_builtins` from `ci-llvm` if appropriate

Running all of `tests/coverage` requires the LLVM profiler runtime, which requires setting `build.profiler = true`.

Historically, doing that has required checking out the entire `src/llvm-project` submodule. For compiler contributors who otherwise don't need that submodule (thanks to `download-ci-vm`), that's quite inconvenient.

However, thanks to #129116, the downloaded CI LLVM tarball now contains a copy of LLVM's `compiler-rt` directory, which includes all the files needed to build the profiler runtime. So with a little bit of extra logic in bootstrap, we can have `library/profiler_builtins` look for the `compiler-rt` files in `ci-llvm` instead of the `src/llvm-project` submodule.
2024-08-25 14:44:55 +00:00
Ralf Jung a772db4206 ub_checks intrinsics: fall back to cfg(ub_checks) 2024-08-25 13:15:48 +02:00
bors 717aec0f8e Auto merge of #129521 - matthiaskrgr:rollup-uigv77m, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #128596 (stabilize const_fn_floating_point_arithmetic)
 - #129199 (make writes_through_immutable_pointer a hard error)
 - #129246 (Retroactively feature gate `ConstArgKind::Path`)
 - #129290 (Pin `cc` to 1.0.105)
 - #129323 (Implement `ptr::fn_addr_eq`)
 - #129500 (remove invalid `TyCompat` relation for effects)
 - #129501 (panicking: improve hint for Miri's RUST_BACKTRACE behavior)
 - #129505 (interpret: ImmTy: tighten sanity checks in offset logic)
 - #129510 (Fix `elided_named_lifetimes` in code)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-25 08:12:16 +00:00
mu001999 e7f11b6913 Removes dead code from the compiler 2024-08-25 13:41:39 +08:00
Trevor Gross 678193f7d1
Rollup merge of #129481 - scottmcm:update-cb, r=tgross35
Update `compiler_builtins` to `0.1.121`

To pick up https://github.com/rust-lang/compiler-builtins/pull/673 and unblock https://github.com/rust-lang/rust/pull/129403

r? tgross35
2024-08-24 21:03:33 -05:00
Trevor Gross e96faab70b
Rollup merge of #129449 - coolreader18:pin-as_deref_mut-signature, r=dtolnay
Put Pin::as_deref_mut in impl Pin<Ptr> / rearrange Pin methods

Tracking issue: #86918

Based on the suggestion in https://github.com/rust-lang/rust/issues/86918#issuecomment-2189367582

> Some advantages:
>
>  * Synergy with the existing `as_ref` and `as_mut` signatures (stable since Rust 1.33)
>
>  * Lifetime elision reduces noise in the signature
>
>  * Turbofish less verbose: `Pin::<&mut T>::as_deref_mut` vs `Pin::<&mut Pin<&mut T>>::as_deref_mut`

The comment seemed to imply that `Pin::as_ref` and `Pin::as_mut` already share an impl block, which they don't. So, I rearranged it so that they do, and we can see which looks better in the docs.

<details><summary><b>Docs screenshots</b></summary>

Current nightly:
![image](https://github.com/user-attachments/assets/b432cb82-8f4b-48ae-bafc-2fe49d0ad48c)

`Pin::as_deref_mut` moved into the same block as `as_mut`:
![image](https://github.com/user-attachments/assets/f9b35722-6a88-4465-ad1c-28d8e91902ac)

`Pin::as_ref`, `as_mut`, and `as_deref_mut` all in the same block:
![image](https://github.com/user-attachments/assets/9a1b2bf0-70a6-4751-b13f-390f1d575244)

</details>

I think I like the last one the most; obviously I'm biased since I'm the one who rearranged it, but it doesn't make sense to me to have `as_ref` methods split up by an `into_inner` method.

r? dtolnay
2024-08-24 21:03:33 -05:00
Trevor Gross 198a68df1c
Rollup merge of #128735 - jieyouxu:pr-120176-revive, r=cjgillot
Add a special case for `CStr`/`CString` in the `improper_ctypes` lint

Revives #120176. Just needed to bless a test and fix an argument, but seemed reasonable to me otherwise.

Instead of saying to "consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct", we now tell users to "Use `*const ffi::c_char` instead, and pass the value from `CStr::as_ptr()`" when the type involved is a `CStr` or a `CString`.

The suggestion is not made for `&mut CString` or `*mut CString`.

r? ``````@cjgillot`````` (since you were the reviewer of the original PR #120176, but feel free to reroll)
2024-08-24 21:03:31 -05:00
Michael Howell 6df0ccf49e rustdoc: clean up tuple <-> primitive conversion docs
This adds a minor missing feature to `fake_variadic`,
so that it can render `impl From<(T,)> for [T; 1]` correctly.
2024-08-24 14:06:57 -07:00
Matthias Krüger 5611b3714f
Rollup merge of #129501 - RalfJung:miri-rust-backtrace, r=Noratrieb
panicking: improve hint for Miri's RUST_BACKTRACE behavior

Should help with https://github.com/rust-lang/miri/issues/3838
2024-08-24 22:14:14 +02:00
Matthias Krüger 3f5d6b2e40
Rollup merge of #129500 - fee1-dead-contrib:fxrel, r=compiler-errors
remove invalid `TyCompat` relation for effects

if the current impl uses `Maybe` (`impl const`), the parent impl must use `Maybe` (`impl const`) as well.

I'd like to rename `TyCompat` to `Sub` which is probably clearer. But it would conflict with my other PR.

r? ``@rust-lang/project-const-traits``
2024-08-24 22:14:14 +02:00
Matthias Krüger 2c4338802a
Rollup merge of #129323 - Urgau:ptr_fn_addr_eq, r=Mark-Simulacrum
Implement `ptr::fn_addr_eq`

This PR implements https://github.com/rust-lang/libs-team/issues/323: `ptr::fn_addr_eq`.

r? libs
2024-08-24 22:14:13 +02:00
Matthias Krüger 0dfdea1c45
Rollup merge of #128596 - RalfJung:const_fn_floating_point_arithmetic, r=nnethercote
stabilize const_fn_floating_point_arithmetic

Part of https://github.com/rust-lang/rust/issues/128288
Fixes https://github.com/rust-lang/rust/issues/57241

The existing test `tests/ui/consts/const_let_eq_float.rs`  ([link](https://github.com/RalfJung/rust/blob/const_fn_floating_point_arithmetic/tests/ui/consts/const_let_eq_float.rs)) covers the basics, and also Miri has extensive tests covering the interpreter's float machinery. Also, that machinery can already be used on stable inside `const`/`static` initializers, just not inside `const fn`.

This was explicitly called out in https://github.com/rust-lang/rfcs/pull/3514 so in a sense t-lang just recently already FCP'd this, but let's hear from them whether they want another FCP for the stabilization here or whether that was covered by the FCP for the RFC.
Cc ``@rust-lang/lang``

### Open items

- [x] Update the Reference: https://github.com/rust-lang/reference/pull/1566
2024-08-24 22:14:11 +02:00
Pavel Grigorenko b9033bdd92 New `#[rustc_pub_transparent]` attribute 2024-08-24 23:05:37 +03:00
Ralf Jung ec0e16a665 panicking: improve hint for Miri's RUST_BACKTRACE behavior 2024-08-24 14:38:50 +02:00
Zalathar 94aadf0f62 Build `library/profiler_builtins` from `ci-llvm` if appropriate 2024-08-24 21:21:34 +10:00
Deadbeef 378902e325 remove invalid `TyCompat` relation for effects 2024-08-24 14:24:21 +08:00
Jubilee Young 9ccd7abefe library: Move unstable API of new_uninit to new features
- `new_zeroed` variants move to `new_zeroed_alloc`
- the `write` fn moves to `box_uninit_write`

The remainder will be stabilized in upcoming patches, as
it was decided to only stabilize `uninit*` and `assume_init`.
2024-08-23 20:52:02 -07:00
Ben Kimock 5d98d20529 Enable Alignment::new_unchecked precondition check 2024-08-23 18:26:45 -04:00
Trevor Gross e76b7d029c Change `f16` doctests in core to run on x86-64 linux
Since `f16` now works on x86 and x86-64, change doctests to use this
instead of aarch64. This is to make sure any changes get run in PR CI.
2024-08-23 14:21:57 -05:00
Scott McMurray 62f7d5305e Update `compiler_builtins` to `0.1.121` 2024-08-23 12:02:26 -07:00
Trevor Gross 402ce53bfe Enable `f16` tests on x86 and x86-64
Since the `compiler_builtins` update [1], ABI bugs on x86 should be
resolved. Enable tests for f16 on these platforms now.

`f16` math functions (`reliable_f16_math`) are still excluded because
there is an LLVM crash for powi [2].

[1]: https://github.com/rust-lang/rust/pull/125016
[2]: https://github.com/llvm/llvm-project/issues/105747
2024-08-23 13:54:50 -05:00
binarycat d7e7886b3c docs: correct panic conditions for rem_euclid and similar functions
fixes https://github.com/rust-lang/rust/issues/128857
2024-08-23 14:47:21 -04:00
Noa c65ef3d37c
Move into_inner_unchecked back to the bottom of the impl block 2024-08-23 13:06:26 -05:00
Noa b968b26c03
Put Pin::as_deref_mut in impl Pin<Ptr> 2024-08-23 12:45:05 -05:00
Jack Wrenn 2540070fd4 document & impl the transmutation modeled by `BikeshedIntrinsicFrom`
Documents that `BikeshedIntrinsicFrom` models transmute-via-union,
which is slightly more expressive than the transmute-via-cast
implemented by `transmute_copy`. Additionally, we provide an
implementation of transmute-via-union as a method on the
`BikeshedIntrinsicFrom` trait with additional documentation on
the boundary between trait invariants and caller obligations.

Whether or not transmute-via-union is the right kind of transmute
to model remains up for discussion [1]. Regardless, it seems wise
to document the present behavior.

[1] https://rust-lang.zulipchat.com/#narrow/stream/216762-project-safe-transmute/topic/What.20'kind'.20of.20transmute.20to.20model.3F/near/426331967
2024-08-23 14:37:36 +00:00
bors a60a9e567a Auto merge of #129464 - GuillaumeGomez:rollup-ckfqd7h, r=GuillaumeGomez
Rollup of 9 pull requests

Successful merges:

 - #128511 (Document WebAssembly target feature expectations)
 - #129243 (do not build `cargo-miri` by default on stable channel)
 - #129263 (Add a missing compatibility note in the 1.80.0 release notes)
 - #129276 (Stabilize feature `char_indices_offset`)
 - #129350 (adapt integer comparison tests for LLVM 20 IR changes)
 - #129408 (Fix handling of macro arguments within the `dropping_copy_types` lint)
 - #129426 (rustdoc-search: use tighter json for names and parents)
 - #129437 (Fix typo in a help diagnostic)
 - #129457 (kobzol vacation)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-23 10:56:34 +00:00
Guillaume Gomez 26672c93d5
Rollup merge of #129276 - eduardosm:stabilize-char_indices_offset, r=Amanieu
Stabilize feature `char_indices_offset`

Stabilized API:

```rust
impl CharIndices<'_> {
    pub fn offset(&self) -> usize;
}
```

Tracking issue: https://github.com/rust-lang/rust/issues/83871

Closes https://github.com/rust-lang/rust/issues/83871

I also attempted to improved the documentation to make it more clear that it returns the offset of the character that will be returned by the next call to `next()`.
2024-08-23 12:32:15 +02:00
Matthias Krüger 79d36669b5
Rollup merge of #129400 - Amjad50:update-compiler-builtins, r=tgross35
Update `compiler_builtins` to `0.1.120`

Includes https://github.com/rust-lang/compiler-builtins/pull/672 which fixes regression issue with Apple and Windows compilers.

try-job: aarch64-apple
try-job: x86_64-apple-1
try-job: x86_64-msvc
2024-08-23 06:26:53 +02:00
Matthias Krüger 370b3265ff
Rollup merge of #127623 - lolbinarycat:fix_remove_dir_all, r=Amanieu
fix: fs::remove_dir_all: treat internal ENOENT as success

fixes #127576

try-job: test-various
2024-08-23 06:26:51 +02:00