Skip to content

Commit

Permalink
Merge pull request #741 from Nadrieril/dyn
Browse files Browse the repository at this point in the history
Translate `dyn Trait` information
  • Loading branch information
W95Psp committed Jun 28, 2024
2 parents c711b19 + f0e1286 commit 53aa5d8
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
41 changes: 41 additions & 0 deletions frontend/exporter/src/types/copied.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,47 @@ pub struct ParamConst {
pub name: Symbol,
}

/// A predicate without `Self`, for use in `dyn Trait`.
///
/// Reflects [`rustc_middle::ty::ExistentialPredicate`]
#[derive(AdtInto)]
#[args(<'tcx, S: UnderOwnerState<'tcx>>, from: rustc_middle::ty::ExistentialPredicate<'tcx>, state: S as state)]
#[derive(
Clone, Debug, Serialize, Deserialize, JsonSchema, Hash, PartialEq, Eq, PartialOrd, Ord,
)]
pub enum ExistentialPredicate {
/// E.g. `From<u64>`. Note that this isn't `T: From<u64>` with a given `T`, this is just
/// `From<u64>`. Could be written `?: From<u64>`.
Trait(ExistentialTraitRef),
/// E.g. `Iterator::Item = u64`. Could be written `<? as Iterator>::Item = u64`.
Projection(ExistentialProjection),
/// E.g. `Send`.
AutoTrait(DefId),
}

/// Reflects [`rustc_type_ir::ExistentialTraitRef`]
#[derive(AdtInto)]
#[args(<'tcx, S: UnderOwnerState<'tcx>>, from: rustc_type_ir::ExistentialTraitRef<ty::TyCtxt<'tcx>>, state: S as state)]
#[derive(
Clone, Debug, Serialize, Deserialize, JsonSchema, Hash, PartialEq, Eq, PartialOrd, Ord,
)]
pub struct ExistentialTraitRef {
pub def_id: DefId,
pub args: Vec<GenericArg>,
}

/// Reflects [`rustc_type_ir::ExistentialProjection`]
#[derive(AdtInto)]
#[args(<'tcx, S: UnderOwnerState<'tcx>>, from: rustc_type_ir::ExistentialProjection<ty::TyCtxt<'tcx>>, state: S as state)]
#[derive(
Clone, Debug, Serialize, Deserialize, JsonSchema, Hash, PartialEq, Eq, PartialOrd, Ord,
)]
pub struct ExistentialProjection {
pub def_id: DefId,
pub args: Vec<GenericArg>,
pub term: Term,
}

/// Reflects [`rustc_middle::ty::DynKind`]
#[derive(
AdtInto, Clone, Debug, Serialize, Deserialize, JsonSchema, Hash, PartialEq, Eq, PartialOrd, Ord,
Expand Down
1 change: 0 additions & 1 deletion frontend/exporter/src/types/todo.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::prelude::*;
use crate::sinto_todo;
sinto_todo!(rustc_middle::ty, ScalarInt);
sinto_todo!(rustc_middle::ty, ExistentialPredicate<'a>);
sinto_todo!(rustc_middle::ty, AdtFlags);
sinto_todo!(rustc_middle::ty, NormalizesTo<'tcx>);
sinto_todo!(rustc_abi, IntegerType);
Expand Down

0 comments on commit 53aa5d8

Please sign in to comment.