Skip to content
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

Traverse custom alias-like rules in the rust analyzer aspect #1190

Conversation

hlopko
Copy link
Member

@hlopko hlopko commented Mar 14, 2022

No description provided.

Copy link
Collaborator

@illicitonion illicitonion left a comment

Choose a reason for hiding this comment

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

I'm not going to lie, this is one of the stranger PRs, but I assume it solves a useful problem :)

if BuildInfo in dep:
build_info = dep[BuildInfo]
dep_infos = []
if hasattr(ctx.rule.attr, "proc_macro_deps"):
Copy link
Collaborator

Choose a reason for hiding this comment

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

This feels worth a comment - I'm assuming this is for sniffing whether we're a rules_rust rule vs some other one, which happens to also expose BuildInfo?

Copy link
Member Author

Choose a reason for hiding this comment

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

This was a bug :) I wanted to test if there is 'deps' attribute, not a 'proc_macro_deps' attribute. Fixed now.

if hasattr(ctx.rule.attr, "proc_macro_deps"):
dep_infos += [dep[RustAnalyzerInfo] for dep in ctx.rule.attr.proc_macro_deps if RustAnalyzerInfo in dep]
if hasattr(ctx.rule.attr, "crate") and ctx.rule.attr.crate != None:
dep_infos.append(ctx.rule.attr.crate[RustAnalyzerInfo])
if hasattr(ctx.rule.attr, "actual") and ctx.rule.attr.actual != None:
dep_infos.append(ctx.rule.attr.actual[RustAnalyzerInfo])
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should probably sniff for whether actual has a RustAnalyzerInfo before trying to read it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@hlopko hlopko force-pushed the traverse_custom_alias_like_rules_with_rust_analyzer_aspect branch from aa83917 to 90f0c3d Compare March 15, 2022 08:12
Copy link
Collaborator

@UebelAndre UebelAndre left a comment

Choose a reason for hiding this comment

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

Thanks!

@hlopko hlopko force-pushed the traverse_custom_alias_like_rules_with_rust_analyzer_aspect branch from 8aa19f5 to 166b4fa Compare March 15, 2022 16:19
@hlopko hlopko merged commit a665447 into bazelbuild:main Mar 15, 2022
@hlopko hlopko deleted the traverse_custom_alias_like_rules_with_rust_analyzer_aspect branch March 15, 2022 16:50
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.

None yet

3 participants