Skip to content

Commit 5e07662

Browse files
committed
Add ui test with denied elided lifetime
1 parent 753f42a commit 5e07662

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

tests/ui/deny_elided_lifetimes.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#![deny(elided_lifetimes_in_paths)]
2+
3+
#[cxx::bridge]
4+
mod ffi {
5+
#[derive(PartialEq, PartialOrd, Hash)]
6+
struct Struct<'a> {
7+
reference: &'a i32,
8+
}
9+
10+
extern "Rust" {
11+
type Rust<'a>;
12+
}
13+
14+
unsafe extern "C++" {
15+
type Cpp<'a>;
16+
17+
fn lifetime_named<'a>(s: &'a i32) -> UniquePtr<Cpp<'a>>;
18+
19+
fn lifetime_underscore(s: &i32) -> UniquePtr<Cpp<'_>>;
20+
21+
fn lifetime_elided(s: &i32) -> UniquePtr<Cpp>;
22+
}
23+
}
24+
25+
pub struct Rust<'a>(&'a i32);
26+
27+
fn main() {}

tests/ui/deny_elided_lifetimes.stderr

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error: hidden lifetime parameters in types are deprecated
2+
--> tests/ui/deny_elided_lifetimes.rs:21:50
3+
|
4+
21 | fn lifetime_elided(s: &i32) -> UniquePtr<Cpp>;
5+
| ^^^ expected named lifetime parameter
6+
|
7+
note: the lint level is defined here
8+
--> tests/ui/deny_elided_lifetimes.rs:1:9
9+
|
10+
1 | #![deny(elided_lifetimes_in_paths)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
12+
help: consider using the `'_` lifetime
13+
|
14+
21 | fn lifetime_elided(s: &i32) -> UniquePtr<Cpp<'_>>;
15+
| ~~~~~~~

0 commit comments

Comments
 (0)