1
Fork 0

Auto merge of #97697 - WaffleLapkin:no_ref_vec, r=WaffleLapkin

Replace `&Vec<_>`s with `&[_]`s

It's generally preferable to use `&[_]` since it's one less indirection and it can be created from types other that `Vec`.

I've left `&Vec` in some locals where it doesn't really matter, in cases where `TypeFoldable` is expected (`TypeFoldable: Clone` so slice can't implement it) and in cases where it's `&TypeAliasThatIsActiallyVec`. Nothing important, really, I was just a little annoyed by `visit_generic_param_vec` :D

r? `@compiler-errors`
This commit is contained in:
bors 2022-06-05 09:30:53 +00:00
commit 4322a785cc
14 changed files with 53 additions and 45 deletions

View file

@ -146,11 +146,13 @@ impl<'tcx, 'a> GeneratorData<'tcx, 'a> {
/// that are live across the yield of this generator
fn get_generator_interior_types(
&self,
) -> ty::Binder<'tcx, &Vec<GeneratorInteriorTypeCause<'tcx>>> {
) -> ty::Binder<'tcx, &[GeneratorInteriorTypeCause<'tcx>]> {
match self {
GeneratorData::Local(typeck_result) => typeck_result.generator_interior_types.as_ref(),
GeneratorData::Local(typeck_result) => {
typeck_result.generator_interior_types.as_deref()
}
GeneratorData::Foreign(generator_diagnostic_data) => {
generator_diagnostic_data.generator_interior_types.as_ref()
generator_diagnostic_data.generator_interior_types.as_deref()
}
}
}

View file

@ -773,7 +773,7 @@ pub struct PlaceholderReplacer<'me, 'tcx> {
mapped_regions: BTreeMap<ty::PlaceholderRegion, ty::BoundRegion>,
mapped_types: BTreeMap<ty::PlaceholderType, ty::BoundTy>,
mapped_consts: BTreeMap<ty::PlaceholderConst<'tcx>, ty::BoundVar>,
universe_indices: &'me Vec<Option<ty::UniverseIndex>>,
universe_indices: &'me [Option<ty::UniverseIndex>],
current_index: ty::DebruijnIndex,
}
@ -783,7 +783,7 @@ impl<'me, 'tcx> PlaceholderReplacer<'me, 'tcx> {
mapped_regions: BTreeMap<ty::PlaceholderRegion, ty::BoundRegion>,
mapped_types: BTreeMap<ty::PlaceholderType, ty::BoundTy>,
mapped_consts: BTreeMap<ty::PlaceholderConst<'tcx>, ty::BoundVar>,
universe_indices: &'me Vec<Option<ty::UniverseIndex>>,
universe_indices: &'me [Option<ty::UniverseIndex>],
value: T,
) -> T {
let mut replacer = PlaceholderReplacer {