Skip to content

CStore switch FxHashMap to IndexVec - #46913

Merged
bors merged 1 commit into
rust-lang:masterfrom
Eh2406:master
Jan 3, 2018
Merged

CStore switch FxHashMap to IndexVec#46913
bors merged 1 commit into
rust-lang:masterfrom
Eh2406:master

Conversation

@Eh2406

Copy link
Copy Markdown
Contributor

This is a first attempt to fix#46876.

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @eddyb

(rust_highfive has picked a reviewer for you, use r? to override)

@arielb1

Copy link
Copy Markdown
Contributor

Your code does not compile:

[00:15:32] error[E0507]: cannot move out of borrowed content
[00:15:32] --> /checkout/src/librustc_metadata/cstore.rs:114:9
[00:15:32] |
[00:15:32] 114 | self.metas.borrow().get(cnum).unwrap().unwrap().clone()
[00:15:32] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content
[00:15:32] [00:15:32] error[E0596]: cannot borrow immutable local variable `met` as mutable
[00:15:32] --> /checkout/src/librustc_metadata/cstore.rs:121:13
[00:15:32] |
[00:15:32] 119 | let met = self.metas.borrow_mut();
[00:15:32] | --- consider changing this to `mut met`
[00:15:32] 120 | while met.len() <= cnum.index() {
[00:15:32] 121 | met.push(None);
[00:15:32] | ^^^ cannot borrow mutably
[00:15:32] [00:15:32] error[E0596]: cannot borrow immutable local variable `met` as mutable
[00:15:32] --> /checkout/src/librustc_metadata/cstore.rs:123:9
[00:15:32] |
[00:15:32] 119 | let met = self.metas.borrow_mut();
[00:15:32] | --- consider changing this to `mut met`
[00:15:32] ...
[00:15:32] 123 | met[cnum] = Some(data);
[00:15:32] | ^^^ cannot borrow mutably
[00:15:32] 

Comment threadsrc/librustc_metadata/cstore.rs Outdated

@arielb1arielb1Dec 21, 2017

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Use self.metas.borrow()[cnum].clone().unwrap() to fix the borrow error

Comment threadsrc/librustc_metadata/cstore.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This needs to be let mut met

@Eh2406

Copy link
Copy Markdown
ContributorAuthor

Thanks for the heads up. I got distracted trying to test locally.

@kennytmkennytm added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 21, 2017
@Eh2406

Copy link
Copy Markdown
ContributorAuthor

Ok, I am confused, what does that test fail have to do with my changes?

@pnkfelixpnkfelix added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Dec 21, 2017
@pnkfelix

pnkfelix commented Dec 21, 2017

Copy link
Copy Markdown
Contributor

@Eh2406 Assuming that you are referring to the change to the output for ui/print_type_sizes/niche-filling.rs ... here is my current understanding...

I think we are seeing some (currently undiagnosed) non-deterministic treatment of std::foo::bar vs core::foo::bar , and your change is causing a ripple effect there.

You can see some recent notes from me on this at #46905, in particular the commit message for 5f85764

Note in particular that that tests originally said core::cmp::Ordering; it was only changed to std::cmp::Orderingvery recently, in #46708 (which I am becoming increasingly concerned about and am considering reverting in favor of #46838 ...).

Entry::Occupied(mut entry) => {// If `child` is defined in crate `cnum`, ensure// that it is mapped to a parent in `cnum`.if child.krate == cnum && entry.get().krate != cnum {
entry.insert(parent);}}
  • namely, I think the idea of that code is that its better to prefer the path that corresponds to an items definition, if that path is public, rather than a path of a mere re-export of the item.

In the meantime, I personally would be fine with you just updating the print-type-sizes.stdout to match the new output. (Which after all is the same as the old output...)

@Eh2406

Copy link
Copy Markdown
ContributorAuthor

Ok so I switched from core::cmp::Ordering to std::cmp::Ordering in the test, we will see if that fixes things.

@Eh2406

Copy link
Copy Markdown
ContributorAuthor

Any ideas what is up with these errors? Why would this change lead to differences in the error messages?

@eddyb

Copy link
Copy Markdown
Contributor

r? @pnkfelix

@rust-highfiverust-highfive assigned pnkfelix and unassigned eddybDec 22, 2017
@Eh2406

Copy link
Copy Markdown
ContributorAuthor

Is there any Ideas on how to proceed? Should I try a rebase?

@Eh2406

Copy link
Copy Markdown
ContributorAuthor

All the PRs referenced by @pnkfelix have been merged, so I tried a rebase (and I squashed while I was doing). We will see if it works.

@Eh2406

Copy link
Copy Markdown
ContributorAuthor

Ping. The test got fixed by other prs. So this is now back to being a small simple change, with green CI.

@eddyb

eddyb commented Jan 2, 2018

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Jan 2, 2018

Copy link
Copy Markdown
Collaborator

📌 Commit 2c69473 has been approved by eddyb

@bors

bors commented Jan 3, 2018

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 2c69473 with merge 10f980c9f3977872cf1fddb6a4e9986d945c2bbd...

@bors

bors commented Jan 3, 2018

Copy link
Copy Markdown
Collaborator

💔 Test failed - status-appveyor

@Eh2406

Copy link
Copy Markdown
ContributorAuthor

Time out on appveyor. So did the last few commits. So we are on hold for that to get straightened out, yes?

@kennytm

Copy link
Copy Markdown
Member

@bors retry #46903 (3 hour timeout)

@bors

bors commented Jan 3, 2018

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 2c69473 with merge 8d1a302...

bors added a commit that referenced this pull request Jan 3, 2018
CStore switch FxHashMap to IndexVec
This is a first attempt to fix#46876.
@kennytmkennytm 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 Jan 3, 2018
@bors

bors commented Jan 3, 2018

Copy link
Copy Markdown
Collaborator

☀️ Test successful - status-appveyor, status-travis
Approved by: eddyb
Pushing 8d1a302 to master...

@bors
bors merged commit 2c69473 into rust-lang:masterJan 3, 2018
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant 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.

compiler code cleanup: replace metas: HashMap with IndexVec

7 participants

@Eh2406@rust-highfive@arielb1@pnkfelix@eddyb@bors@kennytm