about summary refs log tree commit diff
path: root/compiler/rustc_passes/src/hir_id_validator.rs
AgeCommit message (Collapse)AuthorLines
2025-03-12Adjust `Map`'s `to_string` functionality.Nicholas Nethercote-4/+3
`Map::node_to_string` just calls the free function `hir_id_to_string`. This commit removes the former and changes the latter into a `TyCtxt` method.
2025-02-18Move methods from `Map` to `TyCtxt`, part 2.Nicholas Nethercote-2/+2
Continuing the work started in #136466. Every method gains a `hir_` prefix, though for the ones that already have a `par_` or `try_par_` prefix I added the `hir_` after that.
2025-02-17Overhaul the `intravisit::Map` trait.Nicholas Nethercote-2/+2
First of all, note that `Map` has three different relevant meanings. - The `intravisit::Map` trait. - The `map::Map` struct. - The `NestedFilter::Map` associated type. The `intravisit::Map` trait is impl'd twice. - For `!`, where the methods are all unreachable. - For `map::Map`, which gets HIR stuff from the `TyCtxt`. As part of getting rid of `map::Map`, this commit changes `impl intravisit::Map for map::Map` to `impl intravisit::Map for TyCtxt`. It's fairly straightforward except various things are renamed, because the existing names would no longer have made sense. - `trait intravisit::Map` becomes `trait intravisit::HirTyCtxt`, so named because it gets some HIR stuff from a `TyCtxt`. - `NestedFilter::Map` assoc type becomes `NestedFilter::MaybeTyCtxt`, because it's always `!` or `TyCtxt`. - `Visitor::nested_visit_map` becomes `Visitor::maybe_tcx`. I deliberately made the new trait and associated type names different to avoid the old `type Map: Map` situation, which I found confusing. We now have `type MaybeTyCtxt: HirTyCtxt`.
2025-02-17Move some `Map` methods onto `TyCtxt`.Nicholas Nethercote-3/+3
The end goal is to eliminate `Map` altogether. I added a `hir_` prefix to all of them, that seemed simplest. The exceptions are `module_items` which became `hir_module_free_items` because there was already a `hir_module_items`, and `items` which became `hir_free_items` for consistency with `hir_module_free_items`.
2025-02-03Use a different hir type for patterns in pattern types than we use in match ↵Oli Scherer-2/+2
patterns
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-1/+1
2024-04-08Actually create ranged int types in the type system.Oli Scherer-0/+4
2024-03-06Add proper cfgs for struct HirIdValidator used only with debug assertionsr0cky-24/+12
2024-01-10Add `DiagCtxt::delayed_bug`.Nicholas Nethercote-1/+1
We have `span_delayed_bug` and often pass it a `DUMMY_SP`. This commit adds `delayed_bug`, which matches pairs like `err`/`span_err` and `warn`/`span_warn`.
2023-12-24Remove `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-1/+1
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier access.
2023-12-02Rename `HandlerInner::delay_span_bug` as `HandlerInner::span_delayed_bug`.Nicholas Nethercote-1/+1
Because the corresponding `Level` is `DelayedBug` and `span_delayed_bug` follows the pattern used everywhere else: `span_err`, `span_warning`, etc.
2023-07-25inline format!() args from rustc_codegen_llvm to the end (4)Matthias Krüger-3/+2
r? @WaffleLapkin
2023-05-03Restrict `From<S>` for `{D,Subd}iagnosticMessage`.Nicholas Nethercote-1/+1
Currently a `{D,Subd}iagnosticMessage` can be created from any type that impls `Into<String>`. That includes `&str`, `String`, and `Cow<'static, str>`, which are reasonable. It also includes `&String`, which is pretty weird, and results in many places making unnecessary allocations for patterns like this: ``` self.fatal(&format!(...)) ``` This creates a string with `format!`, takes a reference, passes the reference to `fatal`, which does an `into()`, which clones the reference, doing a second allocation. Two allocations for a single string, bleh. This commit changes the `From` impls so that you can only create a `{D,Subd}iagnosticMessage` from `&str`, `String`, or `Cow<'static, str>`. This requires changing all the places that currently create one from a `&String`. Most of these are of the `&format!(...)` form described above; each one removes an unnecessary static `&`, plus an allocation when executed. There are also a few places where the existing use of `&String` was more reasonable; these now just use `clone()` at the call site. As well as making the code nicer and more efficient, this is a step towards possibly using `Cow<'static, str>` in `{D,Subd}iagnosticMessage::{Str,Eager}`. That would require changing the `From<&'a str>` impls to `From<&'static str>`, which is doable, but I'm not yet sure if it's worthwhile.
2023-04-05incr.comp.: Don't ignore dep-tracking during HirId validation.Michael Woerister-22/+20
2023-04-04incr.comp.: Make sure dependencies are recorded when feeding queries during ↵Michael Woerister-22/+22
eval-always queries.
2023-03-02rustc_middle: Remove trait `DefIdTree`Vadim Petrochenkov-1/+1
This trait was a way to generalize over both `TyCtxt` and `Resolver`, but now `Resolver` has access to `TyCtxt`, so this trait is no longer necessary.
2023-02-01Improve pretty-printing of `HirIdValidator` errorsArpad Borsos-25/+14
This now uses `node_to_string` for both missing and seen Ids, which includes the snippet of code for which the Id was allocated. Also removes the duplicated printing of `HirId`, as `node_to_string` includes that already. Similarly, changes all other users of `node_to_string` that do so, and changes the output of `node_to_string`, which is now "$hirid ($what `$span` in $path)".
2022-11-26Verify that HIR parenting and Def parenting match.Camille GILLOT-24/+51
2022-10-29Rename some `OwnerId` fields.Nicholas Nethercote-4/+4
spastorino noticed some silly expressions like `item_id.def_id.def_id`. This commit renames several `def_id: OwnerId` fields as `owner_id`, so those expressions become `item_id.owner_id.def_id`. `item_id.owner_id.local_def_id` would be even clearer, but the use of `def_id` for values of type `LocalDefId` is *very* widespread, so I left that alone.
2022-09-24separate definitions and `HIR` ownersTakayuki Maeda-8/+7
fix a ui test use `into` fix clippy ui test fix a run-make-fulldeps test implement `IntoQueryParam<DefId>` for `OwnerId` use `OwnerId` for more queries change the type of `ParentOwnerIterator::Item` to `(OwnerId, OwnerNode)`
2022-09-07Format hir_id_validator error using pretty printSantiago Pastorino-1/+1
2022-07-13Rename `debugging_opts` to `unstable_opts`Joshua Nelson-1/+1
This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`). Rename it to be more clear.
2022-07-07Reword comments and rename HIR visiting methods.Camille GILLOT-1/+1
2022-07-04Only validate HIR with `debug_assertions` onJakub Beránek-19/+22
2022-07-04Use a bitset instead of a hash map in HIR ID validatorJakub Beránek-4/+4
2022-05-13remove unnecessary methods from HirIdValidatorMiguel Guarniz-14/+0
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13change back to using tcx.hir() visit-item methodMiguel Guarniz-18/+1
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13remove OuterVisitorMiguel Guarniz-39/+52
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-04-17Stop using CRATE_DEF_INDEX.Camille GILLOT-2/+2
`CRATE_DEF_ID` and `CrateNum::as_def_id` are almost always what we want.
2022-01-16Replace NestedVisitorMap with NestedFilterCameron Steffen-3/+4
2022-01-15Use LocalDefId in rustc_passes::hir_id_validator.Camille GILLOT-6/+5
2021-09-20Do not store visibility in *ItemRef.Camille GILLOT-2/+2
2021-09-12Gather module items after lowering.Camille GILLOT-3/+3
2021-09-02Drop walk_crate_and_attributes.Camille GILLOT-0/+4
2021-03-23GenericParam does not need to be a HIR owner.Camille GILLOT-13/+0
2021-02-15Index Modules using their LocalDefId.Camille GILLOT-6/+3
2021-02-15Only store a LocalDefId in hir::ForeignItem.Camille GILLOT-1/+1
2021-02-15Only store a LocalDefId in hir::ImplItem.Camille GILLOT-1/+1
2021-02-15Only store a LocalDefId in hir::TraitItem.Camille GILLOT-1/+1
2021-02-15Only store a LocalDefId in hir::Item.Camille GILLOT-1/+1
Items are guaranteed to be HIR owner.
2020-11-28Do not visit ForeignItemRef for HIR indexing and validation.Camille GILLOT-0/+7
Similarly to what is done for ImplItemRef and TraitItemRef. Fixes #79487
2020-11-26Store ForeignItem in a side table.Camille GILLOT-0/+5
2020-10-07implement nitsBastian Kauschke-1/+2
2020-10-07bodgeBastian Kauschke-0/+12
2020-09-25Address review commentmarmeladema-4/+4
2020-08-30mv compiler to compiler/mark-0/+166