Skip to content

Commit

Permalink
Fix issue 96381
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Apr 25, 2022
1 parent 18b53ce commit 8a28aa4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
8 changes: 4 additions & 4 deletions compiler/rustc_typeck/src/astconv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
16 changes: 16 additions & 0 deletions src/test/rustdoc/issue-96381.rs
Original file line number Diff line number Diff line change
@@ -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() {}

0 comments on commit 8a28aa4

Please sign in to comment.