File: hir-lifetimes.pp

package info (click to toggle)
rustc 1.90.0%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid
  • size: 925,928 kB
  • sloc: xml: 158,148; javascript: 19,781; sh: 19,174; python: 15,732; ansic: 13,096; cpp: 7,181; asm: 4,376; makefile: 697; lisp: 176; sql: 15
file content (96 lines) | stat: -rw-r--r-- 1,859 bytes parent folder | download | duplicates (2)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//@ pretty-compare-only
//@ pretty-mode:hir
//@ pp-exact:hir-lifetimes.pp

// This tests the pretty-printing of lifetimes in lots of ways.

#![allow(unused)]
#[attr = MacroUse {arguments: UseAll}]
extern crate std;
#[prelude_import]
use ::std::prelude::rust_2015::*;

struct Foo<'a> {
    x: &'a u32,
}

impl <'a> Foo<'a> {
    fn f<'b>(x: &'b u32) { }
}

impl  Foo<'_> {
    fn a(x: &'_ u32) { }

    fn b(x: &'_ u32) { }

    fn c(x: &'_ u32, y: &'static u32) { }

    // FIXME: `'a` before `self` is omitted
    fn d<'a>(&self, x: &'a u32) { }

    // FIXME: impl Traits printed as just `/*impl Trait*/`, ugh
    fn iter1<'a>(&self)
        -> /*impl Trait*/ { #[lang = "Range"] { start: 0, end: 1 } }

    fn iter2(&self)
        -> /*impl Trait*/ { #[lang = "Range"] { start: 0, end: 1 } }
}

fn a(x: Foo<'_>) { }

fn b<'a>(x: Foo<'a>) { }

struct Bar<'a, 'b, 'c, T> {
    x: &'a u32,
    y: &'b &'c u32,
    z: T,
}

fn f1<'a, 'b, T>(x: Bar<'a, 'b, '_, T>) { }

fn f2(x: Bar<'_, '_, '_, u32>) { }

trait MyTrait<'a, 'b> {
    fn f(&self, x: Foo<'a>, y: Foo<'b>);
}

impl <'a, 'b, 'c, T> MyTrait<'a, 'b> for Bar<'a, 'b, 'c, T> {
    fn f(&self, x: Foo<'a>, y: Foo<'b>) { }
}

fn g(x: &'_ dyn for<'a, 'b> MyTrait<'a, 'b>) { }

trait Blah { }

type T<'a> = dyn Blah + 'a;

type Q<'a> = dyn MyTrait<'a, 'a> + 'a;

fn h<'b, F>(f: F, y: Foo<'b>) where F: for<'d> MyTrait<'d, 'b> { }

// FIXME(?): attr printing is weird
#[attr = Repr {reprs: [ReprC]}]
struct S<'a>(&'a u32);

extern "C" {
    unsafe fn g1(s: S<'_>);
    unsafe fn g2(s: S<'_>);
    unsafe fn g3<'a>(s: S<'a>);
}

struct St<'a> {
    x: &'a u32,
}

fn f() { { let _ = St { x: &0 }; }; { let _ = St { x: &0 }; }; }

struct Name<'a>(&'a str);

const A: Name<'_> = Name("a");
const B: &'_ str = "";
static C: &'_ str = "";
static D: &'static str = "";

fn tr(_: Box<dyn Blah>) { }

fn main() { }