From 54f95fb6972e17a6ca118b32cef8e6d0d468a83a Mon Sep 17 00:00:00 2001 From: Jason Ozias Date: Mon, 6 May 2024 16:34:37 -0400 Subject: [PATCH] Updated to use rustc-check-cfg (#340) * updated to use rustc-check-cfg * allow unstable on nightly * rustfmt * removed duplicate lint * rustfmt * fix code coverage unstable issue * allow unexpected_cfgs lint --- test_util/build.rs | 32 ++++++++++++-------------------- test_util/src/lib.rs | 40 +++++++++++++++++++++++++++------------- vergen-git2/Cargo.toml | 2 +- vergen-git2/build.rs | 32 ++++++++++++-------------------- vergen-git2/src/lib.rs | 37 ++++++++++++++++++++++++------------- vergen-gitcl/Cargo.toml | 2 +- vergen-gitcl/build.rs | 32 ++++++++++++-------------------- vergen-gitcl/src/lib.rs | 37 ++++++++++++++++++++++++------------- vergen-gix/Cargo.toml | 2 +- vergen-gix/build.rs | 32 ++++++++++++-------------------- vergen-gix/src/lib.rs | 37 ++++++++++++++++++++++++------------- vergen-lib/Cargo.toml | 2 +- vergen-lib/build.rs | 32 ++++++++++++-------------------- vergen-lib/src/lib.rs | 37 ++++++++++++++++++++++++------------- vergen-pretty/build.rs | 33 +++++++++++++-------------------- vergen-pretty/src/lib.rs | 37 ++++++++++++++++++++++++------------- vergen/Cargo.toml | 2 +- vergen/build.rs | 32 ++++++++++++-------------------- vergen/src/lib.rs | 37 ++++++++++++++++++++++++------------- 19 files changed, 261 insertions(+), 236 deletions(-) diff --git a/test_util/build.rs b/test_util/build.rs index 086074bb..b33f7ed6 100644 --- a/test_util/build.rs +++ b/test_util/build.rs @@ -1,48 +1,40 @@ pub fn main() { println!("cargo:rerun-if-changed=build.rs"); + println!("cargo:rustc-check-cfg=cfg(coverage_nightly)"); nightly(); beta(); stable(); - msrv(); - lints_fix(); } #[rustversion::nightly] fn nightly() { + println!("cargo:rustc-check-cfg=cfg(nightly)"); println!("cargo:rustc-cfg=nightly"); } #[rustversion::not(nightly)] -fn nightly() {} +fn nightly() { + println!("cargo:rustc-check-cfg=cfg(nightly)"); +} #[rustversion::beta] fn beta() { + println!("cargo:rustc-check-cfg=cfg(beta)"); println!("cargo:rustc-cfg=beta"); } #[rustversion::not(beta)] -fn beta() {} +fn beta() { + println!("cargo:rustc-check-cfg=cfg(beta)"); +} #[rustversion::stable] fn stable() { + println!("cargo:rustc-check-cfg=cfg(stable)"); println!("cargo:rustc-cfg=stable"); } #[rustversion::not(stable)] -fn stable() {} - -#[rustversion::before(1.70)] -fn msrv() {} - -#[rustversion::since(1.70)] -fn msrv() { - println!("cargo:rustc-cfg=msrv"); -} - -#[rustversion::before(1.75)] -fn lints_fix() {} - -#[rustversion::since(1.75)] -fn lints_fix() { - println!("cargo:rustc-cfg=lints_fix") +fn stable() { + println!("cargo:rustc-check-cfg=cfg(stable)"); } diff --git a/test_util/src/lib.rs b/test_util/src/lib.rs index 87d6e0f2..6dc79ad3 100644 --- a/test_util/src/lib.rs +++ b/test_util/src/lib.rs @@ -74,12 +74,13 @@ the [`TestRepos`] struct to creat temporary git repositories useful for `vergen- lint_reasons, multiple_supertrait_upcastable, must_not_suspend, + mut_preserve_binding_mode_2024, non_exhaustive_omitted_patterns_lint, rustdoc_missing_doc_code_examples, strict_provenance, ) )] -#![cfg_attr(nightly, allow(box_pointers))] +#![cfg_attr(nightly, allow(box_pointers, single_use_lifetimes, unexpected_cfgs))] #![cfg_attr( nightly, deny( @@ -98,6 +99,7 @@ the [`TestRepos`] struct to creat temporary git repositories useful for `vergen- clashing_extern_declarations, coherence_leak_check, confusable_idents, + const_eval_mutable_ptr_in_final_value, const_evaluatable_unchecked, const_item_mutation, dead_code, @@ -125,17 +127,16 @@ the [`TestRepos`] struct to creat temporary git repositories useful for `vergen- hidden_glob_reexports, improper_ctypes, improper_ctypes_definitions, - incomplete_features, indirect_structural_match, inline_no_sanitize, internal_features, - invalid_doc_attributes, invalid_from_utf8, invalid_macro_export_arguments, invalid_nan_comparisons, invalid_value, irrefutable_let_patterns, - keyword_idents, + keyword_idents_2018, + keyword_idents_2024, large_assignments, late_bound_lifetime_arguments, legacy_derive_helpers, @@ -149,10 +150,13 @@ the [`TestRepos`] struct to creat temporary git repositories useful for `vergen- missing_docs, mixed_script_confusables, named_arguments_used_positionally, + never_type_fallback_flowing_into_unsafe, no_mangle_generic_items, non_ascii_idents, non_camel_case_types, + non_contiguous_range_endpoints, non_fmt_panics, + non_local_definitions, non_shorthand_field_patterns, non_snake_case, non_upper_case_globals, @@ -163,8 +167,10 @@ the [`TestRepos`] struct to creat temporary git repositories useful for `vergen- pointer_structural_match, private_bounds, private_interfaces, + redundant_lifetimes, redundant_semicolons, - refining_impl_trait, + refining_impl_trait_internal, + refining_impl_trait_reachable, renamed_and_removed_lints, repr_transparent_external_private_fields, rust_2021_incompatible_closure_captures, @@ -172,7 +178,6 @@ the [`TestRepos`] struct to creat temporary git repositories useful for `vergen- rust_2021_prefixes_incompatible_syntax, rust_2021_prelude_collisions, semicolon_in_expressions_from_macros, - single_use_lifetimes, special_module_name, stable_features, static_mut_refs, @@ -185,13 +190,15 @@ the [`TestRepos`] struct to creat temporary git repositories useful for `vergen- tyvar_behind_raw_pointer, uncommon_codepoints, unconditional_recursion, + uncovered_param_in_projection, undefined_naked_function_abi, - unexpected_cfgs, ungated_async_fn_track_caller, uninhabited_static, unit_bindings, unknown_lints, + unknown_or_malformed_diagnostic_attributes, unnameable_test_items, + unnameable_types, unreachable_code, unreachable_patterns, unreachable_pub, @@ -225,27 +232,33 @@ the [`TestRepos`] struct to creat temporary git repositories useful for `vergen- unused_variables, useless_ptr_null_checks, variant_size_differences, + wasm_c_abi, where_clauses_object_safety, while_true, writes_through_immutable_pointer, ) )] -// If nightly and unstable, allow `unstable_features` -#![cfg_attr(all(feature = "unstable", nightly), allow(unstable_features))] -// If nightly and not unstable, deny `unstable_features` -#![cfg_attr(all(not(feature = "unstable"), nightly), deny(unstable_features))] +// If nightly and unstable, allow `incomplete_features` and `unstable_features` +#![cfg_attr( + all(feature = "unstable", nightly), + allow(incomplete_features, unstable_features) +)] +// If nightly and not unstable, deny `incomplete_features` and `unstable_features` +#![cfg_attr( + all(not(feature = "unstable"), nightly), + deny(incomplete_features, unstable_features) +)] // The unstable lints #![cfg_attr( all(feature = "unstable", nightly), deny( + dereferencing_mut_binding, fuzzy_provenance_casts, lossy_provenance_casts, multiple_supertrait_upcastable, must_not_suspend, non_exhaustive_omitted_patterns, unfulfilled_lint_expectations, - // unknown_or_malformed_diagnostic_attributes, - unnameable_types, ) )] // clippy lints @@ -269,6 +282,7 @@ the [`TestRepos`] struct to creat temporary git repositories useful for `vergen- )] #![cfg_attr(all(doc, nightly), feature(doc_auto_cfg))] #![cfg_attr(all(docsrs, nightly), feature(doc_cfg))] +#![cfg_attr(all(nightly, coverage_nightly), feature(coverage_attribute))] #[cfg(all(test, not(feature = "repo")))] use {anyhow as _, serial_test as _}; diff --git a/vergen-git2/Cargo.toml b/vergen-git2/Cargo.toml index fe69f0d1..52e3f942 100644 --- a/vergen-git2/Cargo.toml +++ b/vergen-git2/Cargo.toml @@ -52,7 +52,7 @@ lazy_static = "1.4.0" regex = "1.10.3" serial_test = "3.0.0" temp-env = "0.3.6" -test_util = { path = "../test_util", features = ["repo"] } +test_util = { path = "../test_util", features = ["repo", "unstable"] } [package.metadata.docs.rs] features = ["build", "cargo", "emit_and_set", "rustc", "si"] diff --git a/vergen-git2/build.rs b/vergen-git2/build.rs index 086074bb..b33f7ed6 100644 --- a/vergen-git2/build.rs +++ b/vergen-git2/build.rs @@ -1,48 +1,40 @@ pub fn main() { println!("cargo:rerun-if-changed=build.rs"); + println!("cargo:rustc-check-cfg=cfg(coverage_nightly)"); nightly(); beta(); stable(); - msrv(); - lints_fix(); } #[rustversion::nightly] fn nightly() { + println!("cargo:rustc-check-cfg=cfg(nightly)"); println!("cargo:rustc-cfg=nightly"); } #[rustversion::not(nightly)] -fn nightly() {} +fn nightly() { + println!("cargo:rustc-check-cfg=cfg(nightly)"); +} #[rustversion::beta] fn beta() { + println!("cargo:rustc-check-cfg=cfg(beta)"); println!("cargo:rustc-cfg=beta"); } #[rustversion::not(beta)] -fn beta() {} +fn beta() { + println!("cargo:rustc-check-cfg=cfg(beta)"); +} #[rustversion::stable] fn stable() { + println!("cargo:rustc-check-cfg=cfg(stable)"); println!("cargo:rustc-cfg=stable"); } #[rustversion::not(stable)] -fn stable() {} - -#[rustversion::before(1.70)] -fn msrv() {} - -#[rustversion::since(1.70)] -fn msrv() { - println!("cargo:rustc-cfg=msrv"); -} - -#[rustversion::before(1.75)] -fn lints_fix() {} - -#[rustversion::since(1.75)] -fn lints_fix() { - println!("cargo:rustc-cfg=lints_fix") +fn stable() { + println!("cargo:rustc-check-cfg=cfg(stable)"); } diff --git a/vergen-git2/src/lib.rs b/vergen-git2/src/lib.rs index b1467b0d..07c7391c 100644 --- a/vergen-git2/src/lib.rs +++ b/vergen-git2/src/lib.rs @@ -254,12 +254,13 @@ let build = BuildBuilder::default().build_timestamp(true).build()?;"## lint_reasons, multiple_supertrait_upcastable, must_not_suspend, + mut_preserve_binding_mode_2024, non_exhaustive_omitted_patterns_lint, rustdoc_missing_doc_code_examples, strict_provenance, ) )] -#![cfg_attr(nightly, allow(box_pointers))] +#![cfg_attr(nightly, allow(box_pointers, single_use_lifetimes, unexpected_cfgs))] #![cfg_attr( nightly, deny( @@ -278,6 +279,7 @@ let build = BuildBuilder::default().build_timestamp(true).build()?;"## clashing_extern_declarations, coherence_leak_check, confusable_idents, + const_eval_mutable_ptr_in_final_value, const_evaluatable_unchecked, const_item_mutation, dead_code, @@ -305,17 +307,16 @@ let build = BuildBuilder::default().build_timestamp(true).build()?;"## hidden_glob_reexports, improper_ctypes, improper_ctypes_definitions, - incomplete_features, indirect_structural_match, inline_no_sanitize, internal_features, - invalid_doc_attributes, invalid_from_utf8, invalid_macro_export_arguments, invalid_nan_comparisons, invalid_value, irrefutable_let_patterns, - keyword_idents, + keyword_idents_2018, + keyword_idents_2024, large_assignments, late_bound_lifetime_arguments, legacy_derive_helpers, @@ -329,10 +330,13 @@ let build = BuildBuilder::default().build_timestamp(true).build()?;"## missing_docs, mixed_script_confusables, named_arguments_used_positionally, + never_type_fallback_flowing_into_unsafe, no_mangle_generic_items, non_ascii_idents, non_camel_case_types, + non_contiguous_range_endpoints, non_fmt_panics, + non_local_definitions, non_shorthand_field_patterns, non_snake_case, non_upper_case_globals, @@ -343,8 +347,10 @@ let build = BuildBuilder::default().build_timestamp(true).build()?;"## pointer_structural_match, private_bounds, private_interfaces, + redundant_lifetimes, redundant_semicolons, - refining_impl_trait, + refining_impl_trait_internal, + refining_impl_trait_reachable, renamed_and_removed_lints, repr_transparent_external_private_fields, rust_2021_incompatible_closure_captures, @@ -352,7 +358,6 @@ let build = BuildBuilder::default().build_timestamp(true).build()?;"## rust_2021_prefixes_incompatible_syntax, rust_2021_prelude_collisions, semicolon_in_expressions_from_macros, - single_use_lifetimes, special_module_name, stable_features, static_mut_refs, @@ -365,13 +370,15 @@ let build = BuildBuilder::default().build_timestamp(true).build()?;"## tyvar_behind_raw_pointer, uncommon_codepoints, unconditional_recursion, + uncovered_param_in_projection, undefined_naked_function_abi, - unexpected_cfgs, ungated_async_fn_track_caller, uninhabited_static, unit_bindings, unknown_lints, + unknown_or_malformed_diagnostic_attributes, unnameable_test_items, + unnameable_types, unreachable_code, unreachable_patterns, unreachable_pub, @@ -405,27 +412,31 @@ let build = BuildBuilder::default().build_timestamp(true).build()?;"## unused_variables, useless_ptr_null_checks, variant_size_differences, + wasm_c_abi, where_clauses_object_safety, while_true, writes_through_immutable_pointer, ) )] -// If nightly and unstable, allow `unstable_features` -#![cfg_attr(all(feature = "unstable", nightly), allow(unstable_features))] -// If nightly and not unstable, deny `unstable_features` -#![cfg_attr(all(not(feature = "unstable"), nightly), deny(unstable_features))] +#![cfg_attr(all(nightly), allow(unstable_features))] +// If nightly and unstable, allow `incomplete_features` and `unstable_features` +#![cfg_attr(all(feature = "unstable", nightly), allow(incomplete_features))] +// If nightly and not unstable, deny `incomplete_features` and `unstable_features` +#![cfg_attr( + all(not(feature = "unstable"), nightly), + deny(incomplete_features, unstable_features) +)] // The unstable lints #![cfg_attr( all(feature = "unstable", nightly), deny( + dereferencing_mut_binding, fuzzy_provenance_casts, lossy_provenance_casts, multiple_supertrait_upcastable, must_not_suspend, non_exhaustive_omitted_patterns, unfulfilled_lint_expectations, - // unknown_or_malformed_diagnostic_attributes, - unnameable_types, ) )] // clippy lints diff --git a/vergen-gitcl/Cargo.toml b/vergen-gitcl/Cargo.toml index 75312c21..791e5e74 100644 --- a/vergen-gitcl/Cargo.toml +++ b/vergen-gitcl/Cargo.toml @@ -51,7 +51,7 @@ lazy_static = "1.4.0" regex = "1.10.3" serial_test = "3.0.0" temp-env = "0.3.6" -test_util = { path = "../test_util", features = ["repo"] } +test_util = { path = "../test_util", features = ["repo", "unstable"] } [package.metadata.docs.rs] features = ["build", "cargo", "emit_and_set", "rustc", "si"] diff --git a/vergen-gitcl/build.rs b/vergen-gitcl/build.rs index 086074bb..b33f7ed6 100644 --- a/vergen-gitcl/build.rs +++ b/vergen-gitcl/build.rs @@ -1,48 +1,40 @@ pub fn main() { println!("cargo:rerun-if-changed=build.rs"); + println!("cargo:rustc-check-cfg=cfg(coverage_nightly)"); nightly(); beta(); stable(); - msrv(); - lints_fix(); } #[rustversion::nightly] fn nightly() { + println!("cargo:rustc-check-cfg=cfg(nightly)"); println!("cargo:rustc-cfg=nightly"); } #[rustversion::not(nightly)] -fn nightly() {} +fn nightly() { + println!("cargo:rustc-check-cfg=cfg(nightly)"); +} #[rustversion::beta] fn beta() { + println!("cargo:rustc-check-cfg=cfg(beta)"); println!("cargo:rustc-cfg=beta"); } #[rustversion::not(beta)] -fn beta() {} +fn beta() { + println!("cargo:rustc-check-cfg=cfg(beta)"); +} #[rustversion::stable] fn stable() { + println!("cargo:rustc-check-cfg=cfg(stable)"); println!("cargo:rustc-cfg=stable"); } #[rustversion::not(stable)] -fn stable() {} - -#[rustversion::before(1.70)] -fn msrv() {} - -#[rustversion::since(1.70)] -fn msrv() { - println!("cargo:rustc-cfg=msrv"); -} - -#[rustversion::before(1.75)] -fn lints_fix() {} - -#[rustversion::since(1.75)] -fn lints_fix() { - println!("cargo:rustc-cfg=lints_fix") +fn stable() { + println!("cargo:rustc-check-cfg=cfg(stable)"); } diff --git a/vergen-gitcl/src/lib.rs b/vergen-gitcl/src/lib.rs index f4adee61..443a43dc 100644 --- a/vergen-gitcl/src/lib.rs +++ b/vergen-gitcl/src/lib.rs @@ -254,12 +254,13 @@ let build = BuildBuilder::default().build_timestamp(true).build()?;"## lint_reasons, multiple_supertrait_upcastable, must_not_suspend, + mut_preserve_binding_mode_2024, non_exhaustive_omitted_patterns_lint, rustdoc_missing_doc_code_examples, strict_provenance, ) )] -#![cfg_attr(nightly, allow(box_pointers))] +#![cfg_attr(nightly, allow(box_pointers, single_use_lifetimes, unexpected_cfgs))] #![cfg_attr( nightly, deny( @@ -278,6 +279,7 @@ let build = BuildBuilder::default().build_timestamp(true).build()?;"## clashing_extern_declarations, coherence_leak_check, confusable_idents, + const_eval_mutable_ptr_in_final_value, const_evaluatable_unchecked, const_item_mutation, dead_code, @@ -305,17 +307,16 @@ let build = BuildBuilder::default().build_timestamp(true).build()?;"## hidden_glob_reexports, improper_ctypes, improper_ctypes_definitions, - incomplete_features, indirect_structural_match, inline_no_sanitize, internal_features, - invalid_doc_attributes, invalid_from_utf8, invalid_macro_export_arguments, invalid_nan_comparisons, invalid_value, irrefutable_let_patterns, - keyword_idents, + keyword_idents_2018, + keyword_idents_2024, large_assignments, late_bound_lifetime_arguments, legacy_derive_helpers, @@ -329,10 +330,13 @@ let build = BuildBuilder::default().build_timestamp(true).build()?;"## missing_docs, mixed_script_confusables, named_arguments_used_positionally, + never_type_fallback_flowing_into_unsafe, no_mangle_generic_items, non_ascii_idents, non_camel_case_types, + non_contiguous_range_endpoints, non_fmt_panics, + non_local_definitions, non_shorthand_field_patterns, non_snake_case, non_upper_case_globals, @@ -343,8 +347,10 @@ let build = BuildBuilder::default().build_timestamp(true).build()?;"## pointer_structural_match, private_bounds, private_interfaces, + redundant_lifetimes, redundant_semicolons, - refining_impl_trait, + refining_impl_trait_internal, + refining_impl_trait_reachable, renamed_and_removed_lints, repr_transparent_external_private_fields, rust_2021_incompatible_closure_captures, @@ -352,7 +358,6 @@ let build = BuildBuilder::default().build_timestamp(true).build()?;"## rust_2021_prefixes_incompatible_syntax, rust_2021_prelude_collisions, semicolon_in_expressions_from_macros, - single_use_lifetimes, special_module_name, stable_features, static_mut_refs, @@ -365,13 +370,15 @@ let build = BuildBuilder::default().build_timestamp(true).build()?;"## tyvar_behind_raw_pointer, uncommon_codepoints, unconditional_recursion, + uncovered_param_in_projection, undefined_naked_function_abi, - unexpected_cfgs, ungated_async_fn_track_caller, uninhabited_static, unit_bindings, unknown_lints, + unknown_or_malformed_diagnostic_attributes, unnameable_test_items, + unnameable_types, unreachable_code, unreachable_patterns, unreachable_pub, @@ -405,27 +412,31 @@ let build = BuildBuilder::default().build_timestamp(true).build()?;"## unused_variables, useless_ptr_null_checks, variant_size_differences, + wasm_c_abi, where_clauses_object_safety, while_true, writes_through_immutable_pointer, ) )] -// If nightly and unstable, allow `unstable_features` -#![cfg_attr(all(feature = "unstable", nightly), allow(unstable_features))] -// If nightly and not unstable, deny `unstable_features` -#![cfg_attr(all(not(feature = "unstable"), nightly), deny(unstable_features))] +#![cfg_attr(all(nightly), allow(unstable_features))] +// If nightly and unstable, allow `incomplete_features` and `unstable_features` +#![cfg_attr(all(feature = "unstable", nightly), allow(incomplete_features))] +// If nightly and not unstable, deny `incomplete_features` and `unstable_features` +#![cfg_attr( + all(not(feature = "unstable"), nightly), + deny(incomplete_features, unstable_features) +)] // The unstable lints #![cfg_attr( all(feature = "unstable", nightly), deny( + dereferencing_mut_binding, fuzzy_provenance_casts, lossy_provenance_casts, multiple_supertrait_upcastable, must_not_suspend, non_exhaustive_omitted_patterns, unfulfilled_lint_expectations, - // unknown_or_malformed_diagnostic_attributes, - unnameable_types, ) )] // clippy lints diff --git a/vergen-gix/Cargo.toml b/vergen-gix/Cargo.toml index 552d0592..3828a027 100644 --- a/vergen-gix/Cargo.toml +++ b/vergen-gix/Cargo.toml @@ -58,7 +58,7 @@ rustversion = "1.0.14" [dev-dependencies] lazy_static = "1.4.0" regex = "1.10.2" -test_util = { path = "../test_util", features = ["repo"] } +test_util = { path = "../test_util", features = ["repo", "unstable"] } serial_test = "3.0.0" temp-env = "0.3.6" diff --git a/vergen-gix/build.rs b/vergen-gix/build.rs index 086074bb..b33f7ed6 100644 --- a/vergen-gix/build.rs +++ b/vergen-gix/build.rs @@ -1,48 +1,40 @@ pub fn main() { println!("cargo:rerun-if-changed=build.rs"); + println!("cargo:rustc-check-cfg=cfg(coverage_nightly)"); nightly(); beta(); stable(); - msrv(); - lints_fix(); } #[rustversion::nightly] fn nightly() { + println!("cargo:rustc-check-cfg=cfg(nightly)"); println!("cargo:rustc-cfg=nightly"); } #[rustversion::not(nightly)] -fn nightly() {} +fn nightly() { + println!("cargo:rustc-check-cfg=cfg(nightly)"); +} #[rustversion::beta] fn beta() { + println!("cargo:rustc-check-cfg=cfg(beta)"); println!("cargo:rustc-cfg=beta"); } #[rustversion::not(beta)] -fn beta() {} +fn beta() { + println!("cargo:rustc-check-cfg=cfg(beta)"); +} #[rustversion::stable] fn stable() { + println!("cargo:rustc-check-cfg=cfg(stable)"); println!("cargo:rustc-cfg=stable"); } #[rustversion::not(stable)] -fn stable() {} - -#[rustversion::before(1.70)] -fn msrv() {} - -#[rustversion::since(1.70)] -fn msrv() { - println!("cargo:rustc-cfg=msrv"); -} - -#[rustversion::before(1.75)] -fn lints_fix() {} - -#[rustversion::since(1.75)] -fn lints_fix() { - println!("cargo:rustc-cfg=lints_fix") +fn stable() { + println!("cargo:rustc-check-cfg=cfg(stable)"); } diff --git a/vergen-gix/src/lib.rs b/vergen-gix/src/lib.rs index 6b8e3c01..b173b388 100644 --- a/vergen-gix/src/lib.rs +++ b/vergen-gix/src/lib.rs @@ -254,12 +254,13 @@ let build = BuildBuilder::default().build_timestamp(true).build()?;"## lint_reasons, multiple_supertrait_upcastable, must_not_suspend, + mut_preserve_binding_mode_2024, non_exhaustive_omitted_patterns_lint, rustdoc_missing_doc_code_examples, strict_provenance, ) )] -#![cfg_attr(nightly, allow(box_pointers))] +#![cfg_attr(nightly, allow(box_pointers, single_use_lifetimes, unexpected_cfgs))] #![cfg_attr( nightly, deny( @@ -278,6 +279,7 @@ let build = BuildBuilder::default().build_timestamp(true).build()?;"## clashing_extern_declarations, coherence_leak_check, confusable_idents, + const_eval_mutable_ptr_in_final_value, const_evaluatable_unchecked, const_item_mutation, dead_code, @@ -305,17 +307,16 @@ let build = BuildBuilder::default().build_timestamp(true).build()?;"## hidden_glob_reexports, improper_ctypes, improper_ctypes_definitions, - incomplete_features, indirect_structural_match, inline_no_sanitize, internal_features, - invalid_doc_attributes, invalid_from_utf8, invalid_macro_export_arguments, invalid_nan_comparisons, invalid_value, irrefutable_let_patterns, - keyword_idents, + keyword_idents_2018, + keyword_idents_2024, large_assignments, late_bound_lifetime_arguments, legacy_derive_helpers, @@ -329,10 +330,13 @@ let build = BuildBuilder::default().build_timestamp(true).build()?;"## missing_docs, mixed_script_confusables, named_arguments_used_positionally, + never_type_fallback_flowing_into_unsafe, no_mangle_generic_items, non_ascii_idents, non_camel_case_types, + non_contiguous_range_endpoints, non_fmt_panics, + non_local_definitions, non_shorthand_field_patterns, non_snake_case, non_upper_case_globals, @@ -343,8 +347,10 @@ let build = BuildBuilder::default().build_timestamp(true).build()?;"## pointer_structural_match, private_bounds, private_interfaces, + redundant_lifetimes, redundant_semicolons, - refining_impl_trait, + refining_impl_trait_internal, + refining_impl_trait_reachable, renamed_and_removed_lints, repr_transparent_external_private_fields, rust_2021_incompatible_closure_captures, @@ -352,7 +358,6 @@ let build = BuildBuilder::default().build_timestamp(true).build()?;"## rust_2021_prefixes_incompatible_syntax, rust_2021_prelude_collisions, semicolon_in_expressions_from_macros, - single_use_lifetimes, special_module_name, stable_features, static_mut_refs, @@ -365,13 +370,15 @@ let build = BuildBuilder::default().build_timestamp(true).build()?;"## tyvar_behind_raw_pointer, uncommon_codepoints, unconditional_recursion, + uncovered_param_in_projection, undefined_naked_function_abi, - unexpected_cfgs, ungated_async_fn_track_caller, uninhabited_static, unit_bindings, unknown_lints, + unknown_or_malformed_diagnostic_attributes, unnameable_test_items, + unnameable_types, unreachable_code, unreachable_patterns, unreachable_pub, @@ -405,27 +412,31 @@ let build = BuildBuilder::default().build_timestamp(true).build()?;"## unused_variables, useless_ptr_null_checks, variant_size_differences, + wasm_c_abi, where_clauses_object_safety, while_true, writes_through_immutable_pointer, ) )] -// If nightly and unstable, allow `unstable_features` -#![cfg_attr(all(feature = "unstable", nightly), allow(unstable_features))] -// If nightly and not unstable, deny `unstable_features` -#![cfg_attr(all(not(feature = "unstable"), nightly), deny(unstable_features))] +#![cfg_attr(all(nightly), allow(unstable_features))] +// If nightly and unstable, allow `incomplete_features` and `unstable_features` +#![cfg_attr(all(feature = "unstable", nightly), allow(incomplete_features))] +// If nightly and not unstable, deny `incomplete_features` and `unstable_features` +#![cfg_attr( + all(not(feature = "unstable"), nightly), + deny(incomplete_features, unstable_features) +)] // The unstable lints #![cfg_attr( all(feature = "unstable", nightly), deny( + dereferencing_mut_binding, fuzzy_provenance_casts, lossy_provenance_casts, multiple_supertrait_upcastable, must_not_suspend, non_exhaustive_omitted_patterns, unfulfilled_lint_expectations, - // unknown_or_malformed_diagnostic_attributes, - unnameable_types, ) )] // clippy lints diff --git a/vergen-lib/Cargo.toml b/vergen-lib/Cargo.toml index 36da698c..0fb9252e 100644 --- a/vergen-lib/Cargo.toml +++ b/vergen-lib/Cargo.toml @@ -49,7 +49,7 @@ rustversion = "1.0.14" [dev-dependencies] serial_test = "3.0.0" temp-env = "0.3.6" -test_util = { path = "../test_util" } +test_util = { path = "../test_util", features = ["unstable"] } [package.metadata.docs.rs] features = ["build", "cargo", "git", "rustc", "si"] diff --git a/vergen-lib/build.rs b/vergen-lib/build.rs index 086074bb..b33f7ed6 100644 --- a/vergen-lib/build.rs +++ b/vergen-lib/build.rs @@ -1,48 +1,40 @@ pub fn main() { println!("cargo:rerun-if-changed=build.rs"); + println!("cargo:rustc-check-cfg=cfg(coverage_nightly)"); nightly(); beta(); stable(); - msrv(); - lints_fix(); } #[rustversion::nightly] fn nightly() { + println!("cargo:rustc-check-cfg=cfg(nightly)"); println!("cargo:rustc-cfg=nightly"); } #[rustversion::not(nightly)] -fn nightly() {} +fn nightly() { + println!("cargo:rustc-check-cfg=cfg(nightly)"); +} #[rustversion::beta] fn beta() { + println!("cargo:rustc-check-cfg=cfg(beta)"); println!("cargo:rustc-cfg=beta"); } #[rustversion::not(beta)] -fn beta() {} +fn beta() { + println!("cargo:rustc-check-cfg=cfg(beta)"); +} #[rustversion::stable] fn stable() { + println!("cargo:rustc-check-cfg=cfg(stable)"); println!("cargo:rustc-cfg=stable"); } #[rustversion::not(stable)] -fn stable() {} - -#[rustversion::before(1.70)] -fn msrv() {} - -#[rustversion::since(1.70)] -fn msrv() { - println!("cargo:rustc-cfg=msrv"); -} - -#[rustversion::before(1.75)] -fn lints_fix() {} - -#[rustversion::since(1.75)] -fn lints_fix() { - println!("cargo:rustc-cfg=lints_fix") +fn stable() { + println!("cargo:rustc-check-cfg=cfg(stable)"); } diff --git a/vergen-lib/src/lib.rs b/vergen-lib/src/lib.rs index 45432832..2048e1d9 100644 --- a/vergen-lib/src/lib.rs +++ b/vergen-lib/src/lib.rs @@ -16,12 +16,13 @@ lint_reasons, multiple_supertrait_upcastable, must_not_suspend, + mut_preserve_binding_mode_2024, non_exhaustive_omitted_patterns_lint, rustdoc_missing_doc_code_examples, strict_provenance, ) )] -#![cfg_attr(nightly, allow(box_pointers))] +#![cfg_attr(nightly, allow(box_pointers, single_use_lifetimes, unexpected_cfgs))] #![cfg_attr( nightly, deny( @@ -40,6 +41,7 @@ clashing_extern_declarations, coherence_leak_check, confusable_idents, + const_eval_mutable_ptr_in_final_value, const_evaluatable_unchecked, const_item_mutation, dead_code, @@ -67,17 +69,16 @@ hidden_glob_reexports, improper_ctypes, improper_ctypes_definitions, - incomplete_features, indirect_structural_match, inline_no_sanitize, internal_features, - invalid_doc_attributes, invalid_from_utf8, invalid_macro_export_arguments, invalid_nan_comparisons, invalid_value, irrefutable_let_patterns, - keyword_idents, + keyword_idents_2018, + keyword_idents_2024, large_assignments, late_bound_lifetime_arguments, legacy_derive_helpers, @@ -91,10 +92,13 @@ missing_docs, mixed_script_confusables, named_arguments_used_positionally, + never_type_fallback_flowing_into_unsafe, no_mangle_generic_items, non_ascii_idents, non_camel_case_types, + non_contiguous_range_endpoints, non_fmt_panics, + non_local_definitions, non_shorthand_field_patterns, non_snake_case, non_upper_case_globals, @@ -105,8 +109,10 @@ pointer_structural_match, private_bounds, private_interfaces, + redundant_lifetimes, redundant_semicolons, - refining_impl_trait, + refining_impl_trait_internal, + refining_impl_trait_reachable, renamed_and_removed_lints, repr_transparent_external_private_fields, rust_2021_incompatible_closure_captures, @@ -114,7 +120,6 @@ rust_2021_prefixes_incompatible_syntax, rust_2021_prelude_collisions, semicolon_in_expressions_from_macros, - single_use_lifetimes, special_module_name, stable_features, static_mut_refs, @@ -127,13 +132,15 @@ tyvar_behind_raw_pointer, uncommon_codepoints, unconditional_recursion, + uncovered_param_in_projection, undefined_naked_function_abi, - unexpected_cfgs, ungated_async_fn_track_caller, uninhabited_static, unit_bindings, unknown_lints, + unknown_or_malformed_diagnostic_attributes, unnameable_test_items, + unnameable_types, unreachable_code, unreachable_patterns, unreachable_pub, @@ -167,27 +174,31 @@ unused_variables, useless_ptr_null_checks, variant_size_differences, + wasm_c_abi, where_clauses_object_safety, while_true, writes_through_immutable_pointer, ) )] -// If nightly and unstable, allow `unstable_features` -#![cfg_attr(all(feature = "unstable", nightly), allow(unstable_features))] -// If nightly and not unstable, deny `unstable_features` -#![cfg_attr(all(not(feature = "unstable"), nightly), deny(unstable_features))] +#![cfg_attr(all(nightly), allow(unstable_features))] +// If nightly and unstable, allow `incomplete_features` and `unstable_features` +#![cfg_attr(all(feature = "unstable", nightly), allow(incomplete_features))] +// If nightly and not unstable, deny `incomplete_features` and `unstable_features` +#![cfg_attr( + all(not(feature = "unstable"), nightly), + deny(incomplete_features, unstable_features) +)] // The unstable lints #![cfg_attr( all(feature = "unstable", nightly), deny( + dereferencing_mut_binding, fuzzy_provenance_casts, lossy_provenance_casts, multiple_supertrait_upcastable, must_not_suspend, non_exhaustive_omitted_patterns, unfulfilled_lint_expectations, - // unknown_or_malformed_diagnostic_attributes, - unnameable_types, ) )] // clippy lints diff --git a/vergen-pretty/build.rs b/vergen-pretty/build.rs index e12e7ad6..55a41676 100644 --- a/vergen-pretty/build.rs +++ b/vergen-pretty/build.rs @@ -12,11 +12,11 @@ use { }; fn main() -> Result<()> { + println!("cargo:rerun-if-changed=build.rs"); + println!("cargo:rustc-check-cfg=cfg(coverage_nightly)"); nightly(); beta(); stable(); - msrv(); - lints_fix(); setup_env() } @@ -92,40 +92,33 @@ fn emit() -> Result<()> { #[rustversion::nightly] fn nightly() { + println!("cargo:rustc-check-cfg=cfg(nightly)"); println!("cargo:rustc-cfg=nightly"); } #[rustversion::not(nightly)] -fn nightly() {} +fn nightly() { + println!("cargo:rustc-check-cfg=cfg(nightly)"); +} #[rustversion::beta] fn beta() { + println!("cargo:rustc-check-cfg=cfg(beta)"); println!("cargo:rustc-cfg=beta"); } #[rustversion::not(beta)] -fn beta() {} +fn beta() { + println!("cargo:rustc-check-cfg=cfg(beta)"); +} #[rustversion::stable] fn stable() { + println!("cargo:rustc-check-cfg=cfg(stable)"); println!("cargo:rustc-cfg=stable"); } #[rustversion::not(stable)] -fn stable() {} - -#[rustversion::before(1.70)] -fn msrv() {} - -#[rustversion::since(1.70)] -fn msrv() { - println!("cargo:rustc-cfg=msrv"); -} - -#[rustversion::before(1.75)] -fn lints_fix() {} - -#[rustversion::since(1.75)] -fn lints_fix() { - println!("cargo:rustc-cfg=lints_fix") +fn stable() { + println!("cargo:rustc-check-cfg=cfg(stable)"); } diff --git a/vergen-pretty/src/lib.rs b/vergen-pretty/src/lib.rs index f70187cb..691a06a6 100644 --- a/vergen-pretty/src/lib.rs +++ b/vergen-pretty/src/lib.rs @@ -106,12 +106,13 @@ assert!(!buf.is_empty()); lint_reasons, multiple_supertrait_upcastable, must_not_suspend, + mut_preserve_binding_mode_2024, non_exhaustive_omitted_patterns_lint, rustdoc_missing_doc_code_examples, strict_provenance, ) )] -#![cfg_attr(nightly, allow(box_pointers))] +#![cfg_attr(nightly, allow(box_pointers, single_use_lifetimes, unexpected_cfgs))] #![cfg_attr( nightly, deny( @@ -130,6 +131,7 @@ assert!(!buf.is_empty()); clashing_extern_declarations, coherence_leak_check, confusable_idents, + const_eval_mutable_ptr_in_final_value, const_evaluatable_unchecked, const_item_mutation, dead_code, @@ -157,17 +159,16 @@ assert!(!buf.is_empty()); hidden_glob_reexports, improper_ctypes, improper_ctypes_definitions, - incomplete_features, indirect_structural_match, inline_no_sanitize, internal_features, - invalid_doc_attributes, invalid_from_utf8, invalid_macro_export_arguments, invalid_nan_comparisons, invalid_value, irrefutable_let_patterns, - keyword_idents, + keyword_idents_2018, + keyword_idents_2024, large_assignments, late_bound_lifetime_arguments, legacy_derive_helpers, @@ -181,10 +182,13 @@ assert!(!buf.is_empty()); missing_docs, mixed_script_confusables, named_arguments_used_positionally, + never_type_fallback_flowing_into_unsafe, no_mangle_generic_items, non_ascii_idents, non_camel_case_types, + non_contiguous_range_endpoints, non_fmt_panics, + non_local_definitions, non_shorthand_field_patterns, non_snake_case, non_upper_case_globals, @@ -195,8 +199,10 @@ assert!(!buf.is_empty()); pointer_structural_match, private_bounds, private_interfaces, + redundant_lifetimes, redundant_semicolons, - refining_impl_trait, + refining_impl_trait_internal, + refining_impl_trait_reachable, renamed_and_removed_lints, repr_transparent_external_private_fields, rust_2021_incompatible_closure_captures, @@ -204,7 +210,6 @@ assert!(!buf.is_empty()); rust_2021_prefixes_incompatible_syntax, rust_2021_prelude_collisions, semicolon_in_expressions_from_macros, - single_use_lifetimes, special_module_name, stable_features, static_mut_refs, @@ -217,13 +222,15 @@ assert!(!buf.is_empty()); tyvar_behind_raw_pointer, uncommon_codepoints, unconditional_recursion, + uncovered_param_in_projection, undefined_naked_function_abi, - unexpected_cfgs, ungated_async_fn_track_caller, uninhabited_static, unit_bindings, unknown_lints, + unknown_or_malformed_diagnostic_attributes, unnameable_test_items, + unnameable_types, unreachable_code, unreachable_patterns, unreachable_pub, @@ -257,27 +264,31 @@ assert!(!buf.is_empty()); unused_variables, useless_ptr_null_checks, variant_size_differences, + wasm_c_abi, where_clauses_object_safety, while_true, writes_through_immutable_pointer, ) )] -// If nightly and unstable, allow `unstable_features` -#![cfg_attr(all(feature = "unstable", nightly), allow(unstable_features))] -// If nightly and not unstable, deny `unstable_features` -#![cfg_attr(all(not(feature = "unstable"), nightly), deny(unstable_features))] +#![cfg_attr(all(nightly), allow(unstable_features))] +// If nightly and unstable, allow `incomplete_features` and `unstable_features` +#![cfg_attr(all(feature = "unstable", nightly), allow(incomplete_features))] +// If nightly and not unstable, deny `incomplete_features` and `unstable_features` +#![cfg_attr( + all(not(feature = "unstable"), nightly), + deny(incomplete_features, unstable_features) +)] // The unstable lints #![cfg_attr( all(feature = "unstable", nightly), deny( + dereferencing_mut_binding, fuzzy_provenance_casts, lossy_provenance_casts, multiple_supertrait_upcastable, must_not_suspend, non_exhaustive_omitted_patterns, unfulfilled_lint_expectations, - // unknown_or_malformed_diagnostic_attributes, - unnameable_types, ) )] // clippy lints diff --git a/vergen/Cargo.toml b/vergen/Cargo.toml index 1239bac5..f0729c7f 100644 --- a/vergen/Cargo.toml +++ b/vergen/Cargo.toml @@ -53,7 +53,7 @@ rustversion = "1.0.14" [dev-dependencies] lazy_static = "1.4.0" regex = "1.9.1" -test_util = { path = "../test_util" } +test_util = { path = "../test_util", features = ["unstable"] } serial_test = "3.0.0" temp-env = "0.3.6" diff --git a/vergen/build.rs b/vergen/build.rs index 086074bb..b33f7ed6 100644 --- a/vergen/build.rs +++ b/vergen/build.rs @@ -1,48 +1,40 @@ pub fn main() { println!("cargo:rerun-if-changed=build.rs"); + println!("cargo:rustc-check-cfg=cfg(coverage_nightly)"); nightly(); beta(); stable(); - msrv(); - lints_fix(); } #[rustversion::nightly] fn nightly() { + println!("cargo:rustc-check-cfg=cfg(nightly)"); println!("cargo:rustc-cfg=nightly"); } #[rustversion::not(nightly)] -fn nightly() {} +fn nightly() { + println!("cargo:rustc-check-cfg=cfg(nightly)"); +} #[rustversion::beta] fn beta() { + println!("cargo:rustc-check-cfg=cfg(beta)"); println!("cargo:rustc-cfg=beta"); } #[rustversion::not(beta)] -fn beta() {} +fn beta() { + println!("cargo:rustc-check-cfg=cfg(beta)"); +} #[rustversion::stable] fn stable() { + println!("cargo:rustc-check-cfg=cfg(stable)"); println!("cargo:rustc-cfg=stable"); } #[rustversion::not(stable)] -fn stable() {} - -#[rustversion::before(1.70)] -fn msrv() {} - -#[rustversion::since(1.70)] -fn msrv() { - println!("cargo:rustc-cfg=msrv"); -} - -#[rustversion::before(1.75)] -fn lints_fix() {} - -#[rustversion::since(1.75)] -fn lints_fix() { - println!("cargo:rustc-cfg=lints_fix") +fn stable() { + println!("cargo:rustc-check-cfg=cfg(stable)"); } diff --git a/vergen/src/lib.rs b/vergen/src/lib.rs index b05117f0..a0ec8c46 100644 --- a/vergen/src/lib.rs +++ b/vergen/src/lib.rs @@ -300,12 +300,13 @@ let build = BuildBuilder::default().build_timestamp(true).build()?;"## lint_reasons, multiple_supertrait_upcastable, must_not_suspend, + mut_preserve_binding_mode_2024, non_exhaustive_omitted_patterns_lint, rustdoc_missing_doc_code_examples, strict_provenance, ) )] -#![cfg_attr(nightly, allow(box_pointers))] +#![cfg_attr(nightly, allow(box_pointers, single_use_lifetimes, unexpected_cfgs))] #![cfg_attr( nightly, deny( @@ -324,6 +325,7 @@ let build = BuildBuilder::default().build_timestamp(true).build()?;"## clashing_extern_declarations, coherence_leak_check, confusable_idents, + const_eval_mutable_ptr_in_final_value, const_evaluatable_unchecked, const_item_mutation, dead_code, @@ -351,17 +353,16 @@ let build = BuildBuilder::default().build_timestamp(true).build()?;"## hidden_glob_reexports, improper_ctypes, improper_ctypes_definitions, - incomplete_features, indirect_structural_match, inline_no_sanitize, internal_features, - invalid_doc_attributes, invalid_from_utf8, invalid_macro_export_arguments, invalid_nan_comparisons, invalid_value, irrefutable_let_patterns, - keyword_idents, + keyword_idents_2018, + keyword_idents_2024, large_assignments, late_bound_lifetime_arguments, legacy_derive_helpers, @@ -375,10 +376,13 @@ let build = BuildBuilder::default().build_timestamp(true).build()?;"## missing_docs, mixed_script_confusables, named_arguments_used_positionally, + never_type_fallback_flowing_into_unsafe, no_mangle_generic_items, non_ascii_idents, non_camel_case_types, + non_contiguous_range_endpoints, non_fmt_panics, + non_local_definitions, non_shorthand_field_patterns, non_snake_case, non_upper_case_globals, @@ -389,8 +393,10 @@ let build = BuildBuilder::default().build_timestamp(true).build()?;"## pointer_structural_match, private_bounds, private_interfaces, + redundant_lifetimes, redundant_semicolons, - refining_impl_trait, + refining_impl_trait_internal, + refining_impl_trait_reachable, renamed_and_removed_lints, repr_transparent_external_private_fields, rust_2021_incompatible_closure_captures, @@ -398,7 +404,6 @@ let build = BuildBuilder::default().build_timestamp(true).build()?;"## rust_2021_prefixes_incompatible_syntax, rust_2021_prelude_collisions, semicolon_in_expressions_from_macros, - single_use_lifetimes, special_module_name, stable_features, static_mut_refs, @@ -411,13 +416,15 @@ let build = BuildBuilder::default().build_timestamp(true).build()?;"## tyvar_behind_raw_pointer, uncommon_codepoints, unconditional_recursion, + uncovered_param_in_projection, undefined_naked_function_abi, - unexpected_cfgs, ungated_async_fn_track_caller, uninhabited_static, unit_bindings, unknown_lints, + unknown_or_malformed_diagnostic_attributes, unnameable_test_items, + unnameable_types, unreachable_code, unreachable_patterns, unreachable_pub, @@ -451,27 +458,31 @@ let build = BuildBuilder::default().build_timestamp(true).build()?;"## unused_variables, useless_ptr_null_checks, variant_size_differences, + wasm_c_abi, where_clauses_object_safety, while_true, writes_through_immutable_pointer, ) )] -// If nightly and unstable, allow `unstable_features` -#![cfg_attr(all(feature = "unstable", nightly), allow(unstable_features))] -// If nightly and not unstable, deny `unstable_features` -#![cfg_attr(all(not(feature = "unstable"), nightly), deny(unstable_features))] +#![cfg_attr(all(nightly), allow(unstable_features))] +// If nightly and unstable, allow `incomplete_features` and `unstable_features` +#![cfg_attr(all(feature = "unstable", nightly), allow(incomplete_features))] +// If nightly and not unstable, deny `incomplete_features` and `unstable_features` +#![cfg_attr( + all(not(feature = "unstable"), nightly), + deny(incomplete_features, unstable_features) +)] // The unstable lints #![cfg_attr( all(feature = "unstable", nightly), deny( + dereferencing_mut_binding, fuzzy_provenance_casts, lossy_provenance_casts, multiple_supertrait_upcastable, must_not_suspend, non_exhaustive_omitted_patterns, unfulfilled_lint_expectations, - // unknown_or_malformed_diagnostic_attributes, - unnameable_types, ) )] // clippy lints