From 9707599714c755c16e0e90b1c91420341704e5fe Mon Sep 17 00:00:00 2001 From: Andrea Nall Date: Tue, 9 Mar 2021 08:30:33 -0600 Subject: [PATCH] add comment for when can be removed --- clippy_utils/src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/clippy_utils/src/lib.rs b/clippy_utils/src/lib.rs index c0722f37f49..44eb37387e7 100644 --- a/clippy_utils/src/lib.rs +++ b/clippy_utils/src/lib.rs @@ -1486,6 +1486,9 @@ pub fn match_function_call<'tcx>( None } +// FIXME: Per https://doc.rust-lang.org/nightly/nightly-rustc/rustc_trait_selection/infer/at/struct.At.html#method.normalize +// this function can be removed once the `normalizie` method does not panic when normalization does +// not succeed /// Checks if `Ty` is normalizable. This function is useful /// to avoid crashes on `layout_of`. pub fn is_normalizable<'tcx>(cx: &LateContext<'tcx>, param_env: ty::ParamEnv<'tcx>, ty: Ty<'tcx>) -> bool { @@ -1501,7 +1504,8 @@ fn is_normalizable_helper<'tcx>( if let Some(&cached_result) = cache.get(ty) { return cached_result; } - cache.insert(ty, false); // prevent recursive loops + // prevent recursive loops, false-negative is better than endless loop leading to stack overflow + cache.insert(ty, false); let result = cx.tcx.infer_ctxt().enter(|infcx| { let cause = rustc_middle::traits::ObligationCause::dummy(); if infcx.at(&cause, param_env).normalize(ty).is_ok() {