Skip to content

Commit 63d0ea2

Browse files
committed
Auto merge of #23031 - Manishearth:rollup, r=Manishearth
2 parents 3b3bb0e + 8697be6 commit 63d0ea2

File tree

43 files changed

+632
-415
lines changed

Some content is hidden

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

43 files changed

+632
-415
lines changed

mk/tests.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ TEST_SREQ$(1)_T_$(2)_H_$(3) = \
590590

591591
# The tests select when to use debug configuration on their own;
592592
# remove directive, if present, from CFG_RUSTC_FLAGS (issue #7898).
593-
CTEST_RUSTC_FLAGS := $$(subst --cfg ndebug,,$$(CFG_RUSTC_FLAGS))
593+
CTEST_RUSTC_FLAGS := $$(subst -C debug-assertions,,$$(CFG_RUSTC_FLAGS))
594594

595595
# The tests cannot be optimized while the rest of the compiler is optimized, so
596596
# filter out the optimization (if any) from rustc and then figure out if we need

src/etc/tidy.py

+42-38
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import subprocess
1414
import re
1515
import os
16-
from licenseck import *
16+
from licenseck import check_license
1717
import snapshot
1818

1919
err = 0
@@ -22,13 +22,8 @@
2222
tab_flag = "ignore-tidy-tab"
2323
linelength_flag = "ignore-tidy-linelength"
2424

25-
# Be careful to support Python 2.4, 2.6, and 3.x here!
26-
config_proc = subprocess.Popen(["git", "config", "core.autocrlf"],
27-
stdout=subprocess.PIPE)
28-
result = config_proc.communicate()[0]
29-
30-
true = "true".encode('utf8')
31-
autocrlf = result.strip() == true if result is not None else False
25+
interesting_files = ['.rs', '.py', '.js', '.sh', '.c', '.h']
26+
uninteresting_files = ['miniz.c', 'jquery', 'rust_android_dummy']
3227

3328

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

49+
50+
def update_counts(current_name):
51+
global file_counts
52+
global count_other_linted_files
53+
54+
_, ext = os.path.splitext(current_name)
55+
56+
if ext in interesting_files:
57+
file_counts[ext] += 1
58+
else:
59+
count_other_linted_files += 1
60+
61+
62+
def interesting_file(f):
63+
if any(x in f for x in uninteresting_files):
64+
return False
65+
66+
return any(os.path.splitext(f)[1] == ext for ext in interesting_files)
67+
68+
69+
# Be careful to support Python 2.4, 2.6, and 3.x here!
70+
config_proc = subprocess.Popen(["git", "config", "core.autocrlf"],
71+
stdout=subprocess.PIPE)
72+
result = config_proc.communicate()[0]
73+
74+
true = "true".encode('utf8')
75+
autocrlf = result.strip() == true if result is not None else False
76+
5477
current_name = ""
5578
current_contents = ""
5679
check_tab = True
@@ -63,28 +86,16 @@ def do_license_check(name, contents):
6386

6487
src_dir = sys.argv[1]
6588

66-
try:
67-
count_lines = 0
68-
count_non_blank_lines = 0
89+
count_lines = 0
90+
count_non_blank_lines = 0
91+
count_other_linted_files = 0
6992

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

72-
file_counts = {ext: 0 for ext in interesting_files}
73-
file_counts['other'] = 0
74-
75-
def update_counts(current_name):
76-
global file_counts
77-
_, ext = os.path.splitext(current_name)
78-
79-
if ext in file_counts:
80-
file_counts[ext] += 1
81-
else:
82-
file_counts['other'] += 1
83-
84-
all_paths = set()
95+
all_paths = set()
8596

97+
try:
8698
for (dirpath, dirnames, filenames) in os.walk(src_dir):
87-
8899
# Skip some third-party directories
89100
skippable_dirs = {
90101
'src/jemalloc',
@@ -103,14 +114,6 @@ def update_counts(current_name):
103114
if any(d in dirpath for d in skippable_dirs):
104115
continue
105116

106-
def interesting_file(f):
107-
if "miniz.c" in f \
108-
or "jquery" in f \
109-
or "rust_android_dummy" in f:
110-
return False
111-
112-
return any(os.path.splitext(f)[1] == ext for ext in interesting_files)
113-
114117
file_names = [os.path.join(dirpath, f) for f in filenames
115118
if interesting_file(f)
116119
and not f.endswith("_gen.rs")
@@ -196,10 +199,11 @@ def interesting_file(f):
196199
report_err("UTF-8 decoding error " + str(e))
197200

198201
print
199-
for ext in file_counts:
200-
print "* linted " + str(file_counts[ext]) + " " + ext + " files"
201-
print "* total lines of code: " + str(count_lines)
202-
print "* total non-blank lines of code: " + str(count_non_blank_lines)
202+
for ext in sorted(file_counts, key=file_counts.get, reverse=True):
203+
print "* linted {} {} files".format(file_counts[ext], ext)
204+
print "* linted {} other files".format(count_other_linted_files)
205+
print "* total lines of code: {}".format(count_lines)
206+
print "* total non-blank lines of code: {}".format(count_non_blank_lines)
203207
print
204208

205209
sys.exit(err)

src/etc/unicode.py

+21-12
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ def fetch(f):
8484
sys.stderr.write("cannot load %s" % f)
8585
exit(1)
8686

87-
def is_valid_unicode(n):
88-
return 0 <= n <= 0xD7FF or 0xE000 <= n <= 0x10FFFF
87+
def is_surrogate(n):
88+
return 0xD800 <= n <= 0xDFFF
8989

9090
def load_unicode_data(f):
9191
fetch(f)
@@ -96,19 +96,28 @@ def load_unicode_data(f):
9696
canon_decomp = {}
9797
compat_decomp = {}
9898

99+
udict = {};
100+
range_start = -1;
99101
for line in fileinput.input(f):
100-
fields = line.split(";")
101-
if len(fields) != 15:
102+
data = line.split(';');
103+
if len(data) != 15:
102104
continue
103-
[code, name, gencat, combine, bidi,
104-
decomp, deci, digit, num, mirror,
105-
old, iso, upcase, lowcase, titlecase ] = fields
106-
107-
code_org = code
108-
code = int(code, 16)
109-
110-
if not is_valid_unicode(code):
105+
cp = int(data[0], 16);
106+
if is_surrogate(cp):
111107
continue
108+
if range_start >= 0:
109+
for i in xrange(range_start, cp):
110+
udict[i] = data;
111+
range_start = -1;
112+
if data[1].endswith(", First>"):
113+
range_start = cp;
114+
continue;
115+
udict[cp] = data;
116+
117+
for code in udict:
118+
[code_org, name, gencat, combine, bidi,
119+
decomp, deci, digit, num, mirror,
120+
old, iso, upcase, lowcase, titlecase ] = udict[code];
112121

113122
# generate char to char direct common and simple conversions
114123
# uppercase to lowercase

src/grammar/parser-lalr.y

+38-15
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,12 @@ extern char *yytext;
152152
%precedence MOD_SEP
153153
%precedence RARROW ':'
154154
155+
// In where clauses, "for" should have greater precedence when used as
156+
// a higher ranked constraint than when used as the beginning of a
157+
// for_in_type (which is a ty)
158+
%precedence FORTYPE
159+
%precedence FOR
160+
155161
// Binops & unops, and their precedences
156162
%precedence BOX
157163
%precedence BOXPLACE
@@ -582,6 +588,14 @@ item_impl
582588
{
583589
$$ = mk_node("ItemImplNeg", 7, $1, $3, $5, $7, $8, $10, $11);
584590
}
591+
| maybe_unsafe IMPL generic_params trait_ref FOR DOTDOT '{' '}'
592+
{
593+
$$ = mk_node("ItemImplDefault", 3, $1, $3, $4);
594+
}
595+
| maybe_unsafe IMPL generic_params '!' trait_ref FOR DOTDOT '{' '}'
596+
{
597+
$$ = mk_node("ItemImplDefaultNeg", 3, $1, $3, $4);
598+
}
585599
;
586600

587601
maybe_impl_items
@@ -769,10 +783,14 @@ where_predicates
769783
;
770784

771785
where_predicate
772-
: lifetime ':' bounds { $$ = mk_node("WherePredicate", 2, $1, $3); }
773-
| ty ':' ty_param_bounds { $$ = mk_node("WherePredicate", 2, $1, $3); }
786+
: maybe_for_lifetimes lifetime ':' bounds { $$ = mk_node("WherePredicate", 3, $1, $2, $4); }
787+
| maybe_for_lifetimes ty ':' ty_param_bounds { $$ = mk_node("WherePredicate", 3, $1, $2, $4); }
774788
;
775789

790+
maybe_for_lifetimes
791+
: FOR '<' lifetimes '>' { $$ = mk_none(); }
792+
| %prec FORTYPE %empty { $$ = mk_none(); }
793+
776794
ty_params
777795
: ty_param { $$ = mk_node("TyParams", 1, $1); }
778796
| ty_params ',' ty_param { $$ = ext_node($1, 1, $3); }
@@ -1024,7 +1042,8 @@ ty_qualified_path_and_generic_values
10241042
}
10251043
| ty_qualified_path ',' ty_sums maybe_bindings
10261044
{
1027-
$$ = mk_node("GenericValues", 3, mk_none(), ext_node(mk_node("TySums", 1, $1), 1, $3), $4); }
1045+
$$ = mk_node("GenericValues", 3, mk_none(), mk_node("TySums", 2, $1, $3), $4);
1046+
}
10281047
;
10291048

