Skip to content

Commit 6efa354

Browse files
committed
auto merge of #4922 : jbclements/rust/add-deriving-eq-to-asts, r=catamorphism
r? Apply deriving_eq to the data structures in ast.rs, and get rid of the custom definitions of eq that were everywhere. resulting ast.rs is about 400 lines shorter. Also: add a few test cases and a bunch of comments. Also: change ast_ty_to_ty_cache to use node ids rather than ast::ty's. I believe this was a suggestion related to my changes, and it appears to pass all tests. Also: tiny doc fix, remove references to crate keywords.
2 parents 0ae74be + f9d789f commit 6efa354

File tree

10 files changed

+241
-555
lines changed

10 files changed

+241
-555
lines changed

Diff for: doc/rust.md

+1-7
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,7 @@ grammar as double-quoted strings. Other tokens have exact rules given.
202202

203203
### Keywords
204204

205-
The keywords in [crate files](#crate-files) are the following strings:
206-
207-
~~~~~~~~ {.keyword}
208-
mod priv pub use
209-
~~~~~~~~
210-
211-
The keywords in [source files](#source-files) are the following strings:
205+
The keywords are the following strings:
212206

213207
~~~~~~~~ {.keyword}
214208
as assert

Diff for: src/librustc/middle/ty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ struct ctxt_ {
262262
needs_drop_cache: HashMap<t, bool>,
263263
needs_unwind_cleanup_cache: HashMap<t, bool>,
264264
mut tc_cache: LinearMap<uint, TypeContents>,
265-
ast_ty_to_ty_cache: HashMap<@ast::Ty, ast_ty_to_ty_cache_entry>,
265+
ast_ty_to_ty_cache: HashMap<node_id, ast_ty_to_ty_cache_entry>,
266266
enum_var_cache: HashMap<def_id, @~[VariantInfo]>,
267267
trait_method_cache: HashMap<def_id, @~[method]>,
268268
ty_param_bounds: HashMap<ast::node_id, param_bounds>,

Diff for: src/librustc/middle/typeck/astconv.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ pub fn ast_ty_to_ty<AC: AstConv, RS: region_scope Copy Durable>(
277277

278278
let tcx = self.tcx();
279279

280-
match tcx.ast_ty_to_ty_cache.find(&ast_ty) {
280+
match tcx.ast_ty_to_ty_cache.find(&ast_ty.id) {
281281
Some(ty::atttce_resolved(ty)) => return ty,
282282
Some(ty::atttce_unresolved) => {
283283
tcx.sess.span_fatal(ast_ty.span, ~"illegal recursive type; \
@@ -287,7 +287,7 @@ pub fn ast_ty_to_ty<AC: AstConv, RS: region_scope Copy Durable>(
287287
None => { /* go on */ }
288288
}
289289

290-
tcx.ast_ty_to_ty_cache.insert(ast_ty, ty::atttce_unresolved);
290+
tcx.ast_ty_to_ty_cache.insert(ast_ty.id, ty::atttce_unresolved);
291291
let typ = match /*bad*/copy ast_ty.node {
292292
ast::ty_nil => ty::mk_nil(tcx),
293293
ast::ty_bot => ty::mk_bot(tcx),
@@ -409,7 +409,7 @@ pub fn ast_ty_to_ty<AC: AstConv, RS: region_scope Copy Durable>(
409409
}
410410
};
411411

412-
tcx.ast_ty_to_ty_cache.insert(ast_ty, ty::atttce_resolved(typ));
412+
tcx.ast_ty_to_ty_cache.insert(ast_ty.id, ty::atttce_resolved(typ));
413413
return typ;
414414
}
415415

0 commit comments

Comments
 (0)