about summary refs log tree commit diff
path: root/src/librustc_codegen_llvm
diff options
context:
space:
mode:
authorbjorn3 <bjorn3@users.noreply.github.com>2019-03-29 17:23:52 +0100
committerbjorn3 <bjorn3@users.noreply.github.com>2019-03-29 17:23:52 +0100
commit35705dee7eb10783280e0be92aedfc187e019dd2 (patch)
treece087c1461e548a2e67e96d358ac7de7633304b6 /src/librustc_codegen_llvm
parent56842b2154c0c2dd243f64e864b9c6aee718a161 (diff)
downloadrust-35705dee7eb10783280e0be92aedfc187e019dd2.tar.gz
rust-35705dee7eb10783280e0be92aedfc187e019dd2.zip
Use ExactSizeIterator + TrustedLen instead of num_cases arg for switch
Diffstat (limited to 'src/librustc_codegen_llvm')
-rw-r--r--src/librustc_codegen_llvm/builder.rs6
-rw-r--r--src/librustc_codegen_llvm/lib.rs1
2 files changed, 4 insertions, 3 deletions
diff --git a/src/librustc_codegen_llvm/builder.rs b/src/librustc_codegen_llvm/builder.rs
index fbeb978413a..123fda1e215 100644
--- a/src/librustc_codegen_llvm/builder.rs
+++ b/src/librustc_codegen_llvm/builder.rs
@@ -21,6 +21,7 @@ use rustc_codegen_ssa::mir::place::PlaceRef;
 use std::borrow::Cow;
 use std::ops::{Deref, Range};
 use std::ptr;
+use std::iter::TrustedLen;
 
 // All Builders must have an llfn associated with them
 #[must_use]
@@ -169,11 +170,10 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
         &mut self,
         v: &'ll Value,
         else_llbb: &'ll BasicBlock,
-        num_cases: usize,
-        cases: impl Iterator<Item = (u128, &'ll BasicBlock)>,
+        cases: impl ExactSizeIterator<Item = (u128, &'ll BasicBlock)> + TrustedLen,
     ) {
         let switch = unsafe {
-            llvm::LLVMBuildSwitch(self.llbuilder, v, else_llbb, num_cases as c_uint)
+            llvm::LLVMBuildSwitch(self.llbuilder, v, else_llbb, cases.len() as c_uint)
         };
         for (on_val, dest) in cases {
             let on_val = self.const_uint_big(self.val_ty(v), on_val);
diff --git a/src/librustc_codegen_llvm/lib.rs b/src/librustc_codegen_llvm/lib.rs
index c95feafa29a..0aae6b46e3d 100644
--- a/src/librustc_codegen_llvm/lib.rs
+++ b/src/librustc_codegen_llvm/lib.rs
@@ -20,6 +20,7 @@
 #![feature(concat_idents)]
 #![feature(link_args)]
 #![feature(static_nobundle)]
+#![feature(trusted_len)]
 #![deny(rust_2018_idioms)]
 #![allow(explicit_outlives_requirements)]