Skip to content

Commit a1aa6d8

Browse files
committed
---
yaml --- r: 232643 b: refs/heads/try c: c69c29b h: refs/heads/master i: 232641: 30cc3b3 232639: 935e43a v: v3
1 parent 346f742 commit a1aa6d8

File tree

31 files changed

+848
-639
lines changed

31 files changed

+848
-639
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: edeb4f1c86cbf6af8ef9874d4b3af50f721ea1b8
33
refs/heads/snap-stage3: 1af31d4974e33027a68126fa5a5a3c2c6491824f
4-
refs/heads/try: 5e9008dfb7be19a51855009f67b57738c7dea5d2
4+
refs/heads/try: c69c29bb530968e35069c53a573c80299ccc8ac8
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/src/doc/nomicon/coercions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Coercion is allowed between the following types:
2222
for all pointer types (including smart pointers like Box and Rc). Unsize is
2323
only implemented automatically, and enables the following transformations:
2424

25-
* `[T, ..n]` => `[T]`
25+
* `[T; n]` => `[T]`
2626
* `T` => `Trait` where `T: Trait`
2727
* `Foo<..., T, ...>` => `Foo<..., U, ...>` where:
2828
* `T: Unsize<U>`

branches/try/src/doc/nomicon/safe-unsafe-meaning.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ unsafe impl UnsafeOrd for MyType {
125125
But it's probably not the implementation you want.
126126

127127
Rust has traditionally avoided making traits unsafe because it makes Unsafe
128-
pervasive, which is not desirable. Send and Sync are unsafe is because thread
128+
pervasive, which is not desirable. The reason Send and Sync are unsafe is because thread
129129
safety is a *fundamental property* that unsafe code cannot possibly hope to defend
130130
against in the same way it would defend against a bad Ord implementation. The
131131
only way to possibly defend against thread-unsafety would be to *not use

branches/try/src/doc/reference.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2073,6 +2073,7 @@ The following configurations must be defined by the implementation:
20732073
* `target_pointer_width = "..."`. Target pointer width in bits. This is set
20742074
to `"32"` for targets with 32-bit pointers, and likewise set to `"64"` for
20752075
64-bit pointers.
2076+
* `test`. Enabled when compiling the test harness (using the `--test` flag).
20762077
* `unix`. See `target_family`.
20772078
* `windows`. See `target_family`.
20782079

branches/try/src/doc/trpl/concurrency.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,12 +343,14 @@ threads as a simple isolation mechanism:
343343
```rust
344344
use std::thread;
345345

346-
let result = thread::spawn(move || {
346+
let handle = thread::spawn(move || {
347347
panic!("oops!");
348-
}).join();
348+
});
349+
350+
let result = handle.join();
349351

350352
assert!(result.is_err());
351353
```
352354

353-
Our `Thread` gives us a `Result` back, which allows us to check if the thread
355+
`Thread.join()` gives us a `Result` back, which allows us to check if the thread
354356
has panicked or not.

branches/try/src/doc/trpl/documentation.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ hello.rs:4 }
7373
```
7474

7575
This [unfortunate error](https://github.com/rust-lang/rust/issues/22547) is
76-
correct: documentation comments apply to the thing after them, and there's no
77-
thing after that last comment.
76+
correct: documentation comments apply to the thing after them, and there's
77+
nothing after that last comment.
7878

7979
[rc-new]: https://doc.rust-lang.org/nightly/std/rc/struct.Rc.html#method.new
8080

@@ -196,10 +196,10 @@ This will highlight according to whatever language you're showing off.
196196
If you're just showing plain text, choose `text`.
197197

198198
It's important to choose the correct annotation here, because `rustdoc` uses it
199-
in an interesting way: It can be used to actually test your examples, so that
200-
they don't get out of date. If you have some C code but `rustdoc` thinks it's
201-
Rust because you left off the annotation, `rustdoc` will complain when trying to
202-
generate the documentation.
199+
in an interesting way: It can be used to actually test your examples in a
200+
library crate, so that they don't get out of date. If you have some C code but
201+
`rustdoc` thinks it's Rust because you left off the annotation, `rustdoc` will
202+
complain when trying to generate the documentation.
203203

204204
## Documentation as tests
205205

@@ -377,8 +377,8 @@ $ rustdoc --test path/to/my/crate/root.rs
377377
$ cargo test
378378
```
379379

380-
That's right, `cargo test` tests embedded documentation too. However,
381-
`cargo test` will not test binary crates, only library ones. This is
380+
That's right, `cargo test` tests embedded documentation too. **However,
381+
`cargo test` will not test binary crates, only library ones.** This is
382382
due to the way `rustdoc` works: it links against the library to be tested,
383383
but with a binary, there’s nothing to link to.
384384

branches/try/src/doc/trpl/glossary.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ let z = (8, 2, 6);
3838

3939
In the example above `x` and `y` have arity 2. `z` has arity 3.
4040

41+
### DST (Dynamically Sized Type)
42+
43+
A type without a statically known size or alignment. ([more info][link])
44+
45+
[link]: ../nomicon/exotic-sizes.html#dynamically-sized-types-(dsts)
46+
4147
### Expression
4248

4349
In computer programming, an expression is a combination of values, constants,

branches/try/src/doc/trpl/testing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,8 @@ Let's finally check out that third section: documentation tests.
355355
Nothing is better than documentation with examples. Nothing is worse than
356356
examples that don't actually work, because the code has changed since the
357357
documentation has been written. To this end, Rust supports automatically
358-
running examples in your documentation. Here's a fleshed-out `src/lib.rs`
359-
with examples:
358+
running examples in your documentation (**note:** this only works in library
359+
crates, not binary crates). Here's a fleshed-out `src/lib.rs` with examples:
360360

361361
```rust,ignore
362362
//! The `adder` crate provides functions that add numbers to other numbers.

branches/try/src/libcore/intrinsics.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,11 @@ extern "rust-intrinsic" {
247247
/// ```
248248
/// use std::mem;
249249
///
250-
/// let v: &[u8] = unsafe { mem::transmute("L") };
251-
/// assert!(v == [76]);
250+
/// let array: &[u8] = unsafe { mem::transmute("Rust") };
251+
/// assert_eq!(array, [82, 117, 115, 116]);
252252
/// ```
253253
#[stable(feature = "rust1", since = "1.0.0")]
254-
pub fn transmute<T,U>(e: T) -> U;
254+
pub fn transmute<T, U>(e: T) -> U;
255255

256256
/// Gives the address for the return value of the enclosing function.
257257
///

