Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4abbda6

Browse files
committedApr 12, 2024
Register hidden types when equating function definitions in coercion
1 parent 962323f commit 4abbda6

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
@@ -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

+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)
Failed to load comments.