diff options
| author | Zalathar <Zalathar@users.noreply.github.com> | 2025-02-16 21:10:04 +1100 |
|---|---|---|
| committer | Zalathar <Zalathar@users.noreply.github.com> | 2025-02-20 20:37:17 +1100 |
| commit | 8bb574fdd301dbb6ff18bd2500ccf463ce8a19d4 (patch) | |
| tree | 3a637043be888ef333e571e6629cdc5836d3260c /compiler/rustc_middle/src | |
| parent | a64efc72d0811732bbbe9b6d8b678bdebd1848a2 (diff) | |
Don't store a redundant span in user-type projections
This span is already present in the corresponding `CanonicalUserTypeAnnotation`, and can be retrieved via the annotation's ID.
Diffstat (limited to 'compiler/rustc_middle/src')
| -rw-r--r-- | compiler/rustc_middle/src/mir/mod.rs | 21 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/mir/visit.rs | 2 |
2 files changed, 7 insertions, 16 deletions
diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index d74a917f33c..71fed4b3e1e 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -1494,7 +1494,7 @@ pub struct SourceScopeLocalData { /// &'static str`. #[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)] pub struct UserTypeProjections { - pub contents: Vec<(UserTypeProjection, Span)>, + pub contents: Vec<UserTypeProjection>, } impl<'tcx> UserTypeProjections { @@ -1506,26 +1506,17 @@ impl<'tcx> UserTypeProjections { self.contents.is_empty() } - pub fn projections_and_spans( - &self, - ) -> impl Iterator<Item = &(UserTypeProjection, Span)> + ExactSizeIterator { - self.contents.iter() - } - pub fn projections(&self) -> impl Iterator<Item = &UserTypeProjection> + ExactSizeIterator { - self.contents.iter().map(|&(ref user_type, _span)| user_type) + self.contents.iter() } - pub fn push_user_type(mut self, base_user_ty: UserTypeAnnotationIndex, span: Span) -> Self { - self.contents.push((UserTypeProjection { base: base_user_ty, projs: vec![] }, span)); + pub fn push_user_type(mut self, base_user_type: UserTypeAnnotationIndex) -> Self { + self.contents.push(UserTypeProjection { base: base_user_type, projs: vec![] }); self } - fn map_projections( - mut self, - mut f: impl FnMut(UserTypeProjection) -> UserTypeProjection, - ) -> Self { - self.contents = self.contents.into_iter().map(|(proj, span)| (f(proj), span)).collect(); + fn map_projections(mut self, f: impl FnMut(UserTypeProjection) -> UserTypeProjection) -> Self { + self.contents = self.contents.into_iter().map(f).collect(); self } diff --git a/compiler/rustc_middle/src/mir/visit.rs b/compiler/rustc_middle/src/mir/visit.rs index 193806f238b..98e8f269c57 100644 --- a/compiler/rustc_middle/src/mir/visit.rs +++ b/compiler/rustc_middle/src/mir/visit.rs @@ -857,7 +857,7 @@ macro_rules! make_mir_visitor { source_info: *source_info, }); if let Some(user_ty) = user_ty { - for (user_ty, _) in & $($mutability)? user_ty.contents { + for user_ty in & $($mutability)? user_ty.contents { self.visit_user_type_projection(user_ty); } } |
