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 24, 2024
1 parent d4b9459 commit f4521f7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 46 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 @@ -1139,7 +1139,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
8 changes: 5 additions & 3 deletions tests/ui/fn/fn_def_opaque_coercion.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Test that coercing between function items of the same function,
//! but with different args works.
//! but with different generic args works.
//@check-pass

#![feature(type_alias_impl_trait)]

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 All @@ -59,7 +61,7 @@ fn k() -> impl Sized {
let f = foo;
bind(k(), f)
}
false => foo::<()>, //~ ERROR: incompatible types
false => foo::<()>,
};
todo!()
}
Expand Down
42 changes: 0 additions & 42 deletions tests/ui/fn/fn_def_opaque_coercion.stderr

This file was deleted.

0 comments on commit f4521f7

Please sign in to comment.