Skip to content

Commit a33f6ac

Browse files
committed
Fix ICE on suggesting calling function
1 parent f745834 commit a33f6ac

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

compiler/rustc_typeck/src/check/_match.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
3131
_ => (false, false, false),
3232
};
3333

34-
// Type check the descriminant and get its type.
34+
// Type check the discriminant and get its type.
3535
let scrutinee_ty = if force_scrutinee_bool {
3636
// Here we want to ensure:
3737
//

compiler/rustc_typeck/src/check/op.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
504504
return false;
505505
}
506506
// We're emitting a suggestion, so we can just ignore regions
507-
let fn_sig = self.tcx.fn_sig(def_id).skip_binder();
507+
// FIXME: Instead of exiting early when encountering bound vars in
508+
// the function signature, consider keeping the binder here and
509+
// propagating it downwards.
510+
let fn_sig = if let Some(fn_sig) = self.tcx.fn_sig(def_id).no_bound_vars() {
511+
fn_sig
512+
} else {
513+
return false;
514+
};
508515

509516
let other_ty = if let FnDef(def_id, _) = *other_ty.kind() {
510517
if !self.tcx.has_typeck_results(def_id) {
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
fn foo(s: &i32) -> &i32 {
2+
let xs;
3+
xs
4+
}
5+
fn main() {
6+
let y;
7+
// we shouldn't ice with the bound var here.
8+
assert_eq!(foo, y);
9+
//~^ ERROR binary operation `==` cannot be applied to type
10+
//~| ERROR `for<'r> fn(&'r i32) -> &'r i32 {foo}` doesn't implement `Debug`
11+
}
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
fn foo(s: &i32) -> &i32 {
2+
let xs;
3+
xs
4+
}
5+
fn main() {
6+
let y;
7+
if foo == y {}
8+
//~^ ERROR binary operation `==` cannot be applied to type
9+
}

0 commit comments

Comments
 (0)