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

Add std_detect::detect::features() API that returns iterator of target-features and reject unstable features in feature-detection macros #739

Merged
merged 5 commits into from Sep 16, 2019

Conversation

@gnzlbg
Copy link
Collaborator

commented Apr 23, 2019

This PR implements an unstable features() function in std::detect that returns an iterator over the target features, returning a tuple of the target-feature name, and whether it is enabled or disabled in the current host.

This can be used to implement a solution to rust-lang/rust#54688 using our own run-time feature detection system.

The refactor required to implement this also allows us to close #667

@gnzlbg gnzlbg force-pushed the gnzlbg:feature_iterator branch from a93d94d to 6703f2a May 9, 2019
@lu-zero

This comment has been minimized.

Copy link
Collaborator

commented Sep 13, 2019

Do you plan to rebase this? I could use something like this to map the env var content to the features.

@gnzlbg

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 13, 2019

Yep, I'll merge this today.

Copy link
Collaborator

left a comment

It looks fine and I'd use it

@lu-zero

This comment has been minimized.

Copy link
Collaborator

commented Sep 16, 2019

It rebases cleanly but if I try to build it I get:

    Checking core_arch v0.1.5 (/Users/lu_zero/Sources/rust/stdarch/crates/core_arch)
error[E0658]: non-builtin inner attributes are unstable
 --> crates/core_arch/src/simd.rs:3:1
  |
3 | #![rustfmt::skip]
  | ^^^^^^^^^^^^^^^^^
  |
  = note: for more information, see https://github.com/rust-lang/rust/issues/54726
  = help: add `#![feature(custom_inner_attributes)]` to the crate attributes to enable
@gnzlbg

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 16, 2019

Damn I forgot about this.

@lu-zero

This comment has been minimized.

Copy link
Collaborator

commented Sep 16, 2019

Actually I had a problem with my local repo and origin/master was pointing to the wrong place, so a rebase isn't immediate :)

(if you have time to rebase and push would be great)

@gnzlbg gnzlbg force-pushed the gnzlbg:feature_iterator branch from 7665f09 to 938b6dd Sep 16, 2019
@gnzlbg gnzlbg changed the title Add std_detect::detect::features() API that returns iterator of target-features Add std_detect::detect::features() API that returns iterator of target-features and reject unstable features in feature-detection macros Sep 16, 2019
@lu-zero

This comment has been minimized.

Copy link
Collaborator

commented Sep 16, 2019

If it survives I guess it should be good to go pending some shuffling/amending.

@gnzlbg gnzlbg merged commit 7e498df into rust-lang:master Sep 16, 2019
2 checks passed
2 checks passed
rust-lang.stdarch #20190916.4 succeeded
Details
x86_64-unknown-freebsd Task Summary
Details
@gnzlbg

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 16, 2019

Gonna update stdarch upstream and do a crater run. There might be code in the wild accidentally relying on some of the unstable features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.