Skip to content

Conversation

aibaars
Copy link
Contributor

@aibaars aibaars commented Oct 18, 2024

@hvitved FYI

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Oct 18, 2024
import codeql.rust.elements.GenericParam
import codeql.rust.elements.GenericParamList
import codeql.rust.elements.IdentPat
import codeql.rust.elements.IfExpr

Check warning

Code scanning / CodeQL

Redundant import Warning

Redundant import, the module is already imported inside
codeql.rust.elements.FormatArgsExpr
.
Redundant import, the module is already imported inside codeql.rust.elements.FormatArgument.

private import internal.FormatArgumentImpl
import codeql.rust.elements.Format
import codeql.rust.elements.Locatable

Check warning

Code scanning / CodeQL

Redundant import Warning

Redundant import, the module is already imported inside
codeql.rust.elements.Format
.
@aibaars aibaars force-pushed the aibaars/local-defs branch from 8653e35 to a755175 Compare October 22, 2024 12:22
@aibaars aibaars changed the base branch from main to aibaars/rust-format-templates October 22, 2024 12:23
@aibaars aibaars force-pushed the aibaars/rust-format-templates branch 2 times, most recently from 4cfbd20 to 24abe34 Compare October 24, 2024 13:08
@aibaars aibaars force-pushed the aibaars/local-defs branch from a755175 to 54589af Compare October 24, 2024 13:09
@aibaars aibaars force-pushed the aibaars/rust-format-templates branch from 24abe34 to a7628e7 Compare October 24, 2024 13:19
@aibaars aibaars force-pushed the aibaars/local-defs branch 2 times, most recently from 17d4746 to 35b4aa0 Compare October 24, 2024 14:53
Base automatically changed from aibaars/rust-format-templates to main October 25, 2024 10:42
@aibaars aibaars force-pushed the aibaars/local-defs branch from 35b4aa0 to f092594 Compare October 25, 2024 10:57
@aibaars aibaars marked this pull request as ready for review October 25, 2024 13:54
Copy link
Contributor

@hvitved hvitved left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, a few comments. I also think we should have some tests.

/**
* Gets an element, of kind `kind`, that element `use` uses, if any.
*/
cached
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should probably also cache TDef, and make sure to cache them together, e.g.

private cached module Cached {
  cached newtype TDef ...

  cached Definition definitionOf(Use use, string kind) ...
}

predicate definitionOf = Cached::definitionOf/2;

private import codeql.Locations

/** An element with an associated definition. */
abstract class Use extends Locatable {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It probably makes sense to restrict this to uses that are not the result of a macro expansion?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand. This PR adds jump to definition for format arguments, which are all uses that are the result of macro expansion.

Perhaps we should restrict the definitions though. That should get rid of all the left_val and right_val references in the expansion of assert! macros.

*/

private import codeql.rust.elements.Variable
private import codeql.rust.elements.Locatable

Check warning

Code scanning / CodeQL

Redundant import Warning

Redundant import, the module is already imported inside
codeql.rust.elements.Format
.

private import codeql.rust.elements.Variable
private import codeql.rust.elements.Locatable
private import codeql.rust.elements.FormatArgsExpr

Check warning

Code scanning / CodeQL

Redundant import Warning

Redundant import, the module is already imported inside
codeql.rust.elements.Format
.
private import codeql.rust.elements.Variable
private import codeql.rust.elements.Locatable
private import codeql.rust.elements.FormatArgsExpr
private import codeql.rust.elements.FormatArgsArg

Check warning

Code scanning / CodeQL

Redundant import Warning

Redundant import, the module is already imported inside
codeql.rust.elements.FormatArgsExpr
.
@aibaars aibaars merged commit 2326861 into main Oct 28, 2024
14 checks passed
@aibaars aibaars deleted the aibaars/local-defs branch October 28, 2024 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants