]> git.proxmox.com Git - rustc.git/blame - src/test/run-pass/issue-4252.rs
New upstream version 1.19.0+dfsg1
[rustc.git] / src / test / run-pass / issue-4252.rs
CommitLineData
1a4d82fc 1// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
223e47cc
LB
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
223e47cc 11trait X {
85aaf69f
SL
12 fn call<T: std::fmt::Debug>(&self, x: &T);
13 fn default_method<T: std::fmt::Debug>(&self, x: &T) {
1a4d82fc
JJ
14 println!("X::default_method {:?}", x);
15 }
223e47cc
LB
16}
17
85aaf69f 18#[derive(Debug)]
c34b1796 19struct Y(isize);
223e47cc 20
85aaf69f 21#[derive(Debug)]
c34b1796 22struct Z<T: X+std::fmt::Debug> {
223e47cc
LB
23 x: T
24}
25
26impl X for Y {
85aaf69f 27 fn call<T: std::fmt::Debug>(&self, x: &T) {
1a4d82fc 28 println!("X::call {:?} {:?}", self, x);
223e47cc
LB
29 }
30}
31
85aaf69f 32impl<T: X + std::fmt::Debug> Drop for Z<T> {
1a4d82fc
JJ
33 fn drop(&mut self) {
34 // These statements used to cause an ICE.
35 self.x.call(self);
36 self.x.default_method(self);
223e47cc
LB
37 }
38}
39
1a4d82fc
JJ
40pub fn main() {
41 let _z = Z {x: Y(42)};
42}