Skip to content

Rust: Update BadCtorInitialization.ql to use getCanonicalPath. #20150

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

geoffw0
Copy link
Contributor

@geoffw0 geoffw0 commented Jul 31, 2025

Update BadCtorInitialization.ql to use getCanonicalPath() rather than getResolvedCrateOrigin().

  • tests all pass.
  • on MRVA we lose a proportion of results due to them not having a [resolved] getStaticTarget(), but results are otherwise identical (that is, we don't lose any due to the matches expression failing).
  • DCA TODO

@Copilot Copilot AI review requested due to automatic review settings July 31, 2025 14:24
@geoffw0 geoffw0 requested a review from a team as a code owner July 31, 2025 14:24
@geoffw0 geoffw0 added no-change-note-required This PR does not need a change note Rust Pull requests that update Rust code labels Jul 31, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the BadCtorInitialization.ql query to use getCanonicalPath() instead of getResolvedCrateOrigin() for identifying standard library calls. The change aims to improve the reliability of detecting calls to the Rust standard library by using canonical paths with pattern matching rather than crate origin resolution.

  • Replaces getResolvedCrateOrigin() calls with getCanonicalPath().matches() pattern matching
  • Consolidates two separate conditions for CallExpr and MethodCallExpr into a single condition using CallExprBase
  • Uses pattern matching to detect standard library paths with prefixes "std::" and "<std::"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-change-note-required This PR does not need a change note Rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy