Context::generics _of/predicates_of should receive stable_mir::DefId

This commit is contained in:
Santiago Pastorino 2023-08-28 14:55:40 -03:00
parent 7a653feffb
commit e9710f1faa
No known key found for this signature in database
GPG Key ID: 8131A24E0C79EFAF
3 changed files with 12 additions and 12 deletions

View File

@ -10,7 +10,7 @@
use crate::rustc_internal::{self, opaque};
use crate::stable_mir::mir::{CopyNonOverlapping, UserTypeProjection, VariantIdx};
use crate::stable_mir::ty::{
allocation_filter, new_allocation, Const, FloatTy, GenericDef, GenericParamDef, IntTy,
allocation_filter, new_allocation, Const, FloatTy, GenericParamDef, IntTy,
Movability, RigidTy, TyKind, UintTy,
};
use crate::stable_mir::{self, Context};
@ -102,18 +102,18 @@ impl<'tcx> Context for Tables<'tcx> {
ty.stable(self)
}
fn generics_of(&mut self, generic_def: &GenericDef) -> stable_mir::ty::Generics {
let def_id = self.generic_def_id(generic_def);
let generic_def = self.tcx.generics_of(def_id);
generic_def.stable(self)
fn generics_of(&mut self, def_id: stable_mir::DefId) -> stable_mir::ty::Generics {
let def_id = self.def_ids[def_id];
let generics = self.tcx.generics_of(def_id);
generics.stable(self)
}
fn predicates_of(
&mut self,
trait_def: &stable_mir::ty::TraitDef,
def_id: stable_mir::DefId,
) -> stable_mir::GenericPredicates {
let trait_def_id = self.trait_def_id(trait_def);
let ty::GenericPredicates { parent, predicates } = self.tcx.predicates_of(trait_def_id);
let def_id = self.def_ids[def_id];
let ty::GenericPredicates { parent, predicates } = self.tcx.predicates_of(def_id);
stable_mir::GenericPredicates {
parent: parent.map(|did| self.trait_def(did)),
predicates: predicates

View File

@ -16,7 +16,7 @@ use std::cell::Cell;
use crate::rustc_smir::Tables;
use self::ty::{
GenericDef, Generics, ImplDef, ImplTrait, PredicateKind, Span, TraitDecl, TraitDef, Ty, TyKind,
Generics, ImplDef, ImplTrait, PredicateKind, Span, TraitDecl, TraitDef, Ty, TyKind,
};
pub mod mir;
@ -118,8 +118,8 @@ pub trait Context {
fn trait_decl(&mut self, trait_def: &TraitDef) -> TraitDecl;
fn all_trait_impls(&mut self) -> ImplTraitDecls;
fn trait_impl(&mut self, trait_impl: &ImplDef) -> ImplTrait;
fn generics_of(&mut self, generic_def: &GenericDef) -> Generics;
fn predicates_of(&mut self, trait_def: &TraitDef) -> GenericPredicates;
fn generics_of(&mut self, def_id: DefId) -> Generics;
fn predicates_of(&mut self, def_id: DefId) -> GenericPredicates;
/// Get information about the local crate.
fn local_crate(&self) -> Crate;
/// Retrieve a list of all external crates.

View File

@ -137,7 +137,7 @@ impl ImplDef {
impl GenericDef {
pub fn generics_of(&self) -> Generics {
with(|tcx| tcx.generics_of(self))
with(|cx| cx.generics_of(self.0))
}
}