Skip to content

Commit 7e212c1

Browse files
authored
Rollup merge of #93542 - GuillaumeGomez:lifetime-elision, r=oli-obk
Prevent lifetime elision in type alias Fixes #93401. Apparently, the problem has been fixed in the compiler. r? `@oli-obk`
2 parents b622552 + 2308464 commit 7e212c1

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/librustdoc/clean/mod.rs

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

1430+
use crate::rustc_trait_selection::infer::TyCtxtInferExt;
1431+
use crate::rustc_trait_selection::traits::query::normalize::AtExt;
1432+
use rustc_middle::traits::ObligationCause;
1433+
14301434
// Try to normalize `<X as Y>::T` to a type
14311435
let lifted = ty.lift_to_tcx(cx.tcx).unwrap();
1432-
match cx.tcx.try_normalize_erasing_regions(cx.param_env, lifted) {
1436+
let normalized = cx.tcx.infer_ctxt().enter(|infcx| {
1437+
infcx
1438+
.at(&ObligationCause::dummy(), cx.param_env)
1439+
.normalize(lifted)
1440+
.map(|resolved| infcx.resolve_vars_if_possible(resolved.value))
1441+
});
1442+
match normalized {
14331443
Ok(normalized_value) => {
1434-
trace!("normalized {:?} to {:?}", ty, normalized_value);
1444+
debug!("normalized {:?} to {:?}", ty, normalized_value);
14351445
Some(normalized_value)
14361446
}
14371447
Err(err) => {
1438-
info!("failed to normalize {:?}: {:?}", ty, err);
1448+
debug!("failed to normalize {:?}: {:?}", ty, err);
14391449
None
14401450
}
14411451
}

src/test/rustdoc/lifetime-name.rs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#![crate_name = "foo"]
2+
3+
// @has 'foo/type.Resolutions.html'
4+
// @has - '//*[@class="rust typedef"]' "pub type Resolutions<'tcx> = &'tcx u8;"
5+
pub type Resolutions<'tcx> = &'tcx u8;

0 commit comments

Comments
 (0)