Skip to content

std::pat::pattern_type! is gated by two feature gates with nearly identical names #128987

Closed

Description

@PatchMixolydic

I tried this code (playground):

#![feature(core_pattern_type)]

use std::pat::pattern_type;

This resulted in:

warning: unused import: `std::pat::pattern_type`
 --> src/lib.rs:3:5
  |
3 | use std::pat::pattern_type;
  |     ^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

error[E0658]: use of unstable library feature 'core_pattern_types'
 --> src/lib.rs:3:5
  |
3 | use std::pat::pattern_type;
  |     ^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #123646 <https://github.com/rust-lang/rust/issues/123646> for more information
  = help: add `#![feature(core_pattern_types)]` to the crate attributes to enable
  = note: this compiler was built on 2024-08-10; consider upgrading it if it is out of date

I thought I mistyped the feature name, so I tried replacing core_pattern_type with core_pattern_types:

#![feature(core_pattern_types)]

use std::pat::pattern_type;

This resulted in:

warning: unused import: `std::pat::pattern_type`
 --> src/lib.rs:3:5
  |
3 | use std::pat::pattern_type;
  |     ^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

error[E0658]: use of unstable library feature 'core_pattern_type'
 --> src/lib.rs:3:5
  |
3 | use std::pat::pattern_type;
  |     ^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #123646 <https://github.com/rust-lang/rust/issues/123646> for more information
  = help: add `#![feature(core_pattern_type)]` to the crate attributes to enable
  = note: this compiler was built on 2024-08-10; consider upgrading it if it is out of date

This is because std::pat is gated under core_pattern_types (as is core::pat), while core::pattern_type (and, by extension, std::pat::pattern_type) is gated under core_pattern_type (note the lack of a trailing s). This can be confusing to people who are trying to use pattern_type! in the Rust codebase (or, in a hypothetical future, people who are trying to experiment with it in user code).

Meta

rustc --version --verbose:

rustc 1.80.0 (051478957 2024-07-21)
binary: rustc
commit-hash: 051478957371ee0084a7c0913941d2a8c4757bb9
commit-date: 2024-07-21
host: x86_64-unknown-linux-gnu
release: 1.80.0
LLVM version: 18.1.7

Reproduces on the Playground: 1.82.0-nightly (2024-08-10 730d5d4095a264ef5f7c)

@rustbot label +A-contributor-roadblock +F-pattern_types +requires-internal-features +requires-nightly

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    A-contributor-roadblockArea: Makes things more difficult for new or seasoned contributors to Rust
    requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.
    on Aug 11, 2024
  2. workingjubilee commented on Aug 11, 2024

    @workingjubilee
    Member

    nice catch

  3. scottmcm commented on Aug 12, 2024

    @scottmcm
    Member

    Library types being under a different gate from language features is often a good thing.

  4. workingjubilee commented on Aug 12, 2024

    @workingjubilee
    Member

    @scottmcm I won't argue otherwise, but it could at least be a difference that is not "probably a typo" tho'.

  5. PatchMixolydic commented on Aug 12, 2024

    @PatchMixolydic
    ContributorAuthor

    Library types being under a different gate from language features is often a good thing.

    The language feature is actually under a third feature gate, pattern_types.

  6. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    D-confusingDiagnostics: Confusing error or lint that should be reworked.
    T-libsRelevant to the library team, which will review and decide on the PR/issue.
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Aug 13, 2024
  7. added 3 commits that reference this issue on Dec 4, 2024
    06338ca
    c4e6438
    44174d9
  8. added a commit that references this issue on Dec 5, 2024
    7cb68b3
  9. added a commit that references this issue on Mar 11, 2025
    7dfb4de
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-contributor-roadblockArea: Makes things more difficult for new or seasoned contributors to RustA-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.D-confusingDiagnostics: Confusing error or lint that should be reworked.F-core_pattern_type`#![feature(core_pattern_type)]`F-core_pattern_types`#![feature(core_pattern_types)]`F-pattern_types`#![feature(pattern_types)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-libsRelevant to the library team, which will review and decide on the PR/issue.requires-internal-featuresThis issue requires the use of internal features.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions