Commit Graph

16556 Commits

Author SHA1 Message Date
Jonathan Brouwer cecc5e7cea Rollup merge of #153346 - WaffleLapkin:sometimes-test, r=jieyouxu
move never type tests to subdirectories and add some comments

This hopefully makes things a little bit clearer
2026-03-07 01:42:36 +01:00
Jonathan Brouwer 783c9d3de0 Rollup merge of #149937 - jyn514:linker-info, r=mati865
spliit out `linker-info` from `linker-messages`

*[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/pull/149937)*

Helps with https://github.com/rust-lang/rust/issues/136096.
2026-03-07 01:42:35 +01:00
Jonathan Brouwer 69dc318464 Rollup merge of #153452 - GuillaumeGomez:migrate-diag, r=JonathanBrouwer
Cleanup unused diagnostic emission methods

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

To remove `lint_level`, we need to remove all functions calling it. One of them is `TyCtxt::node_span_lint`, so removing it.

r? @JonathanBrouwer
2026-03-06 18:49:51 +01:00
Jonathan Brouwer 56c8de6364 Rollup merge of #153189 - JayanAXHF:refactor/check_attrs_reftor_1, r=JonathanBrouwer
refactor: move `check_align` to `parse_alignment`

Part of rust-lang/rust#153101

r? @JonathanBrouwer

PS: jonathan i'm not sure about what to do with `check_align` now
2026-03-06 18:49:49 +01:00
Jonathan Brouwer 6be5b25aa9 Rollup merge of #152741 - arferreira:fix-invalid-suggestions-destructuring-drop, r=estebank,Kivooeo
Suppress invalid suggestions in destructuring assignment

Fixes rust-lang/rust#152694

When destructuring assignment hits a type with `Drop`, the compiler was emitting two broken suggestions: `ref *&mut String::new()` (invalid syntax) and `.clone()` on a temporary (useless).

Root cause: the suggestion logic didn't know these bindings were synthetic from assign desugaring. The fix reuses the existing `AssignDesugar` detection in `BindingFinder` to collect those spans and skip both suggestions.
2026-03-06 18:49:49 +01:00
Jonathan Brouwer 946e0f4924 Rollup merge of #152040 - JohnTitor:issue-151631, r=BoxyUwU
Do not emit ConstEvaluatable goals if type-const

Fixes rust-lang/rust#151631, fixes rust-lang/rust#151477
r? @fmease

I'd recommend reviewing commit-by-commit, the diff is less-readable to address a cyclic issue.
2026-03-06 18:49:48 +01:00
Jonathan Brouwer ac9bd09ec6 Rollup merge of #153495 - TaKO8Ki:fix-153236-offset-of-recovery, r=petrochenkov
Fix ICE in `offset_of!` error recovery

Fixes rust-lang/rust#153236.

`offset_of!` was changed in rust-lang/rust#148151 to lower through THIR as a sum of calls to the `offset_of` intrinsic. In the error-recovery case, when no valid field indices are recorded, that lowering synthesized `0` as a `u32` even though the overall `offset_of!` expression has type `usize`.

On 64-bit targets, const-eval then tried to write a 4-byte immediate into an 8-byte destination, which caused the ICE.
2026-03-06 18:49:48 +01:00
Jonathan Brouwer 550527989e Rollup merge of #151280 - chenyukang:yukang-fix-149787, r=estebank
Fix incorrect trailing comma suggested in no_accessible_fields

Fixes rust-lang/rust#149787

r? @estebank

I think add new field for AST for it is too heavy change for this issue, here is a trivial fix with source_map, seems enough for it.
2026-03-06 18:49:46 +01:00
Waffle Lapkin 05174fbcc5 tidy never type issue-* tests 2026-03-06 17:44:18 +01:00
Takayuki Maeda ca2178dd9f add UI regression test for offset_of! recovery 2026-03-06 22:19:11 +09:00
Yuki Okushi 1190845a3d Do not emit ConstEvaluatable goals if type-const 2026-03-06 21:51:31 +09:00
Jynn Nelson 20404bf4a6 Split out linker-info from linker-messages
- Hide common linker output behind `linker-info`
- Add tests
- Account for different capitalization on windows-gnu when removing
  "warning" prefix
