Skip to content

Commit ae8ba88

Browse files
committed
Mostly non-behaviour-changing changes (style, etc.)
1 parent 397dda8 commit ae8ba88

File tree

9 files changed

+82
-91
lines changed

9 files changed

+82
-91
lines changed

src/librustc/metadata/decoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ pub fn get_symbol(data: &[u8], id: ast::NodeId) -> String {
435435
}
436436

437437
// Something that a name can resolve to.
438-
#[deriving(Clone)]
438+
#[deriving(Clone,Show)]
439439
pub enum DefLike {
440440
DlDef(def::Def),
441441
DlImpl(ast::DefId),

src/librustc/middle/resolve.rs

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ pub type ExportMap2 = NodeMap<Vec<Export2>>;
108108

109109
pub struct Export2 {
110110
pub name: String, // The name of the target.
111-
pub def_id: DefId, // The definition of the target.
111+
pub def_id: DefId, // The definition of the target.
112112
}
113113

114114
// This set contains all exported definitions from external crates. The set does
@@ -314,7 +314,7 @@ impl<'a> Copy for TypeParameters<'a> {}
314314

315315
// The rib kind controls the translation of local
316316
// definitions (`DefLocal`) to upvars (`DefUpvar`).
317-
317+
#[deriving(Show)]
318318
enum RibKind {
319319
// No translation needs to be applied.
320320
NormalRibKind,
@@ -340,6 +340,7 @@ enum RibKind {
340340
impl Copy for RibKind {}
341341

342342
// Methods can be required or provided. RequiredMethod methods only occur in traits.
343+
#[deriving(Show)]
343344
enum MethodSort {
344345
RequiredMethod,
345346
ProvidedMethod(NodeId)
@@ -414,6 +415,7 @@ enum DuplicateCheckingMode {
414415
impl Copy for DuplicateCheckingMode {}
415416

416417
/// One local scope.
418+
#[deriving(Show)]
417419
struct Rib {
418420
bindings: HashMap<Name, DefLike>,
419421
kind: RibKind,
@@ -728,8 +730,11 @@ impl NameBindings {
728730
let type_def = self.type_def.borrow().clone();
729731
match type_def {
730732
None => {
731-
let module = Module::new(parent_link, def_id, kind,
732-
external, is_public);
733+
let module = Module::new(parent_link,
734+
def_id,
735+
kind,
736+
external,
737+
is_public);
733738
*self.type_def.borrow_mut() = Some(TypeNsDef {
734739
modifiers: modifiers,
735740
module_def: Some(Rc::new(module)),
@@ -774,9 +779,9 @@ impl NameBindings {
774779
}
775780
Some(type_def) => {
776781
*self.type_def.borrow_mut() = Some(TypeNsDef {
782+
module_def: type_def.module_def,
777783
type_def: Some(def),
778784
type_span: Some(sp),
779-
module_def: type_def.module_def,
780785
modifiers: modifiers,
781786
});
782787
}
@@ -1286,7 +1291,7 @@ impl<'a> Resolver<'a> {
12861291
}
12871292

12881293
fn get_parent_link(&mut self, parent: ReducedGraphParent, name: Name)
1289-
-> ParentLink {
1294+
-> ParentLink {
12901295
match parent {
12911296
ModuleReducedGraphParent(module_) => {
12921297
return ModuleParentLink(module_.downgrade(), name);
@@ -1578,14 +1583,14 @@ impl<'a> Resolver<'a> {
15781583

15791584
ItemImpl(_, Some(_), _, _) => parent,
15801585

1581-
ItemTrait(_, _, _, ref methods) => {
1586+
ItemTrait(_, _, _, ref items) => {
15821587
let name_bindings =
15831588
self.add_child(name,
15841589
parent.clone(),
15851590
ForbidDuplicateTypesAndModules,
15861591
sp);
15871592

1588-
// Add all the methods within to a new module.
1593+
// Add all the items within to a new module.
15891594
let parent_link = self.get_parent_link(parent.clone(), name);
15901595
name_bindings.define_module(parent_link,
15911596
Some(local_def(item.id)),
@@ -1598,13 +1603,12 @@ impl<'a> Resolver<'a> {
15981603

15991604
let def_id = local_def(item.id);
16001605

1601-
// Add the names of all the methods to the trait info.
1602-
for method in methods.iter() {
1603-
let (name, kind) = match *method {
1606+
// Add the names of all the items to the trait info.
1607+
for trait_item in items.iter() {
1608+
let (name, kind) = match *trait_item {
16041609
ast::RequiredMethod(_) |
16051610
ast::ProvidedMethod(_) => {
1606-
let ty_m =
1607-
ast_util::trait_item_to_ty_method(method);
1611+
let ty_m = ast_util::trait_item_to_ty_method(trait_item);
16081612

16091613
let name = ty_m.ident.name;
16101614

@@ -3353,7 +3357,7 @@ impl<'a> Resolver<'a> {
33533357
use_lexical_scope: UseLexicalScopeFlag,
33543358
span: Span,
33553359
name_search_type: NameSearchType)
3356-
-> ResolveResult<(Rc<Module>, LastPrivate)> {
3360+
-> ResolveResult<(Rc<Module>, LastPrivate)> {
33573361
let module_path_len = module_path.len();
33583362
assert!(module_path_len > 0);
33593363

@@ -3382,7 +3386,9 @@ impl<'a> Resolver<'a> {
33823386
mpath.slice_to(idx - 1));
33833387
return Failed(Some((span, msg)));
33843388
},
3385-
None => return Failed(None),
3389+
None => {
3390+
return Failed(None)
3391+
}
33863392
}
33873393
}
33883394
Failed(err) => return Failed(err),
@@ -3575,8 +3581,7 @@ impl<'a> Resolver<'a> {
35753581
-> ResolveResult<Rc<Module>> {
35763582
// If this module is an anonymous module, resolve the item in the
35773583
// lexical scope. Otherwise, resolve the item from the crate root.
3578-
let resolve_result = self.resolve_item_in_lexical_scope(
3579-
module_, name, TypeNS);
3584+
let resolve_result = self.resolve_item_in_lexical_scope(module_, name, TypeNS);
35803585
match resolve_result {
35813586
Success((target, _)) => {
35823587
let bindings = &*target.bindings;
@@ -5327,15 +5332,15 @@ impl<'a> Resolver<'a> {
53275332

53285333
// resolve a single identifier (used as a varref)
53295334
fn resolve_identifier(&mut self,
5330-
identifier: Ident,
5331-
namespace: Namespace,
5332-
check_ribs: bool,
5333-
span: Span)
5334-
-> Option<(Def, LastPrivate)> {
5335+
identifier: Ident,
5336+
namespace: Namespace,
5337+
check_ribs: bool,
5338+
span: Span)
5339+
-> Option<(Def, LastPrivate)> {
53355340
if check_ribs {
53365341
match self.resolve_identifier_in_local_ribs(identifier,
5337-
namespace,
5338-
span) {
5342+
namespace,
5343+
span) {
53395344
Some(def) => {
53405345
return Some((def, LastMod(AllPublic)));
53415346
}
@@ -5353,7 +5358,7 @@ impl<'a> Resolver<'a> {
53535358
containing_module: Rc<Module>,
53545359
name: Name,
53555360
namespace: Namespace)
5356-
-> NameDefinition {
5361+
-> NameDefinition {
53575362
// First, search children.
53585363
self.populate_module_if_necessary(&containing_module);
53595364

@@ -5423,9 +5428,9 @@ impl<'a> Resolver<'a> {
54235428

54245429
// resolve a "module-relative" path, e.g. a::b::c
54255430
fn resolve_module_relative_path(&mut self,
5426-
path: &Path,
5427-
namespace: Namespace)
5428-
-> Option<(Def, LastPrivate)> {
5431+
path: &Path,
5432+
namespace: Namespace)
5433+
-> Option<(Def, LastPrivate)> {
54295434
let module_path = path.segments.init().iter()
54305435
.map(|ps| ps.identifier.name)
54315436
.collect::<Vec<_>>();
@@ -5442,9 +5447,8 @@ impl<'a> Resolver<'a> {
54425447
let (span, msg) = match err {
54435448
Some((span, msg)) => (span, msg),
54445449
None => {
5445-
let msg = format!("Use of undeclared module `{}`",
5446-
self.names_to_string(
5447-
module_path.as_slice()));
5450+
let msg = format!("Use of undeclared type or module `{}`",
5451+
self.names_to_string(module_path.as_slice()));
54485452
(path.span, msg)
54495453
}
54505454
};
@@ -5538,10 +5542,10 @@ impl<'a> Resolver<'a> {
55385542
}
55395543

55405544
fn resolve_identifier_in_local_ribs(&mut self,
5541-
ident: Ident,
5542-
namespace: Namespace,
5543-
span: Span)
5544-
-> Option<Def> {
5545+
ident: Ident,
5546+
namespace: Namespace,
5547+
span: Span)
5548+
-> Option<Def> {
55455549
// Check the local set of ribs.
55465550
let search_result = match namespace {
55475551
ValueNS => {

src/librustc/middle/subst.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ impl<'tcx> Substs<'tcx> {
112112
}
113113
}
114114

115-
pub fn self_ty(&self) -> Option<Ty<'tcx>> {
115+
pub fn self_ty(&self) -> Option<Ty<'tcx>> {
116116
self.types.get_self().map(|&t| t)
117117
}
118118

src/librustc/middle/traits/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ impl<'cx, 'tcx> Iterator<Rc<ty::TraitRef<'tcx>>> for Supertraits<'cx, 'tcx> {
139139
}
140140

141141
// determine the `self` type, using fresh variables for all variables
142-
// declared on the impl declaration e.g., `impl<A,B> for ~[(A,B)]`
142+
// declared on the impl declaration e.g., `impl<A,B> for Box<[(A,B)]>`
143143
// would return ($0, $1) where $0 and $1 are freshly instantiated type
144144
// variables.
145145
pub fn fresh_substs_for_impl<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,

src/librustc/middle/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1613,7 +1613,7 @@ pub struct RegionParameterDef {
16131613
pub bounds: Vec<ty::Region>,
16141614
}
16151615

1616-
/// Information about the type/lifetime parameters associated with an
1616+
/// Information about the formal type/lifetime parameters associated with an
16171617
/// item or method. Analogous to ast::Generics.
16181618
#[deriving(Clone, Show)]
16191619
pub struct Generics<'tcx> {

src/librustc_typeck/astconv.rs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -522,16 +522,6 @@ fn convert_parenthesized_parameters<'tcx,AC>(this: &AC,
522522
vec![input_ty, output]
523523
}
524524

525-
pub fn instantiate_poly_trait_ref<'tcx,AC,RS>(
526-
this: &AC,
527-
rscope: &RS,
528-
ast_trait_ref: &ast::PolyTraitRef,
529-
self_ty: Option<Ty<'tcx>>)
530-
-> Rc<ty::TraitRef<'tcx>>
531-
where AC: AstConv<'tcx>, RS: RegionScope
532-
{
533-
instantiate_trait_ref(this, rscope, &ast_trait_ref.trait_ref, self_ty)
534-
}
535525

536526
/// Instantiates the path for the given trait reference, assuming that it's bound to a valid trait
537527
/// type. Returns the def_id for the defining trait. Fails if the type is a type other than a trait
@@ -637,7 +627,6 @@ pub fn ast_path_to_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
637627
rscope,
638628
did,
639629
&generics,
640-
None,
641630
path);
642631
let ty = decl_ty.subst(tcx, &substs);
643632
TypeAndSubsts { substs: substs, ty: ty }
@@ -678,7 +667,7 @@ pub fn ast_path_to_ty_relaxed<'tcx,AC,RS>(
678667
Substs::new(VecPerParamSpace::params_from_type(type_params),
679668
VecPerParamSpace::params_from_type(region_params))
680669
} else {
681-
ast_path_substs_for_ty(this, rscope, did, &generics, None, path)
670+
ast_path_substs_for_ty(this, rscope, did, &generics, path)
682671
};
683672

684673
let ty = decl_ty.subst(tcx, &substs);
@@ -777,7 +766,7 @@ fn ast_ty_to_trait_ref<'tcx,AC,RS>(this: &AC,
777766
}
778767
}
779768
_ => {
780-
span_err!(this.tcx().sess, ty.span, E0171,
769+
span_err!(this.tcx().sess, ty.span, E0178,
781770
"expected a path on the left-hand side of `+`, not `{}`",
782771
pprust::ty_to_string(ty));
783772
match ty.node {
@@ -788,8 +777,7 @@ fn ast_ty_to_trait_ref<'tcx,AC,RS>(this: &AC,
788777
pprust::ty_to_string(&*mut_ty.ty),
789778
pprust::bounds_to_string(bounds));
790779
}
791-
792-
ast::TyRptr(Some(ref lt), ref mut_ty) => {
780+
ast::TyRptr(Some(ref lt), ref mut_ty) => {
793781
span_note!(this.tcx().sess, ty.span,
794782
"perhaps you meant `&{} {}({} +{})`? (per RFC 248)",
795783
pprust::lifetime_to_string(lt),
@@ -806,7 +794,6 @@ fn ast_ty_to_trait_ref<'tcx,AC,RS>(this: &AC,
806794
Err(ErrorReported)
807795
}
808796
}
809-
810797
}
811798

812799
fn trait_ref_to_object_type<'tcx,AC,RS>(this: &AC,

src/librustc_typeck/check/method/probe.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ fn get_method_index<'tcx>(tcx: &ty::ctxt<'tcx>,
10201020
// iterating down the supertraits of the object's trait until
10211021
// we find the trait the method came from, counting up the
10221022
// methods from them.
1023-
let mut method_count = 0;
1023+
let mut method_count = n_method;
10241024
ty::each_bound_trait_and_supertraits(tcx, &[subtrait], |bound_ref| {
10251025
if bound_ref.def_id == trait_ref.def_id {
10261026
false
@@ -1035,7 +1035,7 @@ fn get_method_index<'tcx>(tcx: &ty::ctxt<'tcx>,
10351035
true
10361036
}
10371037
});
1038-
method_count + n_method
1038+
method_count
10391039
}
10401040

10411041
impl<'tcx> Candidate<'tcx> {

src/librustc_typeck/check/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5355,6 +5355,7 @@ pub fn instantiate_path<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
53555355
region_count,
53565356
data.lifetimes.len());
53575357
substs.mut_regions().truncate(space, 0);
5358+
break;
53585359
}
53595360
}
53605361
}

0 commit comments

Comments
 (0)