Skip to content

Commit 37759ef

Browse files
committed
---
yaml --- r: 127966 b: refs/heads/master c: 85fd37f h: refs/heads/master v: v3
1 parent 2ea3d81 commit 37759ef

File tree

14 files changed

+148
-36
lines changed

14 files changed

+148
-36
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: 8f16aa748c63fe86730aaa68b7e21ec05ef7b70d
2+
refs/heads/master: 85fd37f876dad1d4db02208f8a56f02228d975b0
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: aa98b25c4f0c10729dff37c699904ad57b8fbda8
55
refs/heads/try: f1778314378f8951328206626b5ddf725898e0e6

trunk/src/etc/vim/ftplugin/rust.vim

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ if exists("g:loaded_delimitMate")
5656
let b:delimitMate_excluded_regions = delimitMate#Get("excluded_regions") . ',rustLifetimeCandidate,rustGenericLifetimeCandidate'
5757
endif
5858

59+
if has("folding") && exists('g:rust_fold') && g:rust_fold != 0
60+
let b:rust_set_foldmethod=1
61+
setlocal foldmethod=syntax
62+
if g:rust_fold == 2
63+
setlocal foldlevel<
64+
else
65+
setlocal foldlevel=99
66+
endif
67+
endif
68+
5969
if has('conceal') && exists('g:rust_conceal')
6070
let b:rust_set_conceallevel=1
6171
setlocal conceallevel=2
@@ -108,6 +118,10 @@ let b:undo_ftplugin = "
108118
\|else
109119
\|unlet! b:delimitMate_excluded_regions
110120
\|endif
121+
\|if exists('b:rust_set_foldmethod')
122+
\|setlocal foldmethod< foldlevel<
123+
\|unlet b:rust_set_foldmethod
124+
\|endif
111125
\|if exists('b:rust_set_conceallevel')
112126
\|setlocal conceallevel<
113127
\|unlet b:rust_set_conceallevel

trunk/src/etc/vim/syntax/rust.vim

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,6 @@ elseif exists("b:current_syntax")
1111
finish
1212
endif
1313

14-
" Fold settings {{{1
15-
16-
if has("folding") && exists('g:rust_fold') && g:rust_fold != 0
17-
setlocal foldmethod=syntax
18-
if g:rust_fold == 2
19-
setlocal foldlevel<
20-
else
21-
setlocal foldlevel=99
22-
endif
23-
endif
24-
2514
" Syntax definitions {{{1
2615
" Basic keywords {{{2
2716
syn keyword rustConditional match if else

trunk/src/libnum/complex.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,14 @@ mod test {
257257
assert_eq!(_1_0i.inv(), _1_0i.inv());
258258
}
259259

260+
#[test]
261+
#[should_fail]
262+
fn test_divide_by_zero_natural() {
263+
let n = Complex::new(2i, 3i);
264+
let d = Complex::new(0, 0);
265+
let _x = n / d;
266+
}
267+
260268
#[test]
261269
#[should_fail]
262270
#[ignore]

trunk/src/librustc/back/link.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,6 +1472,9 @@ fn link_args(cmd: &mut Command,
14721472
// [1] - https://sourceware.org/bugzilla/show_bug.cgi?id=13130
14731473
// [2] - https://code.google.com/p/go/issues/detail?id=2139
14741474
cmd.arg("-Wl,--enable-long-section-names");
1475+
1476+
// Always enable DEP (NX bit) when it is available
1477+
cmd.arg("-Wl,--nxcompat");
14751478
}
14761479

