Skip to content

Commit 89cad49

Browse files
committed
---
yaml --- r: 234227 b: refs/heads/beta c: b1c9616 h: refs/heads/master i: 234225: 4585256 234223: dab8f3d v: v3
1 parent dab2809 commit 89cad49

File tree

33 files changed

+271
-110
lines changed

33 files changed

+271
-110
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: 5a95acb8aba07ea8e5255893aa4e01e5ba5c2349
26+
refs/heads/beta: b1c96168821d70992157f55ee9f06190bf299ba4
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: 370fe2786109360f7c35b8ba552b83b773dd71d6
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/src/doc/trpl/advanced-linking.md

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -80,33 +80,30 @@ $ mkdir musldist
8080
$ PREFIX=$(pwd)/musldist
8181
$
8282
$ # Build musl
83-
$ wget http://www.musl-libc.org/releases/musl-1.1.10.tar.gz
84-
[...]
83+
$ curl -O http://www.musl-libc.org/releases/musl-1.1.10.tar.gz
8584
$ tar xf musl-1.1.10.tar.gz
8685
$ cd musl-1.1.10/
8786
musl-1.1.10 $ ./configure --disable-shared --prefix=$PREFIX
88-
[...]
8987
musl-1.1.10 $ make
90-
[...]
9188
musl-1.1.10 $ make install
92-
[...]
9389
musl-1.1.10 $ cd ..
9490
$ du -h musldist/lib/libc.a
9591
2.2M musldist/lib/libc.a
9692
$
9793
$ # Build libunwind.a
98-
$ wget http://llvm.org/releases/3.6.1/llvm-3.6.1.src.tar.xz
99-
$ tar xf llvm-3.6.1.src.tar.xz
100-
$ cd llvm-3.6.1.src/projects/
101-
llvm-3.6.1.src/projects $ svn co http://llvm.org/svn/llvm-project/libcxxabi/trunk/ libcxxabi
102-
llvm-3.6.1.src/projects $ svn co http://llvm.org/svn/llvm-project/libunwind/trunk/ libunwind
103-
llvm-3.6.1.src/projects $ sed -i 's#^\(include_directories\).*$#\0\n\1(../libcxxabi/include)#' libunwind/CMakeLists.txt
104-
llvm-3.6.1.src/projects $ mkdir libunwind/build
105-
llvm-3.6.1.src/projects $ cd libunwind/build
106-
llvm-3.6.1.src/projects/libunwind/build $ cmake -DLLVM_PATH=../../.. -DLIBUNWIND_ENABLE_SHARED=0 ..
107-
llvm-3.6.1.src/projects/libunwind/build $ make
108-
llvm-3.6.1.src/projects/libunwind/build $ cp lib/libunwind.a $PREFIX/lib/
109-
llvm-3.6.1.src/projects/libunwind/build $ cd cd ../../../../
94+
$ curl -O http://llvm.org/releases/3.7.0/llvm-3.7.0.src.tar.xz
95+
$ tar xf llvm-3.7.0.src.tar.xz
96+
$ cd llvm-3.7.0.src/projects/
97+
llvm-3.7.0.src/projects $ curl http://llvm.org/releases/3.7.0/libcxxabi-3.7.0.src.tar.xz | tar xJf -
98+
llvm-3.7.0.src/projects $ mv libcxxabi-3.7.0.src libcxxabi
99+
llvm-3.7.0.src/projects $ curl http://llvm.org/releases/3.7.0/libunwind-3.7.0.src.tar.xz | tar xJf -
100+
llvm-3.7.0.src/projects $ mv libunwind-3.7.0.src libunwind
101+
llvm-3.7.0.src/projects $ mkdir libunwind/build
102+
llvm-3.7.0.src/projects $ cd libunwind/build
103+
llvm-3.7.0.src/projects/libunwind/build $ cmake -DLLVM_PATH=../../.. -DLIBUNWIND_ENABLE_SHARED=0 ..
104+
llvm-3.7.0.src/projects/libunwind/build $ make
105+
llvm-3.7.0.src/projects/libunwind/build $ cp lib/libunwind.a $PREFIX/lib/
106+
llvm-3.7.0.src/projects/libunwind/build $ cd ../../../../
110107
$ du -h musldist/lib/libunwind.a
111108
164K musldist/lib/libunwind.a
112109
$

