]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/rcvr-borrowed-to-region.rs
Account for --remap-path-prefix in save-analysis
[rust.git] / src / test / run-pass / rcvr-borrowed-to-region.rs
1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 #![allow(unknown_features)]
12 #![feature(box_syntax)]
13
14 trait get {
15     fn get(self) -> isize;
16 }
17
18 // Note: impl on a slice; we're checking that the pointers below
19 // correctly get borrowed to `&`. (similar to impling for `isize`, with
20 // `&self` instead of `self`.)
21 impl<'a> get for &'a isize {
22     fn get(self) -> isize {
23         return *self;
24     }
25 }
26
27 pub fn main() {
28     let x: Box<_> = box 6;
29     let y = x.get();
30     println!("y={}", y);
31     assert_eq!(y, 6);
32
33     let x = &6;
34     let y = x.get();
35     println!("y={}", y);
36     assert_eq!(y, 6);
37 }