Skip to content

Commit

Permalink
Rename lint to borrowed_reborrowable
Browse files Browse the repository at this point in the history
  • Loading branch information
MrGVSV committed Nov 2, 2024
1 parent 8ac0757 commit 28f8071
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,28 +55,28 @@ use rustc_session::declare_lint_pass;
use rustc_span::{def_id::LocalDefId, symbol::Ident, Span};

declare_bevy_lint! {
pub BORROW_OF_COMMANDS,
pub BORROWED_COMMANDS,
PEDANTIC,
"parameter takes a mutable reference to `Commands` or `EntityCommands` instead of a re-borrowed instance",
}

declare_bevy_lint! {
pub BORROW_OF_RESOURCE,
pub BORROWED_RESOURCE,
PEDANTIC,
"parameter takes a mutable reference to `ResMut` or `NonSendMut` instead of a re-borrowed instance",
}

declare_bevy_lint! {
pub BORROW_OF_QUERY,
pub BORROWED_QUERY,
PEDANTIC,
"parameter takes a mutable reference to `Query` instead of a re-borrowed instance",
}

declare_lint_pass! {
BorrowOfReborrowable => [BORROW_OF_COMMANDS.lint, BORROW_OF_RESOURCE.lint, BORROW_OF_QUERY.lint]
BorrowedReborrowable => [BORROWED_COMMANDS.lint, BORROWED_RESOURCE.lint, BORROWED_QUERY.lint]
}

