switch compare_method to new-style trait error reporting
This commit is contained in:
parent
cea88ebb39
commit
b7b2db4da7
8 changed files with 23 additions and 25 deletions
|
@ -324,10 +324,10 @@ pub fn compare_impl_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
debug!("sub_types failed: impl ty {:?}, trait ty {:?}",
|
||||
impl_fty,
|
||||
trait_fty);
|
||||
span_err!(tcx.sess, impl_m_span, E0053,
|
||||
"method `{}` has an incompatible type for trait: {}",
|
||||
trait_m.name,
|
||||
terr);
|
||||
let trace = infer::TypeTrace::types(origin, false, impl_fty, trait_fty);
|
||||
type_err!(infcx, trace, &terr, E0053,
|
||||
"method `{}` has an incompatible type for trait",
|
||||
trait_m.name).emit();
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -437,10 +437,9 @@ pub fn compare_const_impl<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
// Compute skolemized form of impl and trait const tys.
|
||||
let impl_ty = impl_c.ty.subst(tcx, impl_to_skol_substs);
|
||||
let trait_ty = trait_c.ty.subst(tcx, &trait_to_skol_substs);
|
||||
let origin = TypeOrigin::Misc(impl_c_span);
|
||||
|
||||
let err = infcx.commit_if_ok(|_| {
|
||||
let origin = TypeOrigin::Misc(impl_c_span);
|
||||
|
||||
// There is no "body" here, so just pass dummy id.
|
||||
let impl_ty =
|
||||
assoc::normalize_associated_types_in(&infcx,
|
||||
|
@ -473,11 +472,13 @@ pub fn compare_const_impl<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
debug!("checking associated const for compatibility: impl ty {:?}, trait ty {:?}",
|
||||
impl_ty,
|
||||
trait_ty);
|
||||
span_err!(tcx.sess, impl_c_span, E0326,
|
||||
let values = Some(infer::ValuePairs::Types(ExpectedFound {
|
||||
expected: trait_ty,
|
||||
found: impl_ty
|
||||
}));
|
||||
type_err!(infcx, origin, values, terr, E0326,
|
||||
"implemented const `{}` has an incompatible type for \
|
||||
trait: {}",
|
||||
trait_c.name,
|
||||
terr);
|
||||
trait", trait_c.name).emit();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -18,9 +18,8 @@ struct SignedBar;
|
|||
|
||||
impl Foo for SignedBar {
|
||||
const BAR: i32 = -1;
|
||||
//~^ ERROR implemented const `BAR` has an incompatible type for trait
|
||||
//~| expected u32,
|
||||
//~| found i32 [E0326]
|
||||
//~^ ERROR implemented const `BAR` has an incompatible type for trait [E0326]
|
||||
//~| expected u32, found i32
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -16,7 +16,9 @@ struct Baz;
|
|||
|
||||
impl Foo for Baz {
|
||||
fn bar(&mut self, other: &Foo) {}
|
||||
//~^ ERROR method `bar` has an incompatible type for trait: values differ in mutability [E0053]
|
||||
//~^ ERROR method `bar` has an incompatible type for trait
|
||||
//~| expected type `fn(&mut Baz, &mut Foo)`
|
||||
//~| found type `fn(&mut Baz, &Foo)`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -20,8 +20,8 @@ impl<T: fmt::Debug> ops::FnOnce<(),> for Debuger<T> {
|
|||
type Output = ();
|
||||
fn call_once(self, _args: ()) {
|
||||
//~^ ERROR `call_once` has an incompatible type for trait
|
||||
//~| expected "rust-call" fn,
|
||||
//~| found "Rust" fn
|
||||
//~| expected type `extern "rust-call" fn
|
||||
//~| found type `fn
|
||||
println!("{:?}", self.x);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,8 +14,7 @@ impl Iterator for S {
|
|||
type Item = i32;
|
||||
fn next(&mut self) -> Result<i32, i32> { Ok(7) }
|
||||
//~^ ERROR method `next` has an incompatible type for trait
|
||||
//~| expected enum `std::option::Option`
|
||||
//~| found enum `std::result::Result` [E0053]
|
||||
//~| expected enum `std::option::Option`, found enum `std::result::Result`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -30,9 +30,6 @@ fn main() {
|
|||
impl Deref for Thing {
|
||||
//~^ ERROR not all trait items implemented, missing: `Target` [E0046]
|
||||
fn deref(&self) -> i8 { self.0 }
|
||||
//~^ ERROR method `deref` has an incompatible type for trait
|
||||
//~| expected &-ptr
|
||||
//~| found i8 [E0053]
|
||||
}
|
||||
|
||||
let thing = Thing(72);
|
||||
|
|
|
@ -17,8 +17,8 @@ impl Mumbo for usize {
|
|||
// Cannot have a larger effect than the trait:
|
||||
unsafe fn jumbo(&self, x: &usize) { *self + *x; }
|
||||
//~^ ERROR method `jumbo` has an incompatible type for trait
|
||||
//~| expected normal fn,
|
||||
//~| found unsafe fn
|
||||
//~| expected type `fn
|
||||
//~| found type `unsafe fn
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -17,8 +17,8 @@ trait Foo {
|
|||
impl Foo for u32 {
|
||||
fn len(&self) -> u32 { *self }
|
||||
//~^ ERROR method `len` has an incompatible type for trait
|
||||
//~| expected unsafe fn,
|
||||
//~| found normal fn
|
||||
//~| expected type `unsafe fn(&u32) -> u32`
|
||||
//~| found type `fn(&u32) -> u32`
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
|
Loading…
Add table
Reference in a new issue