@@ -50,7 +50,8 @@ fn read_whole_file(&str filename) -> str {
50
50
}
51
51
52
52
fn write_file ( & str filename , & str content ) {
53
- ioivec:: file_writer ( filename, ~[ ioivec:: create] ) . write_str ( content) ;
53
+ ioivec:: file_writer ( filename, ~[ ioivec:: create,
54
+ ioivec:: truncate] ) . write_str ( content) ;
54
55
}
55
56
56
57
fn file_contains ( & str filename , & str needle ) -> bool {
@@ -149,6 +150,7 @@ fn devnull() -> ioivec::writer { std::ioivec::string_writer().get_writer() }
149
150
150
151
fn as_str ( fn ( ioivec:: writer) f) -> str { auto w = std:: ioivec:: string_writer ( ) ; f ( w. get_writer ( ) ) ; w. get_str ( ) }
151
152
153
+ /*
152
154
fn pp_variants(&ast::crate crate, &codemap::codemap cmap, &str filename) {
153
155
auto exprs = steal_exprs(crate);
154
156
auto exprsL = ivec::len(exprs);
@@ -163,26 +165,30 @@ fn pp_variants(&ast::crate crate, &codemap::codemap cmap, &str filename) {
163
165
}
164
166
}
165
167
}
168
+ */
166
169
167
- fn check_roundtrip( @ast:: crate crate2, & codemap:: codemap cmap, & str filename) {
168
- auto str3 = as_str( bind pprust:: print_crate( cmap, crate2, filename, _, pprust:: no_ann( ) ) ) ;
170
+ fn check_roundtrip( @ast:: crate cr1, & codemap:: codemap cm1, & str filename, & str str1) {
171
+ auto str2 = as_str ( bind pprust:: print_crate ( cm1, cr1, filename,
172
+ ioivec:: string_reader ( str1) , _,
173
+ pprust:: no_ann ( ) ) ) ;
169
174
if ( true
170
- && !contains( str3 , "][]" ) // https://github.com/graydon/rust/issues/669
171
- && !contains( str3 , "][mutable]" ) // https://github.com/graydon/rust/issues/669
172
- && !contains( str3 , "][mutable ]" ) // https://github.com/graydon/rust/issues/669
173
- && !contains( str3 , "self" ) // crazy rules enforced by parser rather than typechecker?
174
- && !contains( str3 , "spawn" ) // more precedence issues
175
- && !contains( str3 , "bind" ) // more precedence issues?
175
+ && !contains ( str2 , "][]" ) // https://github.com/graydon/rust/issues/669
176
+ && !contains ( str2 , "][mutable]" ) // https://github.com/graydon/rust/issues/669
177
+ && !contains ( str2 , "][mutable ]" ) // https://github.com/graydon/rust/issues/669
178
+ && !contains ( str2 , "self" ) // crazy rules enforced by parser rather than typechecker?
179
+ && !contains ( str2 , "spawn" ) // more precedence issues
180
+ && !contains ( str2 , "bind" ) // more precedence issues?
176
181
) {
177
- auto cm4 = codemap:: new_codemap( ) ;
178
- auto crate4 = parser:: parse_crate_from_source_str( filename, str3 , ~[ ] , cm4 ) ;
182
+ auto cm2 = codemap:: new_codemap ( ) ;
183
+ auto cr2 = parser:: parse_crate_from_source_str ( filename, str2 , ~[ ] , cm2 ) ;
179
184
// should compare crates at this point, but it's easier to compare strings
180
- auto str5 = as_str( bind pprust:: print_crate( cm4, crate4, filename, _, pprust:: no_ann( ) ) ) ;
185
+ auto str3 = as_str ( bind pprust:: print_crate ( cm2, cr2, filename, ioivec:: string_reader ( str2) ,
186
+ _, pprust:: no_ann ( ) ) ) ;
181
187
if ( !str :: is_ascii( str3) ) {
182
188
log_err "Non-ASCII in " + filename; // why does non-ASCII work correctly with "rustc --pretty normal" but not here???
183
- } else if ( str3 ! = str5 ) {
184
- write_file( "round-trip-a.rs" , str3 ) ;
185
- write_file( "round-trip-b.rs" , str5 ) ;
189
+ } else if ( str2 != str3 ) {
190
+ write_file ( "round-trip-a.rs" , str2 ) ;
191
+ write_file ( "round-trip-b.rs" , str3 ) ;
186
192
std:: run:: run_program ( "kdiff3" , [ "round-trip-a.rs" , "round-trip-b.rs" ] ) ;
187
193
fail "Mismatch" ;
188
194
}
@@ -201,14 +207,14 @@ fn main(vec[str] args) {
201
207
202
208
for ( str file in files) {
203
209
log_err "=== " + file + " ===" ;
204
- auto cm = codemap:: new_codemap( ) ;
205
- auto src = read_whole_file( file) ;
206
- auto crate = parser:: parse_crate_from_source_str( file, src , ~[ ] , cm ) ;
207
- if ( !contains( src , "#macro" ) // https://github.com/graydon/rust/issues/671
210
+ auto cm1 = codemap:: new_codemap( ) ;
211
+ auto str1 = read_whole_file( file) ;
212
+ auto cr1 = parser:: parse_crate_from_source_str( file, str1 , ~[ ] , cm1 ) ;
213
+ if ( !contains( str1 , "#macro" ) // https://github.com/graydon/rust/issues/671
208
214
&& !str:: ends_with( file, "block-expr-precedence.rs" ) // https://github.com/graydon/rust/issues/674
209
215
&& !str:: ends_with( file, "syntax-extension-fmt.rs" ) // an issue where -2147483648 gains an extra negative sign each time through, which i can't reproduce using "rustc --pretty normal"???
210
216
) {
211
- check_roundtrip( crate , cm , file) ;
217
+ check_roundtrip( cr1 , cm1 , file, str1 ) ;
212
218
}
213
219
//pprust::print_crate(cm, crate, file, devnull(), pprust::no_ann());
214
220
// Currently hits https://github.com/graydon/rust/issues/675
0 commit comments