summary refs log tree commit diff
path: root/compiler/rustc_middle/src/hir/map
AgeCommit message (Collapse)AuthorLines
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-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-10/+23
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-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-27/+19
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
2021-05-30Make resolutions a query.Camille GILLOT-10/+23
2021-05-30Merge CrateDisambiguator into StableCrateIdbjorn3-6/+6
2021-05-28Merge fields and comment.Camille GILLOT-27/+19
2021-05-17Auto merge of #85178 - cjgillot:local-crate, r=oli-obkbors-6/+6
Remove CrateNum parameter for queries that only work on local crate The pervasive `CrateNum` parameter is a remnant of the multi-crate rustc idea. Using `()` as query key in those cases avoids having to worry about the validity of the query key.
2021-05-12Use () for HIR queries.Camille GILLOT-6/+6
2021-05-12Auto merge of #83813 - cbeuw:remap-std, r=michaelwoeristerbors-1/+1
Fix `--remap-path-prefix` not correctly remapping `rust-src` component paths and unify handling of path mapping with virtualized paths This PR fixes #73167 ("Binaries end up containing path to the rust-src component despite `--remap-path-prefix`") by preventing real local filesystem paths from reaching compilation output if the path is supposed to be remapped. `RealFileName::Named` introduced in #72767 is now renamed as `LocalPath`, because this variant wraps a (most likely) valid local filesystem path. `RealFileName::Devirtualized` is renamed as `Remapped` to be used for remapped path from a real path via `--remap-path-prefix` argument, as well as real path inferred from a virtualized (during compiler bootstrapping) `/rustc/...` path. The `local_path` field is now an `Option<PathBuf>`, as it will be set to `None` before serialisation, so it never reaches any build output. Attempting to serialise a non-`None` `local_path` will cause an assertion faliure. When a path is remapped, a `RealFileName::Remapped` variant is created. The original path is preserved in `local_path` field and the remapped path is saved in `virtual_name` field. Previously, the `local_path` is directly modified which goes against its purpose of "suitable for reading from the file system on the local host". `rustc_span::SourceFile`'s fields `unmapped_path` (introduced by #44940) and `name_was_remapped` (introduced by #41508 when `--remap-path-prefix` feature originally added) are removed, as these two pieces of information can be inferred from the `name` field: if it's anything other than a `FileName::Real(_)`, or if it is a `FileName::Real(RealFileName::LocalPath(_))`, then clearly `name_was_remapped` would've been false and `unmapped_path` would've been `None`. If it is a `FileName::Real(RealFileName::Remapped{local_path, virtual_name})`, then `name_was_remapped` would've been true and `unmapped_path` would've been `Some(local_path)`. cc `@eddyb` who implemented `/rustc/...` path devirtualisation
2021-05-11Split span_to_string into span_to_diagnostic/embeddable_stringAndy Wang-1/+1
2021-05-07Hash attributes as part of the crate hash.Camille GILLOT-4/+9
2021-04-29Introduce a hir_owner_parent query.Camille GILLOT-2/+1
2021-04-29Move parenting info to index_hir.Camille GILLOT-20/+38
2021-04-29Do not compute entry parent when not required.Camille GILLOT-98/+125
2021-04-29Remove parent_node.Camille GILLOT-10/+1
2021-04-29Split crate_hash from index_hir.Camille GILLOT-110/+85
2021-04-27Add [TRACKED_NO_CRATE_HASH] and [SUBSTRUCT] directivesJoshua Nelson-1/+1
This is necessary for options that should invalidate the incremental hash but *not* affect the crate hash (e.g. --remap-path-prefix). This doesn't add `for_crate_hash` to the trait directly because it's not relevant for *types*, only for *options*, which are fields on a larger struct. Instead, it adds a new `SUBSTRUCT` directive for options, which does take a `for_crate_hash` parameter. - Use TRACKED_NO_CRATE_HASH for --remap-path-prefix - Add test that `remap_path_prefix` is tracked - Reduce duplication in the test suite to avoid future churn
2021-03-30Remove hir::CrateItem.Camille GILLOT-2/+2
2021-03-27Remove (lots of) dead codeJoshua Nelson-29/+0
Found with https://github.com/est31/warnalyzer. Dubious changes: - Is anyone else using rustc_apfloat? I feel weird completely deleting x87 support. - Maybe some of the dead code in rustc_data_structures, in case someone wants to use it in the future? - Don't change rustc_serialize I plan to scrap most of the json module in the near future (see https://github.com/rust-lang/compiler-team/issues/418) and fixing the tests needed more work than I expected. TODO: check if any of the comments on the deleted code should be kept.
2021-03-25Auto merge of #83424 - cjgillot:noparam, r=lcnrbors-20/+2
GenericParam does not need to be a HIR owner. The special case is not required. Universal impl traits design to regular generic parameters, and their content is owned by the enclosing item. Existential (and opaque) impl traits generate their own enclosing item, and are collected through it.
2021-03-23GenericParam does not need to be a HIR owner.Camille GILLOT-20/+2
2021-03-23progress, stuff compiles nowlcnr-0/+4
2021-03-17Auto merge of #83188 - petrochenkov:field, r=lcnrbors-2/+2
ast/hir: Rename field-related structures I always forget what `ast::Field` and `ast::StructField` mean despite working with AST for long time, so this PR changes the naming to less confusing and more consistent. - `StructField` -> `FieldDef` ("field definition") - `Field` -> `ExprField` ("expression field", not "field expression") - `FieldPat` -> `PatField` ("pattern field", not "field pattern") Various visiting and other methods working with the fields are renamed correspondingly too. The second commit reduces the size of `ExprKind` by boxing fields of `ExprKind::Struct` in preparation for https://github.com/rust-lang/rust/pull/80080.
2021-03-17Rollup merge of #83124 - cjgillot:iiib, r=petrochenkovYuki Okushi-3/+2
Do not insert impl_trait_in_bindings opaque definitions twice. The reference to the item already appears inside the `OpaqueDef`. It does not need to be repeated as a statement.
2021-03-16ast/hir: Rename field-related structuresVadim Petrochenkov-2/+2
StructField -> FieldDef ("field definition") Field -> ExprField ("expression field", not "field expression") FieldPat -> PatField ("pattern field", not "field pattern") Also rename visiting and other methods working on them.
2021-03-15Rollup merge of #83108 - jyn514:remove-unused, r=estebankDylan DPC-5/+0
Remove unused `opt_local_def_id_to_hir_id` function Found while investigating #82933 - all LocalDefIds are expected to have HirIds, there's no point in pretending otherwise.
2021-03-14Assert there is no duplicate node.Camille GILLOT-3/+2
2021-03-14Remove unused `opt_local_def_id_to_hir_id` functionJoshua Nelson-5/+0
Found while investigating #82933 - all LocalDefIds are expected to have HirIds, there's no point in pretending otherwise.
2021-03-12Make def_key and HIR parenting consistent.Camille GILLOT-0/+12
2021-03-09Use BTreeMap to store attributes.Camille GILLOT-7/+2
2021-03-09Do not store attrs in FnKind.Camille GILLOT-25/+13
2021-03-09Collect attributes during HIR lowering.Camille GILLOT-33/+9
2021-02-16Auto merge of #81611 - cjgillot:meowner, r=estebankbors-114/+40
Only store a LocalDefId in some HIR nodes Some HIR nodes are guaranteed to be HIR owners: Item, TraitItem, ImplItem, ForeignItem and MacroDef. As a consequence, we do not need to store the `HirId`'s `local_id`, and we can directly store a `LocalDefId`. This allows to avoid a bit of the dance with `tcx.hir().local_def_id` and `tcx.hir().local_def_id_to_hir_id` mappings.
2021-02-16avoid full-slicing slicesMatthias Krüger-9/+9
If we already have a slice, there is no need to get another full-range slice from that, just use the original. clippy::redundant_slicing
2021-02-15Remove HirItemLike.Camille GILLOT-25/+7
2021-02-15Trait impls are Items, therefore HIR owners.Camille GILLOT-1/+1
2021-02-15Only store a LocalDefId in hir::MacroDef.Camille GILLOT-4/+4
2021-02-15Only store a LocalDefId in hir::ForeignItem.Camille GILLOT-8/+4
2021-02-15Only store a LocalDefId in hir::ImplItem.Camille GILLOT-9/+5
2021-02-15Only store a LocalDefId in hir::TraitItem.Camille GILLOT-9/+5
2021-02-15Only store a LocalDefId in hir::Item.Camille GILLOT-9/+6
Items are guaranteed to be HIR owner.