diff options
| author | Boxy <rust@boxyuwu.dev> | 2025-05-01 13:11:53 +0100 |
|---|---|---|
| committer | Boxy <rust@boxyuwu.dev> | 2025-05-01 13:14:53 +0100 |
| commit | bfe3d54d817cd66e4ab85d94409db8a572fdadd7 (patch) | |
| tree | f2ab03d3aecadc6733cb26d0e792c41fa8d3670d /tests/ui/generic-const-items | |
| parent | 6e23095adf9209614a45f7f75fea36dad7b92afb (diff) | |
| download | rust-bfe3d54d817cd66e4ab85d94409db8a572fdadd7.tar.gz rust-bfe3d54d817cd66e4ab85d94409db8a572fdadd7.zip | |
User type annotations for free consts in pattern position
Diffstat (limited to 'tests/ui/generic-const-items')
| -rw-r--r-- | tests/ui/generic-const-items/user_type_annotations_pattern.rs | 14 | ||||
| -rw-r--r-- | tests/ui/generic-const-items/user_type_annotations_pattern.stderr | 11 |
2 files changed, 25 insertions, 0 deletions
diff --git a/tests/ui/generic-const-items/user_type_annotations_pattern.rs b/tests/ui/generic-const-items/user_type_annotations_pattern.rs new file mode 100644 index 00000000000..aa3846df2bc --- /dev/null +++ b/tests/ui/generic-const-items/user_type_annotations_pattern.rs @@ -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() {} diff --git a/tests/ui/generic-const-items/user_type_annotations_pattern.stderr b/tests/ui/generic-const-items/user_type_annotations_pattern.stderr new file mode 100644 index 00000000000..e15be275d29 --- /dev/null +++ b/tests/ui/generic-const-items/user_type_annotations_pattern.stderr @@ -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 + |
