Commit Graph

25125 Commits

Author SHA1 Message Date
bors 8da2d28cbd Auto merge of #142531 - ohadravid:better-storage-calls-copy-prop, r=tmiasko,cjgillot,saethlin
Remove fewer Storage calls in CopyProp and GVN



Modify the CopyProp and GVN MIR optimization passes to remove fewer `Storage{Live,Dead}` calls, allowing for better optimizations by LLVM - see rust-lang/rust#141649.

### Details

The idea is to use a new `MaybeUninitializedLocals` analysis and remove only the storage calls of locals that are maybe-uninit when accessed in a new location.
2026-04-18 09:16:07 +00:00
Jacob Pratt afb3f3d243 Rollup merge of #155435 - tonywu6:main, r=lolbinarycat
rustdoc: Fix `redundant_explicit_links` incorrectly firing (or not firing) under certain scenarios

Hi! I found some issues with the `rustdoc::redundant_explicit_links` lint while working on a personal project.

- After skipping a link that contains inline markups, the lint would incorrectly skip all the remaining links.

  For example, with the following snippet, the lint is fired for `[Option][Option]`, but not `[Result][Result]`:

  ```rs
  //! [Option][Option]
  //! [**u8**][u8]     (skipped)
  //! [Result][Result]
  ```

  Happening because of a `?` causing a loop to bail early:

  https://github.com/rust-lang/rust/blob/a4a37ed163a6c1d227b58047d91457589c611cf8/src/librustdoc/passes/lint/redundant_explicit_links.rs#L107

- The lint is fired for links that specify titles (like `[link](link "title")`), except that wouldn't be applicable because it's not possible to specify a title without there also being an explicit target. For example:

  ```
  error: redundant explicit link target
  --> <anon>:5:12
    |
  5 | /// [drop](drop "This function is not magic")
    |      ----  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ explicit target is redundant
    |      |
    |      because label contains path that resolves to same destination
    |
    = note: when a link's destination is not specified,
            the label is used to resolve intra-doc links
  help: remove explicit link target
    |
  5 - /// [drop](drop "This function is not magic")
  5 + /// [drop]
    |
  ```

These are found as of:

```
rustdoc 1.97.0-nightly (1b8f2e46e 2026-04-17)
binary: rustdoc
commit-hash: 1b8f2e46e1
commit-date: 2026-04-17
host: aarch64-apple-darwin
release: 1.97.0-nightly
LLVM version: 22.1.2
```

(Note: I ran `./x test tests/rustdoc-ui` locally, but not `./x tidy` due to my slow internet. There was an unrelated failed test at `tests/rustdoc-ui/ice-bug-report-url.rs` which I'm not sure about)
2026-04-18 00:05:20 -04:00
Jacob Pratt e3676b5ab9 Rollup merge of #155428 - lapla-cogito:issue_139089, r=mejrs
Fix ICE in borrowck mutability suggestion with multi-byte ref sigil

Fixes rust-lang/rust#139089

Similarly to rust-lang/rust#155068, this is another instance where span arithmetic did not account for multi-byte characters. (Note that the ampersand in the test is full-width)

This change also results in correcting some inappropriate suggestions.
2026-04-18 00:05:19 -04:00
Jacob Pratt eb52efbbd2 Rollup merge of #155295 - lapla-cogito:issue_154350, r=JohnTitor
Fix misleading "borrowed data escapes outside of function" diagnostic

Fixes rust-lang/rust#154350

Fall back to `report_general_error()` when `fr_name_and_span` is `None` in function items, since the "escaping data" framing is only appropriate for closures capturing outside variables.
2026-04-18 00:05:18 -04:00
Jacob Pratt db3d08421c Rollup merge of #154935 - Darksonn:dyn-trait-dyn-compat, r=scottmcm
Add Sized supertrait for CoerceUnsized and DispatchFromDyn

This is part of rust-lang/rust#149094. I did not include `Receiver` because I think it is correct to allow non-sized receivers.
2026-04-18 00:05:15 -04:00
Jacob Pratt baf4388b8f Rollup merge of #147811 - folkertdev:naked-function-sections, r=Amanieu
naked functions: respect `function-sections`

fixes https://github.com/rust-lang/rust/issues/147789

r? @Amanieu
2026-04-18 00:05:15 -04:00
lapla a779e054a9 Fix ICE in borrowck mutability suggestion with multi-byte ref sigil 2026-04-18 08:52:11 +09:00
bors e9e32aca5a Auto merge of #155432 - JonathanBrouwer:rollup-dJVrrO0, r=JonathanBrouwer
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#154781 (Fix attribute order implementation)
 - rust-lang/rust#155242 (resolve: Introduce `(Local,Extern)Module` newtypes for local and external modules respectively)
 - rust-lang/rust#149614 (Use `MaybeDangling` in `std`)
 - rust-lang/rust#153178 (Add `TryFromIntError::kind` method and `IntErrorKind::NotAPowerOfTwo` variant)
 - rust-lang/rust#155049 (Documenting the case of `Weak::upgrade` returning `None` when the value behind the reference is missing)

Failed merges:

 - rust-lang/rust#155308 (Make `OnDuplicate::Error` the default for attributes)
2026-04-17 19:17:17 +00:00
bors f29256dd14 Auto merge of #155248 - JonathanBrouwer:no_hash_delayed_lints, r=GuillaumeGomez
Don't hash `DelayedLints`

This PR unblocks https://github.com/rust-lang/rust/pull/154432, and was also a minor perf win locally
2026-04-17 16:05:32 +00:00
Jonathan Brouwer 5c7384e1c9 Add regression test 2026-04-17 16:08:45 +02:00
Ohad Ravid 5632001f83 Improve copy_prop and GVN mir-opt passes to remove fewer storage calls 2026-04-17 16:55:43 +03:00
Jonathan Brouwer c142d8013c Rollup merge of #154781 - JonathanBrouwer:fix-attr-order, r=jdonszelmann
Fix attribute order implementation

The implementation in https://github.com/rust-lang/rust/pull/153041 contained a mistake :c
I swapped the place where the error message was on, but did not change any code for which attribute was also selected, which explains the empty crater results.
**Interestingly, the original code is broken too, before https://github.com/rust-lang/rust/pull/153041 it always took the last attribute, regardless of what the `AttributeOrder` actually was...**

Let's first see crater results before making a decision

TODO for this PR: Make better tests for this
2026-04-17 13:28:55 +02:00
Tony Wu b967de6255 rustdoc: fix issues with redundant_explicit_links 2026-04-17 19:17:42 +08:00
bors 4dbafc340b Auto merge of #153955 - aerooneqq:def-path-hash-collision, r=petrochenkov
delegation: fix def path hash collision, add per parent disambiguators



This PR addresses the following delegation issues:
- It fixes rust-lang/rust#153410 when generating new `DefId`s for generic parameters by ~saving `DisambiguatorState`s from resolve stage and using them at AST -> HIR lowering~ introducing per owner disambiguators and transferring them to AST -> HIR lowering stage
- ~Next it fixes the ICE which is connected to using `DUMMY_SP` in delegation code, which was found during previous fix~
- ~Finally, after those fixes the rust-lang/rust#143498 is also fixed, only bugs with propagating synthetic generic params are left.~

Fixes rust-lang/rust#153410. Part of rust-lang/rust#118212.

r? @petrochenkov
2026-04-17 11:13:11 +00:00
Jonathan Brouwer 6f968782fd Add regression tests 2026-04-17 12:37:58 +02:00
Folkert de Vries 2db9de3782 add ignore-cross-compile to run-make test 2026-04-17 11:25:58 +02:00
bors 27dbdb57a2 Auto merge of #155416 - Zalathar:rollup-D1EWnrR, r=Zalathar
Rollup of 19 pull requests

Successful merges:

 - rust-lang/rust#141633 (Suggest to bind `self.x` to `x` when field `x` may be in format string)
 - rust-lang/rust#152980 (c-variadic: fix implementation on `avr`)
 - rust-lang/rust#154491 (Extend `core::char`'s documentation of casing issues (and fix a rustdoc bug))
 - rust-lang/rust#155318 (Use mutable pointers for Unix path buffers)
 - rust-lang/rust#155335 (Bump bootstrap to 1.96 beta)
 - rust-lang/rust#155354 (Remove AttributeSafety from BUILTIN_ATTRIBUTES)
 - rust-lang/rust#154970 (rustdoc: preserve `doc(cfg)` on locally re-exported type aliases)
 - rust-lang/rust#155095 (changed the information provided by (mut x) to mut x (Fix 155030))
 - rust-lang/rust#155305 (Make `convert_while_ascii` unsafe)
 - rust-lang/rust#155358 (ImproperCTypes: Move erasing_region_normalisation into helper function)
 - rust-lang/rust#155377 (tests/debuginfo/basic-stepping.rs: Remove FIXME related to ZSTs)
 - rust-lang/rust#155383 (Rearrange `rustc_ast_pretty`)
 - rust-lang/rust#155384 (triagebot: notify on diagnostic attribute changes)
 - rust-lang/rust#155386 (Use `box_new` diagnostic item for Box::new suggestions)
 - rust-lang/rust#155391 (Small refactor of `QueryJob::latch` method)
 - rust-lang/rust#155395 (Tweak how the "copy path" rustdoc button works to allow some accessibility tool to work with rustdoc)
 - rust-lang/rust#155396 (`as_ref_unchecked` docs link fix)
 - rust-lang/rust#155411 (compiletest: Remove the `//@ should-ice` directive)
 - rust-lang/rust#155413 (fix: typo in `std::fs::hard_link` documentation)
2026-04-17 07:35:43 +00:00
aerooneqq 699eb29443 Fix delegation def path hash collision, add per-parent disambiguators 2026-04-17 09:46:54 +03:00
Stuart Cook 87315a8a53 Rollup merge of #155411 - Zalathar:should-ice, r=jieyouxu
compiletest: Remove the `//@ should-ice` directive

The `//@ should-ice` directive was only being used by one test, which can just as easily use the more general `//@ failure-status` directive instead.

All of the removed exit-code checks were redundant with other exit-code checks that are still present.

---

I have manually verified that `tests/incremental/delayed_span_bug.rs` fails if the failure-status directive is modified or removed.
2026-04-17 16:18:01 +10:00
Stuart Cook f92c79e3e0 Rollup merge of #155395 - GuillaumeGomez:copy-path-with-ronga, r=notriddle
Tweak how the "copy path" rustdoc button works to allow some accessibility tool to work with rustdoc

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

It's a bit better in term of "fragility" to retrieve this information: no need to parse text anymore, just to retrieve content. However it relies on HTML. I added extra tests to ensure it won't break without notice.

cc @Enyium

r? @lolbinarycat
2026-04-17 16:18:00 +10:00
Stuart Cook 36351e1485 Rollup merge of #155377 - Enselic:stepping-zsts, r=petrochenkov
tests/debuginfo/basic-stepping.rs: Remove FIXME related to ZSTs

We don't consider it a bug that users can't break on initialization of some non-zero sized types (see https://github.com/rust-lang/rust/pull/153941 and linked discussions), so it does not make sense to consider it a bug that users can't break on initialization of some zero-sized types.

Closes rust-lang/rust#97083

r? compiler (see https://github.com/rust-lang/rust/pull/155352)
2026-04-17 16:17:56 +10:00
Stuart Cook 16b22a7e0f Rollup merge of #155305 - Zoxc:ub-issue-2, r=tgross35
Make `convert_while_ascii` unsafe

`convert_while_ascii` assumes `convert` only returns ASCII to ensure the output remains valid UTF-8. This adds that requirement as a safety precondition.
2026-04-17 16:17:55 +10:00
Stuart Cook 350e0d7fad Rollup merge of #155095 - lms0806:issue_155030, r=nnethercote
changed the information provided by (mut x) to mut x (Fix 155030)

When trying to change a value without using mut in a for loop, the recommendation for this change is incorrect, so I am correcting it.

resolve: rust-lang/rust#155030
2026-04-17 16:17:54 +10:00
Stuart Cook 0ab3a69f3c Rollup merge of #154970 - shivendra02467:fix-rustdoc-154921, r=GuillaumeGomez
rustdoc: preserve `doc(cfg)` on locally re-exported type aliases

When a type alias is locally re-exported from a private module (an implicit inline), rustdoc drops its `cfg` attributes because it treats it like a standard un-inlined re-export. Since type aliases have no inner fields to carry the `cfg` badge (unlike structs or enums), the portability info is lost entirely.

This patch explicitly preserves the target's `cfg` metadata when the generated item is a `TypeAliasItem`, ensuring the portability badge renders correctly without breaking standard cross-crate re-export behavior.

Fixes rust-lang/rust#154921
2026-04-17 16:17:53 +10:00
Stuart Cook 3c61fba50b Rollup merge of #154491 - Jules-Bertholet:case-docs, r=Mark-Simulacrum,GuillaumeGomez
Extend `core::char`'s documentation of casing issues (and fix a rustdoc bug)

@rustbot label A-unicode A-docs
2026-04-17 16:17:50 +10:00
Stuart Cook 91a7d1b498 Rollup merge of #152980 - folkertdev:c-variadic-avr, r=tgross35
c-variadic: fix implementation on `avr`

tracking issue: https://github.com/rust-lang/rust/issues/44930
cc target maintainer @Patryk27

I ran into multiple issues, and although with this PR and a little harness I can run the test with qemu on avr, the implementation is perhaps not ideal.

The problem we found is that on `avr` the `c_int/c_uint` types are `i16/u16`, and this was not handled in the c-variadic checks. Luckily there is a field in the target configuration that contains the targets `c_int_width`. However, this field is not actually used in `core` at all, there the 16-bit targets are just hardcoded.

https://github.com/rust-lang/rust/blob/1500f0f47f5fe8ddcd6528f6c6c031b210b4eac5/library/core/src/ffi/primitives.rs#L174-L185

Perhaps we should expose this like endianness and pointer width?

---

Finally there are some changes to the test to make it compile with `no_std`.
2026-04-17 16:17:50 +10:00
Stuart Cook 1ff95e018f Rollup merge of #141633 - xizheyin:issue-141350, r=nnethercote
Suggest to bind `self.x` to `x` when field `x` may be in format string

Fixes rust-lang/rust#141350

I added the new test in the first commit, and committed the changes in the second one.

r? @fmease
cc @mejrs
2026-04-17 16:17:49 +10:00
bors 1b8f2e46e1 Auto merge of #155207 - quiode:writable, r=RalfJung
add llvm writable attribute conditionally




This PR tries to address https://github.com/rust-lang/unsafe-code-guidelines/issues/584#issue-3440604811. It is part of a bachelor thesis supervised by @JoJoDeveloping and @RalfJung, for more information, see: [Project_Description.pdf](https://github.com/user-attachments/files/26537277/Project_Description.pdf).
If the new `-Zllvm-writable` flag is set, the [llvm writable attribute](https://llvm.org/docs/LangRef.html#writable) is inserted for all mutable borrows. This can be conditionally turned off on a per-function basis using the `#[rustc_no_writable]` attribute. The new Undefined Behaviour introduced by this can detected by Miri, which is implemented here: https://github.com/rust-lang/miri/pull/4947.

Two library functions already received the `#[rustc_no_writable]` attribute, as they are known to cause problems under the Tree Borrows aliasing model with implicit writes enabled.
2026-04-17 04:13:36 +00:00
Zalathar 975402e329 Remove the //@ should-ice directive
This directive was only being used by one test, which can just as easily use
the more general `//@ failure-status` directive instead.

All of the removed exit-code checks were redundant with other exit-code checks
that are still present.
2026-04-17 13:43:50 +10:00
Guillaume Gomez 6c4ec59d5f Tweak how the "copy path" rustdoc button works to allow some accessibility tool to work with rustdoc 2026-04-16 22:06:45 +02:00
bors 7af3402cda Auto merge of #155380 - jhpratt:rollup-j1e7DVL, r=jhpratt
Rollup of 18 pull requests

Successful merges:

 - rust-lang/rust#154451 (Require that a `<_ as Try>::Residual` implement the `Residual` trait)
 - rust-lang/rust#154595 (Emit fatal on invalid const args with nested defs)
 - rust-lang/rust#154599 (report the `varargs_without_pattern` lint in deps)
 - rust-lang/rust#154699 (`core::unicode`: Replace `Cased` table with `Lt`)
 - rust-lang/rust#155353 (resolve: Remove `inaccessible_ctor_reexport` resolver field)
 - rust-lang/rust#155357 (Add `--remap-path-scope` as unstable in rustdoc)
 - rust-lang/rust#150649 (clippy fix: non_canonical_clone_impl)
 - rust-lang/rust#154604 (abort in core)
 - rust-lang/rust#154616 (Add `--quiet` flag to x.py and bootstrap to suppress output)
 - rust-lang/rust#155215 (Clean up `AttributeLintKind` and refactor diagnostic attribute linting)
 - rust-lang/rust#155228 (Check diagnostic output in incremental `cpass` and `rpass` revisions)
 - rust-lang/rust#155266 (Adjust release notes for post-merge feedback)
 - rust-lang/rust#155326 (Disallow ZST allocations with `TypedArena`.)
 - rust-lang/rust#155334 (docs: Use `0b1` instead of `NonZero::MIN` in `NonZero::bit_width` doctests)
 - rust-lang/rust#155340 (Handle nonnull pattern types in size skeleton)
 - rust-lang/rust#155347 (Add push_mut and new Layout methods to release notes)
 - rust-lang/rust#155356 (remove calls to AliasTyKind::def_id)
 - rust-lang/rust#155364 (Reduce diagnostic type visibilities.)
2026-04-16 18:19:58 +00:00
Dominik Schwaiger da2bbfbbec add llvm writable attribute conditionally 2026-04-16 12:29:39 +00:00
bors 18b439f84e Auto merge of #154605 - estebank:attr-suggest, r=jieyouxu
Make `span_suggestions` always verbose



`span_suggestions` is to provide mutually exclusive suggestions. When it was introduced, we made its behavior be that if a single suggestion is given to it, we present the suggestion inline, otherwise in patch format. Changing this to make all of its uses be verbose, as that is closer in intent of output.
2026-04-16 11:23:18 +00:00
Folkert de Vries b8ba4002f5 c-variadic: handle c_int being i16 and c_double being f32 on avr 2026-04-16 11:48:02 +02:00
Folkert de Vries 41afd5f8d6 handle uefi and test assembly versus regular functions 2026-04-16 11:37:46 +02:00
Folkert de Vries cc1ebb5e20 add uefi to windows link section test 2026-04-16 11:37:46 +02:00
Folkert de Vries 7787bd915b fix macho section specifier & windows test 2026-04-16 11:37:46 +02:00
Folkert de Vries bc4aad37ca naked-functions: properly document the -Zfunction-sections windows status 2026-04-16 11:37:45 +02:00
Folkert de Vries 25e1647869 naked functions: add run-make test for DCE 2026-04-16 11:37:45 +02:00
Folkert de Vries 872301bfdd naked functions: respect function_sections on linux/macos 2026-04-16 11:37:45 +02:00
Folkert de Vries 0e522d6c62 naked functions: respect function_sections on windows
For `gnu` function_sections is off by default.
2026-04-16 11:37:45 +02:00
Shivendra Sharma 52ad8c071c rustdoc: preserve doc(cfg) on locally re-exported type aliases
When a type alias is locally re-exported from a private module (an implicit
inline), rustdoc drops its `cfg` attributes because it treats it like a
standard un-inlined re-export. Since type aliases have no inner fields to
carry the `cfg` badge (unlike structs or enums), the portability info
is lost entirely.

This patch explicitly preserves the target's `cfg` metadata when the
generated item is a `TypeAliasItem`, ensuring the portability badge
renders correctly without breaking standard cross-crate re-export behavior.
2026-04-16 11:51:51 +05:30
Jacob Pratt a5f590a1d6 Rollup merge of #155340 - oli-obk:size-skeleton-pat-tys, r=mati865
Handle nonnull pattern types in size skeleton

The original comment was correct, the size is always the same, but we have more information now. In theory there was an additional bug that would have allowed transmuting things of different sizes, but I don't see how that would have been actually doable as the `tail` types would always have differed.

fixes rust-lang/rust#155330
2026-04-16 01:54:13 -04:00
Jacob Pratt 74bf79509b Rollup merge of #155228 - Zalathar:incr-test-diag, r=jieyouxu
Check diagnostic output in incremental `cpass` and `rpass` revisions

This allows compiler warnings to be annotated in `cpass` and `rpass` revisions, and verifies that no unexpected warnings occur.

---

My underlying motivation is that I want to be able to reduce or eliminate the confusing combination of `cfail` revisions with `//@ build-pass` directives, and replace them with a more straightforward `cpass` revision that also checks diagnostic output. That migration is not part of this PR.
2026-04-16 01:54:11 -04:00
Jacob Pratt 0d98e0d54f Rollup merge of #155215 - mejrs:condense_diag_lints, r=JonathanBrouwer
Clean up `AttributeLintKind` and refactor diagnostic attribute linting

There was a fair amount of duplication here, and thanks to the proliferation of new diagnostic attributes these days, it was threatening to grow bigger.
2026-04-16 01:54:10 -04:00
Jacob Pratt a25356babb Rollup merge of #155357 - Urgau:rustdoc-remap-path-scope, r=GuillaumeGomez
Add `--remap-path-scope` as unstable in rustdoc

This PR adds support for `rustc` `--remap-path-scope` flag in rustdoc as unstable.

`rustc` documentation for the flag is [here](https://doc.rust-lang.org/nightly/rustc/remap-source-paths.html#--remap-path-scope).

I added some complementary tests for `rustdoc`, no need I think to duplicate `rustc` UI tests.
2026-04-16 01:54:07 -04:00
Jacob Pratt 0238243b5f Rollup merge of #154599 - folkertdev:varargs-without-pattern-in-deps, r=mati865
report the `varargs_without_pattern` lint in deps

tracking issue: https://github.com/rust-lang/rust/issues/44930

After discussion in https://github.com/rust-lang/reference/pull/2177#discussion_r2864885208.

Based on https://github.com/rust-lang/rust/pull/143619#issuecomment-3133157725 there was only one actual impacted crate https://crates.io/crates/binrw. The issue was fixed in https://github.com/jam1garner/binrw/issues/342, and has since been released https://github.com/jam1garner/binrw/issues/342#issuecomment-3994700268.

Hence we may as well report this loudly.

r? @ghost
2026-04-16 01:54:05 -04:00
Jacob Pratt 402748551a Rollup merge of #154595 - mu001999-contrib:fix/154539, r=BoxyUwU
Emit fatal on invalid const args with nested defs

Fixed https://github.com/rust-lang/rust/issues/123629
Fixes https://github.com/rust-lang/rust/issues/154539

Invalid const args are rejected, so their surrounding HIR is not preserved. But nested defs inside them can still get created, leaving children lowered without a valid HIR parent and causing an ICE when later error handling walks HIR parents.

r? @BoxyUwU
2026-04-16 01:54:05 -04:00
Martin Nordholts 98242676d9 tests/debuginfo/basic-stepping.rs: Remove FIXME related to ZSTs
We don't consider it a bug that users can't break on initialization of
some non-zero sized types (see comment on `maximally-steppable` at the
top of the file), so it does not make sense to consider it a bug that
users can't break on initialization of some zero-sized types.
2026-04-16 06:05:12 +02:00
Jules Bertholet a9d7027f39 rustdoc: percent-encode URL fragments 2026-04-15 22:32:07 -04:00