Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
let spans = sess.psess.gated_spans.spans.borrow();
macro_rules! gate_all {
($feature:ident, $explain:literal $(, $help:literal)?) => {
for &span in spans.get(&sym::$feature).into_iter().flatten() {
for &span in spans.get(&sym::$feature).into_flat_iter() {
gate!(visitor, $feature, span, $explain $(, $help)?);
}
};
Expand Down Expand Up @@ -527,13 +527,13 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
);

// `associated_const_equality` will be stabilized as part of `min_generic_const_args`.
for &span in spans.get(&sym::associated_const_equality).into_iter().flatten() {
for &span in spans.get(&sym::associated_const_equality).into_flat_iter() {
gate!(visitor, min_generic_const_args, span, "associated const equality is incomplete");
}

// `mgca_type_const_syntax` is part of `min_generic_const_args` so if
// either or both are enabled we don't need to emit a feature error.
for &span in spans.get(&sym::mgca_type_const_syntax).into_iter().flatten() {
for &span in spans.get(&sym::mgca_type_const_syntax).into_flat_iter() {
if visitor.features.min_generic_const_args()
|| visitor.features.mgca_type_const_syntax()
|| span.allows_unstable(sym::min_generic_const_args)
Expand Down Expand Up @@ -561,13 +561,13 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
// it does **not** mean "`T` doesn't implement `Bound` (positively or negatively)"!
// The latter would be a SemVer hazard!
if !sess.opts.unstable_opts.internal_testing_features || !visitor.features.negative_bounds() {
for &span in spans.get(&sym::negative_bounds).into_iter().flatten() {
for &span in spans.get(&sym::negative_bounds).into_flat_iter() {
sess.dcx().emit_err(diagnostics::NegativeBoundUnsupported { span });
}
}

if !visitor.features.never_patterns() {
for &span in spans.get(&sym::never_patterns).into_iter().flatten() {
for &span in spans.get(&sym::never_patterns).into_flat_iter() {
if span.allows_unstable(sym::never_patterns) {
continue;
}
Expand All @@ -585,7 +585,7 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
}

// Yield exprs can be enabled either by `yield_expr`, by `coroutines` or by `gen_blocks`.
for &span in spans.get(&sym::yield_expr).into_iter().flatten() {
for &span in spans.get(&sym::yield_expr).into_flat_iter() {
if (!visitor.features.coroutines() && !span.allows_unstable(sym::coroutines))
&& (!visitor.features.gen_blocks() && !span.allows_unstable(sym::gen_blocks))
&& (!visitor.features.yield_expr() && !span.allows_unstable(sym::yield_expr))
Expand All @@ -607,7 +607,7 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {

macro_rules! soft_gate_all_legacy_dont_use {
($feature:ident, $explain:literal) => {
for &span in spans.get(&sym::$feature).into_iter().flatten() {
for &span in spans.get(&sym::$feature).into_flat_iter() {
if !visitor.features.$feature() && !span.allows_unstable(sym::$feature) {
feature_warn(&visitor.sess, sym::$feature, span, $explain);
}
Expand All @@ -625,7 +625,7 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
soft_gate_all_legacy_dont_use!(try_blocks, "`try` blocks are unstable");
// tidy-alphabetical-end

for &span in spans.get(&sym::min_specialization).into_iter().flatten() {
for &span in spans.get(&sym::min_specialization).into_flat_iter() {
if !visitor.features.specialization()
&& !visitor.features.min_specialization()
&& !span.allows_unstable(sym::specialization)
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_ast_passes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#![feature(deref_patterns)]
#![feature(iter_intersperse)]
#![feature(iter_is_partitioned)]
#![feature(option_into_flat_iter)]
// tidy-alphabetical-end

pub mod ast_validation;
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_borrowck/src/dataflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,9 +476,8 @@ impl<'a, 'tcx> Borrows<'a, 'tcx> {
.borrow_set
.local_map
.get(&place.local)
.into_iter()
.flat_map(|bs| bs.iter())
.copied();
.map(|bs| bs.iter().copied())
.into_flat_iter();

// If the borrowed place is a local with no projections, all other borrows of this
// local must conflict. This is purely an optimization so we don't have to call
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#![feature(file_buffered)]
#![feature(negative_impls)]
#![feature(never_type)]
#![feature(option_into_flat_iter)]
#![feature(rustc_attrs)]
#![feature(stmt_expr_attributes)]
#![feature(try_blocks)]
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/polonius/constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl LocalizedConstraintGraph {
// The physical edges present at this node are:
//
// 1. the typeck edges that flow from region to region *at this point*.
for &succ in self.edges.get(&node).into_iter().flatten() {
for &succ in self.edges.get(&node).into_flat_iter() {
let succ = LocalizedNode { region: succ, point: node.point };
successor_found(succ);
}
Expand Down Expand Up @@ -229,7 +229,7 @@ impl LocalizedConstraintGraph {
}

// And finally, we have the logical edges, materialized at this point.
for &logical_succ in self.logical_edges.get(&node.region).into_iter().flatten() {
for &logical_succ in self.logical_edges.get(&node.region).into_flat_iter() {
let succ = LocalizedNode { region: logical_succ, point: node.point };
successor_found(succ);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub(super) fn apply_member_constraints<'tcx>(
rcx.scc_values.add_region(scc_a, scc_b);
}

for defining_use in member_constraints.get(&scc_a).into_iter().flatten() {
for defining_use in member_constraints.get(&scc_a).into_flat_iter() {
apply_member_constraint(rcx, scc_a, &defining_use.arg_regions);
}
}
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_borrowck/src/region_infer/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ impl LivenessValues {

/// Returns an iterator of all the points where `region` is live.
fn live_points(&self, region: RegionVid) -> impl Iterator<Item = PointIndex> {
self.point_liveness(region).into_iter().flat_map(|set| set.iter())
self.point_liveness(region).map(|set| set.iter()).into_flat_iter()
}

/// For debugging purposes, returns a pretty-printed string of the points where the `region` is
Expand Down Expand Up @@ -348,13 +348,13 @@ impl<'tcx, N: Idx> RegionValues<'tcx, N> {
pub(crate) fn locations_outlived_by(&self, r: N) -> impl Iterator<Item = Location> {
self.points
.row(r)
.into_iter()
.flat_map(move |set| set.iter().map(move |p| self.location_map.to_location(p)))
.map(move |set| set.iter().map(move |p| self.location_map.to_location(p)))
.into_flat_iter()
}

/// Returns just the universal regions that are contained in a given region's value.
pub(crate) fn universal_regions_outlived_by(&self, r: N) -> impl Iterator<Item = RegionVid> {
self.free_regions.row(r).into_iter().flat_map(|set| set.iter())
self.free_regions.row(r).map(|set| set.iter()).into_flat_iter()
}

/// Returns all the elements contained in a given region's value.
Expand All @@ -364,8 +364,8 @@ impl<'tcx, N: Idx> RegionValues<'tcx, N> {
) -> impl Iterator<Item = ty::PlaceholderRegion<'tcx>> {
self.placeholders
.row(r)
.into_iter()
.flat_map(|set| set.iter())
.map(|set| set.iter())
.into_flat_iter()
.map(move |p| self.placeholder_indices.lookup_placeholder(p))
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
self.super_local_decl(local, local_decl);

for user_ty in
local_decl.user_ty.as_deref().into_iter().flat_map(UserTypeProjections::projections)
local_decl.user_ty.as_deref().map(UserTypeProjections::projections).into_flat_iter()
{
let span = self.user_type_annotations[user_ty.base].span;

Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_codegen_ssa/src/assert_module_sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ impl<'tcx> AssertModuleSource<'tcx> {
fn check_attrs(&mut self, attrs: &[hir::Attribute]) {
for &(span, cgu_fields) in find_attr!(attrs,
RustcCguTestAttr(e) => e)
.into_iter()
.flatten()
.into_flat_iter()
{
let (expected_reuse, comp_kind) = match cgu_fields {
CguFields::PartitionReused { .. } => (CguReuse::PreLto, ComparisonKind::AtLeast),
Expand Down
8 changes: 3 additions & 5 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1088,9 +1088,7 @@ fn link_natively(
let get_objects = |objects: &CrtObjects, kind| {
objects
.get(&kind)
.iter()
.copied()
.flatten()
.into_flat_iter()
.map(|obj| {
get_object_file_path(sess, obj, self_contained_crt_objects).into_os_string()
})
Expand Down Expand Up @@ -2070,7 +2068,7 @@ fn add_pre_link_objects(
} else {
&empty
};
for obj in objects.get(&link_output_kind).iter().copied().flatten() {
for obj in objects.get(&link_output_kind).into_flat_iter() {
cmd.add_object(&get_object_file_path(sess, obj, self_contained));
}
}
Expand All @@ -2087,7 +2085,7 @@ fn add_post_link_objects(
} else {
&sess.target.post_link_objects
};
for obj in objects.get(&link_output_kind).iter().copied().flatten() {
for obj in objects.get(&link_output_kind).into_flat_iter() {
cmd.add_object(&get_object_file_path(sess, obj, self_contained));
}
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_ssa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#![feature(deref_patterns)]
#![feature(file_buffered)]
#![feature(negative_impls)]
#![feature(option_into_flat_iter)]
#![feature(string_from_utf8_lossy_owned)]
#![feature(trait_alias)]
#![feature(try_blocks)]
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_hir_analysis/src/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,10 +479,9 @@ fn fn_sig_suggestion<'tcx>(
}
}
};
Some(format!("{splat}{arg_ty}"))
format!("{splat}{arg_ty}")
})
.chain(std::iter::once(if sig.c_variadic() { Some("...".to_string()) } else { None }))
.flatten()
.chain(if sig.c_variadic() { Some("...".to_string()) } else { None })
.collect::<Vec<String>>()
.join(", ");
let mut output = sig.output();
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,7 @@ fn check_eiis_fn(tcx: TyCtxt<'_>, def_id: LocalDefId) {
// does the function have an EiiImpl attribute? that contains the defid of a *macro*
// that was used to mark the implementation. This is a two step process.
for EiiImpl { resolution, span, .. } in
find_attr!(tcx, def_id, EiiImpls(impls) => impls).into_iter().flatten()
find_attr!(tcx, def_id, EiiImpls(impls) => impls).into_flat_iter()
{
let (foreign_item, name) = match resolution {
EiiImplResolution::Macro(def_id) => {
Expand All @@ -1244,7 +1244,7 @@ fn check_eiis_static<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId, ty: Ty<'tcx>)
// does the function have an EiiImpl attribute? that contains the defid of a *macro*
// that was used to mark the implementation. This is a two step process.
for EiiImpl { resolution, span, .. } in
find_attr!(tcx, def_id, EiiImpls(impls) => impls).into_iter().flatten()
find_attr!(tcx, def_id, EiiImpls(impls) => impls).into_flat_iter()
{
let (foreign_item, name) = match resolution {
EiiImplResolution::Macro(def_id) => {
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir_analysis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ This API is completely unstable and subject to change.
#![feature(gen_blocks)]
#![feature(iter_intersperse)]
#![feature(never_type)]
#![feature(option_into_flat_iter)]
#![feature(slice_partition_dedup)]
#![feature(try_blocks)]
#![feature(unwrap_infallible)]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/coercion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
let mut coercion = self.unify_and(
coerce_target,
target,
reborrow.into_iter().flat_map(|(deref, autoref)| [deref, autoref]),
reborrow.map(|(deref, autoref)| [deref, autoref]).into_flat_iter(),
Adjust::Pointer(PointerCoercion::Unsize),
ForceLeakCheck::No,
)?;
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir_typeck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#![feature(iter_intersperse)]
#![feature(iter_order_by)]
#![feature(never_type)]
#![feature(option_into_flat_iter)]
#![feature(option_reference_flattening)]
#![feature(trim_prefix_suffix)]
// tidy-alphabetical-end
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// NOTE: Reporting a method error should also suppress any unused trait errors,
// since the method error is very possibly the reason why the trait wasn't used.
for &import_id in
self.tcx.in_scope_traits(call_id).into_iter().flatten().flat_map(|c| c.import_ids)
self.tcx.in_scope_traits(call_id).into_flat_iter().flat_map(|c| c.import_ids)
{
self.typeck_results.borrow_mut().used_trait_imports.insert(import_id);
}
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_lint/src/if_let_rescope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,7 @@ impl Subdiagnostic for IfLetRescopeRewrite {
closing_brackets
.empty_alt
.then_some(" _ => {}".chars())
.into_iter()
.flatten()
.into_flat_iter()
.chain(repeat_n('}', closing_brackets.count))
.collect(),
));
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_lint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#![allow(internal_features)]
#![feature(deref_patterns)]
#![feature(iter_order_by)]
#![feature(option_into_flat_iter)]
#![feature(rustc_attrs)]
#![feature(titlecase)]
#![feature(try_blocks)]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_metadata/src/eii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub(crate) fn collect<'tcx>(tcx: TyCtxt<'tcx>, LocalCrate: LocalCrate) -> EiiMap

// iterate over all items in the current crate
for id in tcx.hir_crate_items(()).eiis() {
for i in find_attr!(tcx, id, EiiImpls(e) => e).into_iter().flatten() {
for i in find_attr!(tcx, id, EiiImpls(e) => e).into_flat_iter() {
let decl = match i.resolution {
EiiImplResolution::Macro(macro_defid) => {
// find the decl for this one if it wasn't in yet (maybe it's from the local crate? not very useful but not illegal)
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_metadata/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#![feature(macro_metavar_expr)]
#![feature(min_specialization)]
#![feature(never_type)]
#![feature(option_into_flat_iter)]
#![feature(proc_macro_internals)]
#![feature(trusted_len)]
// tidy-alphabetical-end
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_metadata/src/locator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,8 @@ impl<'a> CrateLocator<'a> {
sess.opts
.externs
.get(crate_name.as_str())
.into_iter()
.filter_map(|entry| entry.files())
.flatten()
.and_then(|entry| entry.files())
.into_flat_iter()
.cloned()
.collect()
} else {
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_metadata/src/native_libs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,7 @@ impl<'tcx> Collector<'tcx> {
return;
}

for attr in
find_attr!(self.tcx, def_id, Link(links, _) => links).iter().map(|v| v.iter()).flatten()
{
for attr in find_attr!(self.tcx, def_id, Link(links, _) => links).into_flat_iter() {
let dll_imports = match attr.kind {
NativeLibKind::RawDylib { .. } => foreign_items
.iter()
Expand Down
10 changes: 6 additions & 4 deletions compiler/rustc_metadata/src/rmeta/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2038,10 +2038,12 @@ impl CrateMetadata {
krate: CrateNum,
) -> impl Iterator<Item = DefId> {
gen move {
for def_id in self.root.proc_macro_data.as_ref().into_iter().flat_map(move |data| {
data.macros.decode((self, tcx)).map(move |(index, _)| DefId { index, krate })
}) {
yield def_id;
if let Some(data) = &self.root.proc_macro_data {
for def_id in
data.macros.decode((self, tcx)).map(move |(index, _)| DefId { index, krate })
{
yield def_id;
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_middle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#![feature(min_specialization)]
#![feature(negative_impls)]
#![feature(never_type)]
#![feature(option_into_flat_iter)]
#![feature(ptr_alignment_type)]
#![feature(range_bounds_is_empty)]
#![feature(rustc_attrs)]
Expand Down
Loading
Loading