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

Account for gaps in def path table during decoding #79810

Merged
merged 1 commit into from
Dec 10, 2020

Conversation

Aaron1011
Copy link
Member

When encoding a proc-macro crate, there may be gaps in the table (since
we only encode the crate root and proc-macro items). Account for this by
checking if the entry is present, rather than using unwrap()

@rust-highfive
Copy link
Collaborator

r? @lcnr

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 7, 2020
@Aaron1011
Copy link
Member Author

This resolves the crash in issue #79783. However, I haven't been able to come up with a minimal reproduction yet, so I'm leaving that issue open for now.

Copy link
Contributor

@lcnr lcnr left a comment

Choose a reason for hiding this comment

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

nit

otherwise r=me

compiler/rustc_metadata/src/rmeta/decoder.rs Show resolved Hide resolved
When encoding a proc-macro crate, there may be gaps in the table (since
we only encode the crate root and proc-macro items). Account for this by
checking if the entry is present, rather than using `unwrap()`
@Aaron1011
Copy link
Member Author

@bors r=lcnr

@bors
Copy link
Contributor

bors commented Dec 8, 2020

📌 Commit a332e2b has been approved by lcnr

@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 Dec 8, 2020
@wesleywiser
Copy link
Member

wesleywiser commented Dec 9, 2020

@bors p=1

Resolves a rustc crash on nightly.

@jyn514 jyn514 added A-incr-comp Area: Incremental compilation T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-metadata Area: Crate metadata and removed A-incr-comp Area: Incremental compilation labels Dec 9, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 9, 2020
Rollup of 12 pull requests

Successful merges:

 - rust-lang#79732 (minor stylistic clippy cleanups)
 - rust-lang#79750 (Fix trimming of lint docs)
 - rust-lang#79777 (Remove `first_merge` from liveness debug logs)
 - rust-lang#79795 (Privatize some of libcore unicode_internals)
 - rust-lang#79803 (Update xsv to prevent random CI failures)
 - rust-lang#79810 (Account for gaps in def path table during decoding)
 - rust-lang#79818 (Fixes to Rust coverage)
 - rust-lang#79824 (Strip prefix instead of replacing it with empty string)
 - rust-lang#79826 (Simplify visit_{foreign,trait}_item)
 - rust-lang#79844 (Move RWUTable to a separate module)
 - rust-lang#79861 (Update LLVM submodule)
 - rust-lang#79862 (Remove tab-lock and replace it with ctrl+up/down arrows to switch between search result tabs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors
Copy link
Contributor

bors commented Dec 10, 2020

⌛ Testing commit a332e2b with merge 1cc4107...

@bors bors merged commit a410af9 into rust-lang:master Dec 10, 2020
@rustbot rustbot added this to the 1.50.0 milestone Dec 10, 2020
@@ -1561,9 +1563,12 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
let mut map = FxHashMap::with_capacity_and_hasher(end_id as usize, Default::default());
for i in 0..end_id {
Copy link
Contributor

Choose a reason for hiding this comment

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

Late to the party... but if there are gaps, rather than stopping at end_id, do we need to keep iterating until we've processed self.root.tables.def_path_hashes.size() elements?

(Or maybe something more efficient. I'm not familiar with how these tables work.)

Copy link
Member Author

Choose a reason for hiding this comment

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

The size() method on Lazy<Table> has a somewhat misleading name - it returns the maximum possible value. So, iterating up to end_id guarnatees that we visit all present entries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-metadata Area: Crate metadata 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.

8 participants