Skip to content

Commit

Permalink
Rollup merge of #93542 - GuillaumeGomez:lifetime-elision, r=oli-obk
Browse files Browse the repository at this point in the history
Prevent lifetime elision in type alias

Fixes #93401.

Apparently, the problem has been fixed in the compiler.

r? `@oli-obk`
  • Loading branch information
matthiaskrgr authored Feb 2, 2022
2 parents b622552 + 2308464 commit 7e212c1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1427,15 +1427,25 @@ fn normalize<'tcx>(cx: &mut DocContext<'tcx>, ty: Ty<'_>) -> Option<Ty<'tcx>> {
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 `<X as Y>::T` to a type
let lifted = ty.lift_to_tcx(cx.tcx).unwrap();
match cx.tcx.try_normalize_erasing_regions(cx.param_env, lifted) {
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 {
Ok(normalized_value) => {
trace!("normalized {:?} to {:?}", ty, normalized_value);
debug!("normalized {:?} to {:?}", ty, normalized_value);
Some(normalized_value)
}
Err(err) => {
info!("failed to normalize {:?}: {:?}", ty, err);
debug!("failed to normalize {:?}: {:?}", ty, err);
None
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/test/rustdoc/lifetime-name.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#![crate_name = "foo"]

// @has 'foo/type.Resolutions.html'
// @has - '//*[@class="rust typedef"]' "pub type Resolutions<'tcx> = &'tcx u8;"
pub type Resolutions<'tcx> = &'tcx u8;

0 comments on commit 7e212c1

Please sign in to comment.