Commit Graph

322472 Commits

Author SHA1 Message Date
Jonathan Brouwer
45cec8bb3e Rollup merge of #153532 - jdonszelmann:attributes-containing-rustc, r=petrochenkov
Attributes containing rustc

r? @petrochenkov

I noticed that attributes *containing* the word rustc as a segment also error with a message referring to "starting with rustc". The first commit shows this going wrong by re-exporting `#[test]`, a built-in macro, from a module called rustc.

The 2nd commit addresses this by changing the diagnostic. However, given the wording I wonder if the real solution shouldn't be to allow attributes containing a `rustc` segment and only disallow them when they start. In other words, actually implement the behavior that the original diagnostic pointed out.
2026-04-02 22:13:48 +02:00
Jonathan Brouwer
828e302c7b Rollup merge of #153105 - makai410:erase-if-error, r=lcnr
Compute the result of a projection type with region errors

Fixes: rust-lang/rust#152682

With the old trait solver, `type_known_to_meet_bound_modulo_regions()` isn't really operating "modulo regions" if there are any region errors, since `normalize` will just return a type error to the trait solver if given a ty with a region error, which then starts cascading when there are so many assumptions.

So I think it would be good to erase regions if there are any region errors before we normalize the type when collecting predicates for confirmation.

That said, I somehow feel like this is kind of ad-hoc... I'd really appreciate if someone more familiar with this code could take a closer look :3
2026-04-02 22:13:48 +02:00
Jana Dönszelmann
3e0572e7b6 improve diagnostics for attrs that *contain* the word rustc 2026-04-02 11:10:33 +02:00
bors
e6b64a2f4c Auto merge of #154700 - wesleywiser:revert_151771, r=jieyouxu
Revert "Fix: On wasm targets, call panic_in_cleanup if panic occurs in cleanup #151771"

Clean revert of rust-lang/rust#151771 as discussed in the [compiler team triage meeting](https://rust-lang.zulipchat.com/#narrow/channel/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202026-03-26/near/581957759) and https://github.com/rust-lang/rust/issues/153948#issuecomment-4137655589

Fixes (after backport): rust-lang/rust#153948
2026-04-02 07:34:44 +00:00
bors
8931f23941 Auto merge of #154614 - nnethercote:streamline-CachingSourceMapView, r=JonathanBrouwer
Streamline `CachingSourceMapView`

`CachingSourceMapView` is home to some pretty ugly, low-level, repetitive code. We can do better. Details in individual commits.

r? @JonathanBrouwer
2026-04-02 03:18:50 +00:00
Wesley Wiser
c9d3a00cd1 Revert "Fix: On wasm targets, call panic_in_cleanup if panic occurs in cleanup"
This reverts commit acbfd79acf.
2026-04-01 21:29:42 -05:00
bors
009a6c1e8b Auto merge of #154308 - ShoyuVanilla:undo-fudge-iv, r=jieyouxu
Revert #151380 and #153869

cc https://rust-lang.zulipchat.com/#narrow/channel/474880-t-compiler.2Fbackports/topic/.23153869.3A.20beta-nominated/with/581306395

r? ghost
2026-04-02 00:09:59 +00:00
bors
7e46c5f6fb Auto merge of #154292 - Zalathar:def-kind, r=petrochenkov
Don't use disk-cache for query `def_kind`



From what I can tell, the `def_kind` query has no local provider, and is always given its value via query feeding, usually from `TyCtxt::create_def`.

If that's the case, there should never be any opportunity for a previous value to be loaded from disk-cache, so serializing the current-session values is a waste of time.
2026-04-01 16:54:24 +00:00
bors
2bd7a97871 Auto merge of #154668 - jhpratt:rollup-ePnl7Di, r=jhpratt
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#154356 (    Add integer truncation and extension methods)
 - rust-lang/rust#154641 (build_helper: fix yarn locking, add check, and bump lockfile)
 - rust-lang/rust#154647 (change `c_double` to `f32` on `avr` targets)
 - rust-lang/rust#154655 (Fix associated type bound suggestion span issue)
2026-04-01 08:58:47 +00:00
Makai
339fb64d1c skip early return for region-only errors in projection types 2026-04-01 16:40:02 +08:00
Makai
e18dd4a992 add TypeFlags::HAS_NON_REGION_ERROR and TypeFlags::HAS_RE_ERROR 2026-04-01 16:40:02 +08:00
Jacob Pratt
7f794c3463 Rollup merge of #154655 - chenyukang:yukang-fix-145586-deserializer-bound-syntax, r=jieyouxu
Fix associated type bound suggestion span issue

Fixes rust-lang/rust#145586
2026-04-01 03:35:11 -04:00
Jacob Pratt
1fb655c590 Rollup merge of #154647 - folkertdev:avr-c_double-f32, r=tgross35
change `c_double` to `f32` on `avr` targets

Extracted from https://github.com/rust-lang/rust/pull/152980. That version also makes this change for `msp430` but that is actually incorrect based on https://www.ti.com/lit/ug/slau132r/slau132r.pdf table 5-1 that specifies `double` as `f64`.

r? tgross35
cc @Patryk27 @workingjubilee
2026-04-01 03:35:11 -04:00
Jacob Pratt
6bbf210432 Rollup merge of #154641 - lolbinarycat:fix-yarn-locking, r=GuillaumeGomez,jieyouxu
build_helper: fix yarn locking, add check, and bump lockfile

fixes rust-lang/rust#154446

cc @aDotInTheVoid, @GuillaumeGomez

not sure if this needs review from t-rustdoc, t-bootstrap, or both.
2026-04-01 03:35:10 -04:00
Jacob Pratt
60e85c7ec3 Rollup merge of #154356 - joshtriplett:libs-api-integer-truncate-extend, r=jhpratt
Add integer truncation and extension methods

Tracking issue: https://github.com/rust-lang/rust/issues/154330

This provides `.truncate()`, `.saturating_truncate()`, `.checked_truncate()`, and `.extend()`.

These only work within the same signedness (use `.cast_signed()` and `.cast_unsigned()` to change sign).

The truncation methods only work to smaller (or equal) types. `.extend()` only works to larger (or equal) types.

For the purposes of truncation and extending, `u128` is considered larger than or equal to the size of `usize`, and `usize` is considered larger than `u16` or `u8`. We might, in the future, want to consider ways to expand this.

Much of this was pair-programmed with @Amanieu.

In order to seal the new traits, this PR also adds a `core::sealed::Sealed`, like the one in `std`. I didn't modify `std` to re-export the same one, since by definition it isn't nameable, and since doing that would require that it be nameable (even if it was `#[unstable]`).
2026-04-01 03:35:10 -04:00
bors
3ebe60c8c3 Auto merge of #154659 - chenyukang:rollup-D1UvH9O, r=chenyukang
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#152935 (c-variadic: error when we can't guarantee that the backend does the right thing)
 - rust-lang/rust#153207 (std::net: clamp linger timeout value to prevent silent truncation.)
 - rust-lang/rust#154592 (Fix `mismatched_lifetime_syntaxes` suggestions for hidden path lifetimes)
 - rust-lang/rust#154643 (fix pin docs)
 - rust-lang/rust#154648 (Clarify `ty::List`)
2026-04-01 05:47:55 +00:00
Yukang
18f8cd2c28 Rollup merge of #154648 - nnethercote:clarify-ty-List, r=cuviper
Clarify `ty::List`

`ty::List` is an unusual type. This commit clarifies some things about it. Details in individual commits.

r? @cuviper
2026-04-01 10:43:56 +08:00
Yukang
9344df3cdb Rollup merge of #154643 - AdinAck:fix-pin-docs, r=chenyukang
fix pin docs

This PR fixes a small grammatical error in the projection section of the pin docs. There is probably more than one answer for the fix, but I felt that this correction was the *smallest*.
2026-04-01 10:43:56 +08:00
Yukang
1f5dcf30d7 Rollup merge of #154592 - reddevilmidzy:lifetime, r=chenyukang
Fix `mismatched_lifetime_syntaxes` suggestions for hidden path lifetimes

close: https://github.com/rust-lang/rust/issues/154493

r? shepmaster

cc: @chenyukang
2026-04-01 10:43:55 +08:00
Yukang
8296e03d86 Rollup merge of #153207 - devnexen:net_set_linger_fix, r=Amanieu
std::net: clamp linger timeout value to prevent silent truncation.

Duration::as_secs() returns u64 but l_linger field type is narrower, c_int on most unix platforms, c_ushort on cygwin and windows. clamping before the cast, consistent with how set_timeout handles this.
2026-04-01 10:43:55 +08:00
Yukang
9445be9bf5 Rollup merge of #152935 - folkertdev:c-variadic-disallow, r=tgross35
c-variadic: error when we can't guarantee that the backend does the right thing

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

as discussed in [#t-lang > stabilizing `c_variadic`](https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/stabilizing.20.60c_variadic.60/with/574691397), display an error when we can't guarantee that the codegen backend (only LLVM is supported at the moment) does the right thing.
2026-04-01 10:43:55 +08:00
bors
12ab1cf1fd Auto merge of #154456 - chenyukang:yukang-fix-154434-unused-assignments, r=estebank
Label overwritten for never read assignments



Fixes rust-lang/rust#154434
Closes rust-lang/rust#144079
2026-04-01 02:38:14 +00:00
yukang
50c6679c0b fix unit test naming style 2026-04-01 10:12:05 +08:00
yukang
95d5ecf3ab Fix associated bound suggestion span issue 2026-04-01 09:21:45 +08:00
bors
700cfa8c93 Auto merge of #154649 - JonathanBrouwer:rollup-3KmleSY, r=JonathanBrouwer
Rollup of 2 pull requests

Successful merges:

 - rust-lang/rust#154249 (Mention on which items the `missing_doc_code_examples` is not emitted)
 - rust-lang/rust#154266 (UdpSocket: document `recv/recv_from` differences)
2026-03-31 23:24:59 +00:00
Zalathar
eb5a4000ff Don't use disk-cache for query def_kind
From what I can tell, the `def_kind` query has no local provider, and is always
given its value via query feeding, usually from `TyCtxt::create_def`.

If that's the case, there should never be any opportunity for a previous value
to be loaded from disk-cache, so serializing the current-session values is a
waste of time.
2026-04-01 09:49:49 +11:00
Folkert de Vries
1d0dcfab18 c-variadic: error when we can't guarantee that the backend does the right thing
specifically this emits an error when

- a custom target is used
- `RiscV32 if self.llvm_abiname == "ilp32e"` this abi is used for 32-bit
  embedded targets, and clang/llvm document that the ABI may change in
  the future.
2026-03-31 23:35:25 +02:00
Folkert de Vries
dc9836e29c change c_double to f32 on avr targets 2026-03-31 22:39:18 +02:00
Jonathan Brouwer
807b9aec35 Rollup merge of #154266 - nia-e:udp-socket-docs, r=Mark-Simulacrum
UdpSocket: document `recv/recv_from` differences

Per libs-api consensus, fixes rust-lang/rust#149392 by documenting possible platform-specific behavior in `UdpSocket`.

r? libs
2026-03-31 22:18:34 +02:00
Jonathan Brouwer
5ac294bf66 Rollup merge of #154249 - GuillaumeGomez:missing_doc_code_examples-doc, r=lolbinarycat
Mention on which items the `missing_doc_code_examples` is not emitted

As mentioned in rust-lang/rust#154048, the lint's documentation didn't mention which items were ignored. This PR fixes that.

r? @lolbinarycat
2026-03-31 22:18:34 +02:00
bors
48cc71ee88 Auto merge of #154638 - JonathanBrouwer:rollup-oLBZ6Tr, r=JonathanBrouwer
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#150752 (Update libc to v0.2.183)
 - rust-lang/rust#152432 (add rustc option -Zpacked-stack)
 - rust-lang/rust#154634 (Use `Hcx`/`hcx` consistently for `StableHashingContext`.)
 - rust-lang/rust#154635 (./x run miri: default to edition 2021)
2026-03-31 20:16:05 +00:00
Nicholas Nethercote
64cf1ec685 Update Erasable impls for lists.
- Merge the `List` and `ListWithCachedTypeInfo` impls by referring to
  the shared underlying type, `RawList`. This required increasing the
  visibility of `RawList`.

- Explain why a separate impl is needed for `RawList`.

- Remove an incorrect FIXME comment. Fat reference types will always
  need a separate impl. (To be sure, one could use `T: ?Sized` to merge
  the impls for `&T` and `&[T]` and it would compile but it would behave
  incorrectly because `&T` needs one word of storage and `&[T]` needs
  two words of storage. I tried it and it did not go well.)
2026-04-01 07:04:08 +11:00
Nicholas Nethercote
0f159dc1ac Clarify use of extern type in RawList.
- Add some explanatory comments.
- Rename `OpaqueListContents` as `ExternTy`. I've always found both the
  "opaque" and "contents" parts of this name to be confusing. Calling it
  `ExternTy` makes it clear that all that matters is it's an extern
  type.
2026-04-01 06:58:37 +11:00
Nicholas Nethercote
f334357e8c Add some size assertions for List/RawList.
Checking that they really do use thin pointers.
2026-04-01 06:57:08 +11:00
Nicholas Nethercote
cb74dde256 Rename CacheEncoder::source_map as caching_source_map_view.
To make clear it's not a `SourceMap`.
2026-04-01 06:34:55 +11:00
Nicholas Nethercote
919c632c0e Streamline CachingSourceMapView.
`CachingSourceMapView` caches information about three recent code
positions, to avoid expensive `SourceMap` lookups. The code to do this
is pretty low-level and grotty.

This commit changes it to cache information about a single code
position.
- This is much simpler, with no need to maintain entry time stamps or
  file indices. It's 120 fewer lines of code overall.
- It's also faster. The cache hit rate is only marginally lower, and
  scanning a single entry is faster than scanning three entries in the
  cache miss case (which is still moderately common).

The commit also renames the `lines` field as `line_bounds`, which makes
it clearer that it's a range.
2026-04-01 06:34:55 +11:00
Nicholas Nethercote
c30f5cb084 Refactor byte_pos_to_line_and_col.
By factoring out some repeated code.
2026-04-01 06:34:54 +11:00
Nicholas Nethercote
0eea36fea4 Use Option to indicate failure in CachingSourceMapView.
Currently the `cache_entry_index` uses -1 to indicate failure. But this
is Rust, not C! So this commit uses `Option`, making it impossible to
forget to check for failure, and avoiding many `as usize` casts.
2026-04-01 06:34:31 +11:00
Josh Triplett
68c8339066 Make truncate and extend use const traits to work in const contexts 2026-03-31 09:56:33 -07:00
Josh Triplett
ea421bf991 Add integer truncation and extension methods
This provides `.truncate()`, `.saturating_truncate()`,
`.checked_truncate()`, and `.extend()`.

These only work within the same signedness (use `.cast_signed()` and
`.cast_unsigned()` to change sign).

The truncation methods only work to smaller (or equal) types.
`.extend()` only works to larger (or equal) types.

For the purposes of truncation and extending, `usize` is considered
larger than `u16` or `u8`. This is consistent with `From`/`Into`
conversions.

Adding these methods results in needing to update the output of one test
that gets a new method-name similarity result.

Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
2026-03-31 09:56:04 -07:00
bors
0e95a0f4c6 Auto merge of #154637 - JonathanBrouwer:rollup-fGsU36o, r=JonathanBrouwer
Rollup of 12 pull requests

Successful merges:

 - rust-lang/rust#154419 (Take first task group for further execution)
 - rust-lang/rust#154569 (Fix  type alias where clause suggestion spacing issue)
 - rust-lang/rust#154617 (Update flate2 users to use zlib-rs)
 - rust-lang/rust#154618 (Fix AtomicPtr::update's cfg gate)
 - rust-lang/rust#154620 (stabilize new Range type and iterator)
 - rust-lang/rust#151932 (refactor: remove `Adjust::ReborrowPin`)
 - rust-lang/rust#153980 (refactor: move doc(rust_logo) check to parser)
 - rust-lang/rust#154134 (fix: guard paren-sugar pretty-printing on short trait args)
 - rust-lang/rust#154270 (Create `Ty` type alias in `rustc_type_ir`)
 - rust-lang/rust#154580 (Split AttributeParserError Diagnostic implementation into subfunctions)
 - rust-lang/rust#154606 (misc test cleanups)
 - rust-lang/rust#154612 (Add a test for a now fixed ICE with `offset_of!()`)
2026-03-31 16:44:16 +00:00
Adin Ackerman
9626ca2e3a fix pin docs 2026-03-31 09:38:59 -07:00
Guillaume Gomez
f8a8b8f739 Mention on which items the missing_doc_code_examples is not emitted 2026-03-31 17:52:38 +02:00
binarycat
f0c7cd28b8 build_helper: fix yarn locking, add check, and bump lockfile 2026-03-31 09:37:01 -05:00
yukang
ebf22f83f1 fix unit test 2026-03-31 22:19:49 +08:00
Jonathan Brouwer
c13822a584 Rollup merge of #154635 - RalfJung:miri-run-edition, r=Mark-Simulacrum
./x run miri: default to edition 2021

Fixes https://github.com/rust-lang/rust/issues/154630
2026-03-31 15:27:20 +02:00
Jonathan Brouwer
3cef5b54bc Rollup merge of #154634 - nnethercote:hcx, r=petrochenkov
Use `Hcx`/`hcx` consistently for `StableHashingContext`.

The `HashStable` and `ToStableHashKey` traits both have a type parameter that is sometimes called `CTX` and sometimes called `HCX`. (In practice this type parameter is always instantiated as `StableHashingContext`.) Similarly, variables with these types are sometimes called `ctx` and sometimes called `hcx`. This inconsistency has bugged me for some time.

The `HCX`/`hcx` form is more informative (the `H`/`h` indicates what type of context it is) and it matches other cases like `tcx`, `dcx`, `icx`.

Also, RFC 430 says that type parameters should have names that are "concise UpperCamelCase, usually single uppercase letter: T". In this case `H` feels insufficient, and `Hcx` feels better.

Therefore, this commit changes the code to use `Hcx`/`hcx` everywhere.

r? @petrochenkov
2026-03-31 15:27:19 +02:00
Jonathan Brouwer
f883d62ea5 Rollup merge of #152432 - fneddy:s390x_packed_stack_attribute, r=nikic
add rustc option -Zpacked-stack

this enables `-Zpacked-stack` just as `-mpacked-stack` in clang and gcc. packed-stack is needed on s390x for kernel development.

For reference: rust-lang/rust#151154 and rust-lang/rust#150766

look at @uweigand s post for full explanation of what this does. Here a wrap-up:

https://github.com/rust-lang/rust/pull/150766#issuecomment-3729074303
> [...]
> packed-stack [...] modifies how the compiler-generated function prolog/epilog code makes use of the 160 byte register save area provided by a caller to the callee [...]  this variant is not actually incompatible with the ABI - packed-stack and regular functions can freely call each other without ABI issues.
> [...]
> combination of -mpacked-stack and -mbackchain [...]  the location in the stack frame where the backchain link ought to be stored is not available. [...] is not supported at all with the default ABI
> [...]
> However, in the special case of also using soft-float, our (implied) soft-float ABI provides a different location for the backchain that is compatible with -mpacked-stack, so that combination should be supported
> [...]
2026-03-31 15:27:18 +02:00
Jonathan Brouwer
470facce55 Rollup merge of #150752 - thesummer:update-libc-0.2.179, r=tgross35
Update libc to v0.2.183

Follow-up of https://github.com/rust-lang/rust/pull/150484.
This PR updates libc to include the latest patches to make rtems target (and probably others) compile again.
2026-03-31 15:27:18 +02:00
bors
ba11b1e3f0 Auto merge of #154576 - Zalathar:cache-on-disk, r=nnethercote
Simplify the `cache_on_disk_if` modifier to just `cache_on_disk`



Thanks to https://github.com/rust-lang/rust/pull/154304, there is now only one remaining query with a non-trivial cache-on-disk condition (`check_liveness`). But prior experiments at https://github.com/rust-lang/rust/pull/153441#issuecomment-4009037104 indicate that `check_liveness` can also be made non-disk-caching with little or no measurable effect.

This PR takes advantage of those facts to replace the `cache_on_disk_if` modifier with a simpler `cache_on_disk` modifier:
- When combined with `separate_provide_extern`, only values for “local” keys are cached to disk.
- For any other query with `cache_on_disk`, values are cached to disk unconditionally.

r? nnethercote (or compiler)
2026-03-31 13:13:38 +00:00