Skip to content

Commit

Permalink
Move TraitRef impl next to struct definition.
Browse files Browse the repository at this point in the history
  • Loading branch information
frewsxcv committed Feb 20, 2017
1 parent 23d9211 commit a754ea6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
18 changes: 0 additions & 18 deletions src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1086,24 +1086,6 @@ impl<'tcx> InstantiatedPredicates<'tcx> {
}
}

impl<'tcx> TraitRef<'tcx> {
pub fn new(def_id: DefId, substs: &'tcx Substs<'tcx>) -> TraitRef<'tcx> {
TraitRef { def_id: def_id, substs: substs }
}

pub fn self_ty(&self) -> Ty<'tcx> {
self.substs.type_at(0)
}

pub fn input_types<'a>(&'a self) -> impl DoubleEndedIterator<Item=Ty<'tcx>> + 'a {
// Select only the "input types" from a trait-reference. For
// now this is all the types that appear in the
// trait-reference, but it should eventually exclude
// associated types.
self.substs.types()
}
}

/// When type checking, we use the `ParameterEnvironment` to track
/// details about the type/lifetime parameters that are in scope.
/// It primarily stores the bounds information.
Expand Down
18 changes: 18 additions & 0 deletions src/librustc/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,24 @@ pub struct TraitRef<'tcx> {
pub substs: &'tcx Substs<'tcx>,
}

impl<'tcx> TraitRef<'tcx> {
pub fn new(def_id: DefId, substs: &'tcx Substs<'tcx>) -> TraitRef<'tcx> {
TraitRef { def_id: def_id, substs: substs }
}

pub fn self_ty(&self) -> Ty<'tcx> {
self.substs.type_at(0)
}

pub fn input_types<'a>(&'a self) -> impl DoubleEndedIterator<Item=Ty<'tcx>> + 'a {
// Select only the "input types" from a trait-reference. For
// now this is all the types that appear in the
// trait-reference, but it should eventually exclude
// associated types.
self.substs.types()
}
}

pub type PolyTraitRef<'tcx> = Binder<TraitRef<'tcx>>;

impl<'tcx> PolyTraitRef<'tcx> {
Expand Down

0 comments on commit a754ea6

Please sign in to comment.