-
Notifications
You must be signed in to change notification settings - Fork 22
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
Can lints provide new annotations? #529
Comments
If I'm understanding the problem correctly, we need to find a way to make Offhand, I can think of two ways to do this:
As you can see from the tracking issue, Please let me know if I have misunderstood the problem. |
That sounds promising! I'll give noop-attr a try. |
It's not clear to me if the dummy proc macvro will work. jdm/dylint-test@816eaee is my attempt at it, and I see |
The following seems to work to recover the attributes: fn attr_def_ids(mut span: rustc_span::Span) -> Vec<rustc_hir::def_id::DefId> {
use rustc_span::hygiene::{walk_chain, ExpnKind, MacroKind};
use rustc_span::{ExpnData, SyntaxContext};
let mut def_ids = Vec::new();
while span.ctxt() != SyntaxContext::root() {
let expn_data = span.ctxt().outer_expn_data();
if let ExpnData {
kind: ExpnKind::Macro(MacroKind::Attr, _),
macro_def_id: Some(def_id),
..
} = expn_data
{
def_ids.push(def_id);
}
span = walk_chain(span, SyntaxContext::root());
}
def_ids
} When I run it in a fork of your example like this:
I see:
Note, however, that I had to change the procedural macro from pub fn must_root(
_: proc_macro::TokenStream,
body: proc_macro::TokenStream,
) -> proc_macro::TokenStream {
body.into_iter()
.map(|mut tree| {
tree.set_span(proc_macro::Span::call_site());
tree
})
.collect()
} Another approach, alternative to using Yet another approach I briefly considered was simulating Sorry that there is no obvious, one, "right" solution to this problem (at least not right now). |
Thank you so much! |
I'm experimenting with migrating Servo away from deprecated compiler plugins to using dylint. It's almost working, but I haven't figured out how to support a lint that looks for the presence of an annotation on a type (example). The original plugin is here, and I've found the following:
#[cfg_attr(dylint_lib = "lint", unrooted_must_root_lint::must_root)]
allows the non-dylint build to successuse of undeclared crate or module "unrooted_must_root_lint"
rlib
output to the lint crate and add a dependency on it, I getcould not find "unrooted_must_root_lint" in "lint"
when I trylint::unrooted_must_root_lint::must_rot
I have pushed my reduced testcase to https://github.com/jdm/dylint-test. Am I missing something, or is this not something that dylint can support?
The text was updated successfully, but these errors were encountered: