Skip to content

Commit ac6d836

Browse files
committed
Auto merge of #160557 - JonathanBrouwer:rollup-OtzfGt5, r=<try>
Rollup of 25 pull requests try-job: dist-various-1 try-job: test-various try-job: x86_64-gnu-aux try-job: x86_64-gnu-llvm-21-3 try-job: x86_64-msvc-1 try-job: aarch64-apple try-job: x86_64-mingw-1 try-job: i686-msvc-*
2 parents 1b29cfd + 32c1b4e commit ac6d836

255 files changed

Lines changed: 2651 additions & 1761 deletions

File tree

Some content is hidden

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

.git-blame-ignore-revs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,6 @@ c682aa162b0d41e21cc6748f4fecfe01efb69d1f
3333
1fcae03369abb4c2cc180cd5a49e1f4440a81300
3434
# Breaking up of compiletest runtest.rs
3535
60600a6fa403216bfd66e04f948b1822f6450af7
36+
37+
# std: move futex implementations into sys::sync::futex
38+
7232830d10b6af772e0e4670a2ff61dd23830ed8

.github/pull_request_template.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
<!-- homu-ignore:start -->
2+
3+
- [ ] I did not use an LLM to create a change in this PR.
4+
- [ ] I used an LLM to create a change in this PR, and I have explained below how it was used.
5+
26
<!--
7+
Please read our [LLM policy] before opening a PR,
8+
and check one of the boxes above to indicate whether you've used an LLM.
9+
If you do not check a box, a reviewer may ask you whether an LLM was involved.
10+
LLM contributions are not banned, but are held to a higher standard of review and correctness.
11+
12+
[LLM policy]: https://forge.rust-lang.org/policies/llm-usage.html
13+
314
If this PR is related to an unstable feature or an otherwise tracked effort,
415
please link to the relevant tracking issue here. If you don't know of a related
516
tracking issue or there are none, feel free to ignore this.

CONTRIBUTING.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ that you read and understand the [rustc-dev-guide] before making a contribution.
2929
talks about the different bots in the Rust ecosystem, the Rust development tools,
3030
bootstrapping, the compiler architecture, source code representation, and more.
3131

32+
## LLM policy
33+
34+
We have a policy for how LLMs are allowed to be used in contributions to `rust-lang/rust`.
35+
You can read it [on Forge][LLM policy].
36+
For suggestions about how to use LLMs *well*, and how to review LLM-created PRs, see [the dev-guide][llm-guidance].
37+
38+
[LLM policy]: https://forge.rust-lang.org/policies/llm-usage.html
39+
[llm-guidance]: https://rustc-dev-guide.rust-lang.org/llm-guidance.html
40+
3241
## [Getting help](https://rustc-dev-guide.rust-lang.org/getting-started.html#asking-questions)
3342

3443
There are many ways you can get help when you're stuck. Rust has two platforms for this:

