Skip to content

Commit

Permalink
Bump rustc version
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadrieril committed May 22, 2024
1 parent f29ad33 commit 7bdba90
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 127 deletions.
17 changes: 8 additions & 9 deletions frontend/exporter/src/constant_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,14 +305,14 @@ pub(crate) fn is_anon_const<'tcx>(
fn trait_const_to_constant_expr_kind<'tcx, S: BaseState<'tcx> + HasOwnerId>(
s: &S,
_const_def_id: rustc_hir::def_id::DefId,
substs: rustc_middle::ty::SubstsRef<'tcx>,
generics: rustc_middle::ty::GenericArgsRef<'tcx>,
assoc: &rustc_middle::ty::AssocItem,
) -> ConstantExprKind {
assert!(assoc.trait_item_def_id.is_some());
let name = assoc.name.to_string();

// Retrieve the trait information
let impl_expr = get_trait_info(s, substs, assoc);
let impl_expr = get_trait_info(s, generics, assoc);

ConstantExprKind::TraitConst { impl_expr, name }
}
Expand Down Expand Up @@ -356,19 +356,18 @@ pub trait ConstantExt<'tcx>: Sized + std::fmt::Debug {
let cv = if let Some(assoc) = s.base().tcx.opt_associated_item(ucv.def) {
if assoc.trait_item_def_id.is_some() {
// This must be a trait declaration constant
trait_const_to_constant_expr_kind(s, ucv.def, ucv.substs, &assoc)
trait_const_to_constant_expr_kind(s, ucv.def, ucv.args, &assoc)
} else {
// Constant appearing in an inherent impl block.

// Solve the trait obligations
let parent_def_id = tcx.parent(ucv.def);
let param_env = s.param_env();
let trait_refs =
solve_item_traits(s, param_env, parent_def_id, ucv.substs, None);
let trait_refs = solve_item_traits(s, param_env, parent_def_id, ucv.args, None);

// Convert
let id = ucv.def.sinto(s);
let generics = ucv.substs.sinto(s);
let generics = ucv.args.sinto(s);
ConstantExprKind::GlobalName {
id,
generics,
Expand All @@ -377,7 +376,7 @@ pub trait ConstantExt<'tcx>: Sized + std::fmt::Debug {
}
} else {
// Top-level constant.
assert!(ucv.substs.is_empty(), "top-level constant has generics?");
assert!(ucv.args.is_empty(), "top-level constant has generics?");
let id = ucv.def.sinto(s);
ConstantExprKind::GlobalName {
id,
Expand Down Expand Up @@ -559,9 +558,9 @@ pub fn const_value_to_constant_expr<'tcx, S: UnderOwnerState<'tcx>>(
let cv = match &hty {
Ty::Tuple(tys) if tys.is_empty() => ConstantExprKind::Tuple { fields: Vec::new() },
Ty::Arrow(_) => match ty.kind() {
rustc_middle::ty::TyKind::FnDef(def_id, substs) => {
rustc_middle::ty::TyKind::FnDef(def_id, args) => {
let (def_id, generics, generics_impls, method_impl) =
get_function_from_def_id_and_substs(s, *def_id, substs);
get_function_from_def_id_and_generics(s, *def_id, args);

ConstantExprKind::FnPtr {
def_id,
Expand Down
8 changes: 4 additions & 4 deletions frontend/exporter/src/rustc_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ impl<'tcx, T: ty::TypeFoldable<ty::TyCtxt<'tcx>>> ty::Binder<'tcx, T> {
fn subst(
self,
tcx: ty::TyCtxt<'tcx>,
substs: &[ty::subst::GenericArg<'tcx>],
generics: &[ty::GenericArg<'tcx>],
) -> ty::Binder<'tcx, T> {
self.rebind(ty::EarlyBinder::bind(self.clone().skip_binder()).subst(tcx, substs))
self.rebind(ty::EarlyBinder::bind(self.clone().skip_binder()).instantiate(tcx, generics))
}
}

Expand Down Expand Up @@ -95,11 +95,11 @@ impl<'tcx> ty::TyCtxt<'tcx> {
pub fn poly_trait_ref<'tcx, S: UnderOwnerState<'tcx>>(
s: &S,
assoc: &ty::AssocItem,
substs: ty::SubstsRef<'tcx>,
generics: ty::GenericArgsRef<'tcx>,
) -> Option<ty::PolyTraitRef<'tcx>> {
let tcx = s.base().tcx;
let r#trait = tcx.trait_of_item(assoc.def_id)?;
Some(ty::Binder::dummy(ty::TraitRef::new(tcx, r#trait, substs)))
Some(ty::Binder::dummy(ty::TraitRef::new(tcx, r#trait, generics)))
}

#[tracing::instrument(skip(s))]
Expand Down
2 changes: 1 addition & 1 deletion frontend/exporter/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ impl ImplInfos {

Self {
generics: tcx.generics_of(did).sinto(s),
typ: tcx.type_of(did).subst_identity().sinto(s),
typ: tcx.type_of(did).instantiate_identity().sinto(s),
trait_ref: tcx.impl_trait_ref(did).sinto(s),
clauses: tcx.predicates_defined_on(did).predicates.sinto(s),
}
Expand Down
24 changes: 10 additions & 14 deletions frontend/exporter/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ pub(crate) mod search_clause {
fn predicates_to_poly_trait_predicates<'tcx>(
tcx: TyCtxt<'tcx>,
predicates: impl Iterator<Item = Predicate<'tcx>>,
substs: subst::SubstsRef<'tcx>,
generics: GenericArgsRef<'tcx>,
) -> impl Iterator<Item = PolyTraitPredicate<'tcx>> {
predicates
.map(move |pred| pred.kind().subst(tcx, substs))
.map(move |pred| pred.kind().subst(tcx, generics))
.filter_map(|pred| pred.as_poly_trait_predicate())
}

Expand Down Expand Up @@ -160,20 +160,16 @@ pub(crate) mod search_clause {
.predicates_defined_on_or_above(self.def_id())
.into_iter()
.map(|apred| apred.predicate);
predicates_to_poly_trait_predicates(
tcx,
predicates,
self.skip_binder().trait_ref.substs,
)
.enumerate()
.collect()
predicates_to_poly_trait_predicates(tcx, predicates, self.skip_binder().trait_ref.args)
.enumerate()
.collect()
}
fn associated_items_trait_predicates(
self,
s: &S,
) -> Vec<(
AssocItem,
subst::EarlyBinder<Vec<(usize, PolyTraitPredicate<'tcx>)>>,
EarlyBinder<Vec<(usize, PolyTraitPredicate<'tcx>)>>,
)> {
let tcx = s.base().tcx;
tcx.associated_items(self.def_id())
Expand All @@ -185,7 +181,7 @@ pub(crate) mod search_clause {
predicates_to_poly_trait_predicates(
tcx,
clauses.into_iter().map(|clause| clause.as_predicate()),
self.skip_binder().trait_ref.substs,
self.skip_binder().trait_ref.args,
)
.enumerate()
.collect()
Expand Down Expand Up @@ -321,11 +317,11 @@ impl<'tcx> IntoImplExpr<'tcx> for rustc_middle::ty::PolyTraitRef<'tcx> {
match select_trait_candidate(s, param_env, *self) {
ImplSource::UserDefined(ImplSourceUserDefinedData {
impl_def_id,
substs,
args: generics,
nested,
}) => ImplExprAtom::Concrete {
id: impl_def_id.sinto(s),
generics: substs.sinto(s),
generics: generics.sinto(s),
}
.with_args(impl_exprs(s, &nested), trait_ref),
ImplSource::Param(nested, _constness) => {
Expand Down Expand Up @@ -398,7 +394,7 @@ pub fn super_clause_to_clause_and_impl_expr<'tcx, S: UnderOwnerState<'tcx>>(
let tcx = s.base().tcx;
let impl_trait_ref = tcx
.impl_trait_ref(impl_did)
.map(|binder| rustc_middle::ty::Binder::dummy(binder.subst_identity()))?;
.map(|binder| rustc_middle::ty::Binder::dummy(binder.instantiate_identity()))?;
let original_predicate_id = {
// We don't want the id of the substituted clause id, but the
// original clause id (with, i.e., `Self`)
Expand Down
Loading

0 comments on commit 7bdba90

Please sign in to comment.