diff options
| author | Erick Tryzelaar <erick.tryzelaar@gmail.com> | 2013-08-17 11:09:52 -0700 |
|---|---|---|
| committer | Erick Tryzelaar <erick.tryzelaar@gmail.com> | 2013-08-30 15:10:55 -0700 |
| commit | 66e3a4c50efe21e2e62fcf845184c6f1c8044c97 (patch) | |
| tree | 095536bb090a809881f6f335620ad4932eb79ae7 | |
| parent | 91d6c60bed2c5d574ca524ab4812f731118cd22d (diff) | |
rustc: capitalize types in rscope.rs
| -rw-r--r-- | src/librustc/middle/typeck/astconv.rs | 38 | ||||
| -rw-r--r-- | src/librustc/middle/typeck/check/mod.rs | 4 | ||||
| -rw-r--r-- | src/librustc/middle/typeck/collect.rs | 22 | ||||
| -rw-r--r-- | src/librustc/middle/typeck/rscope.rs | 38 |
4 files changed, 51 insertions, 51 deletions
diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index 6ebcf4facc1..18cc5e65a8b 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -11,7 +11,7 @@ /*! * Conversion from AST representation of types to the ty.rs * representation. The main routine here is `ast_ty_to_ty()`: each use - * is parameterized by an instance of `AstConv` and a `region_scope`. + * is parameterized by an instance of `AstConv` and a `RegionScope`. * * The parameterization of `ast_ty_to_ty()` is because it behaves * somewhat differently during the collect and check phases, @@ -23,12 +23,12 @@ * In the check phase, when the @FnCtxt is used as the `AstConv`, * `get_item_ty()` just looks up the item type in `tcx.tcache`. * - * The `region_scope` trait controls how region references are + * The `RegionScope` trait controls how region references are * handled. It has two methods which are used to resolve anonymous * region references (e.g., `&T`) and named region references (e.g., * `&a.T`). There are numerous region scopes that can be used, but most - * commonly you want either `empty_rscope`, which permits only the static - * region, or `type_rscope`, which permits the self region if the type in + * commonly you want either `EmptyRscope`, which permits only the static + * region, or `TypeRscope`, which permits the self region if the type in * question is parameterized by a region. * * Unlike the `AstConv` trait, the region scope can change as we descend @@ -58,7 +58,7 @@ use middle::ty::{substs}; use middle::ty::{ty_param_substs_and_ty}; use middle::ty; use middle::typeck::rscope::in_binding_rscope; -use middle::typeck::rscope::{region_scope, RegionError}; +use middle::typeck::rscope::{RegionScope, RegionError}; use middle::typeck::rscope::RegionParamNames; use middle::typeck::lookup_def_tcx; @@ -104,7 +104,7 @@ pub fn get_region_reporting_err( } } -pub fn ast_region_to_region<AC:AstConv,RS:region_scope + Clone + 'static>( +pub fn ast_region_to_region<AC:AstConv,RS:RegionScope + Clone + 'static>( this: &AC, rscope: &RS, default_span: span, @@ -129,7 +129,7 @@ pub fn ast_region_to_region<AC:AstConv,RS:region_scope + Clone + 'static>( get_region_reporting_err(this.tcx(), span, opt_lifetime, res) } -fn ast_path_substs<AC:AstConv,RS:region_scope + Clone + 'static>( +fn ast_path_substs<AC:AstConv,RS:RegionScope + Clone + 'static>( this: &AC, rscope: &RS, def_id: ast::def_id, @@ -200,7 +200,7 @@ fn ast_path_substs<AC:AstConv,RS:region_scope + Clone + 'static>( } pub fn ast_path_to_substs_and_ty<AC:AstConv, - RS:region_scope + Clone + 'static>( + RS:RegionScope + Clone + 'static>( this: &AC, rscope: &RS, did: ast::def_id, @@ -217,7 +217,7 @@ pub fn ast_path_to_substs_and_ty<AC:AstConv, ty_param_substs_and_ty { substs: substs, ty: ty } } -pub fn ast_path_to_trait_ref<AC:AstConv,RS:region_scope + Clone + 'static>( +pub fn ast_path_to_trait_ref<AC:AstConv,RS:RegionScope + Clone + 'static>( this: &AC, rscope: &RS, trait_def_id: ast::def_id, @@ -240,7 +240,7 @@ pub fn ast_path_to_trait_ref<AC:AstConv,RS:region_scope + Clone + 'static>( return trait_ref; } -pub fn ast_path_to_ty<AC:AstConv,RS:region_scope + Clone + 'static>( +pub fn ast_path_to_ty<AC:AstConv,RS:RegionScope + Clone + 'static>( this: &AC, rscope: &RS, did: ast::def_id, @@ -262,10 +262,10 @@ pub static NO_TPS: uint = 2; // Parses the programmer's textual representation of a type into our // internal notion of a type. `getter` is a function that returns the type // corresponding to a definition ID: -pub fn ast_ty_to_ty<AC:AstConv, RS:region_scope + Clone + 'static>( +pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope + Clone + 'static>( this: &AC, rscope: &RS, ast_ty: &ast::Ty) -> ty::t { - fn ast_mt_to_mt<AC:AstConv, RS:region_scope + Clone + 'static>( + fn ast_mt_to_mt<AC:AstConv, RS:RegionScope + Clone + 'static>( this: &AC, rscope: &RS, mt: &ast::mt) -> ty::mt { ty::mt {ty: ast_ty_to_ty(this, rscope, mt.ty), mutbl: mt.mutbl} @@ -274,7 +274,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:region_scope + Clone + 'static>( // Handle @, ~, and & being able to mean estrs and evecs. // If a_seq_ty is a str or a vec, make it an estr/evec. // Also handle first-class trait types. - fn mk_pointer<AC:AstConv,RS:region_scope + Clone + 'static>( + fn mk_pointer<AC:AstConv,RS:RegionScope + Clone + 'static>( this: &AC, rscope: &RS, a_seq_ty: &ast::mt, @@ -540,7 +540,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:region_scope + Clone + 'static>( } pub fn ty_of_arg<AC:AstConv, - RS:region_scope + Clone + 'static>( + RS:RegionScope + Clone + 'static>( this: &AC, rscope: &RS, a: &ast::arg, @@ -588,7 +588,7 @@ struct SelfInfo { explicit_self: ast::explicit_self } -pub fn ty_of_method<AC:AstConv,RS:region_scope + Clone + 'static>( +pub fn ty_of_method<AC:AstConv,RS:RegionScope + Clone + 'static>( this: &AC, rscope: &RS, purity: ast::purity, @@ -606,7 +606,7 @@ pub fn ty_of_method<AC:AstConv,RS:region_scope + Clone + 'static>( (a.unwrap(), b) } -pub fn ty_of_bare_fn<AC:AstConv,RS:region_scope + Clone + 'static>( +pub fn ty_of_bare_fn<AC:AstConv,RS:RegionScope + Clone + 'static>( this: &AC, rscope: &RS, purity: ast::purity, @@ -619,7 +619,7 @@ pub fn ty_of_bare_fn<AC:AstConv,RS:region_scope + Clone + 'static>( b } -fn ty_of_method_or_bare_fn<AC:AstConv,RS:region_scope + Clone + 'static>( +fn ty_of_method_or_bare_fn<AC:AstConv,RS:RegionScope + Clone + 'static>( this: &AC, rscope: &RS, purity: ast::purity, @@ -657,7 +657,7 @@ fn ty_of_method_or_bare_fn<AC:AstConv,RS:region_scope + Clone + 'static>( output: output_ty} }); - fn transform_self_ty<AC:AstConv,RS:region_scope + Clone + 'static>( + fn transform_self_ty<AC:AstConv,RS:RegionScope + Clone + 'static>( this: &AC, rscope: &RS, self_info: &SelfInfo) -> Option<ty::t> @@ -690,7 +690,7 @@ fn ty_of_method_or_bare_fn<AC:AstConv,RS:region_scope + Clone + 'static>( } } -pub fn ty_of_closure<AC:AstConv,RS:region_scope + Clone + 'static>( +pub fn ty_of_closure<AC:AstConv,RS:RegionScope + Clone + 'static>( this: &AC, rscope: &RS, sigil: ast::Sigil, diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index 0b27a581a2a..3016d40729b 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -101,7 +101,7 @@ use middle::typeck::infer::{resolve_type, force_tvar}; use middle::typeck::infer; use middle::typeck::rscope::bound_self_region; use middle::typeck::rscope::{RegionError}; -use middle::typeck::rscope::region_scope; +use middle::typeck::rscope::RegionScope; use middle::typeck::{isr_alist, lookup_def_ccx}; use middle::typeck::no_params; use middle::typeck::{require_same_types, method_map, vtable_map}; @@ -705,7 +705,7 @@ impl FnCtxt { } } -impl region_scope for FnCtxt { +impl RegionScope for FnCtxt { fn anon_region(&self, span: span) -> Result<ty::Region, RegionError> { result::Ok(self.infcx().next_region_var(infer::MiscVariable(span))) } diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index 63317d4ca5c..71a9a041fb5 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -97,7 +97,7 @@ pub fn collect_item_types(ccx: @mut CrateCtxt, crate: &ast::Crate) { } pub trait ToTy { - fn to_ty<RS:region_scope + Clone + 'static>( + fn to_ty<RS:RegionScope + Clone + 'static>( &self, rs: &RS, ast_ty: &ast::Ty) @@ -105,7 +105,7 @@ pub trait ToTy { } impl ToTy for CrateCtxt { - fn to_ty<RS:region_scope + Clone + 'static>( + fn to_ty<RS:RegionScope + Clone + 'static>( &self, rs: &RS, ast_ty: &ast::Ty) @@ -163,7 +163,7 @@ pub fn get_enum_variant_types(ccx: &CrateCtxt, let result_ty; match variant.node.kind { ast::tuple_variant_kind(ref args) if args.len() > 0 => { - let rs = type_rscope(region_parameterization); + let rs = TypeRscope(region_parameterization); let input_tys = args.map(|va| ccx.to_ty(&rs, &va.ty)); result_ty = Some(ty::mk_ctor_fn(tcx, input_tys, enum_ty)); } @@ -724,7 +724,7 @@ pub fn convert_field(ccx: &CrateCtxt, generics: &ast::Generics) { let region_parameterization = RegionParameterization::from_variance_and_generics(rp, generics); - let tt = ccx.to_ty(&type_rscope(region_parameterization), &v.node.ty); + let tt = ccx.to_ty(&TypeRscope(region_parameterization), &v.node.ty); write_ty_to_tcx(ccx.tcx, v.node.id, tt); /* add the field to the tcache */ ccx.tcx.tcache.insert(local_def(v.node.id), @@ -863,7 +863,7 @@ pub fn convert(ccx: &CrateCtxt, it: &ast::item) { let i_ty_generics = ty_generics(ccx, rp, generics, 0); let region_parameterization = RegionParameterization::from_variance_and_generics(rp, generics); - let selfty = ccx.to_ty(&type_rscope(region_parameterization), selfty); + let selfty = ccx.to_ty(&TypeRscope(region_parameterization), selfty); write_ty_to_tcx(tcx, it.id, selfty); tcx.tcache.insert(local_def(it.id), ty_param_bounds_and_ty { @@ -1024,7 +1024,7 @@ pub fn instantiate_trait_ref(ccx: &CrateCtxt, let rp = RegionParameterization::from_variance_and_generics(rp, generics); - let rscope = type_rscope(rp); + let rscope = TypeRscope(rp); match lookup_def_tcx(ccx.tcx, ast_trait_ref.path.span, ast_trait_ref.ref_id) { ast::def_trait(trait_did) => { @@ -1099,7 +1099,7 @@ pub fn ty_of_item(ccx: &CrateCtxt, it: &ast::item) let rp = tcx.region_paramd_items.find(&it.id).map_move(|x| *x); match it.node { ast::item_static(ref t, _, _) => { - let typ = ccx.to_ty(&empty_rscope, t); + let typ = ccx.to_ty(&EmptyRscope, t); let tpt = no_params(typ); tcx.tcache.insert(local_def(it.id), tpt); return tpt; @@ -1108,7 +1108,7 @@ pub fn ty_of_item(ccx: &CrateCtxt, it: &ast::item) assert!(rp.is_none()); let ty_generics = ty_generics(ccx, None, generics, 0); let tofd = astconv::ty_of_bare_fn(ccx, - &empty_rscope, + &EmptyRscope, purity, abi, &generics.lifetimes, @@ -1137,7 +1137,7 @@ pub fn ty_of_item(ccx: &CrateCtxt, it: &ast::item) let region_parameterization = RegionParameterization::from_variance_and_generics(rp, generics); let tpt = { - let ty = ccx.to_ty(&type_rscope(region_parameterization), t); + let ty = ccx.to_ty(&TypeRscope(region_parameterization), t); ty_param_bounds_and_ty { generics: ty_generics(ccx, rp, generics, 0), ty: ty @@ -1197,7 +1197,7 @@ pub fn ty_of_foreign_item(ccx: &CrateCtxt, type_param_defs: @~[], region_param: None, }, - ty: ast_ty_to_ty(ccx, &empty_rscope, t) + ty: ast_ty_to_ty(ccx, &EmptyRscope, t) } } } @@ -1282,7 +1282,7 @@ pub fn ty_of_foreign_fn_decl(ccx: &CrateCtxt, -> ty::ty_param_bounds_and_ty { let ty_generics = ty_generics(ccx, None, ast_generics, 0); let region_param_names = RegionParamNames::from_generics(ast_generics); - let rb = in_binding_rscope(&empty_rscope, region_param_names); + let rb = in_binding_rscope(&EmptyRscope, region_param_names); let input_tys = decl.inputs.map(|a| ty_of_arg(ccx, &rb, a, None) ); let output_ty = ast_ty_to_ty(ccx, &rb, &decl.output); diff --git a/src/librustc/middle/typeck/rscope.rs b/src/librustc/middle/typeck/rscope.rs index c9e2b8dd37b..a93ff9c5fd0 100644 --- a/src/librustc/middle/typeck/rscope.rs +++ b/src/librustc/middle/typeck/rscope.rs @@ -24,7 +24,7 @@ pub struct RegionError { replacement: ty::Region } -pub trait region_scope { +pub trait RegionScope { fn anon_region(&self, span: span) -> Result<ty::Region, RegionError>; fn self_region(&self, span: span) -> Result<ty::Region, RegionError>; fn named_region(&self, span: span, id: ast::ident) @@ -32,8 +32,8 @@ pub trait region_scope { } #[deriving(Clone)] -pub enum empty_rscope { empty_rscope } -impl region_scope for empty_rscope { +pub struct EmptyRscope; +impl RegionScope for EmptyRscope { fn anon_region(&self, _span: span) -> Result<ty::Region, RegionError> { result::Err(RegionError { msg: ~"only 'static is allowed here", @@ -175,7 +175,7 @@ impl MethodRscope { } } -impl region_scope for MethodRscope { +impl RegionScope for MethodRscope { fn anon_region(&self, _span: span) -> Result<ty::Region, RegionError> { result::Err(RegionError { msg: ~"anonymous lifetimes are not permitted here", @@ -202,7 +202,7 @@ impl region_scope for MethodRscope { if !self.region_param_names.has_ident(id) { return RegionParamNames::undeclared_name(None); } - do empty_rscope.named_region(span, id).chain_err |_e| { + do EmptyRscope.named_region(span, id).chain_err |_e| { result::Err(RegionError { msg: ~"lifetime is not in scope", replacement: ty::re_bound(ty::br_self) @@ -212,9 +212,9 @@ impl region_scope for MethodRscope { } #[deriving(Clone)] -pub struct type_rscope(Option<RegionParameterization>); +pub struct TypeRscope(Option<RegionParameterization>); -impl type_rscope { +impl TypeRscope { fn replacement(&self) -> ty::Region { if self.is_some() { ty::re_bound(ty::br_self) @@ -223,7 +223,7 @@ impl type_rscope { } } } -impl region_scope for type_rscope { +impl RegionScope for TypeRscope { fn anon_region(&self, _span: span) -> Result<ty::Region, RegionError> { result::Err(RegionError { msg: ~"anonymous lifetimes are not permitted here", @@ -251,7 +251,7 @@ impl region_scope for type_rscope { } fn named_region(&self, span: span, id: ast::ident) -> Result<ty::Region, RegionError> { - do empty_rscope.named_region(span, id).chain_err |_e| { + do EmptyRscope.named_region(span, id).chain_err |_e| { result::Err(RegionError { msg: ~"only 'self is allowed as part of a type declaration", replacement: self.replacement() @@ -268,15 +268,15 @@ pub fn bound_self_region(rp: Option<ty::region_variance>) } } -pub struct binding_rscope { - base: @region_scope, +pub struct BindingRscope { + base: @RegionScope, anon_bindings: @mut uint, region_param_names: RegionParamNames, } -impl Clone for binding_rscope { - fn clone(&self) -> binding_rscope { - binding_rscope { +impl Clone for BindingRscope { + fn clone(&self) -> BindingRscope { + BindingRscope { base: self.base, anon_bindings: self.anon_bindings, region_param_names: self.region_param_names.clone(), @@ -284,20 +284,20 @@ impl Clone for binding_rscope { } } -pub fn in_binding_rscope<RS:region_scope + Clone + 'static>( +pub fn in_binding_rscope<RS:RegionScope + Clone + 'static>( this: &RS, region_param_names: RegionParamNames) - -> binding_rscope { + -> BindingRscope { let base = @(*this).clone(); - let base = base as @region_scope; - binding_rscope { + let base = base as @RegionScope; + BindingRscope { base: base, anon_bindings: @mut 0, region_param_names: region_param_names, } } -impl region_scope for binding_rscope { +impl RegionScope for BindingRscope { fn anon_region(&self, _span: span) -> Result<ty::Region, RegionError> { let idx = *self.anon_bindings; *self.anon_bindings += 1; |
