Commit graph

22104 commits

Author SHA1 Message Date
aerooneqq
3e717121a1 Generate error delegation body when delegation is not resolved 2025-12-05 15:22:26 +03:00
Matthias Krüger
b49b18bcff
Rollup merge of #149471 - Zalathar:tree, r=oli-obk
coverage: Store signature/body spans and branch spans in the expansion tree

In order to support coverage instrumentation of expansion regions, we need to reduce the amount of code that assumes we're only instrumenting a flat function body. Moving more data into expansion tree nodes is an incremental step in that direction.

There should be no change to compiler output.
2025-11-30 18:44:23 +01:00
Matthias Krüger
97b5b9b817
Rollup merge of #148169 - fmease:rustdoc-bad-intra-bad-preprocess, r=lolbinarycat
Fix bad intra-doc-link preprocessing

How did rust-lang/rust#147981 happen?

1. We don't parse intra-doc links as Rust paths or qpaths. Instead they follow a very lenient bespoke grammar. We completely ignore Markdown links if they contain characters that don't match `/[a-zA-Z0-9_:<>, !*&;]/` (we don't even emit lint *broken-intra-doc-links* for these).
2. PR [#132748](https://github.com/rust-lang/rust/pull/132748) made rustdoc intepret more Markdown links as potential intra-doc links. Namely, if the link is surrounded by backticks (and some other conditions apply) then it doesn't matter if the (partially processed) link contains bad characters as defined above (cc `ignore_urllike && should_ignore_link(path_str)`).
3. However, rustdoc's `preprocess_link` must be kept in sync with a simplified counterpart in rustc. More specifically, whenever rustdoc's preprocessor returns a successful result then rustc's must yield the same result. Otherwise, rustc doesn't resolve the necessary links for rustdoc.
4. This uncovered a "dormant bug" / "mistake" in rustc's `preprocess_link`. Namely, when presented with a link like `struct@Type@suffix`, it didn't cut off the disambiguator if present (here: `struct@`). Instead it `rsplit('``@')``` which is incorrect if the "path" contains ```@``` itself (yielding `suffix` instead of `Type@suffix` here). Prior to PR [#132748](https://github.com/rust-lang/rust/pull/132748), a link like ``[`struct@Type@suffix`]`` was not considered a potential intra-doc link / worth querying rustc for. Now it is due to the backticks.
5. Finally, since rustc didn't record a resolution for `Type@suffix` (it only recorded `suffix` (to be `Res::Err`)), we triggered an assertion we have in place to catch cases like this.

Fixes rust-lang/rust#147981.

I didn't and still don't have the time to investigate if rust-lang/rust#132748 led to more rustc/rustdoc mismatches (after all, the PR made rustdoc's `preprocess_link` return `Some(Ok(_))` in more cases). I've at least added another much needed "warning banner" & made the existing one more flashy.

While this fixes a stable-to-beta regression, I don't think it's worth beta backporting, esp. since it's only P-medium and since the final 1.91 release steps commence today / the next days, so it would only be stressful to get it in on time. However, feel free to nominate.

<sub>(I've written such a verbose PR description since I tend to reread my old PR descriptions in the far future to fully freshen my memories when I have to work again in this area)</sub>

r? ``@lolbinarycat``
2025-11-30 18:44:22 +01:00
León Orell Valerian Liehr
55d90c0653
Fix bad intra-doc-link preprocessing 2025-11-30 13:08:59 +01:00
Matthias Krüger
9507d5c149
Rollup merge of #149444 - fee1-dead-contrib:push-lurmmylquwsq, r=oli-obk
collapse `constness` query `match` logic

We already have the HIR node data, so no need for asking `def_kind` again.

r? oli-obk
2025-11-30 12:03:23 +01:00
Zalathar
a3bf870441 coverage: Test some edge cases involving macro expansion 2025-11-30 18:31:54 +11:00
Deadbeef
cf91330b6b collapse constness query match logic
We already have the HIR node data, so no need for asking `def_kind` again.
2025-11-29 20:00:40 -05:00
Matthias Krüger
c93801cb20
Rollup merge of #148765 - joboet:split-up-thread, r=ChrisDenton
std: split up the `thread` module

Almost all functionality in `std::thread` is currently implemented in `thread/mod.rs`, resulting in a *huge* file with more than 2000 lines and multiple, interoperating `unsafe` sections. This PR splits the file up into multiple different private modules, each implementing mostly independent parts of the functionality. The only remaining `unsafe` interplay is that of the `lifecycle` and `scope` modules, the `spawn_scoped` implementation relies on the live thread count being updated correctly by the `lifecycle` module.

This PR contains no functional changes and only moves code around for the most part, with a few notable exceptions:
* `with_current_name` is moved to the already existing `current` module and now uses the `name` method instead of calculating the name from private fields. The old code was just a reimplementation of that method anyway.
* The private `JoinInner` type used to implement both join handles now has some more methods (`is_finished`, `thread` and the `AsInner`/`IntoInner` implementations) to avoid having to expose private fields and their invariants.
* The private `spawn_unchecked_` (note the underscore) method of `Builder` is now a freestanding function in `lifecycle`.

The rest of the changes are just visibility annotations.

I realise this PR ended up quite large – let me know if there is anyway I can aid the review process.

Edit: I've simplified the diff by adding an intermediate commit that creates all the new files by duplicating `mod.rs`. The actual changes in the second commit thus appear to delete the non-relevant parts from the respective file.
2025-11-29 20:54:06 +01:00
Matthias Krüger
8e4c70f02b
Rollup merge of #148746 - RalfJung:mutable-ref-in-const, r=davidtwco
const validation: remove check for mutable refs in final value of const

This check rejects code that is not necessarily UB, e.g. a mutable ref to a `static mut` that is very carefully used correctly. That led to us having to describe it in the Reference, which uncovered just how ad-hoc this check is (https://github.com/rust-lang/reference/issues/2074).

Even without this check, we still reject things like
```rust
const C: &mut i32 = &mut 0;
```
This is rejected by const checking -- the part of the frontend that looks at the source code and says whether it is allowed in const context. In the Reference, this restriction is explained [here](https://doc.rust-lang.org/nightly/reference/const_eval.html#r-const-eval.const-expr.borrows).

So, the check during validation is just a safety net. And it is already a safety net with gaping holes since we only check `&mut T`, not `&UnsafeCell<T>`, due to the fact that we promote some immutable values that have `!Freeze` type so `&!Freeze` actually can occur in the final value of a const.

So... it may be time for me to acknowledge that the "mutable ref in final value of const" check is a cure that's worth than the disease. Nobody asked for that check, I just added it because I was worried about soundness issues when we allow mutable references in constants. Originally it was much stricter, but I had to slowly relax it to its current form to prevent t from firing on code we intend to allow. In the end there are only 3 tests left that trigger this error, and they are all just constants containing references to mutable statics -- not the safest code in the world, but also not so bad that we have to spend a lot of time devising a core language limitation and associated Reference wording to prevent it from ever happening.

So... `@rust-lang/wg-const-eval` `@rust-lang/lang`  I propose that we allow code like this
```rust
static mut S: i32 = 3;
const C2: &'static mut i32 = unsafe { &mut * &raw mut S };
```
`@theemathas` would be great if you could try to poke a hole into this. ;)
2025-11-29 20:54:05 +01:00
joboet
c22b819952
update type names in debuginfo tests 2025-11-29 15:59:11 +01:00
joboet
912f7f9502
update references to thread implementation in tests 2025-11-29 15:59:11 +01:00
Stuart Cook
4e3b7a1e31
Rollup merge of #149409 - cezarbbb:stable_ssp, r=SparrowLii
Test the coexistence of 'stack-protector' and 'safe-stack'

This is a test to detect the coexistence of 'stack-protector' and 'safe-stack', and it's a supplement to pr rust-lang/rust#147115 . After the solution to issue rust-lang/rust#149340, I rewrote a version using minicore to circumvent the 'abi_mismatch' error.

r? `@SparrowLii` (Do you have time to review it?)
2025-11-29 21:12:26 +11:00
Stuart Cook
3a0187ec5d
Rollup merge of #144000 - jacob-greenfield:stable-defid-parent, r=celinval
Add `DefId::parent()` accessor for `rustc_public`

Adds a `parent()` method to `DefId` (the `rustc_pub` version) which exposes the parent path, ie. `foo::bar::baz` -> `foo::bar`.

This is useful for organizing/grouping definitions into a tree, and is probably simpler and less brittle than attempting to parse the fully-qualified name into path components (e.g. especially when handling path components with qualified generic parameters).
2025-11-29 21:12:25 +11:00
cezarbbb
7c24c9a908 Test the coexistence of 'stack-protector' and 'safe-stack' 2025-11-29 14:17:58 +08:00
bors
3c5c55864f Auto merge of #149441 - jhpratt:rollup-4hmqc0z, r=jhpratt
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#147362 (Avoid suggesting constrain the associated type with unknown type)
 - rust-lang/rust#149395 (float::minimum/maximum: say which exact IEEE operation this corresponds to)
 - rust-lang/rust#149396 (Remove outdated comment)
 - rust-lang/rust#149421 (Add a regression test for issue 129865)
 - rust-lang/rust#149424 (Update books)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-11-29 05:20:07 +00:00
Jacob Pratt
0b94bc0322
Rollup merge of #149421 - ShoyuVanilla:regression-129865, r=chenyukang
Add a regression test for issue 129865

Closes rust-lang/rust#129865

Looks like the previous versions (`< 1.85.0`) failed to normalize async block's upvar types containing constants but not anymore
2025-11-28 21:22:25 -05:00
Jacob Pratt
888e5da41c
Rollup merge of #147362 - chenyukang:yukang-fix-bound-147356, r=fee1-dead
Avoid suggesting constrain the associated type with unknown type

Fixes rust-lang/rust#147356
2025-11-28 21:22:23 -05:00
bors
467250ddb2 Auto merge of #144465 - orlp:system-alloc-tls, r=Mark-Simulacrum
Allow the global allocator to use thread-local storage and std:🧵:current()

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

Currently the thread-local storage implementation uses the `Global` allocator if it needs to allocate memory in some places. This effectively means the global allocator can not use thread-local variables. This is a shame as an allocator is precisely one of the locations where you'd *really* want to use thread-locals. We also see that this lead to hacks such as https://github.com/rust-lang/rust/pull/116402, where we detect re-entrance and abort.

So I've made the places where I could find allocation happening in the TLS implementation use the `System` allocator instead. I also applied this change to the storage allocated for a `Thread` handle so that it may be used care-free in the global allocator as well, for e.g. registering it to a central place or parking primitives.

r? `@joboet`
2025-11-29 02:08:53 +00:00
bors
1eb0657f78 Auto merge of #147404 - JamieCunliffe:inline-always, r=jackh726
Fix issue with callsite inline attribute not being applied sometimes.

If the calling function had more target features enabled than the callee than the attribute wasn't being applied as the arguments for the check had been swapped round. Also includes target features that are part of the global set as the warning was checking those but when adding the attribute they were not checked.

Add a codegen-llvm test to check that the attribute is actually applied as previously only the warning was being checked.

Tracking issue: rust-lang/rust#145574
2025-11-28 22:58:22 +00:00
Orson Peters
492fbc56c1 Update debuginfo test from Global to System 2025-11-28 23:35:38 +01:00
bors
cc3eee7fbe Auto merge of #149419 - matthiaskrgr:rollup-v3q93fq, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#147952 (Add a timeout to the `remote-test-client` connection)
 - rust-lang/rust#149321 (Fix ICE when include_str! reads binary files)
 - rust-lang/rust#149398 (add regression test for issue rust-lang/rust#143987)
 - rust-lang/rust#149411 (Tidying up UI tests [5/N])
 - rust-lang/rust#149413 (add test for issue 143821)
 - rust-lang/rust#149415 (Remove test-float-parse from workspace list in tidy)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-11-28 17:26:31 +00:00
Shoyu Vanilla
c6b0f7888b Add a regression test for issue 129865 2025-11-28 23:58:50 +09:00
Matthias Krüger
60e46fbbe3
Rollup merge of #149413 - Aditya-PS-05:test-issue-143821-nested-closure-ice, r=JonathanBrouwer
add test for issue 143821

closes rust-lang/rust#143821
2025-11-28 15:19:17 +01:00
Matthias Krüger
8d6e68b945
Rollup merge of #149411 - reddevilmidzy:t5, r=Kivooeo
Tidying up UI tests [5/N]

> [!NOTE]
> Intermediate commits are intended to help review, but will be squashed prior to merge.

part of rust-lang/rust#133895

merge directory

* `macro_backtrace` -> `macros`
* `missing_non_modrs_mod` -> `modules`
* `modules_and_files_visibility` -> `modules`
* `qualified` -> `typeck`
* `while` -> `for-loop-whlie`

r? Kivooeo
2025-11-28 15:19:16 +01:00
Matthias Krüger
3f1e4f8fee
Rollup merge of #149398 - Aditya-PS-05:test-issue-143987-align-struct-fields, r=Kivooeo
add regression test for issue #143987

closes rust-lang/rust#143987
2025-11-28 15:19:16 +01:00
Matthias Krüger
6d4e3f8596
Rollup merge of #149321 - reddevilmidzy:ice, r=petrochenkov
Fix ICE when include_str! reads binary files

ICE occurred when an invalid UTF8 file with an absolute path were included.

resolve: rust-lang/rust#149304
2025-11-28 15:19:15 +01:00
Aditya-PS-05
2b4b02e613 change test location 2025-11-28 18:52:18 +05:30
reddevilmidzy
ace4aebb6d Merge while with for-loop-while 2025-11-28 21:41:03 +09:00
reddevilmidzy
cd618a9ccb Merge missing_non_modrs with modules 2025-11-28 21:40:59 +09:00
reddevilmidzy
aa97acce62 Relocate qualified/qualified-path-params to
typeck/qualified-path-params.rs

merged test removed ui/qualified directory
2025-11-28 21:40:53 +09:00
reddevilmidzy
8e74c6b137 Relocate modules_and_files_visibility/mod_file_disambig.rs to
modules/mod_file_disambig.rs

add

fix
2025-11-28 21:40:35 +09:00
reddevilmidzy
58a802e629 Relocate modules_ans_files_visibity/mod_file_correct_spans.rs to
modules/mod_file_correct_spans.rs
2025-11-28 21:40:14 +09:00
bors
9050733395 Auto merge of #148020 - bjorn3:oom_backtrace, r=Mark-Simulacrum
Show backtrace on allocation failures when possible

And if an allocation while printing the backtrace fails, don't try to print another backtrace as that will never succeed.

Split out of https://github.com/rust-lang/rust/pull/147725 to allow landing this independently of a decision whether or not to remove `-Zoom=panic`.
2025-11-28 12:27:33 +00:00
Aditya-PS-05
57f92698be add test for borrow checker ICE with nested generic closures 2025-11-28 16:31:28 +05:30
bors
d645a4c9c5 Auto merge of #148871 - WaffleLapkin:never-simplifications, r=lcnr
Remove context dependant `!` fallback

... and minor cleanup.

r? lcnr
2025-11-28 09:16:14 +00:00
Stuart Cook
28fae11eba
Rollup merge of #149394 - Aditya-PS-05:test-issue-146445-guard-patterns-liveness, r=Kivooeo
add regression test for guard patterns liveness ICE

closes rust-lang/rust#146445
2025-11-28 15:30:45 +11:00
Stuart Cook
145c81d872
Rollup merge of #149380 - JonathanBrouwer:cfg_select_lints, r=Urgau
Run `eval_config_entry` on all branches so we always emit lints

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

Ideally I'd have liked to fix this issue using https://github.com/rust-lang/rust/pull/149215, and this is still the long term plan, but this is slightly more annoying to implement than I'd have liked to, and this is also a nice and easy solution to the problem.

r? `@tgross35`
2025-11-28 15:30:45 +11:00
Stuart Cook
6197b5be4c
Rollup merge of #149107 - Enselic:option-inspect-mutation, r=jieyouxu
rustc_borrowck: Don't suggest changing closure param type not under user control

This changes output of a handful of tests more than the one added in the first commit, but as far as I can tell, all removed suggestions were invalid.

Closes rust-lang/rust#128381 which is **D-invalid-suggestion** with two 👍-votes.
2025-11-28 15:30:43 +11:00
Stuart Cook
549c577c2a
Rollup merge of #149087 - nxsaken:unchecked_neg_shifts_stabilize, r=Amanieu
Stabilize `unchecked_neg` and `unchecked_shifts`

Features: `unchecked_neg`, `unchecked_shifts`
Tracking issue: rust-lang/rust#85122

r? `@Amanieu`
2025-11-28 15:30:43 +11:00
reddevilmidzy
bfc0c02043 Relocate macro_backtrace to macro and remove macro_backtrace 2025-11-28 13:12:15 +09:00
reddevilmidzy
3f943fbf84 Fix ICE when include_str! reads absolute path binary files 2025-11-28 12:43:56 +09:00
Orson Peters
ff8ed14a3f Expand test with allocating from thread-local destructors 2025-11-28 00:16:30 +01:00
Orson Peters
750609c0a7 Use System allocator for thread-local storage 2025-11-28 00:09:12 +01:00
bors
e6edf3ae53 Auto merge of #147498 - ferrocene:pvdrz/edition-range-gating, r=jieyouxu,fmease
Gate tests with the right edition

This PR guarantees that `./x test --test-args="--edition XXXX" ui` runs correctly with the 2015, 2018 and 2021 editions.

I don't expect this PR to hold up over time but it helps to submit further updates to the `//@ edition` directives of tests where we can use the new range syntax to have a more robust testing across different editions

r? `@fmease`

---

try-job: aarch64-gnu
try-job: aarch64-apple
try-job: x86_64-msvc-1
try-job: i686-msvc-1
try-job: x86_64-mingw-1
try-job: test-various
try-job: armhf-gnu
2025-11-27 22:37:05 +00:00
Jonathan Brouwer
41900f8bea
Add regression test 2025-11-27 23:02:01 +01:00
Waffle Lapkin
37ecc8e4a6
use a new tracking issue for never type changes 2025-11-27 22:48:00 +01:00
Waffle Lapkin
b48d701f71
remove feature(never_type_fallback) 2025-11-27 22:48:00 +01:00
Aditya-PS-05
3ceea4768b add issue link in test 2025-11-28 02:45:42 +05:30
Aditya-PS-05
b27bb83592 add regression test for align attribute on struct fields 2025-11-28 02:45:42 +05:30
bors
c86564c412 Auto merge of #149397 - matthiaskrgr:rollup-go79y6a, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#147071 (constify from_fn, try_from_fn, try_map, map)
 - rust-lang/rust#148930 (tweak editor configs)
 - rust-lang/rust#149320 (-Znext-solver: normalize expected function input types when fudging)
 - rust-lang/rust#149363 (Port the `#![windows_subsystem]` attribute to the new attribute system)
 - rust-lang/rust#149378 (make run-make tests use 2024 edition by default)
 - rust-lang/rust#149381 (Add `impl TrustedLen` on `BTree{Map,Set}` iterators)
 - rust-lang/rust#149388 (remove session+blob decoder construction)
 - rust-lang/rust#149390 (`rust-analyzer` subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-11-27 19:24:40 +00:00