Allow coercing functions whose signature differs in opaque types in their defining scope into a shared function pointer type
This commit is contained in:
parent
a18f043033
commit
c24148ef7b
3 changed files with 4 additions and 43 deletions
|
@ -1189,7 +1189,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let sig = self
|
||||
.at(cause, self.param_env)
|
||||
.trace(prev_ty, new_ty)
|
||||
.lub(DefineOpaqueTypes::No, a_sig, b_sig)
|
||||
.lub(DefineOpaqueTypes::Yes, a_sig, b_sig)
|
||||
.map(|ok| self.register_infer_ok_obligations(ok))?;
|
||||
|
||||
// Reify both sides and return the reified fn pointer type.
|
||||
|
|
|
@ -34,7 +34,7 @@ type J = impl Sized;
|
|||
fn j(a: J) {
|
||||
let x = match true {
|
||||
true => bar::<J>,
|
||||
false => foo::<()>, //~ ERROR: incompatible types
|
||||
false => foo::<()>,
|
||||
};
|
||||
x(a);
|
||||
x(());
|
||||
|
@ -49,7 +49,7 @@ fn k() -> impl Sized {
|
|||
let f = foo;
|
||||
bind(k(), f)
|
||||
}
|
||||
false => bar::<()>, //~ ERROR: incompatible types
|
||||
false => bar::<()>,
|
||||
};
|
||||
todo!()
|
||||
}
|
||||
|
|
|
@ -33,45 +33,6 @@ help: use parentheses to call this function
|
|||
LL | x = foo::<I>(/* I */);
|
||||
| +++++++++
|
||||
|
||||
error[E0308]: `match` arms have incompatible types
|
||||
--> $DIR/fn_def_opaque_coercion_to_fn_ptr.rs:37:18
|
||||
|
|
||||
LL | type J = impl Sized;
|
||||
| ---------- the expected opaque type
|
||||
...
|
||||
LL | let x = match true {
|
||||
| _____________-
|
||||
LL | | true => bar::<J>,
|
||||
| | -------- this is found to be of type `fn(J) -> J {bar::<J>}`
|
||||
LL | | false => foo::<()>,
|
||||
| | ^^^^^^^^^ expected opaque type, found `()`
|
||||
LL | | };
|
||||
| |_____- `match` arms have incompatible types
|
||||
|
|
||||
= note: expected fn item `fn(J) -> J {bar::<J>}`
|
||||
found fn item `fn(()) {foo::<()>}`
|
||||
|
||||
error[E0308]: `match` arms have incompatible types
|
||||
--> $DIR/fn_def_opaque_coercion_to_fn_ptr.rs:52: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 => bar::<()>,
|
||||
| | ^^^^^^^^^ 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(()) {bar::<()>}`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue