Skip to content

Comments

Update to stabilized const_fn_trait_bound#325

Merged
Amanieu merged 1 commit intoAmanieu:masterfrom
taiki-e:const_fn_trait_bound
Mar 16, 2022
Merged

Update to stabilized const_fn_trait_bound#325
Amanieu merged 1 commit intoAmanieu:masterfrom
taiki-e:const_fn_trait_bound

Conversation

@taiki-e
Copy link
Contributor

@taiki-e taiki-e commented Mar 10, 2022

const_fn_trait_bound has been stabilized on Rust 1.61 (currently nightly, nightly-2022-03-08+): rust-lang/rust#93827

This PR removes #![feature(const_fn_trait_bound)] and makes constructors for lock types const fn on Rust 1.61+ using autocfg.

(The first commit is from #327, and needed to fix CI failure)

Closes #299

@@ -0,0 +1,16 @@
fn main() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Adding a build script will make building a bit slower as the build script has to be compiled and the main crate has to wait on running the build script.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. An alternative approach without such drawbacks is to use the options feature. If the maintainer prefers that approach, I'm happy to switch to using it.

Copy link
Owner

Choose a reason for hiding this comment

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

I personally don't mind this: the build script has no dependencies and can be compiled in parallel with other crates, so it is usually not noticable.

Ok(cfg) => cfg,
Err(e) => {
println!(
"cargo:warning=lock_api: unable to determine rustc version: {}",
Copy link
Owner

Choose a reason for hiding this comment

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

I'd just use an unwrap here. There's no reason we shouldn't be able to detect the rustc version, and if we can't then it would be better to loudly fail so it can be fixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to panic on rustc version detection failure.

@taiki-e taiki-e force-pushed the const_fn_trait_bound branch from 2c8dc2b to cbab7b0 Compare March 16, 2022 14:04
@Amanieu Amanieu merged commit 217248f into Amanieu:master Mar 16, 2022
@taiki-e taiki-e deleted the const_fn_trait_bound branch March 16, 2022 14:07
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.

When am I going to be able to use Mutex::new stablely?

3 participants