Struct rustc_mir_build::thir::pattern::PatCtxt
source · struct PatCtxt<'a, 'tcx> {
tcx: TyCtxt<'tcx>,
param_env: ParamEnv<'tcx>,
typeck_results: &'a TypeckResults<'tcx>,
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§
source§impl PatCtxt<'_, '_>
impl PatCtxt<'_, '_>
fn report_inlining_errors(&self)
fn span_e0158(&self, span: Span, text: &str)
source§impl<'a, 'tcx> PatCtxt<'a, 'tcx>
impl<'a, 'tcx> PatCtxt<'a, 'tcx>
sourcepub(super) fn const_to_pat(
&self,
cv: ConstantKind<'tcx>,
id: HirId,
span: Span,
mir_structural_match_violation: bool
) -> Box<Pat<'tcx>>
pub(super) fn const_to_pat(
&self,
cv: ConstantKind<'tcx>,
id: HirId,
span: Span,
mir_structural_match_violation: bool
) -> Box<Pat<'tcx>>
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).
source§impl<'a, 'tcx> PatCtxt<'a, 'tcx>
impl<'a, 'tcx> PatCtxt<'a, 'tcx>
fn new(
tcx: TyCtxt<'tcx>,
param_env: ParamEnv<'tcx>,
typeck_results: &'a TypeckResults<'tcx>
) -> Self
fn include_lint_checks(&mut self) -> &mut Self
fn lower_pattern(&mut self, pat: &'tcx Pat<'tcx>) -> Box<Pat<'tcx>>
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: ConstantKind<'tcx>,
hi: ConstantKind<'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<(ConstantKind<'tcx>, ConstantKind<'tcx>)>
fn lower_pattern_unadjusted(&mut self, pat: &'tcx Pat<'tcx>) -> Box<Pat<'tcx>>
fn lower_tuple_subpats(
&mut self,
pats: &'tcx [Pat<'tcx>],
expected_len: usize,
gap_pos: DotDotPos
) -> Vec<FieldPat<'tcx>>
fn lower_patterns(&mut self, pats: &'tcx [Pat<'tcx>]) -> Box<[Box<Pat<'tcx>>]>
fn lower_opt_pattern(
&mut self,
pat: &'tcx Option<&'tcx Pat<'tcx>>
) -> Option<Box<Pat<'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>
sourcefn lower_path(
&mut self,
qpath: &QPath<'_>,
id: HirId,
span: Span
) -> Box<Pat<'tcx>>
fn lower_path(
&mut self,
qpath: &QPath<'_>,
id: HirId,
span: Span
) -> Box<Pat<'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§
source§impl<'tcx> UserAnnotatedTyHelpers<'tcx> for PatCtxt<'_, 'tcx>
impl<'tcx> UserAnnotatedTyHelpers<'tcx> for PatCtxt<'_, 'tcx>
fn tcx(&self) -> TyCtxt<'tcx>
fn typeck_results(&self) -> &TypeckResults<'tcx>
source§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> !Send for PatCtxt<'a, 'tcx>
impl<'a, 'tcx> !Sync for PatCtxt<'a, 'tcx>
impl<'a, 'tcx> Unpin for PatCtxt<'a, 'tcx>where
'tcx: 'a,
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