branches/beta/src/libcore/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
#![feature(optin_builtin_traits)]
8080
#![feature(reflect)]
8181
#![feature(rustc_attrs)]
82+
#![feature(unwind_attributes)]
8283
#![cfg_attr(stage0, feature(simd))]
8384
#![cfg_attr(not(stage0), feature(repr_simd, platform_intrinsics))]
8485
#![feature(staged_api)]

branches/beta/src/libcore/num/mod.rs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -537,25 +537,21 @@ macro_rules! int_impl {
537537
let mut base = self;
538538
let mut acc = Self::one();
539539

540-
let mut prev_base = self;
541-
let mut base_oflo = false;
542-
while exp > 0 {
540+
while exp > 1 {
543541
if (exp & 1) == 1 {
544-
if base_oflo {
545-
// ensure overflow occurs in the same manner it
546-
// would have otherwise (i.e. signal any exception
547-
// it would have otherwise).
548-
acc = acc * (prev_base * prev_base);
549-
} else {
550-
acc = acc * base;
551-
}
542+
acc = acc * base;
552543
}
553-
prev_base = base;
554-
let (new_base, new_base_oflo) = base.overflowing_mul(base);
555-
base = new_base;
556-
base_oflo = new_base_oflo;
557544
exp /= 2;
545+
base = base * base;
546+
}
547+
548+
// Deal with the final bit of the exponent separately, since
549+
// squaring the base afterwards is not necessary and may cause a
550+
// needless overflow.
551+
if exp == 1 {
552+
acc = acc * base;
558553
}
554+
559555
acc
560556
}
561557

branches/beta/src/libcore/panicking.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ pub fn panic_fmt(fmt: fmt::Arguments, file_line: &(&'static str, u32)) -> ! {
6262
#[allow(improper_ctypes)]
6363
extern {
6464
#[lang = "panic_fmt"]
65+
#[unwind]
6566
fn panic_impl(fmt: fmt::Arguments, file: &'static str, line: u32) -> !;
6667
}
6768
let (file, line) = *file_line;

branches/beta/src/librustc/diagnostics.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1895,6 +1895,7 @@ register_diagnostics! {
18951895
// E0006 // merged with E0005
18961896
// E0134,
18971897
// E0135,
1898+
E0229, // associated type bindings are not allowed here
18981899
E0264, // unknown external lang item
18991900
E0278, // requirement is not satisfied
19001901
E0279, // requirement is not satisfied

branches/beta/src/librustc/middle/astconv_util.rs

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,36 +16,40 @@
1616

1717
use middle::def;
1818
use middle::ty::{self, Ty};
19-
use rustc_front::hir as ast;
2019

21-
pub const NO_REGIONS: usize = 1;
22-
pub const NO_TPS: usize = 2;
20+
use syntax::codemap::Span;
21+
use rustc_front::hir as ast;
2322

24-
pub fn check_path_args(tcx: &ty::ctxt, segments: &[ast::PathSegment], flags: usize) {
23+
pub fn prohibit_type_params(tcx: &ty::ctxt, segments: &[ast::PathSegment]) {
2524
for segment in segments {
26-
if (flags & NO_TPS) != 0 {
27-
for typ in segment.parameters.types() {
28-
span_err!(tcx.sess, typ.span, E0109,
29-
"type parameters are not allowed on this type");
30-
break;
31-
}
25+
for typ in segment.parameters.types() {
26+
span_err!(tcx.sess, typ.span, E0109,
27+
"type parameters are not allowed on this type");
28+
break;
3229
}
33-
34-
if (flags & NO_REGIONS) != 0 {
35-
for lifetime in segment.parameters.lifetimes() {
36-
span_err!(tcx.sess, lifetime.span, E0110,
37-
"lifetime parameters are not allowed on this type");
38-
break;
39-
}
30+
for lifetime in segment.parameters.lifetimes() {
31+
span_err!(tcx.sess, lifetime.span, E0110,
32+
"lifetime parameters are not allowed on this type");
33+
break;
34+
}
35+
for binding in segment.parameters.bindings() {
36+
prohibit_projection(tcx, binding.span);
37+
break;
4038
}
4139
}
4240
}
4341

42+
pub fn prohibit_projection(tcx: &ty::ctxt, span: Span)
43+
{
44+
span_err!(tcx.sess, span, E0229,
45+
"associated type bindings are not allowed here");
46+
}
47+
4448
pub fn prim_ty_to_ty<'tcx>(tcx: &ty::ctxt<'tcx>,
4549
segments: &[ast::PathSegment],
4650
nty: ast::PrimTy)
4751
-> Ty<'tcx> {
48-
check_path_args(tcx, segments, NO_TPS | NO_REGIONS);
52+
prohibit_type_params(tcx, segments);
4953
match nty {
5054
ast::TyBool => tcx.types.bool,
5155
ast::TyChar => tcx.types.char,

branches/beta/src/librustc_back/tempdir.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,12 @@ impl TempDir {
3838
#[allow(deprecated)] // rand usage
3939
pub fn new_in<P: AsRef<Path>>(tmpdir: P, prefix: &str)
4040
-> io::Result<TempDir> {
41+
Self::_new_in(tmpdir.as_ref(), prefix)
42+
}
43+
44+
fn _new_in(tmpdir: &Path, prefix: &str) -> io::Result<TempDir> {
4145
let storage;
42-
let mut tmpdir = tmpdir.as_ref();
46+
let mut tmpdir = tmpdir;
4347
if !tmpdir.is_absolute() {
4448
let cur_dir = try!(env::current_dir());
4549
storage = cur_dir.join(tmpdir);

branches/beta/src/librustc_trans/trans/attributes.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ pub fn emit_uwtable(val: ValueRef, emit: bool) {
5959

6060
/// Tell LLVM whether the function can or cannot unwind.
6161
#[inline]
62-
#[allow(dead_code)] // possibly useful function
6362
pub fn unwind(val: ValueRef, can_unwind: bool) {
6463
if can_unwind {
6564
unsafe {
@@ -118,6 +117,8 @@ pub fn from_fn_attrs(ccx: &CrateContext, attrs: &[hir::Attribute], llfn: ValueRe
118117
}
119118
} else if attr.check_name("allocator") {
120119
llvm::Attribute::NoAlias.apply_llfn(llvm::ReturnIndex as c_uint, llfn);
120+
} else if attr.check_name("unwind") {
121+
unwind(llfn, true);
121122
}
122123
}
123124
}

branches/beta/src/librustc_trans/trans/base.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -677,11 +677,8 @@ pub fn trans_external_path<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
677677
ccx.sess().bug("unexpected intrinsic in trans_external_path")
678678
}
679679
_ => {
680-
let llfn = foreign::register_foreign_item_fn(ccx, fn_ty.abi,
681-
t, &name);
682680
let attrs = csearch::get_item_attrs(&ccx.sess().cstore, did);
683-
attributes::from_fn_attrs(ccx, &attrs, llfn);
684-
llfn
681+
foreign::register_foreign_item_fn(ccx, fn_ty.abi, t, &name, &attrs)
685682
}
686683
}
687684
}
@@ -2418,9 +2415,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
24182415
let abi = ccx.tcx().map.get_foreign_abi(id);
24192416
let ty = ccx.tcx().node_id_to_type(ni.id);
24202417
let name = foreign::link_name(&*ni);
2421-
let llfn = foreign::register_foreign_item_fn(ccx, abi, ty, &name);
2422-
attributes::from_fn_attrs(ccx, &ni.attrs, llfn);
2423-
llfn
2418+
foreign::register_foreign_item_fn(ccx, abi, ty, &name, &ni.attrs)
24242419
}
24252420
hir::ForeignItemStatic(..) => {
24262421
foreign::register_static(ccx, &*ni)

branches/beta/src/librustc_trans/trans/foreign.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ pub fn get_extern_fn(ccx: &CrateContext,
187187
/// Registers a foreign function found in a library. Just adds a LLVM global.
188188
pub fn register_foreign_item_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
189189
abi: Abi, fty: Ty<'tcx>,
190-
name: &str) -> ValueRef {
190+
name: &str,
191+
attrs: &[hir::Attribute])-> ValueRef {
191192
debug!("register_foreign_item_fn(abi={:?}, \
192193
ty={:?}, \
193194
name={})",
@@ -210,7 +211,9 @@ pub fn register_foreign_item_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
210211
let llfn_ty = lltype_for_fn_from_foreign_types(ccx, &tys);
211212

212213
let llfn = get_extern_fn(ccx, &mut *ccx.externs().borrow_mut(), name, cc, llfn_ty, fty);
214+
attributes::unwind(llfn, false);
213215
add_argument_attributes(&tys, llfn);
216+
attributes::from_fn_attrs(ccx, attrs, llfn);
214217
llfn
215218
}
216219

@@ -489,8 +492,7 @@ pub fn trans_foreign_mod(ccx: &CrateContext, foreign_mod: &hir::ForeignMod) {
489492
"foreign fn's sty isn't a bare_fn_ty?")
490493
}
491494

492-
let llfn = register_foreign_item_fn(ccx, abi, ty, &lname);
493-
attributes::from_fn_attrs(ccx, &foreign_item.attrs, llfn);
495+
register_foreign_item_fn(ccx, abi, ty, &lname, &foreign_item.attrs);
494496
// Unlike for other items, we shouldn't call
495497
// `base::update_linkage` here. Foreign items have
496498
// special linkage requirements, which are handled

branches/beta/src/librustc_typeck/astconv.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
//! case but `&a` in the second. Basically, defaults that appear inside
4949
//! an rptr (`&r.T`) use the region `r` that appears in the rptr.
5050
51-
use middle::astconv_util::{prim_ty_to_ty, check_path_args, NO_TPS, NO_REGIONS};
51+
use middle::astconv_util::{prim_ty_to_ty, prohibit_type_params, prohibit_projection};
5252
use middle::const_eval::{self, ConstVal};
5353
use middle::const_eval::EvalHint::UncheckedExprHint;
5454
use middle::def;
@@ -1207,7 +1207,7 @@ fn associated_path_def_to_ty<'tcx>(this: &AstConv<'tcx>,
12071207

12081208
debug!("associated_path_def_to_ty: {:?}::{}", ty, assoc_name);
12091209

1210-
check_path_args(tcx, slice::ref_slice(item_segment), NO_TPS | NO_REGIONS);
1210+
prohibit_type_params(tcx, slice::ref_slice(item_segment));
12111211

12121212
// Find the type of the associated item, and the trait where the associated
12131213
// item is declared.
@@ -1309,7 +1309,7 @@ fn qpath_to_ty<'tcx>(this: &AstConv<'tcx>,
13091309
{
13101310
let tcx = this.tcx();
13111311

1312-
check_path_args(tcx, slice::ref_slice(item_segment), NO_TPS | NO_REGIONS);
1312+
prohibit_type_params(tcx, slice::ref_slice(item_segment));
13131313

13141314
let self_ty = if let Some(ty) = opt_self_ty {
13151315
ty
@@ -1398,7 +1398,7 @@ fn base_def_to_ty<'tcx>(this: &AstConv<'tcx>,
13981398
base_segments.last().unwrap(),
13991399
&mut projection_bounds);
14001400

1401-
check_path_args(tcx, base_segments.split_last().unwrap().1, NO_TPS | NO_REGIONS);
1401+
prohibit_type_params(tcx, base_segments.split_last().unwrap().1);
14021402
trait_ref_to_object_type(this,
14031403
rscope,
14041404
span,
@@ -1407,7 +1407,7 @@ fn base_def_to_ty<'tcx>(this: &AstConv<'tcx>,
14071407
&[])
14081408
}
14091409
def::DefTy(did, _) | def::DefStruct(did) => {
1410-
check_path_args(tcx, base_segments.split_last().unwrap().1, NO_TPS | NO_REGIONS);
1410+
prohibit_type_params(tcx, base_segments.split_last().unwrap().1);
14111411
ast_path_to_ty(this,
14121412
rscope,
14131413
span,
@@ -1416,12 +1416,12 @@ fn base_def_to_ty<'tcx>(this: &AstConv<'tcx>,
14161416
base_segments.last().unwrap())
14171417
}
14181418
def::DefTyParam(space, index, _, name) => {
1419-
check_path_args(tcx, base_segments, NO_TPS | NO_REGIONS);
1419+
prohibit_type_params(tcx, base_segments);
14201420
tcx.mk_param(space, index, name)
14211421
}
14221422
def::DefSelfTy(_, Some((_, self_ty_id))) => {
14231423
// Self in impl (we know the concrete type).
1424-
check_path_args(tcx, base_segments, NO_TPS | NO_REGIONS);
1424+
prohibit_type_params(tcx, base_segments);
14251425
if let Some(&ty) = tcx.ast_ty_to_ty_cache.borrow().get(&self_ty_id) {
14261426
if let Some(free_substs) = this.get_free_substs() {
14271427
ty.subst(tcx, free_substs)
@@ -1434,11 +1434,11 @@ fn base_def_to_ty<'tcx>(this: &AstConv<'tcx>,
14341434
}
14351435
def::DefSelfTy(Some(_), None) => {
14361436
// Self in trait.
1437-
check_path_args(tcx, base_segments, NO_TPS | NO_REGIONS);
1437+
prohibit_type_params(tcx, base_segments);
14381438
tcx.mk_self_type()
14391439
}
14401440
def::DefAssociatedTy(trait_did, _) => {
1441-
check_path_args(tcx, &base_segments[..base_segments.len()-2], NO_TPS | NO_REGIONS);
1441+
prohibit_type_params(tcx, &base_segments[..base_segments.len()-2]);
14421442
qpath_to_ty(this,
14431443
rscope,
14441444
span,
@@ -2182,8 +2182,7 @@ fn prohibit_projections<'tcx>(tcx: &ty::ctxt<'tcx>,
21822182
bindings: &[ConvertedBinding<'tcx>])
21832183
{
21842184
for binding in bindings.iter().take(1) {
2185-
span_err!(tcx.sess, binding.span, E0229,
2186-
"associated type bindings are not allowed here");
2185+
prohibit_projection(tcx, binding.span);
21872186
}
21882187
}
21892188

branches/beta/src/librustc_typeck/check/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ use self::TupleArgumentsFlag::*;
8383
use astconv::{self, ast_region_to_region, ast_ty_to_ty, AstConv, PathParamMode};
8484
use check::_match::pat_ctxt;
8585
use fmt_macros::{Parser, Piece, Position};
86-
use middle::astconv_util::{check_path_args, NO_TPS, NO_REGIONS};
86+
use middle::astconv_util::prohibit_type_params;
8787
use middle::def;
8888
use middle::def_id::{DefId, LOCAL_CRATE};
8989
use middle::infer;
@@ -4542,8 +4542,7 @@ pub fn instantiate_path<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
45424542
for (opt_space, segment) in segment_spaces.iter().zip(segments) {
45434543
match *opt_space {
45444544
None => {
4545-
check_path_args(fcx.tcx(), slice::ref_slice(segment),
4546-
NO_TPS | NO_REGIONS);
4545+
prohibit_type_params(fcx.tcx(), slice::ref_slice(segment));
45474546
}
45484547

45494548
Some(space) => {

branches/beta/src/librustc_typeck/diagnostics.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3294,7 +3294,6 @@ register_diagnostics! {
32943294
E0226, // only a single explicit lifetime bound is permitted
32953295
E0227, // ambiguous lifetime bound, explicit lifetime bound required
32963296
E0228, // explicit lifetime bound required
3297-
E0229, // associated type bindings are not allowed here
32983297
E0230, // there is no type parameter on trait
32993298
E0231, // only named substitution parameters are allowed
33003299
// E0233,

0 commit comments

Comments
 (0)