Commit Graph

262708 Commits

Author SHA1 Message Date
Matthias Krüger
53a56190af
Rollup merge of #128530 - scottmcm:repeat-n-unchecked, r=joboet
Implement `UncheckedIterator` directly for `RepeatN`

This just pulls the code out of `next` into `next_unchecked`, rather than making the `Some` and `unwrap_unchecked`ing it.

And while I was touching it, I added a codegen test that `array::repeat` for something that's just `Clone`, not `Copy`, still ends up optimizing to the same thing as `[x; n]`: <https://rust.godbolt.org/z/YY3a5ajMW>.
2024-08-03 20:51:52 +02:00
Matthias Krüger
0afbe482f0
Rollup merge of #128283 - lolbinarycat:bootstrap-custom-target, r=albertlarsan68
bootstrap: fix bug preventing the use of custom targets

the bug was caused by two factors:
1. only checking the RUST_TARGET_PATH form, not the full filepath form
2. indirectly trying to use the Debug presentation to get the file path
2024-08-03 20:51:52 +02:00
Matthias Krüger
7d9ed2a864
Rollup merge of #127921 - spastorino:stabilize-unsafe-extern-blocks, r=compiler-errors
Stabilize unsafe extern blocks (RFC 3484)

# Stabilization report

## Summary

This is a tracking issue for the RFC 3484: Unsafe Extern Blocks

