address reviewer comments

This commit is contained in:
mark 2020-11-09 12:19:34 -06:00
parent 459dae94a1
commit 43e4783ce3
2 changed files with 29 additions and 28 deletions

View File

@ -671,12 +671,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
(&TestKind::Range { .. }, _) => None,
(&TestKind::Eq { .. } | &TestKind::Len { .. }, _) => {
// We do call `test()` below to see what kind of test `match_pair` would require.
// If it is the same test as `test`, then we can just use `test`.
// The call to `self.test(&match_pair)` below is not actually used to generate any
// MIR. Instead, we just want to compare with `test` (the parameter of the method)
// to see if it is the same.
//
// However, `test()` assumes that there won't be any or-patterns, so we need to
// specially handle that here and return `None` (since the `test` clearly doesn't
// apply to an or-pattern).
// However, at this point we can still encounter or-patterns that were extracted
// from previous calls to `sort_candidate`, so we need to manually address that
// case to avoid panicking in `self.test()`.
if let PatKind::Or { .. } = &*match_pair.pattern.kind {
return None;
}

View File

@ -3,39 +3,39 @@
#![feature(or_patterns)]
fn main() {
assert_eq!(f("", 0), true);
assert_eq!(f("a", 1), true);
assert_eq!(f("b", 1), true);
assert!(f("", 0));
assert!(f("a", 1));
assert!(f("b", 1));
assert_eq!(f("", 1), false);
assert_eq!(f("a", 0), false);
assert_eq!(f("b", 0), false);
assert!(!f("", 1));
assert!(!f("a", 0));
assert!(!f("b", 0));
assert_eq!(f("asdf", 032), false);
assert!(!f("asdf", 032));
////
assert_eq!(g(true, true, true), false);
assert_eq!(g(false, true, true), false);
assert_eq!(g(true, false, true), false);
assert_eq!(g(false, false, true), false);
assert_eq!(g(true, true, false), false);
assert!(!g(true, true, true));
assert!(!g(false, true, true));
assert!(!g(true, false, true));
assert!(!g(false, false, true));
assert!(!g(true, true, false));
assert_eq!(g(false, true, false), true);
assert_eq!(g(true, false, false), true);
assert_eq!(g(false, false, false), true);
assert!(g(false, true, false));
assert!(g(true, false, false));
assert!(g(false, false, false));
////
assert_eq!(h(true, true, true), false);
assert_eq!(h(false, true, true), false);
assert_eq!(h(true, false, true), false);
assert_eq!(h(false, false, true), false);
assert_eq!(h(true, true, false), false);
assert!(!h(true, true, true));
assert!(!h(false, true, true));
assert!(!h(true, false, true));
assert!(!h(false, false, true));
assert!(!h(true, true, false));
assert_eq!(h(false, true, false), true);
assert_eq!(h(true, false, false), true);
assert_eq!(h(false, false, false), true);
assert!(h(false, true, false));
assert!(h(true, false, false));
assert!(h(false, false, false));
}
fn f(s: &str, num: usize) -> bool {