Skip to content

Commit 1e7db2c

Browse files
committed
Add tests for unchecked region constraints for opaque types in dead code
1 parent 6982935 commit 1e7db2c

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

Diff for: tests/ui/borrowck/opaque-types-deadcode.rs

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//@ compile-flags:-Zverbose-internals
2+
3+
#![feature(rustc_attrs)]
4+
#![rustc_hidden_type_of_opaques]
5+
6+
trait CallMeMaybe<'a, 'b> {
7+
fn mk() -> Self;
8+
fn subtype<T>(self, x: &'b T) -> &'a T;
9+
}
10+
11+
struct Foo<'a, 'b: 'a>(&'a (), &'b ());
12+
impl<'a, 'b> CallMeMaybe<'a, 'b> for Foo<'a, 'b> {
13+
fn mk() -> Self {
14+
Foo(&(), &())
15+
}
16+
17+
fn subtype<T>(self, x: &'b T) -> &'a T {
18+
x
19+
}
20+
}
21+
22+
fn good_bye() -> ! {
23+
panic!();
24+
}
25+
26+
fn foo<'a, 'b: 'a>() -> impl CallMeMaybe<'a, 'b> {
27+
//~^ ERROR: Foo<'{erased}, '{erased}>
28+
good_bye();
29+
Foo(&(), &())
30+
}
31+
32+
fn main() {}

Diff for: tests/ui/borrowck/opaque-types-deadcode.stderr

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: Foo<'{erased}, '{erased}>
2+
--> $DIR/opaque-types-deadcode.rs:26:25
3+
|
4+
LL | fn foo<'a, 'b: 'a>() -> impl CallMeMaybe<'a, 'b> {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^
6+
7+
error: aborting due to 1 previous error
8+

0 commit comments

Comments
 (0)