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

Rollup of 10 pull requests #122472

Closed
wants to merge 43 commits into from
Closed
Changes from 3 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
bf62d59
Give `TRACK_DIAGNOSTIC` a return value.
nnethercote Feb 9, 2024
ecd3718
Inline and remove `Level::get_diagnostic_id`.
nnethercote Feb 13, 2024
272e60b
Move `DelayedBug` handling into the `match`.
nnethercote Feb 13, 2024
c81767e
Reorder `has_future_breakage` handling.
nnethercote Feb 13, 2024
aec4bdb
Move `Expect`/`ForceWarning` handling into the `match`.
nnethercote Feb 13, 2024
a7d9262
Add comments about `TRACK_DIAGNOSTIC` use.
nnethercote Feb 13, 2024
7ef605b
Make the `match` in `emit_diagnostic` complete.
nnethercote Mar 1, 2024
71080dd
Document how removing a type's field can be bad and what to do instead
shepmaster Mar 2, 2024
a82587c
Avoid closing invalid handles
dylni Mar 9, 2024
15b71f4
Add CStr::bytes iterator
clarfonthey Nov 13, 2022
7f427f8
rustdoc-search: parse and search with ML-style HOF
notriddle Jan 6, 2024
d38527e
rustdoc: clean up search.js by removing empty sort case
notriddle Jan 6, 2024
23e931f
rustdoc: use `const` for the special type name ids
notriddle Jan 6, 2024
7b92655
rustdoc-search: add search query syntax `Fn(T) -> U`
notriddle Jan 6, 2024
c076509
Add methods to create constants
celinval Mar 1, 2024
893a910
Add a test to SMIR body transformation
celinval Mar 12, 2024
dd0f41f
Fix WF for AsyncFnKindHelper in new trait solver
compiler-errors Mar 12, 2024
a38a556
Reduce unsafe code, use more NonNull APIs per @cuviper review
clarfonthey Mar 12, 2024
c527ec7
Improve Step docs
CAD97 Mar 13, 2024
90acda1
Fix accidental re-addition of removed code in a previous PR
oli-obk Mar 13, 2024
f10ebfe
Generalize `eval_in_interpreter` with a helper trait
oli-obk Mar 11, 2024
44b1f8a
Move only usage of `take_static_root_alloc` to its definition and inl…
oli-obk Mar 11, 2024
31fa142
Move error handling into const_validate_mplace
oli-obk Mar 11, 2024
71ef9e2
Move InterpCx into eval_in_interpreter
oli-obk Mar 11, 2024
bd7580b
Move generate_stacktrace_from_stack away from InterpCx to avoid havin…
oli-obk Mar 11, 2024
7aee665
Directly pass in the stack instead of computing it from a machine
oli-obk Mar 11, 2024
ffaf082
Remove an argument that can be computed cheaply
oli-obk Mar 12, 2024
66a46bb
Share the `InterpCx` creation between static and const evaluation
oli-obk Mar 12, 2024
af59eec
Move validation into eval_body_using_ecx
oli-obk Mar 12, 2024
2a1a6fa
Move the entire success path into `eval_body_using_ecx`
oli-obk Mar 12, 2024
3393227
Rename some things around validation error reporting to signal that i…
oli-obk Mar 13, 2024
be33586
fix unsoundness in Step::forward_unchecked for signed integers
the8472 Mar 13, 2024
d3cab9f
update virtual clock in miri test since signed loops now execute more…
the8472 Mar 13, 2024
be248f8
Rollup merge of #104353 - clarfonthey:cstr-bytes-iter, r=cuviper
jhpratt Mar 14, 2024
5161634
Rollup merge of #119029 - dylni:avoid-closing-invalid-handles, r=Chri…
jhpratt Mar 14, 2024
206f550
Rollup merge of #119676 - notriddle:notriddle/rustdoc-search-hof, r=G…
jhpratt Mar 14, 2024
eab8823
Rollup merge of #120699 - nnethercote:rm-useless-TRACK_DIAGNOSTIC-cal…
jhpratt Mar 14, 2024
8721f0b
Rollup merge of #121899 - shepmaster:dead-code-docs, r=wesleywiser
jhpratt Mar 14, 2024
26ab7f6
Rollup merge of #122397 - oli-obk:machine-read-hook2, r=RalfJung
jhpratt Mar 14, 2024
16997d6
Rollup merge of #122405 - celinval:smir-new-const, r=oli-obk
jhpratt Mar 14, 2024
136f313
Rollup merge of #122406 - compiler-errors:next-solver-asynckind-wf, r…
jhpratt Mar 14, 2024
f559417
Rollup merge of #122421 - CAD97:step-trait-docs, r=jhpratt
jhpratt Mar 14, 2024
2d1b091
Rollup merge of #122461 - the8472:fix-step-forward-unchecked, r=Amanieu
jhpratt Mar 14, 2024
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
30 changes: 28 additions & 2 deletions library/core/src/iter/range.rs
Original file line number Diff line number Diff line change
@@ -183,8 +183,25 @@ pub trait Step: Clone + PartialOrd + Sized {
}
}

