Avoid trying to normalize unnormalizable types
This commit is contained in:
parent
21917b0866
commit
30754517d1
2 changed files with 10 additions and 3 deletions
|
@ -982,7 +982,10 @@ where
|
||||||
/// different binding level.
|
/// different binding level.
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn dummy(value: T) -> Binder<'tcx, T> {
|
pub fn dummy(value: T) -> Binder<'tcx, T> {
|
||||||
assert!(!value.has_escaping_bound_vars());
|
assert!(
|
||||||
|
!value.has_escaping_bound_vars(),
|
||||||
|
"`{value:?}` has escaping bound vars, so it cannot be wrapped in a dummy binder."
|
||||||
|
);
|
||||||
Binder(value, ty::List::empty())
|
Binder(value, ty::List::empty())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ use rustc_infer::infer::region_constraints::{Constraint, RegionConstraintData};
|
||||||
use rustc_middle::middle::resolve_lifetime as rl;
|
use rustc_middle::middle::resolve_lifetime as rl;
|
||||||
use rustc_middle::ty::fold::TypeFolder;
|
use rustc_middle::ty::fold::TypeFolder;
|
||||||
use rustc_middle::ty::InternalSubsts;
|
use rustc_middle::ty::InternalSubsts;
|
||||||
|
use rustc_middle::ty::TypeVisitable;
|
||||||
use rustc_middle::ty::{self, AdtKind, DefIdTree, EarlyBinder, Ty, TyCtxt};
|
use rustc_middle::ty::{self, AdtKind, DefIdTree, EarlyBinder, Ty, TyCtxt};
|
||||||
use rustc_middle::{bug, span_bug};
|
use rustc_middle::{bug, span_bug};
|
||||||
use rustc_span::hygiene::{AstPass, MacroKind};
|
use rustc_span::hygiene::{AstPass, MacroKind};
|
||||||
|
@ -1459,8 +1460,11 @@ fn clean_qpath<'tcx>(hir_ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> Type
|
||||||
hir::QPath::Resolved(Some(qself), p) => {
|
hir::QPath::Resolved(Some(qself), p) => {
|
||||||
// Try to normalize `<X as Y>::T` to a type
|
// Try to normalize `<X as Y>::T` to a type
|
||||||
let ty = hir_ty_to_ty(cx.tcx, hir_ty);
|
let ty = hir_ty_to_ty(cx.tcx, hir_ty);
|
||||||
if let Some(normalized_value) = normalize(cx, ty::Binder::dummy(ty)) {
|
// `hir_to_ty` can return projection types with escaping vars for GATs, e.g. `<() as Trait>::Gat<'_>`
|
||||||
return clean_middle_ty(normalized_value, cx, None);
|
if !ty.has_escaping_bound_vars() {
|
||||||
|
if let Some(normalized_value) = normalize(cx, ty::Binder::dummy(ty)) {
|
||||||
|
return clean_middle_ty(normalized_value, cx, None);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let trait_segments = &p.segments[..p.segments.len() - 1];
|
let trait_segments = &p.segments[..p.segments.len() - 1];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue