-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rust: implement Expr::getType for cases where rust-analyzer does not …
…provide one
- Loading branch information
Showing
8 changed files
with
73 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 19 additions & 2 deletions
21
rust/ql/lib/codeql/rust/elements/internal/MacroExprImpl.qll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,39 @@ | ||
// generated by codegen, remove this comment if you wish to edit this file | ||
/** | ||
* This module provides a hand-modifiable wrapper around the generated class `MacroExpr`. | ||
* | ||
* INTERNAL: Do not use. | ||
*/ | ||
|
||
private import codeql.rust.elements.internal.generated.MacroExpr | ||
private import codeql.rust.elements.MacroStmts | ||
|
||
/** | ||
* INTERNAL: This module contains the customizable definition of `MacroExpr` and should not | ||
* be referenced directly. | ||
*/ | ||
module Impl { | ||
// the following QLdoc is generated: if you need to edit it, do it in the schema file | ||
/** | ||
* A MacroExpr. For example: | ||
* ```rust | ||
* todo!() | ||
* ``` | ||
*/ | ||
class MacroExpr extends Generated::MacroExpr { } | ||
class MacroExpr extends Generated::MacroExpr { | ||
override string getType() { | ||
result = super.getType() | ||
or | ||
not exists(super.getType()) and | ||
( | ||
result = this.getMacroCall().getExpanded().(Expr).getType() or | ||
result = typeOf(this.getMacroCall().getExpanded().(MacroStmts)) | ||
) | ||
} | ||
} | ||
|
||
string typeOf(MacroStmts stmts) { | ||
result = stmts.getExpr().getType() | ||
or | ||
not exists(stmts.getExpr()) and result = "()" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters