mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
User type annotations for free consts in pattern position
This commit is contained in:
@@ -553,8 +553,7 @@ fn lower_path(&mut self, qpath: &hir::QPath<'_>, id: hir::HirId, span: Span) ->
|
||||
let res = self.typeck_results.qpath_res(qpath, id);
|
||||
|
||||
let (def_id, user_ty) = match res {
|
||||
Res::Def(DefKind::Const, def_id) => (def_id, None),
|
||||
Res::Def(DefKind::AssocConst, def_id) => {
|
||||
Res::Def(DefKind::Const, def_id) | Res::Def(DefKind::AssocConst, def_id) => {
|
||||
(def_id, self.typeck_results.user_provided_types().get(id))
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
#![feature(generic_const_items)]
|
||||
#![expect(incomplete_features)]
|
||||
|
||||
const FOO<'a: 'static>: usize = 10;
|
||||
|
||||
fn bar<'a>() {
|
||||
match 10_usize {
|
||||
FOO::<'a> => todo!(),
|
||||
//~^ ERROR: lifetime may not live long enough
|
||||
_ => todo!(),
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,11 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/user_type_annotations_pattern.rs:8:9
|
||||
|
|
||||
LL | fn bar<'a>() {
|
||||
| -- lifetime `'a` defined here
|
||||
LL | match 10_usize {
|
||||
LL | FOO::<'a> => todo!(),
|
||||
| ^^^^^^^^^ requires that `'a` must outlive `'static`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
Reference in New Issue
Block a user