Skip to content

Instantly share code, notes, and snippets.

@compiler-errors
Created August 22, 2022 05:24
Show Gist options
  • Save compiler-errors/76ad4b33b5c64a258ebe45ee89031957 to your computer and use it in GitHub Desktop.
Save compiler-errors/76ad4b33b5c64a258ebe45ee89031957 to your computer and use it in GitHub Desktop.
diff --git a/compiler/rustc_infer/src/infer/opaque_types.rs b/compiler/rustc_infer/src/infer/opaque_types.rs
index e579afbf389..8c435950977 100644
--- a/compiler/rustc_infer/src/infer/opaque_types.rs
+++ b/compiler/rustc_infer/src/infer/opaque_types.rs
@@ -49,7 +49,7 @@ pub fn replace_opaque_types_with_inference_vars<T: TypeFoldable<'tcx>>(
span: Span,
param_env: ty::ParamEnv<'tcx>,
) -> InferOk<'tcx, T> {
- if !value.has_opaque_types() {
+ if !(value.has_opaque_types() || value.has_ty_alias()) {
return InferOk { value, obligations: vec![] };
}
let mut obligations = vec![];
@@ -58,7 +58,7 @@ pub fn replace_opaque_types_with_inference_vars<T: TypeFoldable<'tcx>>(
.as_local()
.map_or(false, |def_id| self.opaque_type_origin(def_id, span).is_some())
};
- let value = value.fold_with(&mut ty::fold::BottomUpFolder {
+ let value = self.tcx.peel_off_ty_alias(value).fold_with(&mut ty::fold::BottomUpFolder {
tcx: self.tcx,
lt_op: |lt| lt,
ct_op: |ct| ct,
@@ -564,7 +564,7 @@ pub fn register_hidden_type(
for predicate in item_bounds.transpose_iter().map(|e| e.map_bound(|(p, _)| *p)) {
debug!(?predicate);
- let predicate = predicate.subst(tcx, substs);
+ let predicate = tcx.peel_off_ty_alias(predicate.subst(tcx, substs));
let predicate = predicate.fold_with(&mut BottomUpFolder {
tcx,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment