Skip to content

Commit 8ce4fd4

Browse files
committed
---
yaml --- r: 275173 b: refs/heads/stable c: 9d3bce3 h: refs/heads/master i: 275171: 618ef65
1 parent 74c4175 commit 8ce4fd4

File tree

46 files changed

+454
-538
lines changed

Some content is hidden

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

46 files changed

+454
-538
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: c0221c8897db309a79990367476177b1230bb264
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: 27990edb5296ff2b27e2ff9253a66ee266a0ce72
32+
refs/heads/stable: 9d3bce38b4e7c2fe706d8228d720222ec2781e30
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/src/doc/reference.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3564,9 +3564,8 @@ Each instance of a trait object includes:
35643564
each method of `SomeTrait` that `T` implements, a pointer to `T`'s
35653565
implementation (i.e. a function pointer).
35663566

3567-
The purpose of trait objects is to permit "late binding" of methods. Calling a
3568-
method on a trait object results in virtual dispatch at runtime: that is, a
3569-
function pointer is loaded from the trait object vtable and invoked indirectly.
3567+
The purpose of trait objects is to permit "late binding" of methods. A call to
3568+
a method on a trait object is only resolved to a vtable entry at compile time.
35703569
The actual implementation for each vtable entry can vary on an object-by-object
35713570
basis.
35723571

branches/stable/src/etc/licenseck.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
# except according to those terms.
1010

1111
import re
12-
import os
1312

