Skip to content

Commit a95943b

Browse files
authored
Rollup merge of rust-lang#108887 - nnethercote:rename-MapInPlace, r=lqd
Rename `MapInPlace` as `FlatMapInPlace`. After removing the `map_in_place` method, which isn't much use because modifying every element in a collection such as a `Vec` can be done trivially with iteration. r? ``@lqd``
2 parents 031b528 + be60bcb commit a95943b

File tree

5 files changed

+8
-15
lines changed

5 files changed

+8
-15
lines changed

compiler/rustc_ast/src/mut_visit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::ptr::P;
1212
use crate::token::{self, Token};
1313
use crate::tokenstream::*;
1414

15-
use rustc_data_structures::map_in_place::MapInPlace;
15+
use rustc_data_structures::flat_map_in_place::FlatMapInPlace;
1616
use rustc_data_structures::sync::Lrc;
1717
use rustc_span::source_map::Spanned;
1818
use rustc_span::symbol::Ident;

compiler/rustc_data_structures/src/map_in_place.rs renamed to compiler/rustc_data_structures/src/flat_map_in_place.rs

+4-11
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,7 @@ use smallvec::{Array, SmallVec};
22
use std::ptr;
33
use thin_vec::ThinVec;
44

5-
pub trait MapInPlace<T>: Sized {
6-
fn map_in_place<F>(&mut self, mut f: F)
7-
where
8-
F: FnMut(T) -> T,
9-
{
10-
self.flat_map_in_place(|e| Some(f(e)))
11-
}
12-
5+
pub trait FlatMapInPlace<T>: Sized {
136
fn flat_map_in_place<F, I>(&mut self, f: F)
147
where
158
F: FnMut(T) -> I,
@@ -66,14 +59,14 @@ macro_rules! flat_map_in_place {
6659
};
6760
}
6861

69-
impl<T> MapInPlace<T> for Vec<T> {
62+
impl<T> FlatMapInPlace<T> for Vec<T> {
7063
flat_map_in_place!();
7164
}
7265

73-
impl<T, A: Array<Item = T>> MapInPlace<T> for SmallVec<A> {
66+
impl<T, A: Array<Item = T>> FlatMapInPlace<T> for SmallVec<A> {
7467
flat_map_in_place!();
7568
}
7669

77-
impl<T> MapInPlace<T> for ThinVec<T> {
70+
impl<T> FlatMapInPlace<T> for ThinVec<T> {
7871
flat_map_in_place!();
7972
}

compiler/rustc_data_structures/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ pub fn cold_path<F: FnOnce() -> R, R>(f: F) -> R {
5050
pub mod base_n;
5151
pub mod binary_search_util;
5252
pub mod captures;
53+
pub mod flat_map_in_place;
5354
pub mod flock;
5455
pub mod functor;
5556
pub mod fx;
5657
pub mod graph;
5758
pub mod intern;
5859
pub mod jobserver;
5960
pub mod macros;
60-
pub mod map_in_place;
6161
pub mod obligation_forest;
6262
pub mod owning_ref;
6363
pub mod sip128;

compiler/rustc_expand/src/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use rustc_ast::tokenstream::{LazyAttrTokenStream, TokenTree};
1212
use rustc_ast::NodeId;
1313
use rustc_ast::{self as ast, AttrStyle, Attribute, HasAttrs, HasTokens, MetaItem};
1414
use rustc_attr as attr;
15+
use rustc_data_structures::flat_map_in_place::FlatMapInPlace;
1516
use rustc_data_structures::fx::FxHashMap;
16-
use rustc_data_structures::map_in_place::MapInPlace;
1717
use rustc_feature::{Feature, Features, State as FeatureState};
1818
use rustc_feature::{
1919
ACCEPTED_FEATURES, ACTIVE_FEATURES, REMOVED_FEATURES, STABLE_REMOVED_FEATURES,

compiler/rustc_expand/src/expand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use rustc_ast::{ForeignItemKind, HasAttrs, HasNodeId};
2020
use rustc_ast::{Inline, ItemKind, MacStmtStyle, MetaItemKind, ModKind};
2121
use rustc_ast::{NestedMetaItem, NodeId, PatKind, StmtKind, TyKind};
2222
use rustc_ast_pretty::pprust;
23-
use rustc_data_structures::map_in_place::MapInPlace;
23+
use rustc_data_structures::flat_map_in_place::FlatMapInPlace;
2424
use rustc_data_structures::sync::Lrc;
2525
use rustc_errors::PResult;
2626
use rustc_feature::Features;

0 commit comments

Comments
 (0)