@@ -188,23 +188,29 @@ pub fn to_str(input: @IdentInterner, t: &Token) -> ~str {
188
188
}
189
189
LIT_INT_UNSUFFIXED ( i) => { i. to_str ( ) }
190
190
LIT_FLOAT ( ref s, t) => {
191
- let mut body = ident_to_str ( s) . to_owned ( ) ;
191
+ let body_string = get_ident ( s. name ) ;
192
+ let mut body = body_string. get ( ) . to_str ( ) ;
192
193
if body. ends_with ( "." ) {
193
194
body. push_char ( '0' ) ; // `10.f` is not a float literal
194
195
}
195
196
body + ast_util:: float_ty_to_str ( t)
196
197
}
197
198
LIT_FLOAT_UNSUFFIXED ( ref s) => {
198
- let mut body = ident_to_str ( s) . to_owned ( ) ;
199
+ let body_string = get_ident ( s. name ) ;
200
+ let mut body = body_string. get ( ) . to_owned ( ) ;
199
201
if body. ends_with ( "." ) {
200
202
body. push_char ( '0' ) ; // `10.f` is not a float literal
201
203
}
202
204
body
203
205
}
204
- LIT_STR ( ref s) => { format ! ( "\" {}\" " , ident_to_str( s) . escape_default( ) ) }
206
+ LIT_STR ( ref s) => {
207
+ let literal_string = get_ident ( s. name ) ;
208
+ format ! ( "\" {}\" " , literal_string. get( ) . escape_default( ) )
209
+ }
205
210
LIT_STR_RAW ( ref s, n) => {
211
+ let literal_string = get_ident ( s. name ) ;
206
212
format ! ( "r{delim}\" {string}\" {delim}" ,
207
- delim="#" . repeat( n) , string=ident_to_str ( s ) )
213
+ delim="#" . repeat( n) , string=literal_string . get ( ) )
208
214
}
209
215
210
216
/* Name components */
@@ -213,7 +219,10 @@ pub fn to_str(input: @IdentInterner, t: &Token) -> ~str {
213
219
UNDERSCORE => ~"_",
214
220
215
221
/* Other */
216
- DOC_COMMENT ( ref s) => ident_to_str ( s) . to_owned ( ) ,
222
+ DOC_COMMENT ( ref s) => {
223
+ let comment_string = get_ident ( s. name ) ;
224
+ comment_string. get ( ) . to_str ( )
225
+ }
217
226
EOF => ~"<eof>",
218
227
INTERPOLATED(ref nt) => {
219
228
match nt {
@@ -647,11 +656,6 @@ pub fn interner_get(name : Name) -> @str {
647
656
get_ident_interner ( ) . get ( name)
648
657
}
649
658
650
- // maps an identifier to the string that it corresponds to
651
- pub fn ident_to_str ( id : & ast:: Ident ) -> @str {
652
- interner_get ( id. name )
653
- }
654
-
655
659
// maps a string to an identifier with an empty syntax context
656
660
pub fn str_to_ident ( str : & str ) -> ast:: Ident {
657
661
ast:: Ident :: new ( intern ( str) )
@@ -768,23 +772,4 @@ mod test {
768
772
let a1 = mark_ident ( a, 92 ) ;
769
773
assert ! ( mtwt_token_eq( & IDENT ( a, true ) , & IDENT ( a1, false ) ) ) ;
770
774
}
771
-
772
-
773
- #[ test] fn str_ptr_eq_tests ( ) {
774
- let a = @"abc";
775
- let b = @"abc";
776
- let c = a;
777
- assert ! ( str_ptr_eq( a, c) ) ;
778
- assert ! ( !str_ptr_eq( a, b) ) ;
779
- }
780
-
781
- #[ test] fn fresh_name_pointer_sharing ( ) {
782
- let ghi = str_to_ident ( "ghi" ) ;
783
- assert_eq ! ( ident_to_str( & ghi) , @"ghi" ) ;
784
- assert ! ( str_ptr_eq( ident_to_str( & ghi) , ident_to_str( & ghi) ) )
785
- let fresh = ast:: Ident :: new ( fresh_name ( & ghi) ) ;
786
- assert_eq ! ( ident_to_str( & fresh) , @"ghi" ) ;
787
- assert ! ( str_ptr_eq( ident_to_str( & ghi) , ident_to_str( & fresh) ) ) ;
788
- }
789
-
790
775
}
0 commit comments