Skip to content

Commit

Permalink
lints, rustc-check-cfg (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
CraZySacX authored May 6, 2024
1 parent 1bfd136 commit 5afd436
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ derive_builder = "0.20.0"
futures = "0.3.24"
getset = "0.1.2"
libeither = "0.5.0"
reqwest = { version = "0.11.13", features = [ "json" ] }
reqwest = { version = "0.12.4", features = [ "json" ] }
serde = { version = "1.0.151", features = [ "derive" ] }
serde_json = "1.0.91"
thiserror = "1.0.38"
Expand Down
16 changes: 13 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,30 +1,40 @@
pub fn main() {
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rustc-check-cfg=cfg(coverage_nightly)");
nightly();
beta();
stable();
}

#[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() {}
fn stable() {
println!("cargo:rustc-check-cfg=cfg(stable)");
}
35 changes: 25 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@
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,
Expand All @@ -217,6 +218,7 @@
clashing_extern_declarations,
coherence_leak_check,
confusable_idents,
const_eval_mutable_ptr_in_final_value,
const_evaluatable_unchecked,
const_item_mutation,
dead_code,
Expand Down Expand Up @@ -244,17 +246,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,
Expand All @@ -268,10 +269,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,
Expand All @@ -282,8 +286,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,
Expand All @@ -303,13 +309,16 @@
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,
Expand Down Expand Up @@ -343,27 +352,33 @@
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
Expand Down

0 comments on commit 5afd436

Please sign in to comment.