2014-06-03 14:38:00 -05:00
|
|
|
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
|
|
|
// All 3 expressions should work in that the argument gets
|
|
|
|
// coerced to a trait object
|
|
|
|
|
2015-02-15 02:52:21 -06:00
|
|
|
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
|
2015-01-07 19:25:56 -06:00
|
|
|
|
2014-06-03 14:38:00 -05:00
|
|
|
fn main() {
|
2015-02-15 02:52:21 -06:00
|
|
|
send::<Box<Foo>>(Box::new(Output(0)));
|
|
|
|
Test::<Box<Foo>>::foo(Box::new(Output(0)));
|
|
|
|
Test::<Box<Foo>>::new().send(Box::new(Output(0)));
|
2014-06-03 14:38:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn send<T>(_: T) {}
|
|
|
|
|
2015-02-12 09:29:52 -06:00
|
|
|
struct Test<T> { marker: std::marker::PhantomData<T> }
|
2014-06-03 14:38:00 -05:00
|
|
|
impl<T> Test<T> {
|
2015-02-12 09:29:52 -06:00
|
|
|
fn new() -> Test<T> { Test { marker: ::std::marker::PhantomData } }
|
2014-06-03 14:38:00 -05:00
|
|
|
fn foo(_: T) {}
|
|
|
|
fn send(&self, _: T) {}
|
|
|
|
}
|
|
|
|
|
2015-02-12 09:29:52 -06:00
|
|
|
trait Foo { fn dummy(&self) { }}
|
2014-06-03 14:38:00 -05:00
|
|
|
struct Output(int);
|
|
|
|
impl Foo for Output {}
|