Skip to content

Commit 585ab91

Browse files
committed
fix rustdoc ICE
1 parent 5dab0c9 commit 585ab91

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

compiler/rustc_lint/src/default_could_be_derived.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,13 @@ fn check_path<'tcx>(
481481
let instance = Instance::try_resolve(cx.tcx, cx.typing_env(), default_fn_def_id, args);
482482

483483
let Ok(Some(instance)) = instance else { return false };
484+
if let ty::InstanceKind::Item(def) = instance.def
485+
&& !cx.tcx.is_mir_available(def)
486+
{
487+
// Avoid ICE while running rustdoc for not providing `optimized_mir` query.
488+
return false;
489+
}
490+
484491
// Get the MIR Body for the `<FieldTy as Default>::default()` function.
485492
// If it is a value or call (either fn or ctor), we compare its DefId against the one for the
486493
// resolution of the expression we had in the path. This lets us identify, for example, that

0 commit comments

Comments
 (0)