Skip to content

Commit 90a7d4a

Browse files
committed
---
yaml --- r: 128447 b: refs/heads/auto c: d7916f8 h: refs/heads/master i: 128445: 70eac4f 128443: 3659240 128439: d33d1af 128431: 16e101d 128415: 77c24d5 128383: 80d28ac v: v3
1 parent 9c388d5 commit 90a7d4a

File tree

11 files changed

+49
-101
lines changed

11 files changed

+49
-101
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 1824973a139443b15e2c093b3e316169f2792cb3
16+
refs/heads/auto: d7916f8d4416e739aec3226adb0df1077e15a80a
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/libregex/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,7 @@ mod parse;
395395
mod re;
396396
mod vm;
397397

398-
// FIXME(#13725) windows needs fixing.
399-
#[cfg(test, not(windows))]
398+
#[cfg(test)]
400399
mod test;
401400

402401
/// The `native` module exists to support the `regex!` macro. Do not use.

branches/auto/src/librustc/diagnostics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ register_diagnostics!(
139139
E0120,
140140
E0121,
141141
E0122,
142+
E0123,
142143
E0124,
143144
E0125,
144145
E0126,
@@ -172,6 +173,5 @@ register_diagnostics!(
172173
E0154,
173174
E0155,
174175
E0156,
175-
E0157,
176-
E0158
176+
E0157
177177
)

branches/auto/src/librustc/middle/check_match.rs

Lines changed: 29 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use std::gc::{Gc, GC};
2323
use std::iter::AdditiveIterator;
2424
use std::iter::range_inclusive;
2525
use syntax::ast::*;
26-
use syntax::ast_util::walk_pat;
26+
use syntax::ast_util::{is_unguarded, walk_pat};
2727
use syntax::codemap::{Span, Spanned, DUMMY_SP};
2828
use syntax::fold::{Folder, noop_fold_pat};
2929
use syntax::print::pprust::pat_to_string;
@@ -159,31 +159,13 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &Expr) {
159159
}
160160
}
161161

162-
let mut static_inliner = StaticInliner::new(cx.tcx);
163-
let inlined_arms = arms
164-
.iter()
165-
.map(|arm| Arm {
166-
pats: arm.pats.iter().map(|pat| {
167-
static_inliner.fold_pat(*pat)
168-
}).collect(),
169-
..arm.clone()
170-
})
171-
.collect::<Vec<Arm>>();
172-
173-
if static_inliner.failed {
174-
return;
175-
}
176-
177-
// Third, check if there are any references to NaN that we should warn about.
178-
check_for_static_nan(cx, inlined_arms.as_slice());
179-
180-
// Fourth, check for unreachable arms.
181-
check_arms(cx, inlined_arms.as_slice());
162+
// Third, check for unreachable arms.
163+
check_arms(cx, arms.as_slice());
182164

