for (trait, supers, errs) in [('Rand', [], 1),
('Clone', [], 1), ('DeepClone', ['Clone'], 1),
('Eq', [], 2), ('Ord', [], 8),
- ('TotalEq', [], 2), ('TotalOrd', ['TotalEq'], 2)]:
+ ('TotalEq', [], 1), ('TotalOrd', ['TotalEq'], 1)]:
traits[trait] = (ALL, supers, errs)
for (trait, (types, super_traits, error_count)) in traits.items():
}
/// Double-ended DList iterator
-#[deriving(Clone)]
pub struct Items<'a, T> {
priv head: &'a Link<T>,
priv tail: Rawlink<Node<T>>,
priv nelem: uint,
}
+// FIXME #11820: the &'a Option<> of the Link stops clone working.
+impl<'a, T> Clone for Items<'a, T> {
+ fn clone(&self) -> Items<'a, T> { *self }
+}
+
/// Double-ended mutable DList iterator
pub struct MutItems<'a, T> {
priv list: &'a mut DList<T>,
type BindingsMap = HashMap<Ident, BindingInfo>;
-#[deriving(Clone)]
struct ArmData<'a,'b> {
bodycx: &'b Block<'b>,
arm: &'a ast::Arm,
bindings_map: @BindingsMap
}
+// FIXME #11820: method resolution is unreliable with &
+impl<'a,'b> Clone for ArmData<'a, 'b> {
+ fn clone(&self) -> ArmData<'a, 'b> { *self }
+}
+
/**
* Info about Match.
* If all `pats` are matched then arm `data` will be executed.
}
return bcx;
}
-
-
_ => cx.span_bug(span, "Not exactly 2 arguments in `deriving(Ord)`")
};
- let cmp = cx.expr_binary(span, op,
- cx.expr_deref(span, self_f),
- cx.expr_deref(span, other_f));
+ let cmp = cx.expr_binary(span, op, self_f, other_f);
let not_cmp = cx.expr_unary(span, ast::UnNot,
- cx.expr_binary(span, op,
- cx.expr_deref(span, other_f),
- cx.expr_deref(span, self_f)));
+ cx.expr_binary(span, op, other_f, self_f));
let and = cx.expr_binary(span, ast::BiAnd, not_cmp, subexpr);
cx.expr_binary(span, ast::BiOr, cmp, and)
};
let path = cx.path_ident(sp, cx.ident_of(format!("{}_{}", prefix, i)));
paths.push(path.clone());
- ident_expr.push((sp, opt_id, cx.expr_path(path)));
+ let val = cx.expr(sp, ast::ExprParen(cx.expr_deref(sp, cx.expr_path(path))));
+ ident_expr.push((sp, opt_id, val));
}
let subpats = self.create_subpatterns(paths, mutbl);
let path = cx.path_ident(sp, cx.ident_of(format!("{}_{}", prefix, i)));
paths.push(path.clone());
- ident_expr.push((sp, None, cx.expr_path(path)));
+ let val = cx.expr(sp, ast::ExprParen(cx.expr_deref(sp, cx.expr_path(path))));
+ ident_expr.push((sp, None, val));
}
let subpats = self.create_subpatterns(paths, mutbl);
cx.expr_method_call(field.span,
field.self_,
substructure.method_ident,
- field.other.clone())
+ field.other.map(|e| cx.expr_addr_of(field.span, *e)))
});
f(cx, trait_span, called)
--- /dev/null
+// 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.
+
+struct NoCloneOrEq;
+
+#[deriving(Eq)]
+struct E {
+ x: NoCloneOrEq //~ ERROR does not implement any method in scope named `eq`
+ //~^ ERROR does not implement any method in scope named `ne`
+}
+#[deriving(Clone)]
+struct C {
+ x: NoCloneOrEq //~ ERROR does not implement any method in scope named `clone`
+}
+
+
+fn main() {}
enum Enum {
A {
x: Error //~ ERROR
-//~^ ERROR
}
}
enum Enum {
A(
Error //~ ERROR
-//~^ ERROR
)
}
#[deriving(TotalEq)]
struct Struct {
x: Error //~ ERROR
-//~^ ERROR
}
fn main() {}
#[deriving(TotalEq)]
struct Struct(
Error //~ ERROR
-//~^ ERROR
);
fn main() {}
enum Enum {
A {
x: Error //~ ERROR
-//~^ ERROR
}
}
enum Enum {
A(
Error //~ ERROR
-//~^ ERROR
)
}
#[deriving(TotalOrd,TotalEq)]
struct Struct {
x: Error //~ ERROR
-//~^ ERROR
}
fn main() {}
#[deriving(TotalOrd,TotalEq)]
struct Struct(
Error //~ ERROR
-//~^ ERROR
);
fn main() {}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+
+// xfail-test FIXME #11820: & is unreliable in deriving
+
use std::cmp::{Less,Equal,Greater};
#[deriving(TotalEq,TotalOrd)]
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+// xfail-test FIXME #11820: & is unreliable in deriving
+
#[deriving(Eq,Ord)]
struct A<'a> {
x: &'a int
type Type<'tcx> = &'tcx TypeStructure<'tcx>;
-#[deriving(Eq)]
enum TypeStructure<'tcx> {
TypeInt,
TypeFunction(Type<'tcx>, Type<'tcx>),
}
+impl<'tcx> Eq for TypeStructure<'tcx> {
+ fn eq(&self, other: &TypeStructure<'tcx>) -> bool {
+ match (*self, *other) {
+ (TypeInt, TypeInt) => true,
+ (TypeFunction(s_a, s_b), TypeFunction(o_a, o_b)) => *s_a == *o_a && *s_b == *o_b,
+ _ => false
+ }
+ }
+}
struct TypeContext<'tcx, 'ast> {
ty_arena: &'tcx Arena,