Skip to content

Commit

Permalink
Auto merge of #31646 - Manishearth:rollup, r=Manishearth
Browse files Browse the repository at this point in the history
- Successful merges: #31551, #31581, #31614, #31626, #31632, #31642
- Failed merges:
  • Loading branch information
bors committed Feb 15, 2016
2 parents 17d284b + 8bb217b commit 81c7024
Show file tree
Hide file tree
Showing 14 changed files with 116 additions and 28 deletions.
3 changes: 2 additions & 1 deletion mk/tests.mk
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,8 @@ $(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
$(3) \
"$$(LLVM_LIBDIR_RUSTFLAGS_$(3))" \
"$$(LLVM_ALL_COMPONENTS_$(3))" \
"$$(LLVM_CXXFLAGS_$(3))"
"$$(LLVM_CXXFLAGS_$(3))" \
"$$(CXX_$(3))"
@touch -r [email protected]_time $$@ && rm [email protected]_time
else
# FIXME #11094 - The above rule doesn't work right for multiple targets
Expand Down
11 changes: 9 additions & 2 deletions src/doc/book/vectors.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,21 @@ let v = vec![1, 2, 3, 4, 5]; // v: Vec<i32>
```

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

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

```rust
let v = vec![0; 10]; // ten zeroes
```

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

## Accessing elements

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

[vec]: ../std/vec/index.html
[box]: ../std/boxed/index.html
[generic]: generics.html
[panic]: concurrency.html#panics
[get]: http://doc.rust-lang.org/std/vec/struct.Vec.html#method.get
Expand Down
1 change: 1 addition & 0 deletions src/etc/maketest.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def convert_path_spec(name, value):
putenv('RUSTFLAGS', sys.argv[15])
putenv('LLVM_COMPONENTS', sys.argv[16])
putenv('LLVM_CXXFLAGS', sys.argv[17])
putenv('CXX', sys.argv[18])
putenv('PYTHON', sys.executable)
os.putenv('TARGET', target_triple)

Expand Down
18 changes: 18 additions & 0 deletions src/etc/tidy.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@

interesting_files = ['.rs', '.py', '.js', '.sh', '.c', '.h']
uninteresting_files = ['miniz.c', 'jquery', 'rust_android_dummy']
stable_whitelist = {
'src/bootstrap',
'src/build_helper',
'src/libcollectionstest',
'src/libcore',
'src/libstd',
'src/rustc/std_shim',
'src/test'
}


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

all_paths = set()
needs_unstable_attr = set()

try:
for (dirpath, dirnames, filenames) in os.walk(src_dir):
Expand Down Expand Up @@ -149,6 +159,9 @@ def interesting_file(f):
else:
if "SNAP " in line:
report_warn("unmatched SNAP line: " + line)
search = re.search(r'^#!\[unstable', line)
if search:
needs_unstable_attr.discard(filename)

if cr_flag in line:
check_cr = False
Expand Down Expand Up @@ -181,6 +194,9 @@ def interesting_file(f):
check_cr = True
check_tab = True
check_linelength = True
if all(f not in filename for f in stable_whitelist) and \
re.search(r'src/.*/lib\.rs', filename):
needs_unstable_attr.add(filename)

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

except UnicodeDecodeError as e:
report_err("UTF-8 decoding error " + str(e))
Expand Down
6 changes: 3 additions & 3 deletions src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

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

use super::range::RangeArgument;

/// A growable list type, written `Vec<T>` but pronounced 'vector.'
/// A contiguous growable array type, written `Vec<T>` but pronounced 'vector.'
///
/// # Examples
///
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
link_args: Option<Vec<String>> = (None, parse_opt_list,
"extra arguments to pass to the linker (space separated)"),
link_dead_code: bool = (false, parse_bool,
"let the linker strip dead coded (turning it on can be used for code coverage)"),
"don't let linker strip dead code (turning it on can be used for code coverage)"),
lto: bool = (false, parse_bool,
"perform LLVM link-time optimizations"),
target_cpu: Option<String> = (None, parse_opt_string,
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ r##"<!DOCTYPE html>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code>)
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@
var parts = val.split("->").map(trimmer);
var input = parts[0];
// sort inputs so that order does not matter
var inputs = input.split(",").map(trimmer).sort();
var inputs = input.split(",").map(trimmer).sort().toString();
var output = parts[1];

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

// allow searching for void (no output) functions as well
var typeOutput = type.output ? type.output.name : "";
if (inputs.toString() === typeInputs.toString() &&
output == typeOutput) {
if ((inputs === "*" || inputs === typeInputs.toString()) &&
(output === "*" || output == typeOutput)) {
results.push({id: i, index: -1, dontValidate: true});
}
}
Expand Down
14 changes: 0 additions & 14 deletions src/test/run-make/llvm-module-pass/Makefile

This file was deleted.

17 changes: 17 additions & 0 deletions src/test/run-make/llvm-pass/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
-include ../tools.mk

# Windows doesn't correctly handle include statements with escaping paths,
# so this test will not get run on Windows.
ifdef IS_WINDOWS
all:
else
all: $(call NATIVE_STATICLIB,llvm-function-pass) $(call NATIVE_STATICLIB,llvm-module-pass)
$(RUSTC) plugin.rs -C prefer-dynamic
$(RUSTC) main.rs

$(TMPDIR)/libllvm-function-pass.o:
$(CXX) $(CFLAGS) $(LLVM_CXXFLAGS) -c llvm-function-pass.so.cc -o $(TMPDIR)/libllvm-function-pass.o

$(TMPDIR)/libllvm-module-pass.o:
$(CXX) $(CFLAGS) $(LLVM_CXXFLAGS) -c llvm-module-pass.so.cc -o $(TMPDIR)/libllvm-module-pass.o
endif
56 changes: 56 additions & 0 deletions src/test/run-make/llvm-pass/llvm-function-pass.so.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include "llvm/Pass.h"
#include "llvm/IR/Function.h"

using namespace llvm;

namespace {

class TestLLVMPass : public FunctionPass {

public:

static char ID;
TestLLVMPass() : FunctionPass(ID) { }

bool runOnFunction(Function &F) override;

const char *getPassName() const override {
return "Some LLVM pass";
}

};

}

bool TestLLVMPass::runOnFunction(Function &F) {
// A couple examples of operations that previously caused segmentation faults
// https://github.com/rust-lang/rust/issues/31067

for (auto N = F.begin(); N != F.end(); ++N) {
/* code */
}

LLVMContext &C = F.getContext();
IntegerType *Int8Ty = IntegerType::getInt8Ty(C);
PointerType::get(Int8Ty, 0);
return true;
}

char TestLLVMPass::ID = 0;

static RegisterPass<TestLLVMPass> RegisterAFLPass(
"some-llvm-function-pass", "Some LLVM pass");
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ bool TestLLVMPass::runOnModule(Module &M) {
char TestLLVMPass::ID = 0;

static RegisterPass<TestLLVMPass> RegisterAFLPass(
"some-llvm-pass", "Some LLVM pass");
"some-llvm-module-pass", "Some LLVM pass");
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
extern crate rustc;
extern crate rustc_plugin;

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

use rustc_plugin::registry::Registry;

#[plugin_registrar]
pub fn plugin_registrar(reg: &mut Registry) {
reg.register_llvm_pass("some-llvm-pass");
reg.register_llvm_pass("some-llvm-function-pass");
reg.register_llvm_pass("some-llvm-module-pass");
}

0 comments on commit 81c7024

Please sign in to comment.