mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 14:01:51 +00:00
Register hidden types when equating function definitions in coercion
This commit is contained in:
parent
ca4a18fafc
commit
5c55d6a128
@ -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,
|
||||
)
|
||||
|
@ -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)]
|
||||
|
||||
@ -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(());
|
||||
@ -59,7 +61,7 @@ fn k() -> impl Sized {
|
||||
let f = foo;
|
||||
bind(k(), f)
|
||||
}
|
||||
false => foo::<()>, //~ ERROR: incompatible types
|
||||
false => foo::<()>,
|
||||
};
|
||||
todo!()
|
||||
}
|
||||
|
@ -1,42 +0,0 @@
|
||||
error[E0308]: `match` arms have incompatible types
|
||||
--> $DIR/fn_def_opaque_coercion.rs:47:18
|
||||
|
|
||||
LL | type J = impl Sized;
|
||||
| ---------- the expected opaque type
|
||||
...
|
||||
LL | let x = match true {
|
||||
| _____________-
|
||||
LL | | true => foo::<J>,
|
||||
| | -------- this is found to be of type `fn(J) -> J {foo::<J>}`
|
||||
LL | | false => foo::<()>,
|
||||
| | ^^^^^^^^^ expected opaque type, found `()`
|
||||
LL | | };
|
||||
| |_____- `match` arms have incompatible types
|
||||
|
|
||||
= note: expected fn item `fn(J) -> J {foo::<J>}`
|
||||
found fn item `fn(()) {foo::<()>}`
|
||||
|
||||
error[E0308]: `match` arms have incompatible types
|
||||
--> $DIR/fn_def_opaque_coercion.rs:62:18
|
||||
|
|
||||
LL | fn k() -> impl Sized {
|
||||
| ---------- the expected opaque type
|
||||
...
|
||||
LL | let x = match true {
|
||||
| _____________-
|
||||
LL | | true => {
|
||||
LL | | let f = foo;
|
||||
LL | | bind(k(), f)
|
||||
| | ------------ this is found to be of type `fn(impl Sized) -> impl Sized {foo::<impl Sized>}`
|
||||
LL | | }
|
||||
LL | | false => foo::<()>,
|
||||
| | ^^^^^^^^^ expected opaque type, found `()`
|
||||
LL | | };
|
||||
| |_____- `match` arms have incompatible types
|
||||
|
|
||||
= note: expected fn item `fn(impl Sized) -> impl Sized {foo::<impl Sized>}`
|
||||
found fn item `fn(()) {foo::<()>}`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
Loading…
Reference in New Issue
Block a user