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:
parent
b0280ac538
commit
cb02a37042
17 changed files with 56 additions and 23 deletions
|
|
@ -0,0 +1,24 @@
|
|||
// 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() {}
|
||||
|
|
@ -20,7 +20,6 @@ struct Error;
|
|||
enum Enum {
|
||||
A {
|
||||
x: Error //~ ERROR
|
||||
//~^ ERROR
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ struct Error;
|
|||
enum Enum {
|
||||
A(
|
||||
Error //~ ERROR
|
||||
//~^ ERROR
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ struct Error;
|
|||
#[deriving(TotalEq)]
|
||||
struct Struct {
|
||||
x: Error //~ ERROR
|
||||
//~^ ERROR
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ struct Error;
|
|||
#[deriving(TotalEq)]
|
||||
struct Struct(
|
||||
Error //~ ERROR
|
||||
//~^ ERROR
|
||||
);
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ struct Error;
|
|||
enum Enum {
|
||||
A {
|
||||
x: Error //~ ERROR
|
||||
//~^ ERROR
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ struct Error;
|
|||
enum Enum {
|
||||
A(
|
||||
Error //~ ERROR
|
||||
//~^ ERROR
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ struct Error;
|
|||
#[deriving(TotalOrd,TotalEq)]
|
||||
struct Struct {
|
||||
x: Error //~ ERROR
|
||||
//~^ ERROR
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ struct Error;
|
|||
#[deriving(TotalOrd,TotalEq)]
|
||||
struct Struct(
|
||||
Error //~ ERROR
|
||||
//~^ ERROR
|
||||
);
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@
|
|||
// 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)]
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
// 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
|
||||
|
|
|
|||
|
|
@ -27,11 +27,19 @@ use std::mem;
|
|||
|
||||
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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue