Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use edition = "2024" in the compiler #129636

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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
4 changes: 3 additions & 1 deletion compiler/rustc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
cargo-features = ["edition2024"]

[package]
name = "rustc-main"
version = "0.0.0"
edition = "2021"
edition = "2024"

[dependencies]
# tidy-alphabetical-start
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_abi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
cargo-features = ["edition2024"]

[package]
name = "rustc_abi"
version = "0.0.0"
edition = "2021"
edition = "2024"

[dependencies]
# tidy-alphabetical-start
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1297,7 +1297,7 @@ impl<FieldIdx: Idx> FieldsShape<FieldIdx> {

/// Gets source indices of the fields by increasing offsets.
#[inline]
pub fn index_by_increasing_offset(&self) -> impl ExactSizeIterator<Item = usize> + '_ {
pub fn index_by_increasing_offset(&self) -> impl ExactSizeIterator<Item = usize> {
let mut inverse_small = [0u8; 64];
let mut inverse_big = IndexVec::new();
let use_small = self.count() <= inverse_small.len();
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_arena/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
cargo-features = ["edition2024"]

[package]
name = "rustc_arena"
version = "0.0.0"
edition = "2021"
edition = "2024"

[dependencies]
# tidy-alphabetical-start
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_ast/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
cargo-features = ["edition2024"]

[package]
name = "rustc_ast"
version = "0.0.0"
edition = "2021"
edition = "2024"

[dependencies]
# FIXME: bumping memchr to 2.7.1 causes linker errors in MSVC thin-lto
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_ast_ir/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
cargo-features = ["edition2024"]

[package]
name = "rustc_ast_ir"
version = "0.0.0"
edition = "2021"
edition = "2024"

[dependencies]
# tidy-alphabetical-start
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_ast_lowering/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
cargo-features = ["edition2024"]

[package]
name = "rustc_ast_lowering"
version = "0.0.0"
edition = "2021"
edition = "2024"

[lib]
doctest = false
Expand Down
17 changes: 8 additions & 9 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ use std::collections::hash_map::Entry;
use rustc_ast::node_id::NodeMap;
use rustc_ast::ptr::P;
use rustc_ast::{self as ast, *};
use rustc_data_structures::captures::Captures;
use rustc_data_structures::fingerprint::Fingerprint;
use rustc_data_structures::fx::FxIndexSet;
use rustc_data_structures::sorted_map::SortedMap;
Expand Down Expand Up @@ -2074,11 +2073,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
self.new_named_lifetime_with_res(new_id, ident, res)
}

fn lower_generic_params_mut<'s>(
&'s mut self,
params: &'s [GenericParam],
fn lower_generic_params_mut(
&mut self,
params: &[GenericParam],
source: hir::GenericParamSource,
) -> impl Iterator<Item = hir::GenericParam<'hir>> + Captures<'a> + Captures<'s> {
) -> impl Iterator<Item = hir::GenericParam<'hir>> {
params.iter().map(move |param| self.lower_generic_param(param, source))
}

Expand Down Expand Up @@ -2238,11 +2237,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
self.arena.alloc_from_iter(self.lower_param_bounds_mut(bounds, itctx))
}

fn lower_param_bounds_mut<'s>(
&'s mut self,
bounds: &'s [GenericBound],
fn lower_param_bounds_mut(
&mut self,
bounds: &[GenericBound],
itctx: ImplTraitContext,
) -> impl Iterator<Item = hir::GenericBound<'hir>> + Captures<'s> + Captures<'a> {
) -> impl Iterator<Item = hir::GenericBound<'hir>> {
bounds.iter().map(move |bound| self.lower_param_bound(bound, itctx))
}

Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_ast_passes/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
cargo-features = ["edition2024"]

[package]
name = "rustc_ast_passes"
version = "0.0.0"
edition = "2021"
edition = "2024"

[dependencies]
# tidy-alphabetical-start
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_ast_pretty/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
cargo-features = ["edition2024"]

[package]
name = "rustc_ast_pretty"
version = "0.0.0"
edition = "2021"
edition = "2024"

[dependencies]
# tidy-alphabetical-start
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_attr/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
cargo-features = ["edition2024"]

[package]
name = "rustc_attr"
version = "0.0.0"
edition = "2021"
edition = "2024"

[dependencies]
# tidy-alphabetical-start
Expand Down
24 changes: 12 additions & 12 deletions compiler/rustc_attr/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1163,25 +1163,25 @@ pub fn find_transparency(
(transparency.map_or(fallback, |t| t.0), error)
}

pub fn allow_internal_unstable<'a>(
sess: &'a Session,
attrs: &'a [Attribute],
) -> impl Iterator<Item = Symbol> + 'a {
pub fn allow_internal_unstable(
sess: &Session,
attrs: &[Attribute],
) -> impl Iterator<Item = Symbol> {
allow_unstable(sess, attrs, sym::allow_internal_unstable)
}

