Skip to content

Commit

Permalink
Auto merge of #23031 - Manishearth:rollup, r=Manishearth
Browse files Browse the repository at this point in the history
  • Loading branch information
bors committed Mar 5, 2015
2 parents f0c74f8 + 340d1cc commit b0746ff
Show file tree
Hide file tree
Showing 373 changed files with 1,690 additions and 1,548 deletions.
13 changes: 8 additions & 5 deletions src/doc/intro.md
Expand Up @@ -428,7 +428,8 @@ fn main() {
let guards: Vec<_> = (0..3).map(|i| {
Thread::scoped(move || {
for j in 0..3 { numbers[j] += 1 }
numbers[i] += 1;
println!("numbers[{}] is {}", i, numbers[i]);
});
}).collect();
}
Expand All @@ -437,10 +438,12 @@ fn main() {
It gives us this error:
```text
7:29: 9:10 error: cannot move out of captured outer variable in an `FnMut` closure
7 Thread::scoped(move || {
8 for j in 0..3 { numbers[j] += 1 }
9 });
7:25: 10:6 error: cannot move out of captured outer variable in an `FnMut` closure
7 Thread::scoped(move || {
8 numbers[i] += 1;
9 println!("numbers[{}] is {}", i, numbers[i]);
10 });
error: aborting due to previous error
```
It mentions that "captured outer variable in an `FnMut` closure".
Expand Down
6 changes: 3 additions & 3 deletions src/doc/trpl/compound-data-types.md
Expand Up @@ -6,8 +6,8 @@ strings, but next, let's talk about some more complicated ways of storing data.

## Tuples

The first compound data type we're going to talk about are called *tuples*.
Tuples are an ordered list of a fixed size. Like this:
The first compound data type we're going to talk about is called the *tuple*.
A tuple is an ordered list of fixed size. Like this:

```rust
let x = (1, "hello");
Expand Down Expand Up @@ -229,7 +229,7 @@ enum Character {
```

An `enum` variant can be defined as most normal types. Below are some example
types have been listed which also would be allowed in an `enum`.
types which also would be allowed in an `enum`.

```rust
struct Empty;
Expand Down
80 changes: 42 additions & 38 deletions src/etc/tidy.py
Expand Up @@ -13,7 +13,7 @@
import subprocess
import re
import os
from licenseck import *
from licenseck import check_license
import snapshot

err = 0
Expand All @@ -22,13 +22,8 @@
tab_flag = "ignore-tidy-tab"
linelength_flag = "ignore-tidy-linelength"

# Be careful to support Python 2.4, 2.6, and 3.x here!
config_proc = subprocess.Popen(["git", "config", "core.autocrlf"],
stdout=subprocess.PIPE)
result = config_proc.communicate()[0]

true = "true".encode('utf8')
autocrlf = result.strip() == true if result is not None else False
interesting_files = ['.rs', '.py', '.js', '.sh', '.c', '.h']
uninteresting_files = ['miniz.c', 'jquery', 'rust_android_dummy']


def report_error_name_no(name, no, s):
Expand All @@ -51,6 +46,34 @@ def do_license_check(name, contents):
if not check_license(name, contents):
report_error_name_no(name, 1, "incorrect license")


def update_counts(current_name):
global file_counts
global count_other_linted_files

_, ext = os.path.splitext(current_name)

if ext in interesting_files:
file_counts[ext] += 1
else:
count_other_linted_files += 1


def interesting_file(f):
if any(x in f for x in uninteresting_files):
return False

return any(os.path.splitext(f)[1] == ext for ext in interesting_files)


# Be careful to support Python 2.4, 2.6, and 3.x here!
config_proc = subprocess.Popen(["git", "config", "core.autocrlf"],
stdout=subprocess.PIPE)
result = config_proc.communicate()[0]

true = "true".encode('utf8')
autocrlf = result.strip() == true if result is not None else False

current_name = ""
current_contents = ""
check_tab = True
Expand All @@ -63,28 +86,16 @@ def do_license_check(name, contents):

src_dir = sys.argv[1]

try:
count_lines = 0
count_non_blank_lines = 0
count_lines = 0
count_non_blank_lines = 0
count_other_linted_files = 0

interesting_files = ['.rs', '.py', '.js', '.sh', '.c', '.h']
file_counts = {ext: 0 for ext in interesting_files}

file_counts = {ext: 0 for ext in interesting_files}
file_counts['other'] = 0

def update_counts(current_name):
global file_counts
_, ext = os.path.splitext(current_name)

if ext in file_counts:
file_counts[ext] += 1
else:
file_counts['other'] += 1

all_paths = set()
all_paths = set()

try:
for (dirpath, dirnames, filenames) in os.walk(src_dir):

# Skip some third-party directories
skippable_dirs = {
'src/jemalloc',
Expand All @@ -103,14 +114,6 @@ def update_counts(current_name):
if any(d in dirpath for d in skippable_dirs):
continue

def interesting_file(f):
if "miniz.c" in f \
or "jquery" in f \
or "rust_android_dummy" in f:
return False

return any(os.path.splitext(f)[1] == ext for ext in interesting_files)

file_names = [os.path.join(dirpath, f) for f in filenames
if interesting_file(f)
and not f.endswith("_gen.rs")
Expand Down Expand Up @@ -196,10 +199,11 @@ def interesting_file(f):
report_err("UTF-8 decoding error " + str(e))

print
for ext in file_counts:
print "* linted " + str(file_counts[ext]) + " " + ext + " files"
print "* total lines of code: " + str(count_lines)
print "* total non-blank lines of code: " + str(count_non_blank_lines)
for ext in sorted(file_counts, key=file_counts.get, reverse=True):
print "* linted {} {} files".format(file_counts[ext], ext)
print "* linted {} other files".format(count_other_linted_files)
print "* total lines of code: {}".format(count_lines)
print "* total non-blank lines of code: {}".format(count_non_blank_lines)
print

sys.exit(err)
33 changes: 21 additions & 12 deletions src/etc/unicode.py
Expand Up @@ -84,8 +84,8 @@ def fetch(f):
sys.stderr.write("cannot load %s" % f)
exit(1)

def is_valid_unicode(n):
return 0 <= n <= 0xD7FF or 0xE000 <= n <= 0x10FFFF
def is_surrogate(n):
return 0xD800 <= n <= 0xDFFF

def load_unicode_data(f):
fetch(f)
Expand All @@ -96,19 +96,28 @@ def load_unicode_data(f):
canon_decomp = {}
compat_decomp = {}

udict = {};
range_start = -1;
for line in fileinput.input(f):
fields = line.split(";")
if len(fields) != 15:
data = line.split(';');
if len(data) != 15:
continue
[code, name, gencat, combine, bidi,
decomp, deci, digit, num, mirror,
old, iso, upcase, lowcase, titlecase ] = fields

code_org = code
code = int(code, 16)

if not is_valid_unicode(code):
cp = int(data[0], 16);
if is_surrogate(cp):
continue
if range_start >= 0:
for i in xrange(range_start, cp):
udict[i] = data;
range_start = -1;
if data[1].endswith(", First>"):
range_start = cp;
continue;
udict[cp] = data;

for code in udict:
[code_org, name, gencat, combine, bidi,
decomp, deci, digit, num, mirror,
old, iso, upcase, lowcase, titlecase ] = udict[code];

# generate char to char direct common and simple conversions
# uppercase to lowercase
Expand Down
53 changes: 38 additions & 15 deletions src/grammar/parser-lalr.y
Expand Up @@ -152,6 +152,12 @@ extern char *yytext;
%precedence MOD_SEP
%precedence RARROW ':'
// In where clauses, "for" should have greater precedence when used as
// a higher ranked constraint than when used as the beginning of a
// for_in_type (which is a ty)
%precedence FORTYPE
%precedence FOR
// Binops & unops, and their precedences
%precedence BOX
%precedence BOXPLACE
Expand Down Expand Up @@ -582,6 +588,14 @@ item_impl
{
$$ = mk_node("ItemImplNeg", 7, $1, $3, $5, $7, $8, $10, $11);
}
| maybe_unsafe IMPL generic_params trait_ref FOR DOTDOT '{' '}'
{
$$ = mk_node("ItemImplDefault", 3, $1, $3, $4);
}
| maybe_unsafe IMPL generic_params '!' trait_ref FOR DOTDOT '{' '}'
{
$$ = mk_node("ItemImplDefaultNeg", 3, $1, $3, $4);
}
;

maybe_impl_items
Expand Down Expand Up @@ -769,10 +783,14 @@ where_predicates
;

where_predicate
: lifetime ':' bounds { $$ = mk_node("WherePredicate", 2, $1, $3); }
| ty ':' ty_param_bounds { $$ = mk_node("WherePredicate", 2, $1, $3); }
: maybe_for_lifetimes lifetime ':' bounds { $$ = mk_node("WherePredicate", 3, $1, $2, $4); }
| maybe_for_lifetimes ty ':' ty_param_bounds { $$ = mk_node("WherePredicate", 3, $1, $2, $4); }
;

maybe_for_lifetimes
: FOR '<' lifetimes '>' { $$ = mk_none(); }
| %prec FORTYPE %empty { $$ = mk_none(); }

ty_params
: ty_param { $$ = mk_node("TyParams", 1, $1); }
| ty_params ',' ty_param { $$ = ext_node($1, 1, $3); }
Expand Down Expand Up @@ -1024,7 +1042,8 @@ ty_qualified_path_and_generic_values
}
| ty_qualified_path ',' ty_sums maybe_bindings
{
$$ = mk_node("GenericValues", 3, mk_none(), ext_node(mk_node("TySums", 1, $1), 1, $3), $4); }
$$ = mk_node("GenericValues", 3, mk_none(), mk_node("TySums", 2, $1, $3), $4);
}
;

ty_qualified_path
Expand Down Expand Up @@ -1513,31 +1532,35 @@ nonblock_prefix_expr
;

expr_qualified_path
: '<' ty_sum AS trait_ref '>' MOD_SEP ident
: '<' ty_sum maybe_as_trait_ref '>' MOD_SEP ident
{
$$ = mk_node("ExprQualifiedPath", 3, $2, $4, $7);
$$ = mk_node("ExprQualifiedPath", 3, $2, $3, $6);
}
| '<' ty_sum AS trait_ref '>' MOD_SEP ident generic_args
| '<' ty_sum maybe_as_trait_ref '>' MOD_SEP ident generic_args
{
$$ = mk_node("ExprQualifiedPath", 4, $2, $4, $7, $8);
$$ = mk_node("ExprQualifiedPath", 4, $2, $3, $6, $7);
}
| SHL ty_sum AS trait_ref '>' MOD_SEP ident AS trait_ref '>' MOD_SEP ident
| SHL ty_sum maybe_as_trait_ref '>' MOD_SEP ident maybe_as_trait_ref '>' MOD_SEP ident
{
$$ = mk_node("ExprQualifiedPath", 3, mk_node("ExprQualifiedPath", 3, $2, $4, $7), $9, $12);
$$ = mk_node("ExprQualifiedPath", 3, mk_node("ExprQualifiedPath", 3, $2, $3, $6), $7, $10);
}
| SHL ty_sum AS trait_ref '>' MOD_SEP ident generic_args AS trait_ref '>' MOD_SEP ident
| SHL ty_sum maybe_as_trait_ref '>' MOD_SEP ident generic_args maybe_as_trait_ref '>' MOD_SEP ident
{
$$ = mk_node("ExprQualifiedPath", 3, mk_node("ExprQualifiedPath", 4, $2, $4, $7, $8), $10, $13);
$$ = mk_node("ExprQualifiedPath", 3, mk_node("ExprQualifiedPath", 4, $2, $3, $6, $7), $8, $11);
}
| SHL ty_sum AS trait_ref '>' MOD_SEP ident AS trait_ref '>' MOD_SEP ident generic_args
| SHL ty_sum maybe_as_trait_ref '>' MOD_SEP ident maybe_as_trait_ref '>' MOD_SEP ident generic_args
{
$$ = mk_node("ExprQualifiedPath", 4, mk_node("ExprQualifiedPath", 3, $2, $4, $7), $9, $12, $13);
$$ = mk_node("ExprQualifiedPath", 4, mk_node("ExprQualifiedPath", 3, $2, $3, $6), $7, $10, $11);
}
| SHL ty_sum AS trait_ref '>' MOD_SEP ident generic_args AS trait_ref '>' MOD_SEP ident generic_args
| SHL ty_sum maybe_as_trait_ref '>' MOD_SEP ident generic_args maybe_as_trait_ref '>' MOD_SEP ident generic_args
{
$$ = mk_node("ExprQualifiedPath", 4, mk_node("ExprQualifiedPath", 4, $2, $4, $7, $8), $10, $13, $14);
$$ = mk_node("ExprQualifiedPath", 4, mk_node("ExprQualifiedPath", 4, $2, $3, $6, $7), $8, $11, $12);
}

maybe_as_trait_ref
: AS trait_ref { $$ = $2; }
| %empty { $$ = mk_none(); }
;

lambda_expr
: %prec LAMBDA
Expand Down
2 changes: 1 addition & 1 deletion src/jemalloc
Submodule jemalloc updated 2 files
+6 −0 configure
+5 −0 configure.ac
2 changes: 1 addition & 1 deletion src/liballoc/boxed.rs
Expand Up @@ -42,7 +42,7 @@
//! }
//! ```
//!
//! This will print `Cons(1i32, Box(Cons(2i32, Box(Nil))))`.
//! This will print `Cons(1, Box(Cons(2, Box(Nil))))`.

#![stable(feature = "rust1", since = "1.0.0")]

Expand Down
4 changes: 2 additions & 2 deletions src/liballoc/boxed_test.rs
Expand Up @@ -72,13 +72,13 @@ fn test_show() {
#[test]
fn deref() {
fn homura<T: Deref<Target=i32>>(_: T) { }
homura(Box::new(765i32));
homura(Box::new(765));
}

#[test]
fn raw_sized() {
unsafe {
let x = Box::new(17i32);
let x = Box::new(17);
let p = boxed::into_raw(x);
assert_eq!(17, *p);
*p = 19;
Expand Down

0 comments on commit b0746ff

Please sign in to comment.