Skip to content

Commit 136abb9

Browse files
committed
Made some bits of the auto trait machinery public.
1 parent 7365bee commit 136abb9

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/librustc/traits/auto_trait.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@ use ty::fold::TypeFolder;
2525

2626
// TODO(twk): this is obviously not nice to duplicate like that
2727
#[derive(Eq, PartialEq, Hash, Copy, Clone, Debug)]
28-
enum RegionTarget<'tcx> {
28+
pub enum RegionTarget<'tcx> {
2929
Region(Region<'tcx>),
3030
RegionVid(RegionVid)
3131
}
3232

3333
#[derive(Default, Debug, Clone)]
34-
struct RegionDeps<'tcx> {
34+
pub struct RegionDeps<'tcx> {
3535
larger: FxHashSet<RegionTarget<'tcx>>,
3636
smaller: FxHashSet<RegionTarget<'tcx>>
3737
}
3838

39-
enum AutoTraitResult {
39+
pub enum AutoTraitResult {
4040
ExplicitImpl,
4141
PositiveImpl, /*(ty::Generics), TODO(twk)*/
4242
NegativeImpl,
@@ -56,7 +56,7 @@ pub struct AutoTraitFinder<'a, 'tcx: 'a> {
5656
}
5757

5858
impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
59-
fn find_auto_trait_generics(
59+
pub fn find_auto_trait_generics(
6060
&self,
6161
did: DefId,
6262
trait_did: DefId,
@@ -277,9 +277,9 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
277277
// the final synthesized generics: we don't want our generated docs page to contain something
278278
// like 'T: Copy + Clone', as that's redundant. Therefore, we keep track of a separate
279279
// 'user_env', which only holds the predicates that will actually be displayed to the user.
280-
fn evaluate_predicates<'b, 'gcx, 'c>(
280+
pub fn evaluate_predicates<'b, 'gcx, 'c>(
281281
&self,
282-
infcx: &mut InferCtxt<'b, 'tcx, 'c>,
282+
infcx: & InferCtxt<'b, 'tcx, 'c>,
283283
ty_did: DefId,
284284
trait_did: DefId,
285285
ty: ty::Ty<'c>,
@@ -387,7 +387,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
387387
// starting conditions (e.g. user-provided code). For this reason, it's easier
388388
// to perform the calculations we need on our own, rather than trying to make
389389
// existing inference/solver code do what we want.
390-
fn handle_lifetimes<'cx>(
390+
pub fn handle_lifetimes<'cx>(
391391
&self,
392392
regions: &RegionConstraintData<'cx>,
393393
names_map: &FxHashMap<String, String>, // TODO(twk): lifetime branding
@@ -533,15 +533,15 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
533533
lifetime_predicates
534534
}
535535

536-
fn region_name(&self, region: Region) -> Option<String> {
536+
pub fn region_name(&self, region: Region) -> Option<String> {
537537
match region {
538538
&ty::ReEarlyBound(r) => Some(r.name.as_str().to_string()),
539539
_ => None,
540540
}
541541
}
542542

543543
// TODO(twk): lifetime branding
544-
fn get_lifetime(&self, region: Region, names_map: &FxHashMap<String, String>) -> String {
544+
pub fn get_lifetime(&self, region: Region, names_map: &FxHashMap<String, String>) -> String {
545545
self.region_name(region)
546546
.map(|name| {
547547
names_map.get(&name).unwrap_or_else(|| {
@@ -555,7 +555,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
555555

556556
// This is very similar to handle_lifetimes. However, instead of matching ty::Region's
557557
// to each other, we match ty::RegionVid's to ty::Region's
558-
fn map_vid_to_region<'cx>(
558+
pub fn map_vid_to_region<'cx>(
559559
&self,
560560
regions: &RegionConstraintData<'cx>,
561561
) -> FxHashMap<ty::RegionVid, ty::Region<'cx>> {
@@ -655,7 +655,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
655655
finished_map
656656
}
657657

658-
fn is_of_param(&self, substs: &Substs) -> bool {
658+
pub fn is_of_param(&self, substs: &Substs) -> bool {
659659
if substs.is_noop() {
660660
return false;
661661
}
@@ -667,7 +667,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
667667
};
668668
}
669669

670-
fn evaluate_nested_obligations<'b, 'c, 'd, 'cx,
670+
pub fn evaluate_nested_obligations<'b, 'c, 'd, 'cx,
671671
T: Iterator<Item = Obligation<'cx, ty::Predicate<'cx>>>>(
672672
&self,
673673
ty: ty::Ty,
@@ -775,7 +775,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
775775
return true;
776776
}
777777

778-
fn clean_pred<'c, 'd, 'cx>(
778+
pub fn clean_pred<'c, 'd, 'cx>(
779779
&self,
780780
infcx: &InferCtxt<'c, 'd, 'cx>,
781781
p: ty::Predicate<'cx>,
@@ -785,7 +785,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
785785
}
786786

787787
// Replaces all ReVars in a type with ty::Region's, using the provided map
788-
struct RegionReplacer<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
788+
pub struct RegionReplacer<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
789789
vid_to_region: &'a FxHashMap<ty::RegionVid, ty::Region<'tcx>>,
790790
tcx: TyCtxt<'a, 'gcx, 'tcx>,
791791
}

0 commit comments

Comments
 (0)