Rollup merge of #150980 - fix-ice-150673, r=fee1-dead

Use updated indexes to build reverse map for delegation generics

Fixes rust-lang/rust#150673.

This was a bug that built the `param_def_id_to_index` map with indexes before the new generics were renumbered.

r? @petrochenkov
This commit is contained in:
Matthias Krüger 2026-01-12 13:32:12 +01:00 committed by GitHub
commit 1ff682edcd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 43 additions and 3 deletions

View file

@ -135,9 +135,6 @@ fn build_generics<'tcx>(
// }
own_params.sort_by_key(|key| key.kind.is_ty_or_const());
let param_def_id_to_index =
own_params.iter().map(|param| (param.def_id, param.index)).collect();
let (parent_count, has_self) = if let Some(def_id) = parent {
let parent_generics = tcx.generics_of(def_id);
let parent_kind = tcx.def_kind(def_id);
@ -162,6 +159,9 @@ fn build_generics<'tcx>(
}
}
let param_def_id_to_index =
own_params.iter().map(|param| (param.def_id, param.index)).collect();
ty::Generics {
parent,
parent_count,

View file

@ -0,0 +1,21 @@
#![feature(fn_delegation)]
#![allow(incomplete_features)]
mod to_reuse {
pub fn foo<T>() -> T {
unimplemented!()
}
}
struct S<T>(T);
trait Trait {
reuse to_reuse::foo;
}
impl Trait for S {
//~^ ERROR: missing generics for struct `S`
reuse Trait::foo;
}
fn main() {}

View file

@ -0,0 +1,19 @@
error[E0107]: missing generics for struct `S`
--> $DIR/ice-issue-150673.rs:16:16
|
LL | impl Trait for S {
| ^ expected 1 generic argument
|
note: struct defined here, with 1 generic parameter: `T`
--> $DIR/ice-issue-150673.rs:10:8
|
LL | struct S<T>(T);
| ^ -
help: add missing generic argument
|
LL | impl Trait for S<T> {
| +++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0107`.