File tree Expand file tree Collapse file tree 3 files changed +43
-1
lines changed
compiler/rustc_hir_analysis/src/hir_ty_lowering
tests/ui/type/pattern_types Expand file tree Collapse file tree 3 files changed +43
-1
lines changed Original file line number Diff line number Diff 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 number Diff line number Diff line change 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 number Diff line number Diff line change 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`.
You can’t perform that action at this time.
0 commit comments