Skip to content

Commit 81c7024

Browse files
committed
Auto merge of #31646 - Manishearth:rollup, r=Manishearth
- Successful merges: #31551, #31581, #31614, #31626, #31632, #31642 - Failed merges:
2 parents 17d284b + 8bb217b commit 81c7024

File tree

14 files changed

+116
-28
lines changed

14 files changed

+116
-28
lines changed

mk/tests.mk

+2-1
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,8 @@ $(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
10721072
$(3) \
10731073
"$$(LLVM_LIBDIR_RUSTFLAGS_$(3))" \
10741074
"$$(LLVM_ALL_COMPONENTS_$(3))" \
1075-
"$$(LLVM_CXXFLAGS_$(3))"
1075+
"$$(LLVM_CXXFLAGS_$(3))" \
1076+
"$$(CXX_$(3))"
10761077
@touch -r [email protected]_time $$@ && rm [email protected]_time
10771078
else
10781079
# FIXME #11094 - The above rule doesn't work right for multiple targets

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/maketest.py

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def convert_path_spec(name, value):
5757
putenv('RUSTFLAGS', sys.argv[15])
5858
putenv('LLVM_COMPONENTS', sys.argv[16])
5959
putenv('LLVM_CXXFLAGS', sys.argv[17])
60+
putenv('CXX', sys.argv[18])
6061
putenv('PYTHON', sys.executable)
6162
os.putenv('TARGET', target_triple)
6263

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
}

src/test/run-make/llvm-module-pass/Makefile

-14
This file was deleted.

src/test/run-make/llvm-pass/Makefile

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
-include ../tools.mk
2+
3+
# Windows doesn't correctly handle include statements with escaping paths,
4+
# so this test will not get run on Windows.
5+
ifdef IS_WINDOWS
6+
all:
7+
else
8+
all: $(call NATIVE_STATICLIB,llvm-function-pass) $(call NATIVE_STATICLIB,llvm-module-pass)
9+
$(RUSTC) plugin.rs -C prefer-dynamic
10+
$(RUSTC) main.rs
11+
12+
$(TMPDIR)/libllvm-function-pass.o:
13+
$(CXX) $(CFLAGS) $(LLVM_CXXFLAGS) -c llvm-function-pass.so.cc -o $(TMPDIR)/libllvm-function-pass.o
14+
15+
$(TMPDIR)/libllvm-module-pass.o:
16+
$(CXX) $(CFLAGS) $(LLVM_CXXFLAGS) -c llvm-module-pass.so.cc -o $(TMPDIR)/libllvm-module-pass.o
17+
endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Copyright 2016 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+
#include <stdio.h>
12+
#include <stdlib.h>
13+
#include <unistd.h>
14+
15+
#include "llvm/Pass.h"
16+
#include "llvm/IR/Function.h"
17+
18+
using namespace llvm;
19+
20+
namespace {
21+
22+
class TestLLVMPass : public FunctionPass {
23+
24+
public:
25+
26+
static char ID;
27+
TestLLVMPass() : FunctionPass(ID) { }
28+
29+
bool runOnFunction(Function &F) override;
30+
31+
const char *getPassName() const override {
32+
return "Some LLVM pass";
33+
}
34+
35+
};
36+
37+
}
38+
39+
bool TestLLVMPass::runOnFunction(Function &F) {
40+
// A couple examples of operations that previously caused segmentation faults
41+
// https://github.com/rust-lang/rust/issues/31067
42+
43+
for (auto N = F.begin(); N != F.end(); ++N) {
44+
/* code */
45+
}
46+
47+
LLVMContext &C = F.getContext();
48+
IntegerType *Int8Ty = IntegerType::getInt8Ty(C);
49+
PointerType::get(Int8Ty, 0);
50+
return true;
51+
}
52+
53+
char TestLLVMPass::ID = 0;
54+
55+
static RegisterPass<TestLLVMPass> RegisterAFLPass(
56+
"some-llvm-function-pass", "Some LLVM pass");

src/test/run-make/llvm-module-pass/llvm-pass.so.cc src/test/run-make/llvm-pass/llvm-module-pass.so.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ bool TestLLVMPass::runOnModule(Module &M) {
5252
char TestLLVMPass::ID = 0;
5353

5454
static RegisterPass<TestLLVMPass> RegisterAFLPass(
55-
"some-llvm-pass", "Some LLVM pass");
55+
"some-llvm-module-pass", "Some LLVM pass");
File renamed without changes.

src/test/run-make/llvm-module-pass/plugin.rs src/test/run-make/llvm-pass/plugin.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@
1515
extern crate rustc;
1616
extern crate rustc_plugin;
1717

18-
#[link(name = "llvm-pass", kind = "static")]
18+
#[link(name = "llvm-function-pass", kind = "static")]
19+
#[link(name = "llvm-module-pass", kind = "static")]
1920
extern {}
2021

2122
use rustc_plugin::registry::Registry;
2223

2324
#[plugin_registrar]
2425
pub fn plugin_registrar(reg: &mut Registry) {
25-
reg.register_llvm_pass("some-llvm-pass");
26+
reg.register_llvm_pass("some-llvm-function-pass");
27+
reg.register_llvm_pass("some-llvm-module-pass");
2628
}

0 commit comments

Comments
 (0)