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 tests for 'impl Default for [T; N]' #72628

Merged
merged 2 commits into from
Jun 19, 2020

Conversation

MikailBag
Copy link
Contributor

@MikailBag MikailBag commented May 26, 2020

Related: #71690.
This pull request adds two tests:

  • Even it T::default() panics, no leaks occur.
  • [T; 0] is Default even if T is not.

I believe at some moment Default impl for arrays will be rewritten to use const generics instead of macros, and these tests will help to prevent behavior changes.

@rust-highfive
Copy link
Collaborator

r? @shepmaster

(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 May 26, 2020
@MikailBag MikailBag force-pushed the array-default-tests branch 2 times, most recently from 8fc2db7 to fb2d5ed Compare May 26, 2020 21:32
@MikailBag MikailBag marked this pull request as draft May 26, 2020 21:32
@MikailBag MikailBag marked this pull request as ready for review May 26, 2020 22:37
@shepmaster
Copy link
Member

@bors r+ rollup

Thanks!

@bors
Copy link
Contributor

bors commented May 27, 2020

📌 Commit 591584e has been approved by shepmaster

@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 May 27, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request May 27, 2020
…epmaster

Add tests for 'impl Default for [T; N]'

Related: rust-lang#71690.
This pull request adds two tests:
- Even it T::default() panics, no leaks occur.
- [T; 0] is Default even if T is not.

I believe at some moment `Default` impl for arrays will be rewritten to use const generics instead of macros, and these tests will help to prevent behavior changes.
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request May 27, 2020
…epmaster

Add tests for 'impl Default for [T; N]'

Related: rust-lang#71690.
This pull request adds two tests:
- Even it T::default() panics, no leaks occur.
- [T; 0] is Default even if T is not.

I believe at some moment `Default` impl for arrays will be rewritten to use const generics instead of macros, and these tests will help to prevent behavior changes.
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request May 28, 2020
…epmaster

Add tests for 'impl Default for [T; N]'

Related: rust-lang#71690.
This pull request adds two tests:
- Even it T::default() panics, no leaks occur.
- [T; 0] is Default even if T is not.

I believe at some moment `Default` impl for arrays will be rewritten to use const generics instead of macros, and these tests will help to prevent behavior changes.
@JohnTitor
Copy link
Member

Failed in #72673 (comment):

[RUSTC-TIMING] coretests test:true 64.186
    Finished release [optimized] target(s) in 1m 09s
     Running build/x86_64-unknown-linux-gnu/stage2-std/wasm32-unknown-unknown/release/deps/coretests-b7cfeee46333c4a6.wasm
RuntimeError: unreachable
    at __rust_start_panic (wasm-function[1775]:1)
    at rust_panic (wasm-function[1763]:39)
    at _ZN3std9panicking20rust_panic_with_hook17hb4e2fb8af4804e97E (wasm-function[1758]:279)
    at _ZN3std9panicking11begin_panic17hb9f43a2c430997d1E (wasm-function[1107]:55)
    at _ZN4core5array75_$LT$impl$u20$core..default..Default$u20$for$u20$$u5b$T$u3b$$u20$_$u5d$$GT$7default17h75356a07fe8c5952E (wasm-function[410]:287)
    at _ZN4core3ops8function6FnOnce9call_once17h16c8e7c1f7d576cdE (wasm-function[409]:25)
    at _ZN4test28__rust_begin_short_backtrace17h804c565a83fc8136E (wasm-function[1401]:3)
    at _ZN4core3ops8function6FnOnce40call_once$u7b$$u7b$vtable.shim$u7d$$u7d$17hd4fcf7a756fe71aeE (wasm-function[1400]:6)
    at _ZN4test8run_test14run_test_inner17h4c09558679e02456E (wasm-function[1517]:2059)
    at _ZN4test8run_test17h0760c0ff80bcda5cE (wasm-function[1514]:812)
    at _ZN4test9run_tests17ha8a597da42e5b48eE (wasm-function[1468]:14251)
    at _ZN4test7console17run_tests_console17h90e9ea459accc65eE (wasm-function[1466]:1038)
    at _ZN4test9test_main17hff62743d0c9cc2e9E (wasm-function[1510]:332)
    at _ZN4test16test_main_static17hb90aede56671ffa7E (wasm-function[1512]:356)
    at _ZN9coretests4main17hfd760802efbf9d18E (wasm-function[991]:10)
    at _ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17hb3e0ac0d8e7d9f29E (wasm-function[325]:25)
    at _ZN3std10sys_common9backtrace28__rust_begin_short_backtrace17h4faef310d2c1b955E (wasm-function[1744]:8)
    at _ZN3std2rt19lang_start_internal17h08ff942ca8d003dfE (wasm-function[1764]:229)
    at main (wasm-function[992]:46)
    at Object.<anonymous> (/checkout/src/etc/wasm32-shim.js:20:20)
error: test failed, to rerun pass '-p core --test coretests'

@bors r-

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 28, 2020
@MikailBag
Copy link
Contributor Author

Thanks! I reproduced failure locally, on 'wasm32-unknown-unknown'.
I'm pretty sure it is caused by some unwinding limitations in wasm (maybe, it does not support unwinding at all?). I will try to find a solution.

@MikailBag
Copy link
Contributor Author

MikailBag commented May 28, 2020

Yes, it looks like following test

#[test]
fn debugging() {
    std::panic::catch_unwind(|| panic!("hi")).ok();
}

fails on wasm32-unknown-unknown with same error.
I think that test should be skipped on platforms that does not support unwinding.

@JohnTitor
Copy link
Member

I'm pretty sure it is caused by some unwinding limitations in wasm (maybe, it does not support unwinding at all?)

Yeah, right. In this case, I think adding #[cfg(not(target_os = "emscripten"))] is fine here.

@MikailBag
Copy link
Contributor Author

MikailBag commented May 28, 2020

I think I have found out alternate solution:

  • mark test as #[should_panic(expected = "OK")]
  • raise panic!("OK") at the end of test

It seems that way test will be automatically skipped on all targets without unwinding support.
However, it is more hacky.

Also, it seems that target_os = emsripten will not match on wasm32-unknown-unknown.

@JohnTitor
Copy link
Member

Also, it seems that target_os = emsripten will not match on wasm32-unknown-unknown.

Ah indeed! Then #[cfg(not(target_arch = "wasm32"))] should be fine. Also, it'd be great if you could add FIXME comment with your workaround :)

@MikailBag
Copy link
Contributor Author

I think panic=abort problem is fixed, because ./x.py test src/libcore --target wasm32-unknown-unknown now works on my machine.

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Jun 15, 2020
…epmaster

Add tests for 'impl Default for [T; N]'

Related: rust-lang#71690.
This pull request adds two tests:
- Even it T::default() panics, no leaks occur.
- [T; 0] is Default even if T is not.

I believe at some moment `Default` impl for arrays will be rewritten to use const generics instead of macros, and these tests will help to prevent behavior changes.
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Jun 15, 2020
…epmaster

Add tests for 'impl Default for [T; N]'

Related: rust-lang#71690.
This pull request adds two tests:
- Even it T::default() panics, no leaks occur.
- [T; 0] is Default even if T is not.

I believe at some moment `Default` impl for arrays will be rewritten to use const generics instead of macros, and these tests will help to prevent behavior changes.
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Jun 16, 2020
…epmaster

Add tests for 'impl Default for [T; N]'

Related: rust-lang#71690.
This pull request adds two tests:
- Even it T::default() panics, no leaks occur.
- [T; 0] is Default even if T is not.

I believe at some moment `Default` impl for arrays will be rewritten to use const generics instead of macros, and these tests will help to prevent behavior changes.
Manishearth added a commit to Manishearth/rust that referenced this pull request Jun 16, 2020
…epmaster

Add tests for 'impl Default for [T; N]'

Related: rust-lang#71690.
This pull request adds two tests:
- Even it T::default() panics, no leaks occur.
- [T; 0] is Default even if T is not.

I believe at some moment `Default` impl for arrays will be rewritten to use const generics instead of macros, and these tests will help to prevent behavior changes.
Manishearth added a commit to Manishearth/rust that referenced this pull request Jun 16, 2020
…epmaster

Add tests for 'impl Default for [T; N]'

Related: rust-lang#71690.
This pull request adds two tests:
- Even it T::default() panics, no leaks occur.
- [T; 0] is Default even if T is not.

I believe at some moment `Default` impl for arrays will be rewritten to use const generics instead of macros, and these tests will help to prevent behavior changes.
Manishearth added a commit to Manishearth/rust that referenced this pull request Jun 16, 2020
…epmaster

Add tests for 'impl Default for [T; N]'

Related: rust-lang#71690.
This pull request adds two tests:
- Even it T::default() panics, no leaks occur.
- [T; 0] is Default even if T is not.

I believe at some moment `Default` impl for arrays will be rewritten to use const generics instead of macros, and these tests will help to prevent behavior changes.
RalfJung added a commit to RalfJung/rust that referenced this pull request Jun 18, 2020
…epmaster

Add tests for 'impl Default for [T; N]'

Related: rust-lang#71690.
This pull request adds two tests:
- Even it T::default() panics, no leaks occur.
- [T; 0] is Default even if T is not.

I believe at some moment `Default` impl for arrays will be rewritten to use const generics instead of macros, and these tests will help to prevent behavior changes.
Manishearth added a commit to Manishearth/rust that referenced this pull request Jun 18, 2020
…epmaster

Add tests for 'impl Default for [T; N]'

Related: rust-lang#71690.
This pull request adds two tests:
- Even it T::default() panics, no leaks occur.
- [T; 0] is Default even if T is not.

I believe at some moment `Default` impl for arrays will be rewritten to use const generics instead of macros, and these tests will help to prevent behavior changes.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 19, 2020
…arth

Rollup of 17 pull requests

Successful merges:

 - rust-lang#70551 (Make all uses of ty::Error delay a span bug)
 - rust-lang#71338 (Expand "recursive opaque type" diagnostic)
 - rust-lang#71976 (Improve diagnostics for `let x += 1`)
 - rust-lang#72279 (add raw_ref macros)
 - rust-lang#72628 (Add tests for 'impl Default for [T; N]')
 - rust-lang#72804 (Further tweak lifetime errors involving `dyn Trait` and `impl Trait` in return position)
 - rust-lang#72814 (remove visit_terminator_kind from MIR visitor)
 - rust-lang#72836 (Complete the std::time documentation to warn about the inconsistencies between OS)
 - rust-lang#72968 (Only highlight doc search results via mouseover if mouse has moved)
 - rust-lang#73034 (Export `#[inline]` fns with extern indicators)
 - rust-lang#73315 (Clean up some weird command strings)
 - rust-lang#73320 (Make new type param suggestion more targetted)
 - rust-lang#73361 (Tweak "non-primitive cast" error)
 - rust-lang#73425 (Mention functions pointers in the documentation)
 - rust-lang#73428 (Fix typo in librustc_ast docs)
 - rust-lang#73447 (Improve document for `Result::as_deref(_mut)` methods)
 - rust-lang#73476 (Added tooltip for should_panic code examples)

Failed merges:

r? @ghost
@bors bors merged commit 9262fc2 into rust-lang:master Jun 19, 2020
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.

None yet

6 participants