Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Almost fully deprecate hir::map::Map.hir_to_node_id #62975

Merged
merged 1 commit into from
Sep 25, 2019

Conversation

ljedrz
Copy link
Contributor

@ljedrz ljedrz commented Jul 25, 2019

  • HirIdify doctree::Module.id
  • HirIdify hir::Crate.modules
  • introduce a HirId to DefIndex map in map::Definitions

The only last uses of hir::map::Map.hir_to_node_id in the compiler are:

  • for the purposes of driver::pretty (in map::nodes_matching_suffix), but I don't know if we can remove NodeIds in there (I think when I attempted it previously there was some issue due to HirId not being representable with an integer)
  • in ty::query::on_disk_cache (not sure about the purpose of this one)
  • in mir::transform::check_unsafety (only important for error message order)

Any suggestions how to kill these off?

r? @Zoxc

@rust-highfive

This comment has been minimized.

@jonas-schievink jonas-schievink added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 26, 2019
@wirelessringo
Copy link

Ping from triage. @Zoxc any updates on this?

src/librustc/hir/lowering.rs Outdated Show resolved Hide resolved
@ljedrz
Copy link
Contributor Author

ljedrz commented Aug 5, 2019

@Zoxc done 👍

@bors
Copy link
Contributor

bors commented Aug 10, 2019

☔ The latest upstream changes (presumably #62955) made this pull request unmergeable. Please resolve the merge conflicts.

pub hir_to_def_index: HirIdMap<DefIndex>,
/// `DefIndex`es created by DefCollector::create_def; used only to complete the hir_to_def_index
/// mapping after the lowering
defs_awaiting_hir_id: NodeMap<DefIndex>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is another reason why I would prefer if everything with a DefId was a HirId root: you wouldn't need any mappings, a HIR node with a DefId would have a HirId of (def_id, 0).
cc @michaelwoerister @nikomatsakis @petrochenkov

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, we wanted HirId owners to correspond to item-likes mainly because that's the incremental compilation granularity we were shooting for.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, but that seems like it's introducing artificial complexity (with perhaps the exception of TypeckTables - but even in that case, we could just have separate TypeckTables for closures, that are kept in a map in the parent body's TypeckTables).

Bonus: right now things like embedded constants have their own TypeckTables but share a HirId space with their enclosing item, meaning their intra-item IDs are not in a nice 0..n range (if they were, we could maybe use something more efficient than hashmaps).

@Zoxc
Copy link
Contributor

Zoxc commented Aug 20, 2019

The first two commits look good to me, feel free to split those out to a separate PR. I'm less sure about the last one though. I'm probably not the best person to review that.

@ljedrz ljedrz force-pushed the kill_off_hir_to_node_id branch 2 times, most recently from 08f5d85 to 1954174 Compare August 24, 2019 13:54
@ljedrz
Copy link
Contributor Author

ljedrz commented Aug 24, 2019

@Zoxc seems that someone already pushed one of those two, so I left the other one and I'll post the last commit as a separate PR.

@rust-highfive
Copy link
Collaborator

The job mingw-check of your PR failed (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-08-24T13:55:28.0979814Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-08-24T13:55:28.1521116Z ##[command]git config gc.auto 0
2019-08-24T13:55:28.1598788Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-08-24T13:55:28.1646638Z ##[command]git config --get-all http.proxy
2019-08-24T13:55:28.1770920Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/62975/merge:refs/remotes/pull/62975/merge
---
2019-08-24T13:56:01.4491180Z do so (now or later) by using -b with the checkout command again. Example:
2019-08-24T13:56:01.4491229Z 
2019-08-24T13:56:01.4491440Z   git checkout -b <new-branch-name>
2019-08-24T13:56:01.4491469Z 
2019-08-24T13:56:01.4491517Z HEAD is now at 4c2750cf9 Merge 1954174ec1ba7acabfdf8359f55ff5d77094005a into 478464570e60523adc6d303577d1782229ca1f93
2019-08-24T13:56:01.4663022Z ##[section]Starting: Collect CPU-usage statistics in the background
2019-08-24T13:56:01.4665484Z ==============================================================================
2019-08-24T13:56:01.4666701Z Task         : Bash
2019-08-24T13:56:01.4666755Z Description  : Run a Bash script on macOS, Linux, or Windows
---
2019-08-24T14:03:43.5348761Z     Checking syntax_ext v0.0.0 (/checkout/src/libsyntax_ext)
2019-08-24T14:03:54.5957343Z error[E0308]: mismatched types
2019-08-24T14:03:54.5957749Z   --> src/librustc/hir/lowering/item.rs:48:34
2019-08-24T14:03:54.5958142Z    |
2019-08-24T14:03:54.5958470Z 48 |         self.lctx.modules.insert(n, hir::ModuleItems {
2019-08-24T14:03:54.5958975Z    |                                  ^ expected struct `hir::HirId`, found struct `syntax::ast::NodeId`
2019-08-24T14:03:54.5959430Z    = note: expected type `hir::HirId`
2019-08-24T14:03:54.5968598Z               found type `syntax::ast::NodeId`
2019-08-24T14:03:54.5968637Z 
2019-08-24T14:03:54.6817109Z error[E0308]: mismatched types
2019-08-24T14:03:54.6817109Z error[E0308]: mismatched types
2019-08-24T14:03:54.6817428Z   --> src/librustc/hir/lowering/item.rs:55:36
2019-08-24T14:03:54.6817830Z    |
2019-08-24T14:03:54.6818263Z 55 |         self.lctx.current_module = n;
2019-08-24T14:03:54.6818599Z    |                                    ^ expected struct `hir::HirId`, found struct `syntax::ast::NodeId`
2019-08-24T14:03:54.6819579Z    = note: expected type `hir::HirId`
2019-08-24T14:03:54.6820047Z               found type `syntax::ast::NodeId`
2019-08-24T14:03:54.6820096Z 
2019-08-24T14:04:08.2234468Z error: aborting due to 2 previous errors
---
2019-08-24T14:04:08.4112081Z == clock drift check ==
2019-08-24T14:04:08.4124400Z   local time: Sat Aug 24 14:04:08 UTC 2019
2019-08-24T14:04:08.6166054Z   network time: Sat, 24 Aug 2019 14:04:08 GMT
2019-08-24T14:04:08.6166940Z == end clock drift check ==
2019-08-24T14:04:09.6322781Z ##[error]Bash exited with code '1'.
2019-08-24T14:04:09.6353667Z ##[section]Starting: Checkout
2019-08-24T14:04:09.6355410Z ==============================================================================
2019-08-24T14:04:09.6355467Z Task         : Get sources
2019-08-24T14:04:09.6355519Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@ljedrz
Copy link
Contributor Author

ljedrz commented Sep 1, 2019

r? @Zoxc

@JohnCSimon
Copy link
Member

Ping from triage:
@Zoxc Can you please review this PR?
cc: @ljedrz

Thank you!

@JohnCSimon
Copy link
Member

Pinging again from triage
@Zoxc @michaelwoerister Can you please review this PR?
cc: @ljedrz

Thank you!

@JohnTitor
Copy link
Member

Ping from triage: could someone review this? @rust-lang/compiler

@nikomatsakis
Copy link
Contributor

I will review it.

@nikomatsakis nikomatsakis assigned nikomatsakis and unassigned Zoxc Sep 24, 2019
@Zoxc
Copy link
Contributor

Zoxc commented Sep 25, 2019

@bors r+

@bors
Copy link
Contributor

bors commented Sep 25, 2019

📌 Commit 9a6ca41 has been approved by Zoxc

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 25, 2019
@bors
Copy link
Contributor

bors commented Sep 25, 2019

⌛ Testing commit 9a6ca41 with merge 3feba9538bbd452d2fcbd57a5dd5c9465a4010e2...

Centril added a commit to Centril/rust that referenced this pull request Sep 25, 2019
Almost fully deprecate hir::map::Map.hir_to_node_id

- HirIdify `doctree::Module.id`
- HirIdify `hir::Crate.modules`
- introduce a `HirId` to `DefIndex` map in `map::Definitions`

The only last uses of `hir::map::Map.hir_to_node_id` in the compiler are:
- for the purposes of `driver::pretty` (in `map::nodes_matching_suffix`), but I don't know if we can remove `NodeId`s in there (I think when I attempted it previously there was some issue due to `HirId` not being representable with an integer)
- in `ty::query::on_disk_cache` (not sure about the purpose of this one)
- in `mir::transform::check_unsafety` (only important for error message order)

Any suggestions how to kill these off?

r? @Zoxc
@Centril
Copy link
Contributor

Centril commented Sep 25, 2019

@bors retry rolled up.

bors added a commit that referenced this pull request Sep 25, 2019
Rollup of 6 pull requests

Successful merges:

 - #62975 (Almost fully deprecate hir::map::Map.hir_to_node_id)
 - #64386 (use `sign` variable in abs and wrapping_abs methods)
 - #64508 (or-patterns: Push `PatKind/PatternKind::Or` at top level to HIR & HAIR)
 - #64738 (Add const-eval support for SIMD types, insert, and extract)
 - #64759 (Refactor mbe a tiny bit)
 - #64764 (Master is now 1.40 )

Failed merges:

r? @ghost
@bors bors merged commit 9a6ca41 into rust-lang:master Sep 25, 2019
@ljedrz ljedrz deleted the kill_off_hir_to_node_id branch September 25, 2019 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet