Skip to content

Commit 9707599

Browse files
committed
add comment for when can be removed
1 parent e812a8a commit 9707599

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

clippy_utils/src/lib.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1486,6 +1486,9 @@ pub fn match_function_call<'tcx>(
14861486
None
14871487
}
14881488

1489+
// FIXME: Per https://doc.rust-lang.org/nightly/nightly-rustc/rustc_trait_selection/infer/at/struct.At.html#method.normalize
1490+
// this function can be removed once the `normalizie` method does not panic when normalization does
1491+
// not succeed
14891492
/// Checks if `Ty` is normalizable. This function is useful
14901493
/// to avoid crashes on `layout_of`.
14911494
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>(
15011504
if let Some(&cached_result) = cache.get(ty) {
15021505
return cached_result;
15031506
}
1504-
cache.insert(ty, false); // prevent recursive loops
1507+
// prevent recursive loops, false-negative is better than endless loop leading to stack overflow
1508+
cache.insert(ty, false);
15051509
let result = cx.tcx.infer_ctxt().enter(|infcx| {
15061510
let cause = rustc_middle::traits::ObligationCause::dummy();
15071511
if infcx.at(&cause, param_env).normalize(ty).is_ok() {

0 commit comments

Comments
 (0)