Commit Graph

324218 Commits

Author SHA1 Message Date
Nicholas Nethercote f0ebd66eaa Remove unused tcx params.
They are unused because of the previous commit.
2026-04-22 13:54:57 +10:00
Nicholas Nethercote be52e75d69 Simplify one MetaBlob impl.
It's currently an impl for `(CrateMetadataRef, TyCtxt)`, but (a) the
`TyCtxt` is not used, and (b) the `CrateMetadataRef` can be simplified
to a `CrateMetadata` because `CStore` access isn't required. This
require changing `blob` to take `&self`, which is no big deal, and it
simplifies many `get` calls.
2026-04-22 13:25:15 +10:00
Nicholas Nethercote 2f864a9d03 Split Metadata trait into MetaBlob and MetaDecoder.
`Metadata` has two methods, `blob` and `decoder`, which are not used
together. Splitting the trait in two will allow some cleanups in
subsequent commits.
2026-04-22 13:13:25 +10:00
bors c28e303778 Auto merge of #155552 - JonathanBrouwer:rollup-JKIpTuW, r=JonathanBrouwer
Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#154654 (Move `std::io::ErrorKind` to `core::io`)
 - rust-lang/rust#145270 (Fix an ICE observed with an explicit tail-call in a default trait method)
 - rust-lang/rust#154895 (borrowck: Apply `user_arg_index` nomenclature more broadly)
 - rust-lang/rust#155213 (resolve: Make sure visibilities of import declarations make sense)
 - rust-lang/rust#155346 (`single_use_lifetimes`: respect `anonymous_lifetime_in_impl_trait`)
 - rust-lang/rust#155517 (Add a test for Mach-O `#[link_section]` API inherited from LLVM)
 - rust-lang/rust#155549 (Remove some unnecessary lifetimes.)
 - rust-lang/rust#154248 (resolve :  mark repr_simd as internal)
 - rust-lang/rust#154772 (slightly optimize the `non-camel-case-types` lint)
 - rust-lang/rust#155541 (Add `#[rust_analyzer::prefer_underscore_import]` to the traits in `rustc_type_ir::inherent`)
 - rust-lang/rust#155544 (bootstrap: Make "detected modifications" for download-rustc less verbose)
2026-04-20 16:15:13 +00:00
bors 91367b0f73 Auto merge of #154924 - nnethercote:rm-impl-HashStable-for-Attr-slice, r=JonathanBrouwer
Remove `HashStable` impl for `[hir::Attribute]`.



This impl skips:
- All doc comments
- A handful of other attributes, mostly `rustc_*` ones related to incremental compilation testing.
    
This skipping originated in rust-lang/rust#36025 and was extended a couple of times, e.g. in rust-lang/rust#36370. Those PRs don't have any explanation of why the skipping exists. Perhaps the reasoning was that doc comments should only affect rustdoc and rustdoc doesn't use incremental compilation? But doc comments end up in metadata, and there is a query `attrs_for_def` that returns a `&'tcx [hir::Attribute]`. So skipping some attributes just seems plainly wrong.
    
This commit removes the impl, which means `[hir::Attribute]` hashing falls back to the default impl for `[T]`. This has no noticeable effect on the test suite. It does slightly hurt performance, because of the doc comments. This perf regression seems worth it for the correctness benefits.
2026-04-20 12:55:41 +00:00
Jonathan Brouwer 02dda7315a Rollup merge of #155544 - jyn514:download-rustc-verbosity, r=jieyouxu
bootstrap: Make "detected modifications" for download-rustc less verbose

cc https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/bootstrap.20lists.20all.20files.20I.20change/with/585991706, @RalfJung

r? @jieyouxu
2026-04-20 13:52:09 +02:00
Jonathan Brouwer 26f457a114 Rollup merge of #155541 - ChayimFriedman2:import-underscore, r=TaKO8Ki
Add `#[rust_analyzer::prefer_underscore_import]` to the traits in `rustc_type_ir::inherent`

