Skip to content

Commit 8a28aa4

Browse files
Fix issue 96381
1 parent 18b53ce commit 8a28aa4

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)