Skip to content

Commit 7795f62

Browse files
committed
Add explanation for early abort in TAIT hidden type computation
1 parent 64c5b9a commit 7795f62

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

compiler/rustc_typeck/src/collect/type_of.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,15 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> {
598598
}
599599
// Calling `mir_borrowck` can lead to cycle errors through
600600
// const-checking, avoid calling it if we don't have to.
601+
// ```rust
602+
// type Foo = impl Fn() -> usize; // when computing type for this
603+
// const fn bar() -> Foo {
604+
// || 0usize
605+
// }
606+
// const BAZR: Foo = bar(); // we would mir-borrowck this, causing cycles
607+
// // because we again need to reveal `Foo` so we can check whether the
608+
// // constant does not contain interior mutability.
609+
// ```
601610
if self.tcx.typeck(def_id).concrete_opaque_types.get(&self.def_id).is_none() {
602611
debug!("no constraints in typeck results");
603612
return;

0 commit comments

Comments
 (0)