Skip to content

Commit 68e5263

Browse files
committed
---
yaml --- r: 179773 b: refs/heads/tmp c: 94c06a1 h: refs/heads/master i: 179771: d0e3cfa v: v3
1 parent e6ca958 commit 68e5263

File tree

38 files changed

+3229
-227
lines changed

38 files changed

+3229
-227
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3434
refs/heads/beta: 44a287e6eb22ec3c2a687fc156813577464017f7
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3636
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
37-
refs/heads/tmp: 1aedc45f85fe9feb70971f9d0c743c4af550a080
37+
refs/heads/tmp: 94c06a1be0ccfcf1a8e105fc98d126de372dbd40

branches/tmp/src/libcollections/str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ pub use core::str::{Lines, LinesAny, MatchIndices, SplitStr, CharRange};
8080
pub use core::str::{Split, SplitTerminator};
8181
pub use core::str::{SplitN, RSplitN};
8282
pub use core::str::{from_utf8, CharEq, Chars, CharIndices, Bytes};
83-
pub use core::str::{from_utf8_unchecked, from_c_str};
83+
pub use core::str::{from_utf8_unchecked, from_c_str, ParseBoolError};
8484
pub use unicode::str::{Words, Graphemes, GraphemeIndices};
8585

8686
/*

branches/tmp/src/librustc/diagnostics.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ register_diagnostics! {
126126
E0312, // lifetime of reference outlives lifetime of borrowed content
127127
E0313, // lifetime of borrowed pointer outlives lifetime of captured variable
128128
E0314, // closure outlives stack frame
129-
E0315 // cannot invoke closure outside of its lifetime
129+
E0315, // cannot invoke closure outside of its lifetime
130+
E0316 // nested quantification of lifetimes
130131
}
131132

132133
__build_diagnostic_array! { DIAGNOSTICS }

branches/tmp/src/librustc/middle/infer/error_reporting.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,8 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
10761076
trait_ref: ast::TraitRef {
10771077
path: new_path,
10781078
ref_id: tr.ref_id,
1079-
}
1079+
},
1080+
span: poly_tr.span,
10801081
}, modifier)
10811082
}
10821083
}

branches/tmp/src/librustc/middle/resolve_lifetime.rs

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,31 @@ pub enum DefRegion {
4545
/* lifetime decl */ ast::NodeId),
4646
}
4747

48-
// maps the id of each lifetime reference to the lifetime decl
49-
// that it corresponds to
48+
// Maps the id of each lifetime reference to the lifetime decl
49+
// that it corresponds to.
5050
pub type NamedRegionMap = NodeMap<DefRegion>;
5151

5252
struct LifetimeContext<'a> {
5353
sess: &'a Session,
5454
named_region_map: &'a mut NamedRegionMap,
5555
scope: Scope<'a>,
5656
def_map: &'a DefMap,
57+
// Deep breath. Our representation for poly trait refs contains a single
58+
// binder and thus we only allow a single level of quantification. However,
59+
// the syntax of Rust permits quantification in two places, e.g., `T: for <'a> Foo<'a>`
60+
// and `for <'a, 'b> &'b T: Foo<'a>`. In order to get the de Bruijn indices
61+
// correct when representing these constraints, we should only introduce one
62+
// scope. However, we want to support both locations for the quantifier and
63+
// during lifetime resolution we want precise information (so we can't
64+
// desugar in an earlier phase).
65+
66+
// SO, if we encounter a quantifier at the outer scope, we set
67+
// trait_ref_hack to true (and introduce a scope), and then if we encounter
68+
// a quantifier at the inner scope, we error. If trait_ref_hack is false,
69+
// then we introduce the scope at the inner quantifier.
70+
71+
// I'm sorry.
72+
trait_ref_hack: bool,
5773
}
5874

