Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc6b3f3d

Browse files
committed
Auto merge ofrust-lang#127454 - matthiaskrgr:rollup-k3vfen2, r=matthiaskrgr
Rollup of 8 pull requestsSuccessful merges: -rust-lang#127179 (Print `TypeId` as hex for debugging) -rust-lang#127189 (LinkedList's Cursor: method to get a ref to the cursor's list) -rust-lang#127236 (doc: update config file path in platform-support/wasm32-wasip1-threads.md) -rust-lang#127297 (Improve std::Path's Hash quality by avoiding prefix collisions) -rust-lang#127308 (Attribute cleanups) -rust-lang#127354 (Describe Sized requirements for mem::offset_of) -rust-lang#127409 (Emit a wrap expr span_bug only if context is not tainted) -rust-lang#127447 (once_lock: make test not take as long in Miri)r? `@ghost``@rustbot` modify labels: rollup
2 parentsa86fd0f +35c5a45 commitc6b3f3d

File tree

6 files changed

+92
-11
lines changed

6 files changed

+92
-11
lines changed

‎alloc/src/collections/linked_list.rs‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,6 +1495,14 @@ impl<'a, T, A: Allocator> Cursor<'a, T, A> {
14951495
pubfnback(&self) ->Option<&'aT>{
14961496
self.list.back()
14971497
}
1498+
1499+
/// Provides a reference to the cursor's parent list.
1500+
#[must_use]
1501+
#[inline(always)]
1502+
#[unstable(feature ="linked_list_cursors", issue ="58533")]
1503+
pubfnas_list(&self) ->&'aLinkedList<T,A>{
1504+
self.list
1505+
}
14981506
}
14991507

15001508
impl<'a,T,A:Allocator>CursorMut<'a,T,A>{
@@ -1605,6 +1613,18 @@ impl<'a, T, A: Allocator> CursorMut<'a, T, A> {
16051613
pubfnas_cursor(&self) ->Cursor<'_,T,A>{
16061614
Cursor{list:self.list,current:self.current,index:self.index}
16071615
}
1616+
1617+
/// Provides a read-only reference to the cursor's parent list.
1618+
///
1619+
/// The lifetime of the returned reference is bound to that of the
1620+
/// `CursorMut`, which means it cannot outlive the `CursorMut` and that the
1621+
/// `CursorMut` is frozen for the lifetime of the reference.
1622+
#[must_use]
1623+
#[inline(always)]
1624+
#[unstable(feature ="linked_list_cursors", issue ="58533")]
1625+
pubfnas_list(&self) ->&LinkedList<T,A>{
1626+
self.list
1627+
}
16081628
}
16091629

16101630
// Now the list editing operations

‎core/src/any.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ impl hash::Hash for TypeId {
673673
#[stable(feature ="rust1", since ="1.0.0")]
674674
impl fmt::DebugforTypeId{
675675
fnfmt(&self,f:&mut fmt::Formatter<'_>) ->Result<(), fmt::Error>{
676-
f.debug_tuple("TypeId").field(&self.as_u128()).finish()
676+
write!(f,"TypeId({:#034x})",self.as_u128())
677677
}
678678
}
679679

‎core/src/mem/mod.rs‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,6 +1266,20 @@ impl<T> SizedTypeProperties for T {}
12661266
/// // ^^^ error[E0616]: field `private` of struct `Struct` is private
12671267
/// ```
12681268
///
1269+
/// Only [`Sized`] fields are supported, but the container may be unsized:
1270+
/// ```
1271+
/// # use core::mem;
1272+
/// #[repr(C)]
1273+
/// pub struct Struct {
1274+
/// a: u8,
1275+
/// b: [u8],
1276+
/// }
1277+
///
1278+
/// assert_eq!(mem::offset_of!(Struct, a), 0); // OK
1279+
/// // assert_eq!(mem::offset_of!(Struct, b), 1);
1280+
/// // ^^^ error[E0277]: doesn't have a size known at compile-time
1281+
/// ```
1282+
///
12691283
/// Note that type layout is, in general, [subject to change and
12701284
/// platform-specific](https://doc.rust-lang.org/reference/type-layout.html). If
12711285
/// layout stability is required, consider using an [explicit `repr` attribute].

‎std/src/path.rs‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3192,15 +3192,19 @@ impl Hash for Path {
31923192
let bytes =&bytes[prefix_len..];
31933193

31943194
letmut component_start =0;
3195-
letmut bytes_hashed =0;
3195+
// track some extra state to avoid prefix collisions.
3196+
// ["foo", "bar"] and ["foobar"], will have the same payload bytes
3197+
// but result in different chunk_bits
3198+
letmut chunk_bits:usize =0;
31963199

31973200
for iin0..bytes.len(){
31983201
let is_sep =if verbatim{is_verbatim_sep(bytes[i])}else{is_sep_byte(bytes[i])};
31993202
if is_sep{
32003203
if i > component_start{
32013204
let to_hash =&bytes[component_start..i];
3205+
chunk_bits = chunk_bits.wrapping_add(to_hash.len());
3206+
chunk_bits = chunk_bits.rotate_right(2);
32023207
h.write(to_hash);
3203-
bytes_hashed += to_hash.len();
32043208
}
32053209

32063210
// skip over separator and optionally a following CurDir item
@@ -3221,11 +3225,12 @@ impl Hash for Path {
32213225

32223226
if component_start < bytes.len(){
32233227
let to_hash =&bytes[component_start..];
3228+
chunk_bits = chunk_bits.wrapping_add(to_hash.len());
3229+
chunk_bits = chunk_bits.rotate_right(2);
32243230
h.write(to_hash);
3225-
bytes_hashed += to_hash.len();
32263231
}
32273232

3228-
h.write_usize(bytes_hashed);
3233+
h.write_usize(chunk_bits);
32293234
}
32303235
}
32313236

‎std/src/path/tests.rs‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,6 +1619,20 @@ pub fn test_compare() {
16191619
relative_from:Some("")
16201620
);
16211621

1622+
tc!("foo//","foo",
1623+
eq:true,
1624+
starts_with:true,
1625+
ends_with:true,
1626+
relative_from:Some("")
1627+
);
1628+
1629+
tc!("foo///","foo",
1630+
eq:true,
1631+
starts_with:true,
1632+
ends_with:true,
1633+
relative_from:Some("")
1634+
);
1635+
16221636
tc!("foo/.","foo",
16231637
eq:true,
16241638
starts_with:true,
@@ -1633,13 +1647,34 @@ pub fn test_compare() {
16331647
relative_from:Some("")
16341648
);
16351649

1650+
tc!("foo/.//bar","foo/bar",
1651+
eq:true,
1652+
starts_with:true,
1653+
ends_with:true,
1654+
relative_from:Some("")
1655+
);
1656+
1657+
tc!("foo//./bar","foo/bar",
1658+
eq:true,
1659+
starts_with:true,
1660+
ends_with:true,
1661+
relative_from:Some("")
1662+
);
1663+
16361664
tc!("foo/bar","foo",
16371665
eq:false,
16381666
starts_with:true,
16391667
ends_with:false,
16401668
relative_from:Some("bar")
16411669
);
16421670

1671+
tc!("foo/bar","foobar",
1672+
eq:false,
1673+
starts_with:false,
1674+
ends_with:false,
1675+
relative_from:None
1676+
);
1677+
16431678
tc!("foo/bar/baz","foo/bar",
16441679
eq:false,
16451680
starts_with:true,

‎std/src/sync/once_lock.rs‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,21 @@ use crate::sync::Once;
8080
/// static LIST: OnceList<u32> = OnceList::new();
8181
/// static COUNTER: AtomicU32 = AtomicU32::new(0);
8282
///
83-
/// let vec = (0..thread::available_parallelism().unwrap().get()).map(|_| thread::spawn(|| {
84-
/// while let i @ 0..=1000 = COUNTER.fetch_add(1, Ordering::Relaxed) {
85-
/// LIST.push(i);
83+
/// # const LEN: u32 = if cfg!(miri) { 50 } else { 1000 };
84+
/// # /*
85+
/// const LEN: u32 = 1000;
86+
/// # */
87+
/// thread::scope(|s| {
88+
/// for _ in 0..thread::available_parallelism().unwrap().get() {
89+
/// s.spawn(|| {
90+
/// while let i @ 0..LEN = COUNTER.fetch_add(1, Ordering::Relaxed) {
91+
/// LIST.push(i);
92+
/// }
93+
/// });
8694
/// }
87-
/// })).collect::<Vec<thread::JoinHandle<_>>>();
88-
/// vec.into_iter().for_each(|handle| handle.join().unwrap());
95+
/// });
8996
///
90-
/// for i in 0..=1000 {
97+
/// for i in 0..LEN {
9198
/// assert!(LIST.contains(&i));
9299
/// }
93100
///

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp