about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/hir
AgeCommit message (Collapse)AuthorLines
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/+5
2021-04-29Move parenting info to index_hir.Camille GILLOT-26/+41
2021-04-29Do not compute entry parent when not required.Camille GILLOT-100/+127
2021-04-29Remove parent_node.Camille GILLOT-10/+1
2021-04-29Split crate_hash from index_hir.Camille GILLOT-110/+97
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-8/+47
2021-03-09Do not store attrs in FnKind.Camille GILLOT-25/+13
2021-03-09Collect attributes during HIR lowering.Camille GILLOT-33/+10
2021-02-16Auto merge of #81611 - cjgillot:meowner, r=estebankbors-119/+41
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-15Index Modules using their LocalDefId.Camille GILLOT-5/+1
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.
2021-02-15Use ItemId as a strongly typed index.Camille GILLOT-9/+9
2021-02-15Remove useless Named trait.Camille GILLOT-41/+0
2021-02-12Fix typo in mod.rsIkko Ashimine-1/+1
insted -> instead
2021-02-02Bump rustfmt versionMark Rousskov-3/+3
Also switches on formatting of the mir build module
2021-02-01Fixed #[inline] to be warned in fields, arms, macro defsDanuel-0/+18
Add visitors for checking #[inline] Add visitors for checking #[inline] with struct field Fix test for #[inline] Add visitors for checking #[inline] with #[macro_export] macro Add visitors for checking #[inline] without #[macro_export] macro Add use alias with Visitor Fix lint error Reduce unnecessary variable Co-authored-by: LingMan <LingMan@users.noreply.github.com> Change error to warning Add warning for checking field, arm with #[allow_internal_unstable] Add name resolver Formatting Formatting Fix error fixture Add checking field, arm, macro def
2021-01-27Rollup merge of #81325 - osa1:issue81293, r=estebankYuki Okushi-0/+11
typeck: Don't suggest converting LHS exprs Converting LHS of an assignment does not work, so avoid suggesting that. Fixes #81293
2021-01-26typeck: Don't suggest converting LHS exprsÖmer Sinan Ağacan-0/+11
Converting LHS of an assignment does not work, so avoid suggesting that. Fixes #81293
2021-01-26Auto merge of #80692 - Aaron1011:feature/query-result-debug, r=estebankbors-1/+5
Enforce that query results implement Debug Currently, we require that query keys implement `Debug`, but we do not do the same for query values. This can make incremental compilation bugs difficult to debug - there isn't a good place to print out the result loaded from disk. This PR adds `Debug` bounds to several query-related functions, allowing us to debug-print the query value when an 'unstable fingerprint' error occurs. This required adding `#[derive(Debug)]` to a fairly large number of types - hopefully, this doesn't have much of an impact on compiler bootstrapping times.
2021-01-23Allow to query the HIR crate node.Camille GILLOT-5/+3
2021-01-23Iterate to encode def_kind.Camille GILLOT-11/+12
2021-01-23Iterate DefId to encode spans.Camille GILLOT-0/+4
2021-01-23Infallible version of def_span.Camille GILLOT-32/+39
2021-01-16Enforce that query results implement DebugAaron Hill-1/+5
2021-01-14Use Option::map_or instead of `.map(..).unwrap_or(..)`LingMan-3/+2
2021-01-14Auto merge of #79328 - c410-f3r:hir-if, r=matthewjasperbors-5/+7
Reintroduce hir::ExprKind::If Basically copied and paste #59288/https://github.com/rust-lang/rust-clippy/pull/4080 with some modifications. The vast majority of tests were fixed and now there are only a few remaining. Since I am still unable to figure out the missing pieces, any help with the following list is welcome. - [ ] **Unnecessary `typeck` exception**: [Cheated on this one to make CI green.](https://github.com/rust-lang/rust/pull/79328/files#diff-3faee9ba23fc54a12b7c43364ba81f8c5660045c7e1d7989a02a0cee1c5b2051) - [x] **Incorrect span**: [Span should reference `then` and `else` separately.](https://github.com/rust-lang/rust/pull/79328/files#diff-cf2c46e82222ee4b1037a68fff8a1af3c4f1de7a6b3fd798aacbf3c0475abe3d) - [x] **New note regarding `assert!`**: [Modified but not "wrong". Maybe can be a good thing?](https://github.com/rust-lang/rust/pull/79328/files#diff-9e0d7c89ed0224e2b62060c957177c27db43c30dfe3c2974cb6b5091cda9cfb5) - [x] **Inverted report location**: [Modified but not "wrong". Locations were inverted.](https://github.com/rust-lang/rust/pull/79328/files#diff-f637ce7c1f68d523a165aa9651765df05e36c4d7d279194b1a6b28b48a323691) - [x] **`src/test/ui/point-to-type-err-cause-on-impl-trait-return.rs` has weird errors**: [Not sure why this is happening.](https://github.com/rust-lang/rust/pull/79328/files#diff-c823c09660f5b112f95e97e8ff71f1797b6c7f37dbb3d16f8e98bbaea8072e95) - [x] **Missing diagnostic**: [???](https://github.com/rust-lang/rust/pull/79328/files#diff-6b8ab09360d725ba4513933827f9796b42ff9522b0690f80b76de067143af2fc)
2021-01-13Auto merge of #79322 - jyn514:refactor-impl, r=estebankbors-1/+1
Separate out a `hir::Impl` struct This makes it possible to pass the `Impl` directly to functions, instead of having to pass each of the many fields one at a time. It also simplifies matches in many cases. See `rustc_save_analysis::dump_visitor::process_impl` or `rustdoc::clean::clean_impl` for a good example of how this makes `impl`s easier to work with. r? `@petrochenkov` maybe?