We are stabilizing `#![feature(unsafe_extern_blocks)]`, as described in [Unsafe Extern Blocks RFC 3484](https://github.com/rust-lang/rfcs/pull/3484). This feature makes explicit that declaring an extern block is unsafe. Starting in Rust 2024, all extern blocks must be marked as unsafe. In all editions, items within unsafe extern blocks may be marked as safe to use.

RFC: https://github.com/rust-lang/rfcs/pull/3484
Tracking issue: #123743

## What is stabilized

### Summary of stabilization

We now need extern blocks to be marked as unsafe and items inside can also have safety modifiers (unsafe or safe), by default items with no modifiers are unsafe to offer easy migration without surprising results.

```rust
unsafe extern {
    // sqrt (from libm) may be called with any `f64`
    pub safe fn sqrt(x: f64) -> f64;

    // strlen (from libc) requires a valid pointer,
    // so we mark it as being an unsafe fn
    pub unsafe fn strlen(p: *const c_char) -> usize;

    // this function doesn't say safe or unsafe, so it defaults to unsafe
    pub fn free(p: *mut core::ffi::c_void);

    pub safe static IMPORTANT_BYTES: [u8; 256];

    pub safe static LINES: SyncUnsafeCell<i32>;
}
```

## Tests

The relevant tests are in `tests/ui/rust-2024/unsafe-extern-blocks`.

## History

- https://github.com/rust-lang/rust/pull/124482
- https://github.com/rust-lang/rust/pull/124455
- https://github.com/rust-lang/rust/pull/125077
- https://github.com/rust-lang/rust/pull/125522
- https://github.com/rust-lang/rust/issues/126738
- https://github.com/rust-lang/rust/issues/126749
- https://github.com/rust-lang/rust/issues/126755
- https://github.com/rust-lang/rust/pull/126757
- https://github.com/rust-lang/rust/pull/126758
- https://github.com/rust-lang/rust/issues/126756
- https://github.com/rust-lang/rust/pull/126973
- https://github.com/rust-lang/rust/pull/127535
- https://github.com/rust-lang/rustfmt/pull/6204

## Unresolved questions

I am not aware of any unresolved questions.
2024-08-03 20:51:51 +02:00
bors
bbf60c897e Auto merge of #127324 - DianQK:match-br, r=cjgillot
Simplify match based on the cast result of `IntToInt`

Continue to complete #124150. The condition in #120614 is wrong, e.g. `-1i8` cannot be converted to `255i16`. I've rethought the issue and simplified the conditional judgment for a more straightforward approach. The new approach is to check **if the case value after the `IntToInt` conversion equals the target value**.

In different types, `IntToInt` uses different casting methods. This rule is as follows:

- `i8`/`u8` to `i8`/`u8`: do nothing.
- `i8` to `i16`/`u16`: sign extension.
- `u8` to `i16`/`u16`: zero extension.
- `i16`/`u16` to `i8`/`u8`: truncate to the target size.

The previous error was a mix of zext and sext.

r? mir-opt
2024-08-03 18:48:30 +00:00
clubby789
8497800abd Add test for updating enum discriminant through pointer 2024-08-03 16:41:49 +00:00
Chris Denton
f28d157091
Update rmake.rs 2024-08-03 16:04:37 +00:00
Christopher Swenson
36a805939e Remove unnecessary constants from flt2dec dragon
The "dragon" `flt2dec` algorithm uses multi-precision multiplication by
(sometimes large) powers of 10. It has precomputed some values to help
with these calculations.

BUT:

* There is no need to store powers of 10 and 2 * powers of 10: it is
  trivial to compute the second from the first.
* We can save a chunk of memory by storing powers of 5 instead of powers
  of 10 for the large powers (and just shifting by 2 as appropriate).
* This also slightly speeds up the routines (by ~1-3%) since the
  intermediate products are smaller and the shift is cheap.

In this PR, we remove the unnecessary constants and do the necessary
adjustments.

Relevant benchmarks before (on my Threadripper 3970X, x86_64-unknown-linux-gnu):

```
num::flt2dec::bench_big_shortest                      137.92/iter   +/- 2.24
num::flt2dec::strategy:🐉:bench_big_exact_12   2135.28/iter  +/- 38.90
num::flt2dec::strategy:🐉:bench_big_exact_3     904.95/iter  +/- 10.58
num::flt2dec::strategy:🐉:bench_big_exact_inf 47230.33/iter +/- 320.84
num::flt2dec::strategy:🐉:bench_big_shortest   3915.05/iter  +/- 51.37
```

and after:

```
num::flt2dec::bench_big_shortest                      137.40/iter   +/- 2.03
num::flt2dec::strategy:🐉:bench_big_exact_12   2101.10/iter  +/- 25.63
num::flt2dec::strategy:🐉:bench_big_exact_3     873.86/iter   +/- 4.20
num::flt2dec::strategy:🐉:bench_big_exact_inf 47468.19/iter +/- 374.45
num::flt2dec::strategy:🐉:bench_big_shortest   3877.01/iter  +/- 45.74
```
2024-08-03 08:49:38 -07:00
bors
edc4dc337b Auto merge of #128370 - petrochenkov:libsearch, r=bjorn3
linker: Pass fewer search directories to the linker

- The logic for passing `-L` directories to the linker is consolidated in a single function, so the search priorities are immediately clear.
- Only `-Lnative=`, `-Lframework=` `-Lall=` directories are passed to linker, but not `-Lcrate=` and others. That's because only native libraries are looked up by name by linker, all Rust crates are passed using full paths, and their directories should not interfere with linker search paths.
- The main sysroot library directory shouldn't generally be passed because it shouldn't contain native libraries, except for one case which is now marked with a FIXME.
- This also helps with https://github.com/rust-lang/rust/pull/123436, in which we need to walk the same list of directories manually.

The next step is to migrate `find_native_static_library` to exactly the same set and order of search directories (which may be a bit annoying for the `iOSSupport` directories https://github.com/rust-lang/rust/pull/121430#issuecomment-2256372341).
2024-08-03 15:29:52 +00:00
Chris Denton
c2523c9543
Use object in run-make/symbols-visibility 2024-08-03 14:56:16 +00:00
Guillaume Gomez
a3a09b488f Simplify body usage in rustdoc 2024-08-03 15:37:27 +02:00
bors
1f47624f9a Auto merge of #128404 - compiler-errors:revert-dead-code-changes, r=pnkfelix
Revert recent changes to dead code analysis

This is a revert to recent changes to dead code analysis, namely:
* efdf219 Rollup merge of #128104 - mu001999-contrib:fix/128053, r=petrochenkov
* a70dc297a8 Rollup merge of #127017 - mu001999-contrib:dead/enhance, r=pnkfelix
* 31fe9628cf Rollup merge of #127107 - mu001999-contrib:dead/enhance-2, r=pnkfelix
* 2724aeaaeb Rollup merge of #126618 - mu001999-contrib:dead/enhance, r=pnkfelix
* 977c5fd419 Rollup merge of #126315 - mu001999-contrib:fix/126289, r=petrochenkov
* 13314df21b Rollup merge of #125572 - mu001999-contrib:dead/enhance, r=pnkfelix

There is an additional change stacked on top, which suppresses false-negatives that were masked by this work. I believe the functions that are touched in that code are legitimately unused functions and the types are not reachable since this `AnonPipe` type is not publically reachable -- please correct me if I'm wrong cc `@NobodyXu` who added these in ##127153.

Some of these reverts (#126315 and #126618) are only included because it makes the revert apply cleanly, and I think these changes were only done to fix follow-ups from the other PRs?

I apologize for the size of the PR and the churn that it has on the codebase (and for reverting `@mu001999's` work here), but I'm putting this PR up because I am concerned that we're making ad-hoc changes to fix bugs that are fallout of these PRs, and I'd like to see these changes reimplemented in a way that's more separable from the existing dead code pass. I am happy to review any code to reapply these changes in a more separable way.

cc `@mu001999`
r? `@pnkfelix`

Fixes #128272
Fixes #126169
2024-08-03 13:04:30 +00:00
Chris Denton
eb451464a7
Remove BAR for run-make/used.rs 2024-08-03 13:02:32 +00:00
Chris Denton
b564b70d1c
Update run-make/used to use any_symbol_contains 2024-08-03 12:40:53 +00:00
Michael Goulet
106cf7bec2 Remove another false-negative hidden by dead code changes 2024-08-03 07:57:31 -04:00
Michael Goulet
a57b8b91db Bless test fallout 2024-08-03 07:57:31 -04:00
Michael Goulet
cbd27db9a9 Suppress new false-negatives that were masked by dead code analysis changes 2024-08-03 07:57:31 -04:00
Michael Goulet
ac56007ea7 Revert "Rollup merge of #125572 - mu001999-contrib:dead/enhance, r=pnkfelix"
This reverts commit 13314df21b, reversing
changes made to 6e534c73c3.
2024-08-03 07:57:31 -04:00
Michael Goulet
d29818c9f5 Revert "Rollup merge of #126315 - mu001999-contrib:fix/126289, r=petrochenkov"
This reverts commit 977c5fd419, reversing
changes made to 24c94f0e4f.
2024-08-03 07:57:31 -04:00
Michael Goulet
22da616245 Revert "Rollup merge of #126618 - mu001999-contrib:dead/enhance, r=pnkfelix"
This reverts commit 2724aeaaeb, reversing
changes made to d929a42a66.
2024-08-03 07:57:31 -04:00
Michael Goulet
5f5b4ee128 Revert "Rollup merge of #127107 - mu001999-contrib:dead/enhance-2, r=pnkfelix"
This reverts commit 31fe9628cf, reversing
changes made to f20307851e.
2024-08-03 07:57:31 -04:00
Michael Goulet
c6b6c1270a Revert "Rollup merge of #127017 - mu001999-contrib:dead/enhance, r=pnkfelix"
This reverts commit a70dc297a8, reversing
changes made to ceae37188b.
2024-08-03 07:57:31 -04:00
Michael Goulet
361ab1af0c Revert "Rollup merge of #128104 - mu001999-contrib:fix/128053, r=petrochenkov"
This reverts commit 91b18a058c, reversing
changes made to 9aedec9313.
2024-08-03 07:57:30 -04:00
Vadim Petrochenkov
1f873f9cf1 Fix linking to sanitizers on Apple targets 2024-08-03 14:20:18 +03:00
Vadim Petrochenkov
35977b47cc linker: Pass fewer search directories to the linker 2024-08-03 14:20:18 +03:00
bors
ad0a2b7180 Auto merge of #128595 - matthiaskrgr:rollup-7a4qa8b, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #126704 (Added SHA512, SM3, SM4 target-features and `sha512_sm_x86` feature gate)
 - #127586 (Add `#[must_use]` to some `into_raw*` functions.)
 - #128161 (nested aux-build in tests/rustdoc/ tests)
 - #128303 (Enable `std::io::copy` specialisation for `std::pipe::{PipeReader, PipeWriter}`)
 - #128368 (Formatting tweaks)
 - #128483 (Still more `cfg` cleanups)
 - #128557 (chore: use shorthand initializer)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-03 10:40:36 +00:00
Matthias Krüger
9b69042d5b
Rollup merge of #128557 - nyurik:dup-init, r=compiler-errors
chore: use shorthand initializer

Tiny readability improvement - don't use redundant initializer vars
2024-08-03 11:17:45 +02:00
Matthias Krüger
dee57ce043
Rollup merge of #128483 - nnethercote:still-more-cfg-cleanups, r=petrochenkov
Still more `cfg` cleanups

Found while looking closely at `cfg`/`cfg_attr` processing code.

r? `````````@petrochenkov`````````
2024-08-03 11:17:44 +02:00
Matthias Krüger
2f549aac39
Rollup merge of #128368 - nnethercote:rustfmt-tweaks, r=cuviper
Formatting tweaks

Some small post-#125443 formatting tweaks.

r? ``@cuviper``
2024-08-03 11:17:44 +02:00
Matthias Krüger
95d9f1c4ab
Rollup merge of #128303 - NobodyXu:specialise-for-pipe, r=cuviper
Enable `std::io::copy` specialisation for `std::pipe::{PipeReader, PipeWriter}`

Enable `std::io::copy` specialisation on unix for the newly added anonymous pipe API, tracking issue rust-lang/rust#127154
2024-08-03 11:17:43 +02:00
Matthias Krüger
47a795bbd3
Rollup merge of #128161 - EtomicBomb:just-compiletest, r=notriddle
nested aux-build in tests/rustdoc/ tests

* Fixes bug that prevented using nested aux-build in `tests/rustdoc/` tests. Before, `fn document` and the auxiliary builder disagreed about where to find the nested aux-build source file (`auxiliary/auxiliary/aux.rs` vs `auxiliary/aux.rs`), preventing them from building. Picked the latter in line with other builders in compiletest.
* Adds `//@ doc-flags` header, which forwards flags to rustdoc and not rustc.
* Adds `//@ unique-doc-out-dir` header, which sets the --out-dir for the rustdoc invocation to a unique directory: `<root out dir>/docs/<test name>/doc`
* Changes working directory of the rustdoc invocation to the root out directory (common among all aux-builds). Prior art: exec_compiled_test in runtest.rs
* Adds tests that use nested aux builds and new headers

These changes provide useful capabilities for writing rustdoc tests on their own. They are also needed to test the implementation for the [mergable-rustdoc-cross-crate-info](https://github.com/rust-lang/rfcs/pull/3662) RFC.

try-job: x86_64-msvc
2024-08-03 11:17:42 +02:00
Matthias Krüger
1f700139f8
Rollup merge of #127586 - zachs18:more-must-use, r=cuviper
Add `#[must_use]` to some `into_raw*` functions.

cc #121287

r? ``@cuviper``

Adds `#[must_use = "losing the pointer will leak memory"]`[^1] to `Box::into_raw(_with_allocator)`, `Vec::into_raw_parts(_with_alloc)`, `String::into_raw_parts`[^2], and `rc::{Rc, Weak}::into_raw_with_allocator` (Rc's normal `into_raw` and all of `Arc`'s `into_raw*`s are already `must_use`).

Adds `#[must_use = "losing the raw <resource name may leak resources"]` to `IntoRawFd::into_raw_fd`, `IntoRawSocket::into_raw_socket`, and `IntoRawHandle::into_raw_handle`.

[^1]: "*will* leak memory" may be too-strong wording (since `Box`/`Vec`/`String`/`rc::Weak` might not have a backing allocation), but I left it as-is for simplicity and consistency.

[^2]: `String::into_raw_parts`'s `must_use` message is changed from the previous (possibly misleading) "`self` will be dropped if the result is not used".
2024-08-03 11:17:42 +02:00
Matthias Krüger
8aa18290a4
Rollup merge of #126704 - sayantn:sha, r=Amanieu
Added SHA512, SM3, SM4 target-features and `sha512_sm_x86` feature gate

This is an effort towards #126624. This adds support for these 3 target-features and introduces the feature flag `sha512_sm_x86`, which would gate these target-features and the yet-to-be-implemented detection and intrinsics in stdarch.
2024-08-03 11:17:41 +02:00
Ralf Jung
21c02517c3 Miri: add a flag to do recursive validity checking 2024-08-03 10:33:58 +02:00
bors
47aea6f806 Auto merge of #3785 - rust-lang:rustup-2024-08-03, r=RalfJung
Automatic Rustup
2024-08-03 08:32:17 +00:00
bors
a6043039ad Auto merge of #128356 - Oneirical:real-estate-reaLTOr, r=jieyouxu
Migrate `cross-lang-lto-clang` and `cross-lang-lto-pgo-smoketest` `run-make` tests to rmake

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

This has the same problem outlined by #126180, where the tests do not actually run as no test-running CI enviroment has `RUSTBUILD_FORCE_CLANG_BASED_TESTS` set.

However, I still find it interesting to turn the Makefiles into the rmake format until the Clang issue is fixed.

This should technically be tested on MSVC... if MSVC actually ran Clang tests.

try-job: x86_64-gnu-debug
2024-08-03 08:07:00 +00:00
onur-ozkan
5ce554f4ec allow setting link-shared and static-libstdcpp with CI LLVM
These options also affect `compiler/rustc_llvm` builds. They should be configurable
even when using CI LLVM.

Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-08-03 09:36:40 +03:00
The Miri Cronjob Bot
62e2800ee4 Merge from rustc 2024-08-03 05:11:07 +00:00
The Miri Cronjob Bot
6aab319def Preparing for merge from rustc 2024-08-03 05:03:34 +00:00
bors
eefd2eac52 Auto merge of #128576 - weihanglo:update-cargo, r=weihanglo
Update cargo

15 commits in 257b72b8adfb1f2aa9916cefca67285c21666276..fa646583675d7c140482bd906145c71b7fb4fc2b
2024-07-30 15:08:27 +0000 to 2024-08-02 16:08:06 +0000
- refactor(toml): Rename 'resolved' to 'normalized' (rust-lang/cargo#14342)
- faq: rephrase offline usage. (rust-lang/cargo#14336)
- docs(unstable): Improve nightly link (rust-lang/cargo#14344)
- Fix a typo in 1.81 changes (rust-lang/cargo#14343)
- Change tests to support `rustc` wording changes (rust-lang/cargo#14341)
- chore(deps): update rust crate windows-sys to 0.59 (rust-lang/cargo#14335)
- chore(deps): update rust crate gix to 0.64.0 (rust-lang/cargo#14332)
- chore(deps): update compatible (rust-lang/cargo#14331)
- chore(deps): update rust crate rusqlite to 0.32.0 (rust-lang/cargo#14334)
- fix: also build manpage for cargo.md (rust-lang/cargo#14339)
- fix(config): Adjust MSRV resolve config field name / values (rust-lang/cargo#14296)
- fix(toml): Resolve regression from toml_edit 0.22.18 (rust-lang/cargo#14329)
- test(publish): More dev-dep stripping cases (rust-lang/cargo#14327)
- Use gmake on AIX (rust-lang/cargo#14323)
- fix(publish): Don't strip non-dev features (rust-lang/cargo#14325)

r? ghost
2024-08-03 03:46:44 +00:00
Michael Goulet
b0beb64830 Use ParamEnv::reveal_all in CFI 2024-08-02 23:24:50 -04:00
DianQK
1f9d9603c0
Re-enable SimplifyToExp in match_branches. 2024-08-03 10:55:46 +08:00
DianQK
8b9d7b1489
Simplify match based on the cast result of IntToInt. 2024-08-03 10:55:43 +08:00
Oli Scherer
33cb33441d Add test for coroutine attribute 2024-08-03 02:28:59 +00:00
Oli Scherer
ed010dd32c Assert that all attributes are actually checked via CheckAttrVisitor and aren't accidentally usable on completely unrelated HIR nodes
Co-authored-by: Jieyou Xu <jieyouxu@outlook.com>
2024-08-03 02:26:21 +00:00
Konippi
a798e0f488 chore: refactor backtrace style in panic 2024-08-03 11:12:16 +09:00
Noah Lev
220c2d8c9b Restructure add_item_to_search_index to eliminate code paths
Many of the code paths it handled were actually impossible. In other
cases, the various checks and transformations were spread around in such
a way that it was hard to tell what was going on.
2024-08-02 18:02:27 -07:00
Noah Lev
08f4d54ea9 Extract local variables 2024-08-02 18:02:27 -07:00
Noah Lev
015aa8d0fb Restructure a confusing match 2024-08-02 18:02:27 -07:00
Noah Lev
4e2084769b rustdoc: Simplify some search index code 2024-08-02 18:02:26 -07:00
Noah Lev
2721e97c5d rustdoc: Clarify construction of name for search index 2024-08-02 17:59:52 -07:00