about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/hir
AgeCommit message (Collapse)AuthorLines
2021-10-03Remove re-export.Camille GILLOT-2/+2
2021-09-30Apply suggestions from code reviewCamille Gillot-1/+1
Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
2021-09-30Do not pass hir::Crate to lints.Camille GILLOT-1/+1
2021-09-29Move body_owners to tcx.hir().Camille GILLOT-0/+11
2021-09-29Avoid more invocations of hir_crate query.Camille GILLOT-0/+55
2021-09-21Rollup merge of #89078 - camsteffen:map-ref, r=cjgillotthe8472-8/+8
Cleanup: Remove needless reference in ParentHirIterator It forces an intermediate binding of `Map` which is a Copy type.
2021-09-20Do not store visibility in *ItemRef.Camille GILLOT-4/+4
2021-09-19Auto merge of #88703 - cjgillot:lazymod, r=petrochenkovbors-6/+116
Gather module items after lowering. This avoids having a non-local analysis inside lowering. By implementing `hir_module_items` using a visitor, we make sure that iterations and visitors are consistent.
2021-09-18Remove needless hir Map refCameron Steffen-8/+8
2021-09-18Do not preallocate UseTree HirIds.Camille GILLOT-6/+1
2021-09-12Use non-recursive algorithm in non-parallel compiler.Camille GILLOT-4/+10
2021-09-12Use boxed slice instead of BTreeSet.Camille GILLOT-34/+40
2021-09-12Gather module items after lowering.Camille GILLOT-3/+101
2021-09-12Rollup merge of #88677 - petrochenkov:exportid, r=davidtwcoManish Goregaokar-9/+4
rustc: Remove local variable IDs from `Export`s Local variables can never be exported.
2021-09-11Auto merge of #84373 - cjgillot:resolve-span, r=michaelwoerister,petrochenkovbors-13/+14
Encode spans relative to the enclosing item The aim of this PR is to avoid recomputing queries when code is moved without modification. MCP at https://github.com/rust-lang/compiler-team/issues/443 This is achieved by : 1. storing the HIR owner LocalDefId information inside the span; 2. encoding and decoding spans relative to the enclosing item in the incremental on-disk cache; 3. marking a dependency to the `source_span(LocalDefId)` query when we translate a span from the short (`Span`) representation to its explicit (`SpanData`) representation. Since all client code uses `Span`, step 3 ensures that all manipulations of span byte positions actually create the dependency edge between the caller and the `source_span(LocalDefId)`. This query return the actual absolute span of the parent item. As a consequence, any source code motion that changes the absolute byte position of a node will either: - modify the distance to the parent's beginning, so change the relative span's hash; - dirty `source_span`, and trigger the incremental recomputation of all code that depends on the span's absolute byte position. With this scheme, I believe the dependency tracking to be accurate. For the moment, the spans are marked during lowering. I'd rather do this during def-collection, but the AST MutVisitor is not practical enough just yet. The only difference is that we attach macro-expanded spans to their expansion point instead of the macro itself.
2021-09-10rustc: Remove local variable IDs from `Export`sVadim Petrochenkov-9/+4
Local variables can never be exported.
2021-09-10Add actual spans to the crate hash.Camille GILLOT-13/+13
Now that we encode spans relative to the items, the item's own span is never actually hashed as part of the HIR. In consequence, we explicitly include it in the crate hash to avoid missing cross-crate invalidations.
2021-09-10Track span dependency using a callback.Camille GILLOT-0/+1
2021-09-09Ignore automatically derived impls of `Clone` and `Debug` in dead code analysisFabian Wolff-7/+0
2021-09-05Auto merge of #88435 - cjgillot:no-walk-crate, r=Aaron1011bors-3/+20
Avoid invoking the hir_crate query to traverse the HIR Walking the HIR tree is done using the `hir_crate` query. However, this is unnecessary, since `hir_owner(CRATE_DEF_ID)` provides the same information. Since depending on `hir_crate` forces dependents to always be executed, this leads to unnecessary work. By splitting HIR and attributes visits, we can avoid an edge to `hir_crate` when trying to visit the HIR tree.
2021-09-02Rename walk_crate.Camille GILLOT-1/+1
2021-09-02Stop using walk_crate.Camille GILLOT-3/+20
2021-09-01Compute all_traits_impls during resolution.Camille GILLOT-1/+1
2021-08-28Remove obsolete `MacroDef` variant of `OwnerNode`inquisitivecrystal-13/+0
2021-08-28Treat macros as HIR itemsinquisitivecrystal-25/+2
2021-08-22Fix typos “a”→“an”Frank Steffahn-1/+1
2021-07-31rustc: Replace `HirId`s with `LocalDefId`s in `AccessLevels` tablesVadim Petrochenkov-8/+0
and passes using them - primarily privacy checking, stability checking and dead code checking. WIP
2021-07-27Auto merge of #83484 - JulianKnodt:infer, r=oli-obk,lcnrbors-0/+11
Add hir::GenericArg::Infer In order to extend inference to consts, make an Infer type on hir::GenericArg.
2021-07-25Auto merge of #83723 - cjgillot:ownernode, r=petrochenkovbors-182/+102
Store all HIR owners in the same container This replaces the previous storage in a BTreeMap for each of Item/ImplItem/TraitItem/ForeignItem. This should allow for a more compact storage. Based on https://github.com/rust-lang/rust/pull/83114
2021-07-25Use more of OwnerNode.Camille GILLOT-54/+43
2021-07-25Use OwnerNode in indexing.Camille GILLOT-106/+57
2021-07-25Introduce OwnerNode::Crate.Camille GILLOT-18/+2
2021-07-25Merge the BTreeMap in hir::Crate.Camille GILLOT-8/+4
2021-07-25Add inferred args to typeckkadmin-1/+1
2021-07-25Add generic arg inferkadmin-0/+11
2021-07-24Auto merge of #86580 - BoxyUwU:cgd-subst-ice, r=nikomatsakisbors-0/+13
dont provide fwd declared params to cg defaults Fixes #83938 ```rust #![feature(const_evaluatable_checked, const_generics, const_generics_defaults)] #![allow(incomplete_features)] pub struct Bar<const N: usize, const M: usize = { N + 1 }>; pub fn foo<const N1: usize>() -> Bar<N1> { loop {} } fn main() {} ``` This PR makes this code no longer ICE, it was ICE'ing previously because when building substs for `Bar<N1>` we would subst the anon ct: `ConstKind::Unevaluated({N + 1}, substs: [N, M])` with substs of `[N1]`. the anon const has forward declared params supplied though so we end up trying to substitute the provided `M` param which causes the ICE. This PR doesn't handle the predicates of the const so ```rust trait Foo<const N: usize> { const Assoc: usize; } pub struct Bar<const N: usize = { <()>::Assoc }> where (): Foo<N>; ``` Resolves to `<() as Foo<N>>::Assoc` which can allow for using fwd declared params indirectly. ```rust trait Foo<const N: usize> {} struct Bar<const N: usize = { 2 + 3 }> where (): Foo<N>; ``` This code also ICEs under this PR because instantiating the default's predicates causes an ICE as predicates_of contains predicates with fwd declared params PR was briefly discussed [in this zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/evil.20preds.20in.20param.20env.20.2386580)
2021-07-20Support HIR wf checking for function signaturesAaron Hill-1/+4
During function type-checking, we normalize any associated types in the function signature (argument types + return type), and then create WF obligations for each of the normalized types. The HIR wf code does not currently support this case, so any errors that we get have imprecise spans. This commit extends `ObligationCauseCode::WellFormed` to support recording a function parameter, allowing us to get the corresponding HIR type if an error occurs. Function typechecking is modified to pass this information during signature normalization and WF checking. The resulting code is fairly verbose, due to the fact that we can no longer normalize the entire signature with a single function call. As part of the refactoring, we now perform HIR-based WF checking for several other 'typed items' (statics, consts, and inherent impls). As a result, WF and projection errors in a function signature now have a precise span, which points directly at the responsible type. If a function signature is constructed via a macro, this will allow the error message to point at the code 'most responsible' for the error (e.g. a user-supplied macro argument).
2021-07-14Shrink the CrateStore dynamic interface.Camille GILLOT-7/+6
2021-07-13Put checking if anonct is a default into a method on hir mapEllen-0/+13
2021-07-13Auto merge of #86857 - fee1-dead:add-attr, r=oli-obkbors-1/+9
Add #[default_method_body_is_const] `@rustbot` label F-const_trait_impl
2021-07-10functions marked with attr are not constDeadbeef-1/+9
2021-07-06Correct comments about untracked accesses.Camille GILLOT-12/+14
2021-07-06Make resolutions a query.Camille GILLOT-11/+24
2021-07-06Revert "Revert "Merge CrateDisambiguator into StableCrateId""bjorn3-6/+6
This reverts commit 8176ab8bc18fdd7d3c2cf7f720c51166364c33a3.
2021-06-07Revert "Merge CrateDisambiguator into StableCrateId"bjorn3-6/+6
This reverts commit d0ec85d3fb6d322496cb8f4bc1c21e19f23284ad.
2021-06-04Always go through the expn_that_defined query.Camille GILLOT-0/+4
2021-06-01Revert "Reduce the amount of untracked state in TyCtxt"Camille Gillot-35/+15
2021-06-01Auto merge of #85153 - cjgillot:qresolve, r=Aaron1011bors-15/+35
Reduce the amount of untracked state in TyCtxt Access to untracked global state may generate instances of #84970. The GlobalCtxt contains the lowered HIR, the resolver outputs and interners. By wrapping the resolver inside a query, we make sure those accesses are properly tracked. As a no_hash query, all dependent queries essentially become `eval_always`, what they should have been from the beginning.
2021-05-31Auto merge of #85266 - cjgillot:hir-dep-clean, r=michaelwoeristerbors-38/+45
Remove obsolete workaround. The regression test for #62649 appears to pass even without the workaround.
2021-05-30Correct comments about untracked accesses.Camille GILLOT-13/+20