File: issue-14589.rs

package info (click to toggle)
rustc 1.88.0%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 934,128 kB
  • sloc: xml: 158,127; python: 36,062; javascript: 19,855; sh: 19,700; cpp: 18,947; ansic: 12,993; asm: 4,792; makefile: 690; lisp: 29; perl: 29; ruby: 19; sql: 11
file content (23 lines) | stat: -rw-r--r-- 629 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//@ run-pass
// All 3 expressions should work in that the argument gets
// coerced to a trait object


fn main() {
    send::<Box<dyn Foo>>(Box::new(Output(0)));
    Test::<Box<dyn Foo>>::foo(Box::new(Output(0)));
    Test::<Box<dyn Foo>>::new().send(Box::new(Output(0)));
}

fn send<T>(_: T) {}

struct Test<T> { marker: std::marker::PhantomData<T> }
impl<T> Test<T> {
    fn new() -> Test<T> { Test { marker: ::std::marker::PhantomData } }
    fn foo(_: T) {}
    fn send(&self, _: T) {}
}

trait Foo { fn dummy(&self) { }} //~ WARN method `dummy` is never used
struct Output(#[allow(dead_code)] isize);
impl Foo for Output {}