File tree Expand file tree Collapse file tree
src/queries/unusedentities
test/query-tests/unusedentities Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import rust
2+ private import codeql.rust.internal.PathResolution
23
34/**
45 * A deliberately unused variable, for example `_` or `_x`.
@@ -23,9 +24,13 @@ predicate isUnused(Variable v) {
2324 */
2425class IncompleteCallable extends Callable {
2526 IncompleteCallable ( ) {
26- exists ( MacroExpr me |
27- me .getEnclosingCallable ( ) = this and
27+ exists ( MacroExpr me | me .getEnclosingCallable ( ) = this |
2828 not me .getMacroCall ( ) .hasMacroCallExpansion ( )
29+ or
30+ exists ( ItemNode i |
31+ i .getCanonicalPath ( _) = [ "core::macros::unimplemented" , "core::macros::todo" ] and
32+ me .getMacroCall ( ) .resolveMacro ( ) = i
33+ )
2934 )
3035 }
3136}
Original file line number Diff line number Diff line change @@ -558,6 +558,14 @@ trait MyTrait {
558558 fn my_func2 ( & self , x : i32 ) -> i32 ;
559559}
560560
561+ fn unimplemented ( x : i32 ) {
562+ unimplemented ! ( )
563+ }
564+
565+ fn todo ( x : i32 ) {
566+ todo ! ( )
567+ }
568+
561569// --- main ---
562570
563571fn main ( ) {
You can’t perform that action at this time.
0 commit comments