Commit graph

281 commits

Author SHA1 Message Date
Matthias Krüger
87822b27ee
Rollup merge of #89558 - lcnr:query-stable-lint, r=estebank
Add rustc lint, warning when iterating over hashmaps

r? rust-lang/wg-incr-comp
2021-10-24 15:48:42 +02:00
Yuki Okushi
91fb223f59
Rollup merge of #89895 - camsteffen:for-loop-head-span, r=davidtwco
Don't mark for loop iter expression as desugared

We typically don't mark spans of lowered things as desugared. This helps Clippy rightly discern when code is (not) from expansion. This was discovered by ``@flip1995`` at https://github.com/rust-lang/rust-clippy/pull/7789#issuecomment-939289501.
2021-10-22 19:42:45 +09:00
bors
bd41e09da3 Auto merge of #89124 - cjgillot:owner-info, r=michaelwoerister
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-18 19:53:05 +00:00
Vadim Petrochenkov
a6808335d4 rustc_span: Ident::invalid -> Ident::empty
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-17 23:20:30 +03:00
Cameron Steffen
a697aa63d6 Use more lowered spans in for loop 2021-10-15 08:04:51 -05:00
Cameron Steffen
bd1a1e4f0d Don't mark for loop head span with desugaring 2021-10-15 08:04:50 -05:00
lcnr
00e5abe9b6 allow potential_query_instability everywhere 2021-10-15 10:58:18 +02:00
Camille GILLOT
c5628a5e65 Use invalid local id for zeroth node parent. 2021-10-12 08:41:53 +02:00
Camille GILLOT
12b39e5912 Make naming more explicit. 2021-10-11 22:36:37 +02:00
Camille GILLOT
0431fdb113 Compute full HIR hash during lowering. 2021-10-10 00:05:49 +02:00
Camille GILLOT
41e80b85cf Directly use AttributeMap inside OwnerInfo. 2021-10-10 00:05:35 +02:00
Camille GILLOT
1c7f85f17c Perform indexing during lowering.
Do not access DefId<->HirId maps before they are initialized.
2021-10-09 23:47:59 +02:00
Camille GILLOT
ed3c8e86cb Hash during lowering. 2021-10-09 19:44:55 +02:00
Camille GILLOT
457de08487 Forbid hashing HIR outside of indexing. 2021-10-09 18:38:28 +02:00
Camille GILLOT
cd1ace488f Use an IndexVec for bodies. 2021-10-09 14:01:09 +02:00
Camille GILLOT
48a339ddbb Store lowering outputs per owner. 2021-10-09 11:56:29 +02:00
Matthias Krüger
5ebb6a8fd9
Rollup merge of #89641 - asquared31415:asm-feature-attr-regs, r=oli-obk
make #[target_feature] work with `asm` register classes

Fixes #89289
2021-10-09 11:56:00 +02:00
Matthias Krüger
e6f77a1787 clippy::complexity fixes 2021-10-08 20:07:44 +02:00
asquared31415
271da7d8bc make #[target_feature] work with asm register classes 2021-10-07 15:42:18 -04:00
Cameron Steffen
67ea84d97a Add desugaring mark to while loop 2021-10-02 17:41:14 -05:00
Manish Goregaokar
746e46548c
Rollup merge of #89344 - jackh726:maybe-bound-eror, r=cjgillot
Cleanup lower_generics_mut and make span be the bound itself

Closes #86298 (supersedes those changes)

r? `@cjgillot` since you reviewed the other PR

(Used wrong branch for #89338)
2021-09-30 23:41:09 -07:00
jackh726
e1a9ecca26 Cleanup lower_generics_mut and make span be the bound itself, not the type 2021-09-29 13:31:03 -04:00
Vadim Petrochenkov
fbe5e5c0ee rustc_index: Add some map-like APIs to IndexVec 2021-09-22 03:11:29 +03:00
bors
ac2d9fc509 Auto merge of #89103 - Mark-Simulacrum:migrate-2021, r=estebank
Migrate in-tree crates to 2021

This replaces #89075 (cherry picking some of the commits from there), and closes #88637 and fixes #89074.

It excludes a migration of the library crates for now (see tidy diff) because we have some pending bugs around macro spans to fix there.

I instrumented bootstrap during the migration to make sure all crates moved from 2018 to 2021 had the compatibility warnings applied first.

Originally, the intent was to support cargo fix --edition within bootstrap, but this proved fairly difficult to pull off. We'd need to architect the check functionality to support running cargo check and cargo fix within the same x.py invocation, and only resetting sysroots on check. Further, it was found that cargo fix doesn't behave too well with "not quite workspaces", such as Clippy which has several crates. Bootstrap runs with --manifest-path ... for all the tools, and this makes cargo fix only attempt migration for that crate. We can't use e.g. --workspace due to needing to maintain sysroots for different phases of compilation appropriately.

It is recommended to skip the mass migration of Cargo.toml's to 2021 for review purposes; you can also use `git diff d6cd2c6c87 -I'^edition = .20...$'` to ignore the edition = 2018/21 lines in the diff.
2021-09-21 19:25:49 +00:00
Mark Rousskov
c746be2219 Migrate to 2021 2021-09-20 22:21:42 -04:00
Camille GILLOT
a1a35576eb Make with_hir_id_owner responsible for registering the item. 2021-09-20 08:31:16 +02:00
Camille GILLOT
c1bac9229a Remove lower_node_id_with_owner. 2021-09-20 00:50:47 +02:00
Camille GILLOT
d7795d302a Do not store visibility in *ItemRef. 2021-09-20 00:29:53 +02:00
bors
7b5f95270f Auto merge of #88703 - cjgillot:lazymod, r=petrochenkov
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-19 16:13:42 +00:00
bors
697118d23e Auto merge of #88627 - cjgillot:noallocuse, r=petrochenkov
Do not preallocate HirIds

Part of https://github.com/rust-lang/rust/pull/87234

r? `@petrochenkov`
2021-09-19 13:44:18 +00:00
Camille GILLOT
d60bbde7e2 Do not preallocate UseTree HirIds. 2021-09-18 14:41:50 +02:00
Camille GILLOT
59f43bdd29 Do not preallocate item HirIds. 2021-09-18 13:14:29 +02:00
Manish Goregaokar
fb2d7dff80
Rollup merge of #88775 - pnkfelix:revert-anon-union-parsing, r=davidtwco
Revert anon union parsing

Revert PR #84571 and #85515, which implemented anonymous union parsing in a manner that broke the context-sensitivity for the `union` keyword and thus broke stable Rust code.

Fix #88583.
2021-09-15 14:56:58 -07:00
Camille GILLOT
fa6f5adf73 Gather module items after lowering. 2021-09-12 16:33:16 +02:00
bors
547d9374d2 Auto merge of #84373 - cjgillot:resolve-span, r=michaelwoerister,petrochenkov
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-11 23:35:28 +00:00
Camille GILLOT
7842b80478 Rebase fallout. 2021-09-11 17:52:39 +02:00
bors
4e880f8cbc Auto merge of #88214 - notriddle:notriddle/for-loop-span-drop-temps-mut, r=nagisa
rustc: use more correct span data in for loop desugaring

Fixes #82462

Before:

      help: consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped
         |
      LL |     for x in DroppingSlice(&*v).iter(); {
         |                                       +

After:

      help: consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped
         |
      LL |     };
         |      +

This seems like a reasonable fix: since the desugared "expr_drop_temps_mut" contains the entire desugared loop construct, its span should contain the entire loop construct as well.
2021-09-11 07:11:01 +00:00
Camille GILLOT
f84856cbb0 Give spans their parent item during lowering.
We only do this operation when incremental compilation is enabled. This
avoids pessimizing the span handling for non-incremental compilation.
2021-09-10 20:18:36 +02:00
Camille GILLOT
fb5ced0fbd Add sanity check.
We force the relative span's parent to be absolute. This avoids having to
handle long dependency chains.
2021-09-10 20:18:26 +02:00
Camille GILLOT
e85ddeb474 Encode spans relative to their parent. 2021-09-10 20:18:11 +02:00
Felix S. Klock II
91feb76d13 Revert "Implement Anonymous{Struct, Union} in the AST"
This reverts commit 059b68dd67.

Note that this was manually adjusted to retain some of the refactoring
introduced by commit 059b68dd67, so that it could
likewise retain the correction introduced in commit
5b4bc05fa5
2021-09-09 09:14:17 -04:00
jackh726
216906fb75 Change is_unsized to add_implicitly_sized 2021-09-07 18:08:46 -04:00
jackh726
f1f1d56d93 Don't move ?Trait bounds to param bounds if they're in where clauses 2021-09-07 18:08:46 -04:00
Camille GILLOT
fed4410def Replace Vec by Option. 2021-09-03 23:36:22 +02:00
Camille GILLOT
1baac86670 Simplify lifetimes_from_impl_trait_bounds. 2021-09-03 23:35:55 +02:00
bors
577a76f003 Auto merge of #88597 - cjgillot:lower-global, r=petrochenkov
Move global analyses from lowering to resolution

Split off https://github.com/rust-lang/rust/pull/87234

r? `@petrochenkov`
2021-09-03 14:47:13 +00:00
bors
b27ccbc7e1 Auto merge of #87114 - cjgillot:abilint, r=estebank
Lint missing Abi in ast validation instead of lowering.
2021-09-02 06:06:24 +00:00
Camille GILLOT
f8efe5d822 Compute proc_macros in resolutions. 2021-09-01 20:13:16 +02:00
Camille GILLOT
635978041d Compute all_traits_impls during resolution. 2021-09-01 20:13:16 +02:00
Camille GILLOT
26eeec0baf Compute item_generics_num_lifetimes during resolution. 2021-09-01 20:13:16 +02:00