Skip to content

Commit 13675a5

Browse files
committed
Auto merge of #31646 - Manishearth:rollup, r=Manishearth
- Successful merges: #31551, #31581, #31614, #31626, #31632, #31642 - Failed merges:
2 parents 17d284b + 39c2d85 commit 13675a5

File tree

6 files changed

+35
-10
lines changed

6 files changed

+35
-10
lines changed

src/doc/book/vectors.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,21 @@ let v = vec![1, 2, 3, 4, 5]; // v: Vec<i32>
1111
```
1212

1313
(Notice that unlike the `println!` macro we’ve used in the past, we use square
14-
brackets `[]` with `vec!` macro. Rust allows you to use either in either situation,
15-
this is just convention.)
14+
brackets `[]` with `vec!` macro. Rust allows you to use either in either
15+
situation, this is just convention.)
1616

1717
There’s an alternate form of `vec!` for repeating an initial value:
1818

1919
```rust
2020
let v = vec![0; 10]; // ten zeroes
2121
```
2222

23+
Vectors store their contents as contiguous arrays of `T` on the heap. This means
24+
that they must be able to know the size of `T` at compile time (that is, how
25+
many bytes are needed to store a `T`?). The size of some things can't be known
26+
at compile time. For these you'll have to store a pointer to that thing:
27+
thankfully, the [`Box`][box] type works perfectly for this.
28+
2329
## Accessing elements
2430

2531
To get the value at a particular index in the vector, we use `[]`s:
@@ -113,6 +119,7 @@ Vectors have many more useful methods, which you can read about in [their
113119
API documentation][vec].
114120

115121
[vec]: ../std/vec/index.html
122+
[box]: ../std/boxed/index.html
116123
[generic]: generics.html
117124
[panic]: concurrency.html#panics
118125
[get]: http://doc.rust-lang.org/std/vec/struct.Vec.html#method.get

src/etc/tidy.py

+18
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@
2424

2525
interesting_files = ['.rs', '.py', '.js', '.sh', '.c', '.h']
2626
uninteresting_files = ['miniz.c', 'jquery', 'rust_android_dummy']
27+
stable_whitelist = {
28+
'src/bootstrap',
29+
'src/build_helper',
30+
'src/libcollectionstest',
31+
'src/libcore',
32+
'src/libstd',
33+
'src/rustc/std_shim',
34+
'src/test'
35+
}
2736

2837

2938
def report_error_name_no(name, no, s):
@@ -93,6 +102,7 @@ def interesting_file(f):
93102
file_counts = {ext: 0 for ext in interesting_files}
94103

95104
all_paths = set()
105+
needs_unstable_attr = set()
96106

97107
try:
98108
for (dirpath, dirnames, filenames) in os.walk(src_dir):
@@ -149,6 +159,9 @@ def interesting_file(f):
149159
else:
150160
if "SNAP " in line:
151161
report_warn("unmatched SNAP line: " + line)
162+
search = re.search(r'^#!\[unstable', line)
163+
if search:
164+
needs_unstable_attr.discard(filename)
152165

153166
if cr_flag in line:
154167
check_cr = False
@@ -181,6 +194,9 @@ def interesting_file(f):
181194
check_cr = True
182195
check_tab = True
183196
check_linelength = True
197+
if all(f not in filename for f in stable_whitelist) and \
198+
re.search(r'src/.*/lib\.rs', filename):
199+
needs_unstable_attr.add(filename)
184200

185201
# Put a reasonable limit on the amount of header data we use for
186202
# the licenseck
@@ -195,6 +211,8 @@ def interesting_file(f):
195211
update_counts(current_name)
196212
assert len(current_contents) > 0
197213
do_license_check(current_name, current_contents)
214+
for f in needs_unstable_attr:
215+
report_error_name_no(f, 1, "requires unstable attribute")
198216

199217
except UnicodeDecodeError as e:
200218
report_err("UTF-8 decoding error " + str(e))

src/libcollections/vec.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
//! A growable list type with heap-allocated contents, written `Vec<T>` but
12-
//! pronounced 'vector.'
11+
//! A contiguous growable array type with heap-allocated contents, written
12+
//! `Vec<T>` but pronounced 'vector.'
1313
//!
1414
//! Vectors have `O(1)` indexing, amortized `O(1)` push (to the end) and
1515
//! `O(1)` pop (from the end).
@@ -78,7 +78,7 @@ use borrow::{Cow, IntoCow};
7878

7979
use super::range::RangeArgument;
8080

81-
/// A growable list type, written `Vec<T>` but pronounced 'vector.'
81+
/// A contiguous growable array type, written `Vec<T>` but pronounced 'vector.'
8282
///
8383
/// # Examples
8484
///

src/librustc/session/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
510510
link_args: Option<Vec<String>> = (None, parse_opt_list,
511511
"extra arguments to pass to the linker (space separated)"),
512512
link_dead_code: bool = (false, parse_bool,
513-
"let the linker strip dead coded (turning it on can be used for code coverage)"),
513+
"don't let linker strip dead code (turning it on can be used for code coverage)"),
514514
lto: bool = (false, parse_bool,
515515
"perform LLVM link-time optimizations"),
516516
target_cpu: Option<String> = (None, parse_opt_string,

src/librustdoc/html/layout.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ r##"<!DOCTYPE html>
122122
123123
<p>
124124
Search functions by type signature (e.g.
125-
<code>vec -> usize</code>)
125+
<code>vec -> usize</code> or <code>* -> vec</code>)
126126
</p>
127127
</div>
128128
</div>

src/librustdoc/html/static/main.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@
280280
var parts = val.split("->").map(trimmer);
281281
var input = parts[0];
282282
// sort inputs so that order does not matter
283-
var inputs = input.split(",").map(trimmer).sort();
283+
var inputs = input.split(",").map(trimmer).sort().toString();
284284
var output = parts[1];
285285

286286
for (var i = 0; i < nSearchWords; ++i) {
@@ -296,8 +296,8 @@
296296

297297
// allow searching for void (no output) functions as well
298298
var typeOutput = type.output ? type.output.name : "";
299-
if (inputs.toString() === typeInputs.toString() &&
300-
output == typeOutput) {
299+
if ((inputs === "*" || inputs === typeInputs.toString()) &&
300+
(output === "*" || output == typeOutput)) {
301301
results.push({id: i, index: -1, dontValidate: true});
302302
}
303303
}

0 commit comments

Comments
 (0)