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

Extra tests for move and autoderef #15

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ijackson
Copy link

My now-closed-by-me MR #14 seemed simple and passed the in-tree if_chain tests but produced a number of regressions in projects of my own. That seems suboptimal. I have distilled the failure cases into these new tests, which pass on current if_chain and break with my #14.

Copy link
Owner

@lambda-fairy lambda-fairy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the tests!

I made a few simplifications which should help readability.


#[test]
fn magic_deref() {
fn f(y: &'static str) -> (&'static str, bool) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be simplified:

#[test]
fn magic_deref() {
    struct Wrapped<T>(T);
    let s = "hello";
    if_chain! {
        then { Wrapped(s) }
        else { Wrapped(&s) }
    };
}


#[test]
fn no_move() {
struct NoCopy;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This as well:

#[test]
fn no_move() {
    struct NoCopy;
    let x = NoCopy;
    if_chain! {
        then { drop(x); }
        else { drop(x); }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants