Skip to content

Commit 39a523b

Browse files
committed
Auto merge of #34139 - steveklabnik:rollup, r=steveklabnik
Rollup of 13 pull requests - Successful merges: #33645, #33897, #33945, #34007, #34060, #34070, #34094, #34098, #34099, #34104, #34124, #34125, #34138 - Failed merges:
2 parents 9b2beca + a0bf3b8 commit 39a523b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+483
-331
lines changed

CONTRIBUTING.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ root.
108108
There are large number of options accepted by this script to alter the
109109
configuration used later in the build process. Some options to note:
110110

111-
- `--enable-debug` - Build a debug version of the compiler (disables optimizations)
111+
- `--enable-debug` - Build a debug version of the compiler (disables optimizations,
112+
which speeds up compilation of stage1 rustc)
112113
- `--enable-optimize` - Enable optimizations (can be used with `--enable-debug`
113114
to make a debug build with optimizations)
114115
- `--disable-valgrind-rpass` - Don't run tests with valgrind
@@ -128,6 +129,12 @@ Some common make targets are:
128129
cases we don't need to build the stage2 compiler, so we can save time by not
129130
building it. The stage1 compiler is a fully functioning compiler and
130131
(probably) will be enough to determine if your change works as expected.
132+
- `make $host/stage1/bin/rustc` - Where $host is a target triple like x86_64-unknown-linux-gnu.
133+
This will build just rustc, without libstd. This is the fastest way to recompile after
134+
you changed only rustc source code. Note however that the resulting rustc binary
135+
won't have a stdlib to link against by default. You can build libstd once with
136+
`make rustc-stage1`, rustc will pick it up afterwards. libstd is only guaranteed to
137+
work if recompiled, so if there are any issues recompile it.
131138
- `make check` - build the full compiler & run all tests (takes a while). This
132139
is what gets run by the continuous integration system against your pull
133140
request. You should run this before submitting to make sure your tests pass

Makefile.in

+11
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@
6262
# * tidy - Basic style check, show highest rustc error code and
6363
# the status of language and lib features
6464
# * rustc-stage$(stage) - Only build up to a specific stage
65+
# * $host/stage1/bin/rustc - Only build stage1 rustc, not libstd. For further
66+
# information see "Rust recipes for build system success" below.
6567
#
6668
# Then mix in some of these environment variables to harness the
6769
# ultimate power of The Rust Build System.
@@ -93,6 +95,15 @@
9395
# // Modifying libstd? Use this command to run unit tests just on your change
9496
# make check-stage1-std NO_REBUILD=1 NO_BENCH=1
9597
#
98+
# // Modifying just rustc?
99+
# // Compile rustc+libstd once
100+
# make rustc-stage1
101+
# // From now on use this command to rebuild just rustc and reuse the previously built libstd
102+
# // $host is a target triple, eg. x86_64-unknown-linux-gnu
103+
# // The resulting binary is located at $host/stage1/bin/rustc.
104+
# // If there are any issues with libstd recompile it with the command above.
105+
# make $host/stage1/bin/rustc
106+
#
96107
# // Added a run-pass test? Use this to test running your test
97108
# make check-stage1-rpass TESTNAME=my-shiny-new-test
98109
#

configure

+2-2
Original file line numberDiff line numberDiff line change
@@ -988,11 +988,11 @@ then
988988
LLVM_VERSION=$($LLVM_CONFIG --version)
989989

990990
case $LLVM_VERSION in
991-
(3.[6-8]*)
991+
(3.[7-8]*)
992992
msg "found ok version of LLVM: $LLVM_VERSION"
993993
;;
994994
(*)
995-
err "bad LLVM version: $LLVM_VERSION, need >=3.6"
995+
err "bad LLVM version: $LLVM_VERSION, need >=3.7"
996996
;;
997997
esac
998998
fi

src/doc/book/functions.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ stack backtrace:
249249
If you need to override an already set `RUST_BACKTRACE`,
250250
in cases when you cannot just unset the variable,
251251
then set it to `0` to avoid getting a backtrace.
252-
Any other value(even no value at all) turns on backtrace.
252+
Any other value (even no value at all) turns on backtrace.
253253

254254
```text
255255
$ export RUST_BACKTRACE=1

src/doc/book/testing.md

+10-4
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,9 @@ the `tests` directory.
380380

381381
# The `tests` directory
382382

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

386387
```rust,ignore
387388
extern crate adder;
@@ -394,8 +395,8 @@ fn it_works() {
394395
```
395396

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

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

432+
Cargo will ignore files in subdirectories of the `tests/` directory.
433+
Therefore shared modules in integrations tests are possible.
434+
For example `tests/common/mod.rs` is not seperatly compiled by cargo but can
435+
be imported in every test with `mod common;`
436+
431437
That's all there is to the `tests` directory. The `tests` module isn't needed
432438
here, since the whole thing is focused on tests.
433439

src/doc/book/variable-bindings.md

+11-7
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ of our minds as we go forward.
3737
Rust is a statically typed language, which means that we specify our types up
3838
front, and they’re checked at compile time. So why does our first example
3939
compile? Well, Rust has this thing called ‘type inference’. If it can figure
40-
out what the type of something is, Rust doesn’t require you to actually type it
41-
out.
40+
out what the type of something is, Rust doesn’t require you to explicitly type
41+
it out.
4242

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

@@ -159,8 +159,9 @@ error: aborting due to previous error
159159
Could not compile `hello_world`.
160160
```
161161

162-
Rust will not let us use a value that has not been initialized. Next, let’s
163-
talk about this stuff we've added to `println!`.
162+
Rust will not let us use a value that has not been initialized.
163+
164+
Let take a minute to talk about this stuff we've added to `println!`.
164165

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

245249
```rust
246250
let mut x: i32 = 1;

src/doc/reference.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -1983,6 +1983,7 @@ macro scope.
19831983

19841984
### Miscellaneous attributes
19851985

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

2429-
* - `deprecated` - Allows using the `#[deprecated]` attribute.
2430-
24312430
* - `type_ascription` - Allows type ascription expressions `expr: Type`.
24322431

24332432
* - `abi_vectorcall` - Allows the usage of the vectorcall calling convention

src/doc/rust.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ a > code {
229229
pre.rust .kw { color: #8959A8; }
230230
pre.rust .kw-2, pre.rust .prelude-ty { color: #4271AE; }
231231
pre.rust .number, pre.rust .string { color: #718C00; }
232-
pre.rust .self, pre.rust .boolval, pre.rust .prelude-val,
232+
pre.rust .self, pre.rust .bool-val, pre.rust .prelude-val,
233233
pre.rust .attribute, pre.rust .attribute .ident { color: #C82829; }
234234
pre.rust .comment { color: #8E908C; }
235235
pre.rust .doccomment { color: #4D4D4C; }

src/liballoc/rc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ impl<T> Rc<T> {
271271
}
272272

273273
impl<T: ?Sized> Rc<T> {
274-
/// Downgrades the `Rc<T>` to a `Weak<T>` reference.
274+
/// Creates a new `Weak<T>` reference from this value.
275275
///
276276
/// # Examples
277277
///

src/libcollections/str.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1404,8 +1404,8 @@ impl str {
14041404
/// Returns a string slice with all prefixes and suffixes that match a
14051405
/// pattern repeatedly removed.
14061406
///
1407-
/// The pattern can be a `&str`, [`char`], or a closure that determines
1408-
/// if a character matches.
1407+
/// The pattern can be a [`char`] or a closure that determines if a
1408+
/// character matches.
14091409
///
14101410
/// [`char`]: primitive.char.html
14111411
///

src/libpanic_unwind/dwarf/eh.rs

+40-35
Original file line numberDiff line numberDiff line change
@@ -24,36 +24,35 @@
2424
use dwarf::DwarfReader;
2525
use core::mem;
2626

27-
pub const DW_EH_PE_omit : u8 = 0xFF;
28-
pub const DW_EH_PE_absptr : u8 = 0x00;
29-
30-
pub const DW_EH_PE_uleb128 : u8 = 0x01;
31-
pub const DW_EH_PE_udata2 : u8 = 0x02;
32-
pub const DW_EH_PE_udata4 : u8 = 0x03;
33-
pub const DW_EH_PE_udata8 : u8 = 0x04;
34-
pub const DW_EH_PE_sleb128 : u8 = 0x09;
35-
pub const DW_EH_PE_sdata2 : u8 = 0x0A;
36-
pub const DW_EH_PE_sdata4 : u8 = 0x0B;
37-
pub const DW_EH_PE_sdata8 : u8 = 0x0C;
38-
39-
pub const DW_EH_PE_pcrel : u8 = 0x10;
40-
pub const DW_EH_PE_textrel : u8 = 0x20;
41-
pub const DW_EH_PE_datarel : u8 = 0x30;
42-
pub const DW_EH_PE_funcrel : u8 = 0x40;
43-
pub const DW_EH_PE_aligned : u8 = 0x50;
44-
45-
pub const DW_EH_PE_indirect : u8 = 0x80;
27+
pub const DW_EH_PE_omit: u8 = 0xFF;
28+
pub const DW_EH_PE_absptr: u8 = 0x00;
29+
30+
pub const DW_EH_PE_uleb128: u8 = 0x01;
31+
pub const DW_EH_PE_udata2: u8 = 0x02;
32+
pub const DW_EH_PE_udata4: u8 = 0x03;
33+
pub const DW_EH_PE_udata8: u8 = 0x04;
34+
pub const DW_EH_PE_sleb128: u8 = 0x09;
35+
pub const DW_EH_PE_sdata2: u8 = 0x0A;
36+
pub const DW_EH_PE_sdata4: u8 = 0x0B;
37+
pub const DW_EH_PE_sdata8: u8 = 0x0C;
38+
39+
pub const DW_EH_PE_pcrel: u8 = 0x10;
40+
pub const DW_EH_PE_textrel: u8 = 0x20;
41+
pub const DW_EH_PE_datarel: u8 = 0x30;
42+
pub const DW_EH_PE_funcrel: u8 = 0x40;
43+
pub const DW_EH_PE_aligned: u8 = 0x50;
44+
45+
pub const DW_EH_PE_indirect: u8 = 0x80;
4646

4747
#[derive(Copy, Clone)]
4848
pub struct EHContext {
49-
pub ip: usize, // Current instruction pointer
49+
pub ip: usize, // Current instruction pointer
5050
pub func_start: usize, // Address of the current function
5151
pub text_start: usize, // Address of the code section
5252
pub data_start: usize, // Address of the data section
5353
}
5454

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

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

115114
unsafe fn read_encoded_pointer(reader: &mut DwarfReader,
116115
context: &EHContext,
117-
encoding: u8) -> usize {
116+
encoding: u8)
117+
-> usize {
118118
assert!(encoding != DW_EH_PE_omit);
119119

120120
// DW_EH_PE_aligned implies it's an absolute pointer value
121121
if encoding == DW_EH_PE_aligned {
122-
reader.ptr = round_up(reader.ptr as usize,
123-
mem::size_of::<usize>()) as *const u8;
122+
reader.ptr = round_up(reader.ptr as usize, mem::size_of::<usize>()) as *const u8;
124123
return reader.read::<usize>();
125124
}
126125

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

140139
result += match encoding & 0x70 {
141140
DW_EH_PE_absptr => 0,
142141
// relative to address of the encoded value, despite the name
143142
DW_EH_PE_pcrel => reader.ptr as usize,
144-
DW_EH_PE_textrel => { assert!(context.text_start != 0);
145-
context.text_start },
146-
DW_EH_PE_datarel => { assert!(context.data_start != 0);
147-
context.data_start },
148-
DW_EH_PE_funcrel => { assert!(context.func_start != 0);
149-
context.func_start },
150-
_ => panic!()
143+
DW_EH_PE_textrel => {
144+
assert!(context.text_start != 0);
145+
context.text_start
146+
}
147+
DW_EH_PE_datarel => {
148+
assert!(context.data_start != 0);
149+
context.data_start
150+
}
151+
DW_EH_PE_funcrel => {
152+
assert!(context.func_start != 0);
153+
context.func_start
154+
}
155+
_ => panic!(),
151156
};
152157

153158
if encoding & DW_EH_PE_indirect != 0 {

src/libpanic_unwind/dwarf/mod.rs

+11-19
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,22 @@ pub mod eh;
2121
use core::mem;
2222

2323
pub struct DwarfReader {
24-
pub ptr : *const u8
24+
pub ptr: *const u8,
2525
}
2626

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

3030
impl DwarfReader {
31-
32-
pub fn new(ptr : *const u8) -> DwarfReader {
33-
DwarfReader {
34-
ptr : ptr
35-
}
31+
pub fn new(ptr: *const u8) -> DwarfReader {
32+
DwarfReader { ptr: ptr }
3633
}
3734

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

6562
pub unsafe fn read_sleb128(&mut self) -> i64 {
66-
let mut shift : usize = 0;
67-
let mut result : u64 = 0;
68-
let mut byte : u8;
63+
let mut shift: usize = 0;
64+
let mut result: u64 = 0;
65+
let mut byte: u8;
6966
loop {
7067
byte = self.read::<u8>();
7168
result |= ((byte & 0x7F) as u64) << shift;
@@ -84,12 +81,7 @@ impl DwarfReader {
8481

8582
#[test]
8683
fn dwarf_reader() {
87-
let encoded: &[u8] = &[1,
88-
2, 3,
89-
4, 5, 6, 7,
90-
0xE5, 0x8E, 0x26,
91-
0x9B, 0xF1, 0x59,
92-
0xFF, 0xFF];
84+
let encoded: &[u8] = &[1, 2, 3, 4, 5, 6, 7, 0xE5, 0x8E, 0x26, 0x9B, 0xF1, 0x59, 0xFF, 0xFF];
9385

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

0 commit comments

Comments
 (0)