syntax: make deriving have slightly less cryptic error messages.
This unfortunately changes an error like
error: mismatched types: expected `&&NotClone` but found `&NotClone`
into
error: type `NotClone` does not implement any method in scope named `clone`
This commit is contained in:
@@ -78,14 +78,10 @@ fn cs_op(less: bool, equal: bool, cx: &ExtCtxt, span: Span, substr: &Substructur
|
||||
_ => 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)
|
||||
|
||||
@@ -1009,7 +1009,8 @@ impl<'a> TraitDef<'a> {
|
||||
};
|
||||
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);
|
||||
@@ -1053,7 +1054,8 @@ impl<'a> TraitDef<'a> {
|
||||
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);
|
||||
@@ -1128,7 +1130,7 @@ pub fn cs_same_method(f: |&ExtCtxt, Span, ~[@Expr]| -> @Expr,
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user