Skip to content

Commit 88d14fd

Browse files
committed
---
yaml --- r: 60157 b: refs/heads/master c: 7a4c6e5 h: refs/heads/master i: 60155: 6f491f6 v: v3
1 parent 983f83b commit 88d14fd

File tree

19 files changed

+225
-373
lines changed

19 files changed

+225
-373
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: dc2ca9d8830a7a34242aa7722f545bc242813af3
2+
refs/heads/master: 7a4c6e587d631c0316d51c9b4a50d406f38221cd
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2d28d645422c1617be58c8ca7ad9a457264ca850
55
refs/heads/try: c50a9d5b664478e533ba1d1d353213d70c8ad589

trunk/src/librustc/driver/session.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ pub impl Session_ {
237237
msg: &str) {
238238
let level = lint::get_lint_settings_level(
239239
self.lint_settings, lint_mode, expr_id, item_id);
240+
let msg = fmt!("%s [-W %s]", msg, lint::get_lint_name(lint_mode));
240241
self.span_lint_level(level, span, msg);
241242
}
242243
fn next_node_id(@self) -> ast::node_id {

trunk/src/librustc/metadata/tydecode.rs

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -555,34 +555,18 @@ 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::ParamBounds {
559-
let mut param_bounds = ty::ParamBounds {
560-
builtin_bounds: ty::EmptyBuiltinBounds(),
561-
trait_bounds: ~[]
562-
};
558+
fn parse_bounds(st: @mut PState, conv: conv_did) -> @~[ty::param_bound] {
559+
let mut bounds = ~[];
563560
loop {
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-
}
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+
});
587570
}
571+
@bounds
588572
}

trunk/src/librustc/metadata/tyencode.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -396,21 +396,19 @@ 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::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'),
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+
}
406410
}
407411
}
408-
409-
for bs.trait_bounds.each |&tp| {
410-
w.write_char('I');
411-
enc_trait_ref(w, cx, tp);
412-
}
413-
414412
w.write_char('.');
415413
}
416414

trunk/src/librustc/middle/kind.rs

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ 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;
1817

1918
use syntax::ast::*;
2019
use syntax::attr::attrs_contains_name;
@@ -339,19 +338,46 @@ pub fn check_bounds(cx: Context,
339338
type_param_def: &ty::TypeParameterDef)
340339
{
341340
let kind = ty::type_contents(cx.tcx, ty);
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);
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+
}
346371
}
347372
}
373+
348374
if !missing.is_empty() {
349375
cx.tcx.sess.span_err(
350376
sp,
351377
fmt!("instantiating a type parameter with an incompatible type \
352378
`%s`, which does not fulfill `%s`",
353379
ty_to_str(cx.tcx, ty),
354-
missing.user_string(cx.tcx)));
380+
str::connect_slices(missing, " ")));
355381
}
356382
}
357383

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

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

trunk/src/librustc/middle/lint.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,14 @@ pub fn get_lint_dict() -> LintDict {
237237
return @map;
238238
}
239239

240+
pub fn get_lint_name(lint_mode: lint) -> ~str {
241+
for lint_table.each |&(name, spec)| {
242+
if spec.lint == lint_mode {
243+
return name.to_str();
244+
}
245+
}
246+
fail!();
247+
}
240248
// This is a highly not-optimal set of data structure decisions.
241249
type LintModes = @mut SmallIntMap<level>;
242250
type LintModeMap = @mut HashMap<ast::node_id, LintModes>;

trunk/src/librustc/middle/subst.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,9 @@ 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-
match self {
84-
&@ref t => @t.subst(tcx, substs)
85-
}
81+
impl<T:Subst> Subst for @~[T] {
82+
fn subst(&self, tcx: ty::ctxt, substs: &ty::substs) -> @~[T] {
83+
@(**self).subst(tcx, substs)
8684
}
8785
}
8886

@@ -117,11 +115,19 @@ impl Subst for ty::BareFnTy {
117115
}
118116
}
119117

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)
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+
}
125131
}
126132
}
127133
}

trunk/src/librustc/middle/trans/monomorphize.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,14 @@ 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.trait_bounds.each |_bound| {
352-
v.push(meth::vtable_id(ccx, /*bad*/copy vts[i]));
353-
i += 1;
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+
}
354359
}
355360
(*subst, if !v.is_empty() { Some(v) } else { None })
356361
})

0 commit comments

Comments
 (0)