Skip to content

Commit de09c43

Browse files
authored
Unrolled build for rust-lang#140548
Rollup merge of rust-lang#140548 - BoxyUwU:gci_patterns_user_ty_annotation, r=compiler-errors Emit user type annotations for free consts in pattern position This previously wasnt done because free consts couldn't have any generic parameters that need to be preserved for borrowck. This is no longer the case with `feature(generic_const_items)` r? fmease
2 parents 2ad5f86 + bfe3d54 commit de09c43

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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 14 additions & 0 deletions
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() {}
Lines changed: 11 additions & 0 deletions
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)