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

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

Open
PatchMixolydic opened this issue Aug 11, 2024 · 4 comments
Labels
A-contributor-roadblock Area: Makes things more difficult for new contributors to rust itself A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. D-confusing Diagnostics: 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)]` requires-internal-features This issue requires the use of internal features. requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Comments

@PatchMixolydic
Copy link
Contributor

PatchMixolydic commented Aug 11, 2024

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

@PatchMixolydic PatchMixolydic added the C-bug Category: This is a bug. label Aug 11, 2024
@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. A-contributor-roadblock Area: Makes things more difficult for new contributors to rust itself F-pattern_types `#![feature(pattern_types)]` requires-internal-features This issue requires the use of internal features. requires-nightly This issue requires a nightly compiler in some way. labels Aug 11, 2024
@workingjubilee
Copy link
Member

nice catch

@scottmcm
Copy link
Member

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

@workingjubilee
Copy link
Member

workingjubilee commented Aug 12, 2024

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

@PatchMixolydic
Copy link
Contributor Author

PatchMixolydic commented Aug 12, 2024

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.

@jieyouxu jieyouxu added F-core_pattern_types `#![feature(core_pattern_types)]` F-core_pattern_type `#![feature(core_pattern_type)]` A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. D-confusing Diagnostics: Confusing error or lint that should be reworked. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Aug 13, 2024
@jieyouxu jieyouxu added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-contributor-roadblock Area: Makes things more difficult for new contributors to rust itself A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. D-confusing Diagnostics: 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)]` requires-internal-features This issue requires the use of internal features. requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants