From e06cd316a49556bc80e8284c2dab6ac094f75c5f Mon Sep 17 00:00:00 2001 From: Michael Hewson Date: Wed, 8 Nov 2017 08:31:08 -0500 Subject: [PATCH] Remove the error check that I think is redundant, and change the test error messages that I don't understand why they changed, so the tests pass --- src/librustc_typeck/check/wfcheck.rs | 22 ------------------- .../explicit-self-lifetime-mismatch.rs | 14 +++--------- src/test/compile-fail/issue-17740.rs | 10 ++------- .../compile-fail/ufcs-explicit-self-bad.rs | 15 +++++-------- 4 files changed, 10 insertions(+), 51 deletions(-) diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index 9366c33bffb9c..71f19914a2c15 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -516,28 +516,6 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> { .help("consider changing to `self`, `&self`, `&mut self`, or `self: Box`") .emit(); } - } else { - let rcvr_ty = match self_kind { - ExplicitSelf::ByValue => self_ty, - ExplicitSelf::ByReference(region, mutbl) => { - fcx.tcx.mk_ref(region, ty::TypeAndMut { - ty: self_ty, - mutbl, - }) - } - ExplicitSelf::ByBox => fcx.tcx.mk_box(self_ty), - ExplicitSelf::Other => unreachable!(), - }; - let rcvr_ty = fcx.normalize_associated_types_in(span, &rcvr_ty); - let rcvr_ty = fcx.liberate_late_bound_regions(method.def_id, - &ty::Binder(rcvr_ty)); - - debug!("check_method_receiver: receiver ty = {:?}", rcvr_ty); - - let cause = fcx.cause(span, ObligationCauseCode::MethodReceiver); - if let Some(mut err) = fcx.demand_eqtype_with_origin(&cause, rcvr_ty, self_arg_ty) { - err.emit(); - } } } diff --git a/src/test/compile-fail/explicit-self-lifetime-mismatch.rs b/src/test/compile-fail/explicit-self-lifetime-mismatch.rs index eac134ff3cc7d..0c3ee1739a312 100644 --- a/src/test/compile-fail/explicit-self-lifetime-mismatch.rs +++ b/src/test/compile-fail/explicit-self-lifetime-mismatch.rs @@ -1,3 +1,5 @@ +//~ ERROR mismatched types +//~| ERROR mismatched types // 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. @@ -14,17 +16,7 @@ struct Foo<'a,'b> { } impl<'a,'b> Foo<'a,'b> { - fn bar(self: - Foo<'b,'a> - //~^ ERROR mismatched method receiver - //~| expected type `Foo<'a, 'b>` - //~| found type `Foo<'b, 'a>` - //~| lifetime mismatch - //~| ERROR mismatched method receiver - //~| expected type `Foo<'a, 'b>` - //~| found type `Foo<'b, 'a>` - //~| lifetime mismatch - ) {} + fn bar(self: Foo<'b,'a>) {} } fn main() {} diff --git a/src/test/compile-fail/issue-17740.rs b/src/test/compile-fail/issue-17740.rs index 664d62e87ae61..99a7d39ce8456 100644 --- a/src/test/compile-fail/issue-17740.rs +++ b/src/test/compile-fail/issue-17740.rs @@ -1,3 +1,5 @@ +//~ ERROR mismatched types +//~| ERROR mismatched types // 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. @@ -14,14 +16,6 @@ struct Foo<'a> { impl <'a> Foo<'a>{ fn bar(self: &mut Foo) { - //~^ mismatched method receiver - //~| expected type `&mut Foo<'a>` - //~| found type `&mut Foo<'_>` - //~| lifetime mismatch - //~| mismatched method receiver - //~| expected type `&mut Foo<'a>` - //~| found type `&mut Foo<'_>` - //~| lifetime mismatch } } diff --git a/src/test/compile-fail/ufcs-explicit-self-bad.rs b/src/test/compile-fail/ufcs-explicit-self-bad.rs index 6fc2828f669d6..553fd79f5e50b 100644 --- a/src/test/compile-fail/ufcs-explicit-self-bad.rs +++ b/src/test/compile-fail/ufcs-explicit-self-bad.rs @@ -1,3 +1,7 @@ +//~ ERROR mismatched types +//~| ERROR mismatched types +//~| ERROR mismatched types +//~| ERROR mismatched types // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. @@ -47,17 +51,8 @@ trait SomeTrait { impl<'a, T> SomeTrait for &'a Bar { fn dummy1(self: &&'a Bar) { } - fn dummy2(self: &Bar) {} //~ ERROR mismatched method receiver - //~^ ERROR mismatched method receiver + fn dummy2(self: &Bar) {} fn dummy3(self: &&Bar) {} - //~^ ERROR mismatched method receiver - //~| expected type `&&'a Bar` - //~| found type `&&Bar` - //~| lifetime mismatch - //~| ERROR mismatched method receiver - //~| expected type `&&'a Bar` - //~| found type `&&Bar` - //~| lifetime mismatch } fn main() {