Skip to content

Commit be168c7

Browse files
committed
Register hidden types when equating function definitions in coercion
1 parent d3350e8 commit be168c7

File tree

3 files changed

+4
-23
lines changed

3 files changed

+4
-23
lines changed

compiler/rustc_hir_typeck/src/coercion.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11451145
// are the same function and their parameters have a LUB.
11461146
match self.commit_if_ok(|_| {
11471147
self.at(cause, self.param_env).lub(
1148-
DefineOpaqueTypes::No,
1148+
DefineOpaqueTypes::Yes,
11491149
prev_ty,
11501150
new_ty,
11511151
)

tests/ui/fn/fn_def_opaque_coercion.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//! Test that coercing between function items of the same function,
22
//! but with different args works.
33
4+
//@check-pass
5+
46
#![feature(type_alias_impl_trait)]
57

68
fn foo<T>(t: T) -> T {
@@ -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(());

tests/ui/fn/fn_def_opaque_coercion.stderr

-21
This file was deleted.

0 commit comments

Comments
 (0)