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

Don't let auto trait syntax bleed through on stable Rust #3478

Merged
merged 2 commits into from
Sep 29, 2023

Conversation

mejrs
Copy link
Member

@mejrs mejrs commented Sep 28, 2023

See rust-lang/rust#116121 and rust-lang/rust#116126 for context.

I've skipped the changelog because this this is an invisible change, for now.

@mejrs mejrs added CI-skip-changelog Skip checking changelog entry CI-build-full labels Sep 28, 2023
src/marker.rs Outdated
/// });
/// ```
pub unsafe auto trait Ungil {}
}

#[cfg(feature = "nightly")]
Copy link
Member

Choose a reason for hiding this comment

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

Could we merge mod negative_impls into the define! invocation to have only one way of conditionally compile the nightly-only code related to Ungil?

Copy link
Member

Choose a reason for hiding this comment

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

Or potentially the other way around, move the define! declaration and invocation inside of the mod negative_impls (maybe renamed to mod ungil) and re-export pub use ungil::Ungil from that?

Could also have mod ungil for the stable branch too, so the #[cfg] attributes are only applied to the two variants of mod ungil.

Copy link
Member

Choose a reason for hiding this comment

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

Is a cfg-disabled module a sufficient barrier for invalid code that should not parse? I was under the impression that the macro is necessary precisely because it is not.

Copy link
Member

@davidhewitt davidhewitt Sep 29, 2023

Choose a reason for hiding this comment

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

I meant keep the macro but with this structure, which I think should work:

#[cfg(not(feature = "nightly"))]
mod ungil {
    // stable implementation
}

#[cfg(feature = "nightly")]
mod ungil {
    macro_rules! define {  /* ... */ }
    
    define! {
        // nightly definition of `Ungil`
    }

    // negative implementations of `Ungil`
}

pub use ungil::Ungil;

Copy link
Member

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

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

Ugh, it's a little unfortunate that this means future stable compilers will begin to reject older versions of PyO3. Guess that'll be an incentive for users to upgrade 😂

src/marker.rs Outdated
/// });
/// ```
pub unsafe auto trait Ungil {}
}

#[cfg(feature = "nightly")]
Copy link
Member

Choose a reason for hiding this comment

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

Or potentially the other way around, move the define! declaration and invocation inside of the mod negative_impls (maybe renamed to mod ungil) and re-export pub use ungil::Ungil from that?

Could also have mod ungil for the stable branch too, so the #[cfg] attributes are only applied to the two variants of mod ungil.

@davidhewitt davidhewitt added this pull request to the merge queue Sep 29, 2023
Merged via the queue into PyO3:main with commit b9e9859 Sep 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI-build-full CI-skip-changelog Skip checking changelog entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants