about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/ty/print
AgeCommit message (Collapse)AuthorLines
2025-09-30Split Bound into Canonical and Boundjackh726-2/+2
2025-09-24Improve the pretty print of UnstableFeature clausetiif-2/+1
2025-09-17Remove `DynKind`León Orell Valerian Liehr-4/+2
2025-09-09Auto merge of #145717 - BoxyUwU:erase_regions_rename, r=lcnrbors-2/+2
rename erase_regions to erase_and_anonymize_regions I find it consistently confusing that `erase_regions` does more than replacing regions with `'erased`. it also makes some code look real goofy to be writing manual folders to erase regions with a comment saying "we cant use erase regions" :> or code that re-calls erase_regions on types with regions already erased just to anonymize all the bound regions. r? lcnr idk how i feel about the name being almost twice as long now
2025-09-09erase_regions to erase_and_anonymize_regionsBoxy-2/+2
2025-09-08fixup limit handling codeJana Dönszelmann-1/+1
2025-09-08Move `describe_as_module` from `rustc_middle::print` to `rustc:middle::query`.Nicholas Nethercote-11/+1
That way it doesn't need to be exported.
2025-08-19Pretty print the name of an future from calling async closureMichael Goulet-3/+13
2025-08-14Print regions in `type_name`.Nicholas Nethercote-7/+7
Currently they are skipped, which is a bit weird, and it sometimes causes malformed output like `Foo<>` and `dyn Bar<, A = u32>`. Most regions are erased by the time `type_name` does its work. So all regions are now printed as `'_` in non-optional places. Not perfect, but better than the status quo. `c_name` is updated to trim lifetimes from MIR pass names, so that the `PASS_NAMES` sanity check still works. It is also renamed as `simplify_pass_type_name` and made non-const, because it doesn't need to be const and the non-const implementation is much shorter. The commit also renames `should_print_region` as `should_print_optional_region`, which makes it clearer that it only applies to some regions. Fixes #145168.
2025-08-13Rollup merge of #144949 - nnethercote:more-Printer-cleanups, r=davidtwcoGuillaume Gomez-81/+110
More `Printer` cleanups A sequel to rust-lang/rust#144776. r? ```@davidtwco```
2025-08-08Rollup merge of #144039 - estebank:short-paths, r=fee1-deadTrevor Gross-1/+1
Use `tcx.short_string()` in more diagnostics `TyCtxt::short_string` ensures that user visible type paths aren't overwhelming on the terminal output, and properly saves the long name to disk as a side-channel. We already use these throughout the compiler and have been using them as needed when users find cases where the output is verbose. This is a proactive search of some cases to use `short_string`. We add support for shortening the path of "trait path only". Every manual use of `short_string` is a bright marker that that error should be using structured diagnostics instead (as they have proper handling of long types without the maintainer having to think abou tthem).
2025-08-07Use `tcx.short_string()` in more diagnosticsEsteban Küber-1/+1
`TyCtxt::short_string` ensures that user visible type paths aren't overwhelming on the terminal output, and properly saves the long name to disk as a side-channel. We already use these throughout the compiler and have been using them as needed when users find cases where the output is verbose. This is a proactive search of some cases to use `short_string`. We add support for shortening the path of "trait path only". Every manual use of `short_string` is a bright marker that that error should be using structured diagnostics instead (as they have proper handling of long types without the maintainer having to think abou tthem). When we don't actually print out a shortened type we don't need the "use `--verbose`" note. On E0599 show type identity to avoid expanding the receiver's generic parameters. Unify wording on `long_ty_path` everywhere.
2025-08-06Add support for shortening `Instance` and use itEsteban Küber-31/+38
Replace ad-hoc type path shortening logic for recursive mono instantiation errors to use `tcx.short_string()` instead.
2025-08-06Rename some `PrettyPrinter` methods.Nicholas Nethercote-26/+26
More consistency.
2025-08-06Rename some `Printer` methods.Nicholas Nethercote-30/+37
I find these name clearer, and starting them all with `print_` makes things more consistent.
2025-08-06Move `should_truncate` from trait `Printer` to sub-trait `PrettyPrinter`.Nicholas Nethercote-8/+8
It's not used in `Printer`.
2025-08-06Add comments to `Printer`.Nicholas Nethercote-17/+39
These details took me some time to work out.
2025-08-05Clarify `value_path_str_with_args`.Nicholas Nethercote-4/+4
The use of `print_value_path` means the value namespace is always used and the `guess_def_namespace` call is unnecessary. This commit removes the `guess_def_namespace` call and hard-codes `ValueNS`. It also changes the `print_value_path` to `print_def_path` for consistency with `def_path_str_with_args`.
2025-08-04Avoid some code duplication.Nicholas Nethercote-6/+1
`print_binder` can call `wrap_binder`.
2025-08-03Remove unused arg from `path_append_impl`.Nicholas Nethercote-8/+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-03Rename `Printer` variables.Nicholas Nethercote-117/+117
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-03Inline and remove two `FmtPrinter` methods.Nicholas Nethercote-34/+12
They each have a single call site.
2025-07-31Remove the witness type from coroutine argsMichael Goulet-6/+2
2025-07-28Auto merge of #144469 - Kivooeo:chains-cleanup, r=SparrowLiibors-4/+4
Some `let chains` clean-up Not sure if this kind of clean-up is welcoming because of size, but I decided to try out one r? compiler
2025-07-28use let chains in hir, lint, mirKivooeo-4/+4
2025-07-24Use LocalKey<Cell> methods moreCameron Steffen-3/+3
2025-07-18Remove pretty print hack for async blocksMichael Goulet-25/+1
2025-07-17Auto merge of #144044 - fmease:rollup-kg413pt, r=fmeasebors-1/+1
Rollup of 15 pull requests Successful merges: - rust-lang/rust#142304 (tests: Add `RUST_BACKTRACE` and `-Cpanic` revisions to `panic-main.rs` test) - rust-lang/rust#143388 (Various refactors to the LTO handling code) - rust-lang/rust#143409 (Enable xgot feature for mips64 musl targets) - rust-lang/rust#143592 (UWP: link ntdll functions using raw-dylib) - rust-lang/rust#143595 (add `const_make_global`; err for `const_allocate` ptrs if didn't call) - rust-lang/rust#143678 (Added error for invalid char cast) - rust-lang/rust#143820 (Fixed a core crate compilation failure when enabling the `optimize_for_size` feature on some targets) - rust-lang/rust#143829 (Trim `BorrowedCursor` API) - rust-lang/rust#143851 (ci cleanup: rustdoc-gui-test now installs browser-ui-test) - rust-lang/rust#143856 (Linting public reexport of private dependencies) - rust-lang/rust#143895 (Dont collect assoc ty item bounds from trait where clause for host effect predicates) - rust-lang/rust#143922 (Improve path segment joining) - rust-lang/rust#143964 (Fix handling of SCRIPT_ARG in docker images) - rust-lang/rust#144002 (Update poison.rs) - rust-lang/rust#144016 (trait_sel: `MetaSized` always holds temporarily) r? `@ghost` `@rustbot` modify labels: rollup
2025-07-17Auto merge of #140399 - tiif:unstable_impl, r=lcnr,BoxyUwUbors-0/+1
Implement unstable trait impl This PR allows marking impls of stable trait with stable type as unstable. ## Approach In std/core, an impl can be marked as unstable by annotating it with ``#[unstable_feature_bound(feat_name)]``. This will add a ``ClauseKind::Unstable_Feature(feat_name)`` to the list of predicates in ``predicates_of`` . When an unstable impl's function is called, we will first iterate through all the goals in ``param_env`` to check if there is any ``ClauseKind::UnstableFeature(feat_name)`` in ``param_env``. The existence of ``ClauseKind::Unstable_Feature(feat_name)`` in ``param_env`` means an``#[unstable_feature_bound(feat_name)]`` is present at the call site of the function, so we allow the check to succeed in this case. If ``ClauseKind::UnstableFeature(feat_name)`` does not exist in ``param_env``, we will still allow the check to succeed for either of the cases below: 1. The feature is enabled through ``#[feature(feat_name)]`` outside of std / core. 2. We are in codegen because we may be monomorphizing a body from an upstream crate which had an unstable feature enabled that the downstream crate do not. For the rest of the case, it will fail with ambiguity. ## Limitation In this PR, we do not support: 1. using items that need ``#[unstable_feature_bound]`` within stable APIs 2. annotate main function with ``#[unstable_feature_bound]`` 3. annotate ``#[unstable_feature_bound]`` on items other than free function and impl ## Acknowledgement The design and mentoring are done by `@BoxyUwU`
2025-07-17Use `join_path_syms` in one more place.Nicholas Nethercote-1/+1
This one is a bit marginal, because the segments are a mix of symbols and strings.
2025-07-16resolve: Merge `NameBindingKind::Module` into `NameBindingKind::Res`Vadim Petrochenkov-3/+1
2025-07-15Implement other logicstiif-0/+1
2025-07-09Add opaque TypeId handles for CTFEOli Scherer-0/+1
2025-07-07Auto merge of #143182 - xdoardo:more-addrspace, r=workingjubileebors-1/+1
Allow custom default address spaces and parse `p-` specifications in the datalayout string Some targets, such as CHERI, use as default an address space different from the "normal" default address space `0` (in the case of CHERI, [200 is used](https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-877.pdf)). Currently, `rustc` does not allow to specify custom address spaces and does not take into consideration [`p-` specifications in the datalayout string](https://llvm.org/docs/LangRef.html#langref-datalayout). This patch tries to mitigate these problems by allowing targets to define a custom default address space (while keeping the default value to address space `0`) and adding the code to parse the `p-` specifications in `rustc_abi`. The main changes are that `TargetDataLayout` now uses functions to refer to pointer-related informations, instead of having specific fields for the size and alignment of pointers in the default address space; furthermore, the two `pointer_size` and `pointer_align` fields in `TargetDataLayout` are replaced with an `FxHashMap` that holds info for all the possible address spaces, as parsed by the `p-` specifications. The potential performance drawbacks of not having ad-hoc fields for the default address space will be tested in this PR's CI run. r? workingjubilee
2025-07-07compiler: Parse `p-` specs in datalayout string, allow definition of custom ↵Edoardo Marangoni-1/+1
default data address space
2025-07-04Fix elided lifetimes in rustdocMichael Goulet-1/+1
2025-07-04Fix pretty printing of placeholder typesMichael Goulet-7/+11
2025-07-04Same for typesMichael Goulet-4/+4
2025-07-04Remove Symbol for Named LateParam/Bound variantsMichael Goulet-57/+24
2025-07-01Remove support for dyn*Michael Goulet-1/+0
2025-06-29give Pointer::into_parts a more scary name and offer a safer alternativeRalf Jung-1/+1
2025-06-26Change const trait bound syntax from ~const to [const]Oli Scherer-2/+2
2025-06-16middle: print `{Meta,Pointee}Sized` in opaquesDavid Wood-5/+31
When `sized_hierarchy` is enabled, rustc should print `MetaSized` or `PointeeSized` instead of `?Sized` in opaques.
2025-06-03Ensure query keys are printed with reduced queriesMichael Goulet-1/+1
2025-05-27Rename unpack to kindMichael Goulet-3/+3
2025-05-08Remove some unnecessary erasesMichael Goulet-2/+0
2025-05-07Require T: TypeFoldable in Binder<T> visitMichael Goulet-1/+1
2025-05-06Auto merge of #131160 - ↵bors-17/+13
ismailarilik:handle-potential-query-instability-lint-for-rustc-middle, r=oli-obk Handle `rustc_middle` cases of `rustc::potential_query_instability` lint This PR removes `#![allow(rustc::potential_query_instability)]` line from [`compiler/rustc_middle/src/lib.rs`](https://github.com/rust-lang/rust/blob/master/compiler/rustc_middle/src/lib.rs#L29) and converts `FxHash{Map,Set}` types into `FxIndex{Map,Set}` to suppress lint errors. A somewhat tracking issue: https://github.com/rust-lang/rust/issues/84447 r? `@compiler-errors`
2025-05-05Handle rustc_middle cases of rustc::potential_query_instability lintismailarilik-17/+13