pub fn rustc_allow_const_fn_unstable<'a>(
sess: &'a Session,
attrs: &'a [Attribute],
) -> impl Iterator<Item = Symbol> + 'a {
pub fn rustc_allow_const_fn_unstable(
sess: &Session,
attrs: &[Attribute],
) -> impl Iterator<Item = Symbol> {
allow_unstable(sess, attrs, sym::rustc_allow_const_fn_unstable)
}

fn allow_unstable<'a>(
sess: &'a Session,
attrs: &'a [Attribute],
fn allow_unstable(
sess: &Session,
attrs: &[Attribute],
symbol: Symbol,
) -> impl Iterator<Item = Symbol> + 'a {
) -> impl Iterator<Item = Symbol> {
let attrs = attr::filter_by_name(attrs, symbol);
let list = attrs
.filter_map(move |attr| {
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_baked_icu_data/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
cargo-features = ["edition2024"]

[package]
name = "rustc_baked_icu_data"
version = "0.0.0"
edition = "2021"
edition = "2024"

[dependencies]
# tidy-alphabetical-start
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_borrowck/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
cargo-features = ["edition2024"]

[package]
name = "rustc_borrowck"
version = "0.0.0"
edition = "2021"
edition = "2024"

[dependencies]
# tidy-alphabetical-start
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/borrow_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ impl<'tcx> BorrowSet<'tcx> {
self.location_map.len()
}

pub(crate) fn indices(&self) -> impl Iterator<Item = BorrowIndex> {
pub(crate) fn indices(&self) -> impl Iterator<Item = BorrowIndex> + use<> {
BorrowIndex::ZERO..BorrowIndex::from_usize(self.len())
}

Expand Down
7 changes: 3 additions & 4 deletions compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use std::ops::ControlFlow;

use either::Either;
use hir::{ClosureKind, Path};
use rustc_data_structures::captures::Captures;
use rustc_data_structures::fx::FxIndexSet;
use rustc_errors::codes::*;
use rustc_errors::{struct_span_code_err, Applicability, Diag, MultiSpan};
Expand Down Expand Up @@ -3553,10 +3552,10 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
location: Location,
mpi: MovePathIndex,
) -> (Vec<MoveSite>, Vec<Location>) {
fn predecessor_locations<'a, 'tcx>(
body: &'a mir::Body<'tcx>,
fn predecessor_locations<'tcx>(
body: &mir::Body<'tcx>,
location: Location,
) -> impl Iterator<Item = Location> + Captures<'tcx> + 'a {
) -> impl Iterator<Item = Location> {
if location.statement_index == 0 {
let predecessors = body.basic_blocks.predecessors()[location.block].to_vec();
Either::Left(predecessors.into_iter().map(move |bb| body.terminator_loc(bb)))
Expand Down
7 changes: 2 additions & 5 deletions compiler/rustc_borrowck/src/member_constraints.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::hash::Hash;
use std::ops::Index;

use rustc_data_structures::captures::Captures;
use rustc_data_structures::fx::FxIndexMap;
use rustc_index::{IndexSlice, IndexVec};
use rustc_middle::infer::MemberConstraint;
Expand Down Expand Up @@ -151,9 +150,7 @@ impl<'tcx, R> MemberConstraintSet<'tcx, R>
where
R: Copy + Hash + Eq,
{
pub(crate) fn all_indices(
&self,
) -> impl Iterator<Item = NllMemberConstraintIndex> + Captures<'tcx> + '_ {
pub(crate) fn all_indices(&self) -> impl Iterator<Item = NllMemberConstraintIndex> {
self.constraints.indices()
}

Expand All @@ -163,7 +160,7 @@ where
pub(crate) fn indices(
&self,
member_region_vid: R,
) -> impl Iterator<Item = NllMemberConstraintIndex> + Captures<'tcx> + '_ {
) -> impl Iterator<Item = NllMemberConstraintIndex> {
let mut next = self.first_constraints.get(&member_region_vid).cloned();
std::iter::from_fn(move || -> Option<NllMemberConstraintIndex> {
if let Some(current) = next {
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_borrowck/src/region_infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
}

/// Returns an iterator over all the region indices.
pub fn regions(&self) -> impl Iterator<Item = RegionVid> + 'tcx {
pub fn regions(&self) -> impl Iterator<Item = RegionVid> {
self.definitions.indices()
}

Expand All @@ -566,7 +566,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
}

/// Returns an iterator over all the outlives constraints.
pub fn outlives_constraints(&self) -> impl Iterator<Item = OutlivesConstraint<'tcx>> + '_ {
pub fn outlives_constraints(&self) -> impl Iterator<Item = OutlivesConstraint<'tcx>> {
self.constraints.outlives().iter().copied()
}

Expand Down Expand Up @@ -603,10 +603,10 @@ impl<'tcx> RegionInferenceContext<'tcx> {
self.scc_values.region_value_str(scc)
}

pub(crate) fn placeholders_contained_in<'a>(
&'a self,
pub(crate) fn placeholders_contained_in(
&self,
r: RegionVid,
) -> impl Iterator<Item = ty::PlaceholderRegion> + 'a {
) -> impl Iterator<Item = ty::PlaceholderRegion> {
let scc = self.constraint_sccs.scc(r);
self.scc_values.placeholders_contained_in(scc)
}
Expand Down
5 changes: 1 addition & 4 deletions compiler/rustc_borrowck/src/region_infer/reverse_sccs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ pub(crate) struct ReverseSccGraph {

impl ReverseSccGraph {
/// Find all universal regions that are required to outlive the given SCC.
pub(super) fn upper_bounds<'a>(
&'a self,
scc0: ConstraintSccIndex,
) -> impl Iterator<Item = RegionVid> + 'a {
pub(super) fn upper_bounds(&self, scc0: ConstraintSccIndex) -> impl Iterator<Item = RegionVid> {
let mut duplicates = FxIndexSet::default();
graph::depth_first_search(&self.graph, scc0)
.flat_map(move |scc1| {
Expand Down
24 changes: 9 additions & 15 deletions compiler/rustc_borrowck/src/region_infer/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@ impl LivenessValues {
}

/// Iterate through each region that has a value in this set.
pub(crate) fn regions(&self) -> impl Iterator<Item = RegionVid> + '_ {
pub(crate) fn regions(&self) -> impl Iterator<Item = RegionVid> {
self.points.as_ref().expect("use with_specific_points").rows()
}

/// Iterate through each region that has a value in this set.
// We are passing query instability implications to the caller.
#[rustc_lint_query_instability]
#[allow(rustc::potential_query_instability)]
pub(crate) fn live_regions_unordered(&self) -> impl Iterator<Item = RegionVid> + '_ {
pub(crate) fn live_regions_unordered(&self) -> impl Iterator<Item = RegionVid> {
self.live_regions.as_ref().unwrap().iter().copied()
}

Expand Down Expand Up @@ -173,7 +173,7 @@ impl LivenessValues {
}

/// Returns an iterator of all the points where `region` is live.
fn live_points(&self, region: RegionVid) -> impl Iterator<Item = PointIndex> + '_ {
fn live_points(&self, region: RegionVid) -> impl Iterator<Item = PointIndex> {
let Some(points) = &self.points else {
unreachable!(
"Should be using LivenessValues::with_specific_points to ask whether live at a location"
Expand Down Expand Up @@ -359,7 +359,7 @@ impl<N: Idx> RegionValues<N> {
}

/// Returns the locations contained within a given region `r`.
pub(crate) fn locations_outlived_by<'a>(&'a self, r: N) -> impl Iterator<Item = Location> + 'a {
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()
.take_while(move |&p| self.elements.point_in_range(p))
Expand All @@ -368,18 +368,15 @@ impl<N: Idx> RegionValues<N> {
}

/// Returns just the universal regions that are contained in a given region's value.
pub(crate) fn universal_regions_outlived_by<'a>(
&'a self,
r: N,
) -> impl Iterator<Item = RegionVid> + 'a {
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())
}

/// Returns all the elements contained in a given region's value.
pub(crate) fn placeholders_contained_in<'a>(
&'a self,
pub(crate) fn placeholders_contained_in(
&self,
r: N,
) -> impl Iterator<Item = ty::PlaceholderRegion> + 'a {
) -> impl Iterator<Item = ty::PlaceholderRegion> {
self.placeholders
.row(r)
.into_iter()
Expand All @@ -388,10 +385,7 @@ impl<N: Idx> RegionValues<N> {
}

/// Returns all the elements contained in a given region's value.
pub(crate) fn elements_contained_in<'a>(
&'a self,
r: N,
) -> impl Iterator<Item = RegionElement> + 'a {
pub(crate) fn elements_contained_in(&self, r: N) -> impl Iterator<Item = RegionElement> {
let points_iter = self.locations_outlived_by(r).map(RegionElement::Location);

let free_regions_iter =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ impl UniversalRegionRelations<'_> {
}

/// Returns the _non-transitive_ set of known `outlives` constraints between free regions.
pub(crate) fn known_outlives(&self) -> impl Iterator<Item = (RegionVid, RegionVid)> + '_ {
pub(crate) fn known_outlives(&self) -> impl Iterator<Item = (RegionVid, RegionVid)> {
self.outlives.base_edges()
}
}
Expand Down
Loading
Loading