-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
dependencies warning control, overriding path heuristic #8546
Comments
Have you tried using the |
@Eh2406 |
How many things can I get wrong in one day? :-P Just ignore me. Sorry for the noise. |
It might be reasonable to simply not warn for |
I'd like to take this on. Any pointers to how and where cargo decides to suppress warnings when building dependencies? Edited to add I never actually did start on this and don't plan to now. |
Yay, thanks for looking at this. I'm afraid I don't have any tips for navigating the inside of cargo. But I can say what the behaviour appears to be: Basically, path dependencies are treated like the toplevel crate and have warnings enabled. Warnings are suppressed for dependencies specified as IDK what Overall it appears that this "you see warnings" thing is a property of a dependency edge. Currently, just from the type of the edge. @alexcrichton is suggesting that I hope this is of some use... |
The decision to show warnings is controlled by |
I just encountered this and found this behavior surprising. Since I was doing no local patching of the dependency, the suggestions regarding My naive expectation is that the transition from crates.io dependency -> remote git dependency -> local path dependency should be doable without any change to the warnings that are printed. |
Just found this issue and would definitely appreciate some workaround for this, if only so that it's easier to develop a change for a dependency before submitting a PR upstream. Thank you for everyone's work on such a great system! |
See. #12115 (comment)
|
Describe the problem you are trying to solve
I am working on a project with upstream dependencies, some of which I have had to edit locally. So (pending an upstream release, and sometimes even pending locally committing the upstream code) I have edited my Cargo.toml to have a path dependency on the upstream.
However, the upstream has a number of warnings from rustc.
When I compile the same crate as a non-path dependency, cargo gets the version from crates.io - which has the same warnings - but the warnings are suppressed. Evidently cargo treats the use of a path dependency as an indication that I am a developer of the dependency and therefore want to see the warnings. (I failed to find a discussion of this in the cargo documentation.)
Describe the solution you'd like
This path dependency heuristic is a good rule of thumb. Usually it will be right. But it would be good if there were a way to override it.
I suggest an additional entry in the dependency, alongside the
path
key.propagate_warnings
maybe. The default would be false for non-path dependencies, and true for path dependencies, but it could be overridden by the depending crate.Warnings would be shown to the user if all of the dependency links from the toplevel to the relevant place had
propagate_warnings
. (I haven't checked but presumably this is what cargo does already, only just checking for path dependencies.)In my scenario this would mean that I would see the warnings if I ran
cargo build
in the directory of my dependency, but not in the directory of my own project. That seems right to me.Notes
It seems that a
git
dependency suppresses the warnings. So I could use a git dependency instead, as a workaround. In my situation this is less than ideal, because it means I must always be sure to commit all my edits to the dependency. For another user it might well be useful to enable the warnings.Another possibility would be some kind of global configuration to specify which crates to print warnings for. That would be independently useful but it would be less helpful in my specific situation.
The text was updated successfully, but these errors were encountered: