Struct rustc_mir_build::thir::pattern::PatCtxt [−][src]
pub(crate) struct PatCtxt<'a, 'tcx> {
pub(crate) tcx: TyCtxt<'tcx>,
pub(crate) param_env: ParamEnv<'tcx>,
pub(crate) typeck_results: &'a TypeckResults<'tcx>,
pub(crate) errors: Vec<PatternError>,
include_lint_checks: bool,
}
Fields
tcx: TyCtxt<'tcx>
param_env: ParamEnv<'tcx>
typeck_results: &'a TypeckResults<'tcx>
errors: Vec<PatternError>
include_lint_checks: bool
Implementations
Converts an evaluated constant to a pattern (if possible). This means aggregate values (like structs and enums) are converted to a pattern that matches the value (as if you’d compared via structural equality).
pub(crate) fn new(
tcx: TyCtxt<'tcx>,
param_env: ParamEnv<'tcx>,
typeck_results: &'a TypeckResults<'tcx>
) -> Self
fn lower_range_expr(
&mut self,
expr: &'tcx Expr<'tcx>
) -> (PatKind<'tcx>, Option<Ascription<'tcx>>)
fn lower_pattern_range(
&mut self,
ty: Ty<'tcx>,
lo: &'tcx Const<'tcx>,
hi: &'tcx Const<'tcx>,
end: RangeEnd,
span: Span
) -> PatKind<'tcx>
fn normalize_range_pattern_ends(
&self,
ty: Ty<'tcx>,
lo: Option<&PatKind<'tcx>>,
hi: Option<&PatKind<'tcx>>
) -> Option<(&'tcx Const<'tcx>, &'tcx Const<'tcx>)>
fn lower_tuple_subpats(
&mut self,
pats: &'tcx [Pat<'tcx>],
expected_len: usize,
gap_pos: Option<usize>
) -> Vec<FieldPat<'tcx>>
fn slice_or_array_pattern(
&mut self,
span: Span,
ty: Ty<'tcx>,
prefix: &'tcx [Pat<'tcx>],
slice: &'tcx Option<&'tcx Pat<'tcx>>,
suffix: &'tcx [Pat<'tcx>]
) -> PatKind<'tcx>
fn lower_variant_or_leaf(
&mut self,
res: Res,
hir_id: HirId,
span: Span,
ty: Ty<'tcx>,
subpatterns: Vec<FieldPat<'tcx>>
) -> PatKind<'tcx>
Takes a HIR Path. If the path is a constant, evaluates it and feeds
it to const_to_pat
. Any other path (like enum variants without fields)
is converted to the corresponding pattern via lower_variant_or_leaf
.
Trait Implementations
fn user_substs_applied_to_ty_of_hir_id(
&self,
hir_id: HirId
) -> Option<CanonicalUserType<'tcx>>
fn user_substs_applied_to_ty_of_hir_id(
&self,
hir_id: HirId
) -> Option<CanonicalUserType<'tcx>>
Looks up the type associated with this hir-id and applies the user-given substitutions; the hir-id must map to a suitable type. Read more
Auto Trait Implementations
impl<'a, 'tcx> !RefUnwindSafe for PatCtxt<'a, 'tcx>
impl<'a, 'tcx> !UnwindSafe for PatCtxt<'a, 'tcx>
Blanket Implementations
Layout
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.
Size: 56 bytes