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