-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Improve documentation on cap-lints #5998
Comments
/cc @alexcrichton |
Looks like Cargo has issues with silenting lint warnings on external dependencies (rust-lang/cargo#5998), so until that's fixed, let's go back to warning for everything that can sudenly change. From the looks of it, the only lint rule that won't be affected by external libraries or the copiler out of a sudden is `unsafe_code`. Therefore, holding on to that one.
@behnam indeed, cargo changes the lint cap based on the type of dependency. Non-local dependencies (i.e. crates you cannot control) are |
I see. Thanks for the explanation, @ehuss. Now, then, first, I believe we need to make sure the docs are explaining this better. The word "upstream" is not defined clearly in the specs, and the actual compiler doc is even missing the word. Apparently, there's also another matter here: the And, I believe there should be more docs around macro/derive behavior, as well. What do you think? |
Code generated by procedural macros will be under the mercy of whatever settings you have in your crate. I don't think it's likely that the compiler can treat it differently since it gets directly inserted in your code at a relatively early phase. In general, using deny can be dangerous (see https://github.com/rust-unofficial/patterns/blob/master/anti_patterns/deny-warnings.md). I imagine the documentation could clarify this behavior and include good practices. I'm not sure where, exactly, though. The rustc book generally doesn't document cargo behavior (I would say the existing remark is just to say "hey, here's an example of how this is used", not a detailed description). There is an open PR to significantly enhance lint controls in Cargo (#5728), and I imagine that would be the perfect opportunity to document it in depth. However, that PR seems to have stalled. |
Generally speaking derive macros are intended to be in a separate lint environment, much like edition scoping, but I don't think it's been implemented yet. |
I'd like to add a cargo |
I think it is actually easier to use registry dependencies. They can be added with one line of code:
|
Okay, I'll go look at the tests that use this pattern and see if I can adapt it to my own needs. |
See #7850 (comment) and #12115. Documentation can be resolved when @rustbot label +S-needs-team-input Laballed as such since it is blocked on |
@weihanglo how is this related to |
I forgot. From what I can see now, not closely related to |
Looking over the points of confusion highlighted in rust-lang#5998, one is in rustc which is agnostic of any of this policy and the rest are in historical documents. Inspired by previous comments, I figured we could fit this into a discussion of `[lints]` by talking about the scope of the feature. Fixes rust-lang#5998
docs(ref): Find a place to comment on --cap-lints Looking over the points of confusion highlighted in #5998, one is in rustc which is agnostic of any of this policy and the rest are in historical documents. Inspired by previous comments, I figured we could fit this into a discussion of `[lints]` by talking about the scope of the feature. Fixes #5998
Looking over the points of confusion highlighted in rust-lang#5998, one is in rustc which is agnostic of any of this policy and the rest are in historical documents. Inspired by previous comments, I figured we could fit this into a discussion of `[lints]` by talking about the scope of the feature. Fixes rust-lang#5998
I'm looking at some docs for the
--cap-lints
and it's not clear what the expected behavior is.In https://doc.rust-lang.org/rustc/lints/levels.html, we have:
In rust-lang/rfcs#1193 we have:
And in #1830 we have:
And the RFC has similar wordings, with an emphasis at the end:
Reading all the docs above, I'm not sure what "upstream dependencies" mean exactly. From the
rustc
doc, it seems that it's just any dependent crate.But my guess is that Cargo doesn't want to disable such warnings when working in a workspace. So, probably "upstream" means any dependency out of current manifest's workspace.
But, setting up a simple test tells me neither of the above is right, and I'm guessing again that "upstream" would mean anything not fetched from the local machine. (Which is a bit more confusing, because I would expect the same behavior if using a remote git repo or using a local checkout of that the same repo--both being outside of my current workspace.)
This is the library:
my-lint-error/src/lib.rs
and this is the caller:
my-caller-app/src/main.rs
and the caller's manifest has:
The build fails with the lint error coming from the dependency:
The test shows how a
deny
error from a library is breakingcargo build
in a dependent crate. Looking at therustc
command, there's no--cap-lints
passed in. Running the same command with--cap-lints allow
builds the dependent without any issues. Therefore, I'm guessing there's a bug here in Cargo.What do you think? Did I miss something in the docs?
PS. I'm on today's
nightly
and my~/.cargo/config
only has a bunch of aliases, so I believe my personal configuration is not causing this.The text was updated successfully, but these errors were encountered: