{"id":13484775,"url":"https://github.com/dtolnay/rustversion","last_synced_at":"2025-12-12T15:02:39.611Z","repository":{"id":38956366,"uuid":"183990447","full_name":"dtolnay/rustversion","owner":"dtolnay","description":"Conditional compilation according to rustc compiler version","archived":false,"fork":false,"pushed_at":"2025-11-20T18:16:39.000Z","size":272,"stargazers_count":388,"open_issues_count":3,"forks_count":21,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-12-09T21:21:00.105Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dtolnay.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"dtolnay"}},"created_at":"2019-04-29T03:03:15.000Z","updated_at":"2025-12-09T14:28:48.000Z","dependencies_parsed_at":"2024-01-13T19:19:00.333Z","dependency_job_id":"e739deeb-c36f-4789-bd2d-00ab776752f8","html_url":"https://github.com/dtolnay/rustversion","commit_stats":{"total_commits":156,"total_committers":3,"mean_commits":52.0,"dds":"0.012820512820512775","last_synced_commit":"9ef9df29942a4ef9f6e45579da07efcaadb16f29"},"previous_names":["dtolnay/select-rustc"],"tags_count":28,"template":false,"template_full_name":null,"purl":"pkg:github/dtolnay/rustversion","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtolnay%2Frustversion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtolnay%2Frustversion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtolnay%2Frustversion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtolnay%2Frustversion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dtolnay","download_url":"https://codeload.github.com/dtolnay/rustversion/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dtolnay%2Frustversion/sbom","scorecard":{"id":358569,"data":{"date":"2025-08-11","repo":{"name":"github.com/dtolnay/rustversion","commit":"0db1c69bf82bd4c4838df557a821ba0ce1d100e3"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":5.5,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/22 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Maintained","score":10,"reason":"13 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":10,"reason":"GitHub workflow tokens follow principle of least privilege","details":["Info: topLevel 'contents' permission set to 'read': .github/workflows/ci.yml:10","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE-APACHE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE-APACHE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:79: update your workflow using https://app.stepsecurity.io/secureworkflow/dtolnay/rustversion/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:80: update your workflow using https://app.stepsecurity.io/secureworkflow/dtolnay/rustversion/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:81: update your workflow using https://app.stepsecurity.io/secureworkflow/dtolnay/rustversion/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:90: update your workflow using https://app.stepsecurity.io/secureworkflow/dtolnay/rustversion/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:91: update your workflow using https://app.stepsecurity.io/secureworkflow/dtolnay/rustversion/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:101: update your workflow using https://app.stepsecurity.io/secureworkflow/dtolnay/rustversion/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:102: update your workflow using https://app.stepsecurity.io/secureworkflow/dtolnay/rustversion/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:114: update your workflow using https://app.stepsecurity.io/secureworkflow/dtolnay/rustversion/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:115: update your workflow using https://app.stepsecurity.io/secureworkflow/dtolnay/rustversion/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:116: update your workflow using https://app.stepsecurity.io/secureworkflow/dtolnay/rustversion/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/dtolnay/rustversion/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:30: update your workflow using https://app.stepsecurity.io/secureworkflow/dtolnay/rustversion/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:31: update your workflow using https://app.stepsecurity.io/secureworkflow/dtolnay/rustversion/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:41: update your workflow using https://app.stepsecurity.io/secureworkflow/dtolnay/rustversion/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:55: update your workflow using https://app.stepsecurity.io/secureworkflow/dtolnay/rustversion/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:56: update your workflow using https://app.stepsecurity.io/secureworkflow/dtolnay/rustversion/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:66: update your workflow using https://app.stepsecurity.io/secureworkflow/dtolnay/rustversion/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:67: update your workflow using https://app.stepsecurity.io/secureworkflow/dtolnay/rustversion/ci.yml/master?enable=pin","Info:   0 out of   8 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of  10 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Security-Policy","score":3,"reason":"security policy file detected","details":["Info: security policy file detected: github.com/dtolnay/.github/SECURITY.md:1","Warn: no linked content found","Warn: One or no descriptive hints of disclosure, vulnerability, and/or timelines in security policy","Info: Found text in security policy: github.com/dtolnay/.github/SECURITY.md:1"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 16 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-18T10:12:31.138Z","repository_id":38956366,"created_at":"2025-08-18T10:12:31.138Z","updated_at":"2025-08-18T10:12:31.138Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27682847,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-12T02:00:06.775Z","response_time":129,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T17:01:33.240Z","updated_at":"2025-12-12T15:02:39.576Z","avatar_url":"https://github.com/dtolnay.png","language":"Rust","readme":"Compiler version cfg\n====================\n\n[\u003cimg alt=\"github\" src=\"https://img.shields.io/badge/github-dtolnay/rustversion-8da0cb?style=for-the-badge\u0026labelColor=555555\u0026logo=github\" height=\"20\"\u003e](https://github.com/dtolnay/rustversion)\n[\u003cimg alt=\"crates.io\" src=\"https://img.shields.io/crates/v/rustversion.svg?style=for-the-badge\u0026color=fc8d62\u0026logo=rust\" height=\"20\"\u003e](https://crates.io/crates/rustversion)\n[\u003cimg alt=\"docs.rs\" src=\"https://img.shields.io/badge/docs.rs-rustversion-66c2a5?style=for-the-badge\u0026labelColor=555555\u0026logo=docs.rs\" height=\"20\"\u003e](https://docs.rs/rustversion)\n[\u003cimg alt=\"build status\" src=\"https://img.shields.io/github/actions/workflow/status/dtolnay/rustversion/ci.yml?branch=master\u0026style=for-the-badge\" height=\"20\"\u003e](https://github.com/dtolnay/rustversion/actions?query=branch%3Amaster)\n\nThis crate provides macros for conditional compilation according to rustc\ncompiler version, analogous to [`#[cfg(...)]`][cfg] and\n[`#[cfg_attr(...)]`][cfg_attr].\n\n[cfg]: https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute\n[cfg_attr]: https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute\n\n```toml\n[dependencies]\nrustversion = \"1.0\"\n```\n\n\u003cbr\u003e\n\n## Selectors\n\n- \u003cb\u003e`#[rustversion::stable]`\u003c/b\u003e\n  —\u003cbr\u003e\n  True on any stable compiler.\n\n- \u003cb\u003e`#[rustversion::stable(1.34)]`\u003c/b\u003e\n  —\u003cbr\u003e\n  True on exactly the specified stable compiler.\n\n- \u003cb\u003e`#[rustversion::beta]`\u003c/b\u003e\n  —\u003cbr\u003e\n  True on any beta compiler.\n\n- \u003cb\u003e`#[rustversion::nightly]`\u003c/b\u003e\n  —\u003cbr\u003e\n  True on any nightly compiler or dev build.\n\n- \u003cb\u003e`#[rustversion::nightly(2025-01-01)]`\u003c/b\u003e\n  —\u003cbr\u003e\n  True on exactly one nightly.\n\n- \u003cb\u003e`#[rustversion::since(1.34)]`\u003c/b\u003e\n  —\u003cbr\u003e\n  True on that stable release and any later compiler, including beta and\n  nightly.\n\n- \u003cb\u003e`#[rustversion::since(2025-01-01)]`\u003c/b\u003e\n  —\u003cbr\u003e\n  True on that nightly and all newer ones.\n\n- \u003cb\u003e`#[rustversion::before(`\u003c/b\u003e\u003ci\u003eversion or date\u003c/i\u003e\u003cb\u003e`)]`\u003c/b\u003e\n  —\u003cbr\u003e\n  Negative of *#[rustversion::since(...)]*.\n\n- \u003cb\u003e`#[rustversion::not(`\u003c/b\u003e\u003ci\u003eselector\u003c/i\u003e\u003cb\u003e`)]`\u003c/b\u003e\n  —\u003cbr\u003e\n  Negative of any selector; for example *#[rustversion::not(nightly)]*.\n\n- \u003cb\u003e`#[rustversion::any(`\u003c/b\u003e\u003ci\u003eselectors...\u003c/i\u003e\u003cb\u003e`)]`\u003c/b\u003e\n  —\u003cbr\u003e\n  True if any of the comma-separated selectors is true; for example\n  *#[rustversion::any(stable, beta)]*.\n\n- \u003cb\u003e`#[rustversion::all(`\u003c/b\u003e\u003ci\u003eselectors...\u003c/i\u003e\u003cb\u003e`)]`\u003c/b\u003e\n  —\u003cbr\u003e\n  True if all of the comma-separated selectors are true; for example\n  *#[rustversion::all(since(1.31), before(1.34))]*.\n\n- \u003cb\u003e`#[rustversion::attr(`\u003c/b\u003e\u003ci\u003eselector\u003c/i\u003e\u003cb\u003e`, `\u003c/b\u003e\u003ci\u003eattribute\u003c/i\u003e\u003cb\u003e`)]`\u003c/b\u003e\n  —\u003cbr\u003e\n  For conditional inclusion of attributes; analogous to `cfg_attr`.\n\n- \u003cb\u003e`rustversion::cfg!(`\u003c/b\u003e\u003ci\u003eselector\u003c/i\u003e\u003cb\u003e`)`\u003c/b\u003e\n  —\u003cbr\u003e\n  An expression form of any of the above attributes; for example\n  *if rustversion::cfg!(any(stable, beta)) { ... }*.\n\n\u003cbr\u003e\n\n## Use cases\n\nProviding additional trait impls as types are stabilized in the standard library\nwithout breaking compatibility with older compilers; in this case Pin\\\u003cP\\\u003e\nstabilized in [Rust 1.33][pin]:\n\n[pin]: https://blog.rust-lang.org/2019/02/28/Rust-1.33.0.html#pinning\n\n```rust\n#[rustversion::since(1.33)]\nuse std::pin::Pin;\n\n#[rustversion::since(1.33)]\nimpl\u003cP: MyTrait\u003e MyTrait for Pin\u003cP\u003e {\n    /* ... */\n}\n```\n\nSimilar but for language features; the ability to control alignment greater than\n1 of packed structs was stabilized in [Rust 1.33][packed].\n\n[packed]: https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1330-2019-02-28\n\n```rust\n#[rustversion::attr(before(1.33), repr(packed))]\n#[rustversion::attr(since(1.33), repr(packed(2)))]\nstruct Six(i16, i32);\n\nfn main() {\n    println!(\"{}\", std::mem::align_of::\u003cSix\u003e());\n}\n```\n\nAugmenting code with `const` as const impls are stabilized in the standard\nlibrary. This use of `const` as an attribute is recognized as a special case by\nthe rustversion::attr macro.\n\n```rust\nuse std::time::Duration;\n\n#[rustversion::attr(since(1.32), const)]\nfn duration_as_days(dur: Duration) -\u003e u64 {\n    dur.as_secs() / 60 / 60 / 24\n}\n```\n\nEmitting Cargo cfg directives from a build script. Note that this requires\nlisting `rustversion` under `[build-dependencies]` in Cargo.toml, not\n`[dependencies]`.\n\n```rust\n// build.rs\n\nfn main() {\n    if rustversion::cfg!(since(1.36)) {\n        println!(\"cargo:rustc-cfg=no_std\");\n    }\n}\n```\n\n```rust\n// src/lib.rs\n\n#![cfg_attr(no_std, no_std)]\n\n#[cfg(no_std)]\nextern crate alloc;\n```\n\n\u003cbr\u003e\n\n#### License\n\n\u003csup\u003e\nLicensed under either of \u003ca href=\"LICENSE-APACHE\"\u003eApache License, Version\n2.0\u003c/a\u003e or \u003ca href=\"LICENSE-MIT\"\u003eMIT license\u003c/a\u003e at your option.\n\u003c/sup\u003e\n\n\u003cbr\u003e\n\n\u003csub\u003e\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in this crate by you, as defined in the Apache-2.0 license, shall\nbe dual licensed as above, without any additional terms or conditions.\n\u003c/sub\u003e\n","funding_links":["https://github.com/sponsors/dtolnay"],"categories":["Rust"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdtolnay%2Frustversion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdtolnay%2Frustversion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdtolnay%2Frustversion/lists"}