Skip to content

Commit 1d32b20

Browse files
committed
Add unit test for issue 78174
1 parent 4acef9a commit 1d32b20

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// run-pass
2+
3+
#![allow(incomplete_features)]
4+
#![feature(const_mut_refs)]
5+
#![feature(inline_const)]
6+
7+
use std::marker::PhantomData;
8+
9+
// rust-lang/rust#78174: ICE: "cannot convert ReErased to a region vid"
10+
fn issue_78174() {
11+
let foo = const { "foo" };
12+
assert_eq!(foo, "foo");
13+
}
14+
15+
pub struct InvariantRef<'a, T: ?Sized>(&'a T, PhantomData<&'a mut &'a T>);
16+
17+
impl<'a, T: ?Sized> InvariantRef<'a, T> {
18+
pub const fn new(r: &'a T) -> Self {
19+
InvariantRef(r, PhantomData)
20+
}
21+
}
22+
23+
fn get_invariant_ref<'a>() -> InvariantRef<'a, ()> {
24+
const { InvariantRef::<'a, ()>::new(&()) }
25+
}
26+
27+
fn get_invariant_ref2<'a>() -> InvariantRef<'a, ()> {
28+
// Try some type inference
29+
const { InvariantRef::new(&()) }
30+
}
31+
32+
fn main() {
33+
issue_78174();
34+
get_invariant_ref();
35+
get_invariant_ref2();
36+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// run-pass
2+
3+
#![allow(incomplete_features)]
4+
#![feature(const_mut_refs)]
5+
#![feature(inline_const)]
6+
7+
use std::marker::PhantomData;
8+
9+
// rust-lang/rust#78174: ICE: "cannot convert ReErased to a region vid"
10+
fn issue_78174() {
11+
match "foo" {
12+
const { concat!("fo", "o") } => (),
13+
_ => unreachable!(),
14+
}
15+
}
16+
17+
#[derive(PartialEq, Eq)]
18+
pub struct InvariantRef<'a, T: ?Sized>(&'a T, PhantomData<&'a mut &'a T>);
19+
20+
impl<'a, T: ?Sized> InvariantRef<'a, T> {
21+
pub const fn new(r: &'a T) -> Self {
22+
InvariantRef(r, PhantomData)
23+
}
24+
}
25+
26+
fn match_invariant_ref<'a>() {
27+
match const { InvariantRef::<'a, _>::new(&()) } {
28+
const { InvariantRef::<'a, ()>::new(&()) } => {
29+
}
30+
}
31+
}
32+
33+
fn main() {
34+
issue_78174();
35+
match_invariant_ref();
36+
}

0 commit comments

Comments
 (0)