diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4fdcd602..8dc0aa03 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -83,6 +83,9 @@ jobs: sweep-cache: true - name: Run Clippy + env: + # Although we don't use any unstable options, this enables `rustc::internal` lints. + RUSTFLAGS: -Zunstable-options run: cargo clippy --workspace --all-targets ${{ matrix.features }} -- --deny warnings rustfmt: diff --git a/bevy_lint/src/lib.rs b/bevy_lint/src/lib.rs index e726399e..878b14e6 100644 --- a/bevy_lint/src/lib.rs +++ b/bevy_lint/src/lib.rs @@ -9,12 +9,19 @@ #![feature(rustc_private)] // Allows chaining `if let` multiple times using `&&`. #![feature(let_chains)] -// Warn on internal `rustc` lints that check for poor usage of internal compiler APIs. +// Warn on internal `rustc` lints that check for poor usage of internal compiler APIs. Note that +// you also need to pass `-Z unstable-options` to `rustc` for this to be enabled: +// `RUSTFLAGS="-Zunstable-options" cargo check` #![warn(rustc::internal)] +#![allow( + rustc::usage_of_ty_tykind, + reason = "Many false positives without a valid replacement." +)] // This is a list of every single `rustc` crate used within this library. If you need another, add // it here! extern crate rustc_abi; +extern crate rustc_data_structures; extern crate rustc_driver; extern crate rustc_errors; extern crate rustc_hir; diff --git a/bevy_lint/src/lints/nursery/duplicate_bevy_dependencies.rs b/bevy_lint/src/lints/nursery/duplicate_bevy_dependencies.rs index 7fbf9622..11541a8d 100644 --- a/bevy_lint/src/lints/nursery/duplicate_bevy_dependencies.rs +++ b/bevy_lint/src/lints/nursery/duplicate_bevy_dependencies.rs @@ -60,13 +60,7 @@ //! leafwing-input-manager = "0.16" //! ``` -use std::{ - collections::{BTreeMap, HashMap}, - ops::Range, - path::Path, - str::FromStr, - sync::Arc, -}; +use std::{collections::BTreeMap, ops::Range, path::Path, str::FromStr, sync::Arc}; use crate::declare_bevy_lint; use cargo_metadata::{ @@ -121,7 +115,7 @@ pub fn check(cx: &LateContext<'_>, metadata: &Metadata, bevy_symbol: Symbol) { let local_name = cx.tcx.crate_name(LOCAL_CRATE); // get the package name and the corresponding version of `bevy` that they depend on - let mut bevy_dependents = HashMap::new(); + let mut bevy_dependents = BTreeMap::default(); for package in &metadata.packages { for dependency in &package.dependencies { if dependency.name.as_str() == "bevy" @@ -155,7 +149,7 @@ fn lint_with_target_version( cargo_toml: &CargoToml, file: &Arc, bevy_cargo: &Spanned, - bevy_dependents: &HashMap<&str, VersionReq>, + bevy_dependents: &BTreeMap<&str, VersionReq>, ) { // Semver only supports checking if a given `VersionReq` matches a `Version` and not if two // `VersionReq` can successfully resolve to one `Version`. Therefore we try to parse the @@ -191,7 +185,7 @@ fn lint_with_target_version( fn minimal_lint( cx: &LateContext<'_>, - bevy_dependents: &HashMap<&str, VersionReq>, + bevy_dependents: &BTreeMap<&str, VersionReq>, resolved: &Resolve, ) { // Examples of the underlying string representation of resolved crates diff --git a/bevy_lint/src/lints/nursery/zst_query.rs b/bevy_lint/src/lints/nursery/zst_query.rs index e57182fc..5b7eb688 100644 --- a/bevy_lint/src/lints/nursery/zst_query.rs +++ b/bevy_lint/src/lints/nursery/zst_query.rs @@ -111,7 +111,7 @@ impl<'tcx> LateLintPass<'tcx> for ZstQuery { hir_ty.span, ZST_QUERY.lint.desc, None, - query_kind.help(&peeled), + query_kind.help(peeled), ); } } @@ -130,7 +130,7 @@ impl QueryKind { } } - fn help(&self, ty: &Ty<'_>) -> String { + fn help(&self, ty: Ty<'_>) -> String { // It should be noted that `With` is not always the best filter to suggest. // While it's most often going to be what users want, there's also `Added` // and `Changed` which might be more appropriate in some cases