-
Notifications
You must be signed in to change notification settings - Fork 29
Add Lints disallow_fixed_update
and disallow_update
#463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
14797b1
to
d998a34
Compare
return; | ||
}; | ||
|
||
let schedule_ty = cx.typeck_results().expr_ty(schedule_label); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a "fun" thing I just realized, the following code isn't caught by the linter:
#![deny(bevy::disallow_update)]
fn update() -> impl ScheduleLabel {
Update
}
fn main() {
// Adding system to `Update` schedule, but no error is emitted.
App::new().add_systems(update(), my_system);
}
impl ScheduleLabel
is seen as an TyKind::Alias
, which isn't caught in match_type()
. We need to resolve the type again in order to get the final, concrete type:
if let TyKind::Alias(_, alias) = schedule_ty.kind() {
schedule_ty = cx.tcx.type_of(alias.def_id);
}
This isn't something you need to handle now, but we may need to eventually check for it in every single lint (oof). I'd like to wait until after #456 before messing with type path matching more, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hahah nice catch! whoever writes update()
is just evil ^^
be870e5
to
c9e437a
Compare
The schedule could be disallowed for a variety of reasons.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be good to go now!
😢 it was not. Missing |
I might have beaten you to it >:D |
closes #99