Skip to content

Commit cc9999c

Browse files
committed
librustc: De-record the type context. rs=derecordification
1 parent 684aa2b commit cc9999c

File tree

1 file changed

+108
-105
lines changed

1 file changed

+108
-105
lines changed

src/librustc/middle/ty.rs

Lines changed: 108 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -233,72 +233,74 @@ pub struct InstantiatedTraitRef {
233233
tpt: ty_param_substs_and_ty
234234
}
235235

236-
pub type ctxt =
237-
@{diag: syntax::diagnostic::span_handler,
238-
interner: HashMap<intern_key, t_box>,
239-
mut next_id: uint,
240-
vecs_implicitly_copyable: bool,
241-
legacy_modes: bool,
242-
legacy_records: bool,
243-
cstore: metadata::cstore::CStore,
244-
sess: session::Session,
245-
def_map: resolve::DefMap,
246-
247-
region_map: middle::region::region_map,
248-
region_paramd_items: middle::region::region_paramd_items,
249-
250-
// Stores the types for various nodes in the AST. Note that this table
251-
// is not guaranteed to be populated until after typeck. See
252-
// typeck::check::fn_ctxt for details.
253-
node_types: node_type_table,
254-
255-
// Stores the type parameters which were substituted to obtain the type
256-
// of this node. This only applies to nodes that refer to entities
257-
// parameterized by type parameters, such as generic fns, types, or
258-
// other items.
259-
node_type_substs: HashMap<node_id, ~[t]>,
260-
261-
items: ast_map::map,
262-
intrinsic_defs: HashMap<ast::ident, (ast::def_id, t)>,
263-
freevars: freevars::freevar_map,
264-
tcache: type_cache,
265-
rcache: creader_cache,
266-
ccache: constness_cache,
267-
short_names_cache: HashMap<t, @~str>,
268-
needs_drop_cache: HashMap<t, bool>,
269-
needs_unwind_cleanup_cache: HashMap<t, bool>,
270-
kind_cache: HashMap<t, Kind>,
271-
ast_ty_to_ty_cache: HashMap<@ast::Ty, ast_ty_to_ty_cache_entry>,
272-
enum_var_cache: HashMap<def_id, @~[VariantInfo]>,
273-
trait_method_cache: HashMap<def_id, @~[method]>,
274-
ty_param_bounds: HashMap<ast::node_id, param_bounds>,
275-
inferred_modes: HashMap<ast::node_id, ast::mode>,
276-
adjustments: HashMap<ast::node_id, @AutoAdjustment>,
277-
normalized_cache: HashMap<t, t>,
278-
lang_items: middle::lang_items::LanguageItems,
279-
legacy_boxed_traits: HashMap<node_id, ()>,
280-
// A mapping from an implementation ID to the method info and trait
281-
// method ID of the provided (a.k.a. default) methods in the traits that
282-
// that implementation implements.
283-
provided_methods: ProvidedMethodsMap,
284-
provided_method_sources: HashMap<ast::def_id, ProvidedMethodSource>,
285-
supertraits: HashMap<ast::def_id, @~[InstantiatedTraitRef]>,
286-
287-
// A mapping from the def ID of an enum or struct type to the def ID
288-
// of the method that implements its destructor. If the type is not
289-
// present in this map, it does not have a destructor. This map is
290-
// populated during the coherence phase of typechecking.
291-
destructor_for_type: HashMap<ast::def_id, ast::def_id>,
292-
293-
// A method will be in this list if and only if it is a destructor.
294-
destructors: HashMap<ast::def_id, ()>,
295-
296-
// Records the value mode (read, copy, or move) for every value.
297-
value_modes: HashMap<ast::node_id, ValueMode>,
298-
299-
// Maps a trait onto a mapping from self-ty to impl
300-
trait_impls: HashMap<ast::def_id, HashMap<t, @Impl>>
301-
};
236+
pub type ctxt = @ctxt_;
237+
238+
struct ctxt_ {
239+
diag: syntax::diagnostic::span_handler,
240+
interner: HashMap<intern_key, t_box>,
241+
mut next_id: uint,
242+
vecs_implicitly_copyable: bool,
243+
legacy_modes: bool,
244+
legacy_records: bool,
245+
cstore: metadata::cstore::CStore,
246+
sess: session::Session,
247+
def_map: resolve::DefMap,
248+
249+
region_map: middle::region::region_map,
250+
region_paramd_items: middle::region::region_paramd_items,
251+
252+
// Stores the types for various nodes in the AST. Note that this table
253+
// is not guaranteed to be populated until after typeck. See
254+
// typeck::check::fn_ctxt for details.
255+
node_types: node_type_table,
256+
257+
// Stores the type parameters which were substituted to obtain the type
258+
// of this node. This only applies to nodes that refer to entities
259+
// parameterized by type parameters, such as generic fns, types, or
260+
// other items.
261+
node_type_substs: HashMap<node_id, ~[t]>,
262+
263+
items: ast_map::map,
264+
intrinsic_defs: HashMap<ast::ident, (ast::def_id, t)>,
265+
freevars: freevars::freevar_map,
266+
tcache: type_cache,
267+
rcache: creader_cache,
268+
ccache: constness_cache,
269+
short_names_cache: HashMap<t, @~str>,
270+
needs_drop_cache: HashMap<t, bool>,
271+
needs_unwind_cleanup_cache: HashMap<t, bool>,
272+
kind_cache: HashMap<t, Kind>,
273+
ast_ty_to_ty_cache: HashMap<@ast::Ty, ast_ty_to_ty_cache_entry>,
274+
enum_var_cache: HashMap<def_id, @~[VariantInfo]>,
275+
trait_method_cache: HashMap<def_id, @~[method]>,
276+
ty_param_bounds: HashMap<ast::node_id, param_bounds>,
277+
inferred_modes: HashMap<ast::node_id, ast::mode>,
278+
adjustments: HashMap<ast::node_id, @AutoAdjustment>,
279+
normalized_cache: HashMap<t, t>,
280+
lang_items: middle::lang_items::LanguageItems,
281+
legacy_boxed_traits: HashMap<node_id, ()>,
282+
// A mapping from an implementation ID to the method info and trait
283+
// method ID of the provided (a.k.a. default) methods in the traits that
284+
// that implementation implements.
285+
provided_methods: ProvidedMethodsMap,
286+
provided_method_sources: HashMap<ast::def_id, ProvidedMethodSource>,
287+
supertraits: HashMap<ast::def_id, @~[InstantiatedTraitRef]>,
288+
289+
// A mapping from the def ID of an enum or struct type to the def ID
290+
// of the method that implements its destructor. If the type is not
291+
// present in this map, it does not have a destructor. This map is
292+
// populated during the coherence phase of typechecking.
293+
destructor_for_type: HashMap<ast::def_id, ast::def_id>,
294+
295+
// A method will be in this list if and only if it is a destructor.
296+
destructors: HashMap<ast::def_id, ()>,
297+
298+
// Records the value mode (read, copy, or move) for every value.
299+
value_modes: HashMap<ast::node_id, ValueMode>,
300+
301+
// Maps a trait onto a mapping from self-ty to impl
302+
trait_impls: HashMap<ast::def_id, HashMap<t, @Impl>>
303+
}
302304