// These are still macro-generated because the integer literals resolve to different types.
macro_rules! step_identical_methods {
// Separate impls for signed ranges because the distance within a signed range can be larger
// than the signed::MAX value. Therefore `as` casting to the signed type would be incorrect.
macro_rules! step_signed_methods {
($unsigned: ty) => {
#[inline]
unsafe fn forward_unchecked(start: Self, n: usize) -> Self {
// SAFETY: the caller has to guarantee that `start + n` doesn't overflow.
unsafe { start.checked_add_unsigned(n as $unsigned).unwrap_unchecked() }
}

#[inline]
unsafe fn backward_unchecked(start: Self, n: usize) -> Self {
// SAFETY: the caller has to guarantee that `start - n` doesn't overflow.
unsafe { start.checked_sub_unsigned(n as $unsigned).unwrap_unchecked() }
}
};
}

macro_rules! step_unsigned_methods {
() => {
#[inline]
unsafe fn forward_unchecked(start: Self, n: usize) -> Self {
@@ -197,7 +214,12 @@ macro_rules! step_identical_methods {
// SAFETY: the caller has to guarantee that `start - n` doesn't overflow.
unsafe { start.unchecked_sub(n as Self) }
}
};
}

// These are still macro-generated because the integer literals resolve to different types.
macro_rules! step_identical_methods {
() => {
#[inline]
#[allow(arithmetic_overflow)]
#[rustc_inherit_overflow_checks]
@@ -238,6 +260,7 @@ macro_rules! step_integer_impls {
#[unstable(feature = "step_trait", reason = "recently redesigned", issue = "42168")]
impl Step for $u_narrower {
step_identical_methods!();
step_unsigned_methods!();

#[inline]
fn steps_between(start: &Self, end: &Self) -> Option<usize> {
@@ -270,6 +293,7 @@ macro_rules! step_integer_impls {
#[unstable(feature = "step_trait", reason = "recently redesigned", issue = "42168")]
impl Step for $i_narrower {
step_identical_methods!();
step_signed_methods!($u_narrower);

#[inline]
fn steps_between(start: &Self, end: &Self) -> Option<usize> {
@@ -334,6 +358,7 @@ macro_rules! step_integer_impls {
#[unstable(feature = "step_trait", reason = "recently redesigned", issue = "42168")]
impl Step for $u_wider {
step_identical_methods!();
step_unsigned_methods!();

#[inline]
fn steps_between(start: &Self, end: &Self) -> Option<usize> {
@@ -359,6 +384,7 @@ macro_rules! step_integer_impls {
#[unstable(feature = "step_trait", reason = "recently redesigned", issue = "42168")]
impl Step for $i_wider {
step_identical_methods!();
step_signed_methods!($u_wider);

#[inline]
fn steps_between(start: &Self, end: &Self) -> Option<usize> {
5 changes: 5 additions & 0 deletions library/core/tests/iter/range.rs
Original file line number Diff line number Diff line change
@@ -325,6 +325,11 @@ fn test_range_advance_by() {
assert_eq!(Ok(()), r.advance_back_by(usize::MAX));

assert_eq!((r.start, r.end), (0u128 + usize::MAX as u128, u128::MAX - usize::MAX as u128));

// issue 122420, Step::forward_unchecked was unsound for signed integers
let mut r = -128i8..127;
assert_eq!(Ok(()), r.advance_by(200));
assert_eq!(r.next(), Some(72));
}

#[test]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
The loop took around 7s
The loop took around 12s