Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 8 additions & 1 deletion bevy_lint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 4 additions & 10 deletions bevy_lint/src/lints/nursery/duplicate_bevy_dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -155,7 +149,7 @@ fn lint_with_target_version(
cargo_toml: &CargoToml,
file: &Arc<SourceFile>,
bevy_cargo: &Spanned<toml::Value>,
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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions bevy_lint/src/lints/nursery/zst_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
);
}
}
Expand All @@ -130,7 +130,7 @@ impl QueryKind {
}
}

fn help(&self, ty: &Ty<'_>) -> String {
fn help(&self, ty: Ty<'_>) -> String {
// It should be noted that `With<Foo>` is not always the best filter to suggest.
// While it's most often going to be what users want, there's also `Added<Foo>`
// and `Changed<Foo>` which might be more appropriate in some cases
Expand Down