10301049
ty_qualified_path
@@ -1513,31 +1532,35 @@ nonblock_prefix_expr
15131532
;
15141533

15151534
expr_qualified_path
1516-
: '<' ty_sum AS trait_ref '>' MOD_SEP ident
1535+
: '<' ty_sum maybe_as_trait_ref '>' MOD_SEP ident
15171536
{
1518-
$$ = mk_node("ExprQualifiedPath", 3, $2, $4, $7);
1537+
$$ = mk_node("ExprQualifiedPath", 3, $2, $3, $6);
15191538
}
1520-
| '<' ty_sum AS trait_ref '>' MOD_SEP ident generic_args
1539+
| '<' ty_sum maybe_as_trait_ref '>' MOD_SEP ident generic_args
15211540
{
1522-
$$ = mk_node("ExprQualifiedPath", 4, $2, $4, $7, $8);
1541+
$$ = mk_node("ExprQualifiedPath", 4, $2, $3, $6, $7);
15231542
}
1524-
| SHL ty_sum AS trait_ref '>' MOD_SEP ident AS trait_ref '>' MOD_SEP ident
1543+
| SHL ty_sum maybe_as_trait_ref '>' MOD_SEP ident maybe_as_trait_ref '>' MOD_SEP ident
15251544
{
1526-
$$ = mk_node("ExprQualifiedPath", 3, mk_node("ExprQualifiedPath", 3, $2, $4, $7), $9, $12);
1545+
$$ = mk_node("ExprQualifiedPath", 3, mk_node("ExprQualifiedPath", 3, $2, $3, $6), $7, $10);
15271546
}
1528-
| SHL ty_sum AS trait_ref '>' MOD_SEP ident generic_args AS trait_ref '>' MOD_SEP ident
1547+
| SHL ty_sum maybe_as_trait_ref '>' MOD_SEP ident generic_args maybe_as_trait_ref '>' MOD_SEP ident
15291548
{
1530-
$$ = mk_node("ExprQualifiedPath", 3, mk_node("ExprQualifiedPath", 4, $2, $4, $7, $8), $10, $13);
1549+
$$ = mk_node("ExprQualifiedPath", 3, mk_node("ExprQualifiedPath", 4, $2, $3, $6, $7), $8, $11);
15311550
}
1532-
| SHL ty_sum AS trait_ref '>' MOD_SEP ident AS trait_ref '>' MOD_SEP ident generic_args
1551+
| SHL ty_sum maybe_as_trait_ref '>' MOD_SEP ident maybe_as_trait_ref '>' MOD_SEP ident generic_args
15331552
{
1534-
$$ = mk_node("ExprQualifiedPath", 4, mk_node("ExprQualifiedPath", 3, $2, $4, $7), $9, $12, $13);
1553+
$$ = mk_node("ExprQualifiedPath", 4, mk_node("ExprQualifiedPath", 3, $2, $3, $6), $7, $10, $11);
15351554
}
1536-
| SHL ty_sum AS trait_ref '>' MOD_SEP ident generic_args AS trait_ref '>' MOD_SEP ident generic_args
1555+
| SHL ty_sum maybe_as_trait_ref '>' MOD_SEP ident generic_args maybe_as_trait_ref '>' MOD_SEP ident generic_args
15371556
{
1538-
$$ = mk_node("ExprQualifiedPath", 4, mk_node("ExprQualifiedPath", 4, $2, $4, $7, $8), $10, $13, $14);
1557+
$$ = mk_node("ExprQualifiedPath", 4, mk_node("ExprQualifiedPath", 4, $2, $3, $6, $7), $8, $11, $12);
15391558
}
15401559

1560+
maybe_as_trait_ref
1561+
: AS trait_ref { $$ = $2; }
1562+
| %empty { $$ = mk_none(); }
1563+
;
15411564

15421565
lambda_expr
15431566
: %prec LAMBDA

src/libcore/macros.rs

