Commit Graph

291081 Commits

Author SHA1 Message Date
Guillaume Gomez
cd0adc9d7b Rollup merge of #140370 - WaffleLapkin:unqualified, r=jdonszelmann
Improve diagnostics for usage of qualified paths within tuple struct exprs/pats

For patterns the old diagnostic was just incorrect, but I also added machine applicable suggestions.

For context, this special cases errors for `<T as Trait>::Assoc(..)` patterns and expressions (latter is just a call). Tuple struct patterns and expressions both live in the value namespace, so they are not forwarded through associated *types*.

r? ``@jdonszelmann``

cc ``@petrochenkov`` in https://github.com/rust-lang/rust/pull/80080#issuecomment-800630582 you were wondering why it doesn't work for types, that's why — tuple patterns are resolved in the value namespace.
2025-06-01 19:35:41 +02:00
Nadrieril
1e169d8dc4 Optionally don't steal the THIR 2025-06-01 19:14:13 +02:00
bors
a88fc0eaae Auto merge of #141860 - RalfJung:miri-sync, r=RalfJung
Miri subtree update

r? `@ghost`

Includes https://github.com/rust-lang/miri/pull/4370 to unbreak PR CI. (So we're committing to having bda28aa38 in the Miri history by landing this, whether or not that Miri PR lands.)

Cc `@Noratrieb` `@tiif`
2025-06-01 15:01:58 +00:00
Ralf Jung
0884c683ad tweak comment and use a weaker fence 2025-06-01 16:32:18 +02:00
zacryol
33127afef0 Fix typo in StructuralPartialEq docs
`equialent` => `equivalent`
2025-06-01 08:15:00 -06:00
Noratrieb
b88cbed741 Make sure to sync on file-io.rs tokio test
Tokio `AsyncWriteExt::write` doesn't actually ensure that the contents
have written, it just *starts* the write operation. To ensure that the
file has actually been written, we need to `sync_all` first.
2025-06-01 15:43:14 +02:00
onur-ozkan
a71c00a713 resolve if-let-chain FIXME on bootstrap
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2025-06-01 14:43:02 +03:00
bors
9b0268a43b Auto merge of #141731 - compiler-errors:tweak-fast-path-trait, r=lcnr
Tweak fast path trait handling

(1.) Make it more sound by considering polarity (lol)

(2.) Make it more general, by considering higher-ranked size/copy/clone

(2.) Make it less observable, by only doing copy/clone fast path if there are no regions involved

r? lcnr
2025-06-01 10:59:38 +00:00
Ralf Jung
4b94f670de Merge pull request #4368 from Noratrieb/write-not-little-but-a-lot-instead
Fix tokio/file-io.rs test relying on `read`/`write` not being short
2025-06-01 10:11:18 +00:00
Noratrieb
9f8e157a1f Fix tokio/file-io.rs test relying on read/write not being short
The test did `write` and `read` and hoped that it would read/write
everything, which doesn't always happen and caused CI failures.
Switch to `write_all` and `read_to_end` to make it more reliable.
2025-06-01 11:43:55 +02:00
Tim Hutt
bdd680ffd1 Add unimplemented current_dll_path() for WASI
This is the only change needed to Rust to allow compiling rustfmt for WASI (rustfmt uses some internal rustc crates).
2025-06-01 09:20:05 +01:00
bors
ba55b7ce3c Auto merge of #141730 - osiewicz:collect-crate-deps-postorder-use-indexset, r=nnethercote
cstore: Use IndexSet as backing store for postorder dependencies

`<rustc_metadata::creader::CStore>::push_dependencies_in_postorder` showed up in new benchmarks from https://github.com/rust-lang/rustc-perf/pull/2143, hence I gave it a shot to remove an obvious O(n) there.

