Skip to content

Commit 727c31a

Browse files
authored
Rollup merge of #123648 - oli-obk:pattern_types_syntax, r=compiler-errors
Avoid ICEing without the pattern_types feature gate fixes #123643
2 parents f3b4412 + 24ee9b9 commit 727c31a

File tree

4 files changed

+44
-2
lines changed

4 files changed

+44
-2
lines changed

compiler/rustc_feature/src/unstable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ declare_features! (
216216
/// Set the maximum pattern complexity allowed (not limited by default).
217217
(internal, pattern_complexity, "1.78.0", None),
218218
/// Allows using pattern types.
219-
(internal, pattern_types, "CURRENT_RUSTC_VERSION", Some(54882)),
219+
(internal, pattern_types, "CURRENT_RUSTC_VERSION", Some(123646)),
220220
/// Allows using `#[prelude_import]` on glob `use` items.
221221
(internal, prelude_import, "1.2.0", None),
222222
/// Used to identify crates that contain the profiler runtime.

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -2249,7 +2249,11 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
22492249
Ty::new_pat(tcx, ty, pat)
22502250
}
22512251
hir::PatKind::Err(e) => Ty::new_error(tcx, e),
2252-
_ => span_bug!(pat.span, "unsupported pattern for pattern type: {pat:#?}"),
2252+
_ => Ty::new_error_with_message(
2253+
tcx,
2254+
pat.span,
2255+
format!("unsupported pattern for pattern type: {pat:#?}"),
2256+
),
22532257
};
22542258
self.record_ty(pat.hir_id, ty, pat.span);
22552259
pat_ty
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//! This test ensures we do not ICE for unimplemented
2+
//! patterns unless the feature gate is enabled.
3+
4+
#![feature(core_pattern_type)]
5+
#![feature(core_pattern_types)]
6+
7+
use std::pat::pattern_type;
8+
9+
type Always = pattern_type!(Option<u32> is Some(_));
10+
//~^ ERROR: pattern types are unstable
11+
12+
type Binding = pattern_type!(Option<u32> is x);
13+
//~^ ERROR: pattern types are unstable
14+
15+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
error[E0658]: pattern types are unstable
2+
--> $DIR/unimplemented_pat.rs:9:15
3+
|
4+
LL | type Always = pattern_type!(Option<u32> is Some(_));
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #123646 <https://github.com/rust-lang/rust/issues/123646> for more information
8+
= help: add `#![feature(pattern_types)]` to the crate attributes to enable
9+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
10+
11+
error[E0658]: pattern types are unstable
12+
--> $DIR/unimplemented_pat.rs:12:16
13+
|
14+
LL | type Binding = pattern_type!(Option<u32> is x);
15+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
16+
|
17+
= note: see issue #123646 <https://github.com/rust-lang/rust/issues/123646> for more information
18+
= help: add `#![feature(pattern_types)]` to the crate attributes to enable
19+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
20+
21+
error: aborting due to 2 previous errors
22+
23+
For more information about this error, try `rustc --explain E0658`.

0 commit comments

Comments
 (0)