about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2025-06-29mir: Add a `new` method to `statement`dianqk-330/+295
Avoid introducing a large number of changes when adding optional initialization fields.
2025-06-29Auto merge of #143173 - matthiaskrgr:rollup-ieu5k05, r=matthiaskrgrbors-67/+121
Rollup of 11 pull requests Successful merges: - rust-lang/rust#142021 (Doc: clarify priority of lint level sources) - rust-lang/rust#142367 (Add regression test for rust-lang/rust#137857 to ensure that we generate intra doc links for extern crate items.) - rust-lang/rust#142641 (Generate symbols.o for proc-macros too) - rust-lang/rust#142889 (Clarify doc comment on unix OpenOptions) - rust-lang/rust#143063 (explain `ImportData::imported_module`) - rust-lang/rust#143088 (Improve documentation of `TagEncoding`) - rust-lang/rust#143135 (fix typos on some doc comments) - rust-lang/rust#143138 (Port `#[link_name]` to the new attribute parsing infrastructure) - rust-lang/rust#143155 (`librustdoc` house-keeping đŸ§č) - rust-lang/rust#143169 (Remove unused feature gates) - rust-lang/rust#143171 (Fix the span of trait bound modifier `[const]`) r? `@ghost` `@rustbot` modify labels: rollup
2025-06-29Rollup merge of #143171 - fmease:fix-span-of-maybe-const-mod, r=compiler-errorsMatthias KrĂŒger-1/+1
Fix the span of trait bound modifier `[const]` r? project-const-traits or anyone
2025-06-29Rollup merge of #143169 - yotamofek:pr/unneeded-features, r=compiler-errorsMatthias KrĂŒger-7/+0
Remove unused feature gates After finding some unused feature gates in rust-lang/rust#143155 , I wrote a small script to see if I can find any others. And I did. Not a lot, but still a small win 😁 Contains a few instances of `iter_from_coroutine` that can be removed due to rust-lang/rust#142801 (I guess).
2025-06-29Rollup merge of #143138 - JonathanBrouwer:link_name_parser, r=jdonszelmannMatthias KrĂŒger-24/+67
Port `#[link_name]` to the new attribute parsing infrastructure Ports `link_name` to the new attribute parsing infrastructure for https://github.com/rust-lang/rust/issues/131229#issuecomment-2971353197 r? `@jdonszelmann`
2025-06-29Rollup merge of #143135 - tshepang:typos, r=compiler-errorsMatthias KrĂŒger-2/+2
fix typos on some doc comments
2025-06-29Rollup merge of #143088 - firefighterduck:improve-doc-discr-tag, r=RalfJungMatthias KrĂŒger-30/+36
Improve documentation of `TagEncoding` This PR is follow-up from the [discussion here](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/.E2.9C.94.20VariantId.3DDiscriminant.20when.20tag.20is.20niche.20encoded.3F/with/524384295). It aims at making the `TagEncoding` documentation less ambiguous and more detailed with references to relevant implementation sides. It especially clears up the ambiguous use of discriminant/variant index, which sparked the discussion referenced above. PS: While working with layout data, I somehow ended up looking at the docs for `FakeBorrowKind` and noticed that the one example was not in a doc comment. I hope that this is minor enough of a fix for it to be okay in this otherwise unrelated PR.
2025-06-29Rollup merge of #143063 - bvanjoi:docs-resolve, r=petrochenkovMatthias KrĂŒger-1/+8
explain `ImportData::imported_module` r? `@petrochenkov`
2025-06-29Rollup merge of #142641 - bjorn3:proc_macro_symbols_o, r=jieyouxuMatthias KrĂŒger-2/+7
Generate symbols.o for proc-macros too To ensure used statics are functioning correctly for proc-macros too.
2025-06-29Auto merge of #143161 - GuillaumeGomez:subtree-update_cg_gcc_2025-06-28, ↔bors-117/+150
r=GuillaumeGomez GCC backend subtree update cc `@antoyo` r? ghost
2025-06-29Fix the span of trait bound modifier `[const]`LeĂłn Orell Valerian Liehr-1/+1
2025-06-28Remove unused feature gatesYotam Ofek-7/+0
2025-06-29Remove `()` returned valueGuillaume Gomez-1/+1
2025-06-28Auto merge of #143157 - matthiaskrgr:rollup-90rtm3a, r=matthiaskrgrbors-101/+69
Rollup of 9 pull requests Successful merges: - rust-lang/rust#123476 (std::net: adding `unix_socket_exclbind` feature for solaris/illumos.) - rust-lang/rust#142708 (Do not include NUL-terminator in computed length) - rust-lang/rust#142963 (Skip unnecessary components in x64 try builds) - rust-lang/rust#142987 (rustdoc: show attributes on enum variants) - rust-lang/rust#143031 (Add windows-gnullvm hosts to the manifest) - rust-lang/rust#143082 (update internal `send_signal` comment) - rust-lang/rust#143110 (Use tidy to sort `sym::*` items) - rust-lang/rust#143111 (BTreeSet: remove duplicated code by reusing `from_sorted_iter`) - rust-lang/rust#143114 (Minor Documentation Improvements) r? `@ghost` `@rustbot` modify labels: rollup try-job: dist-i586-gnu-i586-i686-musl
2025-06-29Fix signature of `filter_landing_pad`Guillaume Gomez-2/+2
2025-06-28Remove unwanted semi-colon in `rustc_codegen_gcc`Guillaume Gomez-1/+1
2025-06-28Merge commit 'b7091eca6d8eb0fe88b58cc9a7aec405d8de5b85' into ↔Guillaume Gomez-117/+150
subtree-update_cg_gcc_2025-06-28
2025-06-28Rollup merge of #143110 - yotamofek:pr/tidy-sort-for-symbols, r=nnethercoteMatthias KrĂŒger-94/+64
Use tidy to sort `sym::*` items Use tidy to sort the symbols in the invocation of `symbols!`, instead of implementing the ordering check inside the proc macro. (asked `````@nnethercote````` about this on zulip, he didn't have any reservations about making this change) This has a couple of benefits: - tidy's "version sort" (thanks to rust-lang/rust#141311 !) is nicer than the naive-cmp sort, so, e.g. `AtomicI{8, 16, 32, 64, 128}` are properly sorted by bit width. - consistency with the rest of the repo - allows us to remove a bit of order-verifying code from the `symbols!` proc macro impl
2025-06-28Rollup merge of #142708 - Darksonn:location-len-without-nul, r=Mark-SimulacrumMatthias KrĂŒger-7/+5
Do not include NUL-terminator in computed length This PR contains just the first commit of rust-lang/rust#142579 which changes it so that the string length stored in the `Location` is the length of the `&str` rather than the length of the `&CStr`. Since most users will want the `&str` length, it seems better to optimize for that use-case. There should be no visible changes in the behavior or API.
2025-06-28Auto merge of #142625 - cjgillot:inline-nocycle, r=oli-obkbors-134/+158
Only compute recursive callees once. Inlining MIR in a cyclic call graph may create query cycles, which are ICEs. The current implementation `mir_callgraph_reachable(inlining_candidate, being_optimized)` checks if calling `inlining_candidate` may cycle back to `being_optimized` that we are currently inlining into. This PR replaces this device with query `mir_callgraph_cyclic(being_optimized)` which searches the call graph for all cycles going back to `being_optimized`, and returns the set of functions involved in those cycles. This is a tradeoff: - in the current implementation, we perform more walks, but shallower; - in this new implementation, we perform fewer walks, but exhaust the graph. I'd have liked to compute this using some kind of SCC, but generic parameters make resolution path-dependent, so usual graph algorithms do not apply.
2025-06-29explain `ImportData::imported_module`bohan-1/+8
2025-06-28Auto merge of #142317 - compiler-errors:perf-fold, r=lcnrbors-0/+11
Don't fold in Instantiate when there's nothing to fold Maybe this helps idk r? lcnr
2025-06-28move discr=varid check to layout_sanity_checkFlorian Sextl-13/+10
2025-06-28fix docs of FakeBorrowKindFlorian Sextl-14/+14
2025-06-28improve TagEncoding docsFlorian Sextl-12/+21
2025-06-28Port `#[link_name]` to the new attribute parsing infrastructureJonathan Brouwer-24/+67
Co-authored-by: Anne Stijns <anstijns@gmail.com> Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-06-28fix typos on some doc commentsTshepang Mbambo-2/+2
2025-06-28Auto merge of #141759 - 1c3t3a:discriminants-query, r=saethlinbors-2/+553
Insert checks for enum discriminants when debug assertions are enabled Similar to the existing null-pointer and alignment checks, this checks for valid enum discriminants on creation of enums through unsafe transmutes. Essentially this sanitizes patterns like the following: ```rust let val: MyEnum = unsafe { std::mem::transmute<u32, MyEnum>(42) }; ``` An extension of this check will be done in a follow-up that explicitly sanitizes for extern enum values that come into Rust from e.g. C/C++. This check is similar to Miri's capabilities of checking for valid construction of enum values. This PR is inspired by saethlin@'s PR https://github.com/rust-lang/rust/pull/104862. Thank you so much for keeping this code up and the detailed comments! I also pair-programmed large parts of this together with vabr-g@. r? `@saethlin`
2025-06-28Use tidy to sort `sym::*` itemsYotam Ofek-94/+64
2025-06-27Auto merge of #143116 - matthiaskrgr:rollup-zy9ez06, r=matthiaskrgrbors-289/+309
Rollup of 9 pull requests Successful merges: - rust-lang/rust#139858 (New const traits syntax) - rust-lang/rust#140809 (Reduce special casing for the panic runtime) - rust-lang/rust#142730 (suggest declaring modules when file found but module not defined) - rust-lang/rust#142806 (Normalize before computing ConstArgHasType goal in new solver) - rust-lang/rust#143046 (const validation: properly ignore zero-sized UnsafeCell) - rust-lang/rust#143092 (const checks for lifetime-extended temporaries: avoid 'top-level scope' terminology) - rust-lang/rust#143096 (tag_for_variant: properly pass TypingEnv) - rust-lang/rust#143104 (hir_analysis: prohibit `dyn PointeeSized`) - rust-lang/rust#143106 (gce: don't ICE on non-local const) Failed merges: - rust-lang/rust#143036 (Remove support for `dyn*` from the compiler) r? `@ghost` `@rustbot` modify labels: rollup
2025-06-27Rollup merge of #143106 - yotamofek:pr/gce/non-local-ice, r=BoxyUwUMatthias KrĂŒger-1/+3
gce: don't ICE on non-local const Fixes rust-lang/rust#133808 I have absolutely no idea what I'm doing here, but I followed `@BoxyUwU` 's [instructions](https://github.com/rust-lang/rust/issues/133808#issuecomment-3009122957), and turns out this small change fixes rust-lang/rust#133808, and doesn't seem to break anything else. (This code path is only reachable when the GCE feature gate is enabled, so even if it does break in a way that is not caught by current test coverage, I guess it's not as bad as breaking stable or non-incomplete features?) Anyways, r? `@BoxyUwU` , if you don't mind.
2025-06-27Rollup merge of #143104 - davidtwco:issue-142652-dyn-pointeesized-deny, ↔Matthias KrĂŒger-2/+24
r=compiler-errors hir_analysis: prohibit `dyn PointeeSized` Fixes rust-lang/rust#142652 Supersedes rust-lang/rust#142663 `dyn PointeeSized` is nonsensical as a `dyn PointeeSized` needs to be `MetaSized`, so lets reject it to avoid hitting code paths that expect a builtin impl for `PointeeSized` r? `@compiler-errors`
2025-06-27Rollup merge of #143096 - RalfJung:tag_for_variant, r=compiler-errorsMatthias KrĂŒger-11/+8
tag_for_variant: properly pass TypingEnv Hard-coding `fully_monomorphized` here does not seem right... This came up [on Zulip](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/.E2.9C.94.20VariantId.3DDiscriminant.20when.20tag.20is.20niche.20encoded.3F/with/526103956).
2025-06-27Rollup merge of #143092 - RalfJung:const-check-lifetime-ext, r=oli-obkMatthias KrĂŒger-35/+19
const checks for lifetime-extended temporaries: avoid 'top-level scope' terminology This error recently got changed in https://github.com/rust-lang/rust/pull/140942 to use the terminology of "top-level scope", but after further discussion in https://github.com/rust-lang/reference/pull/1865 it seems the reference will not be using that terminology after all. So let's also remove it from the compiler again, and let's focus on what actually happens with these temporaries: their lifetime is extended until the end of the program. r? ``@oli-obk`` ``@traviscross``
2025-06-27Rollup merge of #143046 - RalfJung:zst-unsafe-cell, r=lcnr,oli-obkMatthias KrĂŒger-18/+23
const validation: properly ignore zero-sized UnsafeCell Fixes https://github.com/rust-lang/rust/issues/142948 r? `@oli-obk`
2025-06-27Rollup merge of #142806 - compiler-errors:norm-ct-has-ty, r=lcnr,BoxyUwUMatthias KrĂŒger-0/+1
Normalize before computing ConstArgHasType goal in new solver This is a fix for rust-lang/rust#139905. See the description I left in the test. I chose to fix this by normalizing the type before matching on its `.kind()` in `compute_const_arg_has_type_goal` (since it feels somewhat consistent with how we normalize types before assembling their candidates, for example); however, there are several other solutions that come to mind for fixing this ICE: 1. (this solution) 2. Giving `ConstKind::Error` a proper type, like `ConstKind::Value`, so that consts don't go from failing to passing `ConstArgHasType` goals after normalization (i.e. `UNEVALUATED` would normalize into a `ConstKind::Error(_, bool)` type rather than losing its type altogether). 3. Just suppressing the errors and accepting the fact that goals can go from fail->pass after normalization. Thoughts? Happy to discuss this fix further. r? `@BoxyUwU`
2025-06-27Rollup merge of #142730 - ↔Matthias KrĂŒger-0/+51
bend-n:suggest_declaring_modules_when_file_found_but_module_not_defined, r=petrochenkov suggest declaring modules when file found but module not defined suggests declaring modules when a module is found but not defined, i.e ``` ├── main.rs: `use thing::thang;` └── thing.rs: `struct thang` ``` or ``` ├── main.rs: `use thing::thang;` └── thing └── mod.rs: `struct thang` ``` which currently is just ```rust error[E0432]: unresolved import `yeah` --> src/main.rs:1:1 | 1 | use thing::thang; | ^^^^^ use of unresolved module or unlinked crate `thing` | ``` but now would have this nice help: ```text = help: you may have forgotten to declare the module `thing`. use `mod thing` in this file to declare this module. ```
2025-06-27Rollup merge of #140809 - bjorn3:panic_runtime_cleanup, r=petrochenkovMatthias KrĂŒger-117/+57
Reduce special casing for the panic runtime See the individual commits for more info.
2025-06-27Rollup merge of #139858 - oli-obk:new-const-traits-syntax, r=fee1-deadMatthias KrĂŒger-105/+123
New const traits syntax This PR only affects the AST and doesn't actually change anything semantically. All occurrences of `~const` outside of libcore have been replaced by `[const]`. Within libcore we have to wait for rustfmt to be bumped in the bootstrap compiler. This will happen "automatically" (when rustfmt is run) during the bootstrap bump, as rustfmt converts `~const` into `[const]`. After this we can remove the `~const` support from the parser Caveat discovered during impl: there is no legacy bare trait object recovery for `[const] Trait` as that snippet in type position goes down the slice /array parsing code and will error r? ``@fee1-dead`` cc ``@nikomatsakis`` ``@traviscross`` ``@compiler-errors``
2025-06-27Auto merge of #143064 - flip1995:clippy-subtree-update, r=GuillaumeGomezbors-2/+3
Clippy subtree update r? `@Manishearth` Cargo.lock update due to version bump
2025-06-27gce: don't ICE on non-local constYotam Ofek-1/+3
2025-06-27hir_analysis: prohibit `dyn PointeeSized`David Wood-2/+24
2025-06-27Auto merge of #143091 - GuillaumeGomez:rollup-f300qwe, r=GuillaumeGomezbors-367/+348
Rollup of 10 pull requests Successful merges: - rust-lang/rust#142270 (Rustdoc js: even more typechecking improvements) - rust-lang/rust#142420 (Report infer ty errors during hir ty lowering) - rust-lang/rust#142671 (add #![rustc_no_implicit_bounds]) - rust-lang/rust#142721 (Add tracing to `InterpCx::layout_of()` ) - rust-lang/rust#142818 (Port `#[used]` to new attribute parsing infrastructure) - rust-lang/rust#143020 (codegen_fn_attrs: make comment more precise) - rust-lang/rust#143051 (Add tracing to `validate_operand`) - rust-lang/rust#143060 (Only args in main diag are saved and restored without removing the newly added ones) - rust-lang/rust#143065 (Improve recovery when users write `where:`) - rust-lang/rust#143084 (const-eval: error when initializing a static writes to that static) r? `@ghost` `@rustbot` modify labels: rollup
2025-06-27tag_for_variant: properly pass TypingEnvRalf Jung-11/+8
2025-06-27const checks: avoid 'top-level scope' terminologyRalf Jung-35/+19
2025-06-27Rollup merge of #143084 - RalfJung:const-eval-recursive-static-write, r=oli-obkGuillaume Gomez-19/+41
const-eval: error when initializing a static writes to that static Fixes https://github.com/rust-lang/rust/issues/142404 by also calling the relevant hook for writes, not just reads. To avoid erroring during the actual write of the initial value, we neuter the hook when popping the final stack frame. Calling the hook during writes requires changing its signature since we cannot pass in the entire interpreter any more. While doing this I also realized a gap in https://github.com/rust-lang/rust/pull/142575 for zero-sized copies on the read side, so I fixed that and added a test. r? `@oli-obk`
2025-06-27Rollup merge of #143065 - compiler-errors:enum-recovery, r=oli-obkGuillaume Gomez-16/+30
Improve recovery when users write `where:` Improve recovery of `where:`. Fixes https://github.com/rust-lang/rust/issues/143023 The erroneous suggestion was because we were seeing `:` then a type, which the original impl thought must be a struct field. Make this a bit more accurate by checking for a non-reserved ident (which should be a field name). Also, make a custom parser error for `where:` so we can continue parsing after the colon.
2025-06-27Rollup merge of #143060 - xizheyin:simplify-diag, r=oli-obkGuillaume Gomez-11/+5
Only args in main diag are saved and restored without removing the newly added ones cc rust-lang/rust#142724 Here's a more simplified approach, since we'll be storing and restoring the main diagnostic's arg, removing args newly added isn't needed in the derive subdiagnostic implementation. `remove_arg` is helpful only for manual implementation of subdiagnostic. r? ``@oli-obk``
2025-06-27Rollup merge of #143051 - Stypox:tracing-validity, r=RalfJungGuillaume Gomez-4/+11
Add tracing to `validate_operand` This PR adds a tracing call to keep track of how much time is spent in `validate_operand` and `const_validate_operand`. Let me know if more fine-grained tracing is needed (e.g. adding tracing to `validate_operand_internal` too, which is just called from those two functions). I also fixed the rustdoc of `validate_operand` and `const_validate_operand` since it was referencing an older name for the `val` parameter which was renamed in cbdcbf0d6a586792c5e0a0b8965a3179bac56120. Here is some tracing output when Miri is run on `src/tools/miri/tests/pass/hello.rs`, visualizable in [ui.perfetto.dev](https://ui.perfetto.dev/): [trace-1750932222218210.json](https://github.com/user-attachments/files/20924000/trace-1750932222218210.json) **Note: obtaining tracing output depends on https://github.com/rust-lang/miri/pull/4406, but this PR is standalone and can be merged without waiting for https://github.com/rust-lang/miri/pull/4406.** r? `@RalfJung`
2025-06-27Rollup merge of #143020 - RalfJung:codegen_fn_attrs, r=oli-obkGuillaume Gomez-1/+3
codegen_fn_attrs: make comment more precise Follow-up to https://github.com/rust-lang/rust/pull/142854. r? ``@oli-obk`` or ``@workingjubilee``