r? nnethercote
2025-06-01 07:40:52 +00:00
Stan Manilov
171312aa4e Add opaque type attributes
This allows for the code to compile on `nightly`.
2025-06-01 10:36:28 +03:00
王宇逸
810a564d9b Fix TLS model on bootstrap for cygwin 2025-06-01 14:56:54 +08:00
Ben Kimock
af0829b9f1 Merge pull request #4364 from rust-lang/rustup-2025-06-01
Automatic Rustup
2025-06-01 05:34:18 +00:00
The Miri Cronjob Bot
2150180050 Merge from rustc 2025-06-01 05:05:10 +00:00
The Miri Cronjob Bot
de289e45fd Preparing for merge from rustc 2025-06-01 04:57:44 +00:00
bors
13a4540908 Auto merge of #141725 - nnethercote:avoid-UsePath-overcounting, r=BoxyUwU
Avoid over-counting of `UsePath` in the HIR stats.

Currently we over-count. Details in the individual commits.

r? `@BoxyUwU`
2025-06-01 04:21:50 +00:00
Deadbeef
c33b08552b Add visit_id to ast Visitor
This helps with efforts to deduplicate the `MutVisitor` and the
`Visitor` code. All users of `Visitor`'s methods that have extra
`NodeId` as parameters really just want to visit the id on its
own.

Also includes some methods deduplicated and cleaned up as
a result of this change.
2025-06-01 02:38:24 +00:00
bors
337c11e593 Auto merge of #141842 - jhpratt:rollup-r7ldrl2, r=jhpratt
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#141072 (Stabilize feature `result_flattening`)
 - rust-lang/rust#141215 (std: clarify Clone trait documentation about duplication semantics)
 - rust-lang/rust#141277 (Miri CI: test aarch64-apple-darwin in PRs instead of the x86_64 target)
 - rust-lang/rust#141521 (Add `const` support for float rounding methods)
 - rust-lang/rust#141812 (Fix "consider borrowing" for else-if)
 - rust-lang/rust#141832 (library: explain TOCTOU races in `fs::remove_dir_all`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-01 01:02:51 +00:00
Folkert de Vries
be13ce341a implement va_arg for powerpc
This actually fixes a bug where before only 20 arguments could be passed. As far as I can tell, an arbitrary number of arguments is now supported
2025-06-01 00:51:01 +02:00
Jacob Pratt
7f306d5729 Rollup merge of #141832 - workingjubilee:explain-what-toctou-races-are, r=thomcc,ChrisDenton
library: explain TOCTOU races in `fs::remove_dir_all`

In the previous description it said there was a TOCTOU race but did not explain exactly what the problem was. I sat down with the CVE, reviewed its text, and created this explanation. This context should hopefully help people understand the actual risk as-such.

Incidentally, it also fixes the capitalization on the name of Redox OS.

Original CVE and advisory:
- CVE: https://www.cve.org/CVERecord?id=CVE-2022-21658
- security advisory: https://groups.google.com/g/rustlang-security-announcements/c/R1fZFDhnJVQ?pli=1
- github cross-post: https://github.com/rust-lang/rust/security/advisories/GHSA-r9cc-f5pr-p3j2
2025-06-01 00:35:54 +02:00
Jacob Pratt
542dcbf6a2 Rollup merge of #141812 - JonathanBrouwer:fix-else-if-help, r=jdonszelmann
Fix "consider borrowing" for else-if

Fixes rust-lang/rust#141810

When trying to suggest a borrow on a `if` or `block` expression, instead we now recurse into the `if` or `block`.
The comments in the code should explain the goal of the new code.

r? ``@jdonszelmann``
2025-06-01 00:35:53 +02:00
Jacob Pratt
ac49339e03 Rollup merge of #141521 - ruancomelli:const-float-rounding, r=RalfJung
Add `const` support for float rounding methods

# Add `const` support for float rounding methods

This PR makes the following float rounding methods `const`:

- `f64::{floor, ceil, trunc, round, round_ties_even}`
- and the corresponding methods for `f16`, `f32` and `f128`

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

## Procedure

I followed c09ed3e767 as closely as I could in making float methods `const`, and also received great guidance from https://internals.rust-lang.org/t/const-rounding-methods-in-float-types/22957/3?u=ruancomelli.

## Note

This is my first code contribution to the Rust project, so please let me know if I missed anything - I'd be more than happy to revise and learn more. Thank you for taking the time to review it!
2025-06-01 00:35:53 +02:00
Jacob Pratt
c4ba6b00cc Rollup merge of #141277 - RalfJung:miri-ci, r=oli-obk
Miri CI: test aarch64-apple-darwin in PRs instead of the x86_64 target

The aarch64 target is more important, and also this ensures we cover all main architectures (x86_64, i686, aarch64) in PR CI.
2025-06-01 00:35:51 +02:00
Jacob Pratt
fa494d652d Rollup merge of #141215 - xizheyin:issue-141138, r=workingjubilee
std: clarify Clone trait documentation about duplication semantics

Closes rust-lang/rust#141138

The change explicitly explains that cloning behavior varies by type and clarifies that smart pointers (`Arc`, `Rc`) share the same underlying data. I've also added an example of cloning to Arc.
2025-06-01 00:35:50 +02:00
Jacob Pratt
241ec137fb Rollup merge of #141072 - Rynibami:stabilize-const-result-flatten, r=jhpratt
Stabilize feature `result_flattening`

Stabilizes the `Result::flatten` method

## Implementations

- [x] Implementation `Result::flatten`: https://github.com/rust-lang/rust/pull/70140
- [x] Implementation `const` `Result::flatten`: https://github.com/rust-lang/rust/pull/130692
- [x] Update stabilization attribute macros (this PR)

## Stabilization process

- [x] Created this PR [suggested](https://github.com/rust-lang/rust/issues/70142#issuecomment-2885044548) by ``@RalfJung``
- [x] FCP (haven't found any, is it applicable here?)
- [ ] Close issue rust-lang/rust#70142
2025-06-01 00:35:50 +02:00
bors
f0999ffdc4 Auto merge of #139118 - scottmcm:slice-get-unchecked-intrinsic, r=workingjubilee
`slice.get(i)` should use a slice projection in MIR, like `slice[i]` does

`slice[i]` is built-in magic, so ends up being quite different from `slice.get(i)` in MIR, even though they're both doing nearly identical operations -- checking the length of the slice then getting a ref/ptr to the element if it's in-bounds.

This PR adds a `slice_get_unchecked` intrinsic for `impl SliceIndex for usize` to use to fix that, so it no longer needs to do a bunch of lines of pointer math and instead just gets the obvious single statement.  (This is *not* used for the range versions, since `slice[i..]` and `slice[..k]` can't use the mir Slice projection as they're using fenceposts, not indices.)

I originally tried to do this with some kind of GVN pattern, but realized that I'm pretty sure it's not legal to optimize `BinOp::Offset` to `PlaceElem::Index` without an extremely complicated condition.  Basically, the problem is that the `Index` projection on a dereferenced slice pointer *cares about the metadata*, since it's UB to `PlaceElem::Index` outside the range described by the metadata.  But then you cast the fat pointer to a thin pointer then offset it, that *ignores* the slice length metadata, so it's possible to write things that are legal with `Offset` but would be UB if translated in the obvious way to `Index`.  Checking (or even determining) the necessary conditions for that would be complicated and error-prone, whereas this intrinsic-based approach is quite straight-forward.

Zero backend changes, because it just lowers to MIR, so it's already supported naturally by CTFE/Miri/cg_llvm/cg_clif.
2025-05-31 21:38:21 +00:00
nora
a2fd1aa46f Merge pull request #2434 from rust-lang/tshepang-mailmap
update surname (was lekhonkhobe previously) and email
2025-05-31 23:20:40 +02:00
Tshepang Mbambo
755a5e32dd update surname (was lekhonkhobe previously) and email 2025-05-31 23:06:14 +02:00
Jubilee Young
7f7c415d03 library: explain TOCTOU races in fs::remove_dir_all
In the previous description it said there was a TOCTOU race but did not
explain exactly what the problem was. I sat down with the CVE, reviewed
its text, and created this explanation. This context should hopefully
help people understand the actual risk as-such.

Incidentally, it also fixes the capitalization on the name of Redox OS.
2025-05-31 14:05:29 -07:00
nora
8e5ca3068c Merge pull request #2432 from rust-lang/tshepang-patch-1
suggest build/rust-analyzer instead of build-rust-analyzer
2025-05-31 22:53:01 +02:00
nora
da341021b9 Merge pull request #2433 from rust-lang/tshepang-patch-2
replace a broken sentence
2025-05-31 22:52:11 +02:00
Ralf Jung
f388c987cf terminology: allocated object → allocation 2025-05-31 22:49:14 +02:00
Tshepang Mbambo
db4e60286b replace a broken sentence 2025-05-31 22:30:00 +02:00
Tshepang Mbambo
ec84e80650 suggest build/rust-analyzer instead of build-rust-analyzer
This is better because
- `./x clean` also removes it, without needing extra text to explain it
- Does not need an extra .gitignore entry
2025-05-31 22:21:04 +02:00
binarycat
a8b5e706b7 source_span_for_markdown_range: fix utf8 violation
it is non-trivial to reproduce this bug through rustdoc,
which uses this function less than clippy,
so the regression test was added as a unit test
instead of an integration test.
2025-05-31 14:51:16 -05:00
Ruan Comelli
f8e97badb2 Add const support for float rounding methods
Add const support for the float rounding methods floor, ceil, trunc,
fract, round and round_ties_even.
This works by moving the calculation logic from

     src/tools/miri/src/intrinsics/mod.rs

into

     compiler/rustc_const_eval/src/interpret/intrinsics.rs.

All relevant method definitions were adjusted to include the `const`
keyword for all supported float types: f16, f32, f64 and f128.

The constness is hidden behind the feature gate

     feature(const_float_round_methods)

which is tracked in

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

This commit is a squash of the following commits:
- test: add tests that we expect to pass when float rounding becomes const
- feat: make float rounding methods `const`
- fix: replace `rustc_allow_const_fn_unstable(core_intrinsics)` attribute with `#[rustc_const_unstable(feature = "f128", issue = "116909")]` in `library/core/src/num/f128.rs`
- revert: undo update to `library/stdarch`
- refactor: replace multiple `float_<mode>_intrinsic` rounding methods with a single, parametrized one
- fix: add `#[cfg(not(bootstrap))]` to new const method tests
- test: add extra sign tests to check `+0.0` and `-0.0`
- revert: undo accidental changes to `round` docs
- fix: gate `const` float round method behind `const_float_round_methods`
- fix: remove unnecessary `#![feature(const_float_methods)]`
- fix: remove unnecessary `#![feature(const_float_methods)]` [2]
- revert: undo changes to `tests/ui/consts/const-eval/float_methods.rs`
- fix: adjust after rebase
- test: fix float tests
- test: add tests for `fract`
- chore: add commented-out `const_float_round_methods` feature gates to `f16` and `f128`
- fix: adjust NaN when rounding floats
- chore: add FIXME comment for de-duplicating float tests
- test: remove unnecessary test file `tests/ui/consts/const-eval/float_methods.rs`
- test: fix tests after upstream simplification of how float tests are run
2025-05-31 15:26:57 -03:00
bors
4d08223c05 Auto merge of #141824 - matthiaskrgr:rollup-7nffwd0, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#140787 (Note expr being cast when encounter NonScalar cast error)
 - rust-lang/rust#141112 (std: note that `std::str::from_utf8*` functions are aliases to `<str>::from_utf8*` methods)
 - rust-lang/rust#141646 (Document what `distcheck` is intended to exercise)
 - rust-lang/rust#141740 (Hir item kind field order)
 - rust-lang/rust#141793 (`tests/ui`: A New Order [1/N])
 - rust-lang/rust#141805 (Update `compiler-builtins` to 0.1.160)
 - rust-lang/rust#141815 (Enable non-leaf Frame Pointers for mingw-w64 Arm64 Windows)
 - rust-lang/rust#141819 (Fixes for building windows-gnullvm hosts)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-05-31 18:16:35 +00:00
Matthias Krüger
23cc24e0bf Rollup merge of #141819 - mati865:windows-gnullvm-host-fixes, r=jieyouxu
Fixes for building windows-gnullvm hosts

Split out from: https://github.com/rust-lang/rust/pull/140772
2025-05-31 18:51:51 +02:00
Matthias Krüger
0254c67b1a Rollup merge of #141815 - mati865:mingw-aarch64-frame-pointers, r=workingjubilee
Enable non-leaf Frame Pointers for mingw-w64 Arm64 Windows

Based on https://github.com/rust-lang/rust/pull/140828

I don't have AArch64 Windows to test it, but I trust LLVM to handle it well.
2025-05-31 18:51:51 +02:00
Matthias Krüger
04641b14a3 Rollup merge of #141805 - tgross35:update-builtins, r=tgross35
Update `compiler-builtins` to 0.1.160

Includes the following changes:

* Enable `__powitf2` on MSVC [1]
* Update `CmpResult` to use a pointer-sized return type [2]
* Better code reuse between `libm` and `compiler-builtins` [3], [4]
* Stop building C versions of `__netf2` [5] since we have our own implementation

[1]: https://github.com/rust-lang/compiler-builtins/pull/918
[2]: https://github.com/rust-lang/compiler-builtins/pull/920
[3]: https://github.com/rust-lang/compiler-builtins/pull/879
[4]: https://github.com/rust-lang/compiler-builtins/pull/925
[5]: https://github.com/rust-lang/compiler-builtins/pull/828
2025-05-31 18:51:50 +02:00
Matthias Krüger
282c6654a0 Rollup merge of #141793 - Kivooeo:test-reform, r=jieyouxu
`tests/ui`: A New Order [1/N]

not sure if i should say something about changes here, just part of rust-lang/rust#133895

but this is my very first time doing something like this, id love to keep contributing in this area later on, so any feedback is appreciated

also should say that im going to squash it after agreement on changes

r? `@jieyouxu`

mind if i name this PR series like "`tests/ui`: A New Order [N/N]", im not sure if it fits the project tone, so id like your approval first — but i think it sounds really neat (Star Wars reference)

this could be a first part :)
2025-05-31 18:51:49 +02:00
Matthias Krüger
387170c74b Rollup merge of #141740 - nnethercote:hir-ItemKind-field-order, r=fee1-dead
Hir item kind field order

A follow-up to rust-lang/rust#141675.

r? `@fee1-dead`
2025-05-31 18:51:48 +02:00
Matthias Krüger
ec39208527 Rollup merge of #141646 - jieyouxu:distcheck, r=Mark-Simulacrum
Document what `distcheck` is intended to exercise

Or at least attempt to.

Closes rust-lang/rust#141387.

cc `@marcoieni` (re. [#t-infra/bootstrap > Speed up distcheck](https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Speed.20up.20distcheck/with/520208870))
r? `@Mark-Simulacrum` (as you may have some clues about if this is accurate)
2025-05-31 18:51:48 +02:00
Matthias Krüger
a2bf37e39e Rollup merge of #141112 - xizheyin:issue-141079, r=Mark-Simulacrum
std: note that `std::str::from_utf8*` functions are aliases to `<str>::from_utf8*` methods

Closes #141079

r? libs
2025-05-31 18:51:47 +02:00
Matthias Krüger
05debb0d0d Rollup merge of #140787 - xizheyin:issue-140491, r=nnethercote
Note expr being cast when encounter NonScalar cast error

Fixes #140491

I added note for `expr` so that it doesn't treat `&x as T` as `&(x as T)` but `(&x) as T`. But I'm not sure if I want to add note for all NonScalar, maybe for specific `expr_ty`?

r? compiler
2025-05-31 18:51:47 +02:00
许杰友 Jieyou Xu (Joe)
e5139a7ff7 Merge pull request #2431 from jieyouxu/review-group 2025-06-01 00:40:59 +08:00
Jonathan Brouwer
b1a1df2efe Fix consider borrowing for else-if 2025-05-31 18:34:35 +02:00
Jonathan Brouwer
a261d167ac Failing tests for "consider borrowing" 2025-05-31 18:32:50 +02:00