Skip to content

Commit

Permalink
Register hidden types when equating function definitions in coercion
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Apr 11, 2024
1 parent d3350e8 commit be168c7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 23 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/coercion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1145,7 +1145,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// are the same function and their parameters have a LUB.
match self.commit_if_ok(|_| {
self.at(cause, self.param_env).lub(
DefineOpaqueTypes::No,
DefineOpaqueTypes::Yes,
prev_ty,
new_ty,
)
Expand Down
4 changes: 3 additions & 1 deletion tests/ui/fn/fn_def_opaque_coercion.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//! Test that coercing between function items of the same function,
//! but with different args works.
//@check-pass

#![feature(type_alias_impl_trait)]

fn foo<T>(t: T) -> T {
Expand Down Expand Up @@ -44,7 +46,7 @@ type J = impl Sized;
fn j(a: J) {
let x = match true {
true => foo::<J>,
false => foo::<()>, //~ ERROR: incompatible types
false => foo::<()>,
};
x(a);
x(());
Expand Down
21 changes: 0 additions & 21 deletions tests/ui/fn/fn_def_opaque_coercion.stderr

This file was deleted.

0 comments on commit be168c7

Please sign in to comment.