Skip to content

Commit 8417d68

Browse files
committed
Auto merge of #68803 - Dylan-DPC:rollup-b4x6ghj, r=Dylan-DPC
Rollup of 8 pull requests Successful merges: - #68678 (Install robots.txt into rust-docs tarballs) - #68711 (Added upper bound of what vecs and boxes can allocate) - #68744 (Do not ICE in `type-alias-impl-trait` with save-analysis) - #68777 (Clean up E0263 explanation) - #68787 (Optimize core::ptr::align_offset (part 1)) - #68797 (Fix links to types instead of modules) - #68798 (Test that `#[track_caller]` as `fn()` respects RT / CTFE equivalence) - #68800 (Stabilize `core::iter::once_with()`) Failed merges: r? @ghost
2 parents bdd946d + af3c315 commit 8417d68

File tree

19 files changed

+123
-42
lines changed

19 files changed

+123
-42
lines changed

src/bootstrap/dist.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ impl Step for Docs {
105105
t!(fs::create_dir_all(&dst));
106106
let src = builder.doc_out(host);
107107
builder.cp_r(&src, &dst);
108+
builder.install(&builder.src.join("src/doc/robots.txt"), &dst, 0o644);
108109

109110
let mut cmd = rust_installer(builder);
110111
cmd.arg("generate")

src/doc/robots.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# NB: This file is not automatically deployed. After changes, it needs to be uploaded manually to doc.rust-lang.org
21
User-agent: *
32
Disallow: /0.3/
43
Disallow: /0.4/

src/liballoc/boxed.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
//!
33
//! [`Box<T>`], casually referred to as a 'box', provides the simplest form of
44
//! heap allocation in Rust. Boxes provide ownership for this allocation, and
5-
//! drop their contents when they go out of scope.
5+
//! drop their contents when they go out of scope. Boxes also ensure that they
6+
//! never allocate more than `isize::MAX` bytes.
67
//!
78
//! # Examples
89
//!

src/liballoc/vec.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
//! Vectors have `O(1)` indexing, amortized `O(1)` push (to the end) and
55
//! `O(1)` pop (from the end).
66
//!
7+
//! Vectors ensure they never allocate more than `isize::MAX` bytes.
8+
//!
79
//! # Examples
810
//!
911
//! You can explicitly create a [`Vec<T>`] with [`new`]:

src/libcore/iter/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ pub use self::sources::{empty, Empty};
327327
pub use self::sources::{from_fn, FromFn};
328328
#[stable(feature = "iter_once", since = "1.2.0")]
329329
pub use self::sources::{once, Once};
330-
#[unstable(feature = "iter_once_with", issue = "57581")]
330+
#[stable(feature = "iter_once_with", since = "1.43.0")]
331331
pub use self::sources::{once_with, OnceWith};
332332
#[stable(feature = "rust1", since = "1.0.0")]
333333
pub use self::sources::{repeat, Repeat};

src/libcore/iter/sources.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -399,12 +399,12 @@ pub fn once<T>(value: T) -> Once<T> {
399399
///
400400
/// [`once_with`]: fn.once_with.html
401401
#[derive(Copy, Clone, Debug)]
402-
#[unstable(feature = "iter_once_with", issue = "57581")]
402+
#[stable(feature = "iter_once_with", since = "1.43.0")]
403403
pub struct OnceWith<F> {
404404
gen: Option<F>,
405405
}
406406

407-
#[unstable(feature = "iter_once_with", issue = "57581")]
407+
#[stable(feature = "iter_once_with", since = "1.43.0")]
408408
impl<A, F: FnOnce() -> A> Iterator for OnceWith<F> {
409409
type Item = A;
410410

@@ -420,24 +420,24 @@ impl<A, F: FnOnce() -> A> Iterator for OnceWith<F> {
420420
}
421421
}
422422

423-
#[unstable(feature = "iter_once_with", issue = "57581")]
423+
#[stable(feature = "iter_once_with", since = "1.43.0")]
424424
impl<A, F: FnOnce() -> A> DoubleEndedIterator for OnceWith<F> {
425425
fn next_back(&mut self) -> Option<A> {
426426
self.next()
427427
}
428428
}
429429

430-
#[unstable(feature = "iter_once_with", issue = "57581")]
430+
#[stable(feature = "iter_once_with", since = "1.43.0")]
431431
impl<A, F: FnOnce() -> A> ExactSizeIterator for OnceWith<F> {
432432
fn len(&self) -> usize {
433433
self.gen.iter().len()
434434
}
435435
}
436436

437-
#[unstable(feature = "iter_once_with", issue = "57581")]
437+
#[stable(feature = "iter_once_with", since = "1.43.0")]
438438
impl<A, F: FnOnce() -> A> FusedIterator for OnceWith<F> {}
439439

440-
#[unstable(feature = "iter_once_with", issue = "57581")]
440+
#[stable(feature = "iter_once_with", since = "1.43.0")]
441441
unsafe impl<A, F: FnOnce() -> A> TrustedLen for OnceWith<F> {}
442442

443443
/// Creates an iterator that lazily generates a value exactly once by invoking
@@ -458,8 +458,6 @@ unsafe impl<A, F: FnOnce() -> A> TrustedLen for OnceWith<F> {}
458458
/// Basic usage:
459459
///
460460
/// ```
461-
/// #![feature(iter_once_with)]
462-
///
463461
/// use std::iter;
464462
///
465463
/// // one is the loneliest number
@@ -476,8 +474,6 @@ unsafe impl<A, F: FnOnce() -> A> TrustedLen for OnceWith<F> {}
476474
/// `.foorc`:
477475
///
478476
/// ```no_run
479-
/// #![feature(iter_once_with)]
480-
///
481477
/// use std::iter;
482478
/// use std::fs;
483479
/// use std::path::PathBuf;
@@ -500,7 +496,7 @@ unsafe impl<A, F: FnOnce() -> A> TrustedLen for OnceWith<F> {}
500496
/// }
501497
/// ```
502498
#[inline]
503-
#[unstable(feature = "iter_once_with", issue = "57581")]
499+
#[stable(feature = "iter_once_with", since = "1.43.0")]
504500
pub fn once_with<A, F: FnOnce() -> A>(gen: F) -> OnceWith<F> {
505501
OnceWith { gen: Some(gen) }
506502
}

src/libcore/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@
8787
#![feature(intrinsics)]
8888
#![feature(try_find)]
8989
#![feature(is_sorted)]
90-
#![feature(iter_once_with)]
9190
#![feature(lang_items)]
9291
#![feature(link_llvm_intrinsics)]
9392
#![feature(never_type)]

src/libcore/ptr/mod.rs

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,9 +1081,8 @@ pub(crate) unsafe fn align_offset<T: Sized>(p: *const T, a: usize) -> usize {
10811081
// uses e.g., subtraction `mod n`. It is entirely fine to do them `mod
10821082
// usize::max_value()` instead, because we take the result `mod n` at the end
10831083
// anyway.
1084-
inverse = inverse.wrapping_mul(2usize.wrapping_sub(x.wrapping_mul(inverse)))
1085-
& (going_mod - 1);
1086-
if going_mod > m {
1084+
inverse = inverse.wrapping_mul(2usize.wrapping_sub(x.wrapping_mul(inverse)));
1085+
if going_mod >= m {
10871086
return inverse & (m - 1);
10881087
}
10891088
going_mod = going_mod.wrapping_mul(going_mod);
@@ -1115,26 +1114,33 @@ pub(crate) unsafe fn align_offset<T: Sized>(p: *const T, a: usize) -> usize {
11151114
let gcdpow = intrinsics::cttz_nonzero(stride).min(intrinsics::cttz_nonzero(a));
11161115
let gcd = 1usize << gcdpow;
11171116

1118-
if p as usize & (gcd - 1) == 0 {
1117+
if p as usize & (gcd.wrapping_sub(1)) == 0 {
11191118
// This branch solves for the following linear congruence equation:
11201119
//
1121-
// $$ p + so 0 mod a $$
1120+
// ` p + so = 0 mod a `
11221121
//
1123-
// $p$ here is the pointer value, $s$ – stride of `T`, $o$ offset in `T`s, and $a$ – the
1122+
// `p` here is the pointer value, `s` - stride of `T`, `o` offset in `T`s, and `a` - the
11241123
// requested alignment.
11251124
//
1126-
// g = gcd(a, s)
1127-
// o = (a - (p mod a))/g * ((s/g)⁻¹ mod a)
1125+
// With `g = gcd(a, s)`, and the above asserting that `p` is also divisible by `g`, we can
1126+
// denote `a' = a/g`, `s' = s/g`, `p' = p/g`, then this becomes equivalent to:
11281127
//
1129-
// The first term is “the relative alignment of p to a”, the second term is “how does
1130-
// incrementing p by s bytes change the relative alignment of p”. Division by `g` is
1131-
// necessary to make this equation well formed if $a$ and $s$ are not co-prime.
1128+
// ` p' + s'o = 0 mod a' `
1129+
// ` o = (a' - (p' mod a')) * (s'^-1 mod a') `
11321130
//
1133-
// Furthermore, the result produced by this solution is not “minimal”, so it is necessary
1134-
// to take the result $o mod lcm(s, a)$. We can replace $lcm(s, a)$ with just a $a / g$.
1135-
let j = a.wrapping_sub(pmoda) >> gcdpow;
1136-
let k = smoda >> gcdpow;
1137-
return intrinsics::unchecked_rem(j.wrapping_mul(mod_inv(k, a)), a >> gcdpow);
1131+
// The first term is "the relative alignment of `p` to `a`" (divided by the `g`), the second
1132+
// term is "how does incrementing `p` by `s` bytes change the relative alignment of `p`" (again
1133+
// divided by `g`).
1134+
// Division by `g` is necessary to make the inverse well formed if `a` and `s` are not
1135+
// co-prime.
1136+
//
1137+
// Furthermore, the result produced by this solution is not "minimal", so it is necessary
1138+
// to take the result `o mod lcm(s, a)`. We can replace `lcm(s, a)` with just a `a'`.
1139+
let a2 = a >> gcdpow;
1140+
let a2minus1 = a2.wrapping_sub(1);
1141+
let s2 = smoda >> gcdpow;
1142+
let minusp2 = a2.wrapping_sub(pmoda >> gcdpow);
1143+
return (minusp2.wrapping_mul(mod_inv(s2, a2))) & a2minus1;
11381144
}
11391145

11401146
// Cannot be aligned at all.

src/libcore/tests/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#![feature(hashmap_internals)]
1414
#![feature(try_find)]
1515
#![feature(is_sorted)]
16-
#![feature(iter_once_with)]
1716
#![feature(pattern)]
1817
#![feature(range_is_empty)]
1918
#![feature(raw)]
Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1-
A lifetime name cannot be declared more than once in the same scope. For
2-
example:
1+
A lifetime was declared more than once in the same scope.
2+
3+
Erroneous code example:
34

45
```compile_fail,E0263
5-
// error, lifetime name `'a` declared twice in the same scope
6-
fn foo<'a, 'b, 'a>(x: &'a str, y: &'b str) { }
6+
fn foo<'a, 'b, 'a>(x: &'a str, y: &'b str, z: &'a str) { // error!
7+
}
8+
```
9+
10+
Two lifetimes cannot have the same name. To fix this example, change
11+
the second `'a` lifetime into something else (`'c` for example):
12+
13+
```
14+
fn foo<'a, 'b, 'c>(x: &'a str, y: &'b str, z: &'c str) { // ok!
15+
}
716
```

0 commit comments

Comments
 (0)