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

Remove nondeterminism in multiple-definitions test #87092

Merged
merged 1 commit into from
Jul 18, 2021

Conversation

ricobbe
Copy link
Contributor

@ricobbe ricobbe commented Jul 12, 2021

Compare all fields in DllImport when sorting to avoid nondeterminism in the error for multiple inconsistent definitions of an extern function. Restore the multiple-definitions test.

Resolves #87084.

@rust-highfive
Copy link
Collaborator

r? @estebank

(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 Jul 12, 2021
@ricobbe
Copy link
Contributor Author

ricobbe commented Jul 12, 2021

r? @petrochenkov

@ricobbe
Copy link
Contributor Author

ricobbe commented Jul 12, 2021

Question for reviewers: in an earlier version of this code, a reviewer asked me not to have DllImport implement PartialOrd or Ord, I think because the ordering relation as implemented then didn't consider all of DllImport's fields, but it's been a while and I don't remember for certain. The new ordering relation I'm defining here does indeed consider all of the fields, and it's effectively equivalent to the one that we'd get if I just derived PartialOrd and Ord. Would you prefer me to just do that instead?

@fee1-dead
Copy link
Member

I don't think it is nondeterministic when you compared the names, so I don't think the issue is that simple.

@ricobbe
Copy link
Contributor Author

ricobbe commented Jul 13, 2021

I don't think it is nondeterministic when you compared the names, so I don't think the issue is that simple.

The error message is triggered in precisely the case where we have multiple DllImports with the same name. Therefore, to get a unique, well-defined result from sorting the imports (and therefore selecting the second entry with a duplicate name for the error message), I need to compare based on more than just the names.

@petrochenkov
Copy link
Contributor

petrochenkov commented Jul 13, 2021

My version of the fix, with all unnecessary impls removed, and with explicit sorting removed too - petrochenkov@8b9ce0e

(Not tested on src/test/ui/rfc-2627-raw-dylib/multiple-definitions.rs because I don't have a readily available MSVC setup.)

@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 13, 2021
@ricobbe
Copy link
Contributor Author

ricobbe commented Jul 13, 2021

My version of the fix, with all unnecessary impls removed, and with explicit sorting removed too - petrochenkov@8b9ce0e

I'm happy to just go with that; what's the workflow to do that?

@petrochenkov
Copy link
Contributor

@ricobbe
You can cherry-pick that commit and add/update the test.

@ricobbe
Copy link
Contributor Author

ricobbe commented Jul 13, 2021

@petrochenkov

You can cherry-pick that commit and add/update the test.

Ok, I've tried that, and now the restored (and renamed) multiple-declarations.rs test is failing. I've run it with --bless and updated the expected error message (in the comment in the .rs file) to adjust for the change in wording, but the test still fails:

error: process did not return an error status
status: exit code: 0

Everything else looks reasonable; in particular, I'm seeing the expected diagnostics on stderr.

I've tried running the test with the // check-pass header command, and also with // build-pass, but neither have any effect on the results. This is not a failure mode I know how to debug, I'm afraid.

EDIT: with @wesleywiser's help, I was able to figure out why rustc was terminating with an exit code of 0 for this test despite the error message; a little bit of plumbing sufficed to get this fixed up. I'll push shortly.

@petrochenkov petrochenkov added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 14, 2021
@petrochenkov
Copy link
Contributor

r=me after addressing #87092 (comment) and squashing commits.

@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 16, 2021
@ricobbe ricobbe force-pushed the fix-raw-dylib-multiple-definitions branch from 928ca03 to ce59f1a Compare July 16, 2021 18:24
@ricobbe
Copy link
Contributor Author

ricobbe commented Jul 16, 2021

@rustbot label -S-waiting-on-author +S-waiting-on-review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 16, 2021
@wesleywiser
Copy link
Member

@bors r=petrochenkov rollup

@bors
Copy link
Contributor

bors commented Jul 16, 2021

📌 Commit ce59f1a has been approved by petrochenkov

@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 Jul 16, 2021
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Jul 17, 2021
…nitions, r=petrochenkov

Remove nondeterminism in multiple-definitions test

Compare all fields in `DllImport` when sorting to avoid nondeterminism in the error for multiple inconsistent definitions of an extern function.  Restore the multiple-definitions test.

Resolves rust-lang#87084.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 18, 2021
Rollup of 8 pull requests

Successful merges:

 - rust-lang#86763 (Add a regression test for issue-63355)
 - rust-lang#86814 (Recover from a misplaced inner doc comment)
 - rust-lang#86843 (Check that const parameters of trait methods have compatible types)
 - rust-lang#86889 (rustdoc: Cleanup ExternalCrate)
 - rust-lang#87092 (Remove nondeterminism in multiple-definitions test)
 - rust-lang#87170 (Add diagnostic items for Clippy)
 - rust-lang#87183 (fix typo in compile_fail doctest)
 - rust-lang#87205 (rustc_middle: remove redundant clone)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 81d0b70 into rust-lang:master Jul 18, 2021
@rustbot rustbot added this to the 1.55.0 milestone Jul 18, 2021
@ricobbe ricobbe deleted the fix-raw-dylib-multiple-definitions branch July 19, 2021 18:46
bjorn3 pushed a commit to bjorn3/rust that referenced this pull request Aug 6, 2021
…nitions, r=petrochenkov

Remove nondeterminism in multiple-definitions test

Compare all fields in `DllImport` when sorting to avoid nondeterminism in the error for multiple inconsistent definitions of an extern function.  Restore the multiple-definitions test.

Resolves rust-lang#87084.
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unrelated changes make multiple-definitions test fail spuriously
9 participants