branches/try/src/libcoretest/char.rs

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -55,28 +55,24 @@ fn test_to_digit() {
5555

5656
#[test]
5757
fn test_to_lowercase() {
58-
fn lower(c: char) -> char {
59-
let mut it = c.to_lowercase();
60-
let c = it.next().unwrap();
61-
// As of Unicode version 7.0.0, `SpecialCasing.txt` has no lower-case mapping
62-
// to multiple code points.
63-
assert!(it.next().is_none());
64-
c
58+
fn lower(c: char) -> Vec<char> {
59+
c.to_lowercase().collect()
6560
}
66-
assert_eq!(lower('A'), 'a');
67-
assert_eq!(lower('Ö'), 'ö');
68-
assert_eq!(lower('ß'), 'ß');
69-
assert_eq!(lower('Ü'), 'ü');
70-
assert_eq!(lower('💩'), '💩');
71-
assert_eq!(lower('Σ'), 'σ');
72-
assert_eq!(lower('Τ'), 'τ');
73-
assert_eq!(lower('Ι'), 'ι');
74-
assert_eq!(lower('Γ'), 'γ');
75-
assert_eq!(lower('Μ'), 'μ');
76-
assert_eq!(lower('Α'), 'α');
77-
assert_eq!(lower('Σ'), 'σ');
78-
assert_eq!(lower('Dž'), 'dž');
79-
assert_eq!(lower('fi'), 'fi');
61+
assert_eq!(lower('A'), ['a']);
62+
assert_eq!(lower('Ö'), ['ö']);
63+
assert_eq!(lower('ß'), ['ß']);
64+
assert_eq!(lower('Ü'), ['ü']);
65+
assert_eq!(lower('💩'), ['💩']);
66+
assert_eq!(lower('Σ'), ['σ']);
67+
assert_eq!(lower('Τ'), ['τ']);
68+
assert_eq!(lower('Ι'), ['ι']);
69+
assert_eq!(lower('Γ'), ['γ']);
70+
assert_eq!(lower('Μ'), ['μ']);
71+
assert_eq!(lower('Α'), ['α']);
72+
assert_eq!(lower('Σ'), ['σ']);
73+
assert_eq!(lower('Dž'), ['dž']);
74+
assert_eq!(lower('fi'), ['fi']);
75+
assert_eq!(lower('İ'), ['i', '\u{307}']);
8076
}
8177

8278
#[test]

branches/try/src/liblibc/lib.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,15 @@ pub mod types {
192192
/// C. Use the unit type `()` or omit the return type instead.
193193
///
194194
/// For LLVM to recognize the void pointer type and by extension
195-
/// functions like malloc(), we need to have it represented as i8* in
196-
/// LLVM bitcode. The enum used here ensures this and prevents misuse
197-
/// of the "raw" type by only having private variants.. We need two
198-
/// variants, because the compiler complains about the repr attribute
199-
/// otherwise.
195+
/// functions like malloc(), we need to have it represented as i8*
196+
/// in LLVM bitcode. The enum used here ensures this. We need two
197+
/// variants, because the compiler complains about the `repr`
198+
/// attribute otherwise.
200199
#[repr(u8)]
201200
pub enum c_void {
201+
#[doc(hidden)]
202202
__variant1,
203+
#[doc(hidden)]
203204
__variant2,
204205
}
205206

branches/try/src/librustc/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ pub mod middle {
112112
pub mod check_static_recursion;
113113
pub mod check_loop;
114114
pub mod check_match;
115+
pub mod check_no_asm;
115116
pub mod check_rvalues;
116117
pub mod const_eval;
117118
pub mod dataflow;
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright 2015 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+
/// Run over the whole crate and check for ExprInlineAsm.
12+
/// Inline asm isn't allowed on virtual ISA based targets, so we reject it
13+
/// here.
14+
15+
use session::Session;
16+
17+
use syntax::ast;
18+
use syntax::visit::Visitor;
19+
use syntax::visit;
20+
21+
pub fn check_crate(sess: &Session, krate: &ast::Crate) {
22+
if sess.target.target.options.allow_asm { return; }
23+
24+
visit::walk_crate(&mut CheckNoAsm { sess: sess, }, krate);
25+
}
26+
27+
#[derive(Copy, Clone)]
28+
struct CheckNoAsm<'a> {
29+
sess: &'a Session,
30+
}
31+
32+
impl<'a, 'v> Visitor<'v> for CheckNoAsm<'a> {
33+
fn visit_expr(&mut self, e: &ast::Expr) {
34+
match e.node {
35+
ast::ExprInlineAsm(_) => self.sess.span_err(e.span,
36+
"asm! is unsupported on this target"),
37+
_ => {},
38+
}
39+
visit::walk_expr(self, e)
40+
}
41+
}

branches/try/src/librustc_back/target/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ pub struct TargetOptions {
168168
/// currently only "gnu" is used to fall into LLVM. Unknown strings cause
169169
/// the system linker to be used.
170170
pub archive_format: String,
171+
/// Is asm!() allowed? Defaults to true.
172+
pub allow_asm: bool,
171173
/// Whether the target uses a custom unwind resumption routine.
172174
/// By default LLVM lowers `resume` instructions into calls to `_Unwind_Resume`
173175
/// defined in libgcc. If this option is enabled, the target must provide
@@ -217,6 +219,7 @@ impl Default for TargetOptions {
217219
custom_unwind_resume: false,
218220
lib_allocation_crate: "alloc_system".to_string(),
219221
exe_allocation_crate: "alloc_system".to_string(),
222+
allow_asm: true,
220223
}
221224
}
222225
}
@@ -310,6 +313,7 @@ impl Target {
310313
key!(no_compiler_rt, bool);
311314
key!(pre_link_args, list);
312315
key!(post_link_args, list);
316+
key!(allow_asm, bool);
313317

314318
base
315319
}

branches/try/src/librustc_data_structures/transitive_relation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl<T:Debug+PartialEq> TransitiveRelation<T> {
110110
/// (there are corresponding tests below, btw). In each case,
111111
/// the query is `postdom_upper_bound(a, b)`:
112112
///
113-
/// ```
113+
/// ```text
114114
/// // returns Some(x), which is also LUB
115115
/// a -> a1 -> x
116116
/// ^

branches/try/src/librustc_driver/driver.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,9 @@ pub fn phase_2_configure_and_expand(sess: &Session,
563563
time(time_passes, "checking that all macro invocations are gone", ||
564564
syntax::ext::expand::check_for_macros(&sess.parse_sess, &krate));
565565

566+
time(time_passes, "checking for inline asm in case the target doesn't support it", ||
567+
middle::check_no_asm::check_crate(sess, &krate));
568+
566569
// One final feature gating of the true AST that gets compiled
567570
// later, to make sure we've got everything (e.g. configuration
568571
// can insert new attributes via `cfg_attr`)

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,11 @@ pub fn memcpy_ty<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
956956
t: Ty<'tcx>) {
957957
let _icx = push_ctxt("memcpy_ty");
958958
let ccx = bcx.ccx();
959+
960+
if type_is_zero_size(ccx, t) {
961+
return;
962+
}
963+
959964
if t.is_structural() {
960965
let llty = type_of::type_of(ccx, t);
961966
let llsz = llsize_of(ccx, llty);

branches/try/src/librustdoc/clean/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,7 @@ impl Clean<Method> for ast::MethodSig {
999999
values: inputs.clean(cx),
10001000
},
10011001
output: self.decl.output.clean(cx),
1002+
variadic: false,
10021003
attrs: Vec::new()
10031004
};
10041005
Method {
@@ -1032,6 +1033,7 @@ impl Clean<TyMethod> for ast::MethodSig {
10321033
values: inputs.clean(cx),
10331034
},
10341035
output: self.decl.output.clean(cx),
1036+
variadic: false,
10351037
attrs: Vec::new()
10361038
};
10371039
TyMethod {
@@ -1098,6 +1100,7 @@ impl Clean<Item> for doctree::Function {
10981100
pub struct FnDecl {
10991101
pub inputs: Arguments,
11001102
pub output: FunctionRetTy,
1103+
pub variadic: bool,
11011104
pub attrs: Vec<Attribute>,
11021105
}
11031106

@@ -1113,6 +1116,7 @@ impl Clean<FnDecl> for ast::FnDecl {
11131116
values: self.inputs.clean(cx),
11141117
},
11151118
output: self.output.clean(cx),
1119+
variadic: self.variadic,
11161120
attrs: Vec::new()
11171121
}
11181122
}
@@ -1141,6 +1145,7 @@ impl<'a, 'tcx> Clean<FnDecl> for (ast::DefId, &'a ty::PolyFnSig<'tcx>) {
11411145
FnDecl {
11421146
output: Return(sig.0.output.clean(cx)),
11431147
attrs: Vec::new(),
1148+
variadic: sig.0.variadic,
11441149
inputs: Arguments {
11451150
values: sig.0.inputs.iter().map(|t| {
11461151
Argument {

branches/try/src/librustdoc/html/format.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,11 @@ impl fmt::Display for clean::FunctionRetTy {
579579

580580
impl fmt::Display for clean::FnDecl {
581581
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
582-
write!(f, "({args}){arrow}", args = self.inputs, arrow = self.output)
582+
if self.variadic {
583+
write!(f, "({args}, ...){arrow}", args = self.inputs, arrow = self.output)
584+
} else {
585+
write!(f, "({args}){arrow}", args = self.inputs, arrow = self.output)
586+
}
583587
}
584588
}
585589

0 commit comments

Comments
 (0)