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

Missing tests for #92630 #93143

Closed
steffahn opened this issue Jan 21, 2022 · 2 comments · Fixed by #93585
Closed

Missing tests for #92630 #93143

steffahn opened this issue Jan 21, 2022 · 2 comments · Fixed by #93585
Assignees
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Comments

@steffahn
Copy link
Member

steffahn commented Jan 21, 2022

Right.. #92630 is my own PR; I'm noting this as an issue, mainly so I won't forget this, because I won't do this myself right now / today. Or someone else can do this if they want.

I'm not 100% certain where the best place for such a test to go is, and/or whether it makes sense to have them in one place or separated and more close to the respective type's definition.

A test to prevent any future regression removing the new auto trait implementations introduced by #92630 can look about as follows

// does not need to run, just tests by whether or not this compiles
fn _test<'a>() {
    use std::marker::PhantomData;
    use std::panic::{RefUnwindSafe, UnwindSafe};

    trait Trait {}
    type NoAutoTraits<'a> = PhantomData<dyn Trait + 'a>;
    fn all_auto_traits<T: Send + Sync + Unpin + UnwindSafe + RefUnwindSafe>() {}

    all_auto_traits::<std::iter::Empty<NoAutoTraits<'a>>>();
    all_auto_traits::<std::hash::BuildHasherDefault<NoAutoTraits<'a>>>();
    all_auto_traits::<std::future::Pending<NoAutoTraits<'a>>>();
}

Edit: This code is needlessly complicated, see my comment below.

@rustbot label C-enhancement, A-testsuite, E-easy, E-needs-test, T-libs

@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jan 21, 2022
@tamaroning
Copy link
Contributor

@rustbot claim

@steffahn
Copy link
Member Author

@tamaroning

FYI, somehow I missed the more straightforward way of writing these.

// does not need to run, just tests by whether or not this compiles
fn _test<T>() {
    use std::panic::{RefUnwindSafe, UnwindSafe};

    fn all_auto_traits<T: Send + Sync + Unpin + UnwindSafe + RefUnwindSafe>() {}

    all_auto_traits::<std::iter::Empty<T>>();
    all_auto_traits::<std::hash::BuildHasherDefault<T>>();
    all_auto_traits::<std::future::Pending<T>>();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants