Skip to content

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

Open

Description

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

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

Metadata

Assignees

No one assigned

    Labels

    A-contributor-roadblockArea: Makes things more difficult for new contributors to rust itselfArea: Makes things more difficult for new contributors to rust itselfA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.F-core_pattern_type`#![feature(core_pattern_type)]``#![feature(core_pattern_type)]`F-core_pattern_types`#![feature(core_pattern_types)]``#![feature(core_pattern_types)]`F-pattern_types`#![feature(pattern_types)]``#![feature(pattern_types)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant 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.Relevant to the library team, which will review and decide on the PR/issue.requires-internal-featuresThis issue requires the use of internal featuresThis issue requires the use of internal featuresrequires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions