From afaa9854fa6df74d7a1b85ebb1f45bdcd0dcc152 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Fri, 3 Jun 2022 20:42:42 +0400 Subject: Replace `&Vec<_>`s with `&[_]`s --- compiler/rustc_middle/src/middle/region.rs | 5 +++-- compiler/rustc_middle/src/mir/traversal.rs | 6 +++--- compiler/rustc_middle/src/ty/sty.rs | 7 +++++++ 3 files changed, 13 insertions(+), 5 deletions(-) (limited to 'compiler/rustc_middle/src') diff --git a/compiler/rustc_middle/src/middle/region.rs b/compiler/rustc_middle/src/middle/region.rs index 30ef6b775f5..c886175c6ea 100644 --- a/compiler/rustc_middle/src/middle/region.rs +++ b/compiler/rustc_middle/src/middle/region.rs @@ -16,6 +16,7 @@ use rustc_query_system::ich::StableHashingContext; use rustc_span::{Span, DUMMY_SP}; use std::fmt; +use std::ops::Deref; /// Represents a statically-describable scope that can be used to /// bound the lifetime/region for values. @@ -407,8 +408,8 @@ impl ScopeTree { /// Checks whether the given scope contains a `yield`. If so, /// returns `Some(YieldData)`. If not, returns `None`. - pub fn yield_in_scope(&self, scope: Scope) -> Option<&Vec> { - self.yield_in_scope.get(&scope) + pub fn yield_in_scope(&self, scope: Scope) -> Option<&[YieldData]> { + self.yield_in_scope.get(&scope).map(Deref::deref) } /// Gives the number of expressions visited in a body. diff --git a/compiler/rustc_middle/src/mir/traversal.rs b/compiler/rustc_middle/src/mir/traversal.rs index 1cbfed62156..db64bcba3b1 100644 --- a/compiler/rustc_middle/src/mir/traversal.rs +++ b/compiler/rustc_middle/src/mir/traversal.rs @@ -310,7 +310,7 @@ pub fn reachable_as_bitset<'tcx>(body: &Body<'tcx>) -> BitSet { #[derive(Clone)] pub struct ReversePostorderIter<'a, 'tcx> { body: &'a Body<'tcx>, - blocks: &'a Vec, + blocks: &'a [BasicBlock], idx: usize, } @@ -358,9 +358,9 @@ impl PostorderCache { self.cache = OnceCell::new(); } - /// Returns the &Vec represents the postorder graph for this MIR. + /// Returns the `&[BasicBlocks]` represents the postorder graph for this MIR. #[inline] - pub(super) fn compute(&self, body: &Body<'_>) -> &Vec { + pub(super) fn compute(&self, body: &Body<'_>) -> &[BasicBlock] { self.cache.get_or_init(|| Postorder::new(body, START_BLOCK).map(|(bb, _)| bb).collect()) } } diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index faeb729c884..09fe8415652 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -1032,6 +1032,13 @@ impl<'tcx, T> Binder<'tcx, T> { Binder(&self.0, self.1) } + pub fn as_deref(&self) -> Binder<'tcx, &T::Target> + where + T: Deref, + { + Binder(&self.0, self.1) + } + pub fn map_bound_ref_unchecked(&self, f: F) -> Binder<'tcx, U> where F: FnOnce(&T) -> U, -- cgit 1.4.1-3-g733a5