Skip to content

flycheck: Fix label for source file - #4238

Open
tyler-breisacher-zipline wants to merge 3 commits into
bazelbuild:mainfrom
tyler-breisacher-zipline:flycheck
Open

flycheck: Fix label for source file#4238
tyler-breisacher-zipline wants to merge 3 commits into
bazelbuild:mainfrom
tyler-breisacher-zipline:flycheck

Conversation

@tyler-breisacher-zipline

@tyler-breisacher-zipline tyler-breisacher-zipline commented Aug 21, 2026

Copy link
Copy Markdown

For example, if you have a BUILD file at my/cool/project/BUILD, and a source file at my/cool/project/src/utils/lib.rs, the label for that source file should be //my/cool/project:src/utils/lib.rs not //my/cool/project:lib.rs

@tyler-breisacher-zipline tyler-breisacher-zipline changed the title Fix label for source file flycheck: Fix label for source file Aug 21, 2026

@UebelAndre UebelAndre left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks! Can you think of any regression testing that could be added for this?

dzbarsky added a commit to hermeticbuild/rules_rust that referenced this pull request Aug 25, 2026
Use source_file_label to preserve filenames relative to the owning Bazel
package when query_label_for builds the srcs query. Files such as
src/adb.rs now match the target's source label instead of :adb.rs.

Add a regression test for root packages, nested directories, and direct
source files. The test fails with the old basename behavior.

Based on bazelbuild#4238; addresses hermeticbuild/rules_rs#232.

Validation: 10 Flycheck tests and 44 rust-analyzer library tests pass
through rules_rs. --saved-file command checks pass for four package
layouts.
@tyler-breisacher-zipline

Copy link
Copy Markdown
Author

Thanks! Can you think of any regression testing that could be added for this?

Maybe something like this 5f2c153 but the function naming needs some work: it's not obvious without reading the doc comments that query_string_for just produces the query string while query_label_for actually invokes bazel query with that string.

/// files. Returns the dir path; caller is responsible for cleanup
/// (use `remove_dir_all` in a `_guard`-style drop, or accept the
/// leak — TMPDIR gets cleaned eventually).
pub fn make_workspace(tag: &str, files: &[(&str, &str)]) -> Utf8PathBuf {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I wanted to make this #[cfg(test)] but it got configured out, maybe better to make a separate crate of test utils or something

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants