Skip to content

Commit e06cd31

Browse files
committed
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
1 parent 02ce3ac commit e06cd31

File tree

4 files changed

+10
-51
lines changed

4 files changed

+10
-51
lines changed

src/librustc_typeck/check/wfcheck.rs

-22
Original file line numberDiff line numberDiff line change
@@ -516,28 +516,6 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
516516
.help("consider changing to `self`, `&self`, `&mut self`, or `self: Box<Self>`")
517517
.emit();
518518
}
519-
} else {
520-
let rcvr_ty = match self_kind {
521-
ExplicitSelf::ByValue => self_ty,
522-
ExplicitSelf::ByReference(region, mutbl) => {
523-
fcx.tcx.mk_ref(region, ty::TypeAndMut {
524-
ty: self_ty,
525-
mutbl,
526-
})
527-
}
528-
ExplicitSelf::ByBox => fcx.tcx.mk_box(self_ty),
529-
ExplicitSelf::Other => unreachable!(),
530-
};
531-
let rcvr_ty = fcx.normalize_associated_types_in(span, &rcvr_ty);
532-
let rcvr_ty = fcx.liberate_late_bound_regions(method.def_id,
533-
&ty::Binder(rcvr_ty));
534-
535-
debug!("check_method_receiver: receiver ty = {:?}", rcvr_ty);
536-
537-
let cause = fcx.cause(span, ObligationCauseCode::MethodReceiver);
538-
if let Some(mut err) = fcx.demand_eqtype_with_origin(&cause, rcvr_ty, self_arg_ty) {
539-
err.emit();
540-
}
541519
}
542520
}
543521

Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//~ ERROR mismatched types
2+
//~| ERROR mismatched types
13
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
24
// file at the top-level directory of this distribution and at
35
// http://rust-lang.org/COPYRIGHT.
@@ -14,17 +16,7 @@ struct Foo<'a,'b> {
1416
}
1517

1618
impl<'a,'b> Foo<'a,'b> {
17-
fn bar(self:
18-
Foo<'b,'a>
19-
//~^ ERROR mismatched method receiver
20-
//~| expected type `Foo<'a, 'b>`
21-
//~| found type `Foo<'b, 'a>`
22-
//~| lifetime mismatch
23-
//~| ERROR mismatched method receiver
24-
//~| expected type `Foo<'a, 'b>`
25-
//~| found type `Foo<'b, 'a>`
26-
//~| lifetime mismatch
27-
) {}
19+
fn bar(self: Foo<'b,'a>) {}
2820
}
2921

3022
fn main() {}

src/test/compile-fail/issue-17740.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//~ ERROR mismatched types
2+
//~| ERROR mismatched types
13
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
24
// file at the top-level directory of this distribution and at
35
// http://rust-lang.org/COPYRIGHT.
@@ -14,14 +16,6 @@ struct Foo<'a> {
1416

1517
impl <'a> Foo<'a>{
1618
fn bar(self: &mut Foo) {
17-
//~^ mismatched method receiver
18-
//~| expected type `&mut Foo<'a>`
19-
//~| found type `&mut Foo<'_>`
20-
//~| lifetime mismatch
21-
//~| mismatched method receiver
22-
//~| expected type `&mut Foo<'a>`
23-
//~| found type `&mut Foo<'_>`
24-
//~| lifetime mismatch
2519
}
2620
}
2721

src/test/compile-fail/ufcs-explicit-self-bad.rs

+5-10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//~ ERROR mismatched types
2+
//~| ERROR mismatched types
3+
//~| ERROR mismatched types
4+
//~| ERROR mismatched types
15
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
26
// file at the top-level directory of this distribution and at
37
// http://rust-lang.org/COPYRIGHT.
@@ -47,17 +51,8 @@ trait SomeTrait {
4751

4852
impl<'a, T> SomeTrait for &'a Bar<T> {
4953
fn dummy1(self: &&'a Bar<T>) { }
50-
fn dummy2(self: &Bar<T>) {} //~ ERROR mismatched method receiver
51-
//~^ ERROR mismatched method receiver
54+
fn dummy2(self: &Bar<T>) {}
5255
fn dummy3(self: &&Bar<T>) {}
53-
//~^ ERROR mismatched method receiver
54-
//~| expected type `&&'a Bar<T>`
55-
//~| found type `&&Bar<T>`
56-
//~| lifetime mismatch
57-
//~| ERROR mismatched method receiver
58-
//~| expected type `&&'a Bar<T>`
59-
//~| found type `&&Bar<T>`
60-
//~| lifetime mismatch
6156
}
6257

6358
fn main() {

0 commit comments

Comments
 (0)