Skip to content

Commit 8305398

Browse files
committed
Auto merge of rust-lang#96178 - Dylan-DPC:rollup-6z8pcob, r=Dylan-DPC
Rollup of 5 pull requests Successful merges: - rust-lang#96032 (Update books) - rust-lang#96136 (Reword clarification on lifetime for ptr->ref safety docs) - rust-lang#96143 (Fix snapshot --bless not working anymore in htmldocck) - rust-lang#96148 (Use revisions instead of nll compare mode for `/self/` ui tests) - rust-lang#96156 (Replace u8to64_le macro with u64::from_le_bytes) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 0516711 + 55e3997 commit 8305398

Some content is hidden

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

46 files changed

+387
-237
lines changed

library/core/src/ptr/const_ptr.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ impl<T: ?Sized> *const T {
295295
///
296296
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
297297
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
298-
/// In particular, for the duration of this lifetime, the memory the pointer points to must
298+
/// In particular, while this reference exists, the memory the pointer points to must
299299
/// not get mutated (except inside `UnsafeCell`).
300300
///
301301
/// This applies even if the result of this method is unused!
@@ -358,7 +358,7 @@ impl<T: ?Sized> *const T {
358358
///
359359
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
360360
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
361-
/// In particular, for the duration of this lifetime, the memory the pointer points to must
361+
/// In particular, while this reference exists, the memory the pointer points to must
362362
/// not get mutated (except inside `UnsafeCell`).
363363
///
364364
/// This applies even if the result of this method is unused!
@@ -1188,7 +1188,7 @@ impl<T> *const [T] {
11881188
///
11891189
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
11901190
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
1191-
/// In particular, for the duration of this lifetime, the memory the pointer points to must
1191+
/// In particular, while this reference exists, the memory the pointer points to must
11921192
/// not get mutated (except inside `UnsafeCell`).
11931193
///
11941194
/// This applies even if the result of this method is unused!

library/core/src/ptr/mut_ptr.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ impl<T: ?Sized> *mut T {
302302
///
303303
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
304304
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
305-
/// In particular, for the duration of this lifetime, the memory the pointer points to must
305+
/// In particular, while this reference exists, the memory the pointer points to must
306306
/// not get mutated (except inside `UnsafeCell`).
307307
///
308308
/// This applies even if the result of this method is unused!
@@ -368,7 +368,7 @@ impl<T: ?Sized> *mut T {
368368
///
369369
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
370370
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
371-
/// In particular, for the duration of this lifetime, the memory the pointer points to must
371+
/// In particular, while this reference exists, the memory the pointer points to must
372372
/// not get mutated (except inside `UnsafeCell`).
373373
///
374374
/// This applies even if the result of this method is unused!
@@ -550,7 +550,7 @@ impl<T: ?Sized> *mut T {
550550
///
551551
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
552552
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
553-
/// In particular, for the duration of this lifetime, the memory the pointer points to must
553+
/// In particular, while this reference exists, the memory the pointer points to must
554554
/// not get accessed (read or written) through any other pointer.
555555
///
556556
/// This applies even if the result of this method is unused!
@@ -615,7 +615,7 @@ impl<T: ?Sized> *mut T {
615615
///
616616
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
617617
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
618-
/// In particular, for the duration of this lifetime, the memory the pointer points to must
618+
/// In particular, while this reference exists, the memory the pointer points to must
619619
/// not get accessed (read or written) through any other pointer.
620620
///
621621
/// This applies even if the result of this method is unused!
@@ -1461,7 +1461,7 @@ impl<T> *mut [T] {
14611461
///
14621462
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
14631463
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
1464-
/// In particular, for the duration of this lifetime, the memory the pointer points to must
1464+
/// In particular, while this reference exists, the memory the pointer points to must
14651465
/// not get mutated (except inside `UnsafeCell`).
14661466
///
14671467
/// This applies even if the result of this method is unused!
@@ -1513,7 +1513,7 @@ impl<T> *mut [T] {
15131513
///
15141514
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
15151515
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
1516-
/// In particular, for the duration of this lifetime, the memory the pointer points to must
1516+
/// In particular, while this reference exists, the memory the pointer points to must
15171517
/// not get accessed (read or written) through any other pointer.
15181518
///
15191519
/// This applies even if the result of this method is unused!

library/core/src/ptr/non_null.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl<T: Sized> NonNull<T> {
114114
///
115115
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
116116
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
117-
/// In particular, for the duration of this lifetime, the memory the pointer points to must
117+
/// In particular, while this reference exists, the memory the pointer points to must
118118
/// not get mutated (except inside `UnsafeCell`).
119119
///
120120
/// This applies even if the result of this method is unused!
@@ -148,7 +148,7 @@ impl<T: Sized> NonNull<T> {
148148
///
149149
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
150150
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
151-
/// In particular, for the duration of this lifetime, the memory the pointer points to must
151+
/// In particular, while this reference exists, the memory the pointer points to must
152152
/// not get accessed (read or written) through any other pointer.
153153
///
154154
/// This applies even if the result of this method is unused!
@@ -350,7 +350,7 @@ impl<T: ?Sized> NonNull<T> {
350350
///
351351
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
352352
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
353-
/// In particular, for the duration of this lifetime, the memory the pointer points to must
353+
/// In particular, while this reference exists, the memory the pointer points to must
354354
/// not get mutated (except inside `UnsafeCell`).
355355
///
356356
/// This applies even if the result of this method is unused!
@@ -400,7 +400,7 @@ impl<T: ?Sized> NonNull<T> {
400400
///
401401
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
402402
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
403-
/// In particular, for the duration of this lifetime, the memory the pointer points to must
403+
/// In particular, while this reference exists, the memory the pointer points to must
404404
/// not get accessed (read or written) through any other pointer.
405405
///
406406
/// This applies even if the result of this method is unused!
@@ -580,7 +580,7 @@ impl<T> NonNull<[T]> {
580580
///
581581
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
582582
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
583-
/// In particular, for the duration of this lifetime, the memory the pointer points to must
583+
/// In particular, while this reference exists, the memory the pointer points to must
584584
/// not get mutated (except inside `UnsafeCell`).
585585
///
586586
/// This applies even if the result of this method is unused!
@@ -626,7 +626,7 @@ impl<T> NonNull<[T]> {
626626
///
627627
/// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
628628
/// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
629-
/// In particular, for the duration of this lifetime, the memory the pointer points to must
629+
/// In particular, while this reference exists, the memory the pointer points to must
630630
/// not get accessed (read or written) through any other pointer.
631631
///
632632
/// This applies even if the result of this method is unused!

library/core/tests/hash/sip.rs

+2-24
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,6 @@ impl<'a> Hash for Bytes<'a> {
1515
}
1616
}
1717

18-
macro_rules! u8to64_le {
19-
($buf:expr, $i:expr) => {
20-
$buf[0 + $i] as u64
21-
| ($buf[1 + $i] as u64) << 8
22-
| ($buf[2 + $i] as u64) << 16
23-
| ($buf[3 + $i] as u64) << 24
24-
| ($buf[4 + $i] as u64) << 32
25-
| ($buf[5 + $i] as u64) << 40
26-
| ($buf[6 + $i] as u64) << 48
27-
| ($buf[7 + $i] as u64) << 56
28-
};
29-
($buf:expr, $i:expr, $len:expr) => {{
30-
let mut t = 0;
31-
let mut out = 0;
32-
while t < $len {
33-
out |= ($buf[t + $i] as u64) << t * 8;
34-
t += 1;
35-
}
36-
out
37-
}};
38-
}
39-
4018
fn hash_with<H: Hasher, T: Hash>(mut st: H, x: &T) -> u64 {
4119
x.hash(&mut st);
4220
st.finish()
@@ -123,7 +101,7 @@ fn test_siphash_1_3() {
123101
let mut state_inc = SipHasher13::new_with_keys(k0, k1);
124102

125103
while t < 64 {
126-
let vec = u8to64_le!(vecs[t], 0);
104+
let vec = u64::from_le_bytes(vecs[t]);
127105
let out = hash_with(SipHasher13::new_with_keys(k0, k1), &Bytes(&buf));
128106
assert_eq!(vec, out);
129107

@@ -217,7 +195,7 @@ fn test_siphash_2_4() {
217195
let mut state_inc = SipHasher::new_with_keys(k0, k1);
218196

219197
while t < 64 {
220-
let vec = u8to64_le!(vecs[t], 0);
198+
let vec = u64::from_le_bytes(vecs[t]);
221199
let out = hash_with(SipHasher::new_with_keys(k0, k1), &Bytes(&buf));
222200
assert_eq!(vec, out);
223201

src/doc/book

Submodule book updated 37 files

src/doc/nomicon

src/etc/htmldocck.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,12 @@ def check_snapshot(snapshot_name, actual_tree, normalize_to_text):
423423
else:
424424
actual_str = flatten(actual_tree)
425425

426+
# Conditions:
427+
# 1. Is --bless
428+
# 2. Are actual and expected tree different
429+
# 3. Are actual and expected text different
426430
if not expected_str \
427-
or (not normalize_to_text and
431+
or (not normalize_to_text and \
428432
not compare_tree(make_xml(actual_str), make_xml(expected_str), stderr)) \
429433
or (normalize_to_text and actual_str != expected_str):
430434

src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.stderr src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.base.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
error[E0623]: lifetime mismatch
2-
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:8:52
2+
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:11:52
33
|
44
LL | async fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f }
55
| ---- ---- ^ ...but data from `f` is returned here
66
| |
77
| this parameter and the return type are declared with different lifetimes...
88

99
error[E0623]: lifetime mismatch
10-
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:11:82
10+
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:15:82
1111
|
1212
LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) }
1313
| ---- ----------------- ^ ...but data from `f` is returned here
1414
| |
1515
| this parameter and the return type are declared with different lifetimes...
1616

1717
error[E0623]: lifetime mismatch
18-
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:17:64
18+
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:22:64
1919
|
2020
LL | async fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg }
2121
| ------ --- ^^^ ...but data from `arg` is returned here

src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.nll.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: lifetime may not live long enough
2-
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:8:52
2+
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:11:52
33
|
44
LL | async fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f }
55
| - - ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
@@ -8,7 +8,7 @@ LL | async fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f }
88
| let's call the lifetime of this reference `'2`
99

1010
error: lifetime may not live long enough
11-
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:11:75
11+
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:15:75
1212
|
1313
LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) }
1414
| - - ^^^^^^^^^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
@@ -17,7 +17,7 @@ LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (
1717
| let's call the lifetime of this reference `'2`
1818

1919
error: lifetime may not live long enough
20-
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:17:64
20+
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:22:64
2121
|
2222
LL | async fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg }
2323
| -- - ^^^ associated function was supposed to return data with lifetime `'1` but it is returning data with lifetime `'a`
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
// edition:2018
2+
// revisions: base nll
3+
// ignore-compare-mode-nll
4+
//[nll] compile-flags: -Z borrowck=mir
25

36
use std::pin::Pin;
47

58
struct Foo;
69

710
impl Foo {
811
async fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f }
9-
//~^ ERROR lifetime mismatch
12+
//[base]~^ ERROR lifetime mismatch
13+
//[nll]~^^ lifetime may not live long enough
1014

1115
async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) }
12-
//~^ ERROR lifetime mismatch
16+
//[base]~^ ERROR lifetime mismatch
17+
//[nll]~^^ lifetime may not live long enough
1318
}
1419

1520
type Alias<T> = Pin<T>;
1621
impl Foo {
17-
async fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg } //~ ERROR E0623
22+
async fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg }
23+
//[base]~^ ERROR E0623
24+
//[nll]~^^ lifetime may not live long enough
1825
}
1926

2027
fn main() {}

src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch.stderr src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch.base.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0623]: lifetime mismatch
2-
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:6:46
2+
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:10:46
33
|
44
LL | fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f }
55
| ---- ---- ^ ...but data from `f` is returned here
@@ -13,7 +13,7 @@ LL | fn a<'a>(self: Pin<&'a Foo>, f: &'a Foo) -> &Foo { f }
1313
| ++++ ++ ++
1414

1515
error[E0623]: lifetime mismatch
16-
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:8:76
16+
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:14:76
1717
|
1818
LL | fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) }
1919
| ---- ----------------- ^ ...but data from `f` is returned here
@@ -27,7 +27,7 @@ LL | fn c<'a>(self: Pin<&'a Self>, f: &'a Foo, g: &Foo) -> (Pin<&Foo>, &Foo)
2727
| ++++ ++ ++
2828

2929
error[E0623]: lifetime mismatch
30-
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:13:58
30+
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:21:58
3131
|
3232
LL | fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg }
3333
| ------ --- ^^^ ...but data from `arg` is returned here

src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch.nll.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: lifetime may not live long enough
2-
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:6:46
2+
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:10:46
33
|
44
LL | fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f }
55
| - - ^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
@@ -8,7 +8,7 @@ LL | fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f }
88
| let's call the lifetime of this reference `'2`
99

1010
error: lifetime may not live long enough
11-
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:8:69
11+
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:14:69
1212
|
1313
LL | fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) }
1414
| - - ^^^^^^^^^ associated function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
@@ -17,7 +17,7 @@ LL | fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self,
1717
| let's call the lifetime of this reference `'2`
1818

1919
error: lifetime may not live long enough
20-
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:13:58
20+
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:21:58
2121
|
2222
LL | fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg }
2323
| -- ---- has type `Pin<&'1 Foo>` ^^^ associated function was supposed to return data with lifetime `'1` but it is returning data with lifetime `'a`
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
1+
// revisions: base nll
2+
// ignore-compare-mode-nll
3+
//[nll] compile-flags: -Z borrowck=mir
4+
15
use std::pin::Pin;
26

37
struct Foo;
48

59
impl Foo {
6-
fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f } //~ ERROR E0623
10+
fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f }
11+
//[base]~^ ERROR E0623
12+
//[nll]~^^ lifetime may not live long enough
713

8-
fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } //~ ERROR E0623
14+
fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) }
15+
//[base]~^ ERROR E0623
16+
//[nll]~^^ lifetime may not live long enough
917
}
1018

1119
type Alias<T> = Pin<T>;
1220
impl Foo {
13-
fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg } //~ ERROR E0623
21+
fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg }
22+
//[base]~^ ERROR E0623
23+
//[nll]~^^ lifetime may not live long enough
1424
}
1525

1626
fn main() {}

0 commit comments

Comments
 (0)