diff options
| author | Andrea Nall <anall@andreanall.com> | 2021-03-09 08:30:33 -0600 |
|---|---|---|
| committer | Andrea Nall <anall@andreanall.com> | 2021-03-09 08:30:33 -0600 |
| commit | 9707599714c755c16e0e90b1c91420341704e5fe (patch) | |
| tree | 912f62b5bc704f70a080a08f3880cf682db5de3e | |
| parent | e812a8abdebd6e4d03aad84b4f7d671a0cb49fdf (diff) | |
| download | rust-9707599714c755c16e0e90b1c91420341704e5fe.tar.gz rust-9707599714c755c16e0e90b1c91420341704e5fe.zip | |
add comment for when can be removed
| -rw-r--r-- | clippy_utils/src/lib.rs | 6 |
1 files changed, 5 insertions, 1 deletions
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() { |
