about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2025-09-03Rollup merge of #146106 - epage:whitespace, r=fee1-deadStuart Cook-18/+31
fix(lexer): Only allow horizontal whitespace in frontmatter In writing up the reference for frontmatter, I realized that we probably shouldn't be accepting Unicode Line Ending characters between the code fence and infostring or trailing after the infostring or a code fence. In digging into the unicode specification we use for Whitespace, it divides it up into categories, so I'm deferring to what it says for horizontal whitespace for what should be used within a line. Note, I am leaving out support for Unicode Default Ignorable characters. I figure that can be discussed outside of this change within the reference and tracking issue. Fixes rust-lang/rust#145971 Frontmatter tracking issue: rust-lang/rust#136889
2025-09-03Rollup merge of #146032 - heiher:loong64-none-no-lsx, r=lqdStuart Cook-1/+1
Explicity disable LSX feature for `loongarch64-unknown-none` target The `loongarch64-unknown-none` target is a bare-metal target with hardware floating-point support and should not enable SIMD extensions by default. However, LLVM's LoongArch64 backend enables LSX implicitly, inadvertently activating SIMD instructions for this target. This patch explicitly disable LSX feature to prevent unintended SIMD usage.
2025-09-03Rollup merge of #145961 - petrochenkov:extprelregr, r=nnethercoteStuart Cook-3/+20
resolve: Avoid a regression from splitting prelude into two scopes Fixes https://github.com/rust-lang/rust/issues/145575.
2025-09-02Auto merge of #146125 - GuillaumeGomez:rollup-ld81n7e, r=GuillaumeGomezbors-97/+112
Rollup of 14 pull requests Successful merges: - rust-lang/rust#144066 (stabilize c-style varargs for sysv64, win64, efiapi, aapcs) - rust-lang/rust#145783 (add span to struct pattern rest (..)) - rust-lang/rust#146034 (Update target spec metadata of Arm64EC Windows and Trusty targets) - rust-lang/rust#146064 (Add compiler error when trying to use concat metavar expr in repetitions) - rust-lang/rust#146070 (rustdoc-search: skip loading unneeded fnData) - rust-lang/rust#146088 (constify impl Try for ControlFlow) - rust-lang/rust#146089 (fix a constness ordering bug in rustfmt) - rust-lang/rust#146091 (fix rustdoc `render_call_locations` panicking because of default span `DUMMY_SP` pointing at non local-source file) - rust-lang/rust#146094 (Make `Parser::parse_for_head` public for rustfmt usage) - rust-lang/rust#146102 (Remove dead code stemming from an old effects desugaring) - rust-lang/rust#146115 (Add maintainer for VxWorks) - rust-lang/rust#146116 (Adjust issue-118306.rs test after LLVM change) - rust-lang/rust#146117 (Fix search index generation) - rust-lang/rust#146118 (improve process::abort rendering in Miri backtraces) r? `@ghost` `@rustbot` modify labels: rollup
2025-09-02Rollup merge of #146102 - fmease:rm-dead-eff-code-iii, r=fee1-deadGuillaume Gomez-20/+12
Remove dead code stemming from an old effects desugaring CC https://github.com/rust-lang/rust/pull/132374, https://github.com/rust-lang/rust/pull/133443. r? fee1-dead
2025-09-02Rollup merge of #146094 - mohe2015:patch-2, r=lcnrGuillaume Gomez-1/+2
Make `Parser::parse_for_head` public for rustfmt usage Similar to https://github.com/rust-lang/rust/pull/138511, I want to add [dioxus rsx](https://dioxuslabs.com/learn/0.6/reference/rsx) formatting to [my rustfmt fork](https://github.com/tucant/rustfmt) and it would be much easier if that method would be public. Thanks.
2025-09-02Rollup merge of #146064 - jullanggit:patch-1, r=fmeaseGuillaume Gomez-1/+6
Add compiler error when trying to use concat metavar expr in repetitions ## Disclaimer This is my first PR to rust, so if I missed/could improve something about this PR, please excuse and tell me! ## The improvement The [metavar_expr_concat feature](https://github.com/rust-lang/rust/issues/124225) currently does not seem to support nested repetitions, and throws an ICE without much explanation if the relevant code path is hit. This PR adds a draft compiler error that attempts to explain the issue. I am not 100% sure what all the ways of triggering this error are, so the message is currently pretty generic, please do correct me if there's something wrong with it or it could be improved. Thank you for you time! Fixes rust-lang/rust#140479.
2025-09-02Rollup merge of #146034 - taiki-e:target-spec, r=nnethercoteGuillaume Gomez-5/+5
Update target spec metadata of Arm64EC Windows and Trusty targets Update outdated target spec metadata in the following targets. - Arm64EC Windows (`arm64ec-pc-windows-msvc`) is "tier 2 without host tools" since https://github.com/rust-lang/rust/pull/126039 and supports `std` since before that, but metadata currently says that is tier 3 and has unknown `std` support status. - Trusty targets (`{aarch64,armv7,x86_64}-unknown-trusty`) support `std` since https://github.com/rust-lang/rust/pull/136842 (and I confirmed they can be compiled with `-Zbuild-std=std`), but metadata currently says that has no `std` support. Mentioning `@dpaoliello` as [arm64ec-pc-windows-msvc target-maintainer](https://doc.rust-lang.org/nightly/rustc/platform-support/arm64ec-pc-windows-msvc.html#target-maintainers). Mentioning `@randomPoison` `@ahomescu` as [Trusty target maintainers](https://doc.rust-lang.org/nightly/rustc/platform-support/trusty.html#target-maintainers).
2025-09-02Rollup merge of #145783 - Erk-:et-cetera-span, r=compiler-errorsGuillaume Gomez-23/+32
add span to struct pattern rest (..) Struct pattern rest (`..`) did not retain span information compared to normal fields. This patch adds span information for it. The motivation of this patch comes from when I implemented this PR for Clippy: https://github.com/rust-lang/rust-clippy/pull/15000#discussion_r2134145163 It is possible to get the span of the Et cetera in a bit roundabout way, but I thought this would be nicer.
2025-09-02Rollup merge of #144066 - RalfJung:extern-c-variadics, r=workingjubileeGuillaume Gomez-47/+55
stabilize c-style varargs for sysv64, win64, efiapi, aapcs This has been split up so the PR now only contains the extended_varargs_abi_support stabilization; "system" has been moved to https://github.com/rust-lang/rust/pull/145954. **Previous (combined) PR description:** This stabilizes extern block declarations of variadic functions with the system, sysv64, win64, efiapi, aapcs ABIs. This corresponds to the extended_varargs_abi_support and extern_system_varargs feature gates. The feature gates were split up since it seemed like there might be further discussion needed for what exactly "system" ABI variadic functions should do, but a [consensus](https://github.com/rust-lang/rust/issues/136946#issuecomment-2967847553) has meanwhile been reached: they shall behave like "C" functions. IOW, the ABI of a "system" function is (bold part is new in this PR): - "stdcall" for win32 targets **for non-variadic functions** - "C" for everything else This had been previously stabilized *without FCP* in https://github.com/rust-lang/rust/pull/116161, which got reverted in https://github.com/rust-lang/rust/pull/136897. There was also a "fun" race condition involved with the system ABI being [added](https://github.com/rust-lang/rust/pull/119587) to the list of variadic-supporting ABIs between the creation and merge of rust-lang/rust#116161. There was a question raised [here](https://github.com/rust-lang/rust/pull/116161#issuecomment-1983829513) whether t-lang even needs to be involved for a change like this. Not sure if that has meanwhile been clarified? The behavior of the "system" ABI (a Rust-specific ABI) definitely feels like t-lang territory to me. Fixes rust-lang/rust#100189 Cc `@rust-lang/lang` # Stabilization report > ## General design > ### What is the RFC for this feature and what changes have occurred to the user-facing design since the RFC was finalized? AFAIK there is no RFC. The tracking issues are - https://github.com/rust-lang/rust/issues/100189 - https://github.com/rust-lang/rust/issues/136946 > ### What behavior are we committing to that has been controversial? Summarize the major arguments pro/con. The only controversial point is whether "system" ABI functions should support variadics. - Pro: This allows crates like windows-rs to consistently use "system", see e.g. https://github.com/microsoft/windows-rs/issues/3626. - Cons: `@workingjubilee` had some implementation concerns, but I think those have been [resolved](https://github.com/rust-lang/rust/issues/136946#issuecomment-2967847553). EDIT: turns out Jubilee still has concerns (she mentioned that in a DM); I'll let her express those. Note that "system" is already a magic ABI we introduced to "do the right thing". This just makes it do the right thing in more cases. In particular, it means that on Windows one can almost always just do ```rust extern "system" { // put all the things here } ``` and it'll do the right thing, rather than having to split imports into non-varargs and varargs, with the varargs in a separate `extern "C"` block (and risking accidentally putting a non-vararg there). (I am saying "almost" always because some Windows API functions actually use cdecl, not stdcall, on x86. Those of course need to go in `extern "C"` blocks.) > ### Are there extensions to this feature that remain unstable? How do we know that we are not accidentally committing to those? Actually defining variadic functions in Rust remains unstable, under the [c_variadic feature gate](https://github.com/rust-lang/rust/issues/44930). > ## Has a Call for Testing period been conducted? If so, what feedback was received? > > Does any OSS nightly users use this feature? For instance, a useful indication might be "search <grep.app> for `#![feature(FEATURE_NAME)]` and had `N` results". There was no call for testing. A search brings up https://github.com/rust-osdev/uefi-rs/blob/main/uefi-raw/src/table/boot.rs using this for "efiapi". This doesn't seem widely used, but it is an "obvious" gap in our support for c-variadics. > ## Implementation quality All rustc does here is forward the ABI to LLVM so there's lot a lot to say here... > ### Summarize the major parts of the implementation and provide links into the code (or to PRs) > > An example for async closures: <https://rustc-dev-guide.rust-lang.org/coroutine-closures.html>. The check for allowed variadic ABIs is [here](https://github.com/rust-lang/rust/blob/9c870d30e2d6434c9e9a004b450c5ccffdf3d844/compiler/rustc_hir_analysis/src/lib.rs#L109-L126). The special handling of "system" is [here](https://github.com/rust-lang/rust/blob/c24914ec8329b22ec7bcaa6ab534a784b2bd8ab9/compiler/rustc_target/src/spec/abi_map.rs#L82-L85). > ### Summarize existing test coverage of this feature > > Consider what the "edges" of this feature are. We're particularly interested in seeing tests that assure us about exactly what nearby things we're not stabilizing. > > Within each test, include a comment at the top describing the purpose of the test and what set of invariants it intends to demonstrate. This is a great help to those reviewing the tests at stabilization time. > > - What does the test coverage landscape for this feature look like? > - Tests for compiler errors when you use the feature wrongly or make mistakes? > - Tests for the feature itself: > - Limits of the feature (so failing compilation) > - Exercises of edge cases of the feature > - Tests that checks the feature works as expected (where applicable, `//@ run-pass`). > - Are there any intentional gaps in test coverage? > > Link to test folders or individual tests (ui/codegen/assembly/run-make tests, etc.). Prior PRs add a codegen test for all ABIs and tests actually calling extern variadic functions for sysv64 and win64: - https://github.com/rust-lang/rust/pull/144359 - https://github.com/rust-lang/rust/pull/144379 We don't have a way of executing uefi target code in the test suite, so it's unclear how to fully test efiapi. aapcs could probably be done? (But note that we have hardly an such actually-calling-functions tests for ABI things, we almost entirely rely on codegen tests.) The test ensuring that we do *not* stabilize *defining* c-variadic functions is `tests/ui/feature-gates/feature-gate-c_variadic.rs`. > ### What outstanding bugs in the issue tracker involve this feature? Are they stabilization-blocking? None that I am aware of. > ### What FIXMEs are still in the code for that feature and why is it ok to leave them there? None that I am aware of. > ### Summarize contributors to the feature by name for recognition and assuredness that people involved in the feature agree with stabilization `@Soveu` added sysv64, win64, efiapi, aapcs to the list of ABIs that allow variadics, `@beepster4096` added system. `@workingjubilee` recently refactored the ABI handling in the compiler, also affecting this feature. > ### Which tools need to be adjusted to support this feature. Has this work been done? > > Consider rustdoc, clippy, rust-analyzer, rustfmt, rustup, docs.rs. Maybe RA needs to be taught about the new allowed ABIs? No idea how precisely they mirror what exactly rustc accepts and rejects here. > ## Type system and execution rules > ### What compilation-time checks are done that are needed to prevent undefined behavior? > > (Be sure to link to tests demonstrating that these tests are being done.) Nothing new here, this just expands the existing support for calling variadic functions to more ABIs. > ### Does the feature's implementation need checks to prevent UB or is it sound by default and needs opt in in places to perform the dangerous/unsafe operations? If it is not sound by default, what is the rationale? Nothing new here, this just expands the existing support for calling variadic functions to more ABIs. > ### Can users use this feature to introduce undefined behavior, or use this feature to break the abstraction of Rust and expose the underlying assembly-level implementation? (Describe.) Nothing new here, this just expands the existing support for calling variadic functions to more ABIs. > ### What updates are needed to the reference/specification? (link to PRs when they exist) - https://github.com/rust-lang/reference/pull/1936 > ## Common interactions > ### Does this feature introduce new expressions and can they produce temporaries? What are the lifetimes of those temporaries? No. > ### What other unstable features may be exposed by this feature? None.
2025-09-02Auto merge of #145951 - lcnr:proof-tree-as-query, r=compiler-errorsbors-441/+331
cleanup and cache proof tree building There's some cruft left over from when we had deep proof trees. We never encounter overflow when evaluating proof trees. Even if the recursion limit is `0`, we still only hit the overflow limit when evaluating nested goals of the root. The root goal simply inherits the `root_depth` of the `SearchGraph`. Split `evaluate_root_goal_for_proof_tree` from the rest of the trait solver. This enables us to simplify the implementation of `evaluate_goal_raw` and the `ProofTreeBuilder` as we no longer need to manually track the state of the builder and can instead use separate types for that. It does require making a few internal methods into associated functions taking a `delegate` and a `span` instead of the `EvalCtxt` itself. I've also split `SearchGraph::evaluate_goal` and `SearchGraph::evaluate_root_goal_for_proof_tree` for the same reason. Both functions don't actually share too much code, so by splitting them each version gets significantly easier to read. Add a `query evaluate_root_goal_for_proof_tree_raw` to cache proof tree building. This requires arena allocating `inspect::Probe`. I've added a new type alias `I::ProbeRef` for this. We may need to adapt this for rust-analyzer? It would definitely be easy to remove the `Copy` bound here :thinking:
2025-09-02Revert introduction of `[workspace.dependencies]`.Nicholas Nethercote-158/+160
This was done in #145740 and #145947. It is causing problems for people using r-a on anything that uses the rustc-dev rustup package, e.g. Miri, clippy. This repository has lots of submodules and subtrees and various different projects are carved out of pieces of it. It seems like `[workspace.dependencies]` will just be more trouble than it's worth.
2025-09-02stabilize extended_varargs_abi_supportRalf Jung-47/+55
2025-09-01fix(lexer): Only allow horizontal whitespace in frontmatterEd Page-6/+21
In writing up the reference for frontmatter, I realized that we probably shouldn't be accepting Unicode Line Ending characters between the code fence and infostring or trailing after the infostring or a code fence. In digging into the unicode specification we use for Whitespace, it divides it up into categories, so I'm deferring to what it says for horizontal whitespace for what should be used within a line. Note, I am leaving out support for Unicde Default Ignorable characters. I figure that can be discussed outside of this change within the reference and tracking issue.
2025-09-01docs(lexer): Organize and document whitespace by Pattern_White_SpaceEd Page-12/+10
2025-09-02Auto merge of #146059 - folkertdev:va-end-lifetime, r=saethlinbors-3/+9
explicitly end the lifetime of `va_list` tracking issue: https://github.com/rust-lang/rust/issues/44930 split out from: https://github.com/rust-lang/rust/pull/144549 The `va_list` is created in the compiler itself when the variable argument list `...` is desugared, and hence the lifetime end is not inserted automatically. The value can't outlive the function in which it was created, so it is correct to end the lifetime here. Ending the lifetime explicitly also appears to give slightly better codegen in https://github.com/rust-lang/rust/pull/144549. I also included a little drive-by improvement to not cast pointers to integers and back again. r? codegen
2025-09-01Auto merge of #145925 - lcnr:revealing-use-closures-2, r=BoxyUwUbors-203/+466
`-Znext-solver`: support non-defining uses in closures Cleaned up version of rust-lang/rust#139587, finishing the implementation of https://github.com/rust-lang/types-team/issues/129. This does not affect stable. The reasoning for why this is the case is subtle however. ## What does it do We split `do_mir_borrowck` into `borrowck_collect_region_constraints` and `borrowck_check_region_constraints`, where `borrowck_collect_region_constraints` returns an enormous `CollectRegionConstraintsResult` struct which contains all the relevant data to actually handle opaque type uses and to check the region constraints later on. `query mir_borrowck` now simply calls `BorrowCheckRootCtxt::do_mir_borrowck` which starts by iterating over all nested bodies of the current function - visiting nested bodies before their parents - and computing their `CollectRegionConstraintsResult`. After we've collected all constraints it's time to actually compute the concrete types for the opaques defined by this function. With this PR we now compute the concrete types of opaques for each body before using them to check the non-defining uses of any of them. After we've computed the concrete types by using all bodies, we use `apply_computed_concrete_opaque_types` for each body to constrain non-defining uses, before finally finishing with `borrowck_check_region_constraints`. We always visit nested bodies before their parents when doing this. ## `ClosureRegionRequirements` As we only call `borrowck_collect_region_constraints` for nested bodies before type checking the parent, we can't simply use the final `ClosureRegionRequirements` of the nested body during MIR type check. We instead track that we need to apply these requirements in `deferred_closure_requirements`. We now manually apply the final closure requirements to each body after handling opaque types. This works, except that we may need the region constraints of nested bodies to successfully define an opaque type in the parent. This is handled by using a new `fn compute_closure_requirements_modulo_opaques` which duplicates region checking - while ignoring any errors - before we've added the constraints from `apply_computed_concrete_opaque_types`. This is necessary for a lot of async tests, as pretty much the entire function is inside of an async block while the opaque type gets defined in the parent. As an performance optimization we only use `fn compute_closure_requirements_modulo_opaques` in case the nested body actually depends on any opaque types. Otherwise we eagerly call `borrowck_check_region_constraints` and apply the final closure region requirements right away. ## Impact on stable code Handling the opaque type uses in the parent function now only uses the closure requirements *modulo opaques*, while it previously also considered member constraints from nested bodies. `External` regions are never valid choice regions. Also, member constraints will never constrain a member region if it is required to be outlived by an external region, as that fails the upper-bound check. https://github.com/rust-lang/rust/blob/564ee219127b796d56f74767366fd359758b97de/compiler/rustc_borrowck/src/region_infer/opaque_types/member_constraints.rs#L90-L96 Member constraints therefore never add constraints for external regions :> r? `@BoxyUwU`
2025-09-01use defining uses of all bodies to constrain non-defining useslcnr-202/+461
support non-defining uses in closures
2025-09-01Remove dead code stemming from an old effects desugaringLeón Orell Valerian Liehr-20/+12
2025-09-01Auto merge of #145721 - dpaoliello:ar050, r=bjorn3bors-53/+79
Update to ar_archive_writer 0.5 This updates `ar_archive_writer` to 0.5, which in turn was updated to match LLVM 20.1.8: <https://github.com/rust-lang/ar_archive_writer/pull/24> As part of this, I refactored part of `SymbolWrapper.cpp` to pull common code that I was about to duplicate again into a new function. NOTE: `ar_archive_writer` does include a breaking change where it no longer supports mangling C++ mangled names for Arm64EC. Since we don't need the mangled name (it's not the "exported name" which we're trying to load from the external dll), I'm setting the `import_name` when building for Arm64EC to prevent error when failing to mangle. r? `@bjorn3`
2025-09-01Make `Parser::parse_for_head` public for rustfmt usageMoritz Hedtke-1/+2
2025-09-01Auto merge of #144783 - folkertdev:loop-match-diverging-loop, r=SparrowLiibors-4/+6
fix `#[loop_match]` on diverging loop tracking issue: https://github.com/rust-lang/rust/issues/132306 fixes https://github.com/rust-lang/rust/issues/144492 fixes https://github.com/rust-lang/rust/issues/144493 fixes https://github.com/rust-lang/rust/issues/144781 this generated invalid MIR before. issue https://github.com/rust-lang/rust/issues/143806 still has an issue where we assign `state = state` which is invalid in MIR. Fixing that problem is tricky, so I'd like to do that separately. r? `@bjorn3`
2025-09-01Auto merge of #143290 - azhogin:azhogin/link-pub-async-impls, r=oli-obkbors-1/+14
pub async fn impl is monomorphized when func itself is monomorphized Implentation coroutine (`func::{closure#0}`) is monomorphized, when func itself is monomorphized. Currently, when `pub async fn foo(..)` is exported from lib and used in several dependent crates, only 'header' function is monomorphized in the defining crate. 'header' function, returning coroutine object, is monomorphized, but the coroutine's poll function (which actually implements all the logic for the function) is not. In such situation, `func::{closure#0}` will be monomorphized in every dependency. This PR adds monomorphization for `func::{closure#0}` (coroutine poll function), when func itself is monomorphized. Simple test with one lib async function and ten dependent crates (executable) that use the function, shows 5-7% compilation time improvement (single-threaded).
2025-09-01Auto merge of #146077 - Zalathar:rollup-l7ip5yi, r=Zalatharbors-162/+225
Rollup of 5 pull requests Successful merges: - rust-lang/rust#145468 (dedup recip, powi, to_degrees, and to_radians float tests) - rust-lang/rust#145643 (coverage: Build an "expansion tree" and use it to unexpand raw spans) - rust-lang/rust#145754 (fix(lexer): Don't require frontmatters to be escaped with indented fences) - rust-lang/rust#146060 (fixup nix dev shell again) - rust-lang/rust#146068 (compiletest: Capture panic messages via a custom panic hook) r? `@ghost` `@rustbot` modify labels: rollup
2025-09-01Rollup merge of #145754 - epage:escape, r=SparrowLiiStuart Cook-21/+13
fix(lexer): Don't require frontmatters to be escaped with indented fences The RFC only limits hyphens at the beginning of lines and not if they are indented or embedded in other content. Sticking to that approach was confirmed by the T-lang liason at https://github.com/rust-lang/rust/issues/141367#issuecomment-3202217544 There is a regression in error message quality which I'm leaving for someone if they feel this needs improving. Tracking issue: rust-lang/rust#136889 Fixes rust-lang/rust#141367
2025-09-01Rollup merge of #145643 - Zalathar:tree, r=SparrowLiiStuart Cook-141/+212
coverage: Build an "expansion tree" and use it to unexpand raw spans Historically and currently, coverage instrumentation assumes that all of a function's spans are in the same file and have the same syntax context. The spans extracted directly from MIR don't satisfy that assumption, so there is an “unexpansion” step that walks up each span's expansion-call-site tree to find a suitable span in the same context as the function's body span. (That unexpansion step is what allows us to have somewhat reasonable coverage instrumentation for macros like `println!`, and for syntax like `for` and `?` that undergo desugaring expansion.) The current unexpansion code mostly works fine in that “flat” single-file single-context world. But it's not suitable for incremental work towards proper expansion-aware coverage instrumentation, which would allow a function's coverage spans to encompass multiple expansion contexts and multiple files. This PR therefore replaces the current unexpansion code with a more sophisticated system that uses the raw MIR spans to reconstruct an “expansion tree”, and then uses that tree to help perform most of the unexpansion work. Building the tree is “overkill” for current unexpansion needs (though it does give some minor edge-case improvements), but my hope is that having the explicit tree available will be a big help when taking the next steps towards proper expansion-region support.
2025-09-01pub async fn implementation coroutine (func::{closure#0}) is monomorphized, ↵Andrew Zhogin-1/+14
when func itself is monomorphized
2025-09-01Add compiler error when trying to use concat metavar expr in repetitionsjullang-1/+6
Replace unimplemented()! with a more helpful compiler error.
2025-09-01Auto merge of #146072 - Zalathar:rollup-0svnrfe, r=Zalatharbors-587/+583
Rollup of 6 pull requests Successful merges: - rust-lang/rust#145421 (`dump_mir` cleanups) - rust-lang/rust#145968 (Add `Bound::copied`) - rust-lang/rust#146004 (resolve: Refactor `struct ExternPreludeEntry`) - rust-lang/rust#146042 (Detect negative literal inferred to unsigned integer) - rust-lang/rust#146046 (Suggest method name with maybe ty mismatch) - rust-lang/rust#146051 (Change std f32 test to pass under Miri) r? `@ghost` `@rustbot` modify labels: rollup
2025-09-01Rollup merge of #146046 - ↵Stuart Cook-1/+1
chenyukang:yukang-fix-method-exists-for-ret-ty-error, r=estebank Suggest method name with maybe ty mismatch Fixes rust-lang/rust#146008 I think it's ok to suggest method name even when the return ty mismatch, since we only reporting in `Applicability::MaybeIncorrect`, user may add `()` and continue to fix following errors. r? ```@estebank```
2025-09-01Rollup merge of #146042 - estebank:issue-83413, r=lcnrStuart Cook-27/+65
Detect negative literal inferred to unsigned integer ``` error[E0277]: the trait bound `usize: Neg` is not satisfied --> $DIR/negative-literal-infered-to-unsigned.rs:2:14 | LL | for x in -5..5 { | ^^ the trait `Neg` is not implemented for `usize` | help: consider specifying an integer type that can be negative | LL | for x in -5isize..5 { | +++++ ``` Applying this suggestion will always end up in another E0308 error at the point where the unsigned inference comes from, which should help with understanding what the actual problem is. Fix rust-lang/rust#83413.
2025-09-01Rollup merge of #146004 - petrochenkov:epentry, r=nnethercoteStuart Cook-53/+56
resolve: Refactor `struct ExternPreludeEntry` Avoid impossible combinations of fields and apply the first part of https://github.com/rust-lang/rust/pull/144737 (do not resolve erroneous entries repeatedly, keep them as `PendingBinding::Ready(None)` instead).
2025-09-01Auto merge of #145663 - Kobzol:bootstrap-test, r=jieyouxubors-4/+7
Enforce in bootstrap that test must have stage at least 1 (except for compiletest) This PR cleans up a bunch of test steps and adds metadata to them. I didn't yet touch the most complicated step (`CompileTest`), I'm leaving that for another PR. Testing anything on stage 0 is only possible for compiletest and with `build.allow-compiletest-stage0`. Testing anything else on stage 0 will either produce a nice error or crash with a stage being subtracted below zero. r? `@jieyouxu` try-job: dist-x86_64-linux try-job: aarch64-gnu try-job: arm-android try-job: `x86_64-gnu-llvm-20*` try-job: `x86_64-msvc-*` try-job: aarch64-apple try-job: test-various
2025-09-01Introduce `MirDumper` and `MirWriter`.Nicholas Nethercote-276/+275
MIR dumping is a mess. There are lots of functions and entry points, e.g. `dump_mir`, `dump_mir_with_options`, `dump_polonius_mir`, `dump_mir_to_writer`. Also, it's crucial that `create_dump_file` is never called without `dump_enabled` first being checked, but there is no mechanism for ensuring this and it's hard to tell if it is satisfied on all paths. (`dump_enabled` is checked twice on some paths, however!) This commit introduces `MirWriter`, which controls the MIR writing, and encapsulates the `extra_data` closure and `options`. Two existing functions are now methods of this type. It sets reasonable defaults, allowing the removal of many `|_, _| Ok(())` closures. The commit also introduces `MirDumper`, which is layered on top of `MirWriter`, and which manages the creation of the dump files, encapsulating pass names, disambiguators, etc. Four existing functions are now methods of this type. - `MirDumper::new` will only succeed if dumps are enabled, and will return `None` otherwise, which makes it impossible to dump when you shouldn't. - It also sets reasonable defaults for various things like disambiguators, which means you no longer need to specify them in many cases. When they do need to be specified, it's now done via setter methods. - It avoids some repetition. E.g. `dump_nll_mir` previously specifed the pass name `"nll"` four times and the disambiguator `&0` three times; now it specifies them just once, to put them in the `MirDumper`. - For Polonius, the `extra_data` closure can now be specified earlier, which avoids having to pass some arguments through some functions.
2025-09-01Indent some functions.Nicholas Nethercote-322/+322
This commit exists purely to simplify reviewing: these functions will become methods in the next commit. This commit indents them so that the next commit is more readable.
2025-09-01Use trait object references for closures.Nicholas Nethercote-59/+39
The dynamic dispatch cost doesn't matter for MIR dumping, which is perf-insensitive. And it's necessary for the next commit, which will store some `extra_data` closures in a struct.
2025-09-01Avoid unnecessary `mut`-ness for various closures.Nicholas Nethercote-16/+16
2025-09-01Inline and remove `dump_mir_for_pass`.Nicholas Nethercote-16/+6
The code is more readable without it.
2025-09-01Inline and remove `dump_matched_mir_node`.Nicholas Nethercote-25/+11
It has a single call site.
2025-08-31Split `ObligationCauseCode::BinOp` for unops to `UnOp`Esteban Küber-28/+27
2025-08-31explicitly end `va_list` lifetimeFolkert de Vries-0/+3
2025-08-31round pointer to alignment without going via intFolkert de Vries-3/+6
2025-08-31Rollup merge of #145592 - nilotpal-n7:fix-format-alignment, r=lcnrMatthias Krüger-1/+3
Fix format string grammar in docs and improve alignment error message for #144023 This PR improves error messages and documentation for format strings involving alignment and formatting traits. Highlights: - Clearer error messages for invalid alignment specifiers (e.g., `{0:#X>18}`), showing the expected `<`, `^`, or `>` and a working example: println!("{0:>#18X}", value); - Updated UI test `format-alignment-hash.rs` to reflect the improved error output. - Documentation clarification: ensures examples correctly show how width, alignment, and traits like `x`, `X`, `#` combine. Motivation: Previously, using `#` with alignment and width produced confusing errors. This PR guides users on the correct syntax and provides actionable examples. Testing: - Built the compiler (`./x build`) - Blessed and ran UI tests (`./x. test src/test/ui/fmt/format-alignment-hash.rs --bless`) - Verified full test suite passes (`./x test`) Issue: rust-lang/rust#144023
2025-08-31Rollup merge of #144443 - WaffleLapkin:integer-target-pointer-width, r=NoratriebMatthias Krüger-21/+16
Make target pointer width in target json an integer r? Noratrieb cc `@RalfJung` (https://github.com/rust-lang/rust/pull/142352/files#r2230380120) try-job: x86_64-rust-for-linux
2025-08-31Auto merge of #145582 - estebank:issue-107806, r=chenyukangbors-0/+97
Detect missing `if let` or `let-else` During `let` binding parse error and encountering a block, detect if there is a likely missing `if` or `else`: ``` error: expected one of `.`, `;`, `?`, `else`, or an operator, found `{` --> $DIR/missing-if-let-or-let-else.rs:14:25 | LL | let Some(x) = foo() { | ^ expected one of `.`, `;`, `?`, `else`, or an operator | help: you might have meant to use `if let` | LL | if let Some(x) = foo() { | ++ help: alternatively, you might have meant to use `let else` | LL | let Some(x) = foo() else { | ++++ ``` Fix rust-lang/rust#107806.
2025-08-31suggest method name with maybe ty mismatchyukang-1/+1
2025-08-30Detect negative literal inferred to unsigned integerEsteban Küber-1/+40
``` error[E0277]: the trait bound `usize: Neg` is not satisfied --> $DIR/negative-literal-infered-to-unsigned.rs:2:14 | LL | for x in -5..5 { | ^^ the trait `Neg` is not implemented for `usize` | help: consider specifying an integer type that can be negative | LL | for x in -5isize..5 { | +++++ ```
2025-08-30review comment: move `Visitor`Esteban Küber-27/+29
2025-08-30Update target spec metadata of Arm64EC Windows and Trusty targetsTaiki Endo-5/+5
2025-08-30Explicity disable LSX feature for `loongarch64-unknown-none` targetWANG Rui-1/+1
The `loongarch64-unknown-none` target is a bare-metal target with hardware floating-point support and should not enable SIMD extensions by default. However, LLVM's LoongArch64 backend enables LSX implicitly, inadvertently activating SIMD instructions for this target. This patch explicitly disable LSX feature to prevent unintended SIMD usage.