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
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bevy_lint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ harness = false
# Contains a series of useful utilities when writing lints. The version is chosen to work with the
# currently pinned nightly Rust version. When the Rust version changes, this too needs to be
# updated!
clippy_utils = "=0.1.89"
clippy_utils = "=0.1.90"

# Easy error propagation and contexts.
anyhow = "1.0.86"
Expand Down
4 changes: 2 additions & 2 deletions bevy_lint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ see <https://linebender.org/blog/doc-include/>.
You can install the toolchain required for the latest release with:

```sh
rustup toolchain install nightly-2025-05-14 \
rustup toolchain install nightly-2025-06-26 \
--component rustc-dev \
--component llvm-tools-preview
```
Expand All @@ -44,7 +44,7 @@ If you are installing a different version of the linter, you may need to install
Once you have the toolchain installed, you can compile and install `bevy_lint` through `cargo`:

```sh
rustup run nightly-2025-05-14 cargo install \
rustup run nightly-2025-06-26 cargo install \
--git https://github.com/TheBevyFlock/bevy_cli.git \
--tag lint-v0.3.0 \
--locked \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl<'tcx> LateLintPass<'tcx> for CameraModificationInFixedUpdate {
// Get the type arguments and ignore Lifetimes
let mut query_type_arguments =
args.iter()
.filter_map(|generic_arg| match generic_arg.unpack() {
.filter_map(|generic_arg| match generic_arg.kind() {
GenericArgKind::Type(ty) => Some(ty),
_ => None,
});
Expand Down Expand Up @@ -195,7 +195,7 @@ impl<'tcx> LateLintPass<'tcx> for CameraModificationInFixedUpdate {
&& let Some(filter_component_arg) = with_args.iter().next()
// Get the type of the component the filter should filter for
&& let GenericArgKind::Type(filter_component_ty) =
filter_component_arg.unpack()
filter_component_arg.kind()
// Check if Filter is of type `Camera`
&& crate::paths::CAMERA.matches_ty(cx, filter_component_ty)
// Emit lint if any `Camera` component is mutably borrowed
Expand Down
9 changes: 4 additions & 5 deletions bevy_lint/src/lints/pedantic/borrowed_reborrowable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,8 @@ use clippy_utils::{
use rustc_errors::Applicability;
use rustc_hir::{Body, FnDecl, MutTy, Mutability, PatKind, intravisit::FnKind};
use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::ty::{Ty, TyKind, TypeVisitable, TypeVisitor};
use rustc_middle::ty::{Region, Ty, TyCtxt, TyKind, TypeVisitable, TypeVisitor};
use rustc_span::{Span, def_id::LocalDefId, kw};
use rustc_type_ir::Interner;

use crate::{declare_bevy_lint, declare_bevy_lint_pass};

Expand Down Expand Up @@ -306,12 +305,12 @@ impl Reborrowable {
}

/// [`TypeVisitor`] for checking if the given region is contained in the type.
struct ContainsRegion<I: Interner>(pub I::Region);
struct ContainsRegion<'tcx>(pub Region<'tcx>);

impl<I: Interner> TypeVisitor<I> for ContainsRegion<I> {
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ContainsRegion<'tcx> {
type Result = ControlFlow<()>;

fn visit_region(&mut self, r: I::Region) -> Self::Result {
fn visit_region(&mut self, r: Region<'tcx>) -> Self::Result {
if self.0 == r {
ControlFlow::Break(())
} else {
Expand Down
4 changes: 2 additions & 2 deletions bevy_lint/src/lints/restriction/missing_reflect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ impl<'tcx> LateLintPass<'tcx> for MissingReflect {

// Extract a list of all fields within the structure definition.
let fields = match without_reflect_item.kind {
ItemKind::Struct(_, data, _) => data.fields().to_vec(),
ItemKind::Enum(_, enum_def, _) => enum_def
ItemKind::Struct(_, _, data) => data.fields().to_vec(),
ItemKind::Enum(_, _, enum_def) => enum_def
.variants
.iter()
.flat_map(|variant| variant.data.fields())
Expand Down
2 changes: 1 addition & 1 deletion bevy_lint/src/sym.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@

use clippy_utils::sym::EXTRA_SYMBOLS as CLIPPY_SYMBOLS;
/// These are symbols that we use but are already interned by either the compiler or Clippy.
pub use clippy_utils::sym::filter;
pub use rustc_span::sym::{bevy_ecs, plugin, reflect};
use rustc_span::{Symbol, symbol::PREDEFINED_SYMBOLS_COUNT};

Expand Down Expand Up @@ -141,7 +142,6 @@ declare_bevy_symbols! {
event,
Event,
Events,
filter,
FilteredEntityMut,
FixedUpdate,
init_resource,
Expand Down
2 changes: 1 addition & 1 deletion docs/src/linter/compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

|`bevy_lint` Version|Rust Version|Rustup Toolchain|Bevy Version|
|-|-|-|-|
|0.4.0-dev|1.89.0|`nightly-2025-05-14`|0.16|
|0.4.0-dev|1.90.0|`nightly-2025-06-26`|0.16|
|0.3.0|1.88.0|`nightly-2025-04-03`|0.16|
|0.2.0|1.87.0|`nightly-2025-02-20`|0.15|
|0.1.0|1.84.0|`nightly-2024-11-14`|0.14|
Expand Down
4 changes: 2 additions & 2 deletions docs/src/linter/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ bevy lint --yes
`bevy_lint` requires a specific nightly Rust toolchain with the `rustc-dev` and `llvm-tools-preview` components. You can install the toolchain required for the latest release with:

```sh
rustup toolchain install nightly-2025-05-14 \
rustup toolchain install nightly-2025-06-26 \
--component rustc-dev \
--component llvm-tools-preview
```
Expand All @@ -38,7 +38,7 @@ If you are installing a different version of the linter, you may need to install
Once you have the toolchain installed, you can compile and install `bevy_lint` through Cargo:

```sh
rustup run nightly-2025-05-14 cargo install \
rustup run nightly-2025-06-26 cargo install \
--git https://github.com/TheBevyFlock/bevy_cli.git \
--tag lint-v0.3.0 \
--locked \
Expand Down
4 changes: 2 additions & 2 deletions docs/src/linter/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ If you have `cranelift` setup as a custom codegen backend, you may run into the

