about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2025-08-06Rollup merge of #144998 - dianqk:visit-no-use-proj, r=cjgillotGuillaume Gomez-14/+20
mir: Do not modify NonUse in `super_projection_elem` Split from rust-lang/rust#142771. r? cjgillot
2025-08-06Rollup merge of #144996 - dianqk:simplifycfg-collapse_goto_chain-changed, ↵Guillaume Gomez-0/+1
r=cjgillot simplifycfg: Mark as changed when start is modified in collapse goto chain Split from rust-lang/rust#142771. r? cjgillot
2025-08-06Rollup merge of #144977 - fmease:fortify-param-default-checks, r=compiler-errorsGuillaume Gomez-99/+101
Fortify generic param default checks * Hard-reject instead of lint-reject type param defaults in generic assoc consts (GACs) (feature: `generic_const_items`). * In https://github.com/rust-lang/rust/pull/113522, I explicitly handled the free const item case and forgot about the assoc const one. * This led rustc to assume the default of emitting the deny-by-default lint `invalid_type_param_default`. * GCIs are unstable, thus we're not bound by backward compat * Hard-reject instead of lint-reject type param defaults in foreign items. * We already hard-reject generic params on foreign items, so this isn't a breaking change. * There's no reason why we need to lint-reject. * Refactor the way we determine where generic param defaults are allowed: * Don't default to emitting lint `invalid_type_param_defaults` for nodes that aren't explicitly handled but instead panic. * This would've caught my GAC oversight from above much earlier via fuzzing * Prevents us from accidentally stabilizing more invalid type param defaults in the future * Streamline the phrasing of the diagnostic
2025-08-06Rollup merge of #144956 - fmease:gate-const-trait-syntax, r=BoxyUwUGuillaume Gomez-0/+3
Gate const trait syntax Missed this during my review of rust-lang/rust#143879, huge apologies! Fixes [after beta backport] https://github.com/rust-lang/rust/issues/144958. cc ``@fee1-dead`` r? ``@BoxyUwU`` or anyone
2025-08-06Rollup merge of #144948 - lcnr:change-candidate-handling, r=compiler-errorsGuillaume Gomez-69/+48
we only merge candidates for trait and normalizes-to goals so change `fn try_merge_responses` to `fn try_merge_candidates` and just use candidates everywhere. Potentially slightly faster than the alternative :3 r? ``@compiler-errors`` ``@BoxyUwU``
2025-08-06Rollup merge of #144917 - compiler-errors:tail-call-linked-lifetimes, r=lcnrGuillaume Gomez-56/+54
Enforce tail call type is related to body return type in borrowck Like all call terminators, tail call terminators instantiate the binder of the callee signature with region variables and equate the arg operand types with that signature's args to ensure that the call is valid. However, unlike normal call terminators, we were forgetting to also relate the return type of the call terminator to anything. In the case of tail call terminators, the correct thing is to relate it to the return type of the caller function (or in other words, the return local `_0`). This meant that if the caller's return type had some lifetime constraint, then that constraint wouldn't flow through the signature and affect the args. This is what's happening in the example test I committed: ```rust fn link(x: &str) -> &'static str { become passthrough(x); } fn passthrough<T>(t: T) -> T { t } fn main() { let x = String::from("hello, world"); let s = link(&x); drop(x); println!("{s}"); } ``` Specifically, the type `x` is `'?0 str`, where `'?0` is some *universal* arg. The type of `passthrough` is `fn(&'?1 str) -> &'?1 str`. Equating the args sets `'?0 = '?1`. However, we need to also equate the return type `&'?1 str` to `&'static str` so that we eventually require that `'?0 = 'static`, which is a borrowck error! ----- Look at the first commit for the functional change, and the second commit is just a refactor because we don't need to pass `Option<BasicBlock>` to `check_call_dest`, but just whether or not the terminator is expected to be diverging (i.e. if the return type is `!`). Fixes rust-lang/rust#144916
2025-08-06Rollup merge of #144835 - compiler-errors:tail-call-sig-binder, r=WaffleLapkinGuillaume Gomez-1/+5
Anonymize binders in tail call sig See the comment for explanation Fixes rust-lang/rust#144826 r? WaffleLapkin
2025-08-06Rollup merge of #144794 - scrabsha:push-noqrrttovmwy, r=jdonszelmannGuillaume Gomez-17/+33
Port `#[coroutine]` to the new attribute system Related to https://github.com/rust-lang/rust/issues/131229#issue-2565886367. r? `````@jdonszelmann`````
2025-08-06Rollup merge of #144195 - Kivooeo:bad-attr, r=fmease,compiler-errorsGuillaume Gomez-7/+91
Parser: Recover from attributes applied to types and generic args r? compiler Add clearer error messages for invalid attribute usage in types or generic types fixes rust-lang/rust#135017 fixes rust-lang/rust#144132
2025-08-06Auto merge of #145003 - Kobzol:rollup-kgb216b, r=Kobzolbors-1/+0
Rollup of 12 pull requests Successful merges: - rust-lang/rust#144552 (Rehome 33 `tests/ui/issues/` tests to other subdirectories under `tests/ui/`) - rust-lang/rust#144676 (Add documentation for unstable_feature_bound) - rust-lang/rust#144836 (Change visibility of Args new function) - rust-lang/rust#144910 (Add regression tests for seemingly fixed issues) - rust-lang/rust#144913 ([rustdoc] Fix wrong `i` tooltip icon) - rust-lang/rust#144924 (compiletest: add hint for when a ui test produces no errors) - rust-lang/rust#144926 (Correct the use of `must_use` on btree::IterMut) - rust-lang/rust#144928 (Drop `rust-version` from `rustc_thread_pool`) - rust-lang/rust#144945 (Autolabel PRs that change explicit tail call tests as `F-explicit_tail_calls`) - rust-lang/rust#144954 (run-make: Allow blessing snapshot files that don't exist yet) - rust-lang/rust#144971 (num: Rename `isolate_most_least_significant_one` functions) - rust-lang/rust#144978 (Fix some doc links for intrinsics) r? `@ghost` `@rustbot` modify labels: rollup
2025-08-06Rollup merge of #144928 - cuviper:rustc_thread_pool-msrv, r=lqdJakub Beránek-1/+0
Drop `rust-version` from `rustc_thread_pool` The current `rust-version = "1.63"` was inherited from rayon, but it doesn't make sense to limit this in the compiler workspace. Having any setting at all has effects on tools like `cargo info` that try to infer the MSRV when the workspace itself doesn't specify it. Since we are the compiler, our only MSRV is whatever bootstrapping requires.
2025-08-06Auto merge of #143679 - sebastianpoeplau:preserve-debug-gdb-scripts-section, ↵bors-60/+50
r=bjorn3 Preserve the .debug_gdb_scripts section Make sure that compiler and linker don't optimize the section's contents away by adding the global holding the data to `llvm.used`. This eliminates the need for a volatile load in the main shim; since the LLVM codegen backend is the only implementer of the corresponding trait function, remove it entirely. Pretty printers in dylib dependencies are now emitted by the main crate instead of the dylib; apart from matching how rlibs are handled, this approach has the advantage that `omit_gdb_pretty_printer_section` keeps working with dylib dependencies. r? `@bjorn3`
2025-08-06mir: Do not modify NonUse in `super_projection_elem`dianqk-14/+20
2025-08-06simplifycfg: Mark as changed when start is modified in collapse goto chaindianqk-0/+1
2025-08-06Embed GDB pretty printers in rlibs and dylibsSebastian Poeplau-33/+20
Instead of collecting pretty printers transitively when building executables/staticlibs/cdylibs, let the debugger find each crate's pretty printers via its .debug_gdb_scripts section. This covers the case where libraries defining custom pretty printers are loaded dynamically.
2025-08-06Fortify generic param default checksLeón Orell Valerian Liehr-99/+101
2025-08-05Auto merge of #144863 - cjgillot:live-or-dead, r=Urgaubors-274/+199
Simplify dead code lint This PR scratches a few itches I had when looking at that code. The perf improvement comes from keeping the `scanned` set through several marking phases. This pretty much divides by 2 the number of HIR traversals.
2025-08-05we only merge candidates for trait and normalizes-to goalslcnr-69/+48
2025-08-05Gate const trait syntaxLeón Orell Valerian Liehr-0/+3
2025-08-05Preserve the .debug_gdb_scripts sectionSebastian Poeplau-45/+48
Make sure that compiler and linker don't optimize the section's contents away by adding the global holding the data to "llvm.used". The volatile load in the main shim is retained because "llvm.used", which translates to SHF_GNU_RETAIN on ELF targets, requires a reasonably recent linker; emitting the volatile load ensures compatibility with older linkers, at least when libstd is used. Pretty printers in dylib dependencies are now emitted by the main crate instead of the dylib; apart from matching how rlibs are handled, this approach has the advantage that `omit_gdb_pretty_printer_section` keeps working with dylib dependencies.
2025-08-05Added checks for attribute in type caseKivooeo-7/+91
2025-08-05Rollup merge of #144920 - compiler-errors:span-arg, r=lqdSamuel Tardieu-3/+3
Dont print arg span in MIR dump for tail call r? WaffleLapkin This makes the MIR dump for tail call terminators consistent w/ regular calls.
2025-08-05Rollup merge of #144890 - WaffleLapkin:project_fields, r=lcnrSamuel Tardieu-33/+44
Add `InterpCx::project_fields` I was hoping for a much bigger improvement and this is lukewarm at best ^^' Still, I think this makes sense.
2025-08-05Rollup merge of #144877 - Zalathar:coverage-various, r=lcnrSamuel Tardieu-68/+76
coverage: Various small cleanups This PR is a collection of small coverage-related changes that I accumulated while working towards other coverage improvements. Each change should hopefully be fairly straightforward.
2025-08-05Rollup merge of #144866 - JonathanBrouwer:should_emit_fix, r=jdonszelmannSamuel Tardieu-4/+11
Remove `SHOULD_EMIT_LINTS` in favor of `should_emit` r? ``@jdonszelmann``
2025-08-05Rollup merge of #144817 - WaffleLapkin:reject-referety, r=UrgauSamuel Tardieu-3/+50
Properly reject tail calls to `&FnPtr` or `&FnDef` Fixes rust-lang/rust#144795
2025-08-05Rollup merge of #144776 - nnethercote:Printer-cleanups, r=cjgillotSamuel Tardieu-693/+649
`Printer` cleanups The trait `Printer` is implemented by six types, and the sub-trait `PrettyPrinter` is implemented by three of those types. The traits and the impls are complex and a bit of a mess. This PR starts to clean them up. r? ``@davidtwco``
2025-08-05Rollup merge of #144741 - ShoyuVanilla:tilde-const-in-block, r=fee1-deadSamuel Tardieu-16/+55
fix: Error on illegal `[const]`s inside blocks within legal positions Fixes rust-lang/rust#132067 I initially considered moving `[const]` validations to `rustc_ast_lowering`, but that approach would require adding constness information to `AssocCtxt`, which introduces significant changes - especially within `rustc_expand` - just to support a single use case here: https://github.com/rust-lang/rust/blob/3fb1b53a9dbfcdf37a4b67d35cde373316829930/compiler/rustc_ast_passes/src/ast_validation.rs#L1596-L1610 Instead, I believe it's sufficient to simply "reset" `[const]` allowness whenever we enter a new block.
2025-08-04Update doc-comment.Camille GILLOT-4/+3
2025-08-04Simplify maybe_record_as_seed.Camille GILLOT-3/+4
2025-08-04Drop `rust-version` from `rustc_thread_pool`Josh Stone-1/+0
The current `rust-version = "1.63"` was inherited from rayon, but it doesn't make sense to limit this in the compiler workspace. Having any setting at all has effects on tools like `cargo info` that try to infer the MSRV when the workspace itself doesn't specify it. Since we are the compiler, our only MSRV is whatever bootstrapping requires.
2025-08-04Dont print arg span in MIR dump for tail callMichael Goulet-3/+3
2025-08-04Don't actually pass BB to check_call_destMichael Goulet-60/+54
2025-08-04Port `#[coroutine]` to the new attribute systemSasha Pourcelot-17/+33
Related to https://github.com/rust-lang/rust/issues/131229#issue-2565886367.
2025-08-04Enforce tail call type is related to body return type in borrowckMichael Goulet-3/+7
2025-08-04Anonymize binders in tail call sigMichael Goulet-1/+5
2025-08-04add `project_fields` helper functionWaffle Lapkin-13/+22
2025-08-04Merge commit '482e8540a1b757ed7bccc2041c5400f051fdb01e' into ↵Guillaume Gomez-45/+275
subtree-update_cg_gcc_2025-08-04
2025-08-04small refactor of `InterpResult`Waffle Lapkin-20/+22
- don't need type alias to default type argument - `Residual` impl allows to use more std APIs (like `<[T; N]>::try_map`)
2025-08-04properly reject tail calls to `&FnPtr` or `&FnDef`Waffle Lapkin-2/+49
2025-08-04drive-by cleanup: fix outdated documentationWaffle Lapkin-1/+1
2025-08-04Rollup merge of #144694 - compiler-errors:with-self-ty, r=SparrowLiiStuart Cook-41/+52
Distinguish prepending and replacing self ty in predicates There are two kinds of functions called `with_self_ty`: 1. Prepends the `Self` type onto an `ExistentialPredicate` which lacks it in its internal representation. 2. Replaces the `Self` type of an existing predicate, either for diagnostics purposes or in the new trait solver when normalizing that self type. This PR distinguishes these two because I often want to only grep for one of them. Namely, let's call it `with_replaced_self_ty` when all we're doing is replacing the self type.
2025-08-04coverage: Represent `CovmapVersion` as an enumZalathar-15/+32
Using an enum here was historically not worth the extra hassle, but now we can lean on `#[derive(TryFromU32)]` to hide most of the boilerplate.
2025-08-04coverage: Simplify access to debug/testing `-Zcoverage-options` flagsZalathar-6/+9
2025-08-04coverage: Push async special case down into `extract_refined_covspans`Zalathar-14/+16
2025-08-04coverage: Remove `-Zcoverage-options=no-mir-spans`Zalathar-23/+4
This flag turned out to be less useful than anticipated, and interferes with work towards expansion support.
2025-08-04coverage: Hoist `counter_for_bcb` out of its loopZalathar-10/+10
Having this helper function in the loop was confusing, because it doesn't rely on anything that changes between loop iterations.
2025-08-04coverage: Include an `Instance` in `CovfunRecord` for debug messagesZalathar-1/+6
2025-08-04Rollup merge of #144746 - petrochenkov:extpreltidy, r=b-naberStuart Cook-63/+73
resolve: Cleanups and micro-optimizations to extern prelude This is what can be done without changing the structure of `ExternPreludeEntry`, like in https://github.com/rust-lang/rust/pull/144737. See individual commits for details.
2025-08-04Rollup merge of #144706 - zachs18:fix-144661, r=RalfJungStuart Cook-2/+6
Do not give function allocations alignment in consteval and Miri. We do not yet have a (clear and T-lang approved) design for how `#[align(N)]` on functions should affect function pointers' addresses on various platforms, so for now do not give function pointers alignment in consteval and Miri. ---- Old summary: Not a full solution to <https://github.com/rust-lang/rust/issues/144661>, but fixes the immediate issue by making function allocations all have alignment 1 in consteval, ignoring `#[rustc_align(N)]`, so the compiler doesn't know if any offset other than 0 is non-null. A more "principlied" solution would probably be to make function pointers to `#[instruction_set(arm::t32)]` functions be at offset 1 of an align-`max(2, align attribute)` allocation instead of at offset 0 of their allocation during consteval, and on wasm to either disallow `#[align(N)]` where N > 1, or to pad the function table such that the function pointer of a `#[align(N)]` function is a multiple of `N` at runtime.