summary refs log tree commit diff
path: root/compiler/rustc_middle/src/hir/map
AgeCommit message (Collapse)AuthorLines
2022-05-07Auto merge of #96094 - Elliot-Roberts:fix_doctests, r=compiler-errorsbors-1/+1
Begin fixing all the broken doctests in `compiler/` Begins to fix #95994. All of them pass now but 24 of them I've marked with `ignore HELP (<explanation>)` (asking for help) as I'm unsure how to get them to work / if we should leave them as they are. There are also a few that I marked `ignore` that could maybe be made to work but seem less important. Each `ignore` has a rough "reason" for ignoring after it parentheses, with - `(pseudo-rust)` meaning "mostly rust-like but contains foreign syntax" - `(illustrative)` a somewhat catchall for either a fragment of rust that doesn't stand on its own (like a lone type), or abbreviated rust with ellipses and undeclared types that would get too cluttered if made compile-worthy. - `(not-rust)` stuff that isn't rust but benefits from the syntax highlighting, like MIR. - `(internal)` uses `rustc_*` code which would be difficult to make work with the testing setup. Those reason notes are a bit inconsistently applied and messy though. If that's important I can go through them again and try a more principled approach. When I run `rg '```ignore \(' .` on the repo, there look to be lots of different conventions other people have used for this sort of thing. I could try unifying them all if that would be helpful. I'm not sure if there was a better existing way to do this but I wrote my own script to help me run all the doctests and wade through the output. If that would be useful to anyone else, I put it here: https://github.com/Elliot-Roberts/rust_doctest_fixing_tool
2022-05-06remove all usages of hir().def_kindMiguel Guarniz-5/+0
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-02fix most compiler/ doctestsElliot Roberts-1/+1
2022-05-02rustc: Panic by default in `DefIdTree::parent`Vadim Petrochenkov-1/+1
Only crate root def-ids don't have a parent, and in majority of cases the argument of `DefIdTree::parent` cannot be a crate root. So we now panic by default in `parent` and introduce a new non-panicing function `opt_parent` for cases where the argument can be a crate root. Same applies to `local_parent`/`opt_local_parent`.
2022-04-23Hash visibilities in crate_hash.Camille GILLOT-0/+4
2022-04-23Stop visiting visibility.Camille GILLOT-8/+0
2022-04-17Auto merge of #95655 - kckeiks:create-hir-crate-items-query, r=cjgillotbors-14/+75
Refactor HIR item-like traversal (part 1) Issue #95004 - Create hir_crate_items query which traverses tcx.hir_crate(()).owners to return a hir::ModuleItems - use tcx.hir_crate_items in tcx.hir().items() to return an iterator of hir::ItemId - use tcx.hir_crate_items to introduce a tcx.hir().par_items(impl Fn(hir::ItemId)) to traverse all items in parallel; Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com> cc `@cjgillot`
2022-04-15Rollup merge of #95194 - kckeiks:update-algo-in-find-use-placement, r=pnkfelixDylan DPC-2/+2
remove find_use_placement A more robust solution to finding where to place use suggestions was added in #94584. The algorithm uses the AST to find the span for the suggestion so we pass this span down to the HIR during lowering and use it instead of calling `find_use_placement` Fixes #94941
2022-04-09rename to par_for_each_itemMiguel Guarniz-1/+1
2022-04-09avoid creating vec in methods in ModuleItemsMiguel Guarniz-2/+2
2022-04-09Use def_key in `tcx.item_name` when possible.Camille GILLOT-7/+6
2022-04-08Refactor HIR item-like traversal (part 1)Miguel Guarniz-14/+75
- Create hir_crate_items query which traverses tcx.hir_crate(()).owners to return a hir::ModuleItems - use tcx.hir_crate_items in tcx.hir().items() to return an iterator of hir::ItemId - add par_items(impl Fn(hir::ItemId)) to traverse all items in parallel Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-04-07Compute `ty_param_owner` using DefIdTree.Camille GILLOT-8/+7
2022-03-31remove find_use_placementFausto-2/+2
A more robust solution to finding where to place use suggestions was added. The algorithm uses the AST to find the span for the suggestion so we pass this span down to the HIR during lowering and use it. Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-03-31Rollup merge of #95497 - nyurik:compiler-spell-comments, r=compiler-errorsDylan DPC-1/+1
Spellchecking compiler comments This PR cleans up the rest of the spelling mistakes in the compiler comments. This PR does not change any literal or code spelling issues.
2022-03-30Auto merge of #95436 - cjgillot:static-mut, r=oli-obkbors-21/+18
Remember mutability in `DefKind::Static`. This allows to compute the `BodyOwnerKind` from `DefKind` only, and removes a direct dependency of some MIR queries onto HIR. As a side effect, it also simplifies metadata, since we don't need 4 flavours of `EntryKind::*Static` any more.
2022-03-30Spellchecking compiler commentsYuri Astrakhan-1/+1
This PR cleans up the rest of the spelling mistakes in the compiler comments. This PR does not change any literal or code spelling issues.
2022-03-30rework implementation for inherent impls for builtin typeslcnr-0/+4
2022-03-29Remember mutability in `DefKind::Static`.Camille GILLOT-21/+18
This allows to compute the `BodyOwnerKind` from `DefKind` only, and removes a direct dependency of some MIR queries onto HIR. As a side effect, it also simplifies metadata, since we don't need 4 flavours of `EntryKind::*Static` any more.
2022-02-24resolve: Fix incorrect results of `opt_def_kind` query for some built-in macrosVadim Petrochenkov-2/+1
Previously it always returned `MacroKind::Bang` while some of those macros are actually attributes and derives
2022-02-10Make all hir::Map methods consistently by-valueFrank Steffahn-78/+78
(hir::Map only consists of a single reference anyways)
2022-01-29Make local_def_id_to_hir_id query directly returh HirIdSantiago Pastorino-6/+1
2022-01-28Separate hir_owner query into two queries to avoid using extensive data on ↵Santiago Pastorino-15/+15
incr comp most of the time
2022-01-27Store def_id_to_hir_id as variant in hir_owner.Camille GILLOT-31/+38
If hir_owner is Owner(_), the LocalDefId is pointing to an owner, so the ItemLocalId is 0. If the HIR node does not exist, we store Phantom. Otherwise, we store the HirId associated to the LocalDefId.
2022-01-25Store hir_id_to_def_id in OwnerInfo.Camille GILLOT-2/+5
2022-01-16Replace NestedVisitorMap with NestedFilterCameron Steffen-3/+4
2022-01-15Reduce use of local_def_id_to_hir_id.Camille GILLOT-2/+1
2022-01-15Make ty_param_owner return a LocalDefId.Camille GILLOT-3/+5
2022-01-15Return a LocalDefId in get_parent_item.Camille GILLOT-18/+29
2022-01-15Add fast path to `opt_local_def_id`.Camille GILLOT-2/+6
2021-12-12Revert "Auto merge of #91491 - spastorino:revert-91354, r=oli-obk"Deadbeef-1/+2
This reverts commit ff2439b7b9bafcfdff86b7847128014699df8442, reversing changes made to 2a9e0831d6603d87220cedd1b1293e2eb82ef55c.
2021-12-03Revert "Auto merge of #91354 - fee1-dead:const_env, r=spastorino"Santiago Pastorino-2/+1
This reverts commit 18bb8c61a975fff6424cda831ace5b0404277145, reversing changes made to d9baa361902b172be716f96619b909f340802dea.
2021-12-02Auto merge of #91354 - fee1-dead:const_env, r=spastorinobors-1/+2
Cleanup: Eliminate ConstnessAnd This is almost a behaviour-free change and purely a refactoring. "almost" because we appear to be using the wrong ParamEnv somewhere already, and this is now exposed by failing a test using the unstable `~const` feature. We most definitely need to review all `without_const` and at some point should probably get rid of many of them by using `TraitPredicate` instead of `TraitRef`. This is a continuation of https://github.com/rust-lang/rust/pull/90274. r? `@oli-obk` cc `@spastorino` `@ecstatic-morse`
2021-11-29Re-use `constness_for_typeck` instead of rolling it ourselvesOli Scherer-17/+5
2021-11-29Add constness to ParamEnvOli Scherer-6/+19
This now causes a lot of queries to be executed twice, as reveal_all forces NotConst
2021-11-28Take a LocalDefId in expect_*item.Camille GILLOT-12/+14
2021-11-07Give inline const separate DefKindGary Guo-1/+9
2021-10-21Use SortedMap in HIR.Camille GILLOT-15/+9
2021-10-19Replace FnLikeNode by FnKind.Camille GILLOT-83/+0
2021-10-19Cleanup dead code in hir::map::blocks.Camille GILLOT-172/+14
2021-10-18Auto merge of #89124 - cjgillot:owner-info, r=michaelwoeristerbors-496/+72
Index and hash HIR as part of lowering Part of https://github.com/rust-lang/rust/pull/88186 ~Based on https://github.com/rust-lang/rust/pull/88880 (see merge commit).~ Once HIR is lowered, it is later indexed by the `index_hir` query and hashed for `crate_hash`. This PR moves those post-processing steps to lowering itself. As a side objective, the HIR crate data structure is refactored as an `IndexVec<LocalDefId, Option<OwnerInfo<'hir>>>` where `OwnerInfo` stores all the relevant information for an HIR owner. r? `@michaelwoerister` cc `@petrochenkov`
2021-10-17rustc_span: `Ident::invalid` -> `Ident::empty`Vadim Petrochenkov-1/+1
The equivalent for `Symbol`s was renamed some time ago (`kw::Invalid` -> `kw::Empty`), and it makes sense to do the same thing for `Ident`s.
2021-10-10Compute full HIR hash during lowering.Camille GILLOT-26/+19
2021-10-10Directly use AttributeMap inside OwnerInfo.Camille GILLOT-1/+1
2021-10-09Perform indexing during lowering.Camille GILLOT-404/+7
Do not access DefId<->HirId maps before they are initialized.
2021-10-09Make index_hir incremental.Camille GILLOT-121/+86
2021-10-09Hash during lowering.Camille GILLOT-27/+4
2021-10-09Forbid hashing HIR outside of indexing.Camille GILLOT-13/+17
2021-10-09Use an IndexVec for bodies.Camille GILLOT-12/+14
2021-10-09Store lowering outputs per owner.Camille GILLOT-19/+51