@@ -156,7 +156,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
156
156
// FIXME: Due to shortcomings in the current type system implementation, only emit this
157
157
// diagnostic if there are no type mismatches in the containing function.
158
158
if self . infer . type_mismatches . iter ( ) . next ( ) . is_some ( ) {
159
- return Some ( ( ) ) ;
159
+ return None ;
160
160
}
161
161
162
162
let is_method_call = matches ! ( expr, Expr :: MethodCall { .. } ) ;
@@ -170,6 +170,14 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
170
170
let mut args = args. clone ( ) ;
171
171
args. insert ( 0 , * receiver) ;
172
172
173
+ let receiver = & self . infer . type_of_expr [ * receiver] ;
174
+ if receiver. strip_references ( ) . is_unknown ( ) {
175
+ // if the receiver is of unknown type, it's very likely we
176
+ // don't know enough to correctly resolve the method call.
177
+ // This is kind of a band-aid for #6975.
178
+ return None ;
179
+ }
180
+
173
181
// FIXME: note that we erase information about substs here. This
174
182
// is not right, but, luckily, doesn't matter as we care only
175
183
// about the number of params
@@ -504,6 +512,22 @@ fn f() {
504
512
) ;
505
513
}
506
514
515
+ #[ test]
516
+ fn method_unknown_receiver ( ) {
517
+ // note: this is incorrect code, so there might be errors on this in the
518
+ // future, but we shouldn't emit an argument count diagnostic here
519
+ check_diagnostics (
520
+ r#"
521
+ trait Foo { fn method(&self, arg: usize) {} }
522
+
523
+ fn f() {
524
+ let x;
525
+ x.method();
526
+ }
527
+ "# ,
528
+ ) ;
529
+ }
530
+
507
531
#[ test]
508
532
fn tuple_struct ( ) {
509
533
check_diagnostics (
0 commit comments