Skip to content
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

Support multiple stability attributes on items #131824

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Commits on Nov 6, 2024

  1. Refactor stability structs

    This moves stability structs' `feature` fields into `StabilityLevel::Unstable` and
    `ConstStabilityLevel::Unstable`, in preparation to support multiple unstable attributes on items.
    
    Seemingly, the `feature` field isn't used with the `StabilityLevel::Stable` variant, so I haven't
    included it. `rustc_passes::lib_features` uses the 'feature' meta-item for 'stable' attributes, but
    it extracts them itself, rather than relying on `rustc_attr`.
    
    In order to support the new const stability check rules, this additionally introduces
    `ConstStabilityLevel` and moves the case of `feature` being `None` to the `Implicit` variant for
    clarity; having it correspond to an empty `unstables` vec seems like it would be a footgun.
    dianne committed Nov 6, 2024
    Configuration menu
    Copy the full SHA
    9e13239 View commit details
    Browse the repository at this point in the history
  2. factor out some commonalities in the find_stability family of funct…

    …ions
    
    the logic for adding unstable attrs gets a bit messier when supporting multiple
    instances thereof. this keeps that from being duplicated in 3 places.
    dianne committed Nov 6, 2024
    Configuration menu
    Copy the full SHA
    bbcb69a View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    cf6adc1 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    3500be9 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    7317353 View commit details
    Browse the repository at this point in the history
  6. find_stability: don't give up when emitting "multiple stability lev…

    …els" errors
    
    this makes things a little cleaner.
    since multiple stability levels are allowed, I think it makes sense too.
    dianne committed Nov 6, 2024
    Configuration menu
    Copy the full SHA
    8c7c0fa View commit details
    Browse the repository at this point in the history
  7. support multiple stability attributes (a mix of stable and unstable)

    An item is unstable if it has any unstable attributes, to make it easier to track which features
    library items depended on as they stabilize.
    
    This changes the text for E0544. Unfortunately, the example doesn't make much sense anymore.
    
    The way this merges stability levels together is made to work for stability-checking and rustdoc;
    as far as I can tell, only `rustc_passes::lib_features` needs them separate, and it extracts them
    itself.
    dianne committed Nov 6, 2024
    Configuration menu
    Copy the full SHA
    22fcdf9 View commit details
    Browse the repository at this point in the history
  8. Improve diagnostics for the use of unstable library features

    - only emits one error/lint (instead of one per missing feature) per usage of unstable and
      body-unstable items
    - only emits one future-name-collision lint (instead of one per missing feature) for unstable trait
      items
    - makes diagnostics for unstable, soft-unstable, const-unstable, and body-unstable library features
      translatable, using common subdiagnostic structs.
    - adds notes with features, reasons, and issue links to const-unstability errors
    - adds notes with issue links to soft_unstable lints
    - on nightly, adds `#![feature]` crate attr help to soft_unstable lints
    - on nightly, adds compiler-upgrade-suggestion notes to const-unstable and soft_unstable diagnostics
    dianne committed Nov 6, 2024
    Configuration menu
    Copy the full SHA
    ac6041e View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    3e86a5e View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    c4ac551 View commit details
    Browse the repository at this point in the history
  11. Simplify unstable language feature use diagnostics

    Reasons provided on `#[unstable]` attributes are now per-item rather than
    per-feature. This is how they mostly are used anyway, and it simplifies both
    the implementation and the diagnostics themselves.
    dianne committed Nov 6, 2024
    Configuration menu
    Copy the full SHA
    de1fbaf View commit details
    Browse the repository at this point in the history
  12. Add sanity check for inconsistent soft usage on soft-unstable items

    It doesn't make sense for something to be partially soft, and allowing inconsistent softness
    markers would risk an item accidentally becoming properly unstable as its features stabilize.
    dianne committed Nov 6, 2024
    Configuration menu
    Copy the full SHA
    ac1f9f7 View commit details
    Browse the repository at this point in the history
  13. Suppress redundant listing of unstable library features used on nightly

    On nightly, there's a suggestion/help containing the `#![feature(..)]`
    attribute required to enable any required unstable features, so the note
    listing the features is unnecessary. This only applies to const-unstable
    and default-body-unstable errors. Normal "use of unstable library
    feature" errors list the features in the error message, so it doesn't
    feel redundant.
    dianne committed Nov 6, 2024
    Configuration menu
    Copy the full SHA
    d9915da View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    b9af36e View commit details
    Browse the repository at this point in the history