Skip to content

Commit 29449e3

Browse files
committed
auto merge of #8889 : erickt/rust/cleanup, r=catamorphism
This fixes a couple minor things I've been sitting on. It cleans up some warnings, CapCases some types in librustc's rscope module, and adds a fixme.
2 parents 8002a09 + 9730ed9 commit 29449e3

18 files changed

+64
-81
lines changed

src/librustc/middle/typeck/astconv.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/*!
1212
* Conversion from AST representation of types to the ty.rs
1313
* representation. The main routine here is `ast_ty_to_ty()`: each use
14-
* is parameterized by an instance of `AstConv` and a `region_scope`.
14+
* is parameterized by an instance of `AstConv` and a `RegionScope`.
1515
*
1616
* The parameterization of `ast_ty_to_ty()` is because it behaves
1717
* somewhat differently during the collect and check phases,
@@ -23,12 +23,12 @@
2323
* In the check phase, when the @FnCtxt is used as the `AstConv`,
2424
* `get_item_ty()` just looks up the item type in `tcx.tcache`.
2525
*
26-
* The `region_scope` trait controls how region references are
26+
* The `RegionScope` trait controls how region references are
2727
* handled. It has two methods which are used to resolve anonymous
2828
* region references (e.g., `&T`) and named region references (e.g.,
2929
* `&a.T`). There are numerous region scopes that can be used, but most
30-
* commonly you want either `empty_rscope`, which permits only the static
31-
* region, or `type_rscope`, which permits the self region if the type in
30+
* commonly you want either `EmptyRscope`, which permits only the static
31+
* region, or `TypeRscope`, which permits the self region if the type in
3232
* question is parameterized by a region.
3333
*
3434
* Unlike the `AstConv` trait, the region scope can change as we descend
@@ -58,7 +58,7 @@ use middle::ty::{substs};
5858
use middle::ty::{ty_param_substs_and_ty};
5959
use middle::ty;
6060
use middle::typeck::rscope::in_binding_rscope;
61-
use middle::typeck::rscope::{region_scope, RegionError};
61+
use middle::typeck::rscope::{RegionScope, RegionError};
6262
use middle::typeck::rscope::RegionParamNames;
6363
use middle::typeck::lookup_def_tcx;
6464

@@ -104,7 +104,7 @@ pub fn get_region_reporting_err(
104104
}
105105
}
106106

107-
pub fn ast_region_to_region<AC:AstConv,RS:region_scope + Clone + 'static>(
107+
pub fn ast_region_to_region<AC:AstConv,RS:RegionScope + Clone + 'static>(
108108
this: &AC,
109109
rscope: &RS,
110110
default_span: span,
@@ -129,7 +129,7 @@ pub fn ast_region_to_region<AC:AstConv,RS:region_scope + Clone + 'static>(
129129
get_region_reporting_err(this.tcx(), span, opt_lifetime, res)
130130
}
131131

132-
fn ast_path_substs<AC:AstConv,RS:region_scope + Clone + 'static>(
132+
fn ast_path_substs<AC:AstConv,RS:RegionScope + Clone + 'static>(
133133
this: &AC,
134134
rscope: &RS,
135135
def_id: ast::def_id,
@@ -200,7 +200,7 @@ fn ast_path_substs<AC:AstConv,RS:region_scope + Clone + 'static>(
200200
}
201201

202202
pub fn ast_path_to_substs_and_ty<AC:AstConv,
203-
RS:region_scope + Clone + 'static>(
203+
RS:RegionScope + Clone + 'static>(
204204
this: &AC,
205205
rscope: &RS,
206206
did: ast::def_id,
@@ -217,7 +217,7 @@ pub fn ast_path_to_substs_and_ty<AC:AstConv,
217217
ty_param_substs_and_ty { substs: substs, ty: ty }
218218
}
219219

220-
pub fn ast_path_to_trait_ref<AC:AstConv,RS:region_scope + Clone + 'static>(
220+
pub fn ast_path_to_trait_ref<AC:AstConv,RS:RegionScope + Clone + 'static>(
221221
this: &AC,
222222
rscope: &RS,
223223
trait_def_id: ast::def_id,
@@ -240,7 +240,7 @@ pub fn ast_path_to_trait_ref<AC:AstConv,RS:region_scope + Clone + 'static>(
240240
return trait_ref;
241241
}
242242

243-
pub fn ast_path_to_ty<AC:AstConv,RS:region_scope + Clone + 'static>(
243+
pub fn ast_path_to_ty<AC:AstConv,RS:RegionScope + Clone + 'static>(
244244
this: &AC,
245245
rscope: &RS,
246246
did: ast::def_id,
@@ -262,10 +262,10 @@ pub static NO_TPS: uint = 2;
262262
// Parses the programmer's textual representation of a type into our
263263
// internal notion of a type. `getter` is a function that returns the type
264264
// corresponding to a definition ID:
265-
pub fn ast_ty_to_ty<AC:AstConv, RS:region_scope + Clone + 'static>(
265+
pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope + Clone + 'static>(
266266
this: &AC, rscope: &RS, ast_ty: &ast::Ty) -> ty::t {
267267

268-
fn ast_mt_to_mt<AC:AstConv, RS:region_scope + Clone + 'static>(
268+
fn ast_mt_to_mt<AC:AstConv, RS:RegionScope + Clone + 'static>(
269269
this: &AC, rscope: &RS, mt: &ast::mt) -> ty::mt {
270270

271271
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>(
274274
// Handle @, ~, and & being able to mean estrs and evecs.
275275
// If a_seq_ty is a str or a vec, make it an estr/evec.
276276
// Also handle first-class trait types.
277-
fn mk_pointer<AC:AstConv,RS:region_scope + Clone + 'static>(
277+
fn mk_pointer<AC:AstConv,RS:RegionScope + Clone + 'static>(
278278
this: &AC,
279279
rscope: &RS,
280280
a_seq_ty: &ast::mt,
@@ -540,7 +540,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:region_scope + Clone + 'static>(
540540
}
541541

542542
pub fn ty_of_arg<AC:AstConv,
543-
RS:region_scope + Clone + 'static>(
543+
RS:RegionScope + Clone + 'static>(
544544
this: &AC,
545545
rscope: &RS,
546546
a: &ast::arg,
@@ -588,7 +588,7 @@ struct SelfInfo {
588588
explicit_self: ast::explicit_self
589589
}
590590

591-
pub fn ty_of_method<AC:AstConv,RS:region_scope + Clone + 'static>(
591+
pub fn ty_of_method<AC:AstConv,RS:RegionScope + Clone + 'static>(
592592
this: &AC,
593593
rscope: &RS,
594594
purity: ast::purity,
@@ -606,7 +606,7 @@ pub fn ty_of_method<AC:AstConv,RS:region_scope + Clone + 'static>(
606606
(a.unwrap(), b)
607607
}
608608

609-
pub fn ty_of_bare_fn<AC:AstConv,RS:region_scope + Clone + 'static>(
609+
pub fn ty_of_bare_fn<AC:AstConv,RS:RegionScope + Clone + 'static>(
610610
this: &AC,
611611
rscope: &RS,
612612
purity: ast::purity,
@@ -619,7 +619,7 @@ pub fn ty_of_bare_fn<AC:AstConv,RS:region_scope + Clone + 'static>(
619619
b
620620
}
621621

622-
fn ty_of_method_or_bare_fn<AC:AstConv,RS:region_scope + Clone + 'static>(
622+
fn ty_of_method_or_bare_fn<AC:AstConv,RS:RegionScope + Clone + 'static>(
623623
this: &AC,
624624
rscope: &RS,
625625
purity: ast::purity,
@@ -657,7 +657,7 @@ fn ty_of_method_or_bare_fn<AC:AstConv,RS:region_scope + Clone + 'static>(
657657
output: output_ty}
658658
});
659659

660-
fn transform_self_ty<AC:AstConv,RS:region_scope + Clone + 'static>(
660+
fn transform_self_ty<AC:AstConv,RS:RegionScope + Clone + 'static>(
661661
this: &AC,
662662
rscope: &RS,
663663
self_info: &SelfInfo) -> Option<ty::t>
@@ -690,7 +690,7 @@ fn ty_of_method_or_bare_fn<AC:AstConv,RS:region_scope + Clone + 'static>(
690690
}
691691
}
692692

693-
pub fn ty_of_closure<AC:AstConv,RS:region_scope + Clone + 'static>(
693+
pub fn ty_of_closure<AC:AstConv,RS:RegionScope + Clone + 'static>(
694694
this: &AC,
695695
rscope: &RS,
696696
sigil: ast::Sigil,

src/librustc/middle/typeck/check/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ use middle::typeck::infer::{resolve_type, force_tvar};
101101
use middle::typeck::infer;
102102
use middle::typeck::rscope::bound_self_region;
103103
use middle::typeck::rscope::{RegionError};
104-
use middle::typeck::rscope::region_scope;
104+
use middle::typeck::rscope::RegionScope;
105105
use middle::typeck::{isr_alist, lookup_def_ccx};
106106
use middle::typeck::no_params;
107107
use middle::typeck::{require_same_types, method_map, vtable_map};
@@ -705,7 +705,7 @@ impl FnCtxt {
705705
}
706706
}
707707

708-
impl region_scope for FnCtxt {
708+
impl RegionScope for FnCtxt {
709709
fn anon_region(&self, span: span) -> Result<ty::Region, RegionError> {
710710
result::Ok(self.infcx().next_region_var(infer::MiscVariable(span)))
711711
}

src/librustc/middle/typeck/collect.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,15 @@ pub fn collect_item_types(ccx: @mut CrateCtxt, crate: &ast::Crate) {
9797
}
9898

9999
pub trait ToTy {
100-
fn to_ty<RS:region_scope + Clone + 'static>(
100+
fn to_ty<RS:RegionScope + Clone + 'static>(
101101
&self,
102102
rs: &RS,
103103
ast_ty: &ast::Ty)
104104
-> ty::t;
105105
}
106106

107107
impl ToTy for CrateCtxt {
108-
fn to_ty<RS:region_scope + Clone + 'static>(
108+
fn to_ty<RS:RegionScope + Clone + 'static>(
109109
&self,
110110
rs: &RS,
111111
ast_ty: &ast::Ty)
@@ -163,7 +163,7 @@ pub fn get_enum_variant_types(ccx: &CrateCtxt,
163163
let result_ty;
164164
match variant.node.kind {
165165
ast::tuple_variant_kind(ref args) if args.len() > 0 => {
166-
let rs = type_rscope(region_parameterization);
166+
let rs = TypeRscope(region_parameterization);
167167
let input_tys = args.map(|va| ccx.to_ty(&rs, &va.ty));
168168
result_ty = Some(ty::mk_ctor_fn(tcx, input_tys, enum_ty));
169169
}
@@ -724,7 +724,7 @@ pub fn convert_field(ccx: &CrateCtxt,
724724
generics: &ast::Generics) {
725725
let region_parameterization =
726726
RegionParameterization::from_variance_and_generics(rp, generics);
727-
let tt = ccx.to_ty(&type_rscope(region_parameterization), &v.node.ty);
727+
let tt = ccx.to_ty(&TypeRscope(region_parameterization), &v.node.ty);
728728
write_ty_to_tcx(ccx.tcx, v.node.id, tt);
729729
/* add the field to the tcache */
730730
ccx.tcx.tcache.insert(local_def(v.node.id),
@@ -863,7 +863,7 @@ pub fn convert(ccx: &CrateCtxt, it: &ast::item) {
863863
let i_ty_generics = ty_generics(ccx, rp, generics, 0);
864864
let region_parameterization =
865865
RegionParameterization::from_variance_and_generics(rp, generics);
866-
let selfty = ccx.to_ty(&type_rscope(region_parameterization), selfty);
866+
let selfty = ccx.to_ty(&TypeRscope(region_parameterization), selfty);
867867
write_ty_to_tcx(tcx, it.id, selfty);
868868
tcx.tcache.insert(local_def(it.id),
869869
ty_param_bounds_and_ty {
@@ -1024,7 +1024,7 @@ pub fn instantiate_trait_ref(ccx: &CrateCtxt,
10241024

10251025
let rp = RegionParameterization::from_variance_and_generics(rp, generics);
10261026

1027-
let rscope = type_rscope(rp);
1027+
let rscope = TypeRscope(rp);
10281028

10291029
match lookup_def_tcx(ccx.tcx, ast_trait_ref.path.span, ast_trait_ref.ref_id) {
10301030
ast::def_trait(trait_did) => {
@@ -1099,7 +1099,7 @@ pub fn ty_of_item(ccx: &CrateCtxt, it: &ast::item)
10991099
let rp = tcx.region_paramd_items.find(&it.id).map_move(|x| *x);
11001100
match it.node {
11011101
ast::item_static(ref t, _, _) => {
1102-
let typ = ccx.to_ty(&empty_rscope, t);
1102+
let typ = ccx.to_ty(&EmptyRscope, t);
11031103
let tpt = no_params(typ);
11041104
tcx.tcache.insert(local_def(it.id), tpt);
11051105
return tpt;
@@ -1108,7 +1108,7 @@ pub fn ty_of_item(ccx: &CrateCtxt, it: &ast::item)
11081108
assert!(rp.is_none());
11091109
let ty_generics = ty_generics(ccx, None, generics, 0);
11101110
let tofd = astconv::ty_of_bare_fn(ccx,
1111-
&empty_rscope,
1111+
&EmptyRscope,
11121112
purity,
11131113
abi,
11141114
&generics.lifetimes,
@@ -1137,7 +1137,7 @@ pub fn ty_of_item(ccx: &CrateCtxt, it: &ast::item)
11371137
let region_parameterization =
11381138
RegionParameterization::from_variance_and_generics(rp, generics);
11391139
let tpt = {
1140-
let ty = ccx.to_ty(&type_rscope(region_parameterization), t);
1140+
let ty = ccx.to_ty(&TypeRscope(region_parameterization), t);
11411141
ty_param_bounds_and_ty {
11421142
generics: ty_generics(ccx, rp, generics, 0),
11431143
ty: ty
@@ -1197,7 +1197,7 @@ pub fn ty_of_foreign_item(ccx: &CrateCtxt,
11971197
type_param_defs: @~[],
11981198
region_param: None,
11991199
},
1200-
ty: ast_ty_to_ty(ccx, &empty_rscope, t)
1200+
ty: ast_ty_to_ty(ccx, &EmptyRscope, t)
12011201
}
12021202
}
12031203
}
@@ -1282,7 +1282,7 @@ pub fn ty_of_foreign_fn_decl(ccx: &CrateCtxt,
12821282
-> ty::ty_param_bounds_and_ty {
12831283
let ty_generics = ty_generics(ccx, None, ast_generics, 0);
12841284
let region_param_names = RegionParamNames::from_generics(ast_generics);
1285-
let rb = in_binding_rscope(&empty_rscope, region_param_names);
1285+
let rb = in_binding_rscope(&EmptyRscope, region_param_names);
12861286
let input_tys = decl.inputs.map(|a| ty_of_arg(ccx, &rb, a, None) );
12871287
let output_ty = ast_ty_to_ty(ccx, &rb, &decl.output);
12881288

src/librustc/middle/typeck/rscope.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ pub struct RegionError {
2424
replacement: ty::Region
2525
}
2626

27-
pub trait region_scope {
27+
pub trait RegionScope {
2828
fn anon_region(&self, span: span) -> Result<ty::Region, RegionError>;
2929
fn self_region(&self, span: span) -> Result<ty::Region, RegionError>;
3030
fn named_region(&self, span: span, id: ast::ident)
3131
-> Result<ty::Region, RegionError>;
3232
}
3333

3434
#[deriving(Clone)]
35-
pub enum empty_rscope { empty_rscope }
36-
impl region_scope for empty_rscope {
35+
pub struct EmptyRscope;
36+
impl RegionScope for EmptyRscope {
3737
fn anon_region(&self, _span: span) -> Result<ty::Region, RegionError> {
3838
result::Err(RegionError {
3939
msg: ~"only 'static is allowed here",
@@ -175,7 +175,7 @@ impl MethodRscope {
175175
}
176176
}
177177

178-
impl region_scope for MethodRscope {
178+
impl RegionScope for MethodRscope {
179179
fn anon_region(&self, _span: span) -> Result<ty::Region, RegionError> {
180180
result::Err(RegionError {
181181
msg: ~"anonymous lifetimes are not permitted here",
@@ -202,7 +202,7 @@ impl region_scope for MethodRscope {
202202
if !self.region_param_names.has_ident(id) {
203203
return RegionParamNames::undeclared_name(None);
204204
}
205-
do empty_rscope.named_region(span, id).chain_err |_e| {
205+
do EmptyRscope.named_region(span, id).chain_err |_e| {
206206
result::Err(RegionError {
207207
msg: ~"lifetime is not in scope",
208208
replacement: ty::re_bound(ty::br_self)
@@ -212,9 +212,9 @@ impl region_scope for MethodRscope {
212212
}
213213

214214
#[deriving(Clone)]
215-
pub struct type_rscope(Option<RegionParameterization>);
215+
pub struct TypeRscope(Option<RegionParameterization>);
216216

217-
impl type_rscope {
217+
impl TypeRscope {
218218
fn replacement(&self) -> ty::Region {
219219
if self.is_some() {
220220
ty::re_bound(ty::br_self)
@@ -223,7 +223,7 @@ impl type_rscope {
223223
}
224224
}
225225
}
226-
impl region_scope for type_rscope {
226+
impl RegionScope for TypeRscope {
227227
fn anon_region(&self, _span: span) -> Result<ty::Region, RegionError> {
228228
result::Err(RegionError {
229229
msg: ~"anonymous lifetimes are not permitted here",
@@ -251,7 +251,7 @@ impl region_scope for type_rscope {
251251
}
252252
fn named_region(&self, span: span, id: ast::ident)
253253
-> Result<ty::Region, RegionError> {
254-
do empty_rscope.named_region(span, id).chain_err |_e| {
254+
do EmptyRscope.named_region(span, id).chain_err |_e| {
255255
result::Err(RegionError {
256256
msg: ~"only 'self is allowed as part of a type declaration",
257257
replacement: self.replacement()
@@ -268,36 +268,36 @@ pub fn bound_self_region(rp: Option<ty::region_variance>)
268268
}
269269
}
270270

271-
pub struct binding_rscope {
272-
base: @region_scope,
271+
pub struct BindingRscope {
272+
base: @RegionScope,
273273
anon_bindings: @mut uint,
274274
region_param_names: RegionParamNames,
275275
}
276276

277-
impl Clone for binding_rscope {
278-
fn clone(&self) -> binding_rscope {
279-
binding_rscope {
277+
impl Clone for BindingRscope {
278+
fn clone(&self) -> BindingRscope {
279+
BindingRscope {
280280
base: self.base,
281281
anon_bindings: self.anon_bindings,
282282
region_param_names: self.region_param_names.clone(),
283283
}
284284
}
285285
}
286286

287-
pub fn in_binding_rscope<RS:region_scope + Clone + 'static>(
287+
pub fn in_binding_rscope<RS:RegionScope + Clone + 'static>(
288288
this: &RS,
289289
region_param_names: RegionParamNames)
290-
-> binding_rscope {
290+
-> BindingRscope {
291291
let base = @(*this).clone();
292-
let base = base as @region_scope;
293-
binding_rscope {
292+
let base = base as @RegionScope;
293+
BindingRscope {
294294
base: base,
295295
anon_bindings: @mut 0,
296296
region_param_names: region_param_names,
297297
}
298298
}
299299

300-
impl region_scope for binding_rscope {
300+
impl RegionScope for BindingRscope {
301301
fn anon_region(&self, _span: span) -> Result<ty::Region, RegionError> {
302302
let idx = *self.anon_bindings;
303303
*self.anon_bindings += 1;

src/libstd/fmt/parse.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,6 @@ impl<'self> Parser<'self> {
595595
mod tests {
596596
use super::*;
597597
use prelude::*;
598-
use realstd::fmt::{String};
599598

600599
fn same(fmt: &'static str, p: ~[Piece<'static>]) {
601600
let mut parser = Parser::new(fmt);

0 commit comments

Comments
 (0)