Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit e557d29

Browse files
committed
Auto merge of rust-lang#118769 - pitaj:range-experiment, r=<try>
Range experiment Meant for a crater run to see how much breakage we can expect outside of the Iterator methods themselves https://internals.rust-lang.org/t/pre-rfc-fixing-range-by-2027/19936
2 parents 6f40082 + f74b74c commit e557d29

File tree

128 files changed

+4320
-1921
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+4320
-1921
lines changed

Cargo.lock

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3006,9 +3006,9 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068"
30063006

30073007
[[package]]
30083008
name = "proc-macro2"
3009-
version = "1.0.63"
3009+
version = "1.0.70"
30103010
source = "registry+https://github.com/rust-lang/crates.io-index"
3011-
checksum = "7b368fba921b0dce7e60f5e04ec15e565b3303972b42bcfde1d0713b881959eb"
3011+
checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b"
30123012
dependencies = [
30133013
"unicode-ident",
30143014
]
@@ -3064,9 +3064,8 @@ checksum = "07589615d719a60c8dd8a4622e7946465dfef20d1a428f969e3443e7386d5f45"
30643064

30653065
[[package]]
30663066
name = "quote"
3067-
version = "1.0.29"
3068-
source = "registry+https://github.com/rust-lang/crates.io-index"
3069-
checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105"
3067+
version = "1.0.33"
3068+
source = "git+https://github.com/pitaj/quote#44feebf0594b255a511ff20890a7acbf4d6aeed1"
30703069
dependencies = [
30713070
"proc-macro2",
30723071
]
@@ -3349,11 +3348,10 @@ dependencies = [
33493348
[[package]]
33503349
name = "rustc-rayon"
33513350
version = "0.5.0"
3352-
source = "registry+https://github.com/rust-lang/crates.io-index"
3353-
checksum = "eb81aadc8837ca6ecebe0fe1353f15df83b3b3cc2cf7a8afd571bc22aa121710"
3351+
source = "git+https://github.com/pitaj/rustc-rayon#e76e554512ce25abb48f4118576ede5d7a457918"
33543352
dependencies = [
33553353
"either",
3356-
"rustc-rayon-core",
3354+
"rustc-rayon-core 0.5.0 (git+https://github.com/pitaj/rustc-rayon)",
33573355
]
33583356

33593357
[[package]]
@@ -3368,6 +3366,17 @@ dependencies = [
33683366
"num_cpus",
33693367
]
33703368

3369+
[[package]]
3370+
name = "rustc-rayon-core"
3371+
version = "0.5.0"
3372+
source = "git+https://github.com/pitaj/rustc-rayon#e76e554512ce25abb48f4118576ede5d7a457918"
3373+
dependencies = [
3374+
"crossbeam-channel",
3375+
"crossbeam-deque",
3376+
"crossbeam-utils",
3377+
"num_cpus",
3378+
]
3379+
33713380
[[package]]
33723381
name = "rustc-semver"
33733382
version = "1.1.0"
@@ -3697,7 +3706,7 @@ dependencies = [
36973706
"portable-atomic",
36983707
"rustc-hash",
36993708
"rustc-rayon",
3700-
"rustc-rayon-core",
3709+
"rustc-rayon-core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
37013710
"rustc_arena",
37023711
"rustc_graphviz",
37033712
"rustc_index",
@@ -4023,7 +4032,7 @@ version = "0.0.0"
40234032
dependencies = [
40244033
"libloading 0.7.4",
40254034
"rustc-rayon",
4026-
"rustc-rayon-core",
4035+
"rustc-rayon-core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
40274036
"rustc_ast",
40284037
"rustc_ast_lowering",
40294038
"rustc_ast_passes",
@@ -4188,7 +4197,7 @@ dependencies = [
41884197
"measureme",
41894198
"polonius-engine",
41904199
"rustc-rayon",
4191-
"rustc-rayon-core",
4200+
"rustc-rayon-core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
41924201
"rustc_apfloat",
41934202
"rustc_arena",
41944203
"rustc_ast",
@@ -4388,7 +4397,7 @@ version = "0.0.0"
43884397
dependencies = [
43894398
"field-offset",
43904399
"measureme",
4391-
"rustc-rayon-core",
4400+
"rustc-rayon-core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
43924401
"rustc_data_structures",
43934402
"rustc_errors",
43944403
"rustc_hir",
@@ -4407,7 +4416,7 @@ name = "rustc_query_system"
44074416
version = "0.0.0"
44084417
dependencies = [
44094418
"parking_lot 0.12.1",
4410-
"rustc-rayon-core",
4419+
"rustc-rayon-core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
44114420
"rustc_ast",
44124421
"rustc_data_structures",
44134422
"rustc_errors",

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,8 @@ rustc-std-workspace-core = { path = 'library/rustc-std-workspace-core' }
111111
rustc-std-workspace-alloc = { path = 'library/rustc-std-workspace-alloc' }
112112
rustc-std-workspace-std = { path = 'library/rustc-std-workspace-std' }
113113

114+
rustc-rayon = { git = "https://github.com/pitaj/rustc-rayon" }
115+
quote = { git = "https://github.com/pitaj/quote" }
116+
114117
[patch."https://github.com/rust-lang/rust-clippy"]
115118
clippy_lints = { path = "src/tools/clippy/clippy_lints" }

compiler/rustc_borrowck/src/borrow_set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ impl<'tcx> BorrowSet<'tcx> {
161161
}
162162

163163
pub(crate) fn indices(&self) -> impl Iterator<Item = BorrowIndex> {
164-
BorrowIndex::from_usize(0)..BorrowIndex::from_usize(self.len())
164+
(BorrowIndex::from_usize(0)..BorrowIndex::from_usize(self.len())).into_iter()
165165
}
166166

167167
pub(crate) fn iter_enumerated(&self) -> impl Iterator<Item = (BorrowIndex, &BorrowData<'tcx>)> {

compiler/rustc_borrowck/src/region_infer/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2140,7 +2140,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
21402140
// we still want to screen for an "interesting" point to
21412141
// highlight (e.g., a call site or something).
21422142
let target_scc = self.constraint_sccs.scc(target_region);
2143-
let mut range = 0..path.len();
2143+
let mut range = (0..path.len()).into_iter();
21442144

21452145
// As noted above, when reporting an error, there is typically a chain of constraints
21462146
// leading from some "source" region which must outlive some "target" region.

compiler/rustc_builtin_macros/src/deriving/cmp/partial_ord.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub fn expand_deriving_partial_ord(
2828
// No data, placing the tag check first makes codegen simpler
2929
0 => true,
3030
1..=2 => false,
31-
_ => (0..dataful.len() - 1).any(|i| {
31+
_ => (0..dataful.len() - 1).into_iter().any(|i| {
3232
if dataful[i]
3333
&& let Some(idx) = dataful[i + 1..].iter().position(|v| *v)
3434
{

compiler/rustc_const_eval/src/interpret/projection.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub trait Projectable<'tcx, Prov: Provenance>: Sized + std::fmt::Debug {
9999
/// A type representing iteration over the elements of an array.
100100
pub struct ArrayIterator<'tcx, 'a, Prov: Provenance, P: Projectable<'tcx, Prov>> {
101101
base: &'a P,
102-
range: Range<u64>,
102+
range: <Range<u64> as IntoIterator>::IntoIter,
103103
stride: Size,
104104
field_layout: TyAndLayout<'tcx>,
105105
_phantom: PhantomData<Prov>, // otherwise it says `Prov` is never used...
@@ -280,7 +280,13 @@ where
280280
debug!("project_array_fields: {base:?} {len}");
281281
base.offset(len * stride, self.layout_of(self.tcx.types.unit).unwrap(), self)?;
282282
// Create the iterator.
283-
Ok(ArrayIterator { base, range: 0..len, stride, field_layout, _phantom: PhantomData })
283+
Ok(ArrayIterator {
284+
base,
285+
range: (0..len).into_iter(),
286+
stride,
287+
field_layout,
288+
_phantom: PhantomData,
289+
})
284290
}
285291

286292
/// Subslicing

compiler/rustc_error_codes/src/error_codes/E0562.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Erroneous code example:
55

66
```compile_fail,E0562
77
fn main() {
8-
let count_to_ten: impl Iterator<Item=usize> = 0..10;
8+
let count_to_ten: impl IntoIterator<Item=usize> = 0..10;
99
// error: `impl Trait` not allowed outside of function and inherent method
1010
// return types
1111
for i in count_to_ten {
@@ -17,7 +17,7 @@ fn main() {
1717
Make sure `impl Trait` only appears in return-type position.
1818

1919
```
20-
fn count_to_n(n: usize) -> impl Iterator<Item=usize> {
20+
fn count_to_n(n: usize) -> impl IntoIterator<Item=usize> {
2121
0..n
2222
}
2323

compiler/rustc_metadata/src/rmeta/decoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ impl<T: ParameterizedOverTcx> LazyValue<T> {
251251
}
252252

253253
struct DecodeIterator<'a, 'tcx, T> {
254-
elem_counter: std::ops::Range<usize>,
254+
elem_counter: <std::ops::Range<usize> as IntoIterator>::IntoIter,
255255
dcx: DecodeContext<'a, 'tcx>,
256256
_phantom: PhantomData<fn() -> T>,
257257
}
@@ -294,7 +294,7 @@ impl<T: ParameterizedOverTcx> LazyArray<T> {
294294
{
295295
let mut dcx = metadata.decoder(self.position.get());
296296
dcx.lazy_state = LazyState::NodeStart(self.position);
297-
DecodeIterator { elem_counter: (0..self.num_elems), dcx, _phantom: PhantomData }
297+
DecodeIterator { elem_counter: (0..self.num_elems).into_iter(), dcx, _phantom: PhantomData }
298298
}
299299
}
300300

compiler/rustc_middle/src/mir/interpret/allocation/init_mask.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ impl InitMaskMaterialized {
534534
end: Size,
535535
is_init: bool,
536536
) -> Option<Size> {
537-
(start..end).find(|&i| init_mask.get(i) == is_init)
537+
(start..end).into_iter().find(|&i| init_mask.get(i) == is_init)
538538
}
539539

540540
let result = find_bit_fast(self, start, end, is_init);

compiler/rustc_parse/src/parser/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2905,7 +2905,7 @@ impl<'a> Parser<'a> {
29052905
}
29062906

29072907
pub fn is_diff_marker(&mut self, long_kind: &TokenKind, short_kind: &TokenKind) -> bool {
2908-
(0..3).all(|i| self.look_ahead(i, |tok| tok == long_kind))
2908+
(0..3).into_iter().all(|i| self.look_ahead(i, |tok| tok == long_kind))
29092909
&& self.look_ahead(3, |tok| tok == short_kind)
29102910
}
29112911

0 commit comments

Comments
 (0)