2015-02-17 09:57:15 -06:00
|
|
|
// Copyright 2015 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.
|
|
|
|
|
|
|
|
// Regression test for #22040.
|
|
|
|
|
|
|
|
use std::fmt::Debug;
|
|
|
|
|
|
|
|
trait Expr: Debug + PartialEq {
|
|
|
|
fn print_element_count(&self);
|
|
|
|
}
|
|
|
|
|
|
|
|
//#[derive(PartialEq)]
|
|
|
|
#[derive(Debug)]
|
2015-08-11 13:20:27 -05:00
|
|
|
struct SExpr<'x> {
|
2015-02-17 09:57:15 -06:00
|
|
|
elements: Vec<Box<Expr+ 'x>>,
|
2015-09-24 10:27:29 -05:00
|
|
|
//~^ ERROR E0038
|
2015-02-17 09:57:15 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'x> PartialEq for SExpr<'x> {
|
|
|
|
fn eq(&self, other:&SExpr<'x>) -> bool {
|
|
|
|
println!("L1: {} L2: {}", self.elements.len(), other.elements.len());
|
2015-09-25 18:52:46 -05:00
|
|
|
|
2015-02-17 09:57:15 -06:00
|
|
|
let result = self.elements.len() == other.elements.len();
|
|
|
|
|
|
|
|
println!("Got compare {}", result);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl <'x> SExpr<'x> {
|
|
|
|
fn new() -> SExpr<'x> { return SExpr{elements: Vec::new(),}; }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl <'x> Expr for SExpr<'x> {
|
|
|
|
fn print_element_count(&self) {
|
|
|
|
println!("element count: {}", self.elements.len());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2015-09-24 10:27:29 -05:00
|
|
|
let a: Box<Expr> = Box::new(SExpr::new());
|
|
|
|
let b: Box<Expr> = Box::new(SExpr::new());
|
2015-02-17 09:57:15 -06:00
|
|
|
|
2015-08-11 13:20:27 -05:00
|
|
|
// assert_eq!(a , b);
|
2015-02-17 09:57:15 -06:00
|
|
|
}
|