Skip to content

Commit 886235d

Browse files
committed
Mostly non-behaviour-changing changes (style, etc.)
1 parent 534e6f4 commit 886235d

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
@@ -436,7 +436,7 @@ pub fn get_symbol(data: &[u8], id: ast::NodeId) -> String {
436436
}
437437

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

src/librustc/middle/resolve.rs

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

107107
pub struct Export2 {
108108
pub name: String, // The name of the target.
109-
pub def_id: DefId, // The definition of the target.
109+
pub def_id: DefId, // The definition of the target.
110110
}
111111

112112
// This set contains all exported definitions from external crates. The set does
@@ -296,7 +296,7 @@ enum TypeParameters<'a> {
296296

297297
// The rib kind controls the translation of local
298298
// definitions (`DefLocal`) to upvars (`DefUpvar`).
299-
299+
#[deriving(Show)]
300300
enum RibKind {
301301
// No translation needs to be applied.
302302
NormalRibKind,
@@ -320,6 +320,7 @@ enum RibKind {
320320
}
321321

322322
// Methods can be required or provided. RequiredMethod methods only occur in traits.
323+
#[deriving(Show)]
323324
enum MethodSort {
324325
RequiredMethod,
325326
ProvidedMethod(NodeId)
@@ -382,6 +383,7 @@ enum DuplicateCheckingMode {
382383
}
383384

384385
/// One local scope.
386+
#[deriving(Show)]
385387
struct Rib {
386388
bindings: HashMap<Name, DefLike>,
387389
kind: RibKind,
@@ -688,8 +690,11 @@ impl NameBindings {
688690
let type_def = self.type_def.borrow().clone();
689691
match type_def {
690692
None => {
691-
let module = Module::new(parent_link, def_id, kind,
692-
external, is_public);
693+
let module = Module::new(parent_link,
694+
def_id,
695+
kind,
696+
external,
697+
is_public);
693698
*self.type_def.borrow_mut() = Some(TypeNsDef {
694699
modifiers: modifiers,
695700
module_def: Some(Rc::new(module)),
@@ -734,9 +739,9 @@ impl NameBindings {
734739
}
735740
Some(type_def) => {
736741
*self.type_def.borrow_mut() = Some(TypeNsDef {
742+
module_def: type_def.module_def,
737743
type_def: Some(def),
738744
type_span: Some(sp),
739-
module_def: type_def.module_def,
740745
modifiers: modifiers,
741746
});
742747
}
@@ -1246,7 +1251,7 @@ impl<'a> Resolver<'a> {
12461251
}
12471252

12481253
fn get_parent_link(&mut self, parent: ReducedGraphParent, name: Name)
1249-
-> ParentLink {
1254+
-> ParentLink {
12501255
match parent {
12511256
ModuleReducedGraphParent(module_) => {
12521257
return ModuleParentLink(module_.downgrade(), name);
@@ -1538,14 +1543,14 @@ impl<'a> Resolver<'a> {
15381543

15391544
ItemImpl(_, Some(_), _, _) => parent,
15401545

1541-
ItemTrait(_, _, _, ref methods) => {
1546+
ItemTrait(_, _, _, ref items) => {
15421547
let name_bindings =
15431548
self.add_child(name,
15441549
parent.clone(),
15451550
ForbidDuplicateTypesAndModules,
15461551
sp);
15471552

1548-
// Add all the methods within to a new module.
1553+
// Add all the items within to a new module.
15491554
let parent_link = self.get_parent_link(parent.clone(), name);
15501555
name_bindings.define_module(parent_link,
15511556
Some(local_def(item.id)),
@@ -1558,13 +1563,12 @@ impl<'a> Resolver<'a> {
15581563

15591564
let def_id = local_def(item.id);
15601565

1561-
// Add the names of all the methods to the trait info.
1562-
for method in methods.iter() {
1563-
let (name, kind) = match *method {
1566+
// Add the names of all the items to the trait info.
1567+
for trait_item in items.iter() {
1568+
let (name, kind) = match *trait_item {
15641569
ast::RequiredMethod(_) |
15651570
ast::ProvidedMethod(_) => {
1566-
let ty_m =
1567-
ast_util::trait_item_to_ty_method(method);
1571+
let ty_m = ast_util::trait_item_to_ty_method(trait_item);
15681572

15691573
let name = ty_m.ident.name;
15701574

@@ -3288,7 +3292,7 @@ impl<'a> Resolver<'a> {
32883292
use_lexical_scope: UseLexicalScopeFlag,
32893293
span: Span,
32903294
name_search_type: NameSearchType)
3291-
-> ResolveResult<(Rc<Module>, LastPrivate)> {
3295+
-> ResolveResult<(Rc<Module>, LastPrivate)> {
32923296
let module_path_len = module_path.len();
32933297
assert!(module_path_len > 0);
32943298

@@ -3317,7 +3321,9 @@ impl<'a> Resolver<'a> {
33173321
mpath.slice_to(idx - 1));
33183322
return Failed(Some((span, msg)));
33193323
},
3320-
None => return Failed(None),
3324+
None => {
3325+
return Failed(None)
3326+
}
33213327
}
33223328
}
33233329
Failed(err) => return Failed(err),
@@ -3510,8 +3516,7 @@ impl<'a> Resolver<'a> {
35103516
-> ResolveResult<Rc<Module>> {
35113517
// If this module is an anonymous module, resolve the item in the
35123518
// lexical scope. Otherwise, resolve the item from the crate root.
3513-
let resolve_result = self.resolve_item_in_lexical_scope(
3514-
module_, name, TypeNS);
3519+
let resolve_result = self.resolve_item_in_lexical_scope(module_, name, TypeNS);
35153520
match resolve_result {
35163521
Success((target, _)) => {
35173522
let bindings = &*target.bindings;
@@ -5262,15 +5267,15 @@ impl<'a> Resolver<'a> {
52625267

52635268
// resolve a single identifier (used as a varref)
52645269
fn resolve_identifier(&mut self,
5265-
identifier: Ident,
5266-
namespace: Namespace,
5267-
check_ribs: bool,
5268-
span: Span)
5269-
-> Option<(Def, LastPrivate)> {
5270+
identifier: Ident,
5271+
namespace: Namespace,
5272+
check_ribs: bool,
5273+
span: Span)
5274+
-> Option<(Def, LastPrivate)> {
52705275
if check_ribs {
52715276
match self.resolve_identifier_in_local_ribs(identifier,
5272-
namespace,
5273-
span) {
5277+
namespace,
5278+
span) {
52745279
Some(def) => {
52755280
return Some((def, LastMod(AllPublic)));
52765281
}
@@ -5288,7 +5293,7 @@ impl<'a> Resolver<'a> {
52885293
containing_module: Rc<Module>,
52895294
name: Name,
52905295
namespace: Namespace)
5291-
-> NameDefinition {
5296+
-> NameDefinition {
52925297
// First, search children.
52935298
self.populate_module_if_necessary(&containing_module);
52945299

@@ -5358,9 +5363,9 @@ impl<'a> Resolver<'a> {
53585363

53595364
// resolve a "module-relative" path, e.g. a::b::c
53605365
fn resolve_module_relative_path(&mut self,
5361-
path: &Path,
5362-
namespace: Namespace)
5363-
-> Option<(Def, LastPrivate)> {
5366+
path: &Path,
5367+
namespace: Namespace)
5368+
-> Option<(Def, LastPrivate)> {
53645369
let module_path = path.segments.init().iter()
53655370
.map(|ps| ps.identifier.name)
53665371
.collect::<Vec<_>>();
@@ -5377,9 +5382,8 @@ impl<'a> Resolver<'a> {
53775382
let (span, msg) = match err {
53785383
Some((span, msg)) => (span, msg),
53795384
None => {
5380-
let msg = format!("Use of undeclared module `{}`",
5381-
self.names_to_string(
5382-
module_path.as_slice()));
5385+
let msg = format!("Use of undeclared type or module `{}`",
5386+
self.names_to_string(module_path.as_slice()));
53835387
(path.span, msg)
53845388
}
53855389
};
@@ -5473,10 +5477,10 @@ impl<'a> Resolver<'a> {
54735477
}
54745478

54755479
fn resolve_identifier_in_local_ribs(&mut self,
5476-
ident: Ident,
5477-
namespace: Namespace,
5478-
span: Span)
5479-
-> Option<Def> {
5480+
ident: Ident,
5481+
namespace: Namespace,
5482+
span: Span)
5483+
-> Option<Def> {
54805484
// Check the local set of ribs.
54815485
let search_result = match namespace {
54825486
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
@@ -1369,7 +1369,7 @@ pub struct RegionParameterDef {
13691369
pub bounds: Vec<ty::Region>,
13701370
}
13711371

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

src/librustc/middle/typeck/astconv.rs

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

464-
pub fn instantiate_poly_trait_ref<'tcx,AC,RS>(
465-
this: &AC,
466-
rscope: &RS,
467-
ast_trait_ref: &ast::PolyTraitRef,
468-
self_ty: Option<Ty<'tcx>>)
469-
-> Rc<ty::TraitRef<'tcx>>
470-
where AC: AstConv<'tcx>, RS: RegionScope
471-
{
472-
instantiate_trait_ref(this, rscope, &ast_trait_ref.trait_ref, self_ty)
473-
}
474464

475465
/// Instantiates the path for the given trait reference, assuming that it's bound to a valid trait
476466
/// type. Returns the def_id for the defining trait. Fails if the type is a type other than a trait
@@ -576,7 +566,6 @@ pub fn ast_path_to_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
576566
rscope,
577567
did,
578568
&generics,
579-
None,
580569
path);
581570
let ty = decl_ty.subst(tcx, &substs);
582571
TypeAndSubsts { substs: substs, ty: ty }
@@ -617,7 +606,7 @@ pub fn ast_path_to_ty_relaxed<'tcx,AC,RS>(
617606
Substs::new(VecPerParamSpace::params_from_type(type_params),
618607
VecPerParamSpace::params_from_type(region_params))
619608
} else {
620-
ast_path_substs_for_ty(this, rscope, did, &generics, None, path)
609+
ast_path_substs_for_ty(this, rscope, did, &generics, path)
621610
};
622611

623612
let ty = decl_ty.subst(tcx, &substs);
@@ -784,7 +773,7 @@ fn ast_ty_to_trait_ref<'tcx,AC,RS>(this: &AC,
784773
}
785774
}
786775
_ => {
787-
span_err!(this.tcx().sess, ty.span, E0171,
776+
span_err!(this.tcx().sess, ty.span, E0178,
788777
"expected a path on the left-hand side of `+`, not `{}`",
789778
pprust::ty_to_string(ty));
790779
match ty.node {
@@ -795,8 +784,7 @@ fn ast_ty_to_trait_ref<'tcx,AC,RS>(this: &AC,
795784
pprust::ty_to_string(&*mut_ty.ty),
796785
pprust::bounds_to_string(bounds));
797786
}
798-
799-
ast::TyRptr(Some(ref lt), ref mut_ty) => {
787+
ast::TyRptr(Some(ref lt), ref mut_ty) => {
800788
span_note!(this.tcx().sess, ty.span,
801789
"perhaps you meant `&{} {}({} +{})`? (per RFC 248)",
802790
pprust::lifetime_to_string(lt),
@@ -813,7 +801,6 @@ fn ast_ty_to_trait_ref<'tcx,AC,RS>(this: &AC,
813801
Err(ErrorReported)
814802
}
815803
}
816-
817804
}
818805

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

src/librustc/middle/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/middle/typeck/check/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5344,6 +5344,7 @@ pub fn instantiate_path<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
53445344
region_count,
53455345
data.lifetimes.len());
53465346
substs.mut_regions().truncate(space, 0);
5347+
break;
53475348
}
53485349
}
53495350
}

0 commit comments

Comments
 (0)