about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2022-04-27 02:47:10 +0200
committerGitHub <noreply@github.com>2022-04-27 02:47:10 +0200
commit5645732b041ff1f3e7cee585d454613a9e7c43f0 (patch)
tree589674d090636878ff6e84c0cbe5f8f54b44f055
parente63da0ba000b94c932aa6e166a02cebe9bf2c719 (diff)
parent8a28aa48d20ac4fd64d47815b84f1daf0c62f460 (diff)
downloadrust-5645732b041ff1f3e7cee585d454613a9e7c43f0.tar.gz
rust-5645732b041ff1f3e7cee585d454613a9e7c43f0.zip
Rollup merge of #96383 - compiler-errors:issue-96381, r=estebank
Fix erased region escaping into wfcheck due to #95395

We can just use `liberate_late_bound_regions` instead of `erase_late_bound_regions`... This gives us `ReEarlyBound` instead of `ReErased`, the former being something typeck actually knows how to deal with...

Fixes #96381

Side-note: We only actually get far enough in the compiler pipeline to cause this ICE when we're invoking rustdoc. We actually abort rustc right before wfcheck because of the error that we emit (having `_` in the type signature). Why does rustdoc keep going even though we raise an error?
-rw-r--r--compiler/rustc_typeck/src/astconv/mod.rs8
-rw-r--r--src/test/rustdoc/issue-96381.rs16
2 files changed, 20 insertions, 4 deletions
diff --git a/compiler/rustc_typeck/src/astconv/mod.rs b/compiler/rustc_typeck/src/astconv/mod.rs
index 1cd0ace8adb..1caf93e5fe0 100644
--- a/compiler/rustc_typeck/src/astconv/mod.rs
+++ b/compiler/rustc_typeck/src/astconv/mod.rs
@@ -2681,21 +2681,21 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
         let trait_ref =
             self.instantiate_mono_trait_ref(i.of_trait.as_ref()?, self.ast_ty_to_ty(i.self_ty));
 
-        let x: &ty::AssocItem = tcx.associated_items(trait_ref.def_id).find_by_name_and_kind(
+        let assoc = tcx.associated_items(trait_ref.def_id).find_by_name_and_kind(
             tcx,
             *ident,
             ty::AssocKind::Fn,
             trait_ref.def_id,
         )?;
 
-        let fn_sig = tcx.fn_sig(x.def_id).subst(
+        let fn_sig = tcx.fn_sig(assoc.def_id).subst(
             tcx,
-            trait_ref.substs.extend_to(tcx, x.def_id, |param, _| tcx.mk_param_from_def(param)),
+            trait_ref.substs.extend_to(tcx, assoc.def_id, |param, _| tcx.mk_param_from_def(param)),
         );
 
         let ty = if let Some(arg_idx) = arg_idx { fn_sig.input(arg_idx) } else { fn_sig.output() };
 
-        Some(tcx.erase_late_bound_regions(ty))
+        Some(tcx.liberate_late_bound_regions(fn_hir_id.expect_owner().to_def_id(), ty))
     }
 
     fn validate_late_bound_regions(
diff --git a/src/test/rustdoc/issue-96381.rs b/src/test/rustdoc/issue-96381.rs
new file mode 100644
index 00000000000..f0f123f85a0
--- /dev/null
+++ b/src/test/rustdoc/issue-96381.rs
@@ -0,0 +1,16 @@
+// should-fail
+
+#![allow(unused)]
+
+trait Foo<T>: Sized {
+    fn bar(i: i32, t: T, s: &Self) -> (T, i32);
+}
+
+impl Foo<usize> for () {
+    fn bar(i: _, t: _, s: _) -> _ {
+        //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions
+        (1, 2)
+    }
+}
+
+fn main() {}