normalize closure output before relation
This commit is contained in:
parent
80917360d3
commit
c75e6e0f6c
2 changed files with 50 additions and 15 deletions
|
@ -124,21 +124,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||||
// Return types are a bit more complex. They may contain opaque `impl Trait` types.
|
// Return types are a bit more complex. They may contain opaque `impl Trait` types.
|
||||||
let mir_output_ty = body.local_decls[RETURN_PLACE].ty;
|
let mir_output_ty = body.local_decls[RETURN_PLACE].ty;
|
||||||
let output_span = body.local_decls[RETURN_PLACE].source_info.span;
|
let output_span = body.local_decls[RETURN_PLACE].source_info.span;
|
||||||
if let Err(terr) = self.eq_types(
|
self.equate_normalized_input_or_output(normalized_output_ty, mir_output_ty, output_span);
|
||||||
normalized_output_ty,
|
|
||||||
mir_output_ty,
|
|
||||||
Locations::All(output_span),
|
|
||||||
ConstraintCategory::BoringNoLocation,
|
|
||||||
) {
|
|
||||||
span_mirbug!(
|
|
||||||
self,
|
|
||||||
Location::START,
|
|
||||||
"equate_inputs_and_outputs: `{:?}=={:?}` failed with `{:?}`",
|
|
||||||
normalized_output_ty,
|
|
||||||
mir_output_ty,
|
|
||||||
terr
|
|
||||||
);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[instrument(skip(self), level = "debug")]
|
#[instrument(skip(self), level = "debug")]
|
||||||
|
|
49
tests/ui/nll/issue-112604-closure-output-normalize.rs
Normal file
49
tests/ui/nll/issue-112604-closure-output-normalize.rs
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
//check-pass
|
||||||
|
|
||||||
|
use higher_kinded_types::*;
|
||||||
|
mod higher_kinded_types {
|
||||||
|
pub(crate) trait HKT {
|
||||||
|
type Of<'lt>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) trait WithLifetime<'lt> {
|
||||||
|
type T;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: ?Sized + for<'any> WithLifetime<'any>> HKT for T {
|
||||||
|
type Of<'lt> = <T as WithLifetime<'lt>>::T;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
trait Trait {
|
||||||
|
type Gat<'lt>;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Trait for () {
|
||||||
|
type Gat<'lt> = ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Same as `Trait`, but using HKTs rather than GATs
|
||||||
|
trait HTrait {
|
||||||
|
type Hat: ?Sized + HKT;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: Trait> HTrait for T {
|
||||||
|
type Hat = dyn for<'lt> WithLifetime<'lt, T = T::Gat<'lt>>;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<Hat: ?Sized + HKT> Trait for Box<dyn '_ + HTrait<Hat = Hat>> {
|
||||||
|
type Gat<'lt> = Hat::Of<'lt>;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn existential() -> impl for<'a> Trait<Gat<'a> = ()> {}
|
||||||
|
|
||||||
|
fn dyn_hoops<T: Trait>(
|
||||||
|
_: T,
|
||||||
|
) -> Box<dyn HTrait<Hat = dyn for<'a> WithLifetime<'a, T = T::Gat<'a>>>> {
|
||||||
|
loop {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let _ = || -> _ { dyn_hoops(existential()) };
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue