about summary refs log tree commit diff
path: root/tests/ui/stats
AgeCommit message (Collapse)AuthorLines
2025-08-25add span to struct pattern rest (..)Valdemar Erk-10/+10
2025-08-08Fix some bad formatting in `-Zmacro-stats` output.Nicholas Nethercote-5/+5
I also double-checked that everything looks good on some real-world crates.
2025-08-08Augment the test.Nicholas Nethercote-5/+32
Some cases that are currently handled incorrectly.
2025-07-13Retire hir::*ItemRef.Camille GILLOT-3/+3
2025-07-13Retire hir::ForeignItemRef.Camille GILLOT-2/+2
2025-07-13Remove hir::AssocItemKind.Camille GILLOT-3/+3
2025-07-13Move trait_item_def_id from ImplItemRef to ImplItem.Camille GILLOT-2/+2
2025-06-30Improve macro-stats printing.Nicholas Nethercote-2/+1
By allowing long names to overlap with the "Uses" field when it has spare space. This avoids unnecessary line breaks in the output.
2025-06-30Augment the macro-stats test.Nicholas Nethercote-3/+10
With a long macro name that could fit on one line, but currently isn't formatted that way, because the name would overlap with the maximum width of the "Uses" column. (The next commit will fix this.)
2025-06-25tests: Do not run afoul of asm.validity.non-exhaustive in input-statsJubilee Young-7/+10
2025-06-24Rollup merge of #142934 - nnethercote:tweak-macro-stats, r=petrochenkovJubilee-20/+20
Tweak `-Zmacro-stats` measurement. It currently reports net size, i.e. size(output) - size(input). After some use I think this is sub-optimal, and it's better to just report size(output). Because for derive macros the input size is always 1, and for attribute macros it's almost always 1. r? ```@petrochenkov```
2025-06-24Tweak `-Zinput-stats` and `-Zmeta-stats` output.Nicholas Nethercote-4/+6
To make it match `-Zmacro-stats`, and work better if you have enabled it for multiple crates. - Print each crate's name. - Print a `===` banner at the start and end for separation.
2025-06-24Reverse order of `-Zinput-stats` and `-Zmeta-stats` output.Nicholas Nethercote-93/+93
Currently they have the largest items at the end. I believe the rationale is that it saves you scrolling up through terminal output because the important stuff is at the bottom. But it's also surprising and a bit confusing, and I think the obvious order (big things at the top) is better.
2025-06-24Tweak `-Zmacro-stats` measurement.Nicholas Nethercote-20/+20
It currently reports net size, i.e. size(output) - size(input). After some use I think this is sub-optimal, and it's better to just report size(output). Because for derive macros the input size is always 1, and for attribute macros it's almost always 1.
2025-06-13Rollup merge of #142158 - xizheyin:141617, r=jdonszelmannMatthias Krüger-2/+2
Tracking the old name of renamed unstable library features This PR resolves the first problem of rust-lang/rust#141617 : tracking renamed unstable features. The first commit is to add a ui test, and the second one tracks the changes. I will comment on the code for clarification. r? `@jdonszelmann` There have been a lot of PR's reviewed by you lately, thanks for your time! cc `@jyn514`
2025-06-12Tracking the old name of renamed unstable library attributexizheyin-2/+2
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-06-12Introduce `-Zmacro-stats`.Nicholas Nethercote-0/+159
It collects data about macro expansions and prints them in a table after expansion finishes. It's very useful for detecting macro bloat, especially for proc macros. Details: - It measures code snippets by pretty-printing them and then measuring lines and bytes. This required a bunch of additional pretty-printing plumbing, in `rustc_ast_pretty` and `rustc_expand`. - The measurement is done in `MacroExpander::expand_invoc`. - The measurements are stored in `ExtCtxt::macro_stats`.
2025-06-03Remove pre-expansion AST stats.Nicholas Nethercote-117/+60
They're very little value, because they only measure the top-level `main.rs` or `lib.rs` file. (Other `.rs` files don't get read and parsed until expansion occurs.) I saw an example recently where the pre-expansion AST was 3KB in size and the post-expansion AST was 66MB. I kept the "POST EXPANSION" in the output header, I think that's useful information to avoid possible confusion about when the measurement happens.
2025-05-28Avoid over-counting of `UsePath` in the HIR stats.Nicholas Nethercote-3/+3
2025-05-28Filter percentages out of `tests/ui/stats/input-stats.rs` output.Nicholas Nethercote-160/+164
This will make future diffs to this file much easier to read.
2025-04-04Implement `super let`.Mara Bos-18/+18
2025-04-01Move `ast::Item::ident` into `ast::ItemKind`.Nicholas Nethercote-39/+39
`ast::Item` has an `ident` field. - It's always non-empty for these item kinds: `ExternCrate`, `Static`, `Const`, `Fn`, `Mod`, `TyAlias`, `Enum`, `Struct`, `Union`, `Trait`, `TraitAlias`, `MacroDef`, `Delegation`. - It's always empty for these item kinds: `Use`, `ForeignMod`, `GlobalAsm`, `Impl`, `MacCall`, `DelegationMac`. There is a similar story for `AssocItemKind` and `ForeignItemKind`. Some sites that handle items check for an empty ident, some don't. This is a very C-like way of doing things, but this is Rust, we have sum types, we can do this properly and never forget to check for the exceptional case and never YOLO possibly empty identifiers (or possibly dummy spans) around and hope that things will work out. The commit is large but it's mostly obvious plumbing work. Some notable things. - `ast::Item` got 8 bytes bigger. This could be avoided by boxing the fields within some of the `ast::ItemKind` variants (specifically: `Struct`, `Union`, `Enum`). I might do that in a follow-up; this commit is big enough already. - For the visitors: `FnKind` no longer needs an `ident` field because the `Fn` within how has one. - In the parser, the `ItemInfo` typedef is no longer needed. It was used in various places to return an `Ident` alongside an `ItemKind`, but now the `Ident` (if present) is within the `ItemKind`. - In a few places I renamed identifier variables called `name` (or `foo_name`) as `ident` (or `foo_ident`), to better match the type, and because `name` is normally used for `Symbol`s. It's confusing to see something like `foo_name.name`.
2025-03-28Don't use `kw::Empty` in `hir::Lifetime::ident`.Nicholas Nethercote-3/+3
`hir::Lifetime::ident` currently sometimes uses `kw::Empty` for elided lifetimes and sometimes uses `kw::UnderscoreLifetime`, and the distinction is used when creating some error suggestions, e.g. in `Lifetime::suggestion` and `ImplicitLifetimeFinder::visit_ty`. I found this *really* confusing, and it took me a while to understand what was going on. This commit replaces all uses of `kw::Empty` in `hir::Lifetime::ident` with `kw::UnderscoreLifetime`. It adds a new field `hir::Lifetime::is_path_anon` that mostly replaces the old empty/underscore distinction and makes things much clearer. Some other notable changes: - Adds a big comment to `Lifetime` talking about permissable field values. - Adds some assertions in `new_named_lifetime` about what ident values are permissible for the different `LifetimeRes` values. - Adds a `Lifetime::new` constructor that does some checking to make sure the `is_elided` and `is_anonymous` states are valid. - `add_static_impl_trait_suggestion` now looks at `Lifetime::res` instead of the ident when creating the suggestion. This is the one case where `is_path_anon` doesn't replace the old empty/underscore distinction. - A couple of minor pretty-printing improvements.
2025-03-01Implment `#[cfg]` and `#[cfg_attr]` in `where` clausesFrank King-14/+14
2025-01-01Fix ICE when opaque captures a duplicated/invalid lifetimeMichael Goulet-6/+6
2024-12-17Fix `-Z inputs-stats` ordering.Nicholas Nethercote-17/+17
In #129533 the main hash function changed and the order of `-Z input-stats` output changed, which showed that it is dependent on the hash function, even though it is sorted. That's because entries with the same cumulative size are ordered in a way that depends on the hash function. This commit fixes that by using the entry label as the secondary ordering key.
2024-12-09Introduce `default_field_values` featureEsteban Küber-18/+18
Initial implementation of `#[feature(default_field_values]`, proposed in https://github.com/rust-lang/rfcs/pull/3681. Support default fields in enum struct variant Allow default values in an enum struct variant definition: ```rust pub enum Bar { Foo { bar: S = S, baz: i32 = 42 + 3, } } ``` Allow using `..` without a base on an enum struct variant ```rust Bar::Foo { .. } ``` `#[derive(Default)]` doesn't account for these as it is still gating `#[default]` only being allowed on unit variants. Support `#[derive(Default)]` on enum struct variants with all defaulted fields ```rust pub enum Bar { #[default] Foo { bar: S = S, baz: i32 = 42 + 3, } } ``` Check for missing fields in typeck instead of mir_build. Expand test with `const` param case (needs `generic_const_exprs` enabled). Properly instantiate MIR const The following works: ```rust struct S<A> { a: Vec<A> = Vec::new(), } S::<i32> { .. } ``` Add lint for default fields that will always fail const-eval We *allow* this to happen for API writers that might want to rely on users' getting a compile error when using the default field, different to the error that they would get when the field isn't default. We could change this to *always* error instead of being a lint, if we wanted. This will *not* catch errors for partially evaluated consts, like when the expression relies on a const parameter. Suggestions when encountering `Foo { .. }` without `#[feature(default_field_values)]`: - Suggest adding a base expression if there are missing fields. - Suggest enabling the feature if all the missing fields have optional values. - Suggest removing `..` if there are no missing fields.
2024-11-25Refactor `where` predicates, and reserve for attributes supportFrank King-23/+23
2024-11-21Implement the unsafe-fields RFC.Luca Versari-15/+15
Co-Authored-By: Jacob Pratt <jacob@jhpratt.dev>
2024-11-15Merge `-Zhir-stats` into `-Zinput-stats`Sam Estep-2/+2
2024-11-15Print total node count in `-Z hir-stats`Sam Estep-4/+4
2024-10-22Represent TraitBoundModifiers as distinct parts in HIRMichael Goulet-8/+8
2024-10-20Stop relying on hashmap iteration for hir stat printingNoratrieb-23/+23
Just because the code says it's OK does not mean that it actually is OK. Nodes with the same total size were not sorted, their order relied on hashmap iteration.
2024-08-31ignore/fix layout-sensitive testsThe 8472-0/+3
2024-07-16Add `ConstArgKind::Path` and make `ConstArg` its own HIR nodeNoah Lev-6/+6
This is a very large commit since a lot needs to be changed in order to make the tests pass. The salient changes are: - `ConstArgKind` gets a new `Path` variant, and all const params are now represented using it. Non-param paths still use `ConstArgKind::Anon` to prevent this change from getting too large, but they will soon use the `Path` variant too. - `ConstArg` gets a distinct `hir_id` field and its own variant in `hir::Node`. This affected many parts of the compiler that expected the parent of an `AnonConst` to be the containing context (e.g., an array repeat expression). They have been changed to check the "grandparent" where necessary. - Some `ast::AnonConst`s now have their `DefId`s created in rustc_ast_lowering rather than `DefCollector`. This is because in some cases they will end up becoming a `ConstArgKind::Path` instead, which has no `DefId`. We have to solve this in a hacky way where we guess whether the `AnonConst` could end up as a path const since we can't know for sure until after name resolution (`N` could refer to a free const or a nullary struct). If it has no chance as being a const param, then we create a `DefId` in `DefCollector` -- otherwise we decide during ast_lowering. This will have to be updated once all path consts use `ConstArgKind::Path`. - We explicitly use `ConstArgHasType` for array lengths, rather than implicitly relying on anon const type feeding -- this is due to the addition of `ConstArgKind::Path`. - Some tests have their outputs changed, but the changes are for the most part minor (including removing duplicate or almost-duplicate errors). One test now ICEs, but it is for an incomplete, unstable feature and is now tracked at #127009.
2024-06-26ast: Standardize visiting orderVadim Petrochenkov-31/+31
Id, attributes, inner nodes in source order if possible, tokens, span. Also always use exhaustive matching in visiting infra, and visit some missing nodes.
2024-05-04Auto merge of #124401 - oli-obk:some_hir_cleanups, r=cjgillotbors-13/+13
Some hir cleanups It seemed odd to not put `AnonConst` in the arena, compared with the other types that we did put into an arena. This way we can also give it a `Span` without growing a lot of other HIR data structures because of the extra field. r? compiler
2024-04-29Add StaticForeignItem and use it on ForeignItemKindSantiago Pastorino-10/+10
2024-04-29Bless ui testsOli Scherer-13/+13
2024-03-14Update `tests/ui/stats/hir-stats.stderr` outputGuillaume Gomez-3/+3
2024-03-01Detect more cases of `=` to `:` typoEsteban Küber-10/+10
When a `Local` is fully parsed, but not followed by a `;`, keep the `:` span arround and mention it. If the type could continue being parsed as an expression, suggest replacing the `:` with a `=`. ``` error: expected one of `!`, `+`, `->`, `::`, `;`, or `=`, found `.` --> file.rs:2:32 | 2 | let _: std::env::temp_dir().join("foo"); | - ^ expected one of `!`, `+`, `->`, `::`, `;`, or `=` | | | while parsing the type for `_` | help: use `=` if you meant to assign ``` Fix #119665.
2024-02-16[AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives许杰友 Jieyou Xu (Joe)-6/+6
2024-01-31Add async bound modifier to enable async Fn boundsMichael Goulet-26/+26
2024-01-05Remove `hir::Guard`Matthew Jasper-4/+4
Use Expr instead. Use `ExprKind::Let` to represent if let guards.
2023-12-25Make closures carry their own ClosureKind, rather than deducing what it is ↵Michael Goulet-4/+4
from movability
2023-12-20Refactor AST trait bound modifiersLeón Orell Valerian Liehr-17/+17
2023-11-24Add `Span` to `TraitBoundModifier`Deadbeef-29/+29
2023-09-22Rollup merge of #116067 - saethlin:meta-stats-ice, r=WaffleLapkinMatthias Krüger-0/+7
Open the FileEncoder file for reading and writing Maybe I just don't know `File` well enough, but the previous comment didn't make it clear enough to me that we can't use `File::create`. This one does. Fixes https://github.com/rust-lang/rust/issues/116055 r? `@WaffleLapkin`
2023-09-22Open the FileEncoder file for reading and writingBen Kimock-0/+7
2023-09-21Record asyncness span in HIRMichael Goulet-16/+16