-
Notifications
You must be signed in to change notification settings - Fork 11
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
Add a way to set the lint level on the function/statement level, without the register_tool
feature
#201
Comments
I'll take a look at this, although my immediate feeling is I will end up in over my head. I'll document anything I find here, but I wouldn't be expecting a PR soon. |
Perfect! Next week, I plan to create some simpler issues, probably focussed on utilities for Marker, if that's something you would be interested in :). Any documentation for this one, would already be a big help :) |
For the second point in the issue description, note that that should only be an unstable opt-in option from the user side. Maybe via an environment value or setting in the configuration :) |
Not sure if you already knew it or if it helps, but beware that there is a hacky workaround that is definitely discouraged from anyone on the rustc developers team. But.. in the absence of a better solution it seems to be a lesser evil than installing a nightly toolchain.
|
I really don't like that, because that would mean the feature would become available, but linted code would still need to use the unstable feature, by putting the I'm going to try to use the conditional compilation approach, because it seems the most palatable, and it seems more stable than relying on undocumented rustc behavior. besides, if we do need the bootstrap hack, we'd probably only want it to happen on linting runs anyway, so we are back to conditional compilation. |
I'm with @NathanFrasier on this one. However, it's an interesting hack to know regardless :) Btw @NathanFrasier, did you make any progress on this one? Otherwise, I could take over. It's totally fine if you're still researching and want to take more time :). I just got back from a long weekend, and will try to catch up on everything first, and there are plenty of other issues for me to tackle :D |
I didn't get terribly far, I spent a little bit of time setting up a more complete testing environment to test the issue, and I have that now, but I haven't really dug into the code yet. I'll probably continue to look into this regardless, my next step was probably to figure out how set a config flag during the driver run so that a conditional compile would have a flag to trigger off. That's just step 1 however, because that doesn't address the core issue of how to get cargo marker to accept the attributes without I'd like to keep looking into this, because it feels like a relatively concrete way to try and learn some of the internals on a deeper level. That said, you can get started on an actual implementation. My hope is that doing this will give me a better overview and I can at least be a competent reviewer of the final PR :) If you'd like to give me more time and see what I come up with, I'm fine with that too. There's plenty of work to go around I suppose. |
Could you describe your setup? This sounds interesting, I'm not quite sure how to test this in the CI yet. I'm guessing it's just a local setup, but it would be interesting :)
Okay, then I'll slowly start looking into this. Reviews are really valuable! ❤️ Writing more documentation about the structure and inner works of Marker is on the todo list. If you have any questions, I'm always happy to answer them :) |
Sure, although I don't think it's really anything special. I've got my local clone of the I removed the ui tests from the linting crate, mostly because I'm trying to keep things minimal for now, and I also got a touch lazy. To actually run my lints against my code, I use a normal |
That sounds like a good setup for |
So I added a simple config flag, I've got my fork here: NathanFrasier:experiment/add-cfg-flag I think this can actually be sufficient for our use case, because you can use the cfg flag both to conditionally compile the lint attribute, ie: The only reason I'm not sure is that I was having trouble getting the tests to behave in a way that I thought made sense. There is very possibly an issue still present with this implementation. It seemed like in some cases the attribute was passed, but in others it wasn't, code that should have produced warnings was sometimes caught by the linter and sometimes not. I don't think the issues I saw would be caused by #200 but I'm not sure. A couple things to note about this bare bones approach.
I intend to keep testing with this, and possibly iterate on it, however I wanted my findings thus far to be documented. |
Having a simple Additional, I would like the option to filter for specific lint crates, similar to how dylint provides the
We could merge the PR for #200 today, it would probably be good to do that beforehand anyways. That will also help with testing. @NathanFrasier do you want to give the additional filtering a try? Then I would start on the most fun part of this issue: Documentation. This will take some time, as I want to first setup an mdbook to then add a chapter about this. I would also leave the exact cfg names blank for now, until we made a decision on the naming :) |
Oh as an additional idea, we could see if we can programmatically add Edit: The relevant function in rustc to find all tool names is |
Yeah, I thought it was pretty elegant actually.
I actually think we might be able to just use
Reviewed, for whatever my opinion is worth.
Before I really continue adding more complexity, I'd really like to see a clean test case of what I currently have. I have no problem continuing to work on this, I just will need a bit of time, since I'm only volunteering nights to this. My tentative plan is to ensure that the current config flag works as expected, then attempt to just supply a
I'm ok writing docs, if you set up an mdbook, I can try to write something up. Again, it's just going to be somewhat time limited. |
I am admittedly, having a hard time seeing the utility of this. I'm all for supplying users with the info, I'm just struggling to see a user story where they would need this. My (possibly wrong) understanding is that dylint needs it because each lint crate gets it's own lint run, and you need to only allow your attribute on the run of that lint crate, and remove it on all others. Would marker be subject to the same limitation? |
That's a really cool idea! I didn't even think of that, that's why discussions are super helpful!
It's definitely helpful, I'll take a look at it :)
Perfect, thank you! Then I'll look into setting up a mdbook! |
Small update from the rust tracking issue (rust-lang/rust#66079) it sounds like anything in that regard is a bust, without a proper RFC. Sadly annoying, but nothing we can do about it right now. The conditional compilation approach will be the best one. I also want to allow users to use an unstable hack, but the |
@NathanFrasier I've assigned you to the issue for overview purposes, hope that's okay with you :) |
So I've finally gotten around to figuring out why the testing was so inconsistent. Now that I've had some time to just do some basic tests, it looks like my plan does pan out, with the slight caveat that I need to pass The only thing I'm struggling with right now is how to get the strings to put in these config flags. Ideally we use the crate name, but during the main function of the driver, it looks like we only have absolute paths to these crates. I think to get crate names, I just need to find a way to call |
Do you really use "--cfg="crate_name""? It sounds like that would add the
Right now, the driver only has access to the absolute paths. Using |
Oops, no, I don't do that. That's the problem writing github comments after midnight. I pass I'll see about updating that environment variable and try to get a PR up today. |
Perfect, I've changed some of the code that reads the |
214: 201/pass cfg flags r=xFrednet a=NathanFrasier This is a little rough. I feel like there has to be a better way to get rid of some of the calls to `.push()` and `.extend()` but I wasn't thinking of them. This still needs documentation as well. Addresses #201 Co-authored-by: Nathan Frasier <[email protected]>
This had been closed by #214 |
Rustc currently forbids lint names starting with a tool name, like
marker::example
. Theregister_tool
feature (rust-lang/rust#66079) can be used to addmarker
as a tool. However, this would require every create that wants to set lint levels on a function/statement level to use nightly.Ideally, I would like the error, to be reduced to a normal lint trigger, until the
register_tool
feature is discussed, one distant day. However, Marker still needs a solution meanwhile for crates that can't update to a new version of rustc.I think the following two solutions should be investigated:
marker_
instead. This could be a viable solution, if this only triggers theunknown_lint
lint of rustcAll working solutions should be documented :)
The text was updated successfully, but these errors were encountered: