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

Provide stable fallback for maybe_uninit_write_slice #64

Merged
merged 4 commits into from
Oct 25, 2022

Conversation

knutwalker
Copy link
Collaborator

This acts also as a scaffold for how to maybe get rid of other feature requirements.

The idea is that we can probe if we need to fallback, which is not the case for nightly or when that features has been stabilized.
If we need to fallback, we provide a compat impl using current stable code.

Copy link
Collaborator

@s1ck s1ck left a comment

Choose a reason for hiding this comment

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

Really cool. Just a minor suggestion to improve readability.

}

// Checks if some code can be compiled with the current toolchain
fn compile_probe(probe: &str) -> Option<ExitStatus> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Very cool idea!

fn main() {
match compile_probe(MAYBE_UNINIT_WRITE_SLICE_PROBE) {
Some(status) if status.success() => {}
_ => println!("cargo:rustc-cfg=no_maybe_uninit_write_slice"),
Copy link
Collaborator

@s1ck s1ck Oct 25, 2022

Choose a reason for hiding this comment

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

Maybe for readability, we can do

fn enable_compat_for_feature(feature_name: &str) {
    println!("cargo:rust-cfg=no_{feature_name}");
}

and in the Err case:

_ => enable_compat_for_feature("maybe_uninit_write_slice")

@knutwalker
Copy link
Collaborator Author

@s1ck thanks, 🏓

Copy link
Collaborator

@s1ck s1ck left a comment

Choose a reason for hiding this comment

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

💋 👌

@s1ck s1ck merged commit adcb970 into neo4j-labs:main Oct 25, 2022
@knutwalker knutwalker deleted the reduce-features branch October 25, 2022 15:44
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