From 18ddf8d636289444a3bc0eaffde9e6c24eb621b4 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Wed, 1 Dec 2021 19:00:27 +0000 Subject: [PATCH] Use `try_normalize_erasing_regions` instead of a custom infer context This unfortunately is still giving an unsilenceable overflow error :( --- src/librustdoc/clean/mod.rs | 16 +++------------ src/test/rustdoc-ui/auxiliary/overflow.rs | 20 ++++++++++++++++++ src/test/rustdoc-ui/normalize-cycle.rs | 25 +++++++++++++++++++++++ src/test/rustdoc-ui/normalize-overflow.rs | 3 +++ 4 files changed, 51 insertions(+), 13 deletions(-) create mode 100644 src/test/rustdoc-ui/auxiliary/overflow.rs create mode 100644 src/test/rustdoc-ui/normalize-cycle.rs create mode 100644 src/test/rustdoc-ui/normalize-overflow.rs diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 9b05716a67bc2..e131089f36183 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1337,25 +1337,15 @@ fn normalize(cx: &mut DocContext<'tcx>, ty: Ty<'_>) -> Option> { return None; } - use crate::rustc_trait_selection::infer::TyCtxtInferExt; - use crate::rustc_trait_selection::traits::query::normalize::AtExt; - use rustc_middle::traits::ObligationCause; - // Try to normalize `::T` to a type let lifted = ty.lift_to_tcx(cx.tcx).unwrap(); - let normalized = cx.tcx.infer_ctxt().enter(|infcx| { - infcx - .at(&ObligationCause::dummy(), cx.param_env) - .normalize(lifted) - .map(|resolved| infcx.resolve_vars_if_possible(resolved.value)) - }); - match normalized { + match cx.tcx.try_normalize_erasing_regions(cx.param_env, lifted) { Ok(normalized_value) => { - debug!("normalized {:?} to {:?}", ty, normalized_value); + trace!("normalized {:?} to {:?}", ty, normalized_value); Some(normalized_value) } Err(err) => { - debug!("failed to normalize {:?}: {:?}", ty, err); + info!("failed to normalize {:?}: {:?}", ty, err); None } } diff --git a/src/test/rustdoc-ui/auxiliary/overflow.rs b/src/test/rustdoc-ui/auxiliary/overflow.rs new file mode 100644 index 0000000000000..ff65936bec95e --- /dev/null +++ b/src/test/rustdoc-ui/auxiliary/overflow.rs @@ -0,0 +1,20 @@ +pub struct B0; +pub struct B1; +use std::ops::Shl; +use std::ops::Sub; +pub type Shleft = >::Output; +pub type Sub1 = >::Output; +pub struct UInt { + pub(crate) msb: U, + pub(crate) lsb: B, +} +impl Shl> for UInt +where + UInt: Sub, + UInt, B0>: Shl>>, +{ + type Output = Shleft, B0>, Sub1>>; + fn shl(self, rhs: UInt) -> Self::Output { + unimplemented!() + } +} diff --git a/src/test/rustdoc-ui/normalize-cycle.rs b/src/test/rustdoc-ui/normalize-cycle.rs new file mode 100644 index 0000000000000..f48cad373cded --- /dev/null +++ b/src/test/rustdoc-ui/normalize-cycle.rs @@ -0,0 +1,25 @@ +// check-pass +// Regresion test for . +pub trait Query {} + +pub trait AsQuery { + type Query; +} + +impl AsQuery for T { + type Query = T; +} + +pub trait SelectDsl { + type Output; +} + +impl SelectDsl for T +where + T: AsQuery, + T::Query: SelectDsl, +{ + type Output = >::Output; +} + +pub type Select = >::Output; diff --git a/src/test/rustdoc-ui/normalize-overflow.rs b/src/test/rustdoc-ui/normalize-overflow.rs new file mode 100644 index 0000000000000..0cdcc88e3141f --- /dev/null +++ b/src/test/rustdoc-ui/normalize-overflow.rs @@ -0,0 +1,3 @@ +// aux-crate:overflow=overflow.rs +// check-pass +// Regression test for .