Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate dyn Trait information #741

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading