Rollup merge of #77161 - est31:swich_len_already_trusted, r=petrochenkov

Remove TrustedLen requirement from BuilderMethods::switch

The main use case of TrustedLen is allowing APIs to specialize on it,
but no use of it uses that specialization. Instead, only the .len()
function provided by ExactSizeIterator is used, which is already
required to be accurate.

Thus, the TrustedLen requirement on BuilderMethods::switch is redundant.
This commit is contained in:
Ralf Jung 2020-09-26 12:58:24 +02:00 committed by GitHub
commit 7c47b1e5f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 2 additions and 6 deletions

View File

@ -21,7 +21,6 @@ use rustc_target::abi::{self, Align, Size};
use rustc_target::spec::{HasTargetSpec, Target}; use rustc_target::spec::{HasTargetSpec, Target};
use std::borrow::Cow; use std::borrow::Cow;
use std::ffi::CStr; use std::ffi::CStr;
use std::iter::TrustedLen;
use std::ops::{Deref, Range}; use std::ops::{Deref, Range};
use std::ptr; use std::ptr;
use tracing::debug; use tracing::debug;
@ -179,7 +178,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
&mut self, &mut self,
v: &'ll Value, v: &'ll Value,
else_llbb: &'ll BasicBlock, else_llbb: &'ll BasicBlock,
cases: impl ExactSizeIterator<Item = (u128, &'ll BasicBlock)> + TrustedLen, cases: impl ExactSizeIterator<Item = (u128, &'ll BasicBlock)>,
) { ) {
let switch = let switch =
unsafe { llvm::LLVMBuildSwitch(self.llbuilder, v, else_llbb, cases.len() as c_uint) }; unsafe { llvm::LLVMBuildSwitch(self.llbuilder, v, else_llbb, cases.len() as c_uint) };

View File

@ -12,7 +12,6 @@
#![feature(in_band_lifetimes)] #![feature(in_band_lifetimes)]
#![feature(nll)] #![feature(nll)]
#![feature(or_patterns)] #![feature(or_patterns)]
#![feature(trusted_len)]
#![recursion_limit = "256"] #![recursion_limit = "256"]
use back::write::{create_informational_target_machine, create_target_machine}; use back::write::{create_informational_target_machine, create_target_machine};

View File

@ -6,7 +6,6 @@
#![feature(in_band_lifetimes)] #![feature(in_band_lifetimes)]
#![feature(nll)] #![feature(nll)]
#![feature(or_patterns)] #![feature(or_patterns)]
#![feature(trusted_len)]
#![feature(associated_type_bounds)] #![feature(associated_type_bounds)]
#![recursion_limit = "256"] #![recursion_limit = "256"]

View File

@ -18,7 +18,6 @@ use rustc_middle::ty::Ty;
use rustc_target::abi::{Abi, Align, Scalar, Size}; use rustc_target::abi::{Abi, Align, Scalar, Size};
use rustc_target::spec::HasTargetSpec; use rustc_target::spec::HasTargetSpec;
use std::iter::TrustedLen;
use std::ops::Range; use std::ops::Range;
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
@ -60,7 +59,7 @@ pub trait BuilderMethods<'a, 'tcx>:
&mut self, &mut self,
v: Self::Value, v: Self::Value,
else_llbb: Self::BasicBlock, else_llbb: Self::BasicBlock,
cases: impl ExactSizeIterator<Item = (u128, Self::BasicBlock)> + TrustedLen, cases: impl ExactSizeIterator<Item = (u128, Self::BasicBlock)>,
); );
fn invoke( fn invoke(
&mut self, &mut self,