Skip to content

Commit 6768e37

Browse files
committed
---
yaml --- r: 187819 b: refs/heads/tmp c: 4db0b32 h: refs/heads/master i: 187817: 6240573 187815: fd2215b v: v3
1 parent 95802b1 commit 6768e37

21 files changed

+1074
-419
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3434
refs/heads/beta: 522d09dfecbeca1595f25ac58c6d0178bbd21d7d
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3636
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
37-
refs/heads/tmp: 357b41bfcfcfd902d842a20f2c5858b8e196495d
37+
refs/heads/tmp: 4db0b32467535d718d6474de7ae8d1007d900818
3838
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/tmp/src/librustc/metadata/tydecode.rs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,6 @@ fn parse_type_param_def_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F)
822822
assert_eq!(next(st), '|');
823823
let index = parse_u32(st);
824824
assert_eq!(next(st), '|');
825-
let bounds = parse_bounds_(st, conv);
826825
let default = parse_opt(st, |st| parse_ty_(st, conv));
827826
let object_lifetime_default = parse_object_lifetime_default(st, conv);
828827

@@ -831,7 +830,6 @@ fn parse_type_param_def_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F)
831830
def_id: def_id,
832831
space: space,
833832
index: index,
834-
bounds: bounds,
835833
default: default,
836834
object_lifetime_default: object_lifetime_default,
837835
}
@@ -924,18 +922,18 @@ fn parse_bounds_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F)
924922
{
925923
let builtin_bounds = parse_builtin_bounds_(st, conv);
926924

925+
let region_bounds = parse_region_bounds_(st, conv);
926+
927927
let mut param_bounds = ty::ParamBounds {
928-
region_bounds: Vec::new(),
928+
region_bounds: region_bounds,
929929
builtin_bounds: builtin_bounds,
930930
trait_bounds: Vec::new(),
931931
projection_bounds: Vec::new(),
932932
};
933+
934+
933935
loop {
934936
match next(st) {
935-
'R' => {
936-
param_bounds.region_bounds.push(
937-
parse_region_(st, conv));
938-
}
939937
'I' => {
940938
param_bounds.trait_bounds.push(
941939
ty::Binder(parse_trait_ref_(st, conv)));
@@ -953,3 +951,18 @@ fn parse_bounds_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F)
953951
}
954952
}
955953
}
954+
955+
fn parse_region_bounds_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F)
956+
-> Vec<ty::Region> where
957+
F: FnMut(DefIdSource, ast::DefId) -> ast::DefId,
958+
{
959+
let mut region_bounds = Vec::new();
960+
loop {
961+
match next(st) {
962+
'R' => { region_bounds.push(parse_region_(st, conv)); }
963+
'.' => { return region_bounds; }
964+
c => { panic!("parse_bounds: bad bounds ('{}')", c); }
965+
}
966+
}
967+
}
968+

branches/tmp/src/librustc/metadata/tyencode.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -386,10 +386,7 @@ pub fn enc_bounds<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>,
386386
bs: &ty::ParamBounds<'tcx>) {
387387
enc_builtin_bounds(w, cx, &bs.builtin_bounds);
388388

389-
for &r in &bs.region_bounds {
390-
mywrite!(w, "R");
391-
enc_region(w, cx, r);
392-
}
389+
enc_region_bounds(w, cx, &bs.region_bounds);
393390

394391
for tp in &bs.trait_bounds {
395392
mywrite!(w, "I");
@@ -404,12 +401,22 @@ pub fn enc_bounds<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>,
404401
mywrite!(w, ".");
405402
}
406403

404+
pub fn enc_region_bounds<'a, 'tcx>(w: &mut SeekableMemWriter,
405+
cx: &ctxt<'a, 'tcx>,
406+
rs: &[ty::Region]) {
407+
for &r in rs {
408+
mywrite!(w, "R");
409+
enc_region(w, cx, r);
410+
}
411+
412+
mywrite!(w, ".");
413+
}
414+
407415
pub fn enc_type_param_def<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>,
408416
v: &ty::TypeParameterDef<'tcx>) {
409417
mywrite!(w, "{}:{}|{}|{}|",
410418
token::get_name(v.name), (cx.ds)(v.def_id),
411419
v.space.to_uint(), v.index);
412-
enc_bounds(w, cx, &v.bounds);
413420
enc_opt(w, v.default, |w, t| enc_ty(w, cx, t));
414421
enc_object_lifetime_default(w, cx, v.object_lifetime_default);
415422
}

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ use middle::region;
5555
use middle::resolve_lifetime;
5656
use middle::infer;
5757
use middle::stability;
58-
use middle::subst::{self, Subst, Substs, VecPerParamSpace};
58+
use middle::subst::{self, ParamSpace, Subst, Substs, VecPerParamSpace};
5959
use middle::traits;
6060
use middle::ty;
6161
use middle::ty_fold::{self, TypeFoldable, TypeFolder};
@@ -1750,7 +1750,6 @@ pub struct TypeParameterDef<'tcx> {
17501750
pub def_id: ast::DefId,
17511751
pub space: subst::ParamSpace,
17521752
pub index: u32,
1753-
pub bounds: ParamBounds<'tcx>,
17541753
pub default: Option<Ty<'tcx>>,
17551754
pub object_lifetime_default: Option<ObjectLifetimeDefault>,
17561755
}
@@ -2546,6 +2545,13 @@ impl<'tcx> ctxt<'tcx> {
25462545
{
25472546
self.closure_tys.borrow()[def_id].subst(self, substs)
25482547
}
2548+
2549+
pub fn type_parameter_def(&self,
2550+
node_id: ast::NodeId)
2551+
-> TypeParameterDef<'tcx>
2552+
{
2553+
self.ty_param_defs.borrow()[node_id].clone()
2554+
}
25492555
}
25502556

25512557
// Interns a type/name combination, stores the resulting box in cx.interner,
@@ -2996,6 +3002,13 @@ impl<'tcx> TyS<'tcx> {
29963002
_ => None,
29973003
}
29983004
}
3005+
3006+
pub fn is_param(&self, space: ParamSpace, index: u32) -> bool {
3007+
match self.sty {
3008+
ty::ty_param(ref data) => data.space == space && data.idx == index,
3009+
_ => false,
3010+
}
3011+
}
29993012
}
30003013

30013014
pub fn walk_ty<'tcx, F>(ty_root: Ty<'tcx>, mut f: F)

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,6 @@ impl<'tcx> TypeFoldable<'tcx> for ty::TypeParameterDef<'tcx> {
377377
def_id: self.def_id,
378378
space: self.space,
379379
index: self.index,
380-
bounds: self.bounds.fold_with(folder),
381380
default: self.default.fold_with(folder),
382381
object_lifetime_default: self.object_lifetime_default.fold_with(folder),
383382
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ pub struct Options {
9999
pub test: bool,
100100
pub parse_only: bool,
101101
pub no_trans: bool,
102+
pub treat_err_as_bug: bool,
102103
pub no_analysis: bool,
103104
pub debugging_opts: DebuggingOptions,
104105
/// Whether to write dependency files. It's (enabled, optional filename).
@@ -223,6 +224,7 @@ pub fn basic_options() -> Options {
223224
test: false,
224225
parse_only: false,
225226
no_trans: false,
227+
treat_err_as_bug: false,
226228
no_analysis: false,
227229
debugging_opts: basic_debugging_options(),
228230
write_dependency_info: (false, None),
@@ -573,6 +575,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
573575
"Parse only; do not compile, assemble, or link"),
574576
no_trans: bool = (false, parse_bool,
575577
"Run all passes except translation; no output"),
578+
treat_err_as_bug: bool = (false, parse_bool,
579+
"Treat all errors that occur as bugs"),
576580
no_analysis: bool = (false, parse_bool,
577581
"Parse and expand the source, but run no analysis"),
578582
extra_plugins: Vec<String> = (Vec::new(), parse_list,
@@ -843,6 +847,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
843847

844848
let parse_only = debugging_opts.parse_only;
845849
let no_trans = debugging_opts.no_trans;
850+
let treat_err_as_bug = debugging_opts.treat_err_as_bug;
846851
let no_analysis = debugging_opts.no_analysis;
847852

848853
if debugging_opts.debug_llvm {
@@ -1030,6 +1035,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
10301035
test: test,
10311036
parse_only: parse_only,
10321037
no_trans: no_trans,
1038+
treat_err_as_bug: treat_err_as_bug,
10331039
no_analysis: no_analysis,
10341040
debugging_opts: debugging_opts,
10351041
write_dependency_info: write_dependency_info,

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,27 @@ impl Session {
7474
self.diagnostic().handler().fatal(msg)
7575
}
7676
pub fn span_err(&self, sp: Span, msg: &str) {
77+
if self.opts.treat_err_as_bug {
78+
self.span_bug(sp, msg);
79+
}
7780
match split_msg_into_multilines(msg) {
7881
Some(msg) => self.diagnostic().span_err(sp, &msg[..]),
7982
None => self.diagnostic().span_err(sp, msg)
8083
}
8184
}
8285
pub fn span_err_with_code(&self, sp: Span, msg: &str, code: &str) {
86+
if self.opts.treat_err_as_bug {
87+
self.span_bug(sp, msg);
88+
}
8389
match split_msg_into_multilines(msg) {
8490
Some(msg) => self.diagnostic().span_err_with_code(sp, &msg[..], code),
8591
None => self.diagnostic().span_err_with_code(sp, msg, code)
8692
}
8793
}
8894
pub fn err(&self, msg: &str) {
95+
if self.opts.treat_err_as_bug {
96+
self.bug(msg);
97+
}
8998
self.diagnostic().handler().err(msg)
9099
}
91100
pub fn err_count(&self) -> uint {

branches/tmp/src/librustc_trans/back/lto.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,12 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
167167
llvm::LLVMRustAddAnalysisPasses(tm, pm, llmod);
168168
llvm::LLVMRustAddPass(pm, "verify\0".as_ptr() as *const _);
169169

170-
let opt = sess.opts.cg.opt_level.unwrap_or(0) as libc::c_uint;
170+
let opt = match sess.opts.optimize {
171+
config::No => 0,
172+
config::Less => 1,
173+
config::Default => 2,
174+
config::Aggressive => 3,
175+
};
171176

172177
let builder = llvm::LLVMPassManagerBuilderCreate();
173178
llvm::LLVMPassManagerBuilderSetOptLevel(builder, opt);

branches/tmp/src/librustc_typeck/astconv.rs

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,14 @@ use syntax::print::pprust;
7373
pub trait AstConv<'tcx> {
7474
fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx>;
7575

76-
fn get_item_type_scheme(&self, id: ast::DefId) -> ty::TypeScheme<'tcx>;
76+
fn get_item_type_scheme(&self, span: Span, id: ast::DefId)
77+
-> Result<ty::TypeScheme<'tcx>, ErrorReported>;
7778

78-
fn get_trait_def(&self, id: ast::DefId) -> Rc<ty::TraitDef<'tcx>>;
79+
fn get_trait_def(&self, span: Span, id: ast::DefId)
80+
-> Result<Rc<ty::TraitDef<'tcx>>, ErrorReported>;
81+
82+
fn get_type_parameter_bounds(&self, span: Span, def_id: ast::NodeId)
83+
-> Result<Vec<ty::PolyTraitRef<'tcx>>, ErrorReported>;
7984

8085
/// Return an (optional) substitution to convert bound type parameters that
8186
/// are in scope into free ones. This function should only return Some
@@ -683,7 +688,14 @@ fn ast_path_to_trait_ref<'a,'tcx>(
683688
-> Rc<ty::TraitRef<'tcx>>
684689
{
685690
debug!("ast_path_to_trait_ref {:?}", trait_segment);
686-
let trait_def = this.get_trait_def(trait_def_id);
691+
let trait_def = match this.get_trait_def(span, trait_def_id) {
692+
Ok(trait_def) => trait_def,
693+
Err(ErrorReported) => {
694+
// No convenient way to recover from a cycle here. Just bail. Sorry!
695+
this.tcx().sess.abort_if_errors();
696+
this.tcx().sess.bug("ErrorReported returned, but no errors reports?")
697+
}
698+
};
687699

688700
let (regions, types, assoc_bindings) = match trait_segment.parameters {
689701
ast::AngleBracketedParameters(ref data) => {
@@ -860,10 +872,15 @@ fn ast_path_to_ty<'tcx>(
860872
item_segment: &ast::PathSegment)
861873
-> Ty<'tcx>
862874
{
863-
let ty::TypeScheme {
864-
generics,
865-
ty: decl_ty
866-
} = this.get_item_type_scheme(did);
875+
let tcx = this.tcx();
876+
let (generics, decl_ty) = match this.get_item_type_scheme(span, did) {
877+
Ok(ty::TypeScheme { generics, ty: decl_ty }) => {
878+
(generics, decl_ty)
879+
}
880+
Err(ErrorReported) => {
881+
return tcx.types.err;
882+
}
883+
};
867884

868885
let substs = ast_path_substs_for_ty(this, rscope,
869886
span, param_mode,
@@ -1001,20 +1018,17 @@ fn associated_path_def_to_ty<'tcx>(this: &AstConv<'tcx>,
10011018
return (tcx.types.err, ty_path_def);
10021019
};
10031020

1004-
let mut suitable_bounds: Vec<_>;
1005-
let ty_param_name: ast::Name;
1006-
{ // contain scope of refcell:
1007-
let ty_param_defs = tcx.ty_param_defs.borrow();
1008-
let ty_param_def = &ty_param_defs[ty_param_node_id];
1009-
ty_param_name = ty_param_def.name;
1021+
let ty_param_name = tcx.ty_param_defs.borrow()[ty_param_node_id].name;
10101022

1023+
// FIXME(#20300) -- search where clauses, not bounds
1024+
let bounds =
1025+
this.get_type_parameter_bounds(span, ty_param_node_id)
1026+
.unwrap_or(Vec::new());
10111027

1012-
// FIXME(#20300) -- search where clauses, not bounds
1013-
suitable_bounds =
1014-
traits::transitive_bounds(tcx, &ty_param_def.bounds.trait_bounds)
1015-
.filter(|b| trait_defines_associated_type_named(this, b.def_id(), assoc_name))
1016-
.collect();
1017-
}
1028+
let mut suitable_bounds: Vec<_> =
1029+
traits::transitive_bounds(tcx, &bounds)
1030+
.filter(|b| trait_defines_associated_type_named(this, b.def_id(), assoc_name))
1031+
.collect();
10181032

10191033
if suitable_bounds.len() == 0 {
10201034
span_err!(tcx.sess, span, E0220,

0 commit comments

Comments
 (0)