Make Candidate
private
This commit is contained in:
parent
c7e6f88926
commit
5f90dbd5e8
3 changed files with 10 additions and 7 deletions
|
@ -659,7 +659,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
crate struct Candidate<'pat, 'tcx> {
|
struct Candidate<'pat, 'tcx> {
|
||||||
/// `Span` of the original pattern that gave rise to this candidate
|
/// `Span` of the original pattern that gave rise to this candidate
|
||||||
span: Span,
|
span: Span,
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||||
///
|
///
|
||||||
/// only generates a single switch. If this happens this method returns
|
/// only generates a single switch. If this happens this method returns
|
||||||
/// `true`.
|
/// `true`.
|
||||||
crate fn simplify_candidate<'pat>(&mut self, candidate: &mut Candidate<'pat, 'tcx>) -> bool {
|
pub(super) fn simplify_candidate<'pat>(
|
||||||
|
&mut self,
|
||||||
|
candidate: &mut Candidate<'pat, 'tcx>,
|
||||||
|
) -> bool {
|
||||||
// repeatedly simplify match pairs until fixed point is reached
|
// repeatedly simplify match pairs until fixed point is reached
|
||||||
loop {
|
loop {
|
||||||
let match_pairs = mem::take(&mut candidate.match_pairs);
|
let match_pairs = mem::take(&mut candidate.match_pairs);
|
||||||
|
|
|
@ -24,7 +24,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||||
/// Identifies what test is needed to decide if `match_pair` is applicable.
|
/// Identifies what test is needed to decide if `match_pair` is applicable.
|
||||||
///
|
///
|
||||||
/// It is a bug to call this with a simplifiable pattern.
|
/// It is a bug to call this with a simplifiable pattern.
|
||||||
crate fn test<'pat>(&mut self, match_pair: &MatchPair<'pat, 'tcx>) -> Test<'tcx> {
|
pub(super) fn test<'pat>(&mut self, match_pair: &MatchPair<'pat, 'tcx>) -> Test<'tcx> {
|
||||||
match *match_pair.pattern.kind {
|
match *match_pair.pattern.kind {
|
||||||
PatKind::Variant { ref adt_def, substs: _, variant_index: _, subpatterns: _ } => Test {
|
PatKind::Variant { ref adt_def, substs: _, variant_index: _, subpatterns: _ } => Test {
|
||||||
span: match_pair.pattern.span,
|
span: match_pair.pattern.span,
|
||||||
|
@ -81,7 +81,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
crate fn add_cases_to_switch<'pat>(
|
pub(super) fn add_cases_to_switch<'pat>(
|
||||||
&mut self,
|
&mut self,
|
||||||
test_place: &Place<'tcx>,
|
test_place: &Place<'tcx>,
|
||||||
candidate: &Candidate<'pat, 'tcx>,
|
candidate: &Candidate<'pat, 'tcx>,
|
||||||
|
@ -125,7 +125,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
crate fn add_variants_to_switch<'pat>(
|
pub(super) fn add_variants_to_switch<'pat>(
|
||||||
&mut self,
|
&mut self,
|
||||||
test_place: &Place<'tcx>,
|
test_place: &Place<'tcx>,
|
||||||
candidate: &Candidate<'pat, 'tcx>,
|
candidate: &Candidate<'pat, 'tcx>,
|
||||||
|
@ -152,7 +152,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
crate fn perform_test(
|
pub(super) fn perform_test(
|
||||||
&mut self,
|
&mut self,
|
||||||
block: BasicBlock,
|
block: BasicBlock,
|
||||||
place: &Place<'tcx>,
|
place: &Place<'tcx>,
|
||||||
|
@ -498,7 +498,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||||
/// that it *doesn't* apply. For now, we return false, indicate that the
|
/// that it *doesn't* apply. For now, we return false, indicate that the
|
||||||
/// test does not apply to this candidate, but it might be we can get
|
/// test does not apply to this candidate, but it might be we can get
|
||||||
/// tighter match code if we do something a bit different.
|
/// tighter match code if we do something a bit different.
|
||||||
crate fn sort_candidate<'pat>(
|
pub(super) fn sort_candidate<'pat>(
|
||||||
&mut self,
|
&mut self,
|
||||||
test_place: &Place<'tcx>,
|
test_place: &Place<'tcx>,
|
||||||
test: &Test<'tcx>,
|
test: &Test<'tcx>,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue