Skip to content

Commit 3fee578

Browse files
committed
---
yaml --- r: 67319 b: refs/heads/master c: 0012b50 h: refs/heads/master i: 67317: 43676bc 67315: d795e70 67311: a69995a v: v3
1 parent 5b81381 commit 3fee578

File tree

11 files changed

+58
-55
lines changed

11 files changed

+58
-55
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: d0f54a5cfb13e9ec437083666eb1b2cca6a39941
2+
refs/heads/master: 0012b5008b32543cf61a2beba36160c42f36d704
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 18e3db7392d2d0697b7e27d6d986139960144d85
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9

trunk/doc/tutorial-container.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,14 @@ impl Iterator<int> for ZeroStream {
108108
## Container iterators
109109
110110
Containers implement iteration over the contained elements by returning an
111-
iterator object. For example, vector slices have four iterators available:
111+
iterator object. For example, vector slices several iterators available:
112112
113-
* `vector.iter()`, for immutable references to the elements
114-
* `vector.mut_iter()`, for mutable references to the elements
115-
* `vector.rev_iter()`, for immutable references to the elements in reverse order
116-
* `vector.mut_rev_iter()`, for mutable references to the elements in reverse order
113+
* `iter()` and `rev_iter()`, for immutable references to the elements
114+
* `mut_iter()` and `mut_rev_iter()`, for mutable references to the elements
115+
* `consume_iter()` and `consume_rev_iter`, to move the elements out by-value
116+
117+
A typical mutable container will implement at least `iter()`, `mut_iter()` and
118+
`consume_iter()` along with the reverse variants if it maintains an order.
117119
118120
### Freezing
119121

trunk/src/librustc/middle/check_match.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
use middle::const_eval::{compare_const_vals, lookup_const_by_id};
13-
use middle::const_eval::{eval_const_expr, const_val, const_bool};
13+
use middle::const_eval::{eval_const_expr, const_val, const_bool, const_float};
1414
use middle::pat_util::*;
1515
use middle::ty::*;
1616
use middle::ty;
@@ -102,6 +102,27 @@ pub fn check_arms(cx: &MatchCheckCtxt, arms: &[arm]) {
102102
let mut seen = ~[];
103103
for arms.iter().advance |arm| {
104104
for arm.pats.iter().advance |pat| {
105+
106+
// Check that we do not match against a static NaN (#6804)
107+
let pat_matches_nan: &fn(@pat) -> bool = |p| {
108+
match cx.tcx.def_map.find(&p.id) {
109+
Some(&def_static(did, false)) => {
110+
let const_expr = lookup_const_by_id(cx.tcx, did).get();
111+
match eval_const_expr(cx.tcx, const_expr) {
112+
const_float(f) if f.is_NaN() => true,
113+
_ => false
114+
}
115+
}
116+
_ => false
117+
}
118+
};
119+
for walk_pat(*pat) |p| {
120+
if pat_matches_nan(p) {
121+
cx.tcx.sess.span_warn(p.span, "unmatchable NaN in pattern, \
122+
use the is_NaN method in a guard instead");
123+
}
124+
}
125+
105126
let v = ~[*pat];
106127
match is_useful(cx, &seen, v) {
107128
not_useful => {

trunk/src/librustc/middle/lint.rs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ pub enum lint {
7979
non_camel_case_types,
8080
non_uppercase_statics,
8181
type_limits,
82-
default_methods,
8382
unused_unsafe,
8483

8584
managed_heap_memory,
@@ -222,13 +221,6 @@ static lint_table: &'static [(&'static str, LintSpec)] = &[
222221
default: warn
223222
}),
224223

225-
("default_methods",
226-
LintSpec {
227-
lint: default_methods,
228-
desc: "allow default methods",
229-
default: allow
230-
}),
231-
232224
("unused_unsafe",
233225
LintSpec {
234226
lint: unused_unsafe,
@@ -690,23 +682,6 @@ fn lint_type_limits() -> visit::vt<@mut Context> {
690682
})
691683
}
692684

693-
fn check_item_default_methods(cx: &Context, item: &ast::item) {
694-
match item.node {
695-
ast::item_trait(_, _, ref methods) => {
696-
for methods.iter().advance |method| {
697-
match *method {
698-
ast::required(*) => {}
699-
ast::provided(*) => {
700-
cx.span_lint(default_methods, item.span,
701-
"default methods are experimental");
702-
}
703-
}
704-
}
705-
}
706-
_ => {}
707-
}
708-
}
709-
710685
fn check_item_ctypes(cx: &Context, it: &ast::item) {
711686
fn check_ty(cx: &Context, ty: &ast::Ty) {
712687
match ty.node {
@@ -1143,7 +1118,6 @@ pub fn check_crate(tcx: ty::ctxt, crate: @ast::Crate) {
11431118
check_item_ctypes(cx, it);
11441119
check_item_non_camel_case_types(cx, it);
11451120
check_item_non_uppercase_statics(cx, it);
1146-
check_item_default_methods(cx, it);
11471121
check_item_heap(cx, it);
11481122

11491123
cx.process(Item(it));

trunk/src/libstd/cmp.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ and `Eq` to overload the `==` and `!=` operators.
2121
*/
2222

2323
#[allow(missing_doc)];
24-
#[allow(default_methods)]; // NOTE: Remove when allowed in stage0
2524

2625
/**
2726
* Trait for values that can be compared for equality and inequality.

trunk/src/libstd/iterator.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ implementing the `Iterator` trait.
1717
1818
*/
1919

20-
#[allow(default_methods)]; // still off by default in stage0
21-
2220
use cmp;
2321
use iter::Times;
2422
use num::{Zero, One};

trunk/src/rt/rust_log.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,7 @@ static void update_entry(const mod_entry* entry, void *cookie) {
234234
}
235235
}
236236
*entry->state = level;
237-
if (longest_match > 0) {
238-
(*args->n_matches)++;
239-
}
237+
(*args->n_matches)++;
240238
}
241239

242240
void update_module_map(const mod_entry* map, log_directive* dirs,
@@ -320,10 +318,11 @@ void update_log_settings(void* crate_map, char* settings) {
320318
n_dirs, &n_matches);
321319

322320
if (n_matches < n_dirs) {
323-
fprintf(stderr, "warning: got %lu RUST_LOG specs but only matched %lu of them.\n"
324-
"You may have mistyped a RUST_LOG spec.\n"
325-
"Use RUST_LOG=::help to see the list of crates and modules.\n",
326-
(unsigned long)n_dirs, (unsigned long)n_matches);
321+
// NB: Android compiler is complaining about format specifiers here
322+
// and I don't understand why
323+
/*printf("warning: got %" PRIdPTR " RUST_LOG specs, "
324+
"enabled %" PRIdPTR " flags.",
325+
(uintptr_t)n_dirs, (uintptr_t)n_matches);*/
327326
}
328327

329328
free(buffer);

trunk/src/rt/rust_task.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,6 @@ cleanup_task(cleanup_args *args) {
152152
#endif
153153
}
154154

155-
extern "C" CDECL void upcall_exchange_free(void *ptr);
156-
157155
// This runs on the Rust stack
158156
void task_start_wrapper(spawn_args *a)
159157
{
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Matching against NaN should result in a warning
2+
3+
use std::float::NaN;
4+
5+
fn main() {
6+
let x = NaN;
7+
match x {
8+
NaN => {},
9+
_ => {},
10+
};
11+
//~^^^ WARNING unmatchable NaN in pattern, use the is_NaN method in a guard instead
12+
match [x, 1.0] {
13+
[NaN, _] => {},
14+
_ => {},
15+
};
16+
//~^^^ WARNING unmatchable NaN in pattern, use the is_NaN method in a guard instead
17+
}
18+
19+
// At least one error is needed so that compilation fails
20+
#[static_assert]
21+
static b: bool = false; //~ ERROR static assertion failed

trunk/src/test/compile-fail/lint-default-methods.rs

Lines changed: 0 additions & 7 deletions
This file was deleted.

trunk/src/test/run-pass/issue-7712.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
// compile-flags:-Z debug-info
1212

13-
#[allow(default_methods)];
14-
1513
pub trait TraitWithDefaultMethod {
1614
pub fn method(self) {
1715
()
@@ -24,4 +22,4 @@ impl TraitWithDefaultMethod for MyStruct { }
2422

2523
fn main() {
2624
MyStruct.method();
27-
}
25+
}

0 commit comments

Comments
 (0)