303305
enum tbox_flag {
304306
has_params = 1,
@@ -833,45 +835,46 @@ pub fn mk_ctxt(s: session::Session,
833835
let vecs_implicitly_copyable =
834836
get_lint_level(s.lint_settings.default_settings,
835837
lint::vecs_implicitly_copyable) == allow;
836-
@{diag: s.diagnostic(),
837-
interner: interner,
838-
mut next_id: 0u,
839-
vecs_implicitly_copyable: vecs_implicitly_copyable,
840-
legacy_modes: legacy_modes,
841-
legacy_records: legacy_records,
842-
cstore: s.cstore,
843-
sess: s,
844-
def_map: dm,
845-
region_map: region_map,
846-
region_paramd_items: region_paramd_items,
847-
node_types: @smallintmap::mk(),
848-
node_type_substs: map::HashMap(),
849-
items: amap,
850-
intrinsic_defs: map::HashMap(),
851-
freevars: freevars,
852-
tcache: HashMap(),
853-
rcache: mk_rcache(),
854-
ccache: HashMap(),
855-
short_names_cache: new_ty_hash(),
856-
needs_drop_cache: new_ty_hash(),
857-
needs_unwind_cleanup_cache: new_ty_hash(),
858-
kind_cache: new_ty_hash(),
859-
ast_ty_to_ty_cache: HashMap(),
860-
enum_var_cache: HashMap(),
861-
trait_method_cache: HashMap(),
862-
ty_param_bounds: HashMap(),
863-
inferred_modes: HashMap(),
864-
adjustments: HashMap(),
865-
normalized_cache: new_ty_hash(),
866-
lang_items: move lang_items,
867-
legacy_boxed_traits: HashMap(),
868-
provided_methods: HashMap(),
869-
provided_method_sources: HashMap(),
870-
supertraits: HashMap(),
871-
destructor_for_type: HashMap(),
872-
destructors: HashMap(),
873-
value_modes: HashMap(),
874-
trait_impls: HashMap()
838+
@ctxt_ {
839+
diag: s.diagnostic(),
840+
interner: interner,
841+
mut next_id: 0u,
842+
vecs_implicitly_copyable: vecs_implicitly_copyable,
843+
legacy_modes: legacy_modes,
844+
legacy_records: legacy_records,
845+
cstore: s.cstore,
846+
sess: s,
847+
def_map: dm,
848+
region_map: region_map,
849+
region_paramd_items: region_paramd_items,
850+
node_types: @smallintmap::mk(),
851+
node_type_substs: map::HashMap(),
852+
items: amap,
853+
intrinsic_defs: map::HashMap(),
854+
freevars: freevars,
855+
tcache: HashMap(),
856+
rcache: mk_rcache(),
857+
ccache: HashMap(),
858+
short_names_cache: new_ty_hash(),
859+
needs_drop_cache: new_ty_hash(),
860+
needs_unwind_cleanup_cache: new_ty_hash(),
861+
kind_cache: new_ty_hash(),
862+
ast_ty_to_ty_cache: HashMap(),
863+
enum_var_cache: HashMap(),
864+
trait_method_cache: HashMap(),
865+
ty_param_bounds: HashMap(),
866+
inferred_modes: HashMap(),
867+
adjustments: HashMap(),
868+
normalized_cache: new_ty_hash(),
869+
lang_items: move lang_items,
870+
legacy_boxed_traits: HashMap(),
871+
provided_methods: HashMap(),
872+
provided_method_sources: HashMap(),
873+
supertraits: HashMap(),
874+
destructor_for_type: HashMap(),
875+
destructors: HashMap(),
876+
value_modes: HashMap(),
877+
trait_impls: HashMap()
875878
}
876879
}
877880

0 commit comments

Comments
 (0)