- Add some more comments
- Add macOS deployment-target test
- Ignore linker warnings from trying to statically link glibc

  I don't know what's going on in `nofile-limit.rs` but I want no part
  of it.

- Use a fake linker so tests are platform-independent
2026-03-06 10:38:21 +01:00
Guillaume Gomez c98094bd32 Remove TyCtxt::node_span_lint usage from rustc_hir_typeck 2026-03-05 23:53:54 +01:00
Guillaume Gomez e1ee66935e Remove TyCtxt::node_span_lint usage from rustc_hir_analysis 2026-03-05 23:53:54 +01:00
JayanAXHF 2093158de7 refactor: move check_align to parse_alignment
* refactor: move `check_align` from check_attrs.rs to `parse_alignment`

rel: attribute parser rework
* fix: fix error messages
* test: fix test
* fix: fix invalid error message
* ops(test): Fix CI
2026-03-05 18:46:00 +00:00
Jonathan Brouwer 11c4beac1e Rollup merge of #153453 - kpreid:fix-153388, r=fmease,estebank
Fix ICEs due to incomplete typechecking on struct literals with syntax errors.

Fixes rust-lang/rust#153388.
Followup to rust-lang/rust#153227.

Today I have learned that when we don’t emit a diagnostic *specifically from typeck*, we need to call `self.infcx.set_tainted_by_errors()` to signal that the type checking is incomplete despite the lack of error.

r? fmease
2026-03-05 19:42:01 +01:00
Jonathan Brouwer 4a5a2165d2 Rollup merge of #153435 - aerooneqq:delegation_res_def_id_ice, r=petrochenkov
Fix obtaining def_id from unresolved segment

This PR fixes ICE when trying to obtain `def_id` from an unresolved segment, part of rust-lang/rust#118212, fixes rust-lang/rust#153389.

r? @petrochenkov
2026-03-05 19:42:01 +01:00
Jonathan Brouwer 9632fd893d Rollup merge of #152906 - lapla-cogito:issue_152653, r=BoxyUwU
Make `const_lit_matches_ty` check literal suffixes for exact type match

`const_lit_matches_ty` ignored literal suffixes. This let the `try_lower_anon_const_lit` fast path produce a mistyped `ty::Const::Value`, bypassing the type mismatch error that typeck would otherwise report.
2026-03-05 19:41:59 +01:00
Kevin Reid 072bd694ad Fix ICEs due to incomplete typechecking on struct literals with syntax errors. 2026-03-05 09:50:13 -08:00
Guillaume Gomez 25c7798004 Create new Diagnostic type for panic calls without literals 2026-03-05 12:12:31 +01:00
aerooneqq 169dd72d47 Fix obtaining def_id from unresolved segment 2026-03-05 10:38:56 +03:00
Jonathan Brouwer fed3c49695 Rollup merge of #153394 - TKanX:bugfix/153390-ice-enum-struct-syntax-error, r=dingxiangfei2009
fix(thir): Include `NoneWithError` in Enum Struct Tail Assertion

### Summary:

Fixes the ICE triggered when a syntax error appears inside an enum variant struct literal.

PR rust-lang/rust#153227 added `StructTailExpr::NoneWithError` and updated the `match base` arm in the `AdtKind::Enum` branch of `thir/cx/expr.rs`, but overlooked the `assert!(matches!(...))` guard preceding it, which still only listed `None | DefaultFields(_)`.

Closes rust-lang/rust#153390

r? @dingxiangfei2009
cc @matthiaskrgr
2026-03-05 06:31:39 +01:00
Jonathan Brouwer fb488de2aa Rollup merge of #153361 - folkertdev:tail-call-indirect-on-stack-true, r=WaffleLapkin
enable `PassMode::Indirect { on_stack: true, .. }` tail call arguments

tracking issue: https://github.com/rust-lang/rust/issues/112788
fixes https://github.com/rust-lang/rust/issues/144855

And add a bunch of tests for tail call target support.

r? WaffleLapkin
2026-03-05 06:31:36 +01:00
bors f8704be04f Auto merge of #153416 - JonathanBrouwer:rollup-eezxWTV, r=JonathanBrouwer
Rollup of 12 pull requests