183165
// Finally, check if the whole match expression is exhaustive.
184166
// Check for empty enum, because is_useful only works on inhabited types.
185167
let pat_ty = node_id_to_type(cx.tcx, scrut.id);
186-
if inlined_arms.is_empty() {
168+
if arms.is_empty() {
187169
if !type_is_empty(cx.tcx, pat_ty) {
188170
// We know the type is inhabited, so this must be wrong
189171
span_err!(cx.tcx.sess, ex.span, E0002,
@@ -195,16 +177,19 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &Expr) {
195177
return;
196178
}
197179

198-
let matrix: Matrix = inlined_arms
199-
.move_iter()
200-
.filter(|arm| arm.guard.is_none())
201-
.flat_map(|arm| arm.pats.move_iter())
202-
.map(|pat| vec![pat])
180+
let mut static_inliner = StaticInliner { tcx: cx.tcx };
181+
let matrix: Matrix = arms
182+
.iter()
183+
.filter(|&arm| is_unguarded(arm))
184+
.flat_map(|arm| arm.pats.iter())
185+
.map(|pat| vec![static_inliner.fold_pat(*pat)])
203186
.collect();
204187
check_exhaustive(cx, ex.span, &matrix);
205188
},
206189
ExprForLoop(ref pat, _, _, _) => {
207-
let mut static_inliner = StaticInliner::new(cx.tcx);
190+
let mut static_inliner = StaticInliner {
191+
tcx: cx.tcx
192+
};
208193
match is_refutable(cx, static_inliner.fold_pat(*pat)) {
209194
Some(uncovered_pat) => {
210195
cx.tcx.sess.span_err(
@@ -231,31 +216,28 @@ fn is_expr_const_nan(tcx: &ty::ctxt, expr: &Expr) -> bool {
231216
}
232217
}
233218

234-
// Check that we do not match against a static NaN (#6804)
235-
fn check_for_static_nan(cx: &MatchCheckCtxt, arms: &[Arm]) {
219+
// Check for unreachable patterns
220+
fn check_arms(cx: &MatchCheckCtxt, arms: &[Arm]) {
221+
let mut seen = Matrix(vec!());
222+
let mut static_inliner = StaticInliner { tcx: cx.tcx };
236223
for arm in arms.iter() {
237-
for &pat in arm.pats.iter() {
238-
walk_pat(&*pat, |p| {
224+
for pat in arm.pats.iter() {
225+
let inlined = static_inliner.fold_pat(*pat);
226+
227+
// Check that we do not match against a static NaN (#6804)
228+
walk_pat(&*inlined, |p| {
239229
match p.node {
240230
PatLit(expr) if is_expr_const_nan(cx.tcx, &*expr) => {
241-
span_warn!(cx.tcx.sess, p.span, E0003,
231+
span_warn!(cx.tcx.sess, pat.span, E0003,
242232
"unmatchable NaN in pattern, \
243233
use the is_nan method in a guard instead");
244234
}
245235
_ => ()
246236
}
247237
true
248238
});
249-
}
250-
}
251-
}
252239

253-
// Check for unreachable patterns
254-
fn check_arms(cx: &MatchCheckCtxt, arms: &[Arm]) {
255-
let mut seen = Matrix(vec!());
256-
for arm in arms.iter() {
257-
for &pat in arm.pats.iter() {
258-
let v = vec![pat];
240+
let v = vec![inlined];
259241
match is_useful(cx, &seen, v.as_slice(), LeaveOutWitness) {
260242
NotUseful => span_err!(cx.tcx.sess, pat.span, E0001, "unreachable pattern"),
261243
Useful => (),
@@ -311,17 +293,7 @@ fn const_val_to_expr(value: &const_val) -> Gc<Expr> {
311293
}
312294

313295
pub struct StaticInliner<'a> {
314-
pub tcx: &'a ty::ctxt,
315-
pub failed: bool
316-
}
317-
318-
impl<'a> StaticInliner<'a> {
319-
pub fn new<'a>(tcx: &'a ty::ctxt) -> StaticInliner<'a> {
320-
StaticInliner {
321-
tcx: tcx,
322-
failed: false
323-
}
324-
}
296+
pub tcx: &'a ty::ctxt
325297
}
326298

327299
impl<'a> Folder for StaticInliner<'a> {
@@ -330,17 +302,9 @@ impl<'a> Folder for StaticInliner<'a> {
330302
PatIdent(..) | PatEnum(..) => {
331303
let def = self.tcx.def_map.borrow().find_copy(&pat.id);
332304
match def {
333-
Some(DefStatic(did, _)) => match lookup_const_by_id(self.tcx, did) {
334-
Some(const_expr) => box (GC) Pat {
335-
span: pat.span,
336-
..(*const_expr_to_pat(self.tcx, const_expr)).clone()
337-
},
338-
None => {
339-
self.failed = true;
340-
span_err!(self.tcx.sess, pat.span, E0158,
341-
"extern statics cannot be referenced in patterns");
342-
pat
343-
}
305+
Some(DefStatic(did, _)) => {
306+
let const_expr = lookup_const_by_id(self.tcx, did).unwrap();
307+
const_expr_to_pat(self.tcx, const_expr)
344308
},
345309
_ => noop_fold_pat(pat, self)
346310
}
@@ -849,7 +813,7 @@ fn check_local(cx: &mut MatchCheckCtxt, loc: &Local) {
849813
LocalFor => "`for` loop"
850814
};
851815

852-
let mut static_inliner = StaticInliner::new(cx.tcx);
816+
let mut static_inliner = StaticInliner { tcx: cx.tcx };
853817
match is_refutable(cx, static_inliner.fold_pat(loc.pat)) {
854818
Some(pat) => {
855819
span_err!(cx.tcx.sess, loc.pat.span, E0005,

branches/auto/src/librustc/middle/trans/_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1422,7 +1422,7 @@ fn trans_match_inner<'a>(scope_cx: &'a Block<'a>,
14221422
bindings_map: create_bindings_map(bcx, *arm.pats.get(0), discr_expr, &*arm.body)
14231423
}).collect();
14241424

1425-
let mut static_inliner = StaticInliner::new(scope_cx.tcx());
1425+
let mut static_inliner = StaticInliner { tcx: scope_cx.tcx() };
14261426
let mut matches = Vec::new();
14271427
for arm_data in arm_datas.iter() {
14281428
matches.extend(arm_data.arm.pats.iter().map(|&p| Match {

branches/auto/src/libsyntax/ast_util.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,21 @@ pub fn name_to_dummy_lifetime(name: Name) -> Lifetime {
209209
name: name }
210210
}
211211

212+
pub fn is_unguarded(a: &Arm) -> bool {
213+
match a.guard {
214+
None => true,
215+
_ => false
216+
}
217+
}
218+
219+
pub fn unguarded_pat(a: &Arm) -> Option<Vec<Gc<Pat>>> {
220+
if is_unguarded(a) {
221+
Some(/* FIXME (#2543) */ a.pats.clone())
222+
} else {
223+
None
224+
}
225+
}
226+
212227
/// Generate a "pretty" name for an `impl` from its type and trait.
213228
/// This is designed so that symbols of `impl`'d methods give some
214229
/// hint of where they came from, (previously they would all just be

branches/auto/src/test/bench/shootout-regex-dna.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@
3838
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
3939
// OF THE POSSIBILITY OF SUCH DAMAGE.
4040

41-
// FIXME(#13725) windows needs fixing.
42-
// ignore-windows
4341
// ignore-stage1
4442
// ignore-cross-compile #12102
4543

branches/auto/src/test/compile-fail-fulldeps/syntax-extension-regex-invalid.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// FIXME(#13725) windows needs fixing.
12-
// ignore-windows
1311
// ignore-stage1
1412

1513
#![feature(phase)]

branches/auto/src/test/compile-fail-fulldeps/syntax-extension-regex-unused-static.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// FIXME(#13725) windows needs fixing.
12-
// ignore-windows
1311
// ignore-stage1
1412

1513
#![feature(phase)]

branches/auto/src/test/compile-fail-fulldeps/syntax-extension-regex-unused.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// FIXME(#13725) windows needs fixing.
12-
// ignore-windows
1311
// ignore-stage1
1412

1513
#![feature(phase)]

branches/auto/src/test/compile-fail/issue-16149.rs

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

0 commit comments

Comments
 (0)