Skip to content

Commit 5c06288

Browse files
committed
---
yaml --- r: 59011 b: refs/heads/incoming c: dc2ca9d h: refs/heads/master i: 59009: 381d585 59007: e37c663 v: v3
1 parent 257a2aa commit 5c06288

File tree

17 files changed

+373
-216
lines changed

17 files changed

+373
-216
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: c50a9d5b664478e533ba1d1d353213d70c8ad589
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/incoming: 4757a58798516ad14a6f361f80b275496cb310b8
9+
refs/heads/incoming: dc2ca9d8830a7a34242aa7722f545bc242813af3
1010
refs/heads/dist-snap: 00dbbd01c2aee72982b3e0f9511ae1d4428c3ba9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

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

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -555,18 +555,34 @@ fn parse_type_param_def(st: @mut PState, conv: conv_did) -> ty::TypeParameterDef
555555
bounds: parse_bounds(st, conv)}
556556
}
557557
558-
fn parse_bounds(st: @mut PState, conv: conv_did) -> @~[ty::param_bound] {
559-
let mut bounds = ~[];
558+
fn parse_bounds(st: @mut PState, conv: conv_did) -> @ty::ParamBounds {
559+
let mut param_bounds = ty::ParamBounds {
560+
builtin_bounds: ty::EmptyBuiltinBounds(),
561+
trait_bounds: ~[]
562+
};
560563
loop {
561-
bounds.push(match next(st) {
562-
'S' => ty::bound_owned,
563-
'C' => ty::bound_copy,
564-
'K' => ty::bound_const,
565-
'O' => ty::bound_durable,
566-
'I' => ty::bound_trait(@parse_trait_ref(st, conv)),
567-
'.' => break,
568-
_ => fail!(~"parse_bounds: bad bounds")
569-
});
564+
match next(st) {
565+
'S' => {
566+
param_bounds.builtin_bounds.add(ty::BoundOwned);
567+
}
568+
'C' => {
569+
param_bounds.builtin_bounds.add(ty::BoundCopy);
570+
}
571+
'K' => {
572+
param_bounds.builtin_bounds.add(ty::BoundConst);
573+
}
574+
'O' => {
575+
param_bounds.builtin_bounds.add(ty::BoundStatic);
576+
}
577+
'I' => {
578+
param_bounds.trait_bounds.push(@parse_trait_ref(st, conv));
579+
}
580+
'.' => {
581+
return @param_bounds;
582+
}
583+
_ => {
584+
fail!(~"parse_bounds: bad bounds")
585+
}
586+
}
570587
}
571-
@bounds
572588
}

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

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -396,19 +396,21 @@ fn enc_fn_sig(w: @io::Writer, cx: @ctxt, fsig: &ty::FnSig) {
396396
enc_ty(w, cx, fsig.output);
397397
}
398398

399-
fn enc_bounds(w: @io::Writer, cx: @ctxt, bs: @~[ty::param_bound]) {
400-
for (*bs).each |bound| {
401-
match *bound {
402-
ty::bound_owned => w.write_char('S'),
403-
ty::bound_copy => w.write_char('C'),
404-
ty::bound_const => w.write_char('K'),
405-
ty::bound_durable => w.write_char('O'),
406-
ty::bound_trait(tp) => {
407-
w.write_char('I');
408-
enc_trait_ref(w, cx, tp);
409-
}
399+
fn enc_bounds(w: @io::Writer, cx: @ctxt, bs: @ty::ParamBounds) {
400+
for bs.builtin_bounds.each |bound| {
401+
match bound {
402+
ty::BoundOwned => w.write_char('S'),
403+
ty::BoundCopy => w.write_char('C'),
404+
ty::BoundConst => w.write_char('K'),
405+
ty::BoundStatic => w.write_char('O'),
410406
}
411407
}
408+
409+
for bs.trait_bounds.each |&tp| {
410+
w.write_char('I');
411+
enc_trait_ref(w, cx, tp);
412+
}
413+
412414
w.write_char('.');
413415
}
414416

branches/incoming/src/librustc/middle/kind.rs

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use middle::pat_util;
1414
use middle::ty;
1515
use middle::typeck;
1616
use util::ppaux::{Repr, ty_to_str};
17+
use util::ppaux::UserString;
1718

1819
use syntax::ast::*;
1920
use syntax::attr::attrs_contains_name;
@@ -338,46 +339,19 @@ pub fn check_bounds(cx: Context,
338339
type_param_def: &ty::TypeParameterDef)
339340
{
340341
let kind = ty::type_contents(cx.tcx, ty);
341-
let mut missing = ~[];
342-
for type_param_def.bounds.each |bound| {
343-
match *bound {
344-
ty::bound_trait(_) => {
345-
/* Not our job, checking in typeck */
346-
}
347-
348-
ty::bound_copy => {
349-
if !kind.is_copy(cx.tcx) {
350-
missing.push("Copy");
351-
}
352-
}
353-
354-
ty::bound_durable => {
355-
if !kind.is_durable(cx.tcx) {
356-
missing.push("'static");
357-
}
358-
}
359-
360-
ty::bound_owned => {
361-
if !kind.is_owned(cx.tcx) {
362-
missing.push("Owned");
363-
}
364-
}
365-
366-
ty::bound_const => {
367-
if !kind.is_const(cx.tcx) {
368-
missing.push("Const");
369-
}
370-
}
342+
let mut missing = ty::EmptyBuiltinBounds();
343+
for type_param_def.bounds.builtin_bounds.each |bound| {
344+
if !kind.meets_bound(cx.tcx, bound) {
345+
missing.add(bound);
371346
}
372347
}
373-
374348
if !missing.is_empty() {
375349
cx.tcx.sess.span_err(
376350
sp,
377351
fmt!("instantiating a type parameter with an incompatible type \
378352
`%s`, which does not fulfill `%s`",
379353
ty_to_str(cx.tcx, ty),
380-
str::connect_slices(missing, " ")));
354+
missing.user_string(cx.tcx)));
381355
}
382356
}
383357

@@ -440,7 +414,7 @@ pub fn check_owned(cx: Context, ty: ty::t, sp: span) -> bool {
440414

441415
// note: also used from middle::typeck::regionck!
442416
pub fn check_durable(tcx: ty::ctxt, ty: ty::t, sp: span) -> bool {
443-
if !ty::type_is_durable(tcx, ty) {
417+
if !ty::type_is_static(tcx, ty) {
444418
match ty::get(ty).sty {
445419
ty::ty_param(*) => {
446420
tcx.sess.span_err(sp, "value may contain borrowed \

branches/incoming/src/librustc/middle/subst.rs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,11 @@ impl<T:Subst> Subst for ~[T] {
7878
}
7979
}
8080

81-
impl<T:Subst> Subst for @~[T] {
82-
fn subst(&self, tcx: ty::ctxt, substs: &ty::substs) -> @~[T] {
83-
@(**self).subst(tcx, substs)
81+
impl<T:Subst> Subst for @T {
82+
fn subst(&self, tcx: ty::ctxt, substs: &ty::substs) -> @T {
83+
match self {
84+
&@ref t => @t.subst(tcx, substs)
85+
}
8486
}
8587
}
8688

@@ -115,19 +117,11 @@ impl Subst for ty::BareFnTy {
115117
}
116118
}
117119

118-
impl Subst for ty::param_bound {
119-
fn subst(&self, tcx: ty::ctxt, substs: &ty::substs) -> ty::param_bound {
120-
match self {
121-
&ty::bound_copy |
122-
&ty::bound_durable |
123-
&ty::bound_owned |
124-
&ty::bound_const => {
125-
*self
126-
}
127-
128-
&ty::bound_trait(tref) => {
129-
ty::bound_trait(@tref.subst(tcx, substs))
130-
}
120+
impl Subst for ty::ParamBounds {
121+
fn subst(&self, tcx: ty::ctxt, substs: &ty::substs) -> ty::ParamBounds {
122+
ty::ParamBounds {
123+
builtin_bounds: self.builtin_bounds,
124+
trait_bounds: self.trait_bounds.subst(tcx, substs)
131125
}
132126
}
133127
}

branches/incoming/src/librustc/middle/trans/monomorphize.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -348,14 +348,9 @@ pub fn make_mono_id(ccx: @CrateContext,
348348
let mut i = 0;
349349
vec::map_zip(*item_ty.generics.type_param_defs, substs, |type_param_def, subst| {
350350
let mut v = ~[];
351-
for type_param_def.bounds.each |bound| {
352-
match *bound {
353-
ty::bound_trait(_) => {
354-
v.push(meth::vtable_id(ccx, /*bad*/copy vts[i]));
355-
i += 1;
356-
}
357-
_ => ()
358-
}
351+
for type_param_def.bounds.trait_bounds.each |_bound| {
352+
v.push(meth::vtable_id(ccx, /*bad*/copy vts[i]));
353+
i += 1;
359354
}
360355
(*subst, if !v.is_empty() { Some(v) } else { None })
361356
})

0 commit comments

Comments
 (0)