about summary refs log tree commit diff
path: root/tests/ui/lifetimes/mismatched-lifetime-syntaxes-details/static.rs
blob: c41cf44e1c5ffbf895b9488bc4d22f22ab92a267 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#![deny(mismatched_lifetime_syntaxes)]

use std::borrow::Cow;

const A: &[u8] = &[];
static B: &str = "hello";

trait Trait {
    const C: &u8 = &0;
}

impl Trait for () {
    const C: &u8 = &1;
}

fn ampersand(x: &'static u8) -> &u8 {
    //~^ ERROR eliding a lifetime that's named elsewhere is confusing
    x
}

struct Brackets<'a>(&'a u8);

fn brackets(x: &'static u8) -> Brackets {
    //~^ ERROR hiding a lifetime that's named elsewhere is confusing
    Brackets(x)
}

struct Comma<'a, T>(&'a T);

fn comma(x: &'static u8) -> Comma<u8> {
    //~^ ERROR hiding a lifetime that's named elsewhere is confusing
    Comma(x)
}

fn underscore(x: &'static u8) -> &'_ u8 {
    //~^ ERROR eliding a lifetime that's named elsewhere is confusing
    x
}

const NESTED: &Vec<&Box<Cow<str>>> = &vec![];

fn main() {
    const HELLO: &str = "Hello";
    static WORLD: &str = "world";
    println!("{HELLO}, {WORLD}!")
}