diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-06-09 09:27:12 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-06-16 10:52:58 +1000 |
| commit | b67635fdfd61d597f0145251dbe4ccb9c2487b8e (patch) | |
| tree | 9c5f18e4fce3e65b168e0529f57cfee7e81cfc7d | |
| parent | 9b4b34a0a673a52991c9579488e6b083f17dd3f2 (diff) | |
| download | rust-b67635fdfd61d597f0145251dbe4ccb9c2487b8e.tar.gz rust-b67635fdfd61d597f0145251dbe4ccb9c2487b8e.zip | |
Remove one use of `compare_const_vals`.
A direct comparison has the same effect. This also avoids the need for a type test within `compare_const_vals`.
| -rw-r--r-- | compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs | 11 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/thir/pattern/mod.rs | 6 |
2 files changed, 2 insertions, 15 deletions
diff --git a/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs index 26532ae33d0..d97da1c8e1d 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs @@ -848,16 +848,7 @@ impl<'tcx> Constructor<'tcx> { (Str(self_val), Str(other_val)) => { // FIXME Once valtrees are available we can directly use the bytes // in the `Str` variant of the valtree for the comparison here. - match compare_const_vals( - pcx.cx.tcx, - *self_val, - *other_val, - pcx.cx.param_env, - pcx.ty, - ) { - Some(comparison) => comparison == Ordering::Equal, - None => false, - } + self_val == other_val } (Slice(self_slice), Slice(other_slice)) => self_slice.is_covered_by(*other_slice), diff --git a/compiler/rustc_mir_build/src/thir/pattern/mod.rs b/compiler/rustc_mir_build/src/thir/pattern/mod.rs index 3161d95fff8..1029d0903c7 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/mod.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/mod.rs @@ -755,16 +755,12 @@ pub(crate) fn compare_const_vals<'tcx>( ty: Ty<'tcx>, ) -> Option<Ordering> { assert_eq!(a.ty(), b.ty()); + assert_eq!(a.ty(), ty); let from_bool = |v: bool| v.then_some(Ordering::Equal); let fallback = || from_bool(a == b); - // Use the fallback if any type differs - if a.ty() != ty { - return fallback(); - } - if a == b { return from_bool(true); } |
