@@ -994,7 +994,7 @@ impl ObjectTreeBuilder {
994994 & mut self ,
995995 location : Location ,
996996 parent : NodeIndex ,
997- child : & str ,
997+ child : & Ident ,
998998 len : usize ,
999999 ) -> NodeIndex {
10001000 if let Some ( & target) = self . inner [ parent] . children . get ( child) {
@@ -1100,24 +1100,24 @@ impl ObjectTreeBuilder {
11001100 )
11011101 }
11021102
1103- fn get_from_path < ' a , I : Iterator < Item = & ' a str > > (
1103+ fn get_from_path < I : Iterator < Item = Ident > > (
11041104 & mut self ,
11051105 location : Location ,
11061106 mut path : I ,
11071107 len : usize ,
1108- ) -> Result < ( NodeIndex , & ' a str ) , DMError > {
1108+ ) -> Result < ( NodeIndex , Ident ) , DMError > {
11091109 let mut current = NodeIndex :: new ( 0 ) ;
11101110 let mut last = match path. next ( ) {
11111111 Some ( name) => name,
11121112 None => return Err ( DMError :: new ( location, "cannot register root path" ) ) ,
11131113 } ;
1114- if is_decl ( last) {
1114+ if is_decl ( & last) {
11151115 return Ok ( ( current, last) ) ;
11161116 }
11171117 for each in path {
1118- current = self . subtype_or_add ( location, current, last, len) ;
1118+ current = self . subtype_or_add ( location, current, & last, len) ;
11191119 last = each;
1120- if is_decl ( last) {
1120+ if is_decl ( & last) {
11211121 break ;
11221122 }
11231123 }
@@ -1129,33 +1129,33 @@ impl ObjectTreeBuilder {
11291129 & mut self ,
11301130 location : Location ,
11311131 parent : NodeIndex ,
1132- mut prev : & ' a str ,
1132+ mut prev : Ident ,
11331133 mut rest : I ,
11341134 comment : DocCollection ,
11351135 suffix : VarSuffix ,
11361136 ) -> Result < Option < & mut TypeVar > , DMError >
11371137 where
1138- I : Iterator < Item = & ' a str > ,
1138+ I : Iterator < Item = Ident > ,
11391139 {
11401140 use super :: ast:: VarTypeFlags ;
11411141 let mut is_declaration = false ;
11421142 let mut flags = VarTypeFlags :: default ( ) ;
11431143
1144- if is_var_decl ( prev) {
1144+ if is_var_decl ( & prev) {
11451145 is_declaration = true ;
11461146 prev = match rest. next ( ) {
11471147 Some ( name) => name,
11481148 None => return Ok ( None ) , // var{} block, children will be real vars
11491149 } ;
1150- while let Some ( flag) = VarTypeFlags :: from_name ( prev) {
1150+ while let Some ( flag) = VarTypeFlags :: from_name ( & prev) {
11511151 if let Some ( name) = rest. next ( ) {
11521152 flags |= flag;
11531153 prev = name;
11541154 } else {
11551155 return Ok ( None ) ; // var/const{} block, children will be real vars
11561156 }
11571157 }
1158- } else if is_proc_decl ( prev) {
1158+ } else if is_proc_decl ( & prev) {
11591159 return Err ( DMError :: new ( location, "proc looks like a var" ) ) ;
11601160 }
11611161
@@ -1174,28 +1174,26 @@ impl ObjectTreeBuilder {
11741174 let symbols = & mut self . symbols ;
11751175 let node = & mut self . inner . graph [ parent. index ( ) ] ;
11761176 // TODO: warn and merge docs for repeats
1177- Ok ( Some (
1178- node. vars
1179- . entry ( Ident :: from_nonstatic ( prev) )
1180- . or_insert_with ( || TypeVar {
1181- value : VarValue {
1177+ Ok ( Some ( node. vars . entry ( prev. clone ( ) ) . or_insert_with ( || {
1178+ TypeVar {
1179+ value : VarValue {
1180+ location,
1181+ expression : suffix. into_initializer ( ) ,
1182+ constant : None ,
1183+ being_evaluated : false ,
1184+ docs : comment,
1185+ } ,
1186+ declaration : if is_declaration {
1187+ Some ( VarDeclaration {
1188+ var_type : var_type. build ( ) ,
11821189 location,
1183- expression : suffix. into_initializer ( ) ,
1184- constant : None ,
1185- being_evaluated : false ,
1186- docs : comment,
1187- } ,
1188- declaration : if is_declaration {
1189- Some ( VarDeclaration {
1190- var_type : var_type. build ( ) ,
1191- location,
1192- id : symbols. allocate ( ) ,
1193- } )
1194- } else {
1195- None
1196- } ,
1197- } ) ,
1198- ) )
1190+ id : symbols. allocate ( ) ,
1191+ } )
1192+ } else {
1193+ None
1194+ } ,
1195+ }
1196+ } ) ) )
11991197 }
12001198
12011199 // It's fine.
@@ -1205,21 +1203,18 @@ impl ObjectTreeBuilder {
12051203 context : & Context ,
12061204 location : Location ,
12071205 parent : NodeIndex ,
1208- name : & str ,
1206+ name : & Ident ,
12091207 declaration : Option < ProcDeclBuilder > ,
12101208 parameters : Vec < Parameter > ,
12111209 return_type : ProcReturnType ,
12121210 code : Option < Block > ,
12131211 body_range : Option < Range < Location > > ,
12141212 ) -> Result < ( usize , & mut ProcValue ) , DMError > {
12151213 let node = & mut self . inner . graph [ parent. index ( ) ] ;
1216- let proc = node
1217- . procs
1218- . entry ( Ident :: from_nonstatic ( name) )
1219- . or_insert_with ( || TypeProc {
1220- value : Vec :: with_capacity ( 1 ) ,
1221- declaration : None ,
1222- } ) ;
1214+ let proc = node. procs . entry ( name. clone ( ) ) . or_insert_with ( || TypeProc {
1215+ value : Vec :: with_capacity ( 1 ) ,
1216+ declaration : None ,
1217+ } ) ;
12231218 if let Some ( decl_builder) = declaration {
12241219 if let Some ( ref decl) = proc. declaration {
12251220 DMError :: new (
@@ -1283,24 +1278,24 @@ impl ObjectTreeBuilder {
12831278 pub ( crate ) fn add_builtin_type ( & mut self , elems : & [ & ' static str ] ) -> & mut Type {
12841279 self . add_type (
12851280 Location :: builtins ( ) ,
1286- elems. iter ( ) . cloned ( ) ,
1281+ elems. iter ( ) . copied ( ) . map ( Ident :: from ) ,
12871282 elems. len ( ) + 1 ,
12881283 Default :: default ( ) ,
12891284 )
12901285 . unwrap ( )
12911286 }
12921287
12931288 // an entry which may be anything depending on the path
1294- fn add_type < ' a , I : Iterator < Item = & ' a str > > (
1289+ fn add_type < I : Iterator < Item = Ident > > (
12951290 & mut self ,
12961291 location : Location ,
12971292 mut path : I ,
12981293 len : usize ,
12991294 comment : DocCollection ,
13001295 ) -> Result < & mut Type , DMError > {
13011296 let ( parent, child) = self . get_from_path ( location, & mut path, len) ?;
1302- assert ! ( !is_var_decl( child) && !is_proc_decl( child) ) ;
1303- let idx = self . subtype_or_add ( location, parent, child, len) ;
1297+ assert ! ( !is_var_decl( & child) && !is_proc_decl( & child) ) ;
1298+ let idx = self . subtype_or_add ( location, parent, & child, len) ;
13041299 self . inner [ idx] . docs . extend ( comment) ;
13051300 Ok ( & mut self . inner [ idx] )
13061301 }
@@ -1311,7 +1306,7 @@ impl ObjectTreeBuilder {
13111306 value : Option < Constant > ,
13121307 ) -> & mut VarValue {
13131308 let location = Location :: builtins ( ) ;
1314- let mut path = elems. iter ( ) . copied ( ) ;
1309+ let mut path = elems. iter ( ) . copied ( ) . map ( Ident :: from ) ;
13151310 let len = elems. len ( ) + 1 ;
13161311
13171312 let ( parent, initial) = self . get_from_path ( location, & mut path, len) . unwrap ( ) ;
@@ -1342,7 +1337,7 @@ impl ObjectTreeBuilder {
13421337 self . add_proc (
13431338 & Default :: default ( ) ,
13441339 Location :: builtins ( ) ,
1345- elems. iter ( ) . copied ( ) ,
1340+ elems. iter ( ) . copied ( ) . map ( Ident :: from ) ,
13461341 elems. len ( ) + 1 ,
13471342 params
13481343 . iter ( )
@@ -1361,7 +1356,7 @@ impl ObjectTreeBuilder {
13611356
13621357 // an entry which is definitely a proc because an argument list is specified
13631358 #[ allow( clippy:: too_many_arguments) ]
1364- fn add_proc < ' a , I : Iterator < Item = & ' a str > > (
1359+ fn add_proc < I : Iterator < Item = Ident > > (
13651360 & mut self ,
13661361 context : & Context ,
13671362 location : Location ,
@@ -1373,9 +1368,9 @@ impl ObjectTreeBuilder {
13731368 ) -> Result < ( usize , & mut ProcValue ) , DMError > {
13741369 let ( parent, mut proc_name) = self . get_from_path ( location, & mut path, len) ?;
13751370 let mut declaration = None ;
1376- if let Some ( kind) = ProcDeclKind :: from_name ( proc_name) {
1371+ if let Some ( kind) = ProcDeclKind :: from_name ( & proc_name) {
13771372 let mut next_entry = path. next ( ) ;
1378- let flags = ProcFlags :: from_name ( next_entry. unwrap_or ( "" ) ) ;
1373+ let flags = ProcFlags :: from_name ( next_entry. as_ref ( ) . map_or ( "" , Ident :: as_str ) ) ;
13791374 if flags. is_some ( ) {
13801375 // did something? take another step
13811376 next_entry = path. next ( ) ;
@@ -1385,7 +1380,7 @@ impl ObjectTreeBuilder {
13851380 Some ( name) => name,
13861381 None => return Err ( DMError :: new ( location, "proc must have a name" ) ) ,
13871382 } ;
1388- } else if is_var_decl ( proc_name) {
1383+ } else if is_var_decl ( & proc_name) {
13891384 return Err ( DMError :: new ( location, "var looks like a proc" ) ) ;
13901385 }
13911386 if let Some ( other) = path. next ( ) {
@@ -1399,7 +1394,7 @@ impl ObjectTreeBuilder {
13991394 context,
14001395 location,
14011396 parent,
1402- proc_name,
1397+ & proc_name,
14031398 declaration,
14041399 parameters,
14051400 ProcReturnType :: default ( ) ,
0 commit comments