]> git.lizzy.rs Git - rust.git/blob - src/test/ui/rcvr-borrowed-to-region.rs
Rollup merge of #61207 - taiki-e:arbitrary_self_types-lifetime-elision-2, r=Centril
[rust.git] / src / test / ui / rcvr-borrowed-to-region.rs
1 // run-pass
2
3 #![allow(non_camel_case_types)]
4 #![feature(box_syntax)]
5
6 trait get {
7     fn get(self) -> isize;
8 }
9
10 // Note: impl on a slice; we're checking that the pointers below
11 // correctly get borrowed to `&`. (similar to impling for `isize`, with
12 // `&self` instead of `self`.)
13 impl<'a> get for &'a isize {
14     fn get(self) -> isize {
15         return *self;
16     }
17 }
18
19 pub fn main() {
20     let x: Box<_> = box 6;
21     let y = x.get();
22     println!("y={}", y);
23     assert_eq!(y, 6);
24
25     let x = &6;
26     let y = x.get();
27     println!("y={}", y);
28     assert_eq!(y, 6);
29 }