Skip to content

Commit f71d354

Browse files
committed
---
yaml --- r: 274264 b: refs/heads/stable c: 70d4f26 h: refs/heads/master
1 parent 55a5bfe commit f71d354

File tree

4 files changed

+36
-82
lines changed

4 files changed

+36
-82
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: c0221c8897db309a79990367476177b1230bb264
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: 43c1a173a874f5513db58b2f5321489a00087484
32+
refs/heads/stable: 70d4f263ba3d1db40f246ebe600992abb1ac85be
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/src/libcore/iter.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4252,13 +4252,15 @@ impl<A: Step> RangeFrom<A> {
42524252
///
42534253
/// # Examples
42544254
///
4255-
/// ```ignore
4256-
/// for i in (0u8..).step_by(2) {
4255+
/// ```
4256+
/// # #![feature(step_by)]
4257+
///
4258+
/// for i in (0u8..).step_by(2).take(10) {
42574259
/// println!("{}", i);
42584260
/// }
42594261
/// ```
42604262
///
4261-
/// This prints all even `u8` values.
4263+
/// This prints the first ten even natural integers (0 to 18).
42624264
#[unstable(feature = "step_by", reason = "recent addition",
42634265
issue = "27741")]
42644266
pub fn step_by(self, by: A) -> StepBy<A, Self> {

branches/stable/src/librustc_resolve/lib.rs

Lines changed: 30 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ enum FallbackSuggestion {
723723
}
724724

725725
#[derive(Copy, Clone)]
726-
enum TypeParameters<'tcx, 'a> {
726+
enum TypeParameters<'a> {
727727
NoTypeParameters,
728728
HasTypeParameters(// Type parameters.
729729
&'a Generics,
@@ -733,13 +733,13 @@ enum TypeParameters<'tcx, 'a> {
733733
ParamSpace,
734734

735735
// The kind of the rib used for type parameters.
736-
RibKind<'tcx>),
736+
RibKind),
737737
}
738738

739739
// The rib kind controls the translation of local
740740
// definitions (`Def::Local`) to upvars (`Def::Upvar`).
741741
#[derive(Copy, Clone, Debug)]
742-
enum RibKind<'a> {
742+
enum RibKind {
743743
// No translation needs to be applied.
744744
NormalRibKind,
745745

@@ -758,9 +758,6 @@ enum RibKind<'a> {
758758

759759
// We're in a constant item. Can't refer to dynamic stuff.
760760
ConstantItemRibKind,
761-
762-
// We passed through an anonymous module.
763-
AnonymousModuleRibKind(Module<'a>),
764761
}
765762

766763
#[derive(Copy, Clone)]
@@ -802,13 +799,13 @@ enum BareIdentifierPatternResolution {
802799

803800
/// One local scope.
804801
#[derive(Debug)]
805-
struct Rib<'a> {
802+
struct Rib {
806803
bindings: HashMap<Name, DefLike>,
807-
kind: RibKind<'a>,
804+
kind: RibKind,
808805
}
809806

810-
impl<'a> Rib<'a> {
811-
fn new(kind: RibKind<'a>) -> Rib<'a> {
807+
impl Rib {
808+
fn new(kind: RibKind) -> Rib {
812809
Rib {
813810
bindings: HashMap::new(),
814811
kind: kind,
@@ -1183,13 +1180,13 @@ pub struct Resolver<'a, 'tcx: 'a> {
11831180

11841181
// The current set of local scopes, for values.
11851182
// FIXME #4948: Reuse ribs to avoid allocation.
1186-
value_ribs: Vec<Rib<'a>>,
1183+
value_ribs: Vec<Rib>,
11871184

11881185
// The current set of local scopes, for types.
1189-
type_ribs: Vec<Rib<'a>>,
1186+
type_ribs: Vec<Rib>,
11901187

11911188
// The current set of local scopes, for labels.
1192-
label_ribs: Vec<Rib<'a>>,
1189+
label_ribs: Vec<Rib>,
11931190

11941191
// The trait that the current context can refer to.
11951192
current_trait_ref: Option<(DefId, TraitRef)>,
@@ -1307,10 +1304,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
13071304
self.arenas.modules.alloc(ModuleS::new(parent_link, def, external, is_public))
13081305
}
13091306

1310-
fn get_ribs<'b>(&'b mut self, ns: Namespace) -> &'b mut Vec<Rib<'a>> {
1311-
match ns { ValueNS => &mut self.value_ribs, TypeNS => &mut self.type_ribs }
1312-
}
1313-
13141307
#[inline]
13151308
fn record_import_use(&mut self, import_id: NodeId, name: Name) {
13161309
if !self.make_glob_map {
@@ -2129,7 +2122,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
21292122
}
21302123
}
21312124

2132-
fn with_type_parameter_rib<'b, F>(&'b mut self, type_parameters: TypeParameters<'a, 'b>, f: F)
2125+
fn with_type_parameter_rib<F>(&mut self, type_parameters: TypeParameters, f: F)
21332126
where F: FnOnce(&mut Resolver)
21342127
{
21352128
match type_parameters {
@@ -2198,7 +2191,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
21982191
}
21992192
}
22002193

2201-
fn resolve_function(&mut self, rib_kind: RibKind<'a>, declaration: &FnDecl, block: &Block) {
2194+
fn resolve_function(&mut self, rib_kind: RibKind, declaration: &FnDecl, block: &Block) {
22022195
// Create a value rib for the function.
22032196
self.value_ribs.push(Rib::new(rib_kind));
22042197

@@ -2501,18 +2494,18 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
25012494

25022495
fn resolve_block(&mut self, block: &Block) {
25032496
debug!("(resolving block) entering block");
2497+
self.value_ribs.push(Rib::new(NormalRibKind));
2498+
25042499
// Move down in the graph, if there's an anonymous module rooted here.
25052500
let orig_module = self.current_module;
2506-
let anonymous_module =
2507-
orig_module.anonymous_children.borrow().get(&block.id).map(|module| *module);
2508-
2509-
if let Some(anonymous_module) = anonymous_module {
2510-
debug!("(resolving block) found anonymous module, moving down");
2511-
self.value_ribs.push(Rib::new(AnonymousModuleRibKind(anonymous_module)));
2512-
self.type_ribs.push(Rib::new(AnonymousModuleRibKind(anonymous_module)));
2513-
self.current_module = anonymous_module;
2514-
} else {
2515-
self.value_ribs.push(Rib::new(NormalRibKind));
2501+
match orig_module.anonymous_children.borrow().get(&block.id) {
2502+
None => {
2503+
// Nothing to do.
2504+
}
2505+
Some(anonymous_module) => {
2506+
debug!("(resolving block) found anonymous module, moving down");
2507+
self.current_module = anonymous_module;
2508+
}
25162509
}
25172510

25182511
// Check for imports appearing after non-item statements.
@@ -2545,9 +2538,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
25452538
if !self.resolved {
25462539
self.current_module = orig_module;
25472540
self.value_ribs.pop();
2548-
if let Some(_) = anonymous_module {
2549-
self.type_ribs.pop();
2550-
}
25512541
}
25522542
debug!("(resolving block) leaving block");
25532543
}
@@ -3086,7 +3076,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
30863076
Def::Local(_, node_id) => {
30873077
for rib in ribs {
30883078
match rib.kind {
3089-
NormalRibKind | AnonymousModuleRibKind(..) => {
3079+
NormalRibKind => {
30903080
// Nothing to do. Continue.
30913081
}
30923082
ClosureRibKind(function_id) => {
@@ -3134,8 +3124,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
31343124
Def::TyParam(..) | Def::SelfTy(..) => {
31353125
for rib in ribs {
31363126
match rib.kind {
3137-
NormalRibKind | MethodRibKind | ClosureRibKind(..) |
3138-
AnonymousModuleRibKind(..) => {
3127+
NormalRibKind | MethodRibKind | ClosureRibKind(..) => {
31393128
// Nothing to do. Continue.
31403129
}
31413130
ItemRibKind => {
@@ -3286,10 +3275,13 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
32863275
namespace: Namespace)
32873276
-> Option<LocalDef> {
32883277
// Check the local set of ribs.
3289-
let name = match namespace { ValueNS => ident.name, TypeNS => ident.unhygienic_name };
3278+
let (name, ribs) = match namespace {
3279+
ValueNS => (ident.name, &self.value_ribs),
3280+
TypeNS => (ident.unhygienic_name, &self.type_ribs),
3281+
};
32903282

3291-
for i in (0 .. self.get_ribs(namespace).len()).rev() {
3292-
if let Some(def_like) = self.get_ribs(namespace)[i].bindings.get(&name).cloned() {
3283+
for (i, rib) in ribs.iter().enumerate().rev() {
3284+
if let Some(def_like) = rib.bindings.get(&name).cloned() {
32933285
match def_like {
32943286
DlDef(def) => {
32953287
debug!("(resolving path in local ribs) resolved `{}` to {:?} at {}",
@@ -3309,18 +3301,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
33093301
}
33103302
}
33113303
}
3312-
3313-
if let AnonymousModuleRibKind(module) = self.get_ribs(namespace)[i].kind {
3314-
if let Success((target, _)) = self.resolve_name_in_module(module,
3315-
ident.unhygienic_name,
3316-
namespace,
3317-
PathSearch,
3318-
true) {
3319-
if let Some(def) = target.binding.def() {
3320-
return Some(LocalDef::from_def(def));
3321-
}
3322-
}
3323-
}
33243304
}
33253305

33263306
None

branches/stable/src/test/run-pass/lexical-scoping.rs

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)