From 5f90dbd5e86a5ba68ec03cef5dd2c2418f587dbb Mon Sep 17 00:00:00 2001 From: Matthew Jasper Date: Sun, 29 Dec 2019 17:00:23 +0000 Subject: [PATCH] Make `Candidate` private --- src/librustc_mir_build/build/matches/mod.rs | 2 +- src/librustc_mir_build/build/matches/simplify.rs | 5 ++++- src/librustc_mir_build/build/matches/test.rs | 10 +++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/librustc_mir_build/build/matches/mod.rs b/src/librustc_mir_build/build/matches/mod.rs index 928363246c2c..7e7035e89abe 100644 --- a/src/librustc_mir_build/build/matches/mod.rs +++ b/src/librustc_mir_build/build/matches/mod.rs @@ -659,7 +659,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } #[derive(Debug)] -crate struct Candidate<'pat, 'tcx> { +struct Candidate<'pat, 'tcx> { /// `Span` of the original pattern that gave rise to this candidate span: Span, diff --git a/src/librustc_mir_build/build/matches/simplify.rs b/src/librustc_mir_build/build/matches/simplify.rs index 3a806ab6bff0..d3ed7c4daf7e 100644 --- a/src/librustc_mir_build/build/matches/simplify.rs +++ b/src/librustc_mir_build/build/matches/simplify.rs @@ -38,7 +38,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// /// only generates a single switch. If this happens this method returns /// `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 loop { let match_pairs = mem::take(&mut candidate.match_pairs); diff --git a/src/librustc_mir_build/build/matches/test.rs b/src/librustc_mir_build/build/matches/test.rs index ff95f1622575..dd0102e1c410 100644 --- a/src/librustc_mir_build/build/matches/test.rs +++ b/src/librustc_mir_build/build/matches/test.rs @@ -24,7 +24,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// Identifies what test is needed to decide if `match_pair` is applicable. /// /// 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 { PatKind::Variant { ref adt_def, substs: _, variant_index: _, subpatterns: _ } => Test { 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, test_place: &Place<'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, test_place: &Place<'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, block: BasicBlock, 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 /// test does not apply to this candidate, but it might be we can get /// tighter match code if we do something a bit different. - crate fn sort_candidate<'pat>( + pub(super) fn sort_candidate<'pat>( &mut self, test_place: &Place<'tcx>, test: &Test<'tcx>,