Commit Graph

290114 Commits

Author SHA1 Message Date
Tshepang Mbambo
a3bd12b88a Path::with_extension: improve examples 2025-05-24 22:12:15 +02:00
bors
3e674b06b5 Auto merge of #141463 - matthiaskrgr:rollup-7k48ui3, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #138896 (std: fix aliasing bug in UNIX process implementation)
 - #140832 (aarch64-linux: Default to FramePointer::NonLeaf)
 - #141065 (Updated std doctests for wasm)
 - #141369 (Simplify `format_integer_with_underscore_sep`)
 - #141374 (make shared_helpers exe function work for both cygwin and non-cygwin hosts)
 - #141398 (chore: fix typos in comment)
 - #141457 (Update mdbook to 0.4.50)

Failed merges:

 - #141405 (GetUserProfileDirectoryW is now documented to always store the size)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-05-23 18:36:34 +00:00
Matthias Krüger
ae3b69652e Rollup merge of #141457 - ehuss:update-mdbook, r=Mark-Simulacrum
Update mdbook to 0.4.50

This updates mdbook to 0.4.50 which brings in several changes, and specifically a fix for syntax highlighting in rust-by-example.

Changelog: https://github.com/rust-lang/mdBook/blob/master/CHANGELOG.md#mdbook-0450
2025-05-23 20:30:12 +02:00
Matthias Krüger
be2705caf2 Rollup merge of #141398 - Dannyyy93:typos, r=Noratrieb
chore: fix typos in comment

## Fix Typos in Comments

This PR addresses several typos in the Rust standard library's documentation comments:

- In `library/std/src/sync/mpmc/list.rs`: Corrected "attemped" to "attempted"
- In `library/std/src/sys/thread_local/guard/key.rs`: Fixed "defering" to "deferring"
- In `library/std/src/sys/thread_local/guard/key.rs`: Fixed "futher" to "further"

These changes improve documentation readability and consistency without affecting any functional code.
2025-05-23 20:30:11 +02:00
Matthias Krüger
8b69895ec2 Rollup merge of #141374 - jeremyd2019:patch-1, r=jieyouxu
make shared_helpers exe function work for both cygwin and non-cygwin hosts

On Cygwin, it needs to not append .exe, because /proc/self/exe (and therefore `std::env::current_exe`) does not include the .exe extension, breaking bootstrap's rustc wrapper.  On hosts other than Cygwin, it *does* need to append .exe because the file really does have a .exe extension, and non-Cygwin hosts won't be doing the same filename rewriting that Cygwin does when looking for a file X but finding only X.exe in its place.

Arising from discussion in https://github.com/rust-lang/rust/pull/140154#pullrequestreview-2855782812
``@mati865`` ``@Berrysoft``
2025-05-23 20:30:11 +02:00
Matthias Krüger
a4836e9965 Rollup merge of #141369 - yotamofek:pr/rustdoc/format_integer_with_underscore_sep, r=notriddle
Simplify `format_integer_with_underscore_sep`

Noticed that this helper fn only ever gets called with decimal-base-formatted ints, so can be simplified a lot by not trying to handle hex and octal radixes.
Second commit is completely unrelated, just simplified some code I wrote a while back 😁
2025-05-23 20:30:10 +02:00
Matthias Krüger
672ad6e172 Rollup merge of #141065 - ehuss:wasm-doctest-xcompile, r=Mark-Simulacrum
Updated std doctests for wasm

This updates some doctests that fail to run on wasm. We will soon be supporting cross-compiled doctests, and the test-various job fails to run these tests. These tests fail because wasm32-wasip1 does not support threads.
2025-05-23 20:30:09 +02:00
Matthias Krüger
d6a61daf60 Rollup merge of #140832 - workingjubilee:aarch64-linux-should-use-frame-pointers, r=compiler-errors
aarch64-linux: Default to FramePointer::NonLeaf