14771480
if sess.targ_cfg.os == abi::OsAndroid {

trunk/src/librustc/metadata/creader.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ use syntax::diagnostic::SpanHandler;
3333
use syntax::parse::token::InternedString;
3434
use syntax::parse::token;
3535
use syntax::visit;
36+
use util::fs;
3637

3738
struct Env<'a> {
3839
sess: &'a Session,
@@ -301,7 +302,7 @@ fn existing_match(e: &Env, name: &str,
301302
match e.sess.opts.externs.find_equiv(&name) {
302303
Some(locs) => {
303304
let found = locs.iter().any(|l| {
304-
let l = Some(Path::new(l.as_slice()));
305+
let l = fs::realpath(&Path::new(l.as_slice())).ok();
305306
l == source.dylib || l == source.rlib
306307
});
307308
if found {

trunk/src/librustc/metadata/loader.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -666,9 +666,9 @@ impl<'a> Context<'a> {
666666
let mut dylibs = HashSet::new();
667667
for loc in locs {
668668
if loc.filename_str().unwrap().ends_with(".rlib") {
669-
rlibs.insert(loc.clone());
669+
rlibs.insert(fs::realpath(&loc).unwrap());
670670
} else {
671-
dylibs.insert(loc.clone());
671+
dylibs.insert(fs::realpath(&loc).unwrap());
672672
}
673673
}
674674

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2278,7 +2278,7 @@ pub fn get_fn_llvm_attributes(ccx: &CrateContext, fn_ty: ty::t)
22782278
match ty::get(ret_ty).sty {
22792279
// `~` pointer return values never alias because ownership
22802280
// is transferred
2281-
ty::ty_uniq(it) if match ty::get(it).sty {
2281+
ty::ty_uniq(it) if match ty::get(it).sty {
22822282
ty::ty_str | ty::ty_vec(..) | ty::ty_trait(..) => true, _ => false
22832283
} => {}
22842284
ty::ty_uniq(_) => {
@@ -2354,15 +2354,21 @@ pub fn get_fn_llvm_attributes(ccx: &CrateContext, fn_ty: ty::t)
23542354
}
23552355

23562356
// `&mut` pointer parameters never alias other parameters, or mutable global data
2357-
// `&` pointer parameters never alias either (for LLVM's purposes) as long as the
2358-
// interior is safe
2357+
//
2358+
// `&T` where `T` contains no `UnsafeCell<U>` is immutable, and can be marked as both
2359+
// `readonly` and `noalias`, as LLVM's definition of `noalias` is based solely on
2360+
// memory dependencies rather than pointer equality
23592361
ty::ty_rptr(b, mt) if mt.mutbl == ast::MutMutable ||
23602362
!ty::type_contents(ccx.tcx(), mt.ty).interior_unsafe() => {
23612363

23622364
let llsz = llsize_of_real(ccx, type_of::type_of(ccx, mt.ty));
23632365
attrs.arg(idx, llvm::NoAliasAttribute)
23642366
.arg(idx, llvm::DereferenceableAttribute(llsz));
23652367

2368+
if mt.mutbl == ast::MutImmutable {
2369+
attrs.arg(idx, llvm::ReadOnlyAttribute);
2370+
}
2371+
23662372
match b {
23672373
ReLateBound(_, BrAnon(_)) => {
23682374
attrs.arg(idx, llvm::NoCaptureAttribute);

trunk/src/libstd/io/util.rs

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,12 @@ impl<R: Reader> Reader for LimitReader<R> {
4848
}
4949

5050
let len = cmp::min(self.limit, buf.len());
51-
self.inner.read(buf.mut_slice_to(len)).map(|len| {
52-
self.limit -= len;
53-
len
54-
})
51+
let res = self.inner.read(buf.mut_slice_to(len));
52+
match res {
53+
Ok(len) => self.limit -= len,
54+
_ => {}
55+
}
56+
res
5557
}
5658
}
5759

@@ -67,6 +69,8 @@ impl<R: Buffer> Buffer for LimitReader<R> {
6769
}
6870

6971
fn consume(&mut self, amt: uint) {
72+
// Don't let callers reset the limit by passing an overlarge value
73+
let amt = cmp::min(amt, self.limit);
7074
self.limit -= amt;
7175
self.inner.consume(amt);
7276
}
@@ -97,6 +101,7 @@ impl Buffer for ZeroReader {
97101
static DATA: [u8, ..64] = [0, ..64];
98102
Ok(DATA.as_slice())
99103
}
104+
100105
fn consume(&mut self, _amt: uint) {}
101106
}
102107

@@ -117,7 +122,10 @@ impl Buffer for NullReader {
117122
fn consume(&mut self, _amt: uint) {}
118123
}
119124

120-
/// A `Writer` which multiplexes writes to a set of `Writers`.
125+
/// A `Writer` which multiplexes writes to a set of `Writer`s.
126+
///
127+
/// The `Writer`s are delegated to in order. If any `Writer` returns an error,
128+
/// that error is returned immediately and remaining `Writer`s are not called.
121129
pub struct MultiWriter {
122130
writers: Vec<Box<Writer>>
123131
}
@@ -132,24 +140,22 @@ impl MultiWriter {
132140
impl Writer for MultiWriter {
133141
#[inline]
134142
fn write(&mut self, buf: &[u8]) -> io::IoResult<()> {
135-
let mut ret = Ok(());
136143
for writer in self.writers.mut_iter() {
137-
ret = ret.and(writer.write(buf));
144+
try!(writer.write(buf));
138145
}
139-
return ret;
146+
Ok(())
140147
}
141148

142149
#[inline]
143150
fn flush(&mut self) -> io::IoResult<()> {
144-
let mut ret = Ok(());
145151
for writer in self.writers.mut_iter() {
146-
ret = ret.and(writer.flush());
152+
try!(writer.flush());
147153
}
148-
return ret;
154+
Ok(())
149155
}
150156
}
151157

152-
/// A `Reader` which chains input from multiple `Readers`, reading each to
158+
/// A `Reader` which chains input from multiple `Reader`s, reading each to
153159
/// completion before moving onto the next.
154160
pub struct ChainedReader<I, R> {
155161
readers: I,
@@ -229,17 +235,16 @@ pub fn copy<R: Reader, W: Writer>(r: &mut R, w: &mut W) -> io::IoResult<()> {
229235
}
230236
}
231237

232-
/// A `Reader` which converts an `Iterator<u8>` into a `Reader`.
238+
/// An adaptor converting an `Iterator<u8>` to a `Reader`.
233239
pub struct IterReader<T> {
234240
iter: T,
235241
}
236242

237243
impl<T: Iterator<u8>> IterReader<T> {
238-
/// Create a new `IterReader` which will read from the specified `Iterator`.
244+
/// Creates a new `IterReader` which will read from the specified
245+
/// `Iterator`.
239246
pub fn new(iter: T) -> IterReader<T> {
240-
IterReader {
241-
iter: iter,
242-
}
247+
IterReader { iter: iter }
243248
}
244249
}
245250

@@ -251,7 +256,7 @@ impl<T: Iterator<u8>> Reader for IterReader<T> {
251256
*slot = elt;
252257
len += 1;
253258
}
254-
if len == 0 {
259+
if len == 0 && buf.len() != 0 {
255260
Err(io::standard_error(io::EndOfFile))
256261
} else {
257262
Ok(len)
@@ -297,6 +302,14 @@ mod test {
297302
assert_eq!(0, r.limit());
298303
}
299304

305+
#[test]
306+
fn test_limit_reader_overlong_consume() {
307+
let mut r = MemReader::new(vec![0, 1, 2, 3, 4, 5]);
308+
let mut r = LimitReader::new(r.by_ref(), 1);
309+
r.consume(2);
310+
assert_eq!(vec![], r.read_to_end().unwrap());
311+
}
312+
300313
#[test]
301314
fn test_null_writer() {
302315
let mut s = NullWriter;
@@ -415,4 +428,11 @@ mod test {
415428

416429
assert_eq!(r.read(buf).unwrap_err().kind, io::EndOfFile);
417430
}
431+
432+
#[test]
433+
fn iter_reader_zero_length() {
434+
let mut r = IterReader::new(range(0u8, 8));
435+
let mut buf = [];
436+
assert_eq!(Ok(0), r.read(buf));
437+
}
418438
}

trunk/src/rustllvm/RustWrapper.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,11 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateSubroutineType(
282282
LLVMValueRef ParameterTypes) {
283283
return wrap(Builder->createSubroutineType(
284284
unwrapDI<DIFile>(File),
285+
#if LLVM_VERSION_MINOR >= 6
285286
unwrapDI<DITypeArray>(ParameterTypes)));
287+
#else
288+
unwrapDI<DIArray>(ParameterTypes)));
289+
#endif
286290
}
287291

288292
extern "C" LLVMValueRef LLVMDIBuilderCreateFunction(
@@ -634,7 +638,11 @@ extern "C" void LLVMDICompositeTypeSetTypeArray(
634638
LLVMValueRef CompositeType,
635639
LLVMValueRef TypeArray)
636640
{
641+
#if LLVM_VERSION_MINOR >= 6
637642
unwrapDI<DICompositeType>(CompositeType).setArrays(unwrapDI<DIArray>(TypeArray));
643+
#else
644+
unwrapDI<DICompositeType>(CompositeType).setTypeArray(unwrapDI<DIArray>(TypeArray));
645+
#endif
638646
}
639647

640648
extern "C" char *LLVMTypeToString(LLVMTypeRef Type) {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-include ../tools.mk
2+
3+
# ignore windows: `ln` is actually `cp` on msys.
4+
ifndef IS_WINDOWS
5+
6+
all:
7+
$(RUSTC) foo.rs
8+
mkdir -p $(TMPDIR)/other
9+
ln -nsf $(TMPDIR)/libfoo.rlib $(TMPDIR)/other
10+
$(RUSTC) bar.rs -L $(TMPDIR)
11+
$(RUSTC) baz.rs --extern foo=$(TMPDIR)/other/libfoo.rlib -L $(TMPDIR)
12+
13+
else
14+
all:
15+
16+
endif
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![crate_type = "rlib"]
12+
13+
extern crate foo;
14+
15+
pub fn bar(_s: foo::S) {
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
extern crate bar;
12+
extern crate foo;
13+
14+
fn main() {
15+
bar::bar(foo::foo());
16+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![crate_type = "rlib"]
12+
13+
pub struct S;
14+
15+
pub fn foo() -> S { S }

0 commit comments

Comments
 (0)