Skip to content

Commit

Permalink
Auto merge of #34139 - steveklabnik:rollup, r=steveklabnik
Browse files Browse the repository at this point in the history
Rollup of 13 pull requests

- Successful merges: #33645, #33897, #33945, #34007, #34060, #34070, #34094, #34098, #34099, #34104, #34124, #34125, #34138
- Failed merges:
  • Loading branch information
bors committed Jun 7, 2016
2 parents 9b2beca + a0bf3b8 commit 39a523b
Show file tree
Hide file tree
Showing 75 changed files with 483 additions and 331 deletions.
9 changes: 8 additions & 1 deletion CONTRIBUTING.md
Expand Up @@ -108,7 +108,8 @@ root.
There are large number of options accepted by this script to alter the
configuration used later in the build process. Some options to note:

- `--enable-debug` - Build a debug version of the compiler (disables optimizations)
- `--enable-debug` - Build a debug version of the compiler (disables optimizations,
which speeds up compilation of stage1 rustc)
- `--enable-optimize` - Enable optimizations (can be used with `--enable-debug`
to make a debug build with optimizations)
- `--disable-valgrind-rpass` - Don't run tests with valgrind
Expand All @@ -128,6 +129,12 @@ Some common make targets are:
cases we don't need to build the stage2 compiler, so we can save time by not
building it. The stage1 compiler is a fully functioning compiler and
(probably) will be enough to determine if your change works as expected.
- `make $host/stage1/bin/rustc` - Where $host is a target triple like x86_64-unknown-linux-gnu.
This will build just rustc, without libstd. This is the fastest way to recompile after
you changed only rustc source code. Note however that the resulting rustc binary
won't have a stdlib to link against by default. You can build libstd once with
`make rustc-stage1`, rustc will pick it up afterwards. libstd is only guaranteed to
work if recompiled, so if there are any issues recompile it.
- `make check` - build the full compiler & run all tests (takes a while). This
is what gets run by the continuous integration system against your pull
request. You should run this before submitting to make sure your tests pass
Expand Down
11 changes: 11 additions & 0 deletions Makefile.in
Expand Up @@ -62,6 +62,8 @@
# * tidy - Basic style check, show highest rustc error code and
# the status of language and lib features
# * rustc-stage$(stage) - Only build up to a specific stage
# * $host/stage1/bin/rustc - Only build stage1 rustc, not libstd. For further
# information see "Rust recipes for build system success" below.
#
# Then mix in some of these environment variables to harness the
# ultimate power of The Rust Build System.
Expand Down Expand Up @@ -93,6 +95,15 @@
# // Modifying libstd? Use this command to run unit tests just on your change
# make check-stage1-std NO_REBUILD=1 NO_BENCH=1
#
# // Modifying just rustc?
# // Compile rustc+libstd once
# make rustc-stage1
# // From now on use this command to rebuild just rustc and reuse the previously built libstd
# // $host is a target triple, eg. x86_64-unknown-linux-gnu
# // The resulting binary is located at $host/stage1/bin/rustc.
# // If there are any issues with libstd recompile it with the command above.
# make $host/stage1/bin/rustc
#
# // Added a run-pass test? Use this to test running your test
# make check-stage1-rpass TESTNAME=my-shiny-new-test
#
Expand Down
4 changes: 2 additions & 2 deletions configure
Expand Up @@ -988,11 +988,11 @@ then
LLVM_VERSION=$($LLVM_CONFIG --version)

case $LLVM_VERSION in
(3.[6-8]*)
(3.[7-8]*)
msg "found ok version of LLVM: $LLVM_VERSION"
;;
(*)
err "bad LLVM version: $LLVM_VERSION, need >=3.6"
err "bad LLVM version: $LLVM_VERSION, need >=3.7"
;;
esac
fi
Expand Down
2 changes: 1 addition & 1 deletion src/doc/book/functions.md
Expand Up @@ -249,7 +249,7 @@ stack backtrace:
If you need to override an already set `RUST_BACKTRACE`,
in cases when you cannot just unset the variable,
then set it to `0` to avoid getting a backtrace.
Any other value(even no value at all) turns on backtrace.
Any other value (even no value at all) turns on backtrace.

```text
$ export RUST_BACKTRACE=1
Expand Down
14 changes: 10 additions & 4 deletions src/doc/book/testing.md
Expand Up @@ -380,8 +380,9 @@ the `tests` directory.

# The `tests` directory

To write an integration test, let's make a `tests` directory, and
put a `tests/lib.rs` file inside, with this as its contents:
Each file in `tests/*.rs` directory is treated as individual crate.
So, to write an integration test, let's make a `tests` directory, and
put a `tests/integration_test.rs` file inside, with this as its contents:

```rust,ignore
extern crate adder;
Expand All @@ -394,8 +395,8 @@ fn it_works() {
```

This looks similar to our previous tests, but slightly different. We now have
an `extern crate adder` at the top. This is because the tests in the `tests`
directory are an entirely separate crate, and so we need to import our library.
an `extern crate adder` at the top. This is because each test in the `tests`
directory is an entirely separate crate, and so we need to import our library.
This is also why `tests` is a suitable place to write integration-style tests:
they use the library like any other consumer of it would.

Expand Down Expand Up @@ -428,6 +429,11 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
Now we have three sections: our previous test is also run, as well as our new
one.

Cargo will ignore files in subdirectories of the `tests/` directory.
Therefore shared modules in integrations tests are possible.
For example `tests/common/mod.rs` is not seperatly compiled by cargo but can
be imported in every test with `mod common;`

That's all there is to the `tests` directory. The `tests` module isn't needed
here, since the whole thing is focused on tests.

Expand Down
18 changes: 11 additions & 7 deletions src/doc/book/variable-bindings.md
Expand Up @@ -37,8 +37,8 @@ of our minds as we go forward.
Rust is a statically typed language, which means that we specify our types up
front, and they’re checked at compile time. So why does our first example
compile? Well, Rust has this thing called ‘type inference’. If it can figure
out what the type of something is, Rust doesn’t require you to actually type it
out.
out what the type of something is, Rust doesn’t require you to explicitly type
it out.

We can add the type if we want to, though. Types come after a colon (`:`):

Expand Down Expand Up @@ -159,8 +159,9 @@ error: aborting due to previous error
Could not compile `hello_world`.
```

Rust will not let us use a value that has not been initialized. Next, let’s
talk about this stuff we've added to `println!`.
Rust will not let us use a value that has not been initialized.

Let take a minute to talk about this stuff we've added to `println!`.

If you include two curly braces (`{}`, some call them moustaches...) in your
string to print, Rust will interpret this as a request to interpolate some sort
Expand Down Expand Up @@ -222,8 +223,8 @@ To learn more, run the command again with --verbose.
```
Additionally, variable bindings can be shadowed. This means that a later
variable binding with the same name as another binding, that's currently in
scope, will override the previous binding.
variable binding with the same name as another binding that is currently in
scope will override the previous binding.
```rust
let x: i32 = 8;
Expand All @@ -240,7 +241,10 @@ println!("{}", x); // Prints "42"
Shadowing and mutable bindings may appear as two sides of the same coin, but
they are two distinct concepts that can't always be used interchangeably. For
one, shadowing enables us to rebind a name to a value of a different type. It
is also possible to change the mutability of a binding.
is also possible to change the mutability of a binding. Note that shadowing a
name does not alter or destroy the value it was bound to, and the value will
continue to exist until it goes out of scope, even if it is no longer accessible
by any means.

```rust
let mut x: i32 = 1;
Expand Down
3 changes: 1 addition & 2 deletions src/doc/reference.md
Expand Up @@ -1983,6 +1983,7 @@ macro scope.

### Miscellaneous attributes

- `deprecated` - mark the item as deprecated; the full attribute is `#[deprecated(since = "crate version", note = "...")`, where both arguments are optional.
- `export_name` - on statics and functions, this determines the name of the
exported symbol.
- `link_section` - on statics and functions, this specifies the section of the
Expand Down Expand Up @@ -2426,8 +2427,6 @@ The currently implemented features of the reference compiler are:
* - `stmt_expr_attributes` - Allows attributes on expressions and
non-item statements.

* - `deprecated` - Allows using the `#[deprecated]` attribute.

* - `type_ascription` - Allows type ascription expressions `expr: Type`.

* - `abi_vectorcall` - Allows the usage of the vectorcall calling convention
Expand Down
2 changes: 1 addition & 1 deletion src/doc/rust.css
Expand Up @@ -229,7 +229,7 @@ a > code {
pre.rust .kw { color: #8959A8; }
pre.rust .kw-2, pre.rust .prelude-ty { color: #4271AE; }
pre.rust .number, pre.rust .string { color: #718C00; }
pre.rust .self, pre.rust .boolval, pre.rust .prelude-val,
pre.rust .self, pre.rust .bool-val, pre.rust .prelude-val,
pre.rust .attribute, pre.rust .attribute .ident { color: #C82829; }
pre.rust .comment { color: #8E908C; }
pre.rust .doccomment { color: #4D4D4C; }
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/rc.rs
Expand Up @@ -271,7 +271,7 @@ impl<T> Rc<T> {
}

impl<T: ?Sized> Rc<T> {
/// Downgrades the `Rc<T>` to a `Weak<T>` reference.
/// Creates a new `Weak<T>` reference from this value.
///
/// # Examples
///
Expand Down
4 changes: 2 additions & 2 deletions src/libcollections/str.rs
Expand Up @@ -1404,8 +1404,8 @@ impl str {
/// Returns a string slice with all prefixes and suffixes that match a
/// pattern repeatedly removed.
///
/// The pattern can be a `&str`, [`char`], or a closure that determines
/// if a character matches.
/// The pattern can be a [`char`] or a closure that determines if a
/// character matches.
///
/// [`char`]: primitive.char.html
///
Expand Down
75 changes: 40 additions & 35 deletions src/libpanic_unwind/dwarf/eh.rs
Expand Up @@ -24,36 +24,35 @@
use dwarf::DwarfReader;
use core::mem;

pub const DW_EH_PE_omit : u8 = 0xFF;
pub const DW_EH_PE_absptr : u8 = 0x00;

pub const DW_EH_PE_uleb128 : u8 = 0x01;
pub const DW_EH_PE_udata2 : u8 = 0x02;
pub const DW_EH_PE_udata4 : u8 = 0x03;
pub const DW_EH_PE_udata8 : u8 = 0x04;
pub const DW_EH_PE_sleb128 : u8 = 0x09;
pub const DW_EH_PE_sdata2 : u8 = 0x0A;
pub const DW_EH_PE_sdata4 : u8 = 0x0B;
pub const DW_EH_PE_sdata8 : u8 = 0x0C;

pub const DW_EH_PE_pcrel : u8 = 0x10;
pub const DW_EH_PE_textrel : u8 = 0x20;
pub const DW_EH_PE_datarel : u8 = 0x30;
pub const DW_EH_PE_funcrel : u8 = 0x40;
pub const DW_EH_PE_aligned : u8 = 0x50;

pub const DW_EH_PE_indirect : u8 = 0x80;
pub const DW_EH_PE_omit: u8 = 0xFF;
pub const DW_EH_PE_absptr: u8 = 0x00;

pub const DW_EH_PE_uleb128: u8 = 0x01;
pub const DW_EH_PE_udata2: u8 = 0x02;
pub const DW_EH_PE_udata4: u8 = 0x03;
pub const DW_EH_PE_udata8: u8 = 0x04;
pub const DW_EH_PE_sleb128: u8 = 0x09;
pub const DW_EH_PE_sdata2: u8 = 0x0A;
pub const DW_EH_PE_sdata4: u8 = 0x0B;
pub const DW_EH_PE_sdata8: u8 = 0x0C;

pub const DW_EH_PE_pcrel: u8 = 0x10;
pub const DW_EH_PE_textrel: u8 = 0x20;
pub const DW_EH_PE_datarel: u8 = 0x30;
pub const DW_EH_PE_funcrel: u8 = 0x40;
pub const DW_EH_PE_aligned: u8 = 0x50;

pub const DW_EH_PE_indirect: u8 = 0x80;

#[derive(Copy, Clone)]
pub struct EHContext {
pub ip: usize, // Current instruction pointer
pub ip: usize, // Current instruction pointer
pub func_start: usize, // Address of the current function
pub text_start: usize, // Address of the code section
pub data_start: usize, // Address of the data section
}

pub unsafe fn find_landing_pad(lsda: *const u8, context: &EHContext)
-> Option<usize> {
pub unsafe fn find_landing_pad(lsda: *const u8, context: &EHContext) -> Option<usize> {
if lsda.is_null() {
return None;
}
Expand All @@ -80,7 +79,7 @@ pub unsafe fn find_landing_pad(lsda: *const u8, context: &EHContext)
let action_table = reader.ptr.offset(call_site_table_length as isize);
// Return addresses point 1 byte past the call instruction, which could
// be in the next IP range.
let ip = context.ip-1;
let ip = context.ip - 1;

while reader.ptr < action_table {
let cs_start = read_encoded_pointer(&mut reader, context, call_site_encoding);
Expand All @@ -90,7 +89,7 @@ pub unsafe fn find_landing_pad(lsda: *const u8, context: &EHContext)
// Callsite table is sorted by cs_start, so if we've passed the ip, we
// may stop searching.
if ip < func_start + cs_start {
break
break;
}
if ip < func_start + cs_start + cs_len {
if cs_lpad != 0 {
Expand All @@ -114,13 +113,13 @@ fn round_up(unrounded: usize, align: usize) -> usize {

unsafe fn read_encoded_pointer(reader: &mut DwarfReader,
context: &EHContext,
encoding: u8) -> usize {
encoding: u8)
-> usize {
assert!(encoding != DW_EH_PE_omit);

// DW_EH_PE_aligned implies it's an absolute pointer value
if encoding == DW_EH_PE_aligned {
reader.ptr = round_up(reader.ptr as usize,
mem::size_of::<usize>()) as *const u8;
reader.ptr = round_up(reader.ptr as usize, mem::size_of::<usize>()) as *const u8;
return reader.read::<usize>();
}

Expand All @@ -134,20 +133,26 @@ unsafe fn read_encoded_pointer(reader: &mut DwarfReader,
DW_EH_PE_sdata2 => reader.read::<i16>() as usize,
DW_EH_PE_sdata4 => reader.read::<i32>() as usize,
DW_EH_PE_sdata8 => reader.read::<i64>() as usize,
_ => panic!()
_ => panic!(),
};

result += match encoding & 0x70 {
DW_EH_PE_absptr => 0,
// relative to address of the encoded value, despite the name
DW_EH_PE_pcrel => reader.ptr as usize,
DW_EH_PE_textrel => { assert!(context.text_start != 0);
context.text_start },
DW_EH_PE_datarel => { assert!(context.data_start != 0);
context.data_start },
DW_EH_PE_funcrel => { assert!(context.func_start != 0);
context.func_start },
_ => panic!()
DW_EH_PE_textrel => {
assert!(context.text_start != 0);
context.text_start
}
DW_EH_PE_datarel => {
assert!(context.data_start != 0);
context.data_start
}
DW_EH_PE_funcrel => {
assert!(context.func_start != 0);
context.func_start
}
_ => panic!(),
};

if encoding & DW_EH_PE_indirect != 0 {
Expand Down
30 changes: 11 additions & 19 deletions src/libpanic_unwind/dwarf/mod.rs
Expand Up @@ -21,25 +21,22 @@ pub mod eh;
use core::mem;

pub struct DwarfReader {
pub ptr : *const u8
pub ptr: *const u8,
}

#[repr(C,packed)]
struct Unaligned<T>(T);

impl DwarfReader {

pub fn new(ptr : *const u8) -> DwarfReader {
DwarfReader {
ptr : ptr
}
pub fn new(ptr: *const u8) -> DwarfReader {
DwarfReader { ptr: ptr }
}

// DWARF streams are packed, so e.g. a u32 would not necessarily be aligned
// on a 4-byte boundary. This may cause problems on platforms with strict
// alignment requirements. By wrapping data in a "packed" struct, we are
// telling the backend to generate "misalignment-safe" code.
pub unsafe fn read<T:Copy>(&mut self) -> T {
pub unsafe fn read<T: Copy>(&mut self) -> T {
let Unaligned(result) = *(self.ptr as *const Unaligned<T>);
self.ptr = self.ptr.offset(mem::size_of::<T>() as isize);
result
Expand All @@ -48,9 +45,9 @@ impl DwarfReader {
// ULEB128 and SLEB128 encodings are defined in Section 7.6 - "Variable
// Length Data".
pub unsafe fn read_uleb128(&mut self) -> u64 {
let mut shift : usize = 0;
let mut result : u64 = 0;
let mut byte : u8;
let mut shift: usize = 0;
let mut result: u64 = 0;
let mut byte: u8;
loop {
byte = self.read::<u8>();
result |= ((byte & 0x7F) as u64) << shift;
Expand All @@ -63,9 +60,9 @@ impl DwarfReader {
}

pub unsafe fn read_sleb128(&mut self) -> i64 {
let mut shift : usize = 0;
let mut result : u64 = 0;
let mut byte : u8;
let mut shift: usize = 0;
let mut result: u64 = 0;
let mut byte: u8;
loop {
byte = self.read::<u8>();
result |= ((byte & 0x7F) as u64) << shift;
Expand All @@ -84,12 +81,7 @@ impl DwarfReader {

#[test]
fn dwarf_reader() {
let encoded: &[u8] = &[1,
2, 3,
4, 5, 6, 7,
0xE5, 0x8E, 0x26,
0x9B, 0xF1, 0x59,
0xFF, 0xFF];
let encoded: &[u8] = &[1, 2, 3, 4, 5, 6, 7, 0xE5, 0x8E, 0x26, 0x9B, 0xF1, 0x59, 0xFF, 0xFF];

let mut reader = DwarfReader::new(encoded.as_ptr());

Expand Down

0 comments on commit 39a523b

Please sign in to comment.