```
error: failed to find a `codegen-backends` folder in the sysroot candidates:
* ~/.rustup/toolchains/nightly-2025-05-14-x86_64-unknown-linux-gnu
* ~/.rustup/toolchains/nightly-2025-05-14-x86_64-unknown-linux-gnu
* ~/.rustup/toolchains/nightly-2025-06-26-x86_64-unknown-linux-gnu
* ~/.rustup/toolchains/nightly-2025-06-26-x86_64-unknown-linux-gnu
```

This error occurs because you do not have `cranelift` installed for the specific nightly toolchain that the linter uses. You can fix this by installing `rustc-codegen-cranelift-preview` for the linter's toolchain:
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
[toolchain]
# Writing custom lints requires using nightly Rust. We pin to a specific version of nightly version
# so that builds are reproducible.
channel = "nightly-2025-05-14"
channel = "nightly-2025-06-26"
# These components are required to use `rustc` crates.
components = ["rustc-dev", "llvm-tools-preview"]
8 changes: 4 additions & 4 deletions src/commands/build/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ impl BuildArgs {
let is_release = self.is_release();

#[cfg(feature = "web")]
if let Some(BuildSubcommands::Web(web_args)) = self.subcommand.as_mut() {
if web_args.wasm_opt.is_empty() {
web_args.wasm_opt = config.wasm_opt(is_release).to_raw();
}
if let Some(BuildSubcommands::Web(web_args)) = self.subcommand.as_mut()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahahha sneaky (;

&& web_args.wasm_opt.is_empty()
{
web_args.wasm_opt = config.wasm_opt(is_release).to_raw();
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/commands/run/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ impl RunArgs {
let is_release = self.is_release();

#[cfg(feature = "web")]
if let Some(RunSubcommands::Web(web_args)) = self.subcommand.as_mut() {
if web_args.wasm_opt.is_empty() {
web_args.wasm_opt = config.wasm_opt(is_release).to_raw();
}
if let Some(RunSubcommands::Web(web_args)) = self.subcommand.as_mut()
&& web_args.wasm_opt.is_empty()
{
web_args.wasm_opt = config.wasm_opt(is_release).to_raw();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ fn extract_default_features(cli_metadata: &Map<String, Value>) -> anyhow::Result
_ => bail!("default_features must be a boolean"),
}
} else {
return Ok(None);
Ok(None)
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/web/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ async fn dev_websocket(ws: WebSocketUpgrade) -> Response {

async fn handle_socket(mut socket: WebSocket) {
while let Some(Ok(msg)) = socket.recv().await {
if let Message::Text(msg) = msg {
if socket.send(Message::Text(msg)).await.is_err() {
break;
}
if let Message::Text(msg) = msg
&& socket.send(Message::Text(msg)).await.is_err()
{
break;
}
}
}
Expand Down
Loading