Skip to content

Commit bfe3d54

Browse files
committed
User type annotations for free consts in pattern position
1 parent 6e23095 commit bfe3d54

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

compiler/rustc_mir_build/src/thir/pattern/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -553,8 +553,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
553553
let res = self.typeck_results.qpath_res(qpath, id);
554554

555555
let (def_id, user_ty) = match res {
556-
Res::Def(DefKind::Const, def_id) => (def_id, None),
557-
Res::Def(DefKind::AssocConst, def_id) => {
556+
Res::Def(DefKind::Const, def_id) | Res::Def(DefKind::AssocConst, def_id) => {
558557
(def_id, self.typeck_results.user_provided_types().get(id))
559558
}
560559

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#![feature(generic_const_items)]
2+
#![expect(incomplete_features)]
3+
4+
const FOO<'a: 'static>: usize = 10;
5+
6+
fn bar<'a>() {
7+
match 10_usize {
8+
FOO::<'a> => todo!(),
9+
//~^ ERROR: lifetime may not live long enough
10+
_ => todo!(),
11+
}
12+
}
13+
14+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error: lifetime may not live long enough
2+
--> $DIR/user_type_annotations_pattern.rs:8:9
3+
|
4+
LL | fn bar<'a>() {
5+
| -- lifetime `'a` defined here
6+
LL | match 10_usize {
7+
LL | FOO::<'a> => todo!(),
8+
| ^^^^^^^^^ requires that `'a` must outlive `'static`
9+
10+
error: aborting due to 1 previous error
11+

0 commit comments

Comments
 (0)