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

Add a regression test for #44415 #47704

Merged
merged 1 commit into from
Feb 6, 2018
Merged

Conversation

dsprenkels
Copy link
Contributor

@dsprenkels dsprenkels commented Jan 24, 2018

This PR adds a regression test for issue #44415.

Fixes #44415.

@rust-highfive
Copy link
Collaborator

r? @alexcrichton

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

@dsprenkels dsprenkels closed this Jan 24, 2018
@dsprenkels dsprenkels deleted the issue-44415 branch January 24, 2018 12:10
@dsprenkels dsprenkels restored the issue-44415 branch January 24, 2018 12:36
@dsprenkels
Copy link
Contributor Author

dsprenkels commented Jan 24, 2018

Turns out I accidentally closed this PR while cleaning up my fork.

@dsprenkels dsprenkels reopened this Jan 24, 2018
@dsprenkels dsprenkels changed the title Add regression test for #44415 Add a regression test for #44415 Jan 24, 2018
@alexcrichton
Copy link
Member

Thanks @dsprenkels!

For us though // error-pattern is pretty old at this point, perhaps //~ ERROR: ... could be used instead? That way we can assert both the error message and the location of the error message!

@dsprenkels
Copy link
Contributor Author

Oh yeah, I forgot about that. I will fix it accordingly.

@kennytm kennytm added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jan 24, 2018
@dsprenkels
Copy link
Contributor Author

dsprenkels commented Jan 25, 2018

Hmmm. It turns out harder than expected, because the error does not trigger in the file itself, but in mem.rs.

error[E0391]: unsupported cyclic reference between types/traits detected
   --> /scratch/dsprenkels/rust/src/libcore/mem.rs:315:14
    |
315 |     unsafe { intrinsics::size_of::<T>() }
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^ cyclic reference
    |
note: the cycle begins when computing layout of `Foo`...
   --> /scratch/dsprenkels/rust/src/libcore/mem.rs:315:14
    |
315 |     unsafe { intrinsics::size_of::<T>() }
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which then requires const-evaluating `Foo::{{initializer}}`...
   --> issue-44415.rs:14:17
    |
14  |     bytes: [u8; std::mem::size_of::<Foo>()],
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: ...which then again requires computing layout of `Foo`, completing the cycle.

error: aborting due to previous error

So the //~ ERROR [...] pattern does not trigger on the correct line in issue-44415.rs. intrinsics::size_of<T>() is an intrinsic and can probably not be defined inline.

Is it possible to specify an //~ ERROR [...] pattern for an error that occurs in another file? In any case, it looks like const-size_of-cycle.rs may have had the same problem. (The PR has been adapted from this test.) This test uses // error-pattern. Shall I keep using // error-pattern?

@kennytm
Copy link
Member

kennytm commented Jan 26, 2018

Maybe try to make it a UI test instead of compile-fail test?

@dsprenkels
Copy link
Contributor Author

dsprenkels commented Jan 30, 2018

Yes I could do this. However, we would have to update the test every time src/libcore/mem.rs changes.

Instead, I chose to redefine the size_of function inside the test itself, such that we actually can trigger on the error (because the file is correct).

@dsprenkels
Copy link
Contributor Author

Btw. I propose that if we adopt any of the solutions that are not // error-pattern, that we will also update const-size_of-cycle.rs.

@pietroalbini pietroalbini 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 Feb 5, 2018
@pietroalbini
Copy link
Member

@alexcrichton ping from triage!

@alexcrichton
Copy link
Member

@bors: r+

Thanks!

@bors
Copy link
Contributor

bors commented Feb 5, 2018

📌 Commit f641ac6 has been approved by alexcrichton

@kennytm kennytm 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 Feb 5, 2018
kennytm added a commit to kennytm/rust that referenced this pull request Feb 5, 2018
Add a regression test for rust-lang#44415

This PR adds a regression test for issue rust-lang#44415.

Fixes rust-lang#44415.
bors added a commit that referenced this pull request Feb 6, 2018
Rollup of 10 pull requests

- Successful merges: #46030, #47496, #47543, #47704, #47753, #47807, #47948, #47959, #48003, #48007
- Failed merges:
@bors bors merged commit f641ac6 into rust-lang:master Feb 6, 2018
@dsprenkels dsprenkels deleted the issue-44415 branch April 14, 2019 15:36
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.

6 participants