Skip to content

Commit

Permalink
Remove use of ptr::eq
Browse files Browse the repository at this point in the history
  • Loading branch information
canndrew committed Feb 5, 2017
1 parent a1f42cd commit 0dbb1e4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
31 changes: 18 additions & 13 deletions src/librustc_const_eval/check_match.rs
Expand Up @@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use std::ptr;
use _match::{MatchCheckCtxt, Matrix, expand_pattern, is_useful};
use _match::Usefulness::*;
use _match::WitnessPreference::*;
Expand Down Expand Up @@ -274,7 +273,7 @@ fn check_arms<'a, 'tcx>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
let mut seen = Matrix::empty();
let mut catchall = None;
let mut printed_if_let_err = false;
for &(ref pats, guard) in arms {
for (arm_index, &(ref pats, guard)) in arms.iter().enumerate() {
for &(pat, hir_pat) in pats {
let v = vec![pat];

Expand Down Expand Up @@ -305,17 +304,23 @@ fn check_arms<'a, 'tcx>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
let span = first_pat.0.span;

// check which arm we're on.
if ptr::eq(first_arm_pats, pats) {
let mut diagnostic = Diagnostic::new(Level::Warning,
"unreachable pattern");
diagnostic.set_span(pat.span);
cx.tcx.sess.add_lint_diagnostic(lint::builtin::UNREACHABLE_PATTERNS,
hir_pat.id, diagnostic);
} else {
struct_span_err!(cx.tcx.sess, span, E0165,
"irrefutable while-let pattern")
.span_label(span, &format!("irrefutable pattern"))
.emit();
match arm_index {
// The arm with the user-specified pattern.
0 => {
let mut diagnostic = Diagnostic::new(Level::Warning,
"unreachable pattern");
diagnostic.set_span(pat.span);
cx.tcx.sess.add_lint_diagnostic(lint::builtin::UNREACHABLE_PATTERNS,
hir_pat.id, diagnostic);
},
// The arm with the wildcard pattern.
1 => {
struct_span_err!(cx.tcx.sess, span, E0165,
"irrefutable while-let pattern")
.span_label(span, &format!("irrefutable pattern"))
.emit();
},
_ => bug!(),
}
},

Expand Down
1 change: 0 additions & 1 deletion src/librustc_const_eval/lib.rs
Expand Up @@ -30,7 +30,6 @@
#![feature(box_syntax)]
#![feature(const_fn)]
#![feature(i128_type)]
#![feature(ptr_eq)]

extern crate arena;
#[macro_use] extern crate syntax;
Expand Down

0 comments on commit 0dbb1e4

Please sign in to comment.