Skip to content

Commit d0fbd2b

Browse files
author
Jakub Wieczorek
committed
---
yaml --- r: 152732 b: refs/heads/try2 c: d4da4ba h: refs/heads/master v: v3
1 parent d971314 commit d0fbd2b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+330
-339
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 34bd1691718346b4e9d0d3508f3c48940c8ec954
8+
refs/heads/try2: d4da4ba4b2f3412c7f9630c4d88ea3e121cd6f2a
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/doc/guide-container.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The standard library provides three owned map/set types:
2626
implement `Eq` and `Hash`
2727
* `collections::TrieMap` and `collections::TrieSet`, requiring the keys to be `uint`
2828
* `collections::TreeMap` and `collections::TreeSet`, requiring the keys
29-
to implement `Ord`
29+
to implement `TotalOrd`
3030

3131
These maps do not use managed pointers so they can be sent between tasks as
3232
long as the key and value types are sendable. Neither the key or value type has

branches/try2/src/doc/rust.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2270,7 +2270,7 @@ impl<T: PartialEq> PartialEq for Foo<T> {
22702270

22712271
Supported traits for `deriving` are:
22722272

2273-
* Comparison traits: `PartialEq`, `Eq`, `PartialOrd`, `Ord`.
2273+
* Comparison traits: `PartialEq`, `TotalEq`, `PartialOrd`, `TotalOrd`.
22742274
* Serialization: `Encodable`, `Decodable`. These require `serialize`.
22752275
* `Clone`, to create `T` from `&T` via a copy.
22762276
* `Hash`, to iterate over the bytes in a data type.

branches/try2/src/doc/tutorial.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2619,8 +2619,8 @@ fn main() {
26192619
}
26202620
~~~
26212621

2622-
The full list of derivable traits is `PartialEq`, `Eq`, `PartialOrd`,
2623-
`Ord`, `Encodable`, `Decodable`, `Clone`,
2622+
The full list of derivable traits is `PartialEq`, `TotalEq`, `Ord`,
2623+
`TotalOrd`, `Encodable`, `Decodable`, `Clone`,
26242624
`Hash`, `Rand`, `Default`, `Zero`, `FromPrimitive` and `Show`.
26252625

26262626
# Crates and the module system

branches/try2/src/etc/generate-deriving-span-tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ def write_file(name, string):
119119
('Clone', [], 1),
120120
('PartialEq', [], 2),
121121
('PartialOrd', ['PartialEq'], 8),
122-
('Eq', ['PartialEq'], 1),
123-
('Ord', ['Eq', 'PartialOrd', 'PartialEq'], 1),
122+
('TotalEq', ['PartialEq'], 1),
123+
('TotalOrd', ['TotalEq', 'PartialOrd', 'PartialEq'], 1),
124124
('Show', [], 1),
125125
('Hash', [], 1)]:
126126
traits[trait] = (ALL, supers, errs)

branches/try2/src/etc/vim/syntax/rust.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ syn keyword rustTrait Ascii AsciiCast OwnedAsciiCast AsciiStr IntoBytes
8282
syn keyword rustTrait ToCStr
8383
syn keyword rustTrait Char
8484
syn keyword rustTrait Clone
85-
syn keyword rustTrait Eq Ord PartialEq PartialOrd Ordering Equiv
85+
syn keyword rustTrait Eq Ord TotalEq TotalOrd Ordering Equiv
8686
syn keyword rustEnumVariant Less Equal Greater
8787
syn keyword rustTrait Container Mutable Map MutableMap Set MutableSet
8888
syn keyword rustTrait FromIterator Extendable
@@ -104,7 +104,7 @@ syn keyword rustTrait Tuple5 Tuple6 Tuple7 Tuple8
104104
syn keyword rustTrait Tuple9 Tuple10 Tuple11 Tuple12
105105
syn keyword rustTrait CloneableVector ImmutableCloneableVector MutableCloneableVector
106106
syn keyword rustTrait ImmutableVector MutableVector
107-
syn keyword rustTrait ImmutableEqVector ImmutableOrdVector MutableOrdVector
107+
syn keyword rustTrait ImmutableEqVector ImmutableTotalOrdVector MutableTotalOrdVector
108108
syn keyword rustTrait Vector VectorVector OwnedVector MutableVectorAllocating
109109
syn keyword rustTrait String
110110
syn keyword rustTrait Vec

branches/try2/src/librustc/metadata/csearch.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ pub fn get_struct_fields(cstore: &cstore::CStore,
193193

194194
pub fn get_type(tcx: &ty::ctxt,
195195
def: ast::DefId)
196-
-> ty::Polytype {
196+
-> ty::ty_param_bounds_and_ty {
197197
let cstore = &tcx.sess.cstore;
198198
let cdata = cstore.get_crate_data(def.krate);
199199
decoder::get_type(&*cdata, def.node, tcx)
@@ -206,7 +206,7 @@ pub fn get_trait_def(tcx: &ty::ctxt, def: ast::DefId) -> ty::TraitDef {
206206
}
207207

208208
pub fn get_field_type(tcx: &ty::ctxt, class_id: ast::DefId,
209-
def: ast::DefId) -> ty::Polytype {
209+
def: ast::DefId) -> ty::ty_param_bounds_and_ty {
210210
let cstore = &tcx.sess.cstore;
211211
let cdata = cstore.get_crate_data(class_id.krate);
212212
let all_items = reader::get_doc(ebml::Doc::new(cdata.data()), tag_items);
@@ -224,7 +224,7 @@ pub fn get_field_type(tcx: &ty::ctxt, class_id: ast::DefId,
224224
def)).to_string()
225225
});
226226
let ty = decoder::item_type(def, the_field, tcx, &*cdata);
227-
ty::Polytype {
227+
ty::ty_param_bounds_and_ty {
228228
generics: ty::Generics {types: VecPerParamSpace::empty(),
229229
regions: VecPerParamSpace::empty()},
230230
ty: ty

branches/try2/src/librustc/metadata/decoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ pub fn get_trait_def(cdata: Cmd,
422422
}
423423

424424
pub fn get_type(cdata: Cmd, id: ast::NodeId, tcx: &ty::ctxt)
425-
-> ty::Polytype {
425+
-> ty::ty_param_bounds_and_ty {
426426

427427
let item = lookup_item(id, cdata.data());
428428

@@ -432,7 +432,7 @@ pub fn get_type(cdata: Cmd, id: ast::NodeId, tcx: &ty::ctxt)
432432
let tp_defs = item_ty_param_defs(item, tcx, cdata, tag_items_data_item_ty_param_bounds);
433433
let rp_defs = item_region_param_defs(item, cdata);
434434

435-
ty::Polytype {
435+
ty::ty_param_bounds_and_ty {
436436
generics: ty::Generics {types: tp_defs,
437437
regions: rp_defs},
438438
ty: t

branches/try2/src/librustc/metadata/encoder.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,11 @@ fn encode_item_variances(ebml_w: &mut Encoder,
196196

197197
fn encode_bounds_and_type(ebml_w: &mut Encoder,
198198
ecx: &EncodeContext,
199-
pty: &ty::Polytype) {
200-
encode_ty_type_param_defs(ebml_w, ecx, &pty.generics.types,
199+
tpt: &ty::ty_param_bounds_and_ty) {
200+
encode_ty_type_param_defs(ebml_w, ecx, &tpt.generics.types,
201201
tag_items_data_item_ty_param_bounds);
202-
encode_region_param_defs(ebml_w, &pty.generics.regions);
203-
encode_type(ecx, ebml_w, pty.ty);
202+
encode_region_param_defs(ebml_w, &tpt.generics.regions);
203+
encode_type(ecx, ebml_w, tpt.ty);
204204
}
205205

206206
fn encode_variant_id(ebml_w: &mut Encoder, vid: DefId) {
@@ -772,8 +772,8 @@ fn encode_info_for_method(ecx: &EncodeContext,
772772
encode_stability(ebml_w, stab);
773773

774774
// The type for methods gets encoded twice, which is unfortunate.
775-
let pty = lookup_item_type(ecx.tcx, m.def_id);
776-
encode_bounds_and_type(ebml_w, ecx, &pty);
775+
let tpt = lookup_item_type(ecx.tcx, m.def_id);
776+
encode_bounds_and_type(ebml_w, ecx, &tpt);
777777

778778
let elem = ast_map::PathName(m.ident.name);
779779
encode_path(ebml_w, impl_path.chain(Some(elem).move_iter()));
@@ -785,7 +785,7 @@ fn encode_info_for_method(ecx: &EncodeContext,
785785
}
786786

787787
for &ast_method in ast_method_opt.iter() {
788-
let any_types = !pty.generics.types.is_empty();
788+
let any_types = !tpt.generics.types.is_empty();
789789
if any_types || is_default_impl || should_inline(ast_method.attrs.as_slice()) {
790790
encode_inlined_item(ecx, ebml_w,
791791
IIMethodRef(local_def(parent_id), false,
@@ -1218,8 +1218,8 @@ fn encode_info_for_item(ecx: &EncodeContext,
12181218
fn_style_static_method_family(
12191219
method_ty.fty.fn_style));
12201220

1221-
let pty = ty::lookup_item_type(tcx, method_def_id);
1222-
encode_bounds_and_type(ebml_w, ecx, &pty);
1221+
let tpt = ty::lookup_item_type(tcx, method_def_id);
1222+
encode_bounds_and_type(ebml_w, ecx, &tpt);
12231223
}
12241224

12251225
_ => {
@@ -1242,8 +1242,8 @@ fn encode_info_for_item(ecx: &EncodeContext,
12421242
// this.
12431243
if method_ty.explicit_self != SelfStatic {
12441244
// FIXME: I feel like there is something funny going on.
1245-
let pty = ty::lookup_item_type(tcx, method_def_id);
1246-
encode_bounds_and_type(ebml_w, ecx, &pty);
1245+
let tpt = ty::lookup_item_type(tcx, method_def_id);
1246+
encode_bounds_and_type(ebml_w, ecx, &tpt);
12471247
}
12481248
encode_method_sort(ebml_w, 'p');
12491249
encode_inlined_item(ecx, ebml_w,

branches/try2/src/librustc/middle/astencode.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -839,9 +839,9 @@ trait ebml_writer_helpers {
839839
fn emit_type_param_def(&mut self,
840840
ecx: &e::EncodeContext,
841841
type_param_def: &ty::TypeParameterDef);
842-
fn emit_polytype(&mut self,
843-
ecx: &e::EncodeContext,
844-
pty: ty::Polytype);
842+
fn emit_tpbt(&mut self,
843+
ecx: &e::EncodeContext,
844+
tpbt: ty::ty_param_bounds_and_ty);
845845
fn emit_substs(&mut self, ecx: &e::EncodeContext, substs: &subst::Substs);
846846
fn emit_auto_adjustment(&mut self, ecx: &e::EncodeContext, adj: &ty::AutoAdjustment);
847847
}
@@ -865,26 +865,26 @@ impl<'a> ebml_writer_helpers for Encoder<'a> {
865865
});
866866
}
867867

868-
fn emit_polytype(&mut self,
868+
fn emit_tpbt(&mut self,
869869
ecx: &e::EncodeContext,
870-
pty: ty::Polytype) {
871-
self.emit_struct("Polytype", 2, |this| {
870+
tpbt: ty::ty_param_bounds_and_ty) {
871+
self.emit_struct("ty_param_bounds_and_ty", 2, |this| {
872872
this.emit_struct_field("generics", 0, |this| {
873873
this.emit_struct("Generics", 2, |this| {
874874
this.emit_struct_field("types", 0, |this| {
875875
Ok(encode_vec_per_param_space(
876-
this, &pty.generics.types,
876+
this, &tpbt.generics.types,
877877
|this, def| this.emit_type_param_def(ecx, def)))
878878
});
879879
this.emit_struct_field("regions", 1, |this| {
880880
Ok(encode_vec_per_param_space(
881-
this, &pty.generics.regions,
881+
this, &tpbt.generics.regions,
882882
|this, def| def.encode(this).unwrap()))
883883
})
884884
})
885885
});
886886
this.emit_struct_field("ty", 1, |this| {
887-
Ok(this.emit_ty(ecx, pty.ty))
887+
Ok(this.emit_ty(ecx, tpbt.ty))
888888
})
889889
});
890890
}
@@ -1030,11 +1030,11 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
10301030
}
10311031

10321032
let lid = ast::DefId { krate: ast::LOCAL_CRATE, node: id };
1033-
for &pty in tcx.tcache.borrow().find(&lid).iter() {
1033+
for &tpbt in tcx.tcache.borrow().find(&lid).iter() {
10341034
ebml_w.tag(c::tag_table_tcache, |ebml_w| {
10351035
ebml_w.id(id);
10361036
ebml_w.tag(c::tag_table_val, |ebml_w| {
1037-
ebml_w.emit_polytype(ecx, pty.clone());
1037+
ebml_w.emit_tpbt(ecx, tpbt.clone());
10381038
})
10391039
})
10401040
}
@@ -1142,8 +1142,8 @@ trait ebml_decoder_decoder_helpers {
11421142
fn read_tys(&mut self, xcx: &ExtendedDecodeContext) -> Vec<ty::t>;
11431143
fn read_type_param_def(&mut self, xcx: &ExtendedDecodeContext)
11441144
-> ty::TypeParameterDef;
1145-
fn read_polytype(&mut self, xcx: &ExtendedDecodeContext)
1146-
-> ty::Polytype;
1145+
fn read_ty_param_bounds_and_ty(&mut self, xcx: &ExtendedDecodeContext)
1146+
-> ty::ty_param_bounds_and_ty;
11471147
fn read_substs(&mut self, xcx: &ExtendedDecodeContext) -> subst::Substs;
11481148
fn read_auto_adjustment(&mut self, xcx: &ExtendedDecodeContext) -> ty::AutoAdjustment;
11491149
fn convert_def_id(&mut self,
@@ -1245,10 +1245,10 @@ impl<'a> ebml_decoder_decoder_helpers for reader::Decoder<'a> {
12451245
}).unwrap()
12461246
}
12471247

1248-
fn read_polytype(&mut self, xcx: &ExtendedDecodeContext)
1249-
-> ty::Polytype {
1250-
self.read_struct("Polytype", 2, |this| {
1251-
Ok(ty::Polytype {
1248+
fn read_ty_param_bounds_and_ty(&mut self, xcx: &ExtendedDecodeContext)
1249+
-> ty::ty_param_bounds_and_ty {
1250+
self.read_struct("ty_param_bounds_and_ty", 2, |this| {
1251+
Ok(ty::ty_param_bounds_and_ty {
12521252
generics: this.read_struct_field("generics", 0, |this| {
12531253
this.read_struct("Generics", 2, |this| {
12541254
Ok(ty::Generics {
@@ -1408,9 +1408,9 @@ fn decode_side_tables(xcx: &ExtendedDecodeContext,
14081408
dcx.tcx.freevars.borrow_mut().insert(id, fv_info);
14091409
}
14101410
c::tag_table_tcache => {
1411-
let pty = val_dsr.read_polytype(xcx);
1411+
let tpbt = val_dsr.read_ty_param_bounds_and_ty(xcx);
14121412
let lid = ast::DefId { krate: ast::LOCAL_CRATE, node: id };
1413-
dcx.tcx.tcache.borrow_mut().insert(lid, pty);
1413+
dcx.tcx.tcache.borrow_mut().insert(lid, tpbt);
14141414
}
14151415
c::tag_table_param_defs => {
14161416
let bounds = val_dsr.read_type_param_def(xcx);

branches/try2/src/librustc/middle/check_match.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -281,21 +281,27 @@ fn missing_constructor(cx: &MatchCheckCtxt, m: &Matrix, left_ty: ty::t) -> Optio
281281
}
282282

283283
fn all_constructors(cx: &MatchCheckCtxt, m: &Matrix, left_ty: ty::t) -> Vec<ctor> {
284+
// This produces a list of all vector constructors that we would expect to appear
285+
// in an exhaustive set of patterns. Because such a list would normally be infinite,
286+
// we narrow it down to only those constructors that actually appear in the inspected
287+
// column, plus, any that are missing and not covered by a pattern with a destructured slice.
284288
fn vec_constructors(m: &Matrix) -> Vec<ctor> {
285289
let max_vec_len = m.iter().map(|r| match r.get(0).node {
286290
PatVec(ref before, _, ref after) => before.len() + after.len(),
287291
_ => 0u
288292
}).max().unwrap_or(0u);
289-
let contains_slice = m.iter().any(|r| match r.get(0).node {
290-
PatVec(_, ref slice, _) => slice.is_some(),
291-
_ => false
292-
});
293-
let lengths = iter::range_inclusive(0u, if contains_slice {
294-
max_vec_len
295-
} else {
296-
max_vec_len + 1
297-
});
298-
lengths.map(|len| vec(len)).collect()
293+
let min_vec_len_with_slice = m.iter().map(|r| match r.get(0).node {
294+
PatVec(ref before, Some(_), ref after) => before.len() + after.len(),
295+
_ => max_vec_len + 1
296+
}).min().unwrap_or(max_vec_len + 1);
297+
let other_lengths = m.iter().map(|r| match r.get(0).node {
298+
PatVec(ref before, _, ref after) => before.len() + after.len(),
299+
_ => 0u
300+
}).filter(|&len| len > min_vec_len_with_slice);
301+
iter::range_inclusive(0u, min_vec_len_with_slice)
302+
.chain(other_lengths)
303+
.map(|len| vec(len))
304+
.collect()
299305
}
300306

301307
match ty::get(left_ty).sty {

branches/try2/src/librustc/middle/lint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ fn check_while_true_expr(cx: &Context, e: &ast::Expr) {
721721
impl<'a> AstConv for Context<'a>{
722722
fn tcx<'a>(&'a self) -> &'a ty::ctxt { self.tcx }
723723

724-
fn get_item_ty(&self, id: ast::DefId) -> ty::Polytype {
724+
fn get_item_ty(&self, id: ast::DefId) -> ty::ty_param_bounds_and_ty {
725725
ty::lookup_item_type(self.tcx, id)
726726
}
727727

branches/try2/src/librustc/middle/trans/_match.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,6 +1200,8 @@ fn pick_col(m: &[Match]) -> uint {
12001200
pub enum branch_kind { no_branch, single, switch, compare, compare_vec_len, }
12011201

12021202
// Compiles a comparison between two things.
1203+
//
1204+
// NB: This must produce an i1, not a Rust bool (i8).
12031205
fn compare_values<'a>(
12041206
cx: &'a Block<'a>,
12051207
lhs: ValueRef,
@@ -1216,7 +1218,11 @@ fn compare_values<'a>(
12161218
format!("comparison of `{}`",
12171219
cx.ty_to_str(rhs_t)).as_slice(),
12181220
StrEqFnLangItem);
1219-
callee::trans_lang_call(cx, did, [lhs, rhs], None)
1221+
let result = callee::trans_lang_call(cx, did, [lhs, rhs], None);
1222+
Result {
1223+
bcx: result.bcx,
1224+
val: bool_to_i1(result.bcx, result.val)
1225+
}
12201226
}
12211227

12221228
let _icx = push_ctxt("compare_values");
@@ -1237,7 +1243,11 @@ fn compare_values<'a>(
12371243
format!("comparison of `{}`",
12381244
cx.ty_to_str(rhs_t)).as_slice(),
12391245
UniqStrEqFnLangItem);
1240-
callee::trans_lang_call(cx, did, [scratch_lhs, scratch_rhs], None)
1246+
let result = callee::trans_lang_call(cx, did, [scratch_lhs, scratch_rhs], None);
1247+
Result {
1248+
bcx: result.bcx,
1249+
val: bool_to_i1(result.bcx, result.val)
1250+
}
12411251
}
12421252
_ => cx.sess().bug("only strings supported in compare_values"),
12431253
},

branches/try2/src/librustc/middle/trans/base.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,7 @@ pub fn maybe_name_value(cx: &CrateContext, v: ValueRef, s: &str) {
501501
// Used only for creating scalar comparison glue.
502502
pub enum scalar_type { nil_type, signed_int, unsigned_int, floating_point, }
503503

504+
// NB: This produces an i1, not a Rust bool (i8).
504505
pub fn compare_scalar_types<'a>(
505506
cx: &'a Block<'a>,
506507
lhs: ValueRef,
@@ -1814,13 +1815,6 @@ pub fn get_fn_llvm_attributes(ccx: &CrateContext, fn_ty: ty::t) -> Vec<(uint, u6
18141815
}
18151816
_ => {}
18161817
}
1817-
1818-
match ty::get(ret_ty).sty {
1819-
ty::ty_bool => {
1820-
attrs.push((lib::llvm::ReturnIndex as uint, lib::llvm::ZExtAttribute as u64));
1821-
}
1822-
_ => {}
1823-
}
18241818
}
18251819

18261820
for (idx, &t) in fn_sig.inputs.iter().enumerate().map(|(i, v)| (i + first_arg_offset, v)) {
@@ -1834,9 +1828,6 @@ pub fn get_fn_llvm_attributes(ccx: &CrateContext, fn_ty: ty::t) -> Vec<(uint, u6
18341828
attrs.push((idx, lib::llvm::NoCaptureAttribute as u64));
18351829
attrs.push((idx, lib::llvm::NonNullAttribute as u64));
18361830
}
1837-
ty::ty_bool => {
1838-
attrs.push((idx, lib::llvm::ZExtAttribute as u64));
1839-
}
18401831
// `~` pointer parameters never alias because ownership is transferred
18411832
ty::ty_uniq(_) => {
18421833
attrs.push((idx, lib::llvm::NoAliasAttribute as u64));

0 commit comments

Comments
 (0)