pub(crate) struct RustItemCtxt<'a, 'genv, 'tcx> {
genv: GlobalEnv<'genv, 'tcx>,
local_id_gen: IndexGen<ItemLocalId>,
owner: MaybeExternId<OwnerId>,
fn_sig_scope: Option<NodeId>,
resolver_output: &'genv ResolverOutput,
opaque: Option<LocalDefId>,
opaque_tys: Option<&'a mut Vec<&'genv OpaqueTy<'genv>>>,
errors: Errors<'genv>,
}Fields§
§genv: GlobalEnv<'genv, 'tcx>§local_id_gen: IndexGen<ItemLocalId>§owner: MaybeExternId<OwnerId>§fn_sig_scope: Option<NodeId>§resolver_output: &'genv ResolverOutput§opaque: Option<LocalDefId>HACK! We assume there’s at most one opaque type (we fail with an error if there’s more than one)
and we store the DefId here if it exists. See collect_opaque_types
opaque_tys: Option<&'a mut Vec<&'genv OpaqueTy<'genv>>>This collects all the opaque types generated in the process of desugaring an FnSig, however
we can only resolve one opaque type so this will contain at most one element.
errors: Errors<'genv>Implementations§
Source§impl<'genv> RustItemCtxt<'_, 'genv, '_>
impl<'genv> RustItemCtxt<'_, 'genv, '_>
pub(crate) fn lift_item(&mut self) -> Result<Item<'genv>, ErrorGuaranteed>
pub(crate) fn lift_trait_item(&mut self) -> TraitItem<'genv>
pub(crate) fn lift_impl_item(&mut self) -> ImplItem<'genv>
pub(crate) fn lift_generics(&mut self) -> Generics<'genv>
pub(crate) fn lift_generic_param( &mut self, param: &GenericParam<'_>, ) -> GenericParam<'genv>
fn lift_generics_inner(&mut self, generics: &Generics<'_>) -> Generics<'genv>
fn lift_generic_bound( &mut self, bound: &GenericBound<'_>, ) -> Result<GenericBound<'genv>, ErrorGuaranteed>
fn lift_poly_trait_ref( &mut self, poly_trait_ref: PolyTraitRef<'_>, ) -> Result<PolyTraitRef<'genv>, ErrorGuaranteed>
fn lift_opaque_ty( &mut self, opaque_ty: &OpaqueTy<'_>, ) -> Result<OpaqueTy<'genv>, ErrorGuaranteed>
pub(crate) fn lift_fn_header(&mut self) -> FnHeader
pub(crate) fn lift_fn_decl(&mut self) -> FnDecl<'genv>
fn lift_fn_decl_inner(&mut self, span: Span, decl: &FnDecl<'_>) -> FnDecl<'genv>
fn lift_fn_ret_ty(&mut self, ret_ty: &FnRetTy<'_>) -> Ty<'genv>
fn lift_type_alias(&mut self, span: Span, ty: &Ty<'_>) -> TyAlias<'genv>
fn lift_struct_def(&mut self, variant_data: VariantData<'_>) -> StructDef<'genv>
pub(crate) fn lift_field_def( &mut self, field_def: &FieldDef<'_>, ) -> FieldDef<'genv>
fn lift_enum_def(&mut self, enum_def: EnumDef<'_>) -> EnumDef<'genv>
pub(crate) fn lift_enum_variant( &mut self, variant: &Variant<'_>, ) -> VariantDef<'genv>
pub(crate) fn lift_variant_ret(&mut self) -> VariantRet<'genv>
fn lift_variant_ret_inner( &mut self, generics: &Generics<'_>, ) -> VariantRet<'genv>
fn lift_ty(&mut self, ty: &Ty<'_>) -> Ty<'genv>
fn lift_bare_fn(&mut self, span: Span, fn_ptr: &FnPtrTy<'_>) -> BareFnTy<'genv>
fn lift_lifetime(&self, lft: &Lifetime) -> Lifetime
fn lift_mut_ty(&mut self, mut_ty: MutTy<'_>) -> MutTy<'genv>
fn lift_qpath( &mut self, qpath: QPath<'_>, ) -> Result<QPath<'genv>, ErrorGuaranteed>
fn lift_path(&mut self, path: &Path<'_>) -> Result<Path<'genv>, ErrorGuaranteed>
fn lift_path_segment( &mut self, segment: &PathSegment<'_>, ) -> Result<PathSegment<'genv>, ErrorGuaranteed>
fn lift_generic_args( &mut self, args: &[GenericArg<'_>], ) -> Result<&'genv [GenericArg<'genv>], ErrorGuaranteed>
fn lift_assoc_item_constraints( &mut self, constraints: &[AssocItemConstraint<'_>], ) -> Result<&'genv [AssocItemConstraint<'genv>], ErrorGuaranteed>
fn lift_const_arg(&mut self, const_arg: &ConstArg<'_>) -> ConstArg
fn emit_unsupported(&self, note: &str) -> ErrorGuaranteed
fn next_fhir_id(&self) -> FhirId
fn local_id(&self) -> LocalDefId
fn lift_fn_sig(&mut self, fn_sig: FnSig<'_>) -> FnSig<'genv>
pub(crate) fn lift_foreign_item( &mut self, foreign_item: ForeignItem<'_>, ) -> Result<ForeignItem<'genv>, ErrorGuaranteed>
Sourcefn fix_maybe_extern_id_in_res(&self, res: Res) -> Res
fn fix_maybe_extern_id_in_res(&self, res: Res) -> Res
Fixes the def ids inside res to point to resolved ids.
Source§impl<'a, 'genv, 'tcx: 'genv> RustItemCtxt<'a, 'genv, 'tcx>
impl<'a, 'genv, 'tcx: 'genv> RustItemCtxt<'a, 'genv, 'tcx>
pub(crate) fn with<T>( genv: GlobalEnv<'genv, 'tcx>, owner: MaybeExternId<OwnerId>, resolver_output: &'genv ResolverOutput, opaque_tys: Option<&'a mut Vec<&'genv OpaqueTy<'genv>>>, f: impl FnOnce(&mut Self) -> Result<T, ErrorGuaranteed>, ) -> Result<T, ErrorGuaranteed>
pub(crate) fn desugar_item( &mut self, item: &Item, ) -> Result<Item<'genv>, ErrorGuaranteed>
pub(crate) fn desugar_trait_item( &mut self, item: &TraitItemFn, ) -> Result<TraitItem<'genv>, ErrorGuaranteed>
pub(crate) fn desugar_impl_item( &mut self, item: &ImplItemFn, ) -> Result<ImplItem<'genv>, ErrorGuaranteed>
fn desugar_trait( &mut self, trait_: &Trait, ) -> Result<Item<'genv>, ErrorGuaranteed>
fn desugar_trait_assoc_refts( &mut self, assoc_refts: &[TraitAssocReft], ) -> Result<&'genv [TraitAssocReft<'genv>], ErrorGuaranteed>
fn desugar_impl(&mut self, impl_: &Impl) -> Item<'genv>
fn desugar_impl_assoc_refts( &mut self, assoc_refts: &[ImplAssocReft], ) -> &'genv [ImplAssocReft<'genv>]
fn desugar_generics(&mut self, generics: &Generics) -> Generics<'genv>
fn desugar_opt_generics( &mut self, generics: Option<&Generics>, ) -> Generics<'genv>
fn desugar_generic_predicates( &mut self, predicates: &[WhereBoundPredicate], ) -> &'genv [WhereBoundPredicate<'genv>]
fn desugar_generic_bounds( &mut self, bounds: &[TraitRef], ) -> GenericBounds<'genv>
fn desugar_trait_ref(&mut self, trait_ref: &TraitRef) -> PolyTraitRef<'genv>
fn desugar_refined_by(&mut self, refined_by: &RefineParams) -> RefinedBy<'genv>
fn desugar_struct_def(&mut self, struct_def: &StructDef) -> Item<'genv>
fn desugar_enum_def( &mut self, enum_def: &EnumDef, ) -> Result<Item<'genv>, ErrorGuaranteed>
fn desugar_enum_variant_def( &mut self, reflected: bool, variant_def: &Option<VariantDef>, hir_variant: &Variant<'_>, ) -> Result<VariantDef<'genv>, ErrorGuaranteed>
fn desugar_type_alias(&mut self, ty_alias: &TyAlias) -> Item<'genv>
fn desugar_const(&mut self, const_info: &ConstantInfo) -> Item<'genv>
fn desugar_fn_sig( &mut self, fn_sig: Option<&FnSig>, ) -> Result<(Generics<'genv>, FnSig<'genv>), ErrorGuaranteed>
fn desugar_fn_sig_refine_params( &mut self, fn_sig: &FnSig, ) -> &'genv [RefineParam<'genv>]
fn desugar_fn_output( &mut self, asyncness: Async, output: &FnOutput, ) -> Result<FnOutput<'genv>, ErrorGuaranteed>
fn desugar_ensures( &mut self, cstr: &Ensures, ) -> Result<Ensures<'genv>, ErrorGuaranteed>
fn desugar_fn_input(&mut self, input: &FnInput) -> Ty<'genv>
fn desugar_asyncness( &mut self, asyncness: Async, returns: &FnRetTy, ) -> Ty<'genv>
fn desugar_opaque_ty_for_async( &mut self, def_id: LocalDefId, returns: &FnRetTy, ) -> OpaqueTy<'genv>
fn make_lang_item_path( &mut self, lang_item: LangItem, span: Span, args: &'genv [GenericArg<'genv>], constraints: &'genv [AssocItemConstraint<'genv>], ) -> Path<'genv>
fn desugar_fn_ret_ty(&mut self, returns: &FnRetTy) -> Ty<'genv>
fn desugar_opaque_ty_for_impl_trait( &mut self, def_id: LocalDefId, bounds: &[TraitRef], ) -> OpaqueTy<'genv>
fn desugar_variant_ret( &mut self, ret: &VariantRet, ) -> Result<VariantRet<'genv>, ErrorGuaranteed>
fn check_variant_ret_path(&mut self, path: &Path) -> Option<DefId>
fn insert_opaque_ty( &mut self, opaque_ty: OpaqueTy<'genv>, ) -> &'genv OpaqueTy<'genv>
Trait Implementations§
Source§impl<'genv, 'tcx> DesugarCtxt<'genv, 'tcx> for RustItemCtxt<'_, 'genv, 'tcx>
impl<'genv, 'tcx> DesugarCtxt<'genv, 'tcx> for RustItemCtxt<'_, 'genv, 'tcx>
fn next_fhir_id(&self) -> FhirId
fn genv(&self) -> GlobalEnv<'genv, 'tcx>
fn resolver_output(&self) -> &'genv ResolverOutput
fn desugar_impl_trait(&mut self, bounds: &[TraitRef]) -> TyKind<'genv>
fn allow_primop_app(&self) -> bool
fn resolve_implicit_param( &self, node_id: NodeId, ) -> Option<(ParamId, ParamKind)>
fn desugar_epath(&self, path: &ExprPath) -> QPathExpr<'genv>
fn desugar_loc( &self, ident: Ident, node_id: NodeId, ) -> Result<Res<ParamId>, ErrorGuaranteed>
fn resolve_param(&self, node_id: NodeId) -> (ParamId, ParamKind)
fn resolve_implicit_params( &self, scope: NodeId, ) -> impl ExactSizeIterator<Item = (Ident, ParamId, ParamKind)>
fn implicit_params_to_params( &self, scope: NodeId, ) -> impl ExactSizeIterator<Item = RefineParam<'genv>>
fn desugar_refine_params( &mut self, params: &[RefineParam], ) -> &'genv [RefineParam<'genv>]
fn desugar_refine_params_iter( &mut self, params: &[RefineParam], ) -> impl ExactSizeIterator<Item = RefineParam<'genv>>
fn desugar_refine_param(&mut self, param: &RefineParam) -> RefineParam<'genv>
fn desugar_sort( &mut self, sort: &Sort, generic_id_to_var_idx: Option<&FxIndexSet<DefId>>, ) -> Sort<'genv>
fn desugar_base_sort( &mut self, sort: &BaseSort, generic_id_to_var_idx: Option<&FxIndexSet<DefId>>, ) -> Sort<'genv>
fn desugar_generic_args( &mut self, res: Res, args: &[GenericArg], ) -> (&'genv [GenericArg<'genv>], &'genv [AssocItemConstraint<'genv>])
fn desugar_const_path_to_const_arg( &mut self, path: &Path, res: Res<!>, ) -> GenericArg<'genv>
Source§fn desugar_ty(&mut self, ty: &Ty) -> Ty<'genv>
fn desugar_ty(&mut self, ty: &Ty) -> Ty<'genv>
This is the mega desugaring function
surface::Ty -> fhir::Ty.
These are both similar representations. The most important difference is that
fhir::Ty has explicit refinement parameters and surface::Ty does not.
Refinements are implicitly scoped in surface.fn desugar_const_arg(const_arg: &ConstArg) -> ConstArg
fn desugar_bty(&mut self, bty: &BaseTy) -> BaseTy<'genv>
fn desugar_path_to_bty( &mut self, qself: Option<&Ty>, path: &Path, ) -> BaseTy<'genv>
fn desugar_qpath(&mut self, qself: Option<&Ty>, path: &Path) -> QPath<'genv>
fn desugar_path_segment(&mut self, segment: &PathSegment) -> PathSegment<'genv>
fn desugar_epath_segment(&self, segment: &ExprPathSegment) -> PathSegment<'genv>
fn ty_path(&self, qpath: QPath<'genv>) -> Ty<'genv>
fn mk_lft_hole(&self) -> Lifetime
fn desugar_indices(&mut self, idxs: &Indices) -> Expr<'genv>
fn desugar_refine_arg(&mut self, arg: &RefineArg) -> Expr<'genv>
fn implicit_param_into_refine_arg( &self, ident: Ident, node_id: NodeId, ) -> Option<Expr<'genv>>
fn desugar_expr(&mut self, expr: &Expr) -> Expr<'genv>
fn desugar_call(&mut self, callee: &Expr, args: &[Expr]) -> ExprKind<'genv>
fn desugar_constructor( &mut self, path: Option<&ExprPath>, args: &[ConstructorArg], ) -> ExprKind<'genv>
fn desugar_exprs(&mut self, exprs: &[Expr]) -> &'genv [Expr<'genv>]
fn try_parse_int_lit( &self, span: Span, s: &str, ) -> Result<u128, ErrorGuaranteed>
Source§impl ErrorCollector<ErrorGuaranteed> for RustItemCtxt<'_, '_, '_>
impl ErrorCollector<ErrorGuaranteed> for RustItemCtxt<'_, '_, '_>
type Result = Result<(), ErrorGuaranteed>
fn collect(&mut self, err: ErrorGuaranteed)
fn into_result(self) -> Self::Result
Source§impl ErrorEmitter for RustItemCtxt<'_, '_, '_>
impl ErrorEmitter for RustItemCtxt<'_, '_, '_>
fn emit<'a>(&'a self, err: impl Diagnostic<'a>) -> ErrorGuaranteed
Auto Trait Implementations§
impl<'a, 'genv, 'tcx> !Freeze for RustItemCtxt<'a, 'genv, 'tcx>
impl<'a, 'genv, 'tcx> !RefUnwindSafe for RustItemCtxt<'a, 'genv, 'tcx>
impl<'a, 'genv, 'tcx> !Send for RustItemCtxt<'a, 'genv, 'tcx>
impl<'a, 'genv, 'tcx> !Sync for RustItemCtxt<'a, 'genv, 'tcx>
impl<'a, 'genv, 'tcx> Unpin for RustItemCtxt<'a, 'genv, 'tcx>
impl<'a, 'genv, 'tcx> !UnwindSafe for RustItemCtxt<'a, 'genv, 'tcx>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more