Skip to content

Commit 5c55d6a

Browse files
committed
Register hidden types when equating function definitions in coercion
1 parent ca4a18f commit 5c55d6a

File tree

3 files changed

+6
-46
lines changed

3 files changed

+6
-46
lines changed

compiler/rustc_hir_typeck/src/coercion.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11391139
// are the same function and their parameters have a LUB.
11401140
match self.commit_if_ok(|_| {
11411141
self.at(cause, self.param_env).lub(
1142-
DefineOpaqueTypes::No,
1142+
DefineOpaqueTypes::Yes,
11431143
prev_ty,
11441144
new_ty,
11451145
)

tests/ui/fn/fn_def_opaque_coercion.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Test that coercing between function items of the same function,
2-
//! but with different args works.
2+
//! but with different generic args works.
3+
4+
//@check-pass
35

46
#![feature(type_alias_impl_trait)]
57

@@ -44,7 +46,7 @@ type J = impl Sized;
4446
fn j(a: J) {
4547
let x = match true {
4648
true => foo::<J>,
47-
false => foo::<()>, //~ ERROR: incompatible types
49+
false => foo::<()>,
4850
};
4951
x(a);
5052
x(());
@@ -59,7 +61,7 @@ fn k() -> impl Sized {
5961
let f = foo;
6062
bind(k(), f)
6163
}
62-
false => foo::<()>, //~ ERROR: incompatible types
64+
false => foo::<()>,
6365
};
6466
todo!()
6567
}

tests/ui/fn/fn_def_opaque_coercion.stderr

-42
This file was deleted.

0 commit comments

Comments
 (0)