diff --git a/bevy_lint/src/lints/mod.rs b/bevy_lint/src/lints/mod.rs index 17b4060..189343f 100644 --- a/bevy_lint/src/lints/mod.rs +++ b/bevy_lint/src/lints/mod.rs @@ -22,8 +22,7 @@ pub(crate) static LINTS: &[&BevyLint] = &[ insert_unit_bundle::INSERT_UNIT_BUNDLE, main_return_without_appexit::MAIN_RETURN_WITHOUT_APPEXIT, missing_reflect::MISSING_REFLECT, - panicking_methods::PANICKING_QUERY_METHODS, - panicking_methods::PANICKING_WORLD_METHODS, + panicking_methods::PANICKING_METHODS, plugin_not_ending_in_plugin::PLUGIN_NOT_ENDING_IN_PLUGIN, zst_query::ZST_QUERY, ]; diff --git a/bevy_lint/src/lints/panicking_methods.rs b/bevy_lint/src/lints/panicking_methods.rs index c705d85..c357ca5 100644 --- a/bevy_lint/src/lints/panicking_methods.rs +++ b/bevy_lint/src/lints/panicking_methods.rs @@ -4,10 +4,6 @@ //! For instance, this will lint against `Query::single()`, recommending that `Query::get_single()` //! should be used instead. //! -//! This lint is actually two: [`PANICKING_QUERY_METHODS`] and [`PANICKING_WORLD_METHODS`]. Each -//! can be toggled separately. The query variant lints for `Query` and `QueryState`, while the -//! world variant lints for `World`. -//! //! # Motivation //! //! Panicking is the nuclear option of error handling in Rust: it is meant for cases where recovery @@ -86,24 +82,18 @@ use clippy_utils::{ ty::match_type, }; use rustc_hir::Expr; -use rustc_lint::{LateContext, LateLintPass, Lint}; +use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::Ty; use rustc_span::Symbol; declare_bevy_lint! { - pub PANICKING_QUERY_METHODS, - RESTRICTION, - "called a `Query` or `QueryState` method that can panic when a non-panicking alternative exists", -} - -declare_bevy_lint! { - pub PANICKING_WORLD_METHODS, + pub PANICKING_METHODS, RESTRICTION, - "called a `World` method that can panic when a non-panicking alternative exists", + "called a method that can panic when a non-panicking alternative exists", } declare_bevy_lint_pass! { - pub PanickingMethods => [PANICKING_QUERY_METHODS.lint, PANICKING_WORLD_METHODS.lint], + pub PanickingMethods => [PANICKING_METHODS.lint], } impl<'tcx> LateLintPass<'tcx> for PanickingMethods { @@ -220,7 +210,7 @@ impl<'tcx> LateLintPass<'tcx> for PanickingMethods { span_lint_and_help( cx, - panicking_type.lint(), + PANICKING_METHODS.lint, span, format!( "called a `{}` method that can panic when a non-panicking alternative exists", @@ -295,14 +285,4 @@ impl PanickingType { Self::World => "World", } } - - /// Returns the [`Lint`] associated with this panicking type. - /// - /// This can either return [`PANICKING_QUERY_METHODS`] or [`PANICKING_WORLD_METHODS`]. - fn lint(&self) -> &'static Lint { - match self { - Self::Query | Self::QueryState => PANICKING_QUERY_METHODS.lint, - Self::World => PANICKING_WORLD_METHODS.lint, - } - } } diff --git a/bevy_lint/tests/ui/panicking_methods/query.rs b/bevy_lint/tests/ui/panicking_methods/query.rs index 0244cf2..ffdbe83 100644 --- a/bevy_lint/tests/ui/panicking_methods/query.rs +++ b/bevy_lint/tests/ui/panicking_methods/query.rs @@ -1,8 +1,8 @@ -//! This tests the `panicking_query_methods` lint, specifically when triggered on the `Query` type. +//! This tests the `panicking_methods` lint, specifically when triggered on the `Query` type. #![feature(register_tool)] #![register_tool(bevy)] -#![deny(bevy::panicking_query_methods)] +#![deny(bevy::panicking_methods)] use bevy::prelude::*; diff --git a/bevy_lint/tests/ui/panicking_methods/query.stderr b/bevy_lint/tests/ui/panicking_methods/query.stderr index 8d03ab7..e8d6d59 100644 --- a/bevy_lint/tests/ui/panicking_methods/query.stderr +++ b/bevy_lint/tests/ui/panicking_methods/query.stderr @@ -8,8 +8,8 @@ error: called a `Query` method that can panic when a non-panicking alternative e note: the lint level is defined here --> tests/ui/panicking_methods/query.rs:5:9 | -5 | #![deny(bevy::panicking_query_methods)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +5 | #![deny(bevy::panicking_methods)] + | ^^^^^^^^^^^^^^^^^^^^^^^ error: called a `Query` method that can panic when a non-panicking alternative exists --> tests/ui/panicking_methods/query.rs:21:5 diff --git a/bevy_lint/tests/ui/panicking_methods/query_state.rs b/bevy_lint/tests/ui/panicking_methods/query_state.rs index 96460ce..749eda4 100644 --- a/bevy_lint/tests/ui/panicking_methods/query_state.rs +++ b/bevy_lint/tests/ui/panicking_methods/query_state.rs @@ -1,9 +1,9 @@ -//! This tests the `panicking_query_methods` lint, specifically when triggered on the `QueryState` +//! This tests the `panicking_methods` lint, specifically when triggered on the `QueryState` //! type. #![feature(register_tool)] #![register_tool(bevy)] -#![deny(bevy::panicking_query_methods)] +#![deny(bevy::panicking_methods)] use bevy::prelude::*; diff --git a/bevy_lint/tests/ui/panicking_methods/query_state.stderr b/bevy_lint/tests/ui/panicking_methods/query_state.stderr index c0e4c84..91ccf5b 100644 --- a/bevy_lint/tests/ui/panicking_methods/query_state.stderr +++ b/bevy_lint/tests/ui/panicking_methods/query_state.stderr @@ -8,8 +8,8 @@ error: called a `QueryState` method that can panic when a non-panicking alternat note: the lint level is defined here --> tests/ui/panicking_methods/query_state.rs:6:9 | -6 | #![deny(bevy::panicking_query_methods)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +6 | #![deny(bevy::panicking_methods)] + | ^^^^^^^^^^^^^^^^^^^^^^^ error: called a `QueryState` method that can panic when a non-panicking alternative exists --> tests/ui/panicking_methods/query_state.rs:22:13 diff --git a/bevy_lint/tests/ui/panicking_methods/world.rs b/bevy_lint/tests/ui/panicking_methods/world.rs index 890d501..6ceddbc 100644 --- a/bevy_lint/tests/ui/panicking_methods/world.rs +++ b/bevy_lint/tests/ui/panicking_methods/world.rs @@ -1,8 +1,8 @@ -//! This tests the `panicking_query_methods` lint, specifically when triggered on the `World` type. +//! This tests the `panicking_methods` lint, specifically when triggered on the `World` type. #![feature(register_tool)] #![register_tool(bevy)] -#![deny(bevy::panicking_world_methods)] +#![deny(bevy::panicking_methods)] use bevy::prelude::*; diff --git a/bevy_lint/tests/ui/panicking_methods/world.stderr b/bevy_lint/tests/ui/panicking_methods/world.stderr index 1c0cd9f..0431bee 100644 --- a/bevy_lint/tests/ui/panicking_methods/world.stderr +++ b/bevy_lint/tests/ui/panicking_methods/world.stderr @@ -8,8 +8,8 @@ error: called a `World` method that can panic when a non-panicking alternative e note: the lint level is defined here --> tests/ui/panicking_methods/world.rs:5:9 | -5 | #![deny(bevy::panicking_world_methods)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +5 | #![deny(bevy::panicking_methods)] + | ^^^^^^^^^^^^^^^^^^^^^^^ error: called a `World` method that can panic when a non-panicking alternative exists --> tests/ui/panicking_methods/world.rs:27:5