Successful merges:

 - rust-lang/rust#153402 (miri subtree update)
 - rust-lang/rust#152164 (Lint unused features)
 - rust-lang/rust#152801 (Refactor WriteBackendMethods a bit)
 - rust-lang/rust#153196 (Update path separators to be available in const context)
 - rust-lang/rust#153204 (Add `#[must_use]` attribute to `HashMap` and `HashSet` constructors)
 - rust-lang/rust#153317 (Abort after `representability` errors)
 - rust-lang/rust#153276 (Remove `cycle_fatal` query modifier)
 - rust-lang/rust#153300 (Tweak some of our internal `#[rustc_*]` TEST attributes)
 - rust-lang/rust#153396 (use `minicore` in some `run-make` tests)
 - rust-lang/rust#153401 (Migrationg of `LintDiagnostic` - part 7)
 - rust-lang/rust#153406 (Remove a ping for myself)
 - rust-lang/rust#153414 (Rename translation -> formatting)
2026-03-05 00:14:57 +00:00
bors b55e20ad90 Auto merge of #151842 - eggyal:skip-deducing-parameter-attrs-during-ctfe, r=RalfJung
Do not deduce parameter attributes during CTFE

*[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/pull/151842)*

Ever since rust-lang/rust#103172, `fn_abi_of_instance` might look at a function's body to deduce certain codegen optimization attributes for its indirectly-passed parameters beyond what can be determined purely from its signature (namely today `ArgAttribute::ReadOnly` and `ArgAttribute::CapturesNone`). Since rust-lang/rust#130201, looking at a function's body in this way entails generating, for any coroutine-closures, additional by-move MIR bodies (which aren't represented in the HIR)—but this requires knowing the types of their context and consequently cycles can ensue if such bodies are generated before typeck is complete (such as during CTFE).

Since they have no bearing on the evaluation result, this patch breaks a subquery out from `fn_abi_of_instance`, `fn_abi_of_instance_no_deduced_attrs`, which returns the ABI before such parameter attributes are deduced; and that new subquery is used in CTFE instead (however, since parameter attributes are only deduced in optimized builds, as a performance optimization we avoid calling the original query unless we are performing such a build).

Fixes rust-lang/rust#151748
Fixes rust-lang/rust#152497
2026-03-04 20:18:52 +00:00
Folkert de Vries 391a7554f3 enable PassMode::Indirect { on_stack: true } tail call arguments 2026-03-04 19:43:12 +01:00
Jonathan Brouwer 1500680ba5 Rollup merge of #153401 - GuillaumeGomez:migrate-diag, r=JonathanBrouwer
Migrationg of `LintDiagnostic` - part 7

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

This PR removes the `LintDiagnostic` trait and proc-macro. \o/

r? @JonathanBrouwer
2026-03-04 19:30:40 +01:00
Jonathan Brouwer 23e27344e9 Rollup merge of #153300 - fmease:test-attrs-tweaks, r=JonathanBrouwer
Tweak some of our internal `#[rustc_*]` TEST attributes

I think I might be the one who's used the internal TEST attrs `#[rustc_{dump_predicates,object_lifetime_default,outlives,variance}]` the most in recent times, I might even be the only one. As such I've noticed some recent-ish issues that haven't been fixed so far and which keep bothering me. Moreover I have a longstanding urge to rename several of these attributes which I couldn't contain anymore.

