Skip to content

Rust: extract declarations of builtin types #19421

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 2 commits into
base: main
Choose a base branch
from

Conversation

aibaars
Copy link
Contributor

@aibaars aibaars commented Apr 30, 2025

This pull request adds extraction of declarations of built-in types.

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Apr 30, 2025
@aibaars aibaars force-pushed the aibaars/rust-builtin-types branch from 21aab9e to c4aa719 Compare April 30, 2025 11:26
@aibaars aibaars marked this pull request as ready for review April 30, 2025 11:40
@Copilot Copilot AI review requested due to automatic review settings April 30, 2025 11:40
@aibaars aibaars requested a review from a team as a code owner April 30, 2025 11:40
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 implements the extraction of built-in type declarations in Rust and updates related build configurations and the extractor.

  • Added a new file (types.rs) with declarations for built-in types.
  • Updated Bazel BUILD files to include the new builtins sources.
  • Extended the extractor to process the builtins directory during extraction.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
rust/tools/builtins/types.rs Added declarations for built-in types.
rust/tools/builtins/BUILD.bazel Defined a Bazel target for built-ins sources.
rust/extractor/src/main.rs Enhanced extractor to include builtins in extraction.
rust/BUILD.bazel Updated tools file group to reference built-ins.

Comment on lines 5 to 25
struct bool;
// Textual types
struct char;
struct str;
// Integer types
struct i8;
struct i16;
struct i32;
struct i64;
struct i128;
struct u8;
struct u16;
struct u32;
struct u64;
struct u128;
// Machine-dependent integer types
struct usize;
struct isize;
// floating-point types
struct f32;
struct f64;
Copy link
Preview

Copilot AI Apr 30, 2025

Choose a reason for hiding this comment

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

If these built-in type declarations are intended for use outside their module, consider adding public visibility (e.g., 'pub struct bool;') to ensure they are accessible where needed.

Suggested change
struct bool;
// Textual types
struct char;
struct str;
// Integer types
struct i8;
struct i16;
struct i32;
struct i64;
struct i128;
struct u8;
struct u16;
struct u32;
struct u64;
struct u128;
// Machine-dependent integer types
struct usize;
struct isize;
// floating-point types
struct f32;
struct f64;
pub struct bool;
// Textual types
pub struct char;
pub struct str;
// Integer types
pub struct i8;
pub struct i16;
pub struct i32;
pub struct i64;
pub struct i128;
pub struct u8;
pub struct u16;
pub struct u32;
pub struct u64;
pub struct u128;
// Machine-dependent integer types
pub struct usize;
pub struct isize;
// floating-point types
pub struct f32;
pub struct f64;

Copilot uses AI. Check for mistakes.

@@ -276,5 +277,13 @@ fn main() -> anyhow::Result<()> {
}
}
}
let builtins_dir = env::var("CODEQL_EXTRACTOR_RUST_ROOT")
Copy link
Preview

Copilot AI Apr 30, 2025

Choose a reason for hiding this comment

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

[nitpick] When iterating over the builtins directory, consider filtering for Rust source files (e.g., files ending with '.rs') to prevent the processing of unrelated files in case extra files are present.

Copilot uses AI. Check for mistakes.

@aibaars aibaars force-pushed the aibaars/rust-builtin-types branch from c4aa719 to e8797ed Compare April 30, 2025 11:58
@aibaars aibaars force-pushed the aibaars/rust-builtin-types branch from e8797ed to 8a02f98 Compare April 30, 2025 15:11
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.

1 participant