@@ -21,46 +21,46 @@ use ty::TypeVariants::*;
2121/// Represents a set of DefIds closed under the ancestor relation. That is, if
2222/// a DefId is in this set then so are all its descendants.
2323#[ derive( Clone ) ]
24- pub struct DefIdForrest {
24+ pub struct DefIdForest {
2525 /// The minimal set of DefIds required to represent the whole set.
26- /// If A and B are DefIds in the DefIdForrest , and A is a desecendant
26+ /// If A and B are DefIds in the DefIdForest , and A is a desecendant
2727 /// of B, then only B will be in root_ids.
2828 /// We use a SmallVec here because (for its use in this module) its rare
2929 /// that this will contain even two ids.
3030 root_ids : SmallVec < [ DefId ; 1 ] > ,
3131}
3232
33- impl < ' a , ' gcx , ' tcx > DefIdForrest {
34- /// Create an empty forrest .
35- pub fn empty ( ) -> DefIdForrest {
36- DefIdForrest {
33+ impl < ' a , ' gcx , ' tcx > DefIdForest {
34+ /// Create an empty forest .
35+ pub fn empty ( ) -> DefIdForest {
36+ DefIdForest {
3737 root_ids : SmallVec :: new ( ) ,
3838 }
3939 }
4040
41- /// Create a forrest consisting of a single tree representing the entire
41+ /// Create a forest consisting of a single tree representing the entire
4242 /// crate.
4343 #[ inline]
44- pub fn full ( tcx : TyCtxt < ' a , ' gcx , ' tcx > ) -> DefIdForrest {
44+ pub fn full ( tcx : TyCtxt < ' a , ' gcx , ' tcx > ) -> DefIdForest {
4545 let crate_id = tcx. map . local_def_id ( CRATE_NODE_ID ) ;
46- DefIdForrest :: from_id ( crate_id)
46+ DefIdForest :: from_id ( crate_id)
4747 }
4848
49- /// Create a forrest containing a DefId and all its descendants.
50- pub fn from_id ( id : DefId ) -> DefIdForrest {
49+ /// Create a forest containing a DefId and all its descendants.
50+ pub fn from_id ( id : DefId ) -> DefIdForest {
5151 let mut root_ids = SmallVec :: new ( ) ;
5252 root_ids. push ( id) ;
53- DefIdForrest {
53+ DefIdForest {
5454 root_ids : root_ids,
5555 }
5656 }
5757
58- /// Test whether the forrest is empty.
58+ /// Test whether the forest is empty.
5959 pub fn is_empty ( & self ) -> bool {
6060 self . root_ids . is_empty ( )
6161 }
6262
63- /// Test whether the forrest conains a given DefId.
63+ /// Test whether the forest conains a given DefId.
6464 pub fn contains ( & self ,
6565 tcx : TyCtxt < ' a , ' gcx , ' tcx > ,
6666 id : DefId ) -> bool
@@ -73,25 +73,25 @@ impl<'a, 'gcx, 'tcx> DefIdForrest {
7373 false
7474 }
7575
76- /// Calculate the intersection of a collection of forrests .
76+ /// Calculate the intersection of a collection of forests .
7777 pub fn intersection < I > ( tcx : TyCtxt < ' a , ' gcx , ' tcx > ,
78- iter : I ) -> DefIdForrest
79- where I : IntoIterator < Item =DefIdForrest >
78+ iter : I ) -> DefIdForest
79+ where I : IntoIterator < Item =DefIdForest >
8080 {
81- let mut ret = DefIdForrest :: full ( tcx) ;
81+ let mut ret = DefIdForest :: full ( tcx) ;
8282 let mut next_ret = SmallVec :: new ( ) ;
8383 let mut old_ret: SmallVec < [ DefId ; 1 ] > = SmallVec :: new ( ) ;
84- for next_forrest in iter {
84+ for next_forest in iter {
8585 for id in ret. root_ids . drain ( ..) {
86- if next_forrest . contains ( tcx, id) {
86+ if next_forest . contains ( tcx, id) {
8787 next_ret. push ( id) ;
8888 } else {
8989 old_ret. push ( id) ;
9090 }
9191 }
9292 ret. root_ids . extend ( old_ret. drain ( ..) ) ;
9393
94- for id in next_forrest . root_ids {
94+ for id in next_forest . root_ids {
9595 if ret. contains ( tcx, id) {
9696 next_ret. push ( id) ;
9797 }
@@ -103,21 +103,21 @@ impl<'a, 'gcx, 'tcx> DefIdForrest {
103103 ret
104104 }
105105
106- /// Calculate the union of a collection of forrests .
106+ /// Calculate the union of a collection of forests .
107107 pub fn union < I > ( tcx : TyCtxt < ' a , ' gcx , ' tcx > ,
108- iter : I ) -> DefIdForrest
109- where I : IntoIterator < Item =DefIdForrest >
108+ iter : I ) -> DefIdForest
109+ where I : IntoIterator < Item =DefIdForest >
110110 {
111- let mut ret = DefIdForrest :: empty ( ) ;
111+ let mut ret = DefIdForest :: empty ( ) ;
112112 let mut next_ret = SmallVec :: new ( ) ;
113- for next_forrest in iter {
113+ for next_forest in iter {
114114 for id in ret. root_ids . drain ( ..) {
115- if !next_forrest . contains ( tcx, id) {
115+ if !next_forest . contains ( tcx, id) {
116116 next_ret. push ( id) ;
117117 }
118118 }
119119
120- for id in next_forrest . root_ids {
120+ for id in next_forest . root_ids {
121121 if !next_ret. contains ( & id) {
122122 next_ret. push ( id) ;
123123 }
@@ -131,18 +131,18 @@ impl<'a, 'gcx, 'tcx> DefIdForrest {
131131}
132132
133133impl < ' a , ' gcx , ' tcx > AdtDef {
134- /// Calculate the forrest of DefIds from which this adt is visibly uninhabited.
134+ /// Calculate the forest of DefIds from which this adt is visibly uninhabited.
135135 pub fn uninhabited_from (
136136 & self ,
137137 visited : & mut FxHashSet < ( DefId , & ' tcx Substs < ' tcx > ) > ,
138138 tcx : TyCtxt < ' a , ' gcx , ' tcx > ,
139- substs : & ' tcx Substs < ' tcx > ) -> DefIdForrest
139+ substs : & ' tcx Substs < ' tcx > ) -> DefIdForest
140140 {
141141 if !visited. insert ( ( self . did , substs) ) {
142- return DefIdForrest :: empty ( ) ;
142+ return DefIdForest :: empty ( ) ;
143143 }
144144
145- let ret = DefIdForrest :: intersection ( tcx, self . variants . iter ( ) . map ( |v| {
145+ let ret = DefIdForest :: intersection ( tcx, self . variants . iter ( ) . map ( |v| {
146146 v. uninhabited_from ( visited, tcx, substs, self . adt_kind ( ) )
147147 } ) ) ;
148148 visited. remove ( & ( self . did , substs) ) ;
@@ -151,27 +151,27 @@ impl<'a, 'gcx, 'tcx> AdtDef {
151151}
152152
153153impl < ' a , ' gcx , ' tcx > VariantDef {
154- /// Calculate the forrest of DefIds from which this variant is visibly uninhabited.
154+ /// Calculate the forest of DefIds from which this variant is visibly uninhabited.
155155 pub fn uninhabited_from (
156156 & self ,
157157 visited : & mut FxHashSet < ( DefId , & ' tcx Substs < ' tcx > ) > ,
158158 tcx : TyCtxt < ' a , ' gcx , ' tcx > ,
159159 substs : & ' tcx Substs < ' tcx > ,
160- adt_kind : AdtKind ) -> DefIdForrest
160+ adt_kind : AdtKind ) -> DefIdForest
161161 {
162162 match adt_kind {
163163 AdtKind :: Union => {
164- DefIdForrest :: intersection ( tcx, self . fields . iter ( ) . map ( |f| {
164+ DefIdForest :: intersection ( tcx, self . fields . iter ( ) . map ( |f| {
165165 f. uninhabited_from ( visited, tcx, substs, false )
166166 } ) )
167167 } ,
168168 AdtKind :: Struct => {
169- DefIdForrest :: union ( tcx, self . fields . iter ( ) . map ( |f| {
169+ DefIdForest :: union ( tcx, self . fields . iter ( ) . map ( |f| {
170170 f. uninhabited_from ( visited, tcx, substs, false )
171171 } ) )
172172 } ,
173173 AdtKind :: Enum => {
174- DefIdForrest :: union ( tcx, self . fields . iter ( ) . map ( |f| {
174+ DefIdForest :: union ( tcx, self . fields . iter ( ) . map ( |f| {
175175 f. uninhabited_from ( visited, tcx, substs, true )
176176 } ) )
177177 } ,
@@ -180,24 +180,24 @@ impl<'a, 'gcx, 'tcx> VariantDef {
180180}
181181
182182impl < ' a , ' gcx , ' tcx > FieldDef {
183- /// Calculate the forrest of DefIds from which this field is visibly uninhabited.
183+ /// Calculate the forest of DefIds from which this field is visibly uninhabited.
184184 pub fn uninhabited_from (
185185 & self ,
186186 visited : & mut FxHashSet < ( DefId , & ' tcx Substs < ' tcx > ) > ,
187187 tcx : TyCtxt < ' a , ' gcx , ' tcx > ,
188188 substs : & ' tcx Substs < ' tcx > ,
189- is_enum : bool ) -> DefIdForrest
189+ is_enum : bool ) -> DefIdForest
190190 {
191191 let mut data_uninhabitedness = move || self . ty ( tcx, substs) . uninhabited_from ( visited, tcx) ;
192192 if is_enum {
193193 data_uninhabitedness ( )
194194 } else {
195195 match self . vis {
196- Visibility :: Invisible => DefIdForrest :: empty ( ) ,
196+ Visibility :: Invisible => DefIdForest :: empty ( ) ,
197197 Visibility :: Restricted ( from) => {
198- let forrest = DefIdForrest :: from_id ( from) ;
199- let iter = Some ( forrest ) . into_iter ( ) . chain ( Some ( data_uninhabitedness ( ) ) ) ;
200- DefIdForrest :: intersection ( tcx, iter)
198+ let forest = DefIdForest :: from_id ( from) ;
199+ let iter = Some ( forest ) . into_iter ( ) . chain ( Some ( data_uninhabitedness ( ) ) ) ;
200+ DefIdForest :: intersection ( tcx, iter)
201201 } ,
202202 Visibility :: Public => data_uninhabitedness ( ) ,
203203 }
@@ -206,58 +206,58 @@ impl<'a, 'gcx, 'tcx> FieldDef {
206206}
207207
208208impl < ' a , ' gcx , ' tcx > TyS < ' tcx > {
209- /// Calculate the forrest of DefIds from which this type is visibly uninhabited.
209+ /// Calculate the forest of DefIds from which this type is visibly uninhabited.
210210 pub fn uninhabited_from (
211211 & self ,
212212 visited : & mut FxHashSet < ( DefId , & ' tcx Substs < ' tcx > ) > ,
213- tcx : TyCtxt < ' a , ' gcx , ' tcx > ) -> DefIdForrest
213+ tcx : TyCtxt < ' a , ' gcx , ' tcx > ) -> DefIdForest
214214 {
215215 match tcx. lift_to_global ( & self ) {
216216 Some ( global_ty) => {
217217 {
218218 let cache = tcx. inhabitedness_cache . borrow ( ) ;
219- if let Some ( forrest ) = cache. get ( & global_ty) {
220- return forrest . clone ( ) ;
219+ if let Some ( forest ) = cache. get ( & global_ty) {
220+ return forest . clone ( ) ;
221221 }
222222 }
223- let forrest = global_ty. uninhabited_from_inner ( visited, tcx) ;
223+ let forest = global_ty. uninhabited_from_inner ( visited, tcx) ;
224224 let mut cache = tcx. inhabitedness_cache . borrow_mut ( ) ;
225- cache. insert ( global_ty, forrest . clone ( ) ) ;
226- forrest
225+ cache. insert ( global_ty, forest . clone ( ) ) ;
226+ forest
227227 } ,
228228 None => {
229- let forrest = self . uninhabited_from_inner ( visited, tcx) ;
230- forrest
229+ let forest = self . uninhabited_from_inner ( visited, tcx) ;
230+ forest
231231 } ,
232232 }
233233 }
234234
235235 fn uninhabited_from_inner (
236236 & self ,
237237 visited : & mut FxHashSet < ( DefId , & ' tcx Substs < ' tcx > ) > ,
238- tcx : TyCtxt < ' a , ' gcx , ' tcx > ) -> DefIdForrest
238+ tcx : TyCtxt < ' a , ' gcx , ' tcx > ) -> DefIdForest
239239 {
240240 match self . sty {
241241 TyAdt ( def, substs) => {
242242 def. uninhabited_from ( visited, tcx, substs)
243243 } ,
244244
245- TyNever => DefIdForrest :: full ( tcx) ,
245+ TyNever => DefIdForest :: full ( tcx) ,
246246 TyTuple ( ref tys) => {
247- DefIdForrest :: union ( tcx, tys. iter ( ) . map ( |ty| {
247+ DefIdForest :: union ( tcx, tys. iter ( ) . map ( |ty| {
248248 ty. uninhabited_from ( visited, tcx)
249249 } ) )
250250 } ,
251251 TyArray ( ty, len) => {
252252 if len == 0 {
253- DefIdForrest :: empty ( )
253+ DefIdForest :: empty ( )
254254 } else {
255255 ty. uninhabited_from ( visited, tcx)
256256 }
257257 }
258258 TyRef ( _, ref tm) => tm. ty . uninhabited_from ( visited, tcx) ,
259259
260- _ => DefIdForrest :: empty ( ) ,
260+ _ => DefIdForest :: empty ( ) ,
261261 }
262262 }
263263}
0 commit comments