Skip to content

Future-incompatible warnings should always print a warning, even if lints are allowed #34596

Closed

Description

@nikomatsakis

Currently, if a future-incompatible lint is set to allow (either manually or via cap-lints), no warning is printed. This is bad because it means that if you author a library that is widely used, but which you are not actively using at the moment, you might not notice that it will break in the future -- moreover, your users won't either, since cargo will cap lints when it builds your library as a dependency.

So basically the behavior for future-incompatible lints would be that they can either be "warn" or "deny" but can never be completely silenced. If cap-lints is set to allow, then while other lints will be set to allow, the future-incompatible lints will be set to warn (but not deny).

cc @rust-lang/compiler @brson

Activity

  1. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
    E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.
    on Jul 1, 2016
  2. nikomatsakis commented on Jul 1, 2016

    @nikomatsakis
    ContributorAuthor

    I'm marking this as mentor because I'd be happy to mentor it (though until July 15 I'm on vacation). I marked it as easy because think this should be relatively straightforward, though I may be wrong about that. I'll try to look at the code in a bit and print out a summary of what would need to be done.

  3. hgallagher1993 commented on Jul 1, 2016

    @hgallagher1993
  4. brson commented on Jul 1, 2016

    @brson
  5. hgallagher1993 commented on Jul 11, 2016

    @hgallagher1993
  6. pnkfelix commented on Jul 11, 2016

    @pnkfelix
  7. hgallagher1993 commented on Jul 11, 2016

    @hgallagher1993
  8. nikomatsakis commented on Jul 21, 2016

    @nikomatsakis
    Author
  9. nikomatsakis commented on Aug 2, 2016

    @nikomatsakis
    ContributorAuthor

    @hgallagher1993 ok, sorry for the delay. I did a bit of digging. I think the changes you need to make are roughly this:

    In src/librustc/lint.rs, there is a function called set_level -- it changes the level of reporting for a lint. Currently, it first checks something called the lint_cap, which records a maximum level (this is used by cargo so that you don't see "unused variable" warnings for your dependencies).

    What we want to do I think is change that function to also check whether self.future_incompatible(lint).is_some(), in which case this is a future-incompatibility warning. In that case, after applying the lint-cap, we should set the level to max(level, warn) -- in other words, ensure the level is at least warn, regardless of what the lint-cap says.

    We can also add some test cases for this using the testing framework. The simplest test would be something that takes some future-incompatible lint and sets it to #[allow] -- we should still get a warning. We can also have a test that passes -A cap-lints=allow, which should yield the same result. I can help you more w/ writing said tests if you need.

    (One twist: we may want to add a "dummy" future-incompatible lint just for testing purposes...)

  10. nikomatsakis commented on Aug 3, 2016

    @nikomatsakis
    ContributorAuthor

    That said, @wycats has been arguing to me that this would be a bad thing to do. It may be worth having a wider discussion if there are other approaches we might consider.

  11. nikomatsakis commented on Aug 3, 2016

    @nikomatsakis
    ContributorAuthor

    I think, if I may take a stab at summarizing @wycats's point-of-view, that his position is:

    • seeing warnings in code you don't control is annoying (true)
    • users are unlikely to file issues or know how to respond (seems true)
      • they may well respond by just downgrading
    • we would be better off finding other ways to alert crates.io maintainers of upcoming problems, and finding other ways to alert end-users of the need for action
      • for example, we already try to alert crate owners to warnings that we uncover via crater runs, but we could try to have some kind of dashboard or other thing you can look at...or something...
        • this might include other statistics too, like docs etc
      • we could encourage people to cargo yank soon-to-be-broken versions and give a reason, for example citing the upcoming change
        • this could then warn users that they should update their dependencies to newly available version
  12. jacwah commented on Jan 16, 2017

    @jacwah
    Contributor

    @hgallagher1993 Do you still want to fix this issue? Otherwise I'd be willing to handle it.

    @nikomatsakis Considering @wycats' comments, do you think the implementation you outlined above still should be followed?

    Some thoughts:

    users are unlikely to file issues or know how to respond

    Maybe the message could link to the crate's homepage/repository and invite the user to contact the maintainer?

    seeing warnings in code you don't control is annoying

    This is very true. Say there's a very stable application working well and doing it's thing. There's no reason to change it or upgrade Rust version. This is a case where silencing future incompatible warnings may be desirable.

  13. nikomatsakis commented on Jan 17, 2017

    @nikomatsakis
    ContributorAuthor

    @jacwah I'm honestly not sure what to do here. What we're doing now doesn't seem right, but just enabling the warnings also doesn't seem ideal. I think perhaps what is needed is better integration with cargo and maybe even crates.io -- i.e., if we (the compiler team) could leave annotations on abandoned crates, and those could be summarized to people who depend on them, that might be ideal.

    cc @wycats @alexcrichton

  14. 22 remaining items

  15. pnkfelix commented on Mar 28, 2019

    @pnkfelix
    Contributor

    (removing nomination label since @Centril self-assigned. I'm just going to assert "yes, this is important" until someone convinces me otherwise.)

  16. pnkfelix commented on May 2, 2019

    @pnkfelix
    Contributor

    triage: re-prioritizing to P-medium; this is being addressed, and while the task is high priority, it does not need to be given the same level of urgency that I would like to associate with P-high.

  17. added and removed
    P-highHigh priority
    on May 2, 2019
  18. assigned and unassigned on Sep 29, 2019
  19. Centril commented on Sep 29, 2019

    @Centril
    Contributor

    Reassigning to @pnkfelix since they are doing the work on this right now.

  20. pnkfelix commented on Jan 9, 2020

    @pnkfelix
    Contributor

    The aforementioned work was invested in drafting rust-lang/rfcs#2834

  21. pnkfelix commented on Sep 2, 2022

    @pnkfelix
    Contributor

    I think the problem raised here is now addressed by rust-lang/rfcs#2834 and #71249, right?

  22. est31 commented on Sep 2, 2022

    @est31
    Member

    @pnkfelix I agree this should be closed in favour of the RFC and its tracking issue.

  23. RalfJung commented on Sep 2, 2022

    @RalfJung
    Member

    Is there something tracking the process of turning all existing future-incompatibility warnings into warnings that show up in the FCW report?

  24. est31 commented on Sep 2, 2022

    @est31
    Member

    @RalfJung outside of the C-future-compatibility label I don't know of any better tracking. As for whether each forward compatibility warning should be added to cargo, I'm not sure. I think that if the number of affected users is small it can also be skipped.

  25. pnkfelix commented on Nov 17, 2022

    @pnkfelix
    Contributor

    Closing in favor of rust-lang/rfcs#2834 and #71249,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

C-feature-requestCategory: A feature request, i.e: not implemented / a PR.I-needs-decisionIssue: In need of a decision.P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions