Skip to content

Commit 64d4fd5

Browse files
committed
---
yaml --- r: 54228 b: refs/heads/dist-snap c: 91cb668 h: refs/heads/master v: v3
1 parent d8e7a9a commit 64d4fd5

File tree

16 files changed

+123
-184
lines changed

16 files changed

+123
-184
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
99
refs/heads/incoming: 44d4d6de762f3f9aae1fedcf454c66b79b3ad58d
10-
refs/heads/dist-snap: 772293a25120367bed984243fffd59fcb4b8cd80
10+
refs/heads/dist-snap: 91cb6687a8869fa14aef8d978fb13e330c711cd3
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/libcore/cmp.rs

Lines changed: 22 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -45,62 +45,31 @@ pub trait TotalOrd {
4545
fn cmp(&self, other: &Self) -> Ordering;
4646
}
4747

48-
#[inline(always)]
49-
fn icmp<T: Ord>(a: &T, b: &T) -> Ordering {
50-
if *a < *b { Less }
51-
else if *a > *b { Greater }
52-
else { Equal }
53-
}
54-
55-
impl TotalOrd for u8 {
56-
#[inline(always)]
57-
fn cmp(&self, other: &u8) -> Ordering { icmp(self, other) }
58-
}
59-
60-
impl TotalOrd for u16 {
61-
#[inline(always)]
62-
fn cmp(&self, other: &u16) -> Ordering { icmp(self, other) }
63-
}
64-
65-
impl TotalOrd for u32 {
66-
#[inline(always)]
67-
fn cmp(&self, other: &u32) -> Ordering { icmp(self, other) }
68-
}
69-
70-
impl TotalOrd for u64 {
71-
#[inline(always)]
72-
fn cmp(&self, other: &u64) -> Ordering { icmp(self, other) }
73-
}
74-
75-
impl TotalOrd for i8 {
76-
#[inline(always)]
77-
fn cmp(&self, other: &i8) -> Ordering { icmp(self, other) }
78-
}
79-
80-
impl TotalOrd for i16 {
81-
#[inline(always)]
82-
fn cmp(&self, other: &i16) -> Ordering { icmp(self, other) }
83-
}
84-
85-
impl TotalOrd for i32 {
86-
#[inline(always)]
87-
fn cmp(&self, other: &i32) -> Ordering { icmp(self, other) }
88-
}
48+
macro_rules! totalord_impl(
49+
($t:ty) => {
50+
impl TotalOrd for $t {
51+
#[inline(always)]
52+
fn cmp(&self, other: &$t) -> Ordering {
53+
if *self < *other { Less }
54+
else if *self > *other { Greater }
55+
else { Equal }
56+
}
57+
}
58+
}
59+
)
8960

90-
impl TotalOrd for i64 {
91-
#[inline(always)]
92-
fn cmp(&self, other: &i64) -> Ordering { icmp(self, other) }
93-
}
61+
totalord_impl!(u8)
62+
totalord_impl!(u16)
63+
totalord_impl!(u32)
64+
totalord_impl!(u64)
9465

95-
impl TotalOrd for int {
96-
#[inline(always)]
97-
fn cmp(&self, other: &int) -> Ordering { icmp(self, other) }
98-
}
66+
totalord_impl!(i8)
67+
totalord_impl!(i16)
68+
totalord_impl!(i32)
69+
totalord_impl!(i64)
9970

100-
impl TotalOrd for uint {
101-
#[inline(always)]
102-
fn cmp(&self, other: &uint) -> Ordering { icmp(self, other) }
103-
}
71+
totalord_impl!(int)
72+
totalord_impl!(uint)
10473

10574
/**
10675
* Trait for values that can be compared for a sort-order.

branches/dist-snap/src/librustc/metadata/tydecode.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ use core::vec;
2424
use syntax::ast;
2525
use syntax::ast::*;
2626
use syntax::codemap::{respan, dummy_sp};
27-
use syntax::opt_vec;
2827

2928
// Compact string representation for ty::t values. API ty_str &
3029
// parse_from_str. Extra parameters are for converting to/from def_ids in the
@@ -480,9 +479,7 @@ fn parse_sig(st: @mut PState, conv: conv_did) -> ty::FnSig {
480479
}
481480
st.pos += 1u; // eat the ']'
482481
let ret_ty = parse_ty(st, conv);
483-
ty::FnSig {bound_lifetime_names: opt_vec::Empty, // FIXME(#4846)
484-
inputs: inputs,
485-
output: ret_ty}
482+
ty::FnSig {inputs: inputs, output: ret_ty}
486483
}
487484
488485
// Rust metadata parsing

branches/dist-snap/src/librustc/middle/trans/foreign.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ use util::ppaux::ty_to_str;
4040
use syntax::codemap::span;
4141
use syntax::{ast, ast_util};
4242
use syntax::{attr, ast_map};
43-
use syntax::opt_vec;
4443
use syntax::parse::token::special_idents;
4544

4645
fn abi_info(arch: session::arch) -> @cabi::ABIInfo {
@@ -616,8 +615,7 @@ pub fn trans_intrinsic(ccx: @CrateContext,
616615
sigil: ast::BorrowedSigil,
617616
onceness: ast::Many,
618617
region: ty::re_bound(ty::br_anon(0)),
619-
sig: FnSig {bound_lifetime_names: opt_vec::Empty,
620-
inputs: ~[arg {mode: ast::expl(ast::by_copy),
618+
sig: FnSig {inputs: ~[arg {mode: ast::expl(ast::by_copy),
621619
ty: star_u8}],
622620
output: ty::mk_nil(bcx.tcx())}
623621
});

branches/dist-snap/src/librustc/middle/trans/monomorphize.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ use syntax::ast;
3737
use syntax::ast_map;
3838
use syntax::ast_map::{path, path_mod, path_name};
3939
use syntax::ast_util::local_def;
40-
use syntax::opt_vec;
4140
use syntax::parse::token::special_idents;
4241

4342
pub fn monomorphic_fn(ccx: @CrateContext,
@@ -283,8 +282,7 @@ pub fn normalize_for_monomorphization(tcx: ty::ctxt,
283282
ty::BareFnTy {
284283
purity: ast::impure_fn,
285284
abi: ast::RustAbi,
286-
sig: FnSig {bound_lifetime_names: opt_vec::Empty,
287-
inputs: ~[],
285+
sig: FnSig {inputs: ~[],
288286
output: ty::mk_nil(tcx)}}))
289287
}
290288
ty::ty_closure(ref fty) => {
@@ -318,8 +316,7 @@ pub fn normalize_for_monomorphization(tcx: ty::ctxt,
318316
sigil: sigil,
319317
onceness: ast::Many,
320318
region: ty::re_static,
321-
sig: ty::FnSig {bound_lifetime_names: opt_vec::Empty,
322-
inputs: ~[],
319+
sig: ty::FnSig {inputs: ~[],
323320
output: ty::mk_nil(tcx)}})
324321
}
325322
}

branches/dist-snap/src/librustc/middle/ty.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ use syntax::codemap::span;
4545
use syntax::codemap;
4646
use syntax::print::pprust;
4747
use syntax::{ast, ast_map};
48-
use syntax::opt_vec::OptVec;
49-
use syntax::opt_vec;
5048
use syntax;
5149

5250
// Data types
@@ -378,12 +376,10 @@ pub struct ClosureTy {
378376
* Signature of a function type, which I have arbitrarily
379377
* decided to use to refer to the input/output types.
380378
*
381-
* - `lifetimes` is the list of region names bound in this fn.
382379
* - `inputs` is the list of arguments and their modes.
383380
* - `output` is the return type. */
384381
#[deriving(Eq)]
385382
pub struct FnSig {
386-
bound_lifetime_names: OptVec<ast::ident>,
387383
inputs: ~[arg],
388384
output: t
389385
}
@@ -1066,8 +1062,7 @@ pub fn mk_ctor_fn(cx: ctxt, input_tys: &[ty::t], output: ty::t) -> t {
10661062
BareFnTy {
10671063
purity: ast::pure_fn,
10681064
abi: ast::RustAbi,
1069-
sig: FnSig {bound_lifetime_names: opt_vec::Empty,
1070-
inputs: input_args,
1065+
sig: FnSig {inputs: input_args,
10711066
output: output}})
10721067
}
10731068

@@ -1208,7 +1203,6 @@ pub fn fold_sig(sig: &FnSig, fldop: &fn(t) -> t) -> FnSig {
12081203
};
12091204

12101205
FnSig {
1211-
bound_lifetime_names: copy sig.bound_lifetime_names,
12121206
inputs: args,
12131207
output: fldop(sig.output)
12141208
}

branches/dist-snap/src/librustc/middle/typeck/astconv.rs

Lines changed: 44 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ use middle::const_eval;
5858
use middle::ty::{arg, field, substs};
5959
use middle::ty::{ty_param_substs_and_ty};
6060
use middle::ty;
61-
use middle::typeck::rscope::{in_binding_rscope};
61+
use middle::typeck::rscope::{in_binding_rscope, in_binding_rscope_ext};
6262
use middle::typeck::rscope::{region_scope, type_rscope, RegionError};
6363
use middle::typeck::rscope::{RegionParamNames};
6464

@@ -67,7 +67,6 @@ use core::vec;
6767
use syntax::{ast, ast_util};
6868
use syntax::codemap::span;
6969
use syntax::opt_vec::OptVec;
70-
use syntax::opt_vec;
7170
use syntax::print::pprust::{lifetime_to_str, path_to_str};
7271
use syntax::parse::token::special_idents;
7372
use util::common::indenter;
@@ -348,7 +347,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:region_scope + Copy + Durable>(
348347
}
349348
ast::ty_bare_fn(ref bf) => {
350349
ty::mk_bare_fn(tcx, ty_of_bare_fn(self, rscope, bf.purity,
351-
bf.abi, &bf.lifetimes, &bf.decl))
350+
bf.abi, &bf.decl))
352351
}
353352
ast::ty_closure(ref f) => {
354353
let fn_decl = ty_of_closure(self,
@@ -509,50 +508,18 @@ pub fn ty_of_arg<AC:AstConv,RS:region_scope + Copy + Durable>(
509508
arg {mode: mode, ty: ty}
510509
}
511510

512-
pub fn bound_lifetimes<AC:AstConv>(
513-
self: &AC,
514-
ast_lifetimes: &OptVec<ast::Lifetime>) -> OptVec<ast::ident>
515-
{
516-
/*!
517-
*
518-
* Converts a list of lifetimes into a list of bound identifier
519-
* names. Does not permit special names like 'static or 'self to
520-
* be bound. Note that this function is for use in closures,
521-
* methods, and fn definitions. It is legal to bind 'self in a
522-
* type. Eventually this distinction should go away and the same
523-
* rules should apply everywhere ('self would not be a special name
524-
* at that point).
525-
*/
526-
527-
let special_idents = [special_idents::static, special_idents::self_];
528-
let mut bound_lifetime_names = opt_vec::Empty;
529-
ast_lifetimes.map_to_vec(|ast_lifetime| {
530-
if special_idents.any(|&i| i == ast_lifetime.ident) {
531-
self.tcx().sess.span_err(
532-
ast_lifetime.span,
533-
fmt!("illegal lifetime parameter name: `%s`",
534-
lifetime_to_str(ast_lifetime, self.tcx().sess.intr())));
535-
} else {
536-
bound_lifetime_names.push(ast_lifetime.ident);
537-
}
538-
});
539-
bound_lifetime_names
540-
}
541-
542511
pub fn ty_of_bare_fn<AC:AstConv,RS:region_scope + Copy + Durable>(
543-
self: &AC,
544-
rscope: &RS,
545-
purity: ast::purity,
546-
abi: ast::Abi,
547-
lifetimes: &OptVec<ast::Lifetime>,
548-
decl: &ast::fn_decl) -> ty::BareFnTy
549-
{
512+
self: &AC,
513+
rscope: &RS,
514+
purity: ast::purity,
515+
abi: ast::Abi,
516+
decl: &ast::fn_decl)
517+
-> ty::BareFnTy {
550518
debug!("ty_of_bare_fn");
551519

552520
// new region names that appear inside of the fn decl are bound to
553521
// that function type
554-
let bound_lifetime_names = bound_lifetimes(self, lifetimes);
555-
let rb = in_binding_rscope(rscope, RegionParamNames(copy bound_lifetime_names));
522+
let rb = in_binding_rscope(rscope);
556523

557524
let input_tys = decl.inputs.map(|a| ty_of_arg(self, &rb, *a, None));
558525
let output_ty = match decl.output.node {
@@ -563,9 +530,34 @@ pub fn ty_of_bare_fn<AC:AstConv,RS:region_scope + Copy + Durable>(
563530
ty::BareFnTy {
564531
purity: purity,
565532
abi: abi,
566-
sig: ty::FnSig {bound_lifetime_names: bound_lifetime_names,
567-
inputs: input_tys,
568-
output: output_ty}
533+
sig: ty::FnSig {inputs: input_tys, output: output_ty}
534+
}
535+
}
536+
537+
pub fn ty_of_bare_fn_ext<AC:AstConv,RS:region_scope + Copy + Durable>(
538+
self: &AC,
539+
rscope: &RS,
540+
purity: ast::purity,
541+
abi: ast::Abi,
542+
decl: &ast::fn_decl,
543+
+region_param_names: RegionParamNames)
544+
-> ty::BareFnTy {
545+
debug!("ty_of_bare_fn_ext");
546+
547+
// new region names that appear inside of the fn decl are bound to
548+
// that function type
549+
let rb = in_binding_rscope_ext(rscope, region_param_names);
550+
551+
let input_tys = decl.inputs.map(|a| ty_of_arg(self, &rb, *a, None));
552+
let output_ty = match decl.output.node {
553+
ast::ty_infer => self.ty_infer(decl.output.span),
554+
_ => ast_ty_to_ty(self, &rb, decl.output)
555+
};
556+
557+
ty::BareFnTy {
558+
purity: purity,
559+
abi: abi,
560+
sig: ty::FnSig {inputs: input_tys, output: output_ty}
569561
}
570562
}
571563

@@ -577,16 +569,10 @@ pub fn ty_of_closure<AC:AstConv,RS:region_scope + Copy + Durable>(
577569
onceness: ast::Onceness,
578570
opt_lifetime: Option<@ast::Lifetime>,
579571
decl: &ast::fn_decl,
580-
expected_sig: Option<ty::FnSig>,
572+
expected_tys: Option<ty::FnSig>,
581573
lifetimes: &OptVec<ast::Lifetime>,
582574
span: span)
583-
-> ty::ClosureTy
584-
{
585-
// The caller should not both provide explicit bound lifetime
586-
// names and expected types. Either we infer the bound lifetime
587-
// names or they are provided, but not both.
588-
fail_unless!(lifetimes.is_empty() || expected_sig.is_none());
589-
575+
-> ty::ClosureTy {
590576
debug!("ty_of_fn_decl");
591577
let _i = indenter();
592578

@@ -613,19 +599,19 @@ pub fn ty_of_closure<AC:AstConv,RS:region_scope + Copy + Durable>(
613599

614600
// new region names that appear inside of the fn decl are bound to
615601
// that function type
616-
let bound_lifetime_names = bound_lifetimes(self, lifetimes);
617-
let rb = in_binding_rscope(rscope, RegionParamNames(copy bound_lifetime_names));
602+
let region_param_names = RegionParamNames::from_lifetimes(lifetimes);
603+
let rb = in_binding_rscope_ext(rscope, region_param_names);
618604

619605
let input_tys = do decl.inputs.mapi |i, a| {
620-
let expected_arg_ty = do expected_sig.chain_ref |e| {
606+
let expected_arg_ty = do expected_tys.chain_ref |e| {
621607
// no guarantee that the correct number of expected args
622608
// were supplied
623609
if i < e.inputs.len() {Some(e.inputs[i])} else {None}
624610
};
625611
ty_of_arg(self, &rb, *a, expected_arg_ty)
626612
};
627613

628-
let expected_ret_ty = expected_sig.map(|e| e.output);
614+
let expected_ret_ty = expected_tys.map(|e| e.output);
629615
let output_ty = match decl.output.node {
630616
ast::ty_infer if expected_ret_ty.is_some() => expected_ret_ty.get(),
631617
ast::ty_infer => self.ty_infer(decl.output.span),
@@ -637,8 +623,7 @@ pub fn ty_of_closure<AC:AstConv,RS:region_scope + Copy + Durable>(
637623
sigil: sigil,
638624
onceness: onceness,
639625
region: bound_region,
640-
sig: ty::FnSig {bound_lifetime_names: bound_lifetime_names,
641-
inputs: input_tys,
626+
sig: ty::FnSig {inputs: input_tys,
642627
output: output_ty}
643628
}
644629
}

0 commit comments

Comments
 (0)