Skip to content

Commit 4ae75cf

Browse files
authored
Rollup merge of rust-lang#91430 - jyn514:normalize-fallible, r=jackh726
Add tests for `normalize-docs` overflow errors `@b-naber` do you understand why using `try_normalize_erasing_regions` doesn't silence these cycle errors? Rustdoc isn't emitting them, rustc is aborting before returning an error, even though the function has `try_` in the name. cc rust-lang#82692, rust-lang#91255
2 parents 4a6e8a9 + 18ddf8d commit 4ae75cf

File tree

4 files changed

+51
-13
lines changed

4 files changed

+51
-13
lines changed

src/librustdoc/clean/mod.rs

+3-13
Original file line numberDiff line numberDiff line change
@@ -1337,25 +1337,15 @@ fn normalize(cx: &mut DocContext<'tcx>, ty: Ty<'_>) -> Option<Ty<'tcx>> {
13371337
return None;
13381338
}
13391339

1340-
use crate::rustc_trait_selection::infer::TyCtxtInferExt;
1341-
use crate::rustc_trait_selection::traits::query::normalize::AtExt;
1342-
use rustc_middle::traits::ObligationCause;
1343-
13441340
// Try to normalize `<X as Y>::T` to a type
13451341
let lifted = ty.lift_to_tcx(cx.tcx).unwrap();
1346-
let normalized = cx.tcx.infer_ctxt().enter(|infcx| {
1347-
infcx
1348-
.at(&ObligationCause::dummy(), cx.param_env)
1349-
.normalize(lifted)
1350-
.map(|resolved| infcx.resolve_vars_if_possible(resolved.value))
1351-
});
1352-
match normalized {
1342+
match cx.tcx.try_normalize_erasing_regions(cx.param_env, lifted) {
13531343
Ok(normalized_value) => {
1354-
debug!("normalized {:?} to {:?}", ty, normalized_value);
1344+
trace!("normalized {:?} to {:?}", ty, normalized_value);
13551345
Some(normalized_value)
13561346
}
13571347
Err(err) => {
1358-
debug!("failed to normalize {:?}: {:?}", ty, err);
1348+
info!("failed to normalize {:?}: {:?}", ty, err);
13591349
None
13601350
}
13611351
}
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
pub struct B0;
2+
pub struct B1;
3+
use std::ops::Shl;
4+
use std::ops::Sub;
5+
pub type Shleft<A, B> = <A as Shl<B>>::Output;
6+
pub type Sub1<A> = <A as Sub<B1>>::Output;
7+
pub struct UInt<U, B> {
8+
pub(crate) msb: U,
9+
pub(crate) lsb: B,
10+
}
11+
impl<U, B, Ur, Br> Shl<UInt<Ur, Br>> for UInt<U, B>
12+
where
13+
UInt<Ur, Br>: Sub<B1>,
14+
UInt<UInt<U, B>, B0>: Shl<Sub1<UInt<Ur, Br>>>,
15+
{
16+
type Output = Shleft<UInt<UInt<U, B>, B0>, Sub1<UInt<Ur, Br>>>;
17+
fn shl(self, rhs: UInt<Ur, Br>) -> Self::Output {
18+
unimplemented!()
19+
}
20+
}
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// check-pass
2+
// Regresion test for <https://github.com/rust-lang/rust/issues/79459>.
3+
pub trait Query {}
4+
5+
pub trait AsQuery {
6+
type Query;
7+
}
8+
9+
impl<T: Query> AsQuery for T {
10+
type Query = T;
11+
}
12+
13+
pub trait SelectDsl<Selection> {
14+
type Output;
15+
}
16+
17+
impl<T, Selection> SelectDsl<Selection> for T
18+
where
19+
T: AsQuery,
20+
T::Query: SelectDsl<Selection>,
21+
{
22+
type Output = <T::Query as SelectDsl<Selection>>::Output;
23+
}
24+
25+
pub type Select<Source, Selection> = <Source as SelectDsl<Selection>>::Output;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// aux-crate:overflow=overflow.rs
2+
// check-pass
3+
// Regression test for <https://github.com/rust-lang/rust/issues/79506>.

0 commit comments

Comments
 (0)