For aarch64-apple and aarch64-windows, platform docs state that code must use frame pointers correctly. This is because the AAPCS64 mandates that a platform specify its frame pointer conformance requirements:
- Apple: https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms#Respect-the-purpose-of-specific-CPU-registers
- Windows: https://learn.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions?view=msvc-170#integer-registers
- AAPCS64: 4492d1570e/aapcs64/aapcs64.rst (the-frame-pointer)

Unwinding code either requires unwind tables or frame pointers, and on aarch64 the expectation is that one can use frame pointers for this. Most Linux targets represent a motley variety of possible distributions, so it is unclear who to defer to on conformance, other than perhaps Arm. In the absence of a specific edict for a given aarch64-linux target, Rust will assume aarch64-linux targets also use non-leaf frame pointers. This reflects what compilers like clang do.
2025-05-23 20:30:09 +02:00
Matthias Krüger
c66c8e6b9c Rollup merge of #138896 - joboet:process_noalias, r=Noratrieb
std: fix aliasing bug in UNIX process implementation

`CStringArray` contained both `CString`s and their pointers. Unfortunately, since `CString` uses `Box`, moving the `CString`s into the `Vec` can (under stacked borrows) invalidate the pointer to the string, meaning the resulting `Vec<*const c_char>` was, from an opsem perspective, unusable. This PR removes removes the `Vec<CString>` from `CStringArray`, instead recreating the `CString`/`CStr` from the pointers when necessary. Also,`CStringArray` is now used for the process args as well, the old implementation was suffering from the same kind of bug.
2025-05-23 20:30:08 +02:00
Eric Huss
a12b455bd0 Update mdbook to 0.4.50 2025-05-23 09:37:23 -07:00
bors
e88e854634 Auto merge of #141437 - matthiaskrgr:rollup-jjagkxd, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #136400 (Improve handling of rustdoc lints when used with raw doc fragments.)
 - #140967 (Async drop poll shim for error dropee generates noop body)
 - #141019 (Update std doctests for android)
 - #141109 (discuss deadlocks in the std::io::pipe() example)
 - #141126 (rustdoc JSON: Don't apply `#[repr]` privacy heuristics)
 - #141376 (Rename `kw::Empty` as `sym::empty`.)
 - #141383 (Miri subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-05-23 15:13:45 +00:00
joboet
89a90d6640 std: add safety comments to CStringArray 2025-05-23 17:09:02 +02:00
joboet
a467516c22 std: fix aliasing bug in UNIX process implementation
`CStringArray` contained both `CString`s and their pointers. Unfortunately, since `CString` uses `Box`, moving the `CString`s into the `Vec` can (under stacked borrows) invalidate the pointer to the string, meaning the resulting `Vec<*const c_char>` was, from an opsem perspective, unusable. This PR removes removes the `Vec<CString>` from `CStringArray`, instead recreating the `CString`/`CStr` from the pointers when necessary. Also,`CStringArray` is now used for the process args as well, the old implementation was suffering from the same kind of bug.
2025-05-23 17:09:00 +02:00
Yotam Ofek
5c735d154e Small cleanup for qpath_to_string 2025-05-23 12:37:56 +00:00
Yotam Ofek
5b47d340d3 Simplify format_integer_with_underscore_sep
Only ever needs to handle decimal reprs
2025-05-23 12:37:56 +00:00
Matthias Krüger
ee1768c2a3 Rollup merge of #141383 - RalfJung:miri-sync, r=RalfJung
Miri subtree update

r? `@ghost`
2025-05-23 13:34:21 +02:00
Matthias Krüger
225ed8b9cf Rollup merge of #141376 - nnethercote:rename-kw-Empty, r=petrochenkov
Rename `kw::Empty` as `sym::empty`.

Because the empty string is not a keyword.

r? `@petrochenkov`
2025-05-23 13:34:20 +02:00
Matthias Krüger
893494c90f Rollup merge of #141126 - fmease:rev-rjson-priv-repr, r=aDotInTheVoid
rustdoc JSON: Don't apply `#[repr]` privacy heuristics

Split out from #116882.
Context: https://github.com/rust-lang/rust/pull/116882#issuecomment-2888349161.
Partially reverts #138018.

cc `@obi1kenobi`
r? aDotInTheVoid or rustdoc
2025-05-23 13:34:19 +02:00
Matthias Krüger
dfa3110ed4 Rollup merge of #141109 - oconnor663:pipe_example, r=Mark-Simulacrum
discuss deadlocks in the std::io::pipe() example

I think it's important to discuss deadlocks in examples of how to use pipes. The current example does include an explicit `drop()`, but it also implicitly relies on the fact that the `Command` object is temporary, so that it drops its copy of `pong_tx`. This sort of thing tends to trip people up when they use pipes for the first time. I might've gone overboard with the comments in this version, but I'm curious what folks think.
2025-05-23 13:34:19 +02:00
Matthias Krüger
036607ebba Rollup merge of #141019 - ehuss:android-doctest-xcompile, r=Mark-Simulacrum
Update std doctests for android

This updates some doctests that fail to run on android. We will soon be supporting cross-compiled doctests, and the `arm-android` job fails to run these tests.

In summary:
- Android re-exports some traits from linux under a different path.
- Android doesn't seem to have common unix utilities like `true`, `false`, or `whoami`, so these are disabled.
2025-05-23 13:34:18 +02:00
Matthias Krüger
f7a11798e8 Rollup merge of #140967 - azhogin:azhogin/async-drop-poll-shim-for-error-dropee-fix, r=oli-obk
Async drop poll shim for error dropee generates noop body

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

When dropee type for async drop poll shim is `ty::Error(_)`, the generated poll function will be noop body. To avoid ICE in `elaborate_drop`.
2025-05-23 13:34:17 +02:00
Matthias Krüger
1c2ea28727 Rollup merge of #136400 - lolbinarycat:rustdoc-link-lint-135851, r=GuillaumeGomez
Improve handling of rustdoc lints when used with raw doc fragments.

1. `rustdoc::bare_urls` no longer outputs incoherent suggestions if `source_span_for_markdown_range` returns None, instead outputting no suggestion
2. `source_span_for_markdown_range` has one more heuristic, so it will return `None` less often.
3. add ui test to make sure we don't emit nonsense suggestions.

fixes https://github.com/rust-lang/rust/issues/135851
2025-05-23 13:34:17 +02:00
bors
163cb4ea3f Auto merge of #141062 - ChaiTRex:ide_fmt_2024, r=Mark-Simulacrum
Update IDEs to use rustfmt 2024, fix Zed settings

Update IDEs to use rustfmt 2024, fix Zed settings

- Update IDE `rust-analyzer` settings to use 2024 rather than 2021.
- Fix Zed settings by removing `${workspaceFolder}/` from paths.
2025-05-23 11:15:24 +00:00
bors
52bf0cf795 Auto merge of #140553 - BoxyUwU:defer_type_system_ctfe, r=compiler-errors
Defer evaluating type system constants when they use infers or params

Split out of #137972, the parts necessary for associated const equality and min generic const args to make progress and have correct semantics around when CTFE is invoked. According to a [previous perf run](https://perf.rust-lang.org/compare.html?start=93257e2d20809d82d1bc0fcc1942480d1a66d7cd&end=01b4cbf0f47c3f782330db88fa5ba199bba1f8a2&stat=instructions:u) of adding the new `const_arg_kind` query we should expect minor regressions here.

I think this is acceptable as we should be able to remove this query relatively soon once mgca is more complete as we'll then be able to implement GCE in terms of mgca and rip out `GCEConst` at which point it's trivial to determine what kind of anon const we're dealing with (either it has generics and is a repeat expr hack, or it doesnt and is a normal anon const).

This should only affect unstable code as we handle repeat exprs specially and those are the only kinds of type system consts that are allowed to make use of generic parameters.

Fixes #133066
Fixes #133199
Fixes #136894
Fixes #137813

r? compiler-errors
2025-05-23 05:30:45 +00:00
bors
e7f4317ea0 Auto merge of #135160 - RalfJung:aarch64-softfloat-not-neon, r=Noratrieb
aarch64-softfloat: forbid enabling the neon target feature

This fixes https://github.com/rust-lang/rust/issues/134375 in a rather crude way, by making [the example](https://godbolt.org/z/r56xWo8nT) not build any more on aarch64-unknown-none-softfloat. That is a breaking change since the "neon" aarch64 target feature is stable, but this is justified as a soundness fix. Note that it's not "neon" which is problematic but "fp-armv8"; however, the two are tied together by rustc.

`-Ctarget-feature=+neon` still works, it just causes a warning (but one that we do hope to make a hard error eventually). Only `#[target_feature="neon"]` becomes a hard error with this PR.

More work on the LLVM side will be needed before we can let people use neon without impacting the ABI of float values (and, in particular, the ABI used by automatically inserted calls to libm functions, e.g. for int-to-float casts, which rustc has no control over).

Nominating for `@rust-lang/lang` since it is a breaking change. As-is this PR doesn't have a warning cycle; the hope is that the aarch64-unknown-none-softfloat target is sufficiently niche that there's no huge fallout and we can easily revert if it causes trouble. A warning cycle could be added but would need some dedicated rather hacky check in the target_feature attribute handling logic.

try-job:  dist-various-1
2025-05-23 00:11:55 +00:00
bors
912981a9ea Auto merge of #141396 - matthiaskrgr:rollup-feg050g, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #135562 (Add ignore value suggestion in closure body)
 - #139635 (Finalize repeat expr inference behaviour with inferred repeat counts)
 - #139668 (Handle regions equivalent to 'static in non_local_bounds)
 - #140218 (HIR ty lowering: Clean up & refactor the lowering of type-relative paths)
 - #140435 (use uX::from instead of _ as uX in non - const contexts)
 - #141130 (rustc_on_unimplemented cleanups)
 - #141286 (Querify `coroutine_hidden_types`)

Failed merges:

 - #140247 (Don't build `ParamEnv` and do trait solving in `ItemCtxt`s when lowering IATs)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-05-22 21:02:18 +00:00