1413
license_re = re.compile(
1514
u"""(#|//) Copyright .* The Rust Project Developers. See the COPYRIGHT
@@ -41,9 +40,8 @@
4140
]
4241

4342
def check_license(name, contents):
44-
name = os.path.normpath(name)
4543
# Whitelist check
46-
if any(name.endswith(os.path.normpath(e)) for e in exceptions):
44+
if any(name.endswith(e) for e in exceptions):
4745
return True
4846

4947
# Xfail check

branches/stable/src/etc/tidy.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ def interesting_file(f):
122122
'src/liblibc',
123123
}
124124

125-
dirpath = os.path.normpath(dirpath)
126-
if any(os.path.normpath(d) in dirpath for d in skippable_dirs):
125+
if any(d in dirpath for d in skippable_dirs):
127126
continue
128127

129128
file_names = [os.path.join(dirpath, f) for f in filenames

branches/stable/src/libcollections/borrow.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,12 @@ pub enum Cow<'a, B: ?Sized + 'a>
9595
{
9696
/// Borrowed data.
9797
#[stable(feature = "rust1", since = "1.0.0")]
98-
Borrowed(#[stable(feature = "rust1", since = "1.0.0")] &'a B),
98+
Borrowed(#[cfg_attr(not(stage0), stable(feature = "rust1", since = "1.0.0"))] &'a B),
9999

100100
/// Owned data.
101101
#[stable(feature = "rust1", since = "1.0.0")]
102102
Owned(
103-
#[stable(feature = "rust1", since = "1.0.0")] <B as ToOwned>::Owned
103+
#[cfg_attr(not(stage0), stable(feature = "rust1", since = "1.0.0"))] <B as ToOwned>::Owned
104104
),
105105
}
106106

branches/stable/src/libcollections/btree/map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,13 +238,13 @@ pub enum Entry<'a, K: 'a, V: 'a> {
238238
/// A vacant Entry
239239
#[stable(feature = "rust1", since = "1.0.0")]
240240
Vacant(
241-
#[stable(feature = "rust1", since = "1.0.0")] VacantEntry<'a, K, V>
241+
#[cfg_attr(not(stage0), stable(feature = "rust1", since = "1.0.0"))] VacantEntry<'a, K, V>
242242
),
243243

244244
/// An occupied Entry
245245
#[stable(feature = "rust1", since = "1.0.0")]
246246
Occupied(
247-
#[stable(feature = "rust1", since = "1.0.0")] OccupiedEntry<'a, K, V>
247+
#[cfg_attr(not(stage0), stable(feature = "rust1", since = "1.0.0"))] OccupiedEntry<'a, K, V>
248248
),
249249
}
250250

branches/stable/src/libcollections/slice.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ impl<T> [T] {
407407
}
408408

409409
/// Returns an iterator over `size` elements of the slice at a
410-
/// time. The chunks are slices and do not overlap. If `size` does not divide the
410+
/// time. The chunks do not overlap. If `size` does not divide the
411411
/// length of the slice, then the last chunk will not have length
412412
/// `size`.
413413
///
@@ -433,7 +433,7 @@ impl<T> [T] {
433433
}
434434

435435
/// Returns an iterator over `chunk_size` elements of the slice at a time.
436-
/// The chunks are mutable slices, and do not overlap. If `chunk_size` does
436+
/// The chunks are mutable and do not overlap. If `chunk_size` does
437437
/// not divide the length of the slice, then the last chunk will not
438438
/// have length `chunk_size`.
439439
///

branches/stable/src/libcore/intrinsics.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,5 +586,8 @@ extern "rust-intrinsic" {
586586
/// platforms this is a `*mut *mut T` which is filled in by the compiler and
587587
/// on MSVC it's `*mut [usize; 2]`. For more information see the compiler's
588588
/// source as well as std's catch implementation.
589+
#[cfg(not(stage0))]
589590
pub fn try(f: fn(*mut u8), data: *mut u8, local_ptr: *mut u8) -> i32;
591+
#[cfg(stage0)]
592+
pub fn try(f: fn(*mut u8), data: *mut u8) -> *mut u8;
590593
}

branches/stable/src/libcore/option.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ pub enum Option<T> {
169169
None,
170170
/// Some value `T`
171171
#[stable(feature = "rust1", since = "1.0.0")]
172-
Some(#[stable(feature = "rust1", since = "1.0.0")] T)
172+
Some(#[cfg_attr(not(stage0), stable(feature = "rust1", since = "1.0.0"))] T)
173173
}
174174

175175
/////////////////////////////////////////////////////////////////////////////

branches/stable/src/libcore/result.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,11 @@ use option::Option::{self, None, Some};
250250
pub enum Result<T, E> {
251251
/// Contains the success value
252252
#[stable(feature = "rust1", since = "1.0.0")]
253-
Ok(#[stable(feature = "rust1", since = "1.0.0")] T),
253+
Ok(#[cfg_attr(not(stage0), stable(feature = "rust1", since = "1.0.0"))] T),
254254

255255
/// Contains the error value
256256
#[stable(feature = "rust1", since = "1.0.0")]
257-
Err(#[stable(feature = "rust1", since = "1.0.0")] E)
257+
Err(#[cfg_attr(not(stage0), stable(feature = "rust1", since = "1.0.0"))] E)
258258
}
259259

260260
/////////////////////////////////////////////////////////////////////////////

branches/stable/src/liblibc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Subproject commit 16f1c190afbc7605ed50a40f802189e436de68f6
1+
Subproject commit 1b1eea2cdd77c63d73ba0b09b905a91910d1c992

branches/stable/src/librustc_data_structures/bitvec.rs

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -50,45 +50,6 @@ impl BitVector {
5050
let extra_words = self.data.len() - num_words;
5151
self.data.extend((0..extra_words).map(|_| 0));
5252
}
53-
54-
/// Iterates over indexes of set bits in a sorted order
55-
pub fn iter<'a>(&'a self) -> BitVectorIter<'a> {
56-
BitVectorIter {
57-
iter: self.data.iter(),
58-
current: 0,
59-
idx: 0
60-
}
61-
}
62-
}
63-
64-
pub struct BitVectorIter<'a> {
65-
iter: ::std::slice::Iter<'a, u64>,
66-
current: u64,
67-
idx: usize
68-
}
69-
70-
impl<'a> Iterator for BitVectorIter<'a> {
71-
type Item = usize;
72-
fn next(&mut self) -> Option<usize> {
73-
while self.current == 0 {
74-
self.current = if let Some(&i) = self.iter.next() {
75-
if i == 0 {
76-
self.idx += 64;
77-
continue;
78-
} else {
79-
self.idx = u64s(self.idx) * 64;
80-
i
81-
}
82-
} else {
83-
return None;
84-
}
85-
}
86-
let offset = self.current.trailing_zeros() as usize;
87-
self.current >>= offset;
88-
self.current >>= 1; // shift otherwise overflows for 0b1000_0000_…_0000
89-
self.idx += offset + 1;
90-
return Some(self.idx - 1);
91-
}
9253
}
9354

9455
/// A "bit matrix" is basically a square matrix of booleans
@@ -192,46 +153,6 @@ fn word_mask(index: usize) -> (usize, u64) {
192153
(word, mask)
193154
}
194155

195-
#[test]
196-
fn bitvec_iter_works() {
197-
let mut bitvec = BitVector::new(100);
198-
bitvec.insert(1);
199-
bitvec.insert(10);
200-
bitvec.insert(19);
201-
bitvec.insert(62);
202-
bitvec.insert(63);
203-
bitvec.insert(64);
204-
bitvec.insert(65);
205-
bitvec.insert(66);
206-
bitvec.insert(99);
207-
assert_eq!(bitvec.iter().collect::<Vec<_>>(), [1, 10, 19, 62, 63, 64, 65, 66, 99]);
208-
}
209-
210-
#[test]
211-
fn bitvec_iter_works_2() {
212-
let mut bitvec = BitVector::new(300);
213-
bitvec.insert(1);
214-
bitvec.insert(10);
215-
bitvec.insert(19);
216-
bitvec.insert(62);
217-
bitvec.insert(66);
218-
bitvec.insert(99);
219-
bitvec.insert(299);
220-
assert_eq!(bitvec.iter().collect::<Vec<_>>(), [1, 10, 19, 62, 66, 99, 299]);
221-
222-
}
223-
224-
#[test]
225-
fn bitvec_iter_works_3() {
226-
let mut bitvec = BitVector::new(319);
227-
bitvec.insert(0);
228-
bitvec.insert(127);
229-
bitvec.insert(191);
230-
bitvec.insert(255);
231-
bitvec.insert(319);
232-
assert_eq!(bitvec.iter().collect::<Vec<_>>(), [0, 127, 191, 255, 319]);
233-
}
234-
235156
#[test]
236157
fn union_two_vecs() {
237158
let mut vec1 = BitVector::new(65);

branches/stable/src/librustc_mir/transform/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ pub mod simplify_cfg;
1313
pub mod erase_regions;
1414
pub mod no_landing_pads;
1515
pub mod type_check;
16+
mod util;

branches/stable/src/librustc_mir/transform/simplify_cfg.rs

Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use rustc_data_structures::bitvec::BitVector;
1211
use rustc::middle::const_eval::ConstVal;
1312
use rustc::middle::infer;
1413
use rustc::mir::repr::*;
14+
use transform::util;
1515
use rustc::mir::transform::MirPass;
1616

1717
pub struct SimplifyCfg;
@@ -22,21 +22,23 @@ impl SimplifyCfg {
2222
}
2323

2424
fn remove_dead_blocks(&self, mir: &mut Mir) {
25-
let mut seen = BitVector::new(mir.basic_blocks.len());
25+
let mut seen = vec![false; mir.basic_blocks.len()];
26+
2627
// These blocks are always required.
27-
seen.insert(START_BLOCK.index());
28-
seen.insert(END_BLOCK.index());
28+
seen[START_BLOCK.index()] = true;
29+
seen[END_BLOCK.index()] = true;
2930

30-
let mut worklist = Vec::with_capacity(4);
31-
worklist.push(START_BLOCK);
31+
let mut worklist = vec![START_BLOCK];
3232
while let Some(bb) = worklist.pop() {
3333
for succ in mir.basic_block_data(bb).terminator().successors().iter() {
34-
if seen.insert(succ.index()) {
34+
if !seen[succ.index()] {
35+
seen[succ.index()] = true;
3536
worklist.push(*succ);
3637
}
3738
}
3839
}
39-
retain_basic_blocks(mir, &seen);
40+
41+
util::retain_basic_blocks(mir, &seen);
4042
}
4143

4244
fn remove_goto_chains(&self, mir: &mut Mir) -> bool {
@@ -88,12 +90,12 @@ impl SimplifyCfg {
8890
for bb in mir.all_basic_blocks() {
8991
let basic_block = mir.basic_block_data_mut(bb);
9092
let mut terminator = basic_block.terminator_mut();
93+
9194
*terminator = match *terminator {
9295
Terminator::If { ref targets, .. } if targets.0 == targets.1 => {
9396
changed = true;
9497
Terminator::Goto { target: targets.0 }
9598
}
96-
9799
Terminator::If { ref targets, cond: Operand::Constant(Constant {
98100
literal: Literal::Value {
99101
value: ConstVal::Bool(cond)
@@ -106,7 +108,6 @@ impl SimplifyCfg {
106108
Terminator::Goto { target: targets.1 }
107109
}
108110
}
109-
110111
Terminator::SwitchInt { ref targets, .. } if targets.len() == 1 => {
111112
Terminator::Goto { target: targets[0] }
112113
}
@@ -130,27 +131,3 @@ impl MirPass for SimplifyCfg {
130131
mir.basic_blocks.shrink_to_fit();
131132
}
132133
}
133-
134-
/// Mass removal of basic blocks to keep the ID-remapping cheap.
135-
fn retain_basic_blocks(mir: &mut Mir, keep: &BitVector) {
136-
let num_blocks = mir.basic_blocks.len();
137-
138-
let mut replacements: Vec<_> = (0..num_blocks).map(BasicBlock::new).collect();
139-
let mut used_blocks = 0;
140-
for alive_index in keep.iter() {
141-
replacements[alive_index] = BasicBlock::new(used_blocks);
142-
if alive_index != used_blocks {
143-
// Swap the next alive block data with the current available slot. Since alive_index is
144-
// non-decreasing this is a valid operation.
145-
mir.basic_blocks.swap(alive_index, used_blocks);
146-
}
147-
used_blocks += 1;
148-
}
149-
mir.basic_blocks.truncate(used_blocks);
150-
151-
for bb in mir.all_basic_blocks() {
152-
for target in mir.basic_block_data_mut(bb).terminator_mut().successors_mut() {
153-
*target = replacements[target.index()];
154-
}
155-
}
156-
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
use rustc::mir::repr::*;
12+
13+
/// Update basic block ids in all terminators using the given replacements,
14+
/// useful e.g. after removal of several basic blocks to update all terminators
15+
/// in a single pass
16+
pub fn update_basic_block_ids(mir: &mut Mir, replacements: &[BasicBlock]) {
17+
for bb in mir.all_basic_blocks() {
18+
for target in mir.basic_block_data_mut(bb).terminator_mut().successors_mut() {
19+
*target = replacements[target.index()];
20+
}
21+
}
22+
}
23+
24+
/// Mass removal of basic blocks to keep the ID-remapping cheap.
25+
pub fn retain_basic_blocks(mir: &mut Mir, keep: &[bool]) {
26+
let num_blocks = mir.basic_blocks.len();
27+
28+
// Check that we have a usage flag for every block
29+
assert_eq!(num_blocks, keep.len());
30+
31+
let first_dead = match keep.iter().position(|&k| !k) {
32+
None => return,
33+
Some(first_dead) => first_dead,
34+
};
35+
36+
// `replacements` maps the old block ids to the new ones
37+
let mut replacements: Vec<_> = (0..num_blocks).map(BasicBlock::new).collect();
38+
39+
let mut dead = 0;
40+
for i in first_dead..num_blocks {
41+
if keep[i] {
42+
replacements[i] = BasicBlock::new(i - dead);
43+
mir.basic_blocks.swap(i, i - dead);
44+
} else {
45+
dead += 1;
46+
}
47+
}
48+
mir.basic_blocks.truncate(num_blocks - dead);
49+
50+
update_basic_block_ids(mir, &replacements);
51+
}

0 commit comments

Comments
 (0)