5975
enum ScopeChain<'a> {
@@ -80,6 +96,7 @@ pub fn krate(sess: &Session, krate: &ast::Crate, def_map: &DefMap) -> NamedRegio
8096
named_region_map: &mut named_region_map,
8197
scope: &ROOT_SCOPE,
8298
def_map: def_map,
99+
trait_ref_hack: false,
83100
}, krate);
84101
sess.abort_if_errors();
85102
named_region_map
@@ -198,9 +215,22 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
198215
match predicate {
199216
&ast::WherePredicate::BoundPredicate(ast::WhereBoundPredicate{ ref bounded_ty,
200217
ref bounds,
218+
ref bound_lifetimes,
201219
.. }) => {
202-
self.visit_ty(&**bounded_ty);
203-
visit::walk_ty_param_bounds_helper(self, bounds);
220+
if bound_lifetimes.len() > 0 {
221+
self.trait_ref_hack = true;
222+
let result = self.with(LateScope(bound_lifetimes, self.scope),
223+
|old_scope, this| {
224+
this.check_lifetime_defs(old_scope, bound_lifetimes);
225+
this.visit_ty(&**bounded_ty);
226+
visit::walk_ty_param_bounds_helper(this, bounds);
227+
});
228+
self.trait_ref_hack = false;
229+
result
230+
} else {
231+
self.visit_ty(&**bounded_ty);
232+
visit::walk_ty_param_bounds_helper(self, bounds);
233+
}
204234
}
205235
&ast::WherePredicate::RegionPredicate(ast::WhereRegionPredicate{ref lifetime,
206236
ref bounds,
@@ -222,18 +252,27 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
222252
}
223253
}
224254

225-
fn visit_poly_trait_ref(&mut self, trait_ref:
226-
&ast::PolyTraitRef,
255+
fn visit_poly_trait_ref(&mut self,
256+
trait_ref: &ast::PolyTraitRef,
227257
_modifier: &ast::TraitBoundModifier) {
228258
debug!("visit_poly_trait_ref trait_ref={:?}", trait_ref);
229259

230-
self.with(LateScope(&trait_ref.bound_lifetimes, self.scope), |old_scope, this| {
231-
this.check_lifetime_defs(old_scope, &trait_ref.bound_lifetimes);
232-
for lifetime in &trait_ref.bound_lifetimes {
233-
this.visit_lifetime_def(lifetime);
260+
if !self.trait_ref_hack || trait_ref.bound_lifetimes.len() > 0 {
261+
if self.trait_ref_hack {
262+
println!("{:?}", trait_ref.span);
263+
span_err!(self.sess, trait_ref.span, E0316,
264+
"nested quantification of lifetimes");
234265
}
235-
this.visit_trait_ref(&trait_ref.trait_ref)
236-
})
266+
self.with(LateScope(&trait_ref.bound_lifetimes, self.scope), |old_scope, this| {
267+
this.check_lifetime_defs(old_scope, &trait_ref.bound_lifetimes);
268+
for lifetime in &trait_ref.bound_lifetimes {
269+
this.visit_lifetime_def(lifetime);
270+
}
271+
this.visit_trait_ref(&trait_ref.trait_ref)
272+
})
273+
} else {
274+
self.visit_trait_ref(&trait_ref.trait_ref)
275+
}
237276
}
238277

239278
fn visit_trait_ref(&mut self, trait_ref: &ast::TraitRef) {
@@ -251,6 +290,7 @@ impl<'a> LifetimeContext<'a> {
251290
named_region_map: *named_region_map,
252291
scope: &wrap_scope,
253292
def_map: self.def_map,
293+
trait_ref_hack: self.trait_ref_hack,
254294
};
255295
debug!("entering scope {:?}", this.scope);
256296
f(self.scope, &mut this);

branches/tmp/src/librustc/middle/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1478,7 +1478,7 @@ impl<'tcx> PolyTraitRef<'tcx> {
14781478
/// compiler's representation for things like `for<'a> Fn(&'a int)`
14791479
/// (which would be represented by the type `PolyTraitRef ==
14801480
/// Binder<TraitRef>`). Note that when we skolemize, instantiate,
1481-
/// erase, or otherwise "discharge" these bound reons, we change the
1481+
/// erase, or otherwise "discharge" these bound regions, we change the
14821482
/// type from `Binder<T>` to just `T` (see
14831483
/// e.g. `liberate_late_bound_regions`).
14841484
#[derive(Clone, PartialEq, Eq, Hash, Debug)]

branches/tmp/src/librustc/session/config.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ use syntax::diagnostic::{ColorConfig, Auto, Always, Never, SpanHandler};
3333
use syntax::parse;
3434
use syntax::parse::token::InternedString;
3535

36+
use getopts;
3637
use std::collections::HashMap;
3738
use std::collections::hash_map::Entry::{Occupied, Vacant};
38-
use getopts;
39+
use std::env;
3940
use std::fmt;
4041

4142
use llvm;
@@ -821,7 +822,6 @@ pub fn parse_cfgspecs(cfgspecs: Vec<String> ) -> ast::CrateConfig {
821822
}
822823

823824
pub fn build_session_options(matches: &getopts::Matches) -> Options {
824-
825825
let unparsed_crate_types = matches.opt_strs("crate-type");
826826
let crate_types = parse_crate_types_from_list(unparsed_crate_types)
827827
.unwrap_or_else(|e| early_error(&e[]));
@@ -1041,7 +1041,22 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
10411041
crate_name: crate_name,
10421042
alt_std_name: None,
10431043
libs: libs,
1044-
unstable_features: UnstableFeatures::Disallow
1044+
unstable_features: get_unstable_features_setting(),
1045+
}
1046+
}
1047+
1048+
pub fn get_unstable_features_setting() -> UnstableFeatures {
1049+
// Whether this is a feature-staged build, i.e. on the beta or stable channel
1050+
let disable_unstable_features = option_env!("CFG_DISABLE_UNSTABLE_FEATURES").is_some();
1051+
// The secret key needed to get through the rustc build itself by
1052+
// subverting the unstable features lints
1053+
let bootstrap_secret_key = option_env!("CFG_BOOTSTRAP_KEY");
1054+
// The matching key to the above, only known by the build system
1055+
let bootstrap_provided_key = env::var_string("RUSTC_BOOTSTRAP_KEY").ok();
1056+
match (disable_unstable_features, bootstrap_secret_key, bootstrap_provided_key) {
1057+
(_, Some(ref s), Some(ref p)) if s == p => UnstableFeatures::Cheat,
1058+
(true, _, _) => UnstableFeatures::Disallow,
1059+
(false, _, _) => UnstableFeatures::Default
10451060
}
10461061
}
10471062

branches/tmp/src/librustc_driver/driver.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -27,6 +27,7 @@ use rustc_trans::back::write;
2727
use rustc_trans::trans;
2828
use rustc_typeck as typeck;
2929
use rustc_privacy;
30+
use super::Compilation;
3031

3132
use serialize::json;
3233

@@ -55,7 +56,7 @@ pub fn compile_input(sess: Session,
5556
let state = $make_state;
5657
(control.$point.callback)(state);
5758
}
58-
if control.$point.stop {
59+
if control.$point.stop == Compilation::Stop {
5960
return;
6061
}
6162
})}
@@ -206,14 +207,14 @@ impl<'a> CompileController<'a> {
206207
}
207208

208209
pub struct PhaseController<'a> {
209-
pub stop: bool,
210+
pub stop: Compilation,
210211
pub callback: Box<Fn(CompileState) -> () + 'a>,
211212
}
212213

213214
impl<'a> PhaseController<'a> {
214215
pub fn basic() -> PhaseController<'a> {
215216
PhaseController {
216-
stop: false,
217+
stop: Compilation::Continue,
217218
callback: box |_| {},
218219
}
219220
}

0 commit comments

Comments
 (0)