Skip to content

Set Annotation::is_file_level in affected lint rules #19688

@ntBre

Description

@ntBre

The below is in reference to this check added in #19653:

// The `0..0` range is used to highlight file-level diagnostics.
if range == TextRange::default() {
annotation.set_file_level(true);
}

But this depends on the ability to cache Diagnostics more fully than we currently do in CacheMessage. The current caching scheme would lose the is_file_level flag on any Annotations.

Would it be much more work to instead change the rules that add file level diagnostics rather than doing this "global" override?

(the rule would have to mutate the Diagnostic after reporting it with report_diagnostic).

The reason I'd prefer this is that it makes it more apparent where we rely on this behavior and it doesn't prevent other rules to use an empty range (e.g. what if we had a rule that enforces module level docstrings. That rule would probably ask you to insert the docstring at 0:0.

Originally posted by @MichaReiser in #19653 (comment)

Metadata

Metadata

Assignees

Labels

diagnosticsRelated to reporting of diagnostics.internalAn internal refactor or improvement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions