]> git.proxmox.com Git - rustc.git/blame - src/test/ui/run-pass/autoref-autoderef/autoref-intermediate-types-issue-3585.rs
New upstream version 1.30.0+dfsg1
[rustc.git] / src / test / ui / run-pass / autoref-autoderef / autoref-intermediate-types-issue-3585.rs
CommitLineData
223e47cc
LB
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
b7449926 11// run-pass
1a4d82fc
JJ
12#![feature(box_syntax)]
13
223e47cc 14trait Foo {
1a4d82fc 15 fn foo(&self) -> String;
223e47cc
LB
16}
17
1a4d82fc
JJ
18impl<T:Foo> Foo for Box<T> {
19 fn foo(&self) -> String {
20 format!("box {}", (**self).foo())
223e47cc
LB
21 }
22}
23
c34b1796 24impl Foo for usize {
1a4d82fc
JJ
25 fn foo(&self) -> String {
26 format!("{}", *self)
223e47cc
LB
27 }
28}
29
30pub fn main() {
c34b1796 31 let x: Box<_> = box 3;
1a4d82fc 32 assert_eq!(x.foo(), "box 3".to_string());
223e47cc 33}