Cargo.lock

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3954,6 +3954,7 @@ dependencies = [
39543954
"rustc_errors",
39553955
"rustc_expand",
39563956
"rustc_feature",
3957+
"rustc_hir",
39573958
"rustc_hir_analysis",
39583959
"rustc_hir_pretty",
39593960
"rustc_index",
@@ -4414,7 +4415,6 @@ dependencies = [
44144415
"rustc_graphviz",
44154416
"rustc_hashes",
44164417
"rustc_hir",
4417-
"rustc_hir_pretty",
44184418
"rustc_index",
44194419
"rustc_lint_defs",
44204420
"rustc_macros",
@@ -4621,7 +4621,7 @@ dependencies = [
46214621
"rustc_middle",
46224622
"rustc_session",
46234623
"rustc_span",
4624-
"rustc_ty_utils",
4624+
"rustc_ty_walk",
46254625
"tracing",
46264626
]
46274627

@@ -4908,6 +4908,17 @@ dependencies = [
49084908
"rustc_span",
49094909
"rustc_target",
49104910
"rustc_trait_selection",
4911+
"rustc_ty_walk",
4912+
"tracing",
4913+
]
4914+
4915+
[[package]]
4916+
name = "rustc_ty_walk"
4917+
version = "0.0.0"
4918+
dependencies = [
4919+
"rustc_hir",
4920+
"rustc_middle",
4921+
"rustc_span",
49114922
"tracing",
49124923
]
49134924

compiler/rustc_abi/src/tests.rs

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,68 @@ fn align_constants() {
66
assert_eq!(Align::EIGHT, Align::from_bytes(8).unwrap());
77
}
88

9+
#[test]
10+
#[should_panic(expected = "Value 299 is too big for Size(1 bytes)")]
11+
fn wrapping_range_smallest_range_containing_size_mismatch() {
12+
WrappingRange::smallest_range_containing(200..300, Size::from_bytes(1));
13+
}
14+
15+
#[test]
16+
fn wrapping_range_smallest_range_containing() {
17+
#[track_caller]
18+
fn check(x: impl IntoIterator<Item = u128>, bytes: u64, start: u128, end: u128) {
19+
assert_eq!(
20+
WrappingRange::smallest_range_containing(x, Size::from_bytes(bytes)),
21+
Some(WrappingRange { start, end }),
22+
);
23+
}
24+
25+
assert_eq!(WrappingRange::smallest_range_containing([], Size::from_bytes(1)), None);
26+
27+
check([7], 1, 7, 7);
28+
check([7, 7, 7], 1, 7, 7);
29+
30+
check(0..=127, 1, 0, 127);
31+
check((0..=127).chain([255]), 1, 255, 127);
32+
33+
check((-100..=100_i128).map(i128::cast_unsigned), 16, (-100_i128).cast_unsigned(), 100);
34+
35+
// A wraparound case that's not just "sort them as signed"
36+
check([10, 100, 160, 220], 1, 100, 10);
37+
38+
check([0, 0xFF], 1, 0xFF, 0);
39+
check([0, 0xFF], 2, 0, 0xFF);
40+
check([0, 0xFFFF], 2, 0xFFFF, 0);
41+
check([0, 0xFFFF], 4, 0, 0xFFFF);
42+
check([0, 0xFFFFFFFF], 4, 0xFFFFFFFF, 0);
43+
check([0, 0xFFFFFFFF], 8, 0, 0xFFFFFFFF);
44+
45+
check([100, 200], 1, 100, 200);
46+
check([100, 200, 50], 1, 50, 200);
47+
check([100, 200, 250], 1, 100, 250);
48+
check([100, 200, 250, 50], 1, 200, 100);
49+
50+
check([200, 50], 1, 200, 50);
51+
check([200, 50, 190], 1, 190, 50);
52+
check([200, 50, 60], 1, 200, 60);
53+
check([200, 50, 125], 1, 50, 200);
54+
55+
// The mem::Alignment case
56+
check((0..64).map(|n| 1 << n), 8, 1, i64::MIN.cast_unsigned().into());
57+
58+
// Both `100..=228` and `..=228 | 100..` are the same size, but we pick the one without zero.
59+
check([100, 228], 1, 100, 228);
60+
61+
// The wraparound one here is slightly smaller, so we pick it despite including zero.
62+
// (The distance 10→96 is 86, compared to 85 for 96→181 and 181→10.)
63+
check([10, 96, 181], 1, 96, 10);
64+
65+
// These 4 values are evenly spaced so all 4 candidate ranges have length 193:
66+
// `(..=32) | (96..)`, `(..=96) | (160..)`, `(..=160) | (224..)`, and `32..=224`.
67+
// We pick the last one as the only one that doesn't contain zero.
68+
check([0xA0, 0xE0, 0x20, 0x60], 1, 0x20, 0xE0);
69+
}
70+
971
#[test]
1072
fn wrapping_range_contains_range() {
1173
let size16 = Size::from_bytes(16);

compiler/rustc_abi/src/wrapping_range.rs

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use std::fmt;
21
use std::ops::RangeFull;
2+
use std::{fmt, iter};
33

44
use crate::Size;
55
#[cfg(feature = "nightly")]
@@ -149,51 +149,49 @@ impl WrappingRange {
149149
///
150150
/// # Examples
151151
///
152-
///
153152
/// ```
154153
/// use rustc_abi::{Size, WrappingRange};
155154
///
156-
/// let range = WrappingRange::smallest_range_containing([2, 6, 12, 4], Size::from_bytes(2));
157-
/// assert_eq!(range.unwrap(), WrappingRange { start: 2, end: 12 });
155+
/// let chain = std::iter::chain(10..20, 30..40);
156+
/// let range = WrappingRange::smallest_range_containing(chain, Size::from_bytes(2));
157+
/// assert_eq!(range.unwrap(), WrappingRange { start: 10, end: 39 });
158158
///
159-
/// let range = WrappingRange::smallest_range_containing(0..=127, Size::from_bytes(1));
160-
/// assert_eq!(range.unwrap(), WrappingRange { start: 0, end: 127 });
161-
/// let range = WrappingRange::smallest_range_containing([129, 128, 127], Size::from_bytes(1));
162-
/// assert_eq!(range.unwrap(), WrappingRange { start: 127, end: 129 });
159+
/// // Values don't need to be sorted nor unique
160+
/// let range = WrappingRange::smallest_range_containing([3, 5, 3, 1, 3], Size::from_bytes(2));
161+
/// assert_eq!(range.unwrap(), WrappingRange { start: 1, end: 5 });
163162
///
164163
/// // The size matters because it changes where the wrapping can happen:
165164
/// let range = WrappingRange::smallest_range_containing([1, 254], Size::from_bytes(1));
166165
/// assert_eq!(range.unwrap(), WrappingRange { start: 254, end: 1 });
167166
/// let range = WrappingRange::smallest_range_containing([1, 254], Size::from_bytes(4));
168167
/// assert_eq!(range.unwrap(), WrappingRange { start: 1, end: 254 });
169-
///
170-
/// // Both `100..=228` and `..=228 | 100..` are the same size, but we pick the one without zero.
171-
/// let range = WrappingRange::smallest_range_containing([100, 228], Size::from_bytes(1));
172-
/// assert_eq!(range.unwrap(), WrappingRange { start: 100, end: 228 });
173-
/// // These 4 values are evenly spaced so all 4 candidate ranges have length 193:
174-
/// // `(..=32) | (96..)`, `(..=96) | (160..)`, `(..=160) | (224..)`, and `32..=224`.
175-
/// // We pick the last one as the only one that doesn't contain zero.
176-
/// let range = WrappingRange::smallest_range_containing([0xA0, 0xE0, 0x20, 0x60], Size::from_bytes(1));
177-
/// assert_eq!(range.unwrap(), WrappingRange { start: 0x20, end: 0xE0 });
178168
/// ```
179169
pub fn smallest_range_containing(
180170
values: impl IntoIterator<Item = u128>,
181171
size: Size,
182172
) -> Option<Self> {
183173
let mut values: Vec<_> = values.into_iter().collect();
184-
let umax = size.unsigned_int_max();
185-
for value in &values {
186-
debug_assert!(*value <= umax, "Value {value:?} is too big for {size:?}");
187-
}
188174
values.sort_unstable();
189175

190-
// Having sorted all the values, every element is a possible start point for the
191-
// range of values, up to the previous element (wrapping around the end of the vec).
192-
// Look at all those candidates and pick the one that's as narrow as possible.
193-
let pairs = std::iter::zip(values.iter().copied(), values.iter().copied().cycle().skip(1));
194-
let ranges = pairs.map(|(end, start)| WrappingRange { start, end });
195-
let smallest_range = ranges.min_by_key(|r| (r.width(size), r.start));
196-
smallest_range
176+
// The simple answer is the non-wraparound range `min..=max`.
177+
let obvious_range = WrappingRange { start: *values.first()?, end: *values.last()? };
178+
179+
// Having sorted the inputs, one test is enough to double-check they all fit in `size`.
180+
let max_input = obvious_range.end;
181+
assert!(
182+
max_input <= size.unsigned_int_max(),
183+
"Value {max_input:?} is too big for {size:?}",
184+
);
185+
186+
// But every `[.., end, start, ..]` is also a potential candidate for a wraparound
187+
// range `(..=end) | (start..)`, so long as `start` and `end` aren't duplicates.
188+
let wraparound_ranges = values
189+
.array_windows::<2>()
190+
.filter_map(|&[end, start]| (start != end).then_some(WrappingRange { start, end }));
191+
192+
// Pick whichever range is smallest. By putting the non-wraparound range first,
193+
// it'll be preferred over a wraparound range with the same width.
194+
iter::chain(iter::once(obvious_range), wraparound_ranges).min_by_key(|r| r.width(size))
197195
}
198196
}
199197

compiler/rustc_attr_parsing/src/attributes/traits.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::mem;
33
use rustc_feature::AttributeStability;
44

55
use super::prelude::*;
6+
use crate::AttributeSafety;
67
use crate::attributes::{NoArgsAttributeParser, SingleAttributeParser};
78
use crate::context::AcceptContext;
89
use crate::parser::ArgParser;
@@ -98,12 +99,18 @@ impl NoArgsAttributeParser for RustcSpecializationTraitParser {
9899
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcSpecializationTrait;
99100
}
100101

101-
pub(crate) struct RustcUnsafeSpecializationMarkerParser;
102-
impl NoArgsAttributeParser for RustcUnsafeSpecializationMarkerParser {
103-
const PATH: &[Symbol] = &[sym::rustc_unsafe_specialization_marker];
102+
pub(crate) struct RustcAllowLifetimeDependentSpecializationParser;
103+
impl NoArgsAttributeParser for RustcAllowLifetimeDependentSpecializationParser {
104+
const PATH: &[Symbol] = &[sym::rustc_allow_lifetime_dependent_specialization];
104105
const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[Allow(Target::Trait)]);
105106
const STABILITY: AttributeStability = unstable!(rustc_attrs);
106-
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcUnsafeSpecializationMarker;
107+
const CREATE: fn(Span) -> AttributeKind =
108+
|_| AttributeKind::RustcAllowLifetimeDependentSpecialization;
109+
const SAFETY: AttributeSafety = AttributeSafety::Unsafe {
110+
note: "this attribute requires `unsafe` because lifetime constraints from \
111+
the implementations of the trait are not considered when specializing",
112+
unsafe_since: None,
113+
};
107114
}
108115

109116
// Coherence

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ attribute_parsers!(
295295
Single<WithoutArgs<RustcAllocatorParser>>,
296296
Single<WithoutArgs<RustcAllocatorZeroedParser>>,
297297
Single<WithoutArgs<RustcAllowIncoherentImplParser>>,
298+
Single<WithoutArgs<RustcAllowLifetimeDependentSpecializationParser>>,
298299
Single<WithoutArgs<RustcAsPtrParser>>,
299300
Single<WithoutArgs<RustcCanonicalSymbolParser>>,
300301
Single<WithoutArgs<RustcCaptureAnalysisParser>>,
@@ -355,7 +356,6 @@ attribute_parsers!(
355356
Single<WithoutArgs<RustcStrictCoherenceParser>>,
356357
Single<WithoutArgs<RustcTestEntrypointMarkerParser>>,
357358
Single<WithoutArgs<RustcTrivialFieldReadsParser>>,
358-
Single<WithoutArgs<RustcUnsafeSpecializationMarkerParser>>,
359359
Single<WithoutArgs<SplatParser>>,
360360
Single<WithoutArgs<ThreadLocalParser>>,
361361
Single<WithoutArgs<TrackCallerParser>>,

compiler/rustc_attr_parsing/src/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ fn expr_to_lit<'sess>(
489489
}
490490
}
491491

492-
/// Whether expansions of `expr` metavariables from decrarative macros
492+
/// Whether expansions of `expr` metavariables from declarative macros
493493
/// are permitted. Used when parsing meta items; currently, only `cfg` predicates
494494
/// enable this option
495495
#[derive(Clone, Copy, PartialEq, Eq)]

compiler/rustc_borrowck/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ struct CollectRegionConstraintsResult<'tcx> {
304304
location_map: Rc<DenseLocationMap>,
305305
universal_region_relations: Frozen<UniversalRegionRelations<'tcx>>,
306306
region_bound_pairs: Frozen<RegionBoundPairs<'tcx>>,
307-
known_type_outlives_obligations: Frozen<Vec<ty::PolyTypeOutlivesPredicate<'tcx>>>,
307+
known_type_outlives_obligations: Frozen<Vec<ty::PolyTypeOutlivesClause<'tcx>>>,
308308
constraints: MirTypeckRegionConstraints<'tcx>,
309309
deferred_closure_requirements: DeferredClosureRequirements<'tcx>,
310310
deferred_opaque_type_errors: Vec<DeferredOpaqueTypeError<'tcx>>,

0 commit comments

Comments
 (0)