Skip to content

Missing tests for #92630 #93143

Closed
Closed

Description

@steffahn

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

Activity

  1. added
    A-testsuiteArea: The testsuite used to check the correctness of rustc
    C-enhancementCategory: An issue proposing an enhancement or a PR with one.
    E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
    T-libsRelevant to the library team, which will review and decide on the PR/issue.
    on Jan 21, 2022
  2. tamaroning commented on Jan 21, 2022

    @tamaroning
    Contributor

    @rustbot claim

  3. steffahn commented on Jan 21, 2022

    @steffahn
    MemberAuthor

    @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>>();
    }
  4. added a commit that references this issue on Feb 4, 2022
    ca2ef71
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-testsuiteArea: The testsuite used to check the correctness of rustcC-enhancementCategory: An issue proposing an enhancement or a PR with one.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.T-libsRelevant to the library team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions