Reuse cached layout from PostAnalysis when possible.

This commit is contained in:
Camille Gillot
2025-08-16 17:39:51 +00:00
parent 090d210037
commit dabbc7fddc
3 changed files with 21 additions and 3 deletions
+18
View File
@@ -66,6 +66,24 @@ fn layout_of<'tcx>(
return tcx.layout_of(typing_env.as_query_input(ty));
}
match typing_env.typing_mode() {
ty::TypingMode::Codegen => {
let with_postanalysis =
ty::TypingEnv::new(typing_env.param_env, ty::TypingMode::PostAnalysis);
let res = tcx.layout_of(with_postanalysis.as_query_input(ty));
match res {
Err(LayoutError::TooGeneric(_)) => {}
_ => return res,
};
}
ty::TypingMode::Coherence
| ty::TypingMode::Analysis { .. }
| ty::TypingMode::Borrowck { .. }
| ty::TypingMode::PostBorrowckAnalysis { .. }
| ty::TypingMode::ErasedNotCoherence(_)
| ty::TypingMode::PostAnalysis => {}
}
let cx = LayoutCx::new(tcx, typing_env);
let layout = layout_of_uncached(&cx, ty)?;
@@ -1,4 +1,4 @@
//~ ERROR overflow evaluating the requirement `&mut Self: DispatchFromDyn<&mut RustaceansAreAwesome>
//~ ERROR queries overflow the depth limit!
//~| HELP consider increasing the recursion limit
//@ build-fail
@@ -1,7 +1,7 @@
error[E0275]: overflow evaluating the requirement `&mut Self: DispatchFromDyn<&mut RustaceansAreAwesome>`
error: queries overflow the depth limit!
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "2"]` attribute to your crate (`zero_overflow`)
= note: query depth increased by 2 when computing layout of `isize`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0275`.