Fix aliased crate handling in aliases attribute #3693
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes an issue where
crate_universeconfiguration usingdefault_alias_rule_bzlwould fail when processing aliased crates in the aliases() function.Problem
When using
default_alias_rule_bzlin crate_universe configuration, Bazel fails to build targets that depend on aliased crates. The error occurs because the current logic assumes a direct correspondence between target labels (k.label) and their crate info owners (crate_info.owner), but for aliased targets,crate_info.ownerpoints to the original target, not the alias label.Solution
This change updates the alias resolution logic in
rust/private/rustc.bzlto correctly handle aliased crates by:rust_common.crate_infocrate_info.ownerif available, otherwise falling back tok.labelCode Changes
Modified files:
rust/private/rustc.bzl: Updated alias processing logic incollect_depsfunctionBefore:
After:
Testing
This fix enables the use of
default_alias_rule_bzlfunctionality without breaking alias generation for crates that have aliased targets.Related Issues
Fixes #3692
Checklist
Note: This change is essential for users who want to leverage
default_alias_rule_bzlwith crate_universe to integrate with existing Bazel rule sets like@rules_cc.