Skip to content

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

Closed
@PatchMixolydic

Description

@PatchMixolydic
Contributor

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

added
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
A-contributor-roadblockArea: Makes things more difficult for new or seasoned contributors to Rust
requires-nightlyThis issue requires a nightly compiler in some way.
on Aug 11, 2024
workingjubilee

workingjubilee commented on Aug 11, 2024

@workingjubilee
Member

nice catch

scottmcm

scottmcm commented on Aug 12, 2024

@scottmcm
Member

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

workingjubilee

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'.

PatchMixolydic

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.

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.
and removed
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Aug 13, 2024
added
T-libsRelevant to the library team, which will review and decide on the PR/issue.
on Aug 13, 2024
added 3 commits that reference this issue on Dec 4, 2024

Rollup merge of rust-lang#133863 - oli-obk:push-pystoxvtvssx, r=lqd

06338ca

Rollup merge of rust-lang#133863 - oli-obk:push-pystoxvtvssx, r=lqd

c4e6438

Rollup merge of rust-lang#133863 - oli-obk:push-pystoxvtvssx, r=lqd

44174d9
added a commit that references this issue on Dec 5, 2024
7cb68b3
added a commit that references this issue on Mar 11, 2025

Rollup merge of rust-lang#133863 - oli-obk:push-pystoxvtvssx, r=lqd

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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @PatchMixolydic@scottmcm@jieyouxu@workingjubilee@rustbot

      Issue actions

        `std::pat::pattern_type!` is gated by two feature gates with nearly identical names · Issue #128987 · rust-lang/rust