Commit Graph

270975 Commits

Author SHA1 Message Date
Esteban Küber
04fe839177 Increase accuracy of if condition misparse suggestion
Look at the expression that was parsed when trying to recover from a bad `if` condition to determine what was likely intended by the user beyond "maybe this was meant to be an `else` body".

```
error: expected `{`, found `map`
  --> $DIR/missing-dot-on-if-condition-expression-fixable.rs:4:30
   |
LL |     for _ in [1, 2, 3].iter()map(|x| x) {}
   |                              ^^^ expected `{`
   |
help: you might have meant to write a method call
   |
LL |     for _ in [1, 2, 3].iter().map(|x| x) {}
   |                              +
```
2024-11-16 20:03:31 +00:00
bors
917a50a039 Auto merge of #133079 - matthiaskrgr:rollup-k8u7syk, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #132817 (Recurse into APITs in `impl_trait_overcaptures`)
 - #133021 (Refactor `configure_annotatable`)
 - #133045 (tests: Test pac-ret flag merging on clang with LTO)
 - #133049 (Change Visitor::visit_precise_capturing_arg so it returns a Visitor::Result)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-15 19:13:57 +00:00
Matthias Krüger
a111716c42
Rollup merge of #133049 - maxcabrajac:visit_precise_capturing_arg, r=compiler-errors
Change Visitor::visit_precise_capturing_arg so it returns a Visitor::Result

r? `@petrochenkov`

related to #128974
2024-11-15 19:05:18 +01:00
Matthias Krüger
249a9100a3
Rollup merge of #133045 - mrkajetanp:pauth-test-clang-lto-flag-merge, r=jieyouxu
tests: Test pac-ret flag merging on clang with LTO

Extend the test for pac-ret with clang and LTO by checking that different branch protection flags are preserved after the LTO step. There was an issue in older LLVM versions that was causing this to behave incorrectly.

try-job: aarch64-gnu-debug
2024-11-15 19:05:18 +01:00
Matthias Krüger
6963572c78
Rollup merge of #133021 - nnethercote:refactor-configure_annotatable, r=petrochenkov
Refactor `configure_annotatable`

This PR streamlines `configure_annotatable` and nearby code considerably.

r? `@petrochenkov`
2024-11-15 19:05:16 +01:00
Matthias Krüger
213803549a
Rollup merge of #132817 - compiler-errors:impl-trait-overcaptures-apit, r=BoxyUwU
Recurse into APITs in `impl_trait_overcaptures`

We were previously not detecting cases where an RPIT was located in the return type of an async function, leading to underfiring of the `impl_trait_overcaptures`. This PR does this recursion properly now.

cc https://github.com/rust-lang/rust/issues/132809
2024-11-15 19:05:15 +01:00
bors
ce40196577 Auto merge of #132992 - RalfJung:check-consts-feature-gate, r=compiler-errors
check_consts: fix error requesting feature gate when that gate is not actually needed

When working on https://github.com/rust-lang/hashbrown/pull/586 I noticed that the compiler asks for the `rustc_private` feature to be enabled if one forgets to set `rustc_const_stable_indirect` on a function -- but enabling `rustc_private` would not actually help. This fixes the diagnostics.

r? `@compiler-errors`
2024-11-15 16:03:47 +00:00
Kajetan Puchalski
194471cbd4 tests: Test pac-ret flag merging on clang with LTO
Extend the test for pac-ret with clang and LTO by checking that
different branch protection flags are preserved after the LTO step.
There was an issue in older LLVM versions that was causing this to
behave incorrectly.

Tests the LLVM behaviour added in:
1782810b84
2024-11-15 14:13:38 +00:00
bors
76fd47124b Auto merge of #132910 - osiewicz:crate-loader-smarter-queries, r=saethlin
rustc_metadata: Preprocess search paths for better performance

Over in Zed we've noticed that loading crates for a large-ish workspace (~100 members of workspace, over 1000 crates being built for the main binary target) can take almost 200ms. We've pinned it down to how rustc searches for paths to dependency files, as it performs a linear search over the list of candidate paths. In our case the candidate list had about 20k entries which we had to iterate over for each dependency being loaded. Our workspace is also pretty bottom-heavy, e.g. most of the workspace members pull in most of the transitive dependencies one way or another, which means that we spend quite some time loading crates at rustc startup.

This commit introduces a simple FilesIndex that's just a BTreeMap under the hood. Since crates are looked up by both prefix and suffix, we perform a range search on said BTree (which constraints the search space based on prefix) and follow up with a linear scan of entries with matching suffixes.

Overall, this commit brings down build time for us in dev scenarios by about 6%. 100ms might not seem like much, but this is a constant cost that each of our workspace crates has to pay, even when said crate is miniscule.
2024-11-15 11:48:21 +00:00
Piotr Osiewicz
42e71bb8ea rustc_metadata: Preprocess search paths for better performance
Over in Zed we've noticed that loading crates for a large-ish workspace can take almost 200ms. We've pinned it down to how rustc searches for paths, as it performs a linear search over the list of candidate paths. In our case the candidate list had about 20k entries which we had to iterate over for each dependency being loaded.

This commit introduces a simple FilesIndex that's just a sorted Vec under the hood. Since crates are looked up by both prefix and suffix, we perform a range search on said Vec (which constraints the search space based on prefix) and follow up with a linear scan of entries with matching suffixes.
FilesIndex is also pre-filtered before any queries are performed using available target information; query prefixes/sufixes are based on the target we are compiling for, so we can remove entries that can never match up front.

Overall, this commit brings down build time for us in dev scenarios by about 6%.
100ms might not seem like much, but this is a constant cost that each of our workspace crates has to pay, even when said crate is miniscule.
2024-11-15 10:35:33 +01:00
bors
f00f68245e Auto merge of #132967 - klensy:docker-unite, r=Kobzol
fix REGISTRY_USERNAME to reuse cache between auto and pr jobs

see https://rust-lang.zulipchat.com/#narrow/channel/242791-t-infra/topic/reuse.20.28some.29.20docker.20images.20for.20pr.2Fauto.3F
2024-11-15 08:08:11 +00:00
bors
251dc8ad84 Auto merge of #133059 - workingjubilee:rollup-rc5kvr1, r=workingjubilee
Rollup of 8 pull requests

Successful merges:

 - #132790 (Add as_slice/into_slice for IoSlice/IoSliceMut.)
 - #132905 ([AIX] Add crate "unwind" to link with libunwind)
 - #132977 (Fix compilation error on Solaris due to flock usage)
 - #132984 ([illumos] use pipe2 to create anonymous pipes)
 - #133019 (docs: Fix missing period and colon in methods for primitive types)
 - #133048 (use `&raw` in `{read, write}_unaligned` documentation)
 - #133050 (Always inline functions signatures containing `f16` or `f128`)
 - #133053 (tests: Fix the SIMD FFI tests with certain x86 configuration)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-15 03:29:57 +00:00
Jubilee
efe2c44269
Rollup merge of #133053 - liushuyu:simd-test-x86-baseline-fix, r=workingjubilee
tests: Fix the SIMD FFI tests with certain x86 configuration

This pull request fixes the SIMD FFI tests with certain x86 configurations by gating the SSE2 intrinsic behind the `sse2` feature gate. A generic LLVM intrinsic that is easy to un-fuse on those platforms is added to compensate for those platforms.
2024-11-14 17:55:27 -08:00
Jubilee
cea081e980
Rollup merge of #133050 - tgross35:inline-f16-f128, r=saethlin
Always inline functions signatures containing `f16` or `f128`

There are a handful of tier 2 and tier 3 targets that cause a LLVM crash or linker error when generating code that contains `f16` or `f128`. The cranelift backend also does not support these types. To work around this, every function in `std` or `core` that contains these types must be marked `#[inline]` in order to avoid sending any code to the backend unless specifically requested.

However, this is inconvenient and easy to forget. Introduce a check for these types in the frontend that automatically inlines any function signatures that take or return `f16` or `f128`.

Note that this is not a perfect fix because it does not account for the types being passed by reference or as members of aggregate types, but this is sufficient for what is currently needed in the standard library.

Fixes: https://github.com/rust-lang/rust/issues/133035
Closes: https://github.com/rust-lang/rust/pull/133037
2024-11-14 17:55:27 -08:00
Jubilee
60f3911631
Rollup merge of #133048 - cyrgani:ptr-doc-update, r=Amanieu
use `&raw` in `{read, write}_unaligned` documentation

Fixes #133024 by using `&raw const` and `&raw mut` instead of `addr_of!` and `addr_of_mut!`.
2024-11-14 17:55:26 -08:00
Jubilee
a835f2a81f
Rollup merge of #133019 - sorairolake:add-missing-period-and-colon, r=tgross35
docs: Fix missing period and colon in methods for primitive types

Closes #133018
2024-11-14 17:55:26 -08:00
Jubilee
a5510a5430
Rollup merge of #132984 - sunshowers:pipe2, r=tgross35
[illumos] use pipe2 to create anonymous pipes

pipe2 allows the newly-created pipe to atomically be CLOEXEC.

pipe2 was added to illumos a long time ago:
5dbfd19ad5. I've verified that this change passes all of std's tests on illumos.
2024-11-14 17:55:25 -08:00
Jubilee
3f9f7c4a72
Rollup merge of #132977 - cberner:fix_solaris, r=tgross35
Fix compilation error on Solaris due to flock usage

PR 130999 added the file_lock feature, but libc does not define flock() for the Solaris platform leading to a compilation error.

Additionally, I went through all the Tier 2 platforms and read through their documentation to see whether flock was implemented. This turned up 5 more Unix platforms where flock is not supported, even though it may exist in the libc crate.

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

Related to #130999
2024-11-14 17:55:25 -08:00
Jubilee
fcc084520c
Rollup merge of #132905 - xingxue-ibm:link-unwind, r=bjorn3
[AIX] Add crate "unwind" to link with libunwind

The Rust on IBM AIX uses LLVM's `libunwind`. Since crate `unwind` is a dependency of crate `std` and `#![no_std]` is specified in the test case, `libunwind` is not included in the link command by default. As a result, the test case fails to link with the error "Undefined symbol: ._Unwind_Resume" on AIX. This PR explicitly adds crate `unwind` for AIX, along with feature `panic_unwind`, which is required to include the `unwind` crate.
2024-11-14 17:55:24 -08:00
Jubilee
b1b56b11a2
Rollup merge of #132790 - aDotInTheVoid:ioslice-asslice-rides-again, r=cuviper
Add as_slice/into_slice for IoSlice/IoSliceMut.

ACP: https://github.com/rust-lang/libs-team/issues/93

Tracking issue: #132818

Based on a623c5233ae7f6b540e5c00f2be02f40b33b0793 (CC `@mpdn)` and #111277 (CC `@Lucretiel).`

Closes: #124659

Tracking Issue: TODO

try-job: test-various
try-job: dist-various-1
try-job: dist-various-2

r? libs
2024-11-14 17:55:24 -08:00
bors
3bc6916f4c Auto merge of #132965 - mati865:cfguard-gnullvm, r=wesleywiser
allow CFGuard on windows-gnullvm

No unit tests because of https://github.com/rust-lang/rust/issues/132278
2024-11-15 00:21:07 +00:00
liushuyu
0733ed77d1
tests/run-make/simd-ffi: use a generic LLVM intrinsics ...
... to do more comprehensive type checking
2024-11-14 15:49:51 -07:00
Trevor Gross
5d818914af Always inline functions signatures containing f16 or f128
There are a handful of tier 2 and tier 3 targets that cause a LLVM crash
or linker error when generating code that contains `f16` or `f128`. The
cranelift backend also does not support these types. To work around
this, every function in `std` or `core` that contains these types must
be marked `#[inline]` in order to avoid sending any code to the backend
unless specifically requested.

However, this is inconvenient and easy to forget. Introduce a check for
these types in the frontend that automatically inlines any function
signatures that take or return `f16` or `f128`.

Note that this is not a perfect fix because it does not account for the
types being passed by reference or as members of aggregate types, but
this is sufficient for what is currently needed in the standard library.

Fixes: https://github.com/rust-lang/rust/issues/133035
Closes: https://github.com/rust-lang/rust/pull/133037
2024-11-14 16:18:41 -06:00
Trevor Gross
b77dbbd4fd Pass f16 and f128 by value in const_assert!
These types are currently passed by reference, which does not avoid the
backend crashes. Change these back to being passed by value, which makes
the types easier to detect for automatic inlining.
2024-11-14 16:09:45 -06:00
bors
e84902d35a Auto merge of #133047 - matthiaskrgr:rollup-9se1vth, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #128197 (Skip locking span interner for some syntax context checks)
 - #133040 ([rustdoc] Fix handling of footnote reference in footnote definition)
 - #133043 (rustdoc-search: case-sensitive only when capitals are used)
 - #133046 (Clippy subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-14 21:09:28 +00:00
liushuyu
ede8a74f1e tests/run-make/simd-ffi: fix test crashing on x86 targets ...
... that do not have SSE2 support (e.g. i586)
2024-11-14 14:07:47 -07:00
maxcabrajac
9fde49b338 Change visit_precise_capturing_arg so it returns a Self::Result 2024-11-14 17:07:46 -03:00
cyrgani
7711ba2d14 use &raw in {read, write}_unaligned documentation 2024-11-14 21:04:30 +01:00
Matthias Krüger
d6a9ded560
Rollup merge of #133046 - flip1995:clippy-subtree-update, r=Manishearth
Clippy subtree update

r? `@Manishearth`

Smaller sync today, as the last sync was delayed by a week.
2024-11-14 20:45:16 +01:00
Matthias Krüger
8912909b98
Rollup merge of #133043 - notriddle:master, r=fmease
rustdoc-search: case-sensitive only when capitals are used

This is the "smartcase" behavior, described by vim and dtolnay.

Fixes https://github.com/rust-lang/rust/issues/133017
2024-11-14 20:45:15 +01:00
Matthias Krüger
dd61213be4
Rollup merge of #133040 - GuillaumeGomez:footnote-ref-in-def, r=notriddle
[rustdoc] Fix handling of footnote reference in footnote definition

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

We didn't check if we had footnote reference in footnote definition.

r? `@notriddle`
2024-11-14 20:45:13 +01:00
Matthias Krüger
e158303c09
Rollup merge of #128197 - Alexendoo:span-ctxt, r=davidtwco
Skip locking span interner for some syntax context checks

- `from_expansion` now never needs to consult the interner
- `eq_ctxt` now only needs the interner when both spans are fully interned
2024-11-14 20:45:12 +01:00
Philipp Krones
35c3b25321
Merge commit '786fbd6d683933cd0e567fdcd25d449a69b4320c' into clippy-subtree-update 2024-11-14 19:35:26 +01:00
Michael Howell
32500aa8e0 rustdoc-search: case-sensitive only when capitals are used
This is the "smartcase" behavior, described by vim and dtolnay.
2024-11-14 11:10:14 -07:00
Philipp Krones
786fbd6d68
Rustup (#13687)
r? @ghost

changelog: none
2024-11-14 17:32:56 +00:00
Philipp Krones
99ef36938a
Bump nightly version -> 2024-11-14 2024-11-14 18:27:46 +01:00
Philipp Krones
c166ee1fc8
Merge remote-tracking branch 'upstream/master' into rustup 2024-11-14 18:27:35 +01:00
bors
90ab8eaedd Auto merge of #133039 - GuillaumeGomez:rollup-i223onq, r=GuillaumeGomez
Rollup of 5 pull requests

Successful merges:

 - #132172 (borrowck diagnostics: suggest borrowing function inputs in generic positions)
 - #132649 (add ./x clippy ci)
 - #133005 (rustdoc: use a trie for name-based search)
 - #133034 (update download-rustc comments and default)
 - #133036 (add myself into `users_on_vacation` on triagebot)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-14 17:22:10 +00:00
Guillaume Gomez
052d40adb3 Add regression test for #131946 2024-11-14 17:01:29 +01:00
Guillaume Gomez
1d2f9118fe Fix handling of footnote reference in footnote definition 2024-11-14 17:01:09 +01:00
Xing Xue
467ce2695a Include the "unwind" crate to link with libunwind instead of the "libc" crate. 2024-11-14 10:51:28 -05:00
Guillaume Gomez
35214ebf32
Rollup merge of #133036 - onur-ozkan:vacation, r=jieyouxu
add myself into `users_on_vacation` on triagebot

I will be on vacation for about 10 days.
2024-11-14 15:16:18 +01:00
Guillaume Gomez
19d0e60cf2
Rollup merge of #133034 - onur-ozkan:new-default, r=jieyouxu
update download-rustc comments and default

See https://github.com/rust-lang/rust/pull/132872#issuecomment-2476135053
2024-11-14 15:16:16 +01:00
Guillaume Gomez
fc7ca70013
Rollup merge of #133005 - notriddle:notriddle/trie-search, r=GuillaumeGomez
rustdoc: use a trie for name-based search

Potentially https://github.com/rust-lang/rust/issues/131156 — need to try reproducing the problem with `windows`

Preview and profiler results
----------------------------

Here's some quick profiling in Firefox done on the rust compiler docs:

- Before: https://share.firefox.dev/3UPm3M8
- After: https://share.firefox.dev/40LXvYb

Here's the results for the node.js profiler:

- https://notriddle.com/rustdoc-html-demo-15/trie-perf/index.html

Here's a copy that you can use to try it out. Compare it with [the nightly]. Try typing `typecheckercontext` one character at a time, slowly.

- https://notriddle.com/rustdoc-html-demo-15/compiler-doc-trie/index.html

[the nightly]: https://doc.rust-lang.org/nightly/nightly-rustc/

The fuzzy match algo is based on [Fast String Correction with Levenshtein-Automata] and the corresponding implementation code in [moman] and [Lucene]; the bit-packing representation comes from Lucene, but the actual matcher is more based on `fsc.py`. As suggested in the paper, a trie is used to represent the FSA dictionary.

The same trie is used for prefix matching. Substring matching is done with a side table of three-character[^1] windows that point into the trie.

[Fast String Correction with Levenshtein-Automata]: https://github.com/tpn/pdfs/blob/master/Fast%20String%20Correction%20with%20Levenshtein-Automata%20(2002)%20(10.1.1.16.652).pdf
[Lucene]: https://fossies.org/linux/lucene/lucene/core/src/java/org/apache/lucene/util/automaton/Lev1TParametricDescription.java
[moman]: https://gitlab.com/notriddle/moman-rustdoc

User-visible changes
--------------------

I don't expect anybody to notice anything, but it does cause two changes:

- Substring matches, in the middle of a name, only apply if there's three or more characters in the search query.
- Levenshtein distance limit now maxes out at two. In the old version, the limit was w/3, so you could get looser matches for queries with 9 or more characters[^1] in them.
- It uses more RAM.
- It's faster (assuming you don't swap thrash).

[^1]: technically utf-16 code units
2024-11-14 15:16:14 +01:00
Guillaume Gomez
1a1efafc64
Rollup merge of #132649 - klensy:pa-clippy-ci, r=onur-ozkan
add ./x clippy ci

This is rebase of https://github.com/rust-lang/rust/pull/126321

also https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/enable.20more.20clippy.20lints.20for.20compiler.20.28and.5Cor.20std.29 for context
2024-11-14 15:16:11 +01:00
Guillaume Gomez
5ee347ece4
Rollup merge of #132172 - dianne:suggest-borrow-generic, r=matthewjasper
borrowck diagnostics: suggest borrowing function inputs in generic positions

# Summary
This generalizes borrowck's existing suggestions to borrow instead of moving when passing by-value to a function that's generic in that input. Previously, this was special-cased to `AsRef`/`Borrow`-like traits and `Fn`-like traits. This PR changes it to test if, for a moved place with type `T`, that the callee's signature and clauses don't break if you substitute in `&T` or `&mut T`. For instance, it now works with `Read`/`Write`-like traits.

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

# Incidental changes
- No longer spuriously suggests mutable borrows of closures in some situations (see e.g. the tests in [tests/ui/closures/2229_closure_analysis/](https://github.com/rust-lang/rust/compare/master...dianne:rust:suggest-borrow-generic?expand=1#diff-8dfb200c559f0995d0f2ffa2f23bc6f8041b263e264e5c329a1f4171769787c0)).
- No longer suggests cloning closures that implement `Fn`, since they can be borrowed (see e.g. [tests/ui/moves/borrow-closures-instead-of-move.stderr](https://github.com/rust-lang/rust/compare/master...dianne:rust:suggest-borrow-generic?expand=1#diff-5db268aac405eec56d099a72d8b58ac46dab523cf013e29008104840168577fb)).

This keeps the behavior to suppress suggestions of `fn_once.clone()()`. I think it might make sense to suggest it with a "but this might not be your desired behavior" caveat, as is done when something is used after being consumed as the receiver for a method call. That's probably out of the scope of this PR though.

# Limitations and possible improvements
- This doesn't work for receivers of method calls. This is a small change, and I have it implemented locally, but I'm not sure it's useful on its own. In most cases I've found borrowing the receiver would change the call's output type (see below). In other cases (e.g. `Iterator::sum`), borrowing the receiver isn't useful since it's consumed.
- This doesn't work when it would change the call's output type. In general, I figure inserting references into the output type is an unwanted change. However, this also means it doesn't work in cases where the new output type would be effectively the same as the old one. For example, from the rand crate, the iterator returned by [`Rng::sample_iter`](https://docs.rs/rand/latest/rand/trait.Rng.html#method.sample_iter) is effectively the same (modulo regions) whether you borrow or consume the receiver `Rng`, so common usage involves borrowing it. I'm not sure whether the best approach is to add a more complex check of approximate equivalence, to forego checking the call's output type and give spurious suggestions, or to leave it as-is.
- This doesn't work when it would change the call's other input types. Instead, it could suggest borrowing any others that have the same parameter type (but only when suggesting shared borrows). I think this would be a pretty easy change, but I don't think it's very useful so long as the normalized output type can't change.

I'm happy to implement any of these (or other potential improvements to this), but I'm not sure which are common enough patterns to justify the added complexity. Please let me know if any sound worthwhile.
2024-11-14 15:16:08 +01:00
bors
c82e0dff84 Auto merge of #132709 - programmerjake:optimize-charto_digit, r=joshtriplett
optimize char::to_digit and assert radix is at least 2

approved by t-libs: https://github.com/rust-lang/libs-team/issues/475#issuecomment-2457858458

let me know if this needs an assembly test or similar.
2024-11-14 14:14:40 +00:00
onur-ozkan
2b8c345393 add myself into users_on_vacation on triagebot
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-11-14 15:06:12 +03:00
onur-ozkan
49f9b4b4de update download-rustc comments and default
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-11-14 14:56:48 +03:00
bors
a4cedecc9e Auto merge of #133032 - GuillaumeGomez:rollup-vqakdmw, r=GuillaumeGomez
Rollup of 5 pull requests

Successful merges:

 - #132010 (ci: Enable full `debuginfo-level=2` in `DEPLOY_ALT`)
 - #132310 (compiletest: add `max-llvm-major-version` directive)
 - #132773 (PassWrapper: disable UseOdrIndicator for Asan Win32)
 - #133013 (compiletest: known-bug / crashes: allow for an "auxiliary" directory to contain files that do not have a "known-bug" directive)
 - #133027 (Fix a copy-paste issue in the NuttX raw type definition)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-14 10:59:49 +00:00