[`#[rustc_*]` TEST attributes](https://rustc-dev-guide.rust-lang.org/compiler-debugging.html#rustc_-test-attributes) are internal attributes that basically allow you to dump the output of specific queries for use in UI tests or for debugging purposes.

1. When some of these attributes were ported over to the new parsing API, their targets were unnecessarily restricted. I've kept encountering these incorrect "attribute cannot be used" errors all the while HIR analysis happily & correctly dumped the requested data below it. I've now relaxed their targets.
2. Since we now have target checking for the internal attributes I figured that it's unhelpful if we still intentionally crashed on invalid targets, so I've got rid of that.
3. I've always been annoyed that most of these (very old) attributes don't contain the word `dump` in their name (rendering their purpose non-obvious) and that some of their names diverge quite a bit from the corresponding query name. I've now rectified that. The new names take longer to type but it's still absolutely acceptable imo.

---

I haven't renamed all of the TEST attributes to follow the `rustc_dump_` scheme since that's quite tedious. If it's okay with you I'd like to postpone that (e.g., `rustc_{def_path,hidden_type…,layout,regions,symbol_name}`).

I've noticed that the parsers for TEST attrs are spread across `rustc_dump.rs`, `rustc_internal.rs` & `test_attrs.rs` which is a bit confusing. Since the new names are prefixed with `rustc_dump_` I've moved their parsers into `rustc_dump.rs` but of course they are still TEST attrs. IIRC, `test_attrs.rs` also contains non-`rustc_`-TEST attrs, so we can't just merge these two files. I guess that'll sort itself out in the future when I tackle the other internal TEST attrs.

r\? Jana || Jonathan
2026-03-04 19:30:39 +01:00
Jonathan Brouwer febe0bc218 Rollup merge of #153317 - nnethercote:abort-after-infinite-errors, r=oli-obk
Abort after `representability` errors

Doing so results in better error messages and makes the code a bit simpler. Details in individual commits.

r? @oli-obk
2026-03-04 19:30:38 +01:00
Jonathan Brouwer 1c44dbd580 Rollup merge of #152164 - mu001999-contrib:lint/unused_features, r=JonathanBrouwer
Lint unused features

*[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/pull/152164)*

Fixes rust-lang/rust#44232
Fixes rust-lang/rust#151752

---

This PR records used features through query side effect, then reports unsued features finally.
2026-03-04 19:30:36 +01:00
Alan Egerton 55509a9fe4 Do not deduce parameter attributes during CTFE
`fn_abi_of_instance` can look at function bodies to deduce codegen
optimization attributes (namely `ArgAttribute::ReadOnly` and
`ArgAttribute::CapturesNone`) of indirectly-passed parameters.  This can
lead to cycles when performed during typeck, when such attributes are
irrelevant.

This patch breaks a subquery out from `fn_abi_of_instance`,
`fn_abi_of_instance_no_deduced_attrs`, which returns the ABI before such
parameter attributes are deduced; and that new subquery is used in CTFE
instead.
2026-03-04 16:38:36 +00:00
Guillaume Gomez e805d8c961 Remove mentions of LintDiagnostic 2026-03-04 15:16:52 +01:00
Waffle Lapkin eef3c4db7b move never type tests to subdirectories and add some comments 2026-03-04 13:17:19 +01:00
Tony Kan 20768d802e fix(thir): Include NoneWithError in enum struct tail assertion 2026-03-04 02:11:04 -08:00
Matthias Krüger 5bd6a0c2f9 Rollup merge of #153274 - ValorZard:async-drop-multi-crate-crash, r=oli-obk
Fix async drop multi crate crash

fixes rust-lang/rust#142572
Again, I've been talking in the Zulip about this: [#wg-async > is there a way I can help with Async Drop? @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/187312-wg-async/topic/is.20there.20a.20way.20I.20can.20help.20with.20Async.20Drop.3F/near/575627286)

TL;DR: This is going to be a bit of a refactor, hold your horses

Also, I might end up splitting this into two PRs, so I can first merge my elaborate_drop.rs refactor, and then my fix for the crash later, but IDK yet
2026-03-04 09:49:02 +01:00
Matthias Krüger f222b55782 Rollup merge of #152816 - ShoyuVanilla:issue-151318, r=lcnr
Check for region dependent goals on type_op itself as well

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

r? lcnr
2026-03-04 09:49:01 +01:00
root db6ee18fd0 Fix multi-crate crash if dependency has enabled AsyncDrop 2026-03-04 00:40:47 -08:00
Stuart Cook c4f239ec6a Rollup merge of #153352 - GuillaumeGomez:migrate-diag, r=JonathanBrouwer
Migration of `LintDiagnostic` - part 6

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

r? @JonathanBrouwer
2026-03-04 11:54:11 +11:00
Stuart Cook 010bca6fc7 Rollup merge of #153258 - lapla-cogito:issue_153126, r=Kivooeo
diag: Suppress `.clone()` suggestion inside derive macro expansions

Derives on a packed struct with non-Copy fields generate moves whose spans point back at the original field type definitions. `suggest_cloning_inner()` then proposes inserting `.clone()` at those locations, producing nonsensical output like `String.clone()` in the struct definition.

close rust-lang/rust#153126
2026-03-04 11:54:10 +11:00
Stuart Cook 70287b9bc2 Rollup merge of #153048 - ozankenangungor:fix-irrefutable-let-else-wording, r=Kivooeo
Improve irrefutable let-else lint wording

Update the `irrefutable_let_patterns` wording for let-else to better reflect that the `else` clause is unreachable when the LHS pattern always matches.

Closes rust-lang/rust#152938
2026-03-04 11:54:09 +11:00
Stuart Cook df44e396c0 Rollup merge of #153302 - CathalMullan:rbx, r=Amanieu
x86: reserve `bl` and `bh` registers to match `rbx`

`bl` and `bh` need to be explicitly marked as reserved, as they are sub-registers of `rbx`, which is reserved by LLVM.

Discovered this while trying to run Graviola through Cranelift, which was becoming corrupted due to the register allocator assigning `bl`: https://github.com/rust-lang/rustc_codegen_cranelift/pull/1629

cc: @bjorn3
2026-03-04 11:54:08 +11:00
mu001999 0436634084 Remove unused features in tests 2026-03-04 08:06:45 +08:00
Guillaume Gomez b5ff567193 Migrate more types from LintDiagnostic to Diagnostic 2026-03-03 21:57:02 +01:00
Nicholas Nethercote 52b4de34ec Abort after printing infinite type errors.
Currently, `Representability::from_cycle_error` prints an "infinite
size" error and then returns `Representability::Infinite`, which lets
analysis continue. This commit changes it so it just aborts after
printing the error. This has two benefits.

First, the error messages are better. The error messages we get after
continuing are mostly bad -- we usually get another cycle error, e.g.
about drop checking or layout, which is not much use to the user, and
then abort after that. The only exception is `issue-105231.rs` where a
"conflicting implementations" error is now omitted, but there are three
other errors before that one so it's no great loss.

Second, it allows some simplifications: see the next commit.
2026-03-04 07:02:36 +11:00
Jonathan Brouwer 0605ef5223 Rollup merge of #153345 - Human9000-bit:mgca-diagnostics-fix, r=fmease
MGCA: fix type error handling for const array and tuple lowering logic

It's a simple fix; just needed to handle Ty::Error in `lower_const_arg_array` and `lower_const_arg_tup`

Fixes rust-lang/rust#153254

r? @fmease
2026-03-03 19:11:50 +01:00
Shoyu Vanilla 5f3bdde8e4 Check for region dependent goals on type_op itself as well 2026-03-04 00:02:05 +09:00
Jonathan Brouwer f3f04699c1 Rollup merge of #153319 - DanielEScherzer:ie-dots, r=jhpratt
Comments and docs: add missing periods to "ie."

"i.e." is short for the Latin "id est" and thus both letters should be followed by periods.
2026-03-03 13:08:45 +01:00
Jonathan Brouwer ee8e2dfaea Rollup merge of #153184 - bjorn3:split_crate_info_out_of_codegen_results, r=nnethercote
Replace CodegenResults with CompiledModules

This is already CodegenResults without CrateInfo. The driver can calculate the CrateInfo and pass it by-ref to the backend. Using CompiledModules makes it a bit easier to move some other things out of the backend as will be necessary for moving LTO to the link phase.

Helps with https://github.com/rust-lang/compiler-team/issues/908
2026-03-03 13:08:44 +01:00
Jonathan Brouwer bef489b0ce Rollup merge of #152943 - CoCo-Japan-pan:impl-restriction-parse, r=Urgau,jhpratt
Parse `impl` restrictions

This PR implements the parsing logic for `impl` restrictions (e.g., `pub impl(crate) trait Foo {}`) as proposed in [RFC 3323](https://rust-lang.github.io/rfcs/3323-restrictions.html).
As the first step of the RFC implementation, this PR focuses strictly on the parsing phase. The new syntax is guarded by the `#![feature(impl_restriction)]` feature gate.
This implementation basically follows the pattern used in rust-lang/rust#141754.

r? @jhpratt
2026-03-03 13:08:43 +01:00
human9000 ee1d0cfbe6 MGCA: fix type error handling for array and tuple lowering logic 2026-03-03 17:08:26 +05:00