impl<'tcx> LateLintPass<'tcx> for BorrowOfReborrowable {
impl<'tcx> LateLintPass<'tcx> for BorrowedReborrowable {
fn check_fn(
&mut self,
cx: &LateContext<'tcx>,
Expand Down Expand Up @@ -186,11 +186,11 @@ impl Reborrowable {

fn lint(&self) -> &'static Lint {
match self {
Self::Commands => BORROW_OF_COMMANDS.lint,
Self::EntityCommands => BORROW_OF_COMMANDS.lint,
Self::Query => BORROW_OF_QUERY.lint,
Self::ResMut => BORROW_OF_RESOURCE.lint,
Self::NonSendMut => BORROW_OF_RESOURCE.lint,
Self::Commands => BORROWED_COMMANDS.lint,
Self::EntityCommands => BORROWED_COMMANDS.lint,
Self::Query => BORROWED_QUERY.lint,
Self::ResMut => BORROWED_RESOURCE.lint,
Self::NonSendMut => BORROWED_RESOURCE.lint,
}
}

Expand Down
10 changes: 5 additions & 5 deletions bevy_lint/src/lints/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
use crate::lint::BevyLint;
use rustc_lint::{Lint, LintStore};

pub mod borrow_of_reborrowable;
pub mod borrowed_reborrowable;
pub mod insert_event_resource;
pub mod main_return_without_appexit;
pub mod missing_reflect;
pub mod panicking_methods;
pub mod plugin_not_ending_in_plugin;

pub(crate) static LINTS: &[&BevyLint] = &[
borrow_of_reborrowable::BORROW_OF_COMMANDS,
borrow_of_reborrowable::BORROW_OF_RESOURCE,
borrow_of_reborrowable::BORROW_OF_QUERY,
borrowed_reborrowable::BORROWED_COMMANDS,
borrowed_reborrowable::BORROWED_RESOURCE,
borrowed_reborrowable::BORROWED_QUERY,
insert_event_resource::INSERT_EVENT_RESOURCE,
main_return_without_appexit::MAIN_RETURN_WITHOUT_APPEXIT,
panicking_methods::PANICKING_QUERY_METHODS,
Expand All @@ -30,7 +30,7 @@ pub(crate) fn register_lints(store: &mut LintStore) {
}

pub(crate) fn register_passes(store: &mut LintStore) {
store.register_late_pass(|_| Box::new(borrow_of_reborrowable::BorrowOfReborrowable));
store.register_late_pass(|_| Box::new(borrowed_reborrowable::BorrowedReborrowable));
store.register_late_pass(|_| Box::new(insert_event_resource::InsertEventResource));
store.register_late_pass(|_| Box::new(main_return_without_appexit::MainReturnWithoutAppExit));
store.register_late_pass(|_| Box::new(missing_reflect::MissingReflect));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! This tests the `borrow_of_reborrowable` lint, specifically when triggered on the `Commands` type.
//! This tests the `borrowed_reborrowable` lint, specifically when triggered on the `Commands` type.

#![feature(register_tool)]
#![register_tool(bevy)]
#![deny(bevy::borrow_of_commands)]
#![deny(bevy::borrowed_commands)]

use bevy::ecs::system::EntityCommands;
use bevy::prelude::*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
error: parameter takes `&mut Commands` instead of a re-borrowed `Commands`
--> tests/ui/borrow_of_reborrowable/commands.rs:17:22
--> tests/ui/borrowed_reborrowable/commands.rs:17:22
|
17 | fn mutable_reference(commands: &mut Commands) {
| ^^^^^^^^^^^^^^^^^^^^^^^ help: use `Commands` instead: `mut commands: bevy::prelude::Commands<'_, '_>`
|
note: the lint level is defined here
--> tests/ui/borrow_of_reborrowable/commands.rs:5:9
--> tests/ui/borrowed_reborrowable/commands.rs:5:9
|
5 | #![deny(bevy::borrow_of_commands)]
5 | #![deny(bevy::borrowed_commands)]
| ^^^^^^^^^^^^^^^^^^^^^^^^

error: parameter takes `&mut Commands` instead of a re-borrowed `Commands`
--> tests/ui/borrow_of_reborrowable/commands.rs:23:33
--> tests/ui/borrowed_reborrowable/commands.rs:23:33
|
23 | fn mutable_reference_return<'a>(_commands: &'a mut Commands) -> usize {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `Commands` instead: `mut _commands: bevy::prelude::Commands<'_, '_>`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! This tests the `borrow_of_reborrowable` lint, specifically when triggered on the `Query` type.
//! This tests the `borrowed_reborrowable` lint, specifically when triggered on the `Query` type.

#![feature(register_tool)]
#![register_tool(bevy)]
#![deny(bevy::borrow_of_query)]
#![deny(bevy::borrowed_query)]

use bevy::ecs::system::QueryLens;
use bevy::prelude::*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
error: parameter takes `&mut Query` instead of a re-borrowed `Query`
--> tests/ui/borrow_of_reborrowable/query.rs:17:22
--> tests/ui/borrowed_reborrowable/query.rs:17:22
|
17 | fn mutable_reference(query: &mut Query<Entity>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `Query` instead: `mut query: bevy::prelude::Query<'_, '_, bevy::prelude::Entity>`
|
note: the lint level is defined here
--> tests/ui/borrow_of_reborrowable/query.rs:5:9
--> tests/ui/borrowed_reborrowable/query.rs:5:9
|
5 | #![deny(bevy::borrow_of_query)]
5 | #![deny(bevy::borrowed_query)]
| ^^^^^^^^^^^^^^^^^^^^^

error: parameter takes `&mut Query` instead of a re-borrowed `Query`
--> tests/ui/borrow_of_reborrowable/query.rs:23:33
--> tests/ui/borrowed_reborrowable/query.rs:23:33
|
23 | fn mutable_reference_return<'a>(_query: &'a mut Query<Entity>) -> usize {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `Query` instead: `mut _query: bevy::prelude::Query<'_, '_, bevy::prelude::Entity>`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! This tests the `borrow_of_reborrowable` lint, specifically when triggered on the `ResMut` type.
//! This tests the `borrowed_reborrowable` lint, specifically when triggered on the `ResMut` type.

#![feature(register_tool)]
#![register_tool(bevy)]
#![deny(bevy::borrow_of_resource)]
#![deny(bevy::borrowed_resource)]

use bevy::prelude::*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
error: parameter takes `&mut ResMut` instead of a re-borrowed `ResMut`
--> tests/ui/borrow_of_reborrowable/resource.rs:19:22
--> tests/ui/borrowed_reborrowable/resource.rs:19:22
|
19 | fn mutable_reference(_res: &mut ResMut<Data>) {
| ^^^^^^^^^^^^^^^^^^^^^^^ help: use `ResMut` instead: `mut _res: bevy::prelude::ResMut<'_, Data>`
|
note: the lint level is defined here
--> tests/ui/borrow_of_reborrowable/resource.rs:5:9
--> tests/ui/borrowed_reborrowable/resource.rs:5:9
|
5 | #![deny(bevy::borrow_of_resource)]
5 | #![deny(bevy::borrowed_resource)]
| ^^^^^^^^^^^^^^^^^^^^^^^^

error: parameter takes `&mut ResMut` instead of a re-borrowed `ResMut`
--> tests/ui/borrow_of_reborrowable/resource.rs:25:33
--> tests/ui/borrowed_reborrowable/resource.rs:25:33
|
25 | fn mutable_reference_return<'a>(_res: &'a mut ResMut<Data>) -> usize {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `ResMut` instead: `mut _res: bevy::prelude::ResMut<'_, Data>`
Expand Down

0 comments on commit 28f8071

Please sign in to comment.