Skip to content

Commit 27195ed

Browse files
authored
Rollup merge of rust-lang#96383 - compiler-errors:issue-96381, r=estebank
Fix erased region escaping into wfcheck due to rust-lang#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 rust-lang#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?
2 parents d45d297 + 8a28aa4 commit 27195ed

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

compiler/rustc_typeck/src/astconv/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2681,21 +2681,21 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
26812681
let trait_ref =
26822682
self.instantiate_mono_trait_ref(i.of_trait.as_ref()?, self.ast_ty_to_ty(i.self_ty));
26832683

2684-
let x: &ty::AssocItem = tcx.associated_items(trait_ref.def_id).find_by_name_and_kind(
2684+
let assoc = tcx.associated_items(trait_ref.def_id).find_by_name_and_kind(
26852685
tcx,
26862686
*ident,
26872687
ty::AssocKind::Fn,
26882688
trait_ref.def_id,
26892689
)?;
26902690

2691-
let fn_sig = tcx.fn_sig(x.def_id).subst(
2691+
let fn_sig = tcx.fn_sig(assoc.def_id).subst(
26922692
tcx,
2693-
trait_ref.substs.extend_to(tcx, x.def_id, |param, _| tcx.mk_param_from_def(param)),
2693+
trait_ref.substs.extend_to(tcx, assoc.def_id, |param, _| tcx.mk_param_from_def(param)),
26942694
);
26952695

26962696
let ty = if let Some(arg_idx) = arg_idx { fn_sig.input(arg_idx) } else { fn_sig.output() };
26972697

2698-
Some(tcx.erase_late_bound_regions(ty))
2698+
Some(tcx.liberate_late_bound_regions(fn_hir_id.expect_owner().to_def_id(), ty))
26992699
}
27002700

27012701
fn validate_late_bound_regions(

src/test/rustdoc/issue-96381.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// should-fail
2+
3+
#![allow(unused)]
4+
5+
trait Foo<T>: Sized {
6+
fn bar(i: i32, t: T, s: &Self) -> (T, i32);
7+
}
8+
9+
impl Foo<usize> for () {
10+
fn bar(i: _, t: _, s: _) -> _ {
11+
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions
12+
(1, 2)
13+
}
14+
}
15+
16+
fn main() {}

0 commit comments

Comments
 (0)