This is a new attribute (https://github.com/rust-lang/rust-analyzer/pull/21740) that instructs rust-analyzer to prefer importing the trait `as _`. It is useful for these traits since their names often clashes with the type.
2026-04-20 13:52:09 +02:00
Jonathan Brouwer c4f995c1ba Rollup merge of #154772 - llogiq:nonstandard-style-perf, r=adwinwhite
slightly optimize the `non-camel-case-types` lint

This is just removing a needless `collect()` and a bit of simplification.
2026-04-20 13:52:08 +02:00
Jonathan Brouwer 7162558809 Rollup merge of #154248 - lms0806:issue_154034, r=TaKO8Ki
resolve :  mark repr_simd as internal

I changed ```repr_simd``` to ```internal``` and changed the position to ```feature-group-start: internal feature gates```.

close rust-lang/rust#154034
2026-04-20 13:52:07 +02:00
Jonathan Brouwer eceed7c1c2 Rollup merge of #155549 - nnethercote:rm-lifetimes, r=JohnTitor
Remove some unnecessary lifetimes.

We have a number of structs with more lifetimes than necessary. This commit removes them.

LLM disclosure: I asked Claude Code to check for unnecessary lifetimes in all types with three or more lifetimes, and it produced a list of candidates (half of which were invalid). I did the modifications for the valid cases myself, and found a couple more cases along the way.

r? @JohnTitor
2026-04-20 13:52:07 +02:00
Jonathan Brouwer 356fdf02ca Rollup merge of #155517 - madsmtm:test-macho-link-section-attrs, r=bjorn3
Add a test for Mach-O `#[link_section]` API inherited from LLVM

The format of the `#[link_section]` attribute is under-documented, but on Mach-O, I think it's roughly the following BNF:
```
LinkSection -> Segment `,` Section (`,` (SectionType (`,` (SectionAttributes)?)?)?)?
Segment -> <0 to 16 bytes>
Section -> <0 to 16 bytes>
SectionType -> `regular` | `zerofill` | `cstring_literals` | `4byte_literals` | `8byte_literals` | `literal_pointers` | `non_lazy_symbol_pointers` | `lazy_symbol_pointers` | `symbol_stubs` | `mod_init_funcs` | `mod_term_funcs` | `coalesced` | `interposing` | `16byte_literals` | `thread_local_regular` | `thread_local_zerofill` | `thread_local_variables` | `thread_local_variable_pointers` | `thread_local_init_function_pointers`
SectionAttributes -> SectionAttribute (`+` SectionAttribute)*
SectionAttribute -> `pure_instructions` | `no_toc` | `strip_static_syms` | `no_dead_strip` | `live_support`, `self_modifying_code` | `debug`
```

This PR adds a small test for a little part of this.

Once https://github.com/rust-lang/rust/issues/154429 is resolved, this should make it possible to test https://github.com/rust-lang/rustc_codegen_cranelift/pull/1648 end-to-end.

r? bjorn3
2026-04-20 13:52:06 +02:00
Jonathan Brouwer 1d9b32a5ac Rollup merge of #155346 - GrigorenkoPV:single-use-lifetimes, r=jdonszelmann
`single_use_lifetimes`: respect `anonymous_lifetime_in_impl_trait`

Tracking issue: rust-lang/rust#44752 (for the `single_use_lifetimes` lint; the `anonymous_lifetime_in_impl_trait` feature seems to have no tracking issue).

Closes rust-lang/rust#129255
Closes rust-lang/rust#135550

@rustbot label A-diagnostics A-lifetimes A-lints D-incorrect L-single_use_lifetimes
2026-04-20 13:52:05 +02:00
Jonathan Brouwer d83994951d Rollup merge of #155213 - petrochenkov:importvis, r=mu001999
resolve: Make sure visibilities of import declarations make sense

That they are all ordered inside the module and not more private than the module itself.

The `import_decl_vis` logic is also reused when reporting `ambiguous_import_visibilities` lint.
Some asserts are hardened.
Some relevant tests are added.

Extracted from https://github.com/rust-lang/rust/pull/154149.
2026-04-20 13:52:05 +02:00
Jonathan Brouwer 6245e371b9 Rollup merge of #154895 - Enselic:user-arg-index, r=jdonszelmann
borrowck: Apply `user_arg_index` nomenclature more broadly

No change in behavior. Only renames and a couple of added comments.

As requested here: https://github.com/rust-lang/rust/pull/154674#discussion_r3027381648

r? jdonszelmann
2026-04-20 13:52:04 +02:00
Jonathan Brouwer 3530d82c31 Rollup merge of #145270 - jakubadamw:issue-144985, r=WaffleLapkin
Fix an ICE observed with an explicit tail-call in a default trait method

Right now, explicit tail-calls cannot be used in functions that hold the `#[track_caller]` attribute. This check is performed on a resolved concrete instance of a function, which would be absent for a tail-call performed from the body of a default trait method. This PR fixes the issue by checking for the relevant attribute in default trait methods separately, without expecting a specific resolved instance.

Closes https://github.com/rust-lang/rust/issues/144985.
2026-04-20 13:52:03 +02:00
Jonathan Brouwer 3ca43dc55e Rollup merge of #154654 - bushrat011899:core_io_error_kind, r=Mark-Simulacrum
Move `std::io::ErrorKind` to `core::io`

ACP: https://github.com/rust-lang/libs-team/issues/755
Tracking issue: https://github.com/rust-lang/rust/issues/154046
Related: https://github.com/rust-lang/rust/pull/152918

## Description

I consider rust-lang/rust#154046 to be really important for `no_std`, but I'm concerned rust-lang/rust#152918 might be too controversial. As an alternative, I'd like to propose starting small with `ErrorKind`, since it can be moved somewhat trivially. It has no dependencies on functionality in `std`, no platform specific behaviour, and could provide an excellent bridging point for `no_std` IO libraries.

Since `std::io::Error` implements `From<ErrorKind>`, libraries could write functions which return `Result<T, core::io::ErrorKind>`, and therefore be usable in `std`-using libraries with the `?` operator. For that reason, I'd consider this to be a worthwhile change even if the rest of `std::io` couldn't be moved to `core`/`alloc`, and entirely compatible with any efforts to make such a change in the future.

## Notes

* This is my first PR against Rust, please let me know if there's anything I should be doing that I have not done. I tried reading through the library contributors guide but I'm sure I've missed _something_.
* No AI tooling of any kind was used in the creation of this PR.
* I believe it's appropriate that this be a part of the linked tracking issue, but please let me know if that's not the case!
2026-04-20 13:52:03 +02:00
Vadim Petrochenkov 394c7172f4 resolve: Make sure visibilities of import declarations make sense
That they are all ordered inside the module and not more private than the module itself
The `import_decl_vis` logic is reused when reporting `ambiguous_import_visibilities` lint
Some asserts are hardened
Some relevant tests are added
2026-04-20 13:41:33 +03:00
Vadim Petrochenkov 38c14f301d resolve: Do not create unnecessary ParentScope when building external modules 2026-04-20 13:37:43 +03:00
Jacob Adam ac5734a779 Fix an ICE when using become in a default trait method
The logic determining whether the relevant function is marked as `#[track_caller]`
only worked with functions that could be resolved to a concrete instance, which default
trait methods cannot. We need to check the codegen attribute on the default method itself.

Co-authored-by: Folkert de Vries <folkert@folkertdev.nl>
2026-04-20 11:42:09 +02:00
bors d12e1e12ae Auto merge of #155542 - JonathanBrouwer:rollup-F7GZlGr, r=JonathanBrouwer
Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#155054 (constify `Index(Mut)`, `Deref(Mut)` for `Vec`)
 - rust-lang/rust#155264 (Add autocast support for `x86amx`)
 - rust-lang/rust#155507 (suggest expect instead of unwrap when arg provided)
 - rust-lang/rust#154664 (core/num: Implement feature `integer_cast_extras`)
 - rust-lang/rust#155238 (compiletest: add a new diff for compare-out-by-lines tests.)
 - rust-lang/rust#155474 (Rename incremental `cfail`/`cpass` revisions to `bfail`/`bpass`)
 - rust-lang/rust#155493 (docs(num): fix stale link to `mem::Alignment`)
 - rust-lang/rust#155529 (Remove `AttributeLintKind` variants - part 3)
 - rust-lang/rust#155531 (Tweak `is_ascii_punctuation()` docs wording)
 - rust-lang/rust#155533 (Provide a const new for `GlobalCache`)
2026-04-20 09:29:42 +00:00
Nicholas Nethercote 5e00b8e7d5 Remove some unnecessary lifetimes.
We have a number of structs with more lifetimes than necessary. This
commit removes them.

LLM disclosure: I asked Claude Code to check for unnecessary lifetimes
in all types with three or more lifetimes, and it produced a list of
candidates (half of which were invalid). I did the modifications for the
valid cases myself, and found a couple more cases along the way.
2026-04-20 19:25:51 +10:00
Zac Harrold fe2b39f064 Move std::io::ErrorKind to core::io
Move `std::io::ErrorKind` to `core::io`
* Update `rustdoc-html` tests for the new path
* Add `core_io` feature to control stability. This replaces the use of `core_io_borrowed_buf` on the `core::io` module itself.
* Re-export `core::io::ErrorKind` in `std::io::error`
2026-04-20 18:38:25 +10:00
Jynn Nelson 38debc3949 bootstrap: Make "detected modifications" for download-rustc less verbose 2026-04-20 10:00:13 +02:00
Jonathan Brouwer d00c0476e7 Rollup merge of #155533 - ChayimFriedman2:const-cache-new, r=ShoyuVanilla
Provide a const new for `GlobalCache`

This can help rust-analyzer a bit.
2026-04-20 08:14:15 +02:00
Jonathan Brouwer 2e5a9fc307 Rollup merge of #155531 - Jules-Bertholet:is_ascii_punctuation_docs, r=scottmcm
Tweak `is_ascii_punctuation()` docs wording

These methods return `true` for characters with Unicode general category of punctuation (P), but also for those with general category of symbol (S).

@rustbot label A-docs
2026-04-20 08:14:14 +02:00
Jonathan Brouwer 055543f263 Rollup merge of #155529 - GuillaumeGomez:rm-attributelintkind, r=JonathanBrouwer
Remove `AttributeLintKind` variants - part 3

Part of https://github.com/rust-lang/rust/issues/153099.

r? @JonathanBrouwer
2026-04-20 08:14:14 +02:00
Jonathan Brouwer ede69dad7d Rollup merge of #155493 - sorairolake:fix-alignment-doc-link, r=scottmcm
docs(num): fix stale link to `mem::Alignment`

This pull request updates a stale link to `mem::Alignment` in `num::IntErrorKind`.

In rust-lang/rust#153178, I added a link to `Alignment` in `IntErrorKind`, but I overlooked that `Alignment` had been moved from `core::ptr` to `core::mem`. Although it is still re-exported in `core::ptr`, this pull request points the link to its canonical location.

@rustbot label +A-docs
2026-04-20 08:14:13 +02:00
Jonathan Brouwer fda59bfb6f Rollup merge of #155474 - Zalathar:bpass, r=jieyouxu
Rename incremental `cfail`/`cpass` revisions to `bfail`/`bpass`

Long ago, UI tests were divided into *compile* and *run* tests. Later, the compile tests were further subdivided into *check* and *build* tests, to speed up tests that don't need a full build.

The same split was never applied to incremental test revisions, so the only way to perform a check build in incremental tests is (confusingly) to use a `cfail` revision and then specify `//@ check-fail` or `//@ check-pass`.

This PR makes room for dedicated check-fail and check-pass revisions by renaming the existing `cfail` and `cpass` revisions to `bfail` and `bpass`, since they currently perform a full build.

---

The test updates were done with a regex whole-word find-and-replace for `c(fail|pass)(\d*)`, and I also took the opportunity to manually add a space after `revisions:` on affected lines.

r? jieyouxu
2026-04-20 08:14:12 +02:00
Jonathan Brouwer 1204fb1445 Rollup merge of #155238 - Ozzy1423:diff-by-lines, r=jieyouxu
compiletest: add a new diff for compare-out-by-lines tests.

Previously, when comparing output by lines, only the actual diff was shown. This is unhelpful since we expect lines to be shuffled around.

With this new print, we can see the exact lines that are missing or have appeared without the noise of the moved around lines.

Example, in this case a note has moved slightly so there is one more separator line "|":

```
+	   |
+	   = help: maybe it is overwritten before being read?

Compare output by lines enabled, diff by lines:
Expected contains these lines that are not in actual:
(no lines found)
Actual contains these lines that are not in expected:
   |

The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args liveness/liveness-consts.rs`
```

r? @jieyouxu
cc @zetanumbers @ywxt
2026-04-20 08:14:12 +02:00
Jonathan Brouwer 26f47ae831 Rollup merge of #154664 - okaneco:integer_cast_extras, r=scottmcm
core/num: Implement feature `integer_cast_extras`

Tracking issue https://github.com/rust-lang/rust/issues/154650
Accepted ACP https://github.com/rust-lang/libs-team/issues/765#issuecomment-4164285847

Implement `saturating`, `checked`, and `strict` casting between signed and unsigned integer primitives of the same bit-width.

Add `cast_integer` panic function to `overflow_panic.rs`
2026-04-20 08:14:11 +02:00
Jonathan Brouwer 8beed17a3d Rollup merge of #155507 - Kivooeo:no-expect, r=mejrs
suggest expect instead of unwrap when arg provided

r? mejrs (feel free to reroll)

fixes https://github.com/rust-lang/rust/issues/155502
2026-04-20 08:14:10 +02:00
Jonathan Brouwer cccf996225 Rollup merge of #155264 - sayantn:amx-autocast, r=dianqk
Add autocast support for `x86amx`

Builds on rust-lang/rust#140763 by further adding autocasts for `x86amx` from/to vectors of size 8192 bits.

This also disables SIMD vector abi checks for the `"unadjusted"` abi because
 - This is primarily used to link with LLVM intrinsics, which don't actually lower to function calls with vector arguments. Even with other cg backends, this is true.
 - This ABI is internal and perma-unstable (and also super specific), so it is very unlikely that this will cause breakages.
 - (The primary reason) Without doing this we can't actually use 8192 bit long vectors to represent `x86amx`

> Why do we need a bypass for `x86amx`? Can't we use a `#[lang_item]` or something?

If `x86amx` was a normal LLVM type, this approach would've worked and I would also prefer it. But LLVM specifies that

> No instruction is allowed for this type. There are no arguments, arrays, pointers, vectors or constants of this type.

So we can't treat it like a normal type at all -- even if we add it like a lang-item, we would still have to special-case everywhere to check if we are passing to the correct LLVM intrinsic, and only then use the `x86amx` type. IMO this is needlessly complex, and way worse than this solution, which just adds it to the autocast list in cg_llvm

r? codegen
2026-04-20 08:14:10 +02:00
Jonathan Brouwer ce91732a75 Rollup merge of #155054 - Lars-Schumann:const-vec-ops, r=dtolnay
constify `Index(Mut)`, `Deref(Mut)` for `Vec`

Relevant tracking issues
const_convert: https://github.com/rust-lang/rust/issues/143773
const_index: https://github.com/rust-lang/rust/issues/143775
2026-04-20 08:14:09 +02:00
Chayim Refael Friedman 592c8154de Add #[rust_analyzer::prefer_underscore_import] to the traits in rustc_type_ir::inherent
This is a new attribute that instructs rust-analyzer to prefer importing the trait `as _`. It is useful for these traits
since their names often clashes with the type.
2026-04-20 09:04:01 +03:00
Oscar Bray 459be3e7b1 compiletest: add a new diff for compare-out-by-lines tests.
Previously, when comparing output by lines, only the actual
diff was shown. This is unhelpful since we expect lines to be
shuffled around.

With this new print, we can see the exact lines that are missing
or have appeared without the noise of the moved around lines.
2026-04-20 06:31:21 +01:00
Jules Bertholet fd65209a77 Tweak is_ascii_punctuation()/graphic() docs wording
The `_punctuation` methods return `true` for characters with
Unicode general category of punctuation (P),
but also for those with general category
of symbol (S).
2026-04-19 22:27:16 -04:00
Chayim Refael Friedman 5749fe87e9 Provide a const new for GlobalCache
This can help rust-analyzer a bit.
2026-04-20 04:52:59 +03:00
Guillaume Gomez 6d23cf97da Remove AttributeLintKind::DocUnknownInclude variant 2026-04-20 02:23:56 +02:00
Guillaume Gomez 4b2e2ace23 Remove unused AttributeLintKind::DocInvalid variant 2026-04-20 02:09:33 +02:00
Guillaume Gomez dacc42fb1b Remove AttributeLintKind::DocAutoCfgHideShowExpectsList variant 2026-04-20 02:08:18 +02:00
Guillaume Gomez d7d9cf9153 Remove AttributeLintKind::DocAutoCfgHideShowUnexpectedItem variant 2026-04-20 01:59:03 +02:00
Guillaume Gomez ace320fba3 Remove AttributeLintKind::AmbiguousDeriveHelpers variant 2026-04-20 00:50:55 +02:00
Zac Harrold 6960e7c958 Adjust usage of std::io::ErrorKind to be core compatible
* Checking exhaustion will no longer be possible for `repr_bitpacked`. Moving `kind_from_prim` into an associated function, and setting it up to be moved into `core::io` as well.
* `ErrorKind::as_str` is private, but it's only usage is trivially replaced with `Display::fmt`
* The features io_error_inprogress, io_error_more, and io_error_uncategorized will all need to be enabled
2026-04-20 08:29:15 +10:00
Zac Harrold 08bd077df4 Make documentation for std::io::ErrorKind core::io compatible
Certain links will not be valid when moved into `core::io`
2026-04-20 08:29:15 +10:00
Mads Marquart 3695fefd93 Add a test for Mach-O link_section API inherited from LLVM 2026-04-19 23:49:02 +02:00
bors e22c616e4e Auto merge of #155083 - adwinwhite:introduce-unnormalized, r=lcnr
Introduce `Unnormalized` wrapper




This is the first step of the [eager normalization](https://rust-lang.zulipchat.com/#narrow/channel/364551-t-types.2Ftrait-system-refactor/topic/Eager.20normalization.2C.20ahoy.21/with/582996293) series.

This PR introduce an `Unnormalized` wrapper and make most normalization routines consume it. The purpose is to make normalization explicit. 
This PR contains no behavior change.

API changes are in the first two commit. 
There're some normalization routines left untouched:
- `normalize` in the type checker of borrowck: better do it together with `field.ty()` returning `Unnormalized`.
- `normalize_with_depth`: only used inside the old solver. Can be done later.
- `query_normalize`: rarely used.
- misc local normalization helpers.

The compiler errors are mostly fixed via `ast-grep`, with exceptions handled manually.
2026-04-19 19:18:17 +00:00
Adwin White 6279106e72 fix all errors 2026-04-20 00:18:28 +08:00
Adwin White 3e1e35b5d1 make common normalization routines take Unnormalized 2026-04-20 00:08:14 +08:00
Adwin White 5c12b9283e introduce Unnormalized wrapper and make instantiation use it 2026-04-20 00:08:14 +08:00
bors 38799a320d Auto merge of #155519 - JonathanBrouwer:rollup-P17uwTS, r=JonathanBrouwer
Rollup of 12 pull requests

Successful merges:

 - rust-lang/rust#155370 (Add regression test for dead code elimination with drop + panic)
 - rust-lang/rust#154823 (Replace the spdx-rs dependency with a minimal in-tree SPDX tag-value parser)
 - rust-lang/rust#155294 (Add test for coalescing of diagnostic attribute duplicates)
 - rust-lang/rust#155352 (triagebot.toml: Sync `assign.owners` with `autolabel."T-compiler"`)
 - rust-lang/rust#155431 (Add temporary scope to assert_matches)
 - rust-lang/rust#153873 (deprecate `std::char` constants and functions)
 - rust-lang/rust#154865 (libtest: use binary search for --exact test filtering)
 - rust-lang/rust#154979 (add #[must_use] macros for floats)
 - rust-lang/rust#155486 (c-variadic: add roundtrip test)
 - rust-lang/rust#155504 (Remove `AttributeLintKind` variants - part 2)
 - rust-lang/rust#155510 (Update Tidy python executable path)
 - rust-lang/rust#155514 (codegen-options docs: remove -Csoft-float)
2026-04-19 16:04:18 +00:00