Rollup merge of #89441 - Nadrieril:fix-89393, r=tmandry
Normalize after substituting via `field.ty()` Back in https://github.com/rust-lang/rust/issues/72476 I hadn't understood where the problem was coming from, and only worked around the issue. What happens is that calling `field.ty()` on a field of a generic struct substitutes the appropriate generics but doesn't normalize the resulting type. As a consumer of types I'm surprised that one would substitute without normalizing, feels like a footgun, so I added a comment. Fixes https://github.com/rust-lang/rust/issues/89393.
This commit is contained in:
commit
5ab1245303
5 changed files with 62 additions and 27 deletions
|
@ -1640,8 +1640,8 @@ impl ReprOptions {
|
|||
}
|
||||
|
||||
impl<'tcx> FieldDef {
|
||||
/// Returns the type of this field. The `subst` is typically obtained
|
||||
/// via the second field of `TyKind::AdtDef`.
|
||||
/// Returns the type of this field. The resulting type is not normalized. The `subst` is
|
||||
/// typically obtained via the second field of `TyKind::AdtDef`.
|
||||
pub fn ty(&self, tcx: TyCtxt<'tcx>, subst: SubstsRef<'tcx>) -> Ty<'tcx> {
|
||||
tcx.type_of(self.did).subst(tcx, subst)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue