Skip to content

Commit 7a6432f

Browse files
committed
---
yaml --- r: 134583 b: refs/heads/try c: 0f6cbca h: refs/heads/master i: 134581: 0ce835d 134579: af59fae 134575: cd2d584 v: v3
1 parent a3a4130 commit 7a6432f

25 files changed

+174
-329
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 58413c09cd52ea4005d6ea7733ba1fb3a8f36589
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 437179ed8bf7f7672f84b19265df1ce569e70490
5-
refs/heads/try: 1686353650034e19e59c1415202f4f99e8b013cf
5+
refs/heads/try: 0f6cbcaa883864343faf83f7b84119a731c6fc21
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/librustc/middle/resolve.rs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4328,34 +4328,6 @@ impl<'a> Resolver<'a> {
43284328
self.resolve_trait_reference(id, tref, reference_type)
43294329
}
43304330
UnboxedFnTyParamBound(ref unboxed_function) => {
4331-
match self.resolve_path(unboxed_function.ref_id,
4332-
&unboxed_function.path,
4333-
TypeNS,
4334-
true) {
4335-
None => {
4336-
let path_str = self.path_idents_to_string(
4337-
&unboxed_function.path);
4338-
self.resolve_error(unboxed_function.path.span,
4339-
format!("unresolved trait `{}`",
4340-
path_str).as_slice())
4341-
}
4342-
Some(def) => {
4343-
match def {
4344-
(DefTrait(_), _) => {
4345-
self.record_def(unboxed_function.ref_id, def);
4346-
}
4347-
_ => {
4348-
let msg =
4349-
format!("`{}` is not a trait",
4350-
self.path_idents_to_string(
4351-
&unboxed_function.path));
4352-
self.resolve_error(unboxed_function.path.span,
4353-
msg.as_slice());
4354-
}
4355-
}
4356-
}
4357-
}
4358-
43594331
for argument in unboxed_function.decl.inputs.iter() {
43604332
self.resolve_type(&*argument.ty);
43614333
}

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -191,21 +191,13 @@ pub fn decl_fn(ccx: &CrateContext, name: &str, cc: llvm::CallConv,
191191
match ty::get(output).sty {
192192
// functions returning bottom may unwind, but can never return normally
193193
ty::ty_bot => {
194-
unsafe {
195-
llvm::LLVMAddFunctionAttribute(llfn,
196-
llvm::FunctionIndex as c_uint,
197-
llvm::NoReturnAttribute as uint64_t)
198-
}
194+
llvm::SetFunctionAttribute(llfn, llvm::NoReturnAttribute)
199195
}
200196
_ => {}
201197
}
202198

203199
if ccx.tcx().sess.opts.cg.no_redzone {
204-
unsafe {
205-
llvm::LLVMAddFunctionAttribute(llfn,
206-
llvm::FunctionIndex as c_uint,
207-
llvm::NoRedZoneAttribute as uint64_t)
208-
}
200+
llvm::SetFunctionAttribute(llfn, llvm::NoRedZoneAttribute)
209201
}
210202

211203
llvm::SetFunctionCallConv(llfn, cc);

branches/try/src/librustc/middle/trans/foreign.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,7 @@ fn add_argument_attributes(tys: &ForeignTypes,
998998

999999
match tys.fn_ty.ret_ty.attr {
10001000
Some(attr) => unsafe {
1001-
llvm::LLVMAddFunctionAttribute(llfn, i as c_uint, attr as u64);
1001+
llvm::LLVMAddFunctionAttribute(llfn, i as c_uint, attr.bits() as u64);
10021002
},
10031003
None => {}
10041004
}
@@ -1014,7 +1014,7 @@ fn add_argument_attributes(tys: &ForeignTypes,
10141014

10151015
match arg_ty.attr {
10161016
Some(attr) => unsafe {
1017-
llvm::LLVMAddFunctionAttribute(llfn, i as c_uint, attr as u64);
1017+
llvm::LLVMAddFunctionAttribute(llfn, i as c_uint, attr.bits() as u64);
10181018
},
10191019
None => ()
10201020
}

branches/try/src/librustc/middle/typeck/astconv.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -585,29 +585,32 @@ pub fn trait_ref_for_unboxed_function<'tcx, AC: AstConv<'tcx>,
585585
RS:RegionScope>(
586586
this: &AC,
587587
rscope: &RS,
588-
kind: ast::UnboxedClosureKind,
589-
decl: &ast::FnDecl,
588+
unboxed_function: &ast::UnboxedFnTy,
590589
self_ty: Option<ty::t>)
591590
-> ty::TraitRef {
592-
let lang_item = match kind {
591+
let lang_item = match unboxed_function.kind {
593592
ast::FnUnboxedClosureKind => FnTraitLangItem,
594593
ast::FnMutUnboxedClosureKind => FnMutTraitLangItem,
595594
ast::FnOnceUnboxedClosureKind => FnOnceTraitLangItem,
596595
};
597596
let trait_did = this.tcx().lang_items.require(lang_item).unwrap();
598-
let input_types = decl.inputs
599-
.iter()
600-
.map(|input| {
597+
let input_types =
598+
unboxed_function.decl
599+
.inputs
600+
.iter()
601+
.map(|input| {
601602
ast_ty_to_ty(this, rscope, &*input.ty)
602-
}).collect::<Vec<_>>();
603+
}).collect::<Vec<_>>();
603604
let input_tuple = if input_types.len() == 0 {
604605
ty::mk_nil()
605606
} else {
606607
ty::mk_tup(this.tcx(), input_types)
607608
};
608-
let output_type = ast_ty_to_ty(this, rscope, &*decl.output);
609+
let output_type = ast_ty_to_ty(this,
610+
rscope,
611+
&*unboxed_function.decl.output);
609612
let mut substs = Substs::new_type(vec!(input_tuple, output_type),
610-
Vec::new());
613+
Vec::new());
611614

612615
match self_ty {
613616
Some(s) => substs.types.push(SelfSpace, s),
@@ -645,8 +648,7 @@ fn mk_pointer<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
645648
substs
646649
} = trait_ref_for_unboxed_function(this,
647650
rscope,
648-
unboxed_function.kind,
649-
&*unboxed_function.decl,
651+
&**unboxed_function,
650652
None);
651653
let r = ptr_ty.default_region();
652654
let tr = ty::mk_trait(this.tcx(),
@@ -1508,7 +1510,7 @@ fn compute_region_bound<'tcx, AC: AstConv<'tcx>, RS:RegionScope>(
15081510
pub struct PartitionedBounds<'a> {
15091511
pub builtin_bounds: ty::BuiltinBounds,
15101512
pub trait_bounds: Vec<&'a ast::TraitRef>,
1511-
pub unboxed_fn_ty_bounds: Vec<&'a ast::UnboxedFnBound>,
1513+
pub unboxed_fn_ty_bounds: Vec<&'a ast::UnboxedFnTy>,
15121514
pub region_bounds: Vec<&'a ast::Lifetime>,
15131515
}
15141516

@@ -1572,7 +1574,7 @@ pub fn partition_bounds<'a>(tcx: &ty::ctxt,
15721574
region_bounds.push(l);
15731575
}
15741576
ast::UnboxedFnTyParamBound(ref unboxed_function) => {
1575-
unboxed_fn_ty_bounds.push(&**unboxed_function);
1577+
unboxed_fn_ty_bounds.push(unboxed_function);
15761578
}
15771579
}
15781580
}

branches/try/src/librustc/middle/typeck/collect.rs

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,8 +1427,7 @@ pub fn instantiate_unboxed_fn_ty<'tcx,AC>(this: &AC,
14271427
let param_ty = param_ty.to_ty(this.tcx());
14281428
Rc::new(astconv::trait_ref_for_unboxed_function(this,
14291429
&rscope,
1430-
unboxed_function.kind,
1431-
&*unboxed_function.decl,
1430+
unboxed_function,
14321431
Some(param_ty)))
14331432
}
14341433

@@ -2166,42 +2165,9 @@ fn conv_param_bounds<'tcx,AC>(this: &AC,
21662165
region_bounds,
21672166
unboxed_fn_ty_bounds } =
21682167
astconv::partition_bounds(this.tcx(), span, all_bounds.as_slice());
2169-
2170-
let unboxed_fn_ty_bounds = unboxed_fn_ty_bounds.move_iter().map(|b| {
2171-
let trait_id = this.tcx().def_map.borrow().get(&b.ref_id).def_id();
2172-
let mut kind = None;
2173-
for &(lang_item, this_kind) in [
2174-
(this.tcx().lang_items.fn_trait(), ast::FnUnboxedClosureKind),
2175-
(this.tcx().lang_items.fn_mut_trait(),
2176-
ast::FnMutUnboxedClosureKind),
2177-
(this.tcx().lang_items.fn_once_trait(),
2178-
ast::FnOnceUnboxedClosureKind)
2179-
].iter() {
2180-
if Some(trait_id) == lang_item {
2181-
kind = Some(this_kind);
2182-
break
2183-
}
2184-
}
2185-
2186-
let kind = match kind {
2187-
Some(kind) => kind,
2188-
None => {
2189-
this.tcx().sess.span_err(b.path.span,
2190-
"unboxed function trait must be one \
2191-
of `Fn`, `FnMut`, or `FnOnce`");
2192-
ast::FnMutUnboxedClosureKind
2193-
}
2194-
};
2195-
2196-
let rscope = ExplicitRscope;
2197-
let param_ty = param_ty.to_ty(this.tcx());
2198-
Rc::new(astconv::trait_ref_for_unboxed_function(this,
2199-
&rscope,
2200-
kind,
2201-
&*b.decl,
2202-
Some(param_ty)))
2203-
});
2204-
2168+
let unboxed_fn_ty_bounds =
2169+
unboxed_fn_ty_bounds.into_iter()
2170+
.map(|b| instantiate_unboxed_fn_ty(this, b, param_ty));
22052171
let trait_bounds: Vec<Rc<ty::TraitRef>> =
22062172
trait_bounds.into_iter()
22072173
.map(|b| {

branches/try/src/librustc_llvm/lib.rs

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -91,34 +91,35 @@ pub enum DiagnosticSeverity {
9191
Note,
9292
}
9393

94-
#[deriving(Clone)]
95-
pub enum Attribute {
96-
ZExtAttribute = 1 << 0,
97-
SExtAttribute = 1 << 1,
98-
NoReturnAttribute = 1 << 2,
99-
InRegAttribute = 1 << 3,
100-
StructRetAttribute = 1 << 4,
101-
NoUnwindAttribute = 1 << 5,
102-
NoAliasAttribute = 1 << 6,
103-
ByValAttribute = 1 << 7,
104-
NestAttribute = 1 << 8,
105-
ReadNoneAttribute = 1 << 9,
106-
ReadOnlyAttribute = 1 << 10,
107-
NoInlineAttribute = 1 << 11,
108-
AlwaysInlineAttribute = 1 << 12,
109-
OptimizeForSizeAttribute = 1 << 13,
110-
StackProtectAttribute = 1 << 14,
111-
StackProtectReqAttribute = 1 << 15,
112-
AlignmentAttribute = 31 << 16,
113-
NoCaptureAttribute = 1 << 21,
114-
NoRedZoneAttribute = 1 << 22,
115-
NoImplicitFloatAttribute = 1 << 23,
116-
NakedAttribute = 1 << 24,
117-
InlineHintAttribute = 1 << 25,
118-
StackAttribute = 7 << 26,
119-
ReturnsTwiceAttribute = 1 << 29,
120-
UWTableAttribute = 1 << 30,
121-
NonLazyBindAttribute = 1 << 31,
94+
bitflags! {
95+
flags Attribute : u32 {
96+
static ZExtAttribute = 1 << 0,
97+
static SExtAttribute = 1 << 1,
98+
static NoReturnAttribute = 1 << 2,
99+
static InRegAttribute = 1 << 3,
100+
static StructRetAttribute = 1 << 4,
101+
static NoUnwindAttribute = 1 << 5,
102+
static NoAliasAttribute = 1 << 6,
103+
static ByValAttribute = 1 << 7,
104+
static NestAttribute = 1 << 8,
105+
static ReadNoneAttribute = 1 << 9,
106+
static ReadOnlyAttribute = 1 << 10,
107+
static NoInlineAttribute = 1 << 11,
108+
static AlwaysInlineAttribute = 1 << 12,
109+
static OptimizeForSizeAttribute = 1 << 13,
110+
static StackProtectAttribute = 1 << 14,
111+
static StackProtectReqAttribute = 1 << 15,
112+
static AlignmentAttribute = 31 << 16,
113+
static NoCaptureAttribute = 1 << 21,
114+
static NoRedZoneAttribute = 1 << 22,
115+
static NoImplicitFloatAttribute = 1 << 23,
116+
static NakedAttribute = 1 << 24,
117+
static InlineHintAttribute = 1 << 25,
118+
static StackAttribute = 7 << 26,
119+
static ReturnsTwiceAttribute = 1 << 29,
120+
static UWTableAttribute = 1 << 30,
121+
static NonLazyBindAttribute = 1 << 31,
122+
}
122123
}
123124

124125
#[repr(u64)]
@@ -160,13 +161,13 @@ trait AttrHelper {
160161
impl AttrHelper for Attribute {
161162
fn apply_llfn(&self, idx: c_uint, llfn: ValueRef) {
162163
unsafe {
163-
LLVMAddFunctionAttribute(llfn, idx, *self as uint64_t);
164+
LLVMAddFunctionAttribute(llfn, idx, self.bits() as uint64_t);
164165
}
165166
}
166167

167168
fn apply_callsite(&self, idx: c_uint, callsite: ValueRef) {
168169
unsafe {
169-
LLVMAddCallSiteAttribute(callsite, idx, *self as uint64_t);
170+
LLVMAddCallSiteAttribute(callsite, idx, self.bits() as uint64_t);
170171
}
171172
}
172173
}
@@ -2009,7 +2010,7 @@ pub fn ConstFCmp(pred: RealPredicate, v1: ValueRef, v2: ValueRef) -> ValueRef {
20092010

20102011
pub fn SetFunctionAttribute(fn_: ValueRef, attr: Attribute) {
20112012
unsafe {
2012-
LLVMAddFunctionAttribute(fn_, FunctionIndex as c_uint, attr as uint64_t)
2013+
LLVMAddFunctionAttribute(fn_, FunctionIndex as c_uint, attr.bits() as uint64_t)
20132014
}
20142015
}
20152016

branches/try/src/libsyntax/ast.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -213,19 +213,12 @@ pub static DUMMY_NODE_ID: NodeId = -1;
213213
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
214214
pub enum TyParamBound {
215215
TraitTyParamBound(TraitRef),
216-
UnboxedFnTyParamBound(P<UnboxedFnBound>),
216+
UnboxedFnTyParamBound(UnboxedFnTy),
217217
RegionTyParamBound(Lifetime)
218218
}
219219

220220
pub type TyParamBounds = OwnedSlice<TyParamBound>;
221221

222-
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
223-
pub struct UnboxedFnBound {
224-
pub path: Path,
225-
pub decl: P<FnDecl>,
226-
pub ref_id: NodeId,
227-
}
228-
229222
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
230223
pub struct TyParam {
231224
pub ident: Ident,

branches/try/src/libsyntax/diagnostics/plugin.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use std::collections::HashMap;
1313
use ast;
1414
use ast::{Ident, Name, TokenTree};
1515
use codemap::Span;
16-
use ext::base::{ExtCtxt, MacExpr, MacResult, MacItems};
16+
use ext::base::{ExtCtxt, MacExpr, MacItem, MacResult};
1717
use ext::build::AstBuilder;
1818
use parse::token;
1919
use ptr::P;
@@ -102,7 +102,7 @@ pub fn expand_register_diagnostic<'cx>(ecx: &'cx mut ExtCtxt,
102102
let sym = Ident::new(token::gensym((
103103
"__register_diagnostic_".to_string() + token::get_ident(*code).get()
104104
).as_slice()));
105-
MacItems::new(vec![quote_item!(ecx, mod $sym {}).unwrap()].into_iter())
105+
MacItem::new(quote_item!(ecx, mod $sym {}).unwrap())
106106
}
107107

108108
pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt,
@@ -133,7 +133,7 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt,
133133
(descriptions.len(), ecx.expr_vec(span, descriptions))
134134
})
135135
});
136-
MacItems::new(vec![quote_item!(ecx,
136+
MacItem::new(quote_item!(ecx,
137137
pub static $name: [(&'static str, &'static str), ..$count] = $expr;
138-
).unwrap()].into_iter())
138+
).unwrap())
139139
}

branches/try/src/libsyntax/ext/base.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -203,20 +203,25 @@ impl MacResult for MacPat {
203203
Some(self.p)
204204
}
205205
}
206-
/// A type for macros that return multiple items.
207-
pub struct MacItems {
208-
items: SmallVector<P<ast::Item>>
206+
/// A convenience type for macros that return a single item.
207+
pub struct MacItem {
208+
i: P<ast::Item>
209209
}
210-
211-
impl MacItems {
212-
pub fn new<I: Iterator<P<ast::Item>>>(mut it: I) -> Box<MacResult+'static> {
213-
box MacItems { items: it.collect() } as Box<MacResult+'static>
210+
impl MacItem {
211+
pub fn new(i: P<ast::Item>) -> Box<MacResult+'static> {
212+
box MacItem { i: i } as Box<MacResult+'static>
214213
}
215214
}
216-
217-
impl MacResult for MacItems {
218-
fn make_items(self: Box<MacItems>) -> Option<SmallVector<P<ast::Item>>> {
219-
Some(self.items)
215+
impl MacResult for MacItem {
216+
fn make_items(self: Box<MacItem>) -> Option<SmallVector<P<ast::Item>>> {
217+
Some(SmallVector::one(self.i))
218+
}
219+
fn make_stmt(self: Box<MacItem>) -> Option<P<ast::Stmt>> {
220+
Some(P(codemap::respan(
221+
self.i.span,
222+
ast::StmtDecl(
223+
P(codemap::respan(self.i.span, ast::DeclItem(self.i))),
224+
ast::DUMMY_NODE_ID))))
220225
}
221226
}
222227

0 commit comments

Comments
 (0)