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