Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
tiif committed Aug 4, 2024
1 parent 58fb508 commit f7e629f
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/ui/consts/ice-issue-125873.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Test for ICE: cannot convert ReLateParam to a region vid
// https://github.com/rust-lang/rust/issues/125873

fn foo() {
let a = for<'a> |b: &'a ()| -> &'a () {
//~^ `for<...>` binders for closures are experimental
const {
let awd = ();
let _: &'a () = &awd;
//~^ `awd` does not live long enough
};
b
};
}

fn main() {}
31 changes: 31 additions & 0 deletions tests/ui/consts/ice-issue-125873.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
error[E0658]: `for<...>` binders for closures are experimental
--> $DIR/ice-issue-125873.rs:5:13
|
LL | let a = for<'a> |b: &'a ()| -> &'a () {
| ^^^^^^^
|
= note: see issue #97362 <https://github.com/rust-lang/rust/issues/97362> for more information
= help: add `#![feature(closure_lifetime_binder)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
= help: consider removing `for<...>`

error[E0597]: `awd` does not live long enough
--> $DIR/ice-issue-125873.rs:9:29
|
LL | let a = for<'a> |b: &'a ()| -> &'a () {
| -- lifetime `'a` defined here
...
LL | let awd = ();
| --- binding `awd` declared here
LL | let _: &'a () = &awd;
| ------ ^^^^ borrowed value does not live long enough
| |
| type annotation requires that `awd` is borrowed for `'a`
LL |
LL | };
| - `awd` dropped here while still borrowed

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0597, E0658.
For more information about an error, try `rustc --explain E0597`.

0 comments on commit f7e629f

Please sign in to comment.