You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The question is, should we extend its API with simpler functions like check_fn? If yes, for which items should we define them?
The difference in code is basically using a more generic function (check_item) and then checking if the item you are given is the one you want. With proposed helper functions:
impl<'ast>LintPass<'ast>forTestLintPass{fncheck_fn(&mutself,cx:&'astAstContext<'ast>,fn_item:&'astFnItem<'ast>){// do something with the function item}}
Without:
impl<'ast>LintPass<'ast>forTestLintPass{fncheck_item(&mutself,cx:&'astAstContext<'ast>,item:&'astItemKind<'ast>){ifletItemKind::Fn(fn_item) = item {// do something with the function item}}}
As you can see, we already provide some of these functions (check_const_item, check_static_item), and rustc does too in its LateLintPass trait (check_fn, check_arm).
If I look at rustc's LateLintPass documentation, I find it a bit overwhelming and cluttered. Based on this, I think it could be good, to only provide very few check_* methods for ItemKind, ExprKind, StmtKind kind where the user then selects the nodes they're interested in.
The text was updated successfully, but these errors were encountered:
Current
LintPass
trait looks something like this:The question is, should we extend its API with simpler functions like
check_fn
? If yes, for which items should we define them?The difference in code is basically using a more generic function (
check_item
) and then checking if the item you are given is the one you want. With proposed helper functions:Without:
As you can see, we already provide some of these functions (
check_const_item
,check_static_item
), and rustc does too in itsLateLintPass
trait (check_fn
,check_arm
).@xFrednet's comment from rust-marker/marker#75:
The text was updated successfully, but these errors were encountered: