Skip to content

Conversation

@redsun82
Copy link
Contributor

Now the reason of the absence of rust-analyzer semantics is also accompanied by a severity. For the cases where we have a valid reason not to have semantics (the source file is not compiled) we use Info rather than Warning which was the case before.

As I'm touching this area in any case, I also corrected the macro expansion, call graph, and type inference will be skipped message to only mention macro expansion.

@redsun82 redsun82 requested review from geoffw0 and paldepind August 26, 2025 09:59
@redsun82 redsun82 requested a review from a team as a code owner August 26, 2025 09:59
Copilot AI review requested due to automatic review settings August 26, 2025 09:59
@github-actions github-actions bot added the Rust Pull requests that update Rust code label Aug 26, 2025
Copy link
Contributor

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 refines the diagnostic reporting system for Rust extractor by downgrading certain warnings to info level when rust-analyzer semantics are unavailable for valid reasons (like uncompiled source files). It introduces a structured approach to handle different severity levels for missing semantics scenarios.

  • Adds a Default trait to DiagnosticSeverity enum with Info as the default
  • Creates a new RustAnalyzerNoSemantics struct to encapsulate severity and reason for missing semantics
  • Updates error messages to be more accurate and changes severity from Warning to Info for valid non-compilation cases

Reviewed Changes

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

File Description
rust/extractor/src/trap.rs Adds Default derive and default attribute to DiagnosticSeverity::Info
rust/extractor/src/rust_analyzer.rs Introduces RustAnalyzerNoSemantics struct and updates function signatures to use it
rust/extractor/src/main.rs Updates call sites to use new structured error handling and adjusts diagnostic severities

) -> Option<(RootDatabase, Vfs)> {
let progress = |t| trace!("progress: {t}");
let manifest = project.manifest_path();
let manifest: &ManifestPath = project.manifest_path();
Copy link

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

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

[nitpick] This explicit type annotation is unnecessary since the type can be inferred from context. Consider removing it to reduce code noise.

Suggested change
let manifest: &ManifestPath = project.manifest_path();
let manifest = project.manifest_path();

Copilot uses AI. Check for mistakes.
let full_message = format!(
"{message}: macro expansion, call graph, and type inference will be skipped."
);
let full_message = format!("{message}: macro expansion will be skipped.");
Copy link

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

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

[nitpick] The message should be consistent with standard punctuation. Consider removing the period at the end for consistency with other diagnostic messages, or ensure all diagnostic messages follow the same punctuation pattern.

Suggested change
let full_message = format!("{message}: macro expansion will be skipped.");
let full_message = format!("{message}: macro expansion will be skipped");

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@geoffw0 geoffw0 left a comment

Choose a reason for hiding this comment

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

Changes LGTM.

What about the "could not resolve macro" warnings that users are seeing?

match semantics.file_to_module_def(id) {
None => return Err("not included as a module".to_string()),
None => {
return Err(RustAnalyzerNoSemantics::info("not included as a module"));
Copy link
Contributor

Choose a reason for hiding this comment

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

So if I'm understanding correctly, this (and the one immediately below) are the bits of this change that affect results - downgrading these warnings to info so that they're no longer output by rust/diagnostics/extraction-warnings (and thus, we believe, won't appear on the status page).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

indeed

geoffw0
geoffw0 previously approved these changes Aug 26, 2025
@redsun82
Copy link
Contributor Author

What about the "could not resolve macro" warnings that users are seeing?

those are genuine problems, typically coming from rust-analyzer. Sadly, rust-analyzer itself doesn't report more than that (macro expansion returns an Option, not a Result). Still, the wording there is wrong (it's not macro resolution that fails, it's expansion in general), so I tweaked that.

@redsun82 redsun82 requested a review from geoffw0 August 26, 2025 12:01
Copy link
Contributor

@geoffw0 geoffw0 left a comment

Choose a reason for hiding this comment

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

Thanks, still LGTM.

@redsun82 redsun82 merged commit dd68d68 into main Aug 26, 2025
14 of 15 checks passed
@redsun82 redsun82 deleted the redsun82/rust-less-warnings branch August 26, 2025 15:45
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.

3 participants