Commit Graph

324057 Commits

Author SHA1 Message Date
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 eb185531e1 Rollup merge of #154943 - Zalathar:for-each-subpat, r=Nadrieril
Move recursion out of `MatchPairTree::for_pattern` helpers

The helper functions now just iterate over the relevant subpatterns, while leaving recursion up to the main function.

This avoids passing parameters that were only used for recursive plumbing, and consolidates all recursive calls into `for_pattern` itself, which should make it easier to experiment with changes to the recursive structure.

There should be no change to compiler behaviour.
2026-04-18 00:05:17 -04:00
Jacob Pratt 354bfa49ff Rollup merge of #153511 - DanielEScherzer:patch-3, r=scottmcm
`std::any::TypeId`: remove misplaced "and" in `Unique<T>` example
2026-04-18 00:05:17 -04:00
Jacob Pratt 221dab89b4 Rollup merge of #139690 - cuviper:iter_repeat_n_default, r=tgross35
`impl Default for RepeatN`

This creates an empty iterator, like `repeat_n(value, 0)` but without
needing any such value at hand. There's precedent in many other
iterators that the `Default` is empty, like `slice::Iter`.

I found myself wanting this for rayon's `RepeatN` as it lowers to a
sequential iterator [here][1]. Since rayon is also optimizing to avoid
extra clones, it may end up with parallel splits that have count 0 and
no item value. Calling `std::iter::repeat_n(x, 0)` just drops that
value, but there's no way to construct the same result without a value
yet. This would be straightforward with an empty `Default`.

[1]: https://github.com/rayon-rs/rayon/blob/ae07384e3e0b238cea89f0c14891f351c65a5cee/src/iter/repeat.rs#L201-L202

r? libs-api (insta-stable)
2026-04-18 00:05:16 -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
bors 2f201bccb3 Auto merge of #155404 - flip1995:clippy-subtree-update, r=Manishearth
Clippy subtree update

r? Manishearth 

`Cargo.lock` update due to Clippy version bump and cargo_metadata dep bump in Clippy.
2026-04-17 23:02:37 +00: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
Jonathan Brouwer d14311c4a1 Don't hash DelayedLints 2026-04-17 16:08:45 +02:00
Jonathan Brouwer f67a3759bf Rollup merge of #155049 - quixoticaxis:weak-upgrade-documentation-extension, r=jhpratt
Documenting the case of `Weak::upgrade` returning `None` when the value behind the reference is missing

Adds a clause to the documentation of `Weak` for `Arc` which was discussed in rust-lang/rust#154936.

Adds the same clause to the documentation of `Weak` for `Rc`, because the behavior is the same.
2026-04-17 13:28:59 +02:00
Jonathan Brouwer 932d807e7e Rollup merge of #153178 - sorairolake:feature/try-from-int-error-kind, r=tgross35
Add `TryFromIntError::kind` method and `IntErrorKind::NotAPowerOfTwo` variant

- ACP: rust-lang/libs-team#746
- Tracking issue: rust-lang/rust#153978

This pull request adds `kind` method to [`TryFromIntError`](https://doc.rust-lang.org/core/num/struct.TryFromIntError.html), which outputs the detailed cause of converting an integer failing.

This is primarily intended for use in cases where there are multiple causes for failure, such as converting from a large signed integer type to a small signed integer type.

At the moment, this method returns [`&IntErrorKind`](https://doc.rust-lang.org/core/num/enum.IntErrorKind.html). This type implements the `Copy` trait and could return `IntErrorKind`, but returns a reference to align with the behavior of [`ParseIntError::kind`](https://doc.rust-lang.org/core/num/struct.ParseIntError.html#method.kind). If it is not necessary to align the behavior of `TryFromIntError::kind` with `ParseIntError::kind`, I'll change this method to return `IntErrorKind`.

Before this pull request, `IntErrorKind` was only used by [`ParseIntError`](https://doc.rust-lang.org/core/num/struct.ParseIntError.html), but I changed it to be used by `TryFromIntError` as well, so I updated `IntErrorKind`'s documentation.

[`impl TryFrom<usize> for Alignment`](https://doc.rust-lang.org/std/ptr/struct.Alignment.html#impl-TryFrom%3Cusize%3E-for-Alignment) returns `TryFromIntError` as an error if the given value is not a power of two. However, `IntErrorKind` does not have a variant that represents this. So I added the variant `NotAPowerOfTwo` to represent this. For this variant to stabilize, both `try_from_int_error_kind` and `ptr_alignment_type` features must be stabilized.
2026-04-17 13:28:58 +02:00
Jonathan Brouwer ea736ba569 Rollup merge of #149614 - WaffleLapkin:dangle-maybe, r=jhpratt
Use `MaybeDangling` in `std`

cc https://github.com/rust-lang/rust/issues/118166
2026-04-17 13:28:57 +02:00
Jonathan Brouwer 89bec2cd37 Rollup merge of #155242 - petrochenkov:modmodmod, r=mu001999
resolve: Introduce `(Local,Extern)Module` newtypes for local and external modules respectively

Right now both `LocalModule` and `ExternModule` refer to the same `ModuleData`, but the module data for local and extern modules can potentially be made quite different, and we can specialize name lookup for both cases as an optimization.

Declaration creation for local and external modules was already specialized as a part of the parallel import resolution work (see `define_local` and `define_extern`, rust-lang/rust#145108 and previous PRs), because they have different properties with regards to ownership and synchronization.
2026-04-17 13:28:56 +02: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
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
Vadim Petrochenkov 61bc404458 resolve: Introduce (Local,Extern)Module newtypes for local and external modules respectively 2026-04-17 13:09:04 +03:00
Folkert de Vries 2db9de3782 add ignore-cross-compile to run-make test 2026-04-17 11:25:58 +02:00
Sergey Ivanov f580872fe2 Extended the documentation for Arc's Weak::upgrade 2026-04-17 07:47:34 +00: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 9de2e2bfd7 Rollup merge of #155413 - StepfenShawn:patch-2, r=ChrisDenton
fix: typo in `std::fs::hard_link` documentation

Change "corresponds the" to "corresponds to the" in the documentation for `std::fs::hard_link`.
2026-04-17 16:18:02 +10: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 fd57bed92e Rollup merge of #155396 - oconnor663:link_typo, r=folkertdev
`as_ref_unchecked` docs link fix

Fix what's probably a copy-paste-o in a docs link.
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 7e43cdf977 Rollup merge of #155391 - zetanumbers:query_latch_oneliner, r=petrochenkov
Small refactor of `QueryJob::latch` method

We can use `Option::get_or_insert_with` to avoid unwrapping there.
2026-04-17 16:17:59 +10:00
Stuart Cook b9d3efa317 Rollup merge of #155386 - cijiugechu:fix-box-new-diagnostic-item, r=Kivooeo
Use `box_new` diagnostic item for Box::new suggestions

When look this part of code, I noticed this FIXME and fixed it :)
2026-04-17 16:17:58 +10:00
Stuart Cook 37344ab259 Rollup merge of #155384 - mejrs:pingme, r=jieyouxu
triagebot: notify on diagnostic attribute changes

Did I get this right? 😆
2026-04-17 16:17:58 +10:00
Stuart Cook f9c4e61ac0 Rollup merge of #155383 - nnethercote:rearrange-rustc_ast_pretty, r=WaffleLapkin
Rearrange `rustc_ast_pretty`

`rustc_ast_pretty` has two modules, `pp::convenience` and `helpers`, that are small and silly. This PR eliminates them. Details in the individual commits.

r? @WaffleLapkin
2026-04-17 16:17:57 +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 e59e8f0412 Rollup merge of #155358 - niacdoial:improperctypes-refactor2.1, r=petrochenkov
ImproperCTypes: Move erasing_region_normalisation into helper function

This is "part 1/3 of 2/3 of 1/2" of the original pull request https://github.com/rust-lang/rust/pull/134697 (refactor plus overhaul of the ImproperCTypes family of lints)
(all pulls of this series of pulls are supersets of the previous pulls. If this pull is "too small" to be worth the effort, you can instead look at the next in the series)

This pull is a small internal change among the efforts to refactor the ImproperCTypes lints, by moving some "unwrapping" code (`cx.tcx.try_normalize_erasing_regions`) into a helper function.

r? petrochenkov
2026-04-17 16:17:55 +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 d4b573d95c Rollup merge of #155354 - JonathanBrouwer:attr-safety-port-2, r=mejrs
Remove AttributeSafety from BUILTIN_ATTRIBUTES

Encodes the expected attribute safety in the attribute parsers, rather than in `BUILTIN_ATTRIBUTES`, with the goal of removing `BUILTIN_ATTRIBUTES` soon.
We can remove the old attribute safety logic already because unparsed attributes, just like the as of yet unparsed lint attributes, need to be safe.

r? @jdonszelmann  (or @mejrs if you feel like doing it, since you are in T-compiler now 🎉)
2026-04-17 16:17:53 +10:00
Stuart Cook 6951f83914 Rollup merge of #155335 - Mark-Simulacrum:bootstrap-bump, r=jieyouxu
Bump bootstrap to 1.96 beta

See https://forge.rust-lang.org/release/process.html#default-branch-bootstrap-update-tuesday

I think this will wind up needing another PR in a week or so when we pick up assert_matches getting destabilized in beta? But that seems like it can be split into its own PR.
2026-04-17 16:17:52 +10:00
Stuart Cook b7ea9df119 Rollup merge of #155318 - Zoxc:ub-issue-50, r=ChrisDenton
Use mutable pointers for Unix path buffers

This gets mutable pointers for Unix path buffers to ensure they have the right provenance.
2026-04-17 16:17:51 +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
Shun Sakai c35ed1ac32 feat: Add TryFromIntError::kind and IntErrorKind::NotAPowerOfTwo 2026-04-17 14:04:56 +09: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
🍌Shawn b05e29b8cb Fix typo in documentation for CreateHardLink function 2026-04-17 11:52:59 +08: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
Josh Stone a66b7810c3 impl Default for RepeatN
This creates an empty iterator, like `repeat_n(value, 0)` but without
needing any such value at hand. There's precedent in many other
iterators that the `Default` is empty, like `slice::Iter`.

I found myself wanting this for rayon's `RepeatN` as it lowers to a
sequential iterator [here][1]. Since rayon is also optimizing to avoid
extra clones, it may end up with parallel splits that have count 0 and
no item value. Calling `std::iter::repeat_n(x, 0)` just drops that
value, but there's no way to construct the same result without a value
yet. This would be straightforward with an empty `Default`.

[1]: https://github.com/rayon-rs/rayon/blob/ae07384e3e0b238cea89f0c14891f351c65a5cee/src/iter/repeat.rs#L201-L202
2026-04-16 16:49:11 -07:00
Mark Rousskov a64c420c70 Bump stage0 to 1.96 beta 2026-04-16 19:30:56 -04:00
John Kåre Alsaker 7a47964d3f Use mutable pointers for Unix path buffers 2026-04-17 01:08:08 +02:00
bors 0204aca066 Auto merge of #155385 - davidtwco:stdarch-sync-160426, r=davidtwco
stdarch subtree update

Subtree update of `stdarch` to https://github.com/rust-lang/stdarch/commit/095646219d35769f013c4a54d843a982c87d979c.

Created using https://github.com/rust-lang/josh-sync.

r? @ghost
2026-04-16 21:38:27 +00:00