about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2025-08-03Remove `SHOULD_EMIT_LINTS` in favor of `should_emit`Jonathan Brouwer-4/+11
2025-08-03forbid tail calling intrinsicsWaffle Lapkin-3/+17
2025-08-04fix: Error on illegal `[const]`s inside blocks within legal positionsShoyu Vanilla-16/+55
2025-08-03Auto merge of #144732 - lcnr:ignore-shadowed-impls, r=compiler-errorsbors-3/+24
dont assemble shadowed impl candidates Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/109. I've originally intended to fix this by supporting lazy reevaluation when rerunning cycles. This ended up being really difficult, see https://github.com/lcnr/search_graph for my notes used while working on this. It is also insufficient for the `rayon-hang-2.rs` test as we end up with goals which we need to rerun for all combinations of provisional results. While landing such an optimization in the future may still be desirable, it is very difficult and insufficient to fix these hangs. Also see the relevant [zulip thread](https://rust-lang.zulipchat.com/#narrow/channel/364551-t-types.2Ftrait-system-refactor/topic/rustc-rayon.20hang/near/527850058). I was previously opposed to avoiding assembling shadowed impls as it may prevent future improvements in this area, cc rust-lang/rust#141226. Going to track this and the reasoning behind it in https://github.com/rust-lang/trait-system-refactor-initiative/issues/226. r? `@BoxyUwU` `@compiler-errors`
2025-08-03Remove unused arg from `path_append_impl`.Nicholas Nethercote-13/+1
None of the impls use it.
2025-08-03Remove `p!`.Nicholas Nethercote-362/+370
It's a cryptic macro that makes some things slightly more concise in `PrettyPrinter`. E.g. if you declare `define_scope_printer!(p)` in a scope you can then call `p! to get these transformations: ``` p!("foo"); --> write!(p, "foo")?; p!(print(ty)); --> ty.print(p)?; p!(method(args)); --> p.method(args)?; ``` You can also chain calls, e.g.: ``` p!("foo", print(ty)); --> write!(p, "foo")?; ty.print(p)?; ``` Ultimately this doesn't seem worth it. The macro definition is hard to read, the call sites are hard to read, `define_scope_printer!` is pretty gross, and the code size reductions are small. Tellingly, many normal `write!` and `print` calls are sprinkled throughout the code, probably because people have made modifications and didn't want to use or understand how to use `p!`. This commit removes it.
2025-08-03Simplify `SymbolMangler::print_type`.Nicholas Nethercote-7/+4
`Bound`/`Placeholder`/`Infer`/`Error` shouldn't occur, so we can handle them in the second exhaustive `match`, and ignore them in the first non-exhaustive `match`.
2025-08-03Rename `Printer` variables.Nicholas Nethercote-281/+279
Currently they are mostly named `cx`, which is a terrible name for a type that impls `Printer`/`PrettyPrinter`, and is easy to confuse with other types like `TyCtxt`. This commit changes them to `p`. A couple of existing `p` variables had to be renamed to make way.
2025-08-03Remove `type_name::AbsolutePathPrinter::comma_sep`.Nicholas Nethercote-14/+3
It's equivalent to the default `PrettyPrinter::comma_sep`.
2025-08-03Inline and remove two `FmtPrinter` methods.Nicholas Nethercote-34/+12
They each have a single call site.
2025-08-03Mark `Printer` methods as unreachable where appropriate.Nicholas Nethercote-14/+17
This helps me understand the structure of the code a lot. If any of these are actually reachable, we can put the old code back, add a new test case, and we will have improved our test coverage.
2025-08-03Auto merge of #144704 - compiler-errors:explode-wf, r=lcnrbors-35/+30
expand WF obligations when checking method calls Don't wrap a bunch of signatures in `FnPtr` then check their WF; instead, check the WFness of each input/output separately. This is useful for the new trait solver, since because we stall on root obligations we end up needing to repeatedly recompute the WFness of possibly very large function signature types if it ends up bottoming out in ambiguity. This may also give us more chances to hit the WF fast path for certain types like built-ins. Finally, this just seems conceptually correct to do. There's nothing conceptually that suggests that wrapping the function signature in an fn pointer makes sense at all to do; I'm guessing that it was just convenient so that we didn't have to register WF obligations in a loop, but it doesn't affect the readability of this code at all.
2025-08-03Auto merge of #144677 - nnethercote:bound-const-handling, r=lcnrbors-97/+123
Improve bound const handling A few changes to make const handling more similar to type handling. r? `@compiler-errors` -errors
2025-08-03Simplify lint emission.Camille GILLOT-74/+56
2025-08-03Keep scanned set across calls to mark_live_symbols.Camille GILLOT-2/+3
2025-08-03Use less HIR when seeding work list.Camille GILLOT-90/+50
2025-08-03Simplify handling of unsolved items.Camille GILLOT-52/+38
2025-08-03Remove struct_constructors.Camille GILLOT-34/+12
2025-08-02Auto merge of #144814 - samueltardieu:rollup-qyum1hj, r=samueltardieubors-73/+104
Rollup of 17 pull requests Successful merges: - rust-lang/rust#132748 (get rid of some false negatives in rustdoc::broken_intra_doc_links) - rust-lang/rust#143360 (loop match: error on `#[const_continue]` outside `#[loop_match]`) - rust-lang/rust#143662 ([rustdoc] Display unsafe attrs with edition 2024 `unsafe()` wrappers.) - rust-lang/rust#143771 (Constify some more `Result` functions) - rust-lang/rust#144185 (Document guarantees of poisoning) - rust-lang/rust#144395 (update fortanix tests) - rust-lang/rust#144478 (Improve formatting of doc code blocks) - rust-lang/rust#144614 (Fortify RemoveUnneededDrops test.) - rust-lang/rust#144703 ([test][AIX] ignore extern_weak linkage test) - rust-lang/rust#144747 (compiletest: Improve diagnostics for line annotation mismatches 2) - rust-lang/rust#144756 (detect infinite recursion with tail calls in ctfe) - rust-lang/rust#144766 (Add human readable name "Cygwin") - rust-lang/rust#144782 (Properly pass path to staged `rustc` to `compiletest` self-tests) - rust-lang/rust#144786 (Cleanup the definition of `group_type`) - rust-lang/rust#144796 (Add my previous commit name to .mailmap) - rust-lang/rust#144797 (Update safety comment for new_unchecked in niche_types) - rust-lang/rust#144803 (rustc-dev-guide subtree update) r? `@ghost` `@rustbot` modify labels: rollup
2025-08-02Use DefKind in should_explore.Camille GILLOT-10/+34
2025-08-02Do not record derived impl def-id for dead code.Camille GILLOT-17/+11
2025-08-02update linksKivooeo-2/+2
2025-08-02update flags for consistencyKivooeo-2/+3
2025-08-02Return a struct with named fields from `hash_owner_nodes`Zalathar-5/+21
2025-08-02Flatten `hash_owner_nodes` with an early-returnZalathar-21/+21
2025-08-02Update E0562 to account for the new impl trait positionsNoratrieb-5/+4
2025-08-02Rollup merge of #144786 - JonathanBrouwer:cleanup-group-type, r=jdonszelmannSamuel Tardieu-25/+36
Cleanup the definition of `group_type` r? ```@jdonszelmann```
2025-08-02Rollup merge of #144756 - WaffleLapkin:inf-rec-etc-ctfe, r=lqdSamuel Tardieu-1/+1
detect infinite recursion with tail calls in ctfe fixes rust-lang/rust#144753
2025-08-02Rollup merge of #144478 - joshtriplett:doc-code-formatting-prep, r=AmanieuSamuel Tardieu-18/+28
Improve formatting of doc code blocks We don't currently apply automatic formatting to doc comment code blocks. As a result, it has built up various idiosyncracies, which make such automatic formatting difficult. Some of those idiosyncracies also make things harder for human readers or other tools. This PR makes a few improvements to doc code formatting, in the hopes of making future automatic formatting easier, as well as in many cases providing net readability improvements. I would suggest reading each commit separately, as each commit contains one class of changes.
2025-08-02Rollup merge of #143360 - folkertdev:const-continue-outside-loop-match, ↵Samuel Tardieu-28/+34
r=WaffleLapkin loop match: error on `#[const_continue]` outside `#[loop_match]` tracking issue https://github.com/rust-lang/rust/issues/132306 fixes https://github.com/rust-lang/rust/issues/143119 fixes https://github.com/rust-lang/rust/issues/143165 Fixes several ICEs because a panic was reachable. ``````@rustbot`````` label +F-loop_match
2025-08-02Rollup merge of #132748 - ↵Samuel Tardieu-1/+5
lolbinarycat:rustdoc-intra-doc-link-warn-more-54191, r=GuillaumeGomez get rid of some false negatives in rustdoc::broken_intra_doc_links rustdoc will not try to do intra-doc linking if the "path" of a link looks too much like a "real url". however, only inline links (`[text](url)`) can actually contain a url, other types of links (reference links, shortcut links) contain a *reference* which is later resolved to an actual url. the "path" in this case cannot be a url, and therefore it should not be skipped due to looking like a url. fixes https://github.com/rust-lang/rust/issues/54191 to minimize the number of false positives that will be introduced, the following heuristic is used: If there's no backticks, be lenient revert to old behavior. This is to prevent churn by linting on stuff that isn't meant to be a link. only shortcut links have simple enough syntax that they are likely to be written accidentlly, collapsed and reference links need 4 metachars, and reference links will not usually use backticks in the reference name. therefore, only shortcut syntax gets the lenient behavior. here's a truth table for how link kinds that cannot be urls are handled: | | is shortcut link | not shortcut link | |--------------|--------------------|-------------------| | has backtick | never ignore | never ignore | | no backtick | ignore if url-like | never ignore |
2025-08-02Auto merge of #144554 - cjgillot:no-hir-eff-vis, r=petrochenkovbors-101/+119
Use less HIR to compute effective visibility. r? `@ghost`
2025-08-02`Interner` arg to `EarlyBinder` does not affect auto traitsLukas Wirth-1/+1
Conceptually `EarlyBinder` does not contain an `Interner` so it shouldn't tell Rust it does via `PhantomData`. This is necessary for rust-analyzer as it stores `EarlyBinder`s in query results which require `Sync`, placing restrictions on our interner setup.
2025-08-02Auto merge of #129183 - estebank:cfg-visitor, r=davidtwcobors-39/+56
Detect more `cfg`d out items in resolution errors Use a visitor to collect *all* items (including those nested) that were stripped behind a `cfg` condition. ``` error[E0425]: cannot find function `f` in this scope --> $DIR/nested-cfg-attrs.rs:4:13 | LL | fn main() { f() } | ^ not found in this scope | note: found an item that was configured out --> $DIR/nested-cfg-attrs.rs:2:4 | LL | fn f() {} | ^ note: the item is gated here --> $DIR/nested-cfg-attrs.rs:1:35 | LL | #[cfg_attr(all(), cfg_attr(all(), cfg(FALSE)))] | ^^^^^^^^^^ ```
2025-08-02Use less HIR to compute effective visibility.Camille GILLOT-101/+119
2025-08-02Auto merge of #144479 - cjgillot:incr-privacy-mod, r=petrochenkovbors-16/+19
Perform check_private_in_public by module. Based on https://github.com/rust-lang/rust/pull/116316
2025-08-02don't warn on explicit casts of never to any Waffle Lapkin-0/+3
2025-08-01Tweak rendering of cfg'd out itemEsteban Küber-29/+38
``` error[E0433]: failed to resolve: could not find `doesnt_exist` in `inner` --> $DIR/diagnostics-cross-crate.rs:18:23 | LL | cfged_out::inner::doesnt_exist::hello(); | ^^^^^^^^^^^^ could not find `doesnt_exist` in `inner` | note: found an item that was configured out --> $DIR/auxiliary/cfged_out.rs:6:13 | LL | #[cfg(false)] | ----- the item is gated here LL | pub mod doesnt_exist { | ^^^^^^^^^^^^ ```
2025-08-01tiny cleanupEsteban Küber-12/+7
2025-08-01remove recursive search for itemsEsteban Küber-33/+15
2025-08-01Limit how deep we visit items to find cfg'd out namesEsteban Küber-3/+12
2025-08-01Detect more `cfg`d out items in resolution errorsEsteban Küber-23/+45
Use a visitor to collect *all* items (including those nested) that were stripped behind a `cfg` condition. ``` error[E0425]: cannot find function `f` in this scope --> $DIR/nested-cfg-attrs.rs:4:13 | LL | fn main() { f() } | ^ not found in this scope | note: found an item that was configured out --> $DIR/nested-cfg-attrs.rs:2:4 | LL | fn f() {} | ^ note: the item is gated here --> $DIR/nested-cfg-attrs.rs:1:35 | LL | #[cfg_attr(all(), cfg_attr(all(), cfg(FALSE)))] | ^^^^^^^^^^ ```
2025-08-01Auto merge of #144458 - compiler-errors:no-witness-mini, r=lcnrbors-137/+119
Remove the witness type from coroutine *args* (without actually removing the type) This does as much of rust-lang/rust#144157 as we can without having to break rust-lang/rust#143545 and/or introduce some better way of handling higher ranked assumptions. Namely, it: * Stalls coroutines based off of the *coroutine* type rather than the witness type. * Reworks the dtorck constraint hack to not rely on the witness type. * Removes the witness type from the args of the coroutine, eagerly creating the type for nested obligations when needed (auto/clone impls). I'll experiment with actually removing the witness type in a follow-up. r? lcnr
2025-08-01Remove the omit_gdb_pretty_printer_section attributebjorn3-32/+6
Disabling loading of pretty printers in the debugger itself is more reliable. Before this commit the .gdb_debug_scripts section couldn't be included in dylibs or rlibs as otherwise there is no way to disable the section anymore without recompiling the entire standard library.
2025-08-01Update compiler/rustc_const_eval/src/interpret/memory.rs zachs18-1/+1
Replace commented-out code with link to context for change. Co-authored-by: Ralf Jung <post@ralfj.de>
2025-08-01Cleanup the definition of `group_type`Jonathan Brouwer-25/+36
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-08-01Auto merge of #144773 - RalfJung:rollup-uif2yyj, r=RalfJungbors-24/+76
Rollup of 6 pull requests Successful merges: - rust-lang/rust#144397 (`tests/ui/issues/`: The Issues Strike Back [2/N]) - rust-lang/rust#144410 (Make tier 3 musl targets link dynamically by default) - rust-lang/rust#144708 (Add tracing to step.rs and friends) - rust-lang/rust#144730 (Create a typed wrapper for codegen backends in bootstrap) - rust-lang/rust#144771 (Remove some noisy triagebot pings for myself) - rust-lang/rust#144772 (add unsupported_calling_conventions to lint list) r? `@ghost` `@rustbot` modify labels: rollup
2025-08-01more strongly dissuade use of `skip_binder`lcnr-30/+30
2025-08-01Rollup merge of #144772 - RalfJung:unsupported_calling_conventions, r=lqdRalf Jung-0/+1
add unsupported_calling_conventions to lint list Seems like you can emit lints without them being on the list, but users cannot control them then... *oops*.
2025-08-01Rollup merge of #144708 - Stypox:add-tracing-to-step, r=RalfJungRalf Jung-9/+75
Add tracing to step.rs and friends Adds tracing calls to functions in `step.rs` (01717ffecfd47eb51f4877da6ad867b329a1ddd5), to friend functions related to evaluation and stepping (cbfa7c4b96b2ea26c1db185da9b59506bf8c8e55), and adds a new trait method `EnteredTraceSpan::or_if_tracing_disabled` (f0d0d1f5ecdf174696c8a74a5bc98967a2751c93). Adding `EnteredTraceSpan::or_if_tracing_disabled` is optional and is only useful to avoid having both `tracing::info!()` calls (that existed before) and `enter_trace_span!()` calls (that this PR adds) that would be redundant and would slow down the collection of traces. I say it is optional because it adds some cognitive complexity around `EnteredTraceSpan`, which is possibly not worth the reduced redundancy. Let me know if I should revert that commit. The tracing calls added in this PR are meant to make it easier to understand what was being executing at a particular point when looking at a trace. But they are likely not useful for the purpose of understanding which components are fast/slow, hence why I used `tracing_separate_thread` for them. After opening a trace generated using the code in this PR in https://ui.perfetto.dev, and after executing the following query and then pressing on "Show debug track", you will see something like the following image in the timeline: ```sql select slices.id, ts, dur, track_id, category, args.string_value as name, depth, stack_id, parent_stack_id, parent_id, slices.arg_set_id, thread_ts, thread_instruction_count, thread_instruction_delta, cat, slice_id from slices inner join args USING (arg_set_id) where args.key = "args." || slices.name and name = "step" ``` <img width="739" height="87" alt="image" src="https://github.com/user-attachments/assets/74ad9619-9a1f-40e5-9ef4-3db31e33d6e1" />