]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/issue-4252.rs
Rollup merge of #53545 - FelixMcFelix:fix-50865-beta, r=petrochenkov
[rust.git] / src / test / run-pass / issue-4252.rs
1 // Copyright 2013-2014 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 trait X {
12     fn call<T: std::fmt::Debug>(&self, x: &T);
13     fn default_method<T: std::fmt::Debug>(&self, x: &T) {
14         println!("X::default_method {:?}", x);
15     }
16 }
17
18 #[derive(Debug)]
19 struct Y(isize);
20
21 #[derive(Debug)]
22 struct Z<T: X+std::fmt::Debug> {
23     x: T
24 }
25
26 impl X for Y {
27     fn call<T: std::fmt::Debug>(&self, x: &T) {
28         println!("X::call {:?} {:?}", self, x);
29     }
30 }
31
32 impl<T: X + std::fmt::Debug> Drop for Z<T> {
33     fn drop(&mut self) {
34         // These statements used to cause an ICE.
35         self.x.call(self);
36         self.x.default_method(self);
37     }
38 }
39
40 pub fn main() {
41     let _z = Z {x: Y(42)};
42 }