Andrew Zhogin
cb8fdb4d80 Async drop poll shim for error dropee generates noop body (fixes #140930) 2025-05-23 03:40:27 +07:00
León Orell Valerian Liehr
98bd1a6a3a rustdoc JSON: Don't apply #[repr] privacy heuristics 2025-05-22 21:26:48 +02:00
Jeremy Drake
1f862a82e2 make shared_helpers exe function work for both cygwin and non-cygwin hosts
On Cygwin, it needs to not append .exe, because /proc/self/exe (and
therefore std::env::current_exe) does not include the .exe extension,
breaking bootstrap's rustc wrapper.  On hosts other than Cygwin, it
*does* need to append .exe because the file really does have a .exe
extension, and non-Cygwin hosts won't be doing the same filename
rewriting that Cygwin does when looking for a file X but finding only
X.exe in its place.
2025-05-22 11:06:52 -07:00
bors
2eef47813f Auto merge of #141388 - Kobzol:x64-github-runner, r=marcoieni
Move `dist-x86_64-linux` CI job to GitHub temporarily

To make it easier to migrate off the `rust-lang-ci/rust` repository.

r? `@marcoieni`
2025-05-22 18:05:06 +00:00
binarycat
3005a09fed rustdoc: improve diagnostics on raw doc fragments
1. rustdoc::bare_urls doesn't output
   invalid suggestions if source_span_for_markdown_range
   fails to find a span

2. source_span_for_markdown_range tries harder to
   return a span by applying an additional diagnostic

fixes https://github.com/rust-lang/rust/issues/135851
2025-05-22 12:31:28 -05:00
bors
e3892a40a9 Auto merge of #141397 - matthiaskrgr:rollup-l9uu6g6, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #141355 (ci: improve citool job db errors)
 - #141359 (Fix `FnOnce` impl for `AsyncFn`/`AsyncFnMut` self-borrowing closures in new solver)
 - #141362 (Normalize aliases to correct kind of error term)
 - #141377 (Remove unnecessary `is_empty` checks)
 - #141381 (try_cast_aligned: avoid bare int-to-ptr casts)
 - #141382 (ci: convert distcheck to free runner)
 - #141389 (ci: prepare aws access keys for migration)
 - #141390 (Don't allow `poly_select` in new solver)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-05-22 14:55:52 +00:00
Dannyyy93
d6dc08c3f4 docs: fix typos 2025-05-22 22:47:36 +08:00
Matthias Krüger
580bd6e16f Rollup merge of #141390 - compiler-errors:poly-select-new-solver, r=lcnr
Don't allow `poly_select` in new solver

I added a `poly_select` call in #140519, but this causes an ICE since the new solver doesn't properly handle the "instantiate binder -> recanonicalize" step in the proof tree visitor.

While we could fix the select visitor to look at the next step in proof tree, it's not really necessary. Instead, let's enforce that all callees call the non-higher-ranked `select` function in the new solver.

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

r? lcnr
2025-05-22 16:04:16 +02:00
Matthias Krüger
abba164007 Rollup merge of #141389 - marcoieni:aws-secrets-ci-migration, r=Kobzol
ci: prepare aws access keys for migration
2025-05-22 16:04:15 +02:00
Matthias Krüger
9507b10ed3 Rollup merge of #141382 - marcoieni:distcheck-free-x86, r=Kobzol
ci: convert distcheck to free runner

try-job: x86_64-gnu-distcheck
2025-05-22 16:04:14 +02:00
Matthias Krüger
db9525334a Rollup merge of #141381 - RalfJung:try_cast_aligned-strict-provenance, r=tgross35
try_cast_aligned: avoid bare int-to-ptr casts

This fixes a CI failure in https://github.com/rust-lang/miri-test-libstd caused by strict provenance violations in doctests added in https://github.com/rust-lang/rust/pull/141222.

r? `@tgross35`
Cc `@mathisbot`
2025-05-22 16:04:14 +02:00
Matthias Krüger
74b980d3a4 Rollup merge of #141377 - nnethercote:rm-unnecessary-is_empty-checks, r=GuillaumeGomez
Remove unnecessary `is_empty` checks

Part of #137978.

r? `@GuillaumeGomez`
2025-05-22 16:04:13 +02:00
Matthias Krüger
5cab70ed7f Rollup merge of #141362 - BoxyUwU:correct_error_term_kind, r=lcnr
Normalize aliases to correct kind of error term

Fixes #140642

When normalizing an alias to an error in the old solver, normalize to the same term kind as the alias being normalized instead of always to a type error.

r? lcnr
2025-05-22 16:04:12 +02:00
Matthias Krüger
654b2f39f1 Rollup merge of #141359 - compiler-errors:async-fn-once, r=lcnr
Fix `FnOnce` impl for `AsyncFn`/`AsyncFnMut` self-borrowing closures in new solver

This only affects closures that are "`AsyncFn`/`AsyncFnMut`" in their calling capability that are being called with the `FnOnce` trait.

fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/217

r? lcnr
2025-05-22 16:04:12 +02:00
Matthias Krüger
8757915a70 Rollup merge of #141355 - marcoieni:citool-errors, r=Kobzol
ci: improve citool job db errors
2025-05-22 16:04:11 +02:00
Matthias Krüger
8c2508292b Rollup merge of #141286 - compiler-errors:querify-coroutine, r=oli-obk
Querify `coroutine_hidden_types`

This is necessary if we ever want to add implied bounds that would be used for higher-ranked coroutine auto trait goals (e.g. future implements `Send`).

Modest perf regression in `hyper` full build which (afaict?) is the only async stress test, so definitely worth it IMO.

r? oli-obk
2025-05-22 16:02:31 +02:00
Matthias Krüger
c385715806 Rollup merge of #141130 - mejrs:use_self, r=compiler-errors
rustc_on_unimplemented cleanups

Addresses some of the fixmes from https://github.com/rust-lang/rust/pull/139091 and https://github.com/rust-lang/rust/pull/140307.

- switch from `_Self` to `Self` in library
- properly validate that arguments in the `on` filter and the format strings are actually valid

See https://github.com/rust-lang/rustc-dev-guide/pull/2357 for the relevant documentation.
2025-05-22 16:02:30 +02:00
Matthias Krüger
bc6804df27 Rollup merge of #140435 - bend-n:use_ux_from_instead_of_bool_as_ux_unnecessary_transmutes, r=compiler-errors
use uX::from instead of _ as uX in non - const contexts

changes `transmute(bool) -> integer` to `integer::from` as opposed to `bool as integer`.
https://github.com/rust-lang/rust/pull/136083#discussion_r1985061667

`@rustbot` label L-unnecessary_transmutes
2025-05-22 16:02:29 +02:00
Matthias Krüger
3216098e53 Rollup merge of #140218 - fmease:hirtylo-clean-up-path-low, r=compiler-errors
HIR ty lowering: Clean up & refactor the lowering of type-relative paths

While rebasing #126651 I realized that HIR ty lowering could benefit from some *spring cleaning* now that it's been extended to handle RTN and mGCA paths.

More seriously, similar to my merged PR #118668 which unified the handling of all *associated item constraints* (assoc ty, const (ACE) & fn (RTN)), this PR (commit 695fcf517d) partially[^1] deduplicates the resolution code for all *type-relative paths* (assoc ty, const (mGCA) & fn (RTN)).

**Why**? DRY'ing that part of the code means PR #126651 will automatically support RTN paths like `Ty::AssocTy::assoc_fn(..)` and it also implies shared diagnostic code and thus better diagnostics for RTN.

---

The other commits represent cleanups, renamings, moves. More notably, I've renamed path lowering methods to be a lot more descriptive, so ones lowering `QPath(Resolved)` paths now have `_resolved_` in their name and ones lowering `QPath(TypeRelative)` paths now have `_type_relative_` in their name. This should make it stupidly obvious what their purpose is.

---

Best reviewed commit by commit. The changes are close to trivial but the diff might make it look hairier.
r? compiler-errors

[^1]: Sadly, I couldn't unify as much compared to the other PR without introducing unnecessary `unreachable!()`s or rendering the code otherwise illegible with flags and micro helper traits.
2025-05-22 16:02:28 +02:00
Matthias Krüger
706dc70916 Rollup merge of #139668 - matthewjasper:upper-bound-fix, r=compiler-errors
Handle regions equivalent to 'static in non_local_bounds

`non_local_bounds` would only find non local bounds that strictly bound a given region, but it's possible that a local region is equated to 'static when showing a type referencing a locally bound lifetime, such as `dyn Any + 'a` in the tests added, is well-formed. In this case we should return 'static.

closes #122704
closes #139004
2025-05-22 16:02:26 +02:00
Matthias Krüger
4c6aee567d Rollup merge of #139635 - BoxyUwU:no_order_dependent_copy_checks, r=lcnr
Finalize repeat expr inference behaviour with inferred repeat counts

I believe this should be the last change of how repeat exprs are handled before it's finished for `generic_arg_infer`. Assuming we don't wind up deciding to replace this all with a new predicate kind :)

 This PR has three actual changes:
 - Always defer the checks to end of typeck even when generic arg infer is not enabled (needs an FCP)
 - Properly handle element exprs that are constants when the repeat count is inferred
 - "Isolate" each repeat expr check so that inference constraints from `Copy` goals dont affect other repeat expr checks resulting in weird order-dependent inference

The commit history and tests should be relatively helpful for understanding this PR's impl.

r? compiler-errors
2025-05-22 16:02:24 +02:00
Matthias Krüger
3529341afd Rollup merge of #135562 - chenyukang:yukang-fix-128561, r=compiler-errors
Add ignore value suggestion in closure body

Fixes #128561

r? `@estebank`
2025-05-22 16:02:23 +02:00
Boxy
fdccb42167 Add test/comment about const patterns with unused params 2025-05-22 12:52:46 +01:00
Boxy
217c4ad427 Review Comments 2025-05-22 12:47:19 +01:00