+14-10
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,12 @@ macro_rules! assert_eq {
100100
/// This will invoke the `panic!` macro if the provided expression cannot be
101101
/// evaluated to `true` at runtime.
102102
///
103-
/// Unlike `assert!`, `debug_assert!` statements can be disabled by passing
104-
/// `--cfg ndebug` to the compiler. This makes `debug_assert!` useful for
105-
/// checks that are too expensive to be present in a release build but may be
106-
/// helpful during development.
103+
/// Unlike `assert!`, `debug_assert!` statements are only enabled in non
104+
/// optimized builds by default. An optimized build will omit all
105+
/// `debug_assert!` statements unless `-C debug-assertions` is passed to the
106+
/// compiler. This makes `debug_assert!` useful for checks that are too
107+
/// expensive to be present in a release build but may be helpful during
108+
/// development.
107109
///
108110
/// # Example
109111
///
@@ -125,18 +127,20 @@ macro_rules! assert_eq {
125127
#[macro_export]
126128
#[stable(feature = "rust1", since = "1.0.0")]
127129
macro_rules! debug_assert {
128-
($($arg:tt)*) => (if cfg!(not(ndebug)) { assert!($($arg)*); })
130+
($($arg:tt)*) => (if cfg!(debug_assertions) { assert!($($arg)*); })
129131
}
130132

131133
/// Asserts that two expressions are equal to each other, testing equality in
132134
/// both directions.
133135
///
134136
/// On panic, this macro will print the values of the expressions.
135137
///
136-
/// Unlike `assert_eq!`, `debug_assert_eq!` statements can be disabled by
137-
/// passing `--cfg ndebug` to the compiler. This makes `debug_assert_eq!`
138-
/// useful for checks that are too expensive to be present in a release build
139-
/// but may be helpful during development.
138+
/// Unlike `assert_eq!`, `debug_assert_eq!` statements are only enabled in non
139+
/// optimized builds by default. An optimized build will omit all
140+
/// `debug_assert_eq!` statements unless `-C debug-assertions` is passed to the
141+
/// compiler. This makes `debug_assert_eq!` useful for checks that are too
142+
/// expensive to be present in a release build but may be helpful during
143+
/// development.
140144
///
141145
/// # Example
142146
///
@@ -147,7 +151,7 @@ macro_rules! debug_assert {
147151
/// ```
148152
#[macro_export]
149153
macro_rules! debug_assert_eq {
150-
($($arg:tt)*) => (if cfg!(not(ndebug)) { assert_eq!($($arg)*); })
154+
($($arg:tt)*) => (if cfg!(debug_assertions) { assert_eq!($($arg)*); })
151155
}
152156

153157
/// Short circuiting evaluation on Err

src/libcore/ops.rs

+1
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,7 @@ shr_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize }
913913
#[stable(feature = "rust1", since = "1.0.0")]
914914
pub trait Index<Idx: ?Sized> {
915915
/// The returned type after indexing
916+
#[stable(feature = "rust1", since = "1.0.0")]
916917
type Output: ?Sized;
917918

918919
/// The method for the indexing (`Foo[Bar]`) operation

src/liblibc/lib.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,10 @@
1010

1111
#![crate_name = "libc"]
1212
#![crate_type = "rlib"]
13-
#![cfg_attr(not(feature = "cargo-build"),
14-
unstable(feature = "libc"))]
15-
#![cfg_attr(not(feature = "cargo-build"), feature(staged_api))]
13+
#![cfg_attr(not(feature = "cargo-build"), unstable(feature = "libc"))]
14+
#![cfg_attr(not(feature = "cargo-build"), feature(staged_api, core, no_std))]
1615
#![cfg_attr(not(feature = "cargo-build"), staged_api)]
17-
#![cfg_attr(not(feature = "cargo-build"), feature(core))]
18-
#![feature(no_std)]
19-
#![no_std]
16+
#![cfg_attr(not(feature = "cargo-build"), no_std)]
2017
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
2118
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
2219
html_root_url = "http://doc.rust-lang.org/nightly/",

src/liblog/macros.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ macro_rules! info {
157157
/// ```
158158
#[macro_export]
159159
macro_rules! debug {
160-
($($arg:tt)*) => (if cfg!(not(ndebug)) { log!(::log::DEBUG, $($arg)*) })
160+
($($arg:tt)*) => (if cfg!(debug_assertions) { log!(::log::DEBUG, $($arg)*) })
161161
}
162162

163163
/// A macro to test whether a log level is enabled for the current module.
@@ -192,7 +192,7 @@ macro_rules! debug {
192192
macro_rules! log_enabled {
193193
($lvl:expr) => ({
194194
let lvl = $lvl;
195-
(lvl != ::log::DEBUG || cfg!(not(ndebug))) &&
195+
(lvl != ::log::DEBUG || cfg!(debug_assertions)) &&
196196
lvl <= ::log::log_level() &&
197197
::log::mod_enabled(lvl, module_path!())
198198
})

src/librustc/metadata/loader.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ impl<'a> Context<'a> {
353353
}
354354
}
355355
if self.rejected_via_kind.len() > 0 {
356-
self.sess.span_help(self.span, "please recompile this crate using \
356+
self.sess.fileline_help(self.span, "please recompile this crate using \
357357
--crate-type lib");
358358
let mismatches = self.rejected_via_kind.iter();
359359
for (i, &CrateMismatch { ref path, .. }) in mismatches.enumerate() {

0 commit comments

Comments
 (0)