RustItemCtxt

Struct RustItemCtxt 

Source
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, '_>

Source

pub(crate) fn lift_item(&mut self) -> Result<Item<'genv>, ErrorGuaranteed>

Source

pub(crate) fn lift_trait_item(&mut self) -> TraitItem<'genv>

Source

pub(crate) fn lift_impl_item(&mut self) -> ImplItem<'genv>

Source

pub(crate) fn lift_generics(&mut self) -> Generics<'genv>

Source

pub(crate) fn lift_generic_param( &mut self, param: &GenericParam<'_>, ) -> GenericParam<'genv>

Source

fn lift_generics_inner(&mut self, generics: &Generics<'_>) -> Generics<'genv>

Source

fn lift_generic_bound( &mut self, bound: &GenericBound<'_>, ) -> Result<GenericBound<'genv>, ErrorGuaranteed>

Source

fn lift_poly_trait_ref( &mut self, poly_trait_ref: PolyTraitRef<'_>, ) -> Result<PolyTraitRef<'genv>, ErrorGuaranteed>

Source

fn lift_opaque_ty( &mut self, opaque_ty: &OpaqueTy<'_>, ) -> Result<OpaqueTy<'genv>, ErrorGuaranteed>

Source

pub(crate) fn lift_fn_header(&mut self) -> FnHeader

Source

pub(crate) fn lift_fn_decl(&mut self) -> FnDecl<'genv>

Source

fn lift_fn_decl_inner(&mut self, span: Span, decl: &FnDecl<'_>) -> FnDecl<'genv>

Source

fn lift_fn_ret_ty(&mut self, ret_ty: &FnRetTy<'_>) -> Ty<'genv>

Source

fn lift_type_alias(&mut self, span: Span, ty: &Ty<'_>) -> TyAlias<'genv>

Source

fn lift_struct_def(&mut self, variant_data: VariantData<'_>) -> StructDef<'genv>

Source

pub(crate) fn lift_field_def( &mut self, field_def: &FieldDef<'_>, ) -> FieldDef<'genv>

Source

fn lift_enum_def(&mut self, enum_def: EnumDef<'_>) -> EnumDef<'genv>

Source

pub(crate) fn lift_enum_variant( &mut self, variant: &Variant<'_>, ) -> VariantDef<'genv>

Source

pub(crate) fn lift_variant_ret(&mut self) -> VariantRet<'genv>

Source

fn lift_variant_ret_inner( &mut self, generics: &Generics<'_>, ) -> VariantRet<'genv>

Source

fn lift_ty(&mut self, ty: &Ty<'_>) -> Ty<'genv>

Source

fn lift_bare_fn(&mut self, span: Span, fn_ptr: &FnPtrTy<'_>) -> BareFnTy<'genv>

Source

fn lift_lifetime(&self, lft: &Lifetime) -> Lifetime

Source

fn lift_mut_ty(&mut self, mut_ty: MutTy<'_>) -> MutTy<'genv>

Source

fn lift_qpath( &mut self, qpath: QPath<'_>, ) -> Result<QPath<'genv>, ErrorGuaranteed>

Source

fn lift_path(&mut self, path: &Path<'_>) -> Result<Path<'genv>, ErrorGuaranteed>

Source

fn lift_path_segment( &mut self, segment: &PathSegment<'_>, ) -> Result<PathSegment<'genv>, ErrorGuaranteed>

Source

fn lift_generic_args( &mut self, args: &[GenericArg<'_>], ) -> Result<&'genv [GenericArg<'genv>], ErrorGuaranteed>

Source

fn lift_assoc_item_constraints( &mut self, constraints: &[AssocItemConstraint<'_>], ) -> Result<&'genv [AssocItemConstraint<'genv>], ErrorGuaranteed>

Source

fn lift_const_arg(&mut self, const_arg: &ConstArg<'_>) -> ConstArg

Source

fn emit_unsupported(&self, note: &str) -> ErrorGuaranteed

Source

fn next_fhir_id(&self) -> FhirId

Source

fn local_id(&self) -> LocalDefId

Source

fn lift_fn_sig(&mut self, fn_sig: FnSig<'_>) -> FnSig<'genv>

Source

pub(crate) fn lift_foreign_item( &mut self, foreign_item: ForeignItem<'_>, ) -> Result<ForeignItem<'genv>, ErrorGuaranteed>

Source

fn fix_maybe_extern_id_in_res(&self, res: Res) -> Res

Fixes the def ids inside res to point to resolved ids.

Source

fn fix_maybe_extern_id(&self, def_id: DefId) -> DefId

Fixes a DefId that may correspond to a dummy local item for an extern spec to be the “resolved id”. This is to upholad the invariant that a DefId always corresponds to the resolved item.

Source§

impl<'a, 'genv, 'tcx: 'genv> RustItemCtxt<'a, 'genv, 'tcx>

Source

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>

Source

pub(crate) fn desugar_item( &mut self, item: &Item, ) -> Result<Item<'genv>, ErrorGuaranteed>

Source

pub(crate) fn desugar_trait_item( &mut self, item: &TraitItemFn, ) -> Result<TraitItem<'genv>, ErrorGuaranteed>

Source

pub(crate) fn desugar_impl_item( &mut self, item: &ImplItemFn, ) -> Result<ImplItem<'genv>, ErrorGuaranteed>

Source

fn desugar_trait( &mut self, trait_: &Trait, ) -> Result<Item<'genv>, ErrorGuaranteed>

Source

fn desugar_trait_assoc_refts( &mut self, assoc_refts: &[TraitAssocReft], ) -> Result<&'genv [TraitAssocReft<'genv>], ErrorGuaranteed>

Source

fn desugar_impl(&mut self, impl_: &Impl) -> Item<'genv>

Source

fn desugar_impl_assoc_refts( &mut self, assoc_refts: &[ImplAssocReft], ) -> &'genv [ImplAssocReft<'genv>]

Source

fn desugar_generics(&mut self, generics: &Generics) -> Generics<'genv>

Source

fn desugar_opt_generics( &mut self, generics: Option<&Generics>, ) -> Generics<'genv>

Source

fn desugar_generic_predicates( &mut self, predicates: &[WhereBoundPredicate], ) -> &'genv [WhereBoundPredicate<'genv>]

Source

fn desugar_generic_bounds( &mut self, bounds: &[TraitRef], ) -> GenericBounds<'genv>

Source

fn desugar_trait_ref(&mut self, trait_ref: &TraitRef) -> PolyTraitRef<'genv>

Source

fn desugar_refined_by(&mut self, refined_by: &RefineParams) -> RefinedBy<'genv>

Source

fn desugar_struct_def(&mut self, struct_def: &StructDef) -> Item<'genv>

Source

fn desugar_enum_def( &mut self, enum_def: &EnumDef, ) -> Result<Item<'genv>, ErrorGuaranteed>

Source

fn desugar_enum_variant_def( &mut self, reflected: bool, variant_def: &Option<VariantDef>, hir_variant: &Variant<'_>, ) -> Result<VariantDef<'genv>, ErrorGuaranteed>

Source

fn desugar_type_alias(&mut self, ty_alias: &TyAlias) -> Item<'genv>

Source

fn desugar_const(&mut self, const_info: &ConstantInfo) -> Item<'genv>

Source

fn desugar_fn_sig( &mut self, fn_sig: Option<&FnSig>, ) -> Result<(Generics<'genv>, FnSig<'genv>), ErrorGuaranteed>

Source

fn desugar_fn_sig_refine_params( &mut self, fn_sig: &FnSig, ) -> &'genv [RefineParam<'genv>]

Source

fn desugar_fn_output( &mut self, asyncness: Async, output: &FnOutput, ) -> Result<FnOutput<'genv>, ErrorGuaranteed>

Source

fn desugar_ensures( &mut self, cstr: &Ensures, ) -> Result<Ensures<'genv>, ErrorGuaranteed>

Source

fn desugar_fn_input(&mut self, input: &FnInput) -> Ty<'genv>

Source

fn desugar_asyncness( &mut self, asyncness: Async, returns: &FnRetTy, ) -> Ty<'genv>

Source

fn desugar_opaque_ty_for_async( &mut self, def_id: LocalDefId, returns: &FnRetTy, ) -> OpaqueTy<'genv>

Source

fn make_lang_item_path( &mut self, lang_item: LangItem, span: Span, args: &'genv [GenericArg<'genv>], constraints: &'genv [AssocItemConstraint<'genv>], ) -> Path<'genv>

Source

fn desugar_fn_ret_ty(&mut self, returns: &FnRetTy) -> Ty<'genv>

Source

fn desugar_opaque_ty_for_impl_trait( &mut self, def_id: LocalDefId, bounds: &[TraitRef], ) -> OpaqueTy<'genv>

Source

fn desugar_variant_ret( &mut self, ret: &VariantRet, ) -> Result<VariantRet<'genv>, ErrorGuaranteed>

Source

fn check_variant_ret_path(&mut self, path: &Path) -> Option<DefId>

Source

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>

Source§

fn next_fhir_id(&self) -> FhirId

Source§

fn genv(&self) -> GlobalEnv<'genv, 'tcx>

Source§

fn resolver_output(&self) -> &'genv ResolverOutput

Source§

fn desugar_impl_trait(&mut self, bounds: &[TraitRef]) -> TyKind<'genv>

Source§

fn allow_primop_app(&self) -> bool

Source§

fn resolve_implicit_param( &self, node_id: NodeId, ) -> Option<(ParamId, ParamKind)>

Source§

fn desugar_epath(&self, path: &ExprPath) -> QPathExpr<'genv>

Source§

fn desugar_loc( &self, ident: Ident, node_id: NodeId, ) -> Result<Res<ParamId>, ErrorGuaranteed>

Source§

fn resolve_param(&self, node_id: NodeId) -> (ParamId, ParamKind)

Source§

fn resolve_implicit_params( &self, scope: NodeId, ) -> impl ExactSizeIterator<Item = (Ident, ParamId, ParamKind)>

Source§

fn implicit_params_to_params( &self, scope: NodeId, ) -> impl ExactSizeIterator<Item = RefineParam<'genv>>

Source§

fn desugar_refine_params( &mut self, params: &[RefineParam], ) -> &'genv [RefineParam<'genv>]

Source§

fn desugar_refine_params_iter( &mut self, params: &[RefineParam], ) -> impl ExactSizeIterator<Item = RefineParam<'genv>>

Source§

fn desugar_refine_param(&mut self, param: &RefineParam) -> RefineParam<'genv>

Source§

fn desugar_sort( &mut self, sort: &Sort, generic_id_to_var_idx: Option<&FxIndexSet<DefId>>, ) -> Sort<'genv>

Source§

fn desugar_base_sort( &mut self, sort: &BaseSort, generic_id_to_var_idx: Option<&FxIndexSet<DefId>>, ) -> Sort<'genv>

Source§

fn desugar_generic_args( &mut self, res: Res, args: &[GenericArg], ) -> (&'genv [GenericArg<'genv>], &'genv [AssocItemConstraint<'genv>])

Source§

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>

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.
Source§

fn desugar_const_arg(const_arg: &ConstArg) -> ConstArg

Source§

fn desugar_bty(&mut self, bty: &BaseTy) -> BaseTy<'genv>

Source§

fn desugar_path_to_bty( &mut self, qself: Option<&Ty>, path: &Path, ) -> BaseTy<'genv>

Source§

fn desugar_qpath(&mut self, qself: Option<&Ty>, path: &Path) -> QPath<'genv>

Source§

fn desugar_path_segment(&mut self, segment: &PathSegment) -> PathSegment<'genv>

Source§

fn desugar_epath_segment(&self, segment: &ExprPathSegment) -> PathSegment<'genv>

Source§

fn ty_path(&self, qpath: QPath<'genv>) -> Ty<'genv>

Source§

fn mk_lft_hole(&self) -> Lifetime

Source§

fn desugar_indices(&mut self, idxs: &Indices) -> Expr<'genv>

Source§

fn desugar_refine_arg(&mut self, arg: &RefineArg) -> Expr<'genv>

Source§

fn implicit_param_into_refine_arg( &self, ident: Ident, node_id: NodeId, ) -> Option<Expr<'genv>>

Source§

fn desugar_expr(&mut self, expr: &Expr) -> Expr<'genv>

Source§

fn desugar_call(&mut self, callee: &Expr, args: &[Expr]) -> ExprKind<'genv>

Source§

fn desugar_constructor( &mut self, path: Option<&ExprPath>, args: &[ConstructorArg], ) -> ExprKind<'genv>

Source§

fn desugar_exprs(&mut self, exprs: &[Expr]) -> &'genv [Expr<'genv>]

Source§

fn try_parse_int_lit( &self, span: Span, s: &str, ) -> Result<u128, ErrorGuaranteed>

Source§

fn desugar_lit(&self, span: Span, lit: Lit) -> ExprKind<'genv>

Desugar surface literal
Source§

impl ErrorCollector<ErrorGuaranteed> for RustItemCtxt<'_, '_, '_>

Source§

impl ErrorEmitter for RustItemCtxt<'_, '_, '_>

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more