Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit df57f7b

Browse files
committed
Auto merge of rust-lang#103604 - JohnTitor:rollup-q4ns2gh, r=JohnTitor
Rollup of 10 pull requests Successful merges: - rust-lang#103432 (rustdoc: don't mark Box<T> as Iterator, Read, etc) - rust-lang#103526 (More dupe typos again) - rust-lang#103537 (rustdoc: combine shared CSS between `.*-line-numbers`) - rust-lang#103549 (llvm-16: Don't initialize removed legacy passes) - rust-lang#103558 (Update cargo) - rust-lang#103567 (ptr::eq: clarify that comparing dyn Trait is fragile) - rust-lang#103579 (:arrow_up: rust-analyzer) - rust-lang#103580 (Fix typo in docs for `guaranteed_ne`) - rust-lang#103596 (thread::set_name: debug-assert that things went well) - rust-lang#103598 (rustc_lexer::TokenKind improve docs) Failed merges: - rust-lang#103585 (Migrate source line numbers CSS to CSS variables) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 1898c34 + 132883e commit df57f7b

File tree

77 files changed

+2337
-1676
lines changed

Some content is hidden

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

77 files changed

+2337
-1676
lines changed

compiler/rustc_lexer/src/lib.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,29 +57,42 @@ pub enum TokenKind {
5757
// Multi-char tokens:
5858
/// "// comment"
5959
LineComment { doc_style: Option<DocStyle> },
60+
6061
/// `/* block comment */`
6162
///
62-
/// Block comments can be recursive, so the sequence like `/* /* */`
63+
/// Block comments can be recursive, so a sequence like `/* /* */`
6364
/// will not be considered terminated and will result in a parsing error.
6465
BlockComment { doc_style: Option<DocStyle>, terminated: bool },
65-
/// Any whitespace characters sequence.
66+
67+
/// Any whitespace character sequence.
6668
Whitespace,
69+
6770
/// "ident" or "continue"
68-
/// At this step keywords are also considered identifiers.
71+
///
72+
/// At this step, keywords are also considered identifiers.
6973
Ident,
74+
7075
/// Like the above, but containing invalid unicode codepoints.
7176
InvalidIdent,
77+
7278
/// "r#ident"
7379
RawIdent,
74-
/// An unknown prefix like `foo#`, `foo'`, `foo"`. Note that only the
80+
81+
/// An unknown prefix, like `foo#`, `foo'`, `foo"`.
82+
///
83+
/// Note that only the
7584
/// prefix (`foo`) is included in the token, not the separator (which is
7685
/// lexed as its own distinct token). In Rust 2021 and later, reserved
7786
/// prefixes are reported as errors; in earlier editions, they result in a
7887
/// (allowed by default) lint, and are treated as regular identifier
7988
/// tokens.
8089
UnknownPrefix,
81-
/// "12_u8", "1.0e-40", "b"123"". See `LiteralKind` for more details.
90+
91+
/// Examples: `"12_u8"`, `"1.0e-40"`, `b"123`.
92+
///
93+
/// See [LiteralKind] for more details.
8294
Literal { kind: LiteralKind, suffix_start: u32 },
95+
8396
/// "'a"
8497
Lifetime { starts_with_number: bool },
8598

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ extern "C" void LLVMInitializePasses() {
6969
initializeAnalysis(Registry);
7070
initializeTransformUtils(Registry);
7171
initializeInstCombine(Registry);
72+
#if LLVM_VERSION_LT(16, 0)
7273
initializeInstrumentation(Registry);
74+
#endif
7375
initializeTarget(Registry);
7476
}
7577

library/alloc/src/rc.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,8 +1110,8 @@ impl<T: ?Sized> Rc<T> {
11101110

11111111
#[inline]
11121112
#[stable(feature = "ptr_eq", since = "1.17.0")]
1113-
/// Returns `true` if the two `Rc`s point to the same allocation
1114-
/// (in a vein similar to [`ptr::eq`]).
1113+
/// Returns `true` if the two `Rc`s point to the same allocation in a vein similar to
1114+
/// [`ptr::eq`]. See [that function][`ptr::eq`] for caveats when comparing `dyn Trait` pointers.
11151115
///
11161116
/// # Examples
11171117
///
@@ -2419,9 +2419,9 @@ impl<T: ?Sized> Weak<T> {
24192419
}
24202420
}
24212421

2422-
/// Returns `true` if the two `Weak`s point to the same allocation (similar to
2423-
/// [`ptr::eq`]), or if both don't point to any allocation
2424-
/// (because they were created with `Weak::new()`).
2422+
/// Returns `true` if the two `Weak`s point to the same allocation similar to [`ptr::eq`], or if
2423+
/// both don't point to any allocation (because they were created with `Weak::new()`). See [that
2424+
/// function][`ptr::eq`] for caveats when comparing `dyn Trait` pointers.
24252425
///
24262426
/// # Notes
24272427
///

library/alloc/src/sync.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,8 +1117,8 @@ impl<T: ?Sized> Arc<T> {
11171117
drop(Weak { ptr: self.ptr });
11181118
}
11191119

1120-
/// Returns `true` if the two `Arc`s point to the same allocation
1121-
/// (in a vein similar to [`ptr::eq`]).
1120+
/// Returns `true` if the two `Arc`s point to the same allocation in a vein similar to
1121+
/// [`ptr::eq`]. See [that function][`ptr::eq`] for caveats when comparing `dyn Trait` pointers.
11221122
///
11231123
/// # Examples
11241124
///
@@ -2069,9 +2069,9 @@ impl<T: ?Sized> Weak<T> {
20692069
}
20702070
}
20712071

2072-
/// Returns `true` if the two `Weak`s point to the same allocation (similar to
2073-
/// [`ptr::eq`]), or if both don't point to any allocation
2074-
/// (because they were created with `Weak::new()`).
2072+
/// Returns `true` if the two `Weak`s point to the same allocation similar to [`ptr::eq`], or if
2073+
/// both don't point to any allocation (because they were created with `Weak::new()`). See [that
2074+
/// function][`ptr::eq`] for caveats when comparing `dyn Trait` pointers.
20752075
///
20762076
/// # Notes
20772077
///

library/core/src/ptr/const_ptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ impl<T: ?Sized> *const T {
802802

803803
/// Returns whether two pointers are guaranteed to be inequal.
804804
///
805-
/// At runtime this function behaves like `Some(self == other)`.
805+
/// At runtime this function behaves like `Some(self != other)`.
806806
/// However, in some contexts (e.g., compile-time evaluation),
807807
/// it is not always possible to determine inequality of two pointers, so this function may
808808
/// spuriously return `None` for pointers that later actually turn out to have its inequality known.

library/core/src/ptr/mod.rs

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,6 +1733,12 @@ pub(crate) unsafe fn align_offset<T: Sized>(p: *const T, a: usize) -> usize {
17331733
/// by their address rather than comparing the values they point to
17341734
/// (which is what the `PartialEq for &T` implementation does).
17351735
///
1736+
/// When comparing wide pointers, both the address and the metadata are tested for equality.
1737+
/// However, note that comparing trait object pointers (`*const dyn Trait`) is unrealiable: pointers
1738+
/// to values of the same underlying type can compare inequal (because vtables are duplicated in
1739+
/// multiple codegen units), and pointers to values of *different* underlying type can compare equal
1740+
/// (since identical vtables can be deduplicated within a codegen unit).
1741+
///
17361742
/// # Examples
17371743
///
17381744
/// ```
@@ -1759,41 +1765,6 @@ pub(crate) unsafe fn align_offset<T: Sized>(p: *const T, a: usize) -> usize {
17591765
/// assert!(!std::ptr::eq(&a[..2], &a[..3]));
17601766
/// assert!(!std::ptr::eq(&a[0..2], &a[1..3]));
17611767
/// ```
1762-
///
1763-
/// Traits are also compared by their implementation:
1764-
///
1765-
/// ```
1766-
/// #[repr(transparent)]
1767-
/// struct Wrapper { member: i32 }
1768-
///
1769-
/// trait Trait {}
1770-
/// impl Trait for Wrapper {}
1771-
/// impl Trait for i32 {}
1772-
///
1773-
/// let wrapper = Wrapper { member: 10 };
1774-
///
1775-
/// // Pointers have equal addresses.
1776-
/// assert!(std::ptr::eq(
1777-
/// &wrapper as *const Wrapper as *const u8,
1778-
/// &wrapper.member as *const i32 as *const u8
1779-
/// ));
1780-
///
1781-
/// // Objects have equal addresses, but `Trait` has different implementations.
1782-
/// assert!(!std::ptr::eq(
1783-
/// &wrapper as &dyn Trait,
1784-
/// &wrapper.member as &dyn Trait,
1785-
/// ));
1786-
/// assert!(!std::ptr::eq(
1787-
/// &wrapper as &dyn Trait as *const dyn Trait,
1788-
/// &wrapper.member as &dyn Trait as *const dyn Trait,
1789-
/// ));
1790-
///
1791-
/// // Converting the reference to a `*const u8` compares by address.
1792-
/// assert!(std::ptr::eq(
1793-
/// &wrapper as &dyn Trait as *const dyn Trait as *const u8,
1794-
/// &wrapper.member as &dyn Trait as *const dyn Trait as *const u8,
1795-
/// ));
1796-
/// ```
17971768
#[stable(feature = "ptr_eq", since = "1.17.0")]
17981769
#[inline]
17991770
pub fn eq<T: ?Sized>(a: *const T, b: *const T) -> bool {

library/core/src/ptr/mut_ptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ impl<T: ?Sized> *mut T {
730730

731731
/// Returns whether two pointers are guaranteed to be inequal.
732732
///
733-
/// At runtime this function behaves like `Some(self == other)`.
733+
/// At runtime this function behaves like `Some(self != other)`.
734734
/// However, in some contexts (e.g., compile-time evaluation),
735735
/// it is not always possible to determine inequality of two pointers, so this function may
736736
/// spuriously return `None` for pointers that later actually turn out to have its inequality known.

library/std/src/sync/mpsc/stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl<T> Packet<T> {
114114
match self.queue.producer_addition().cnt.fetch_add(1, Ordering::SeqCst) {
115115
// As described in the mod's doc comment, -1 == wakeup
116116
-1 => UpWoke(self.take_to_wake()),
117-
// As as described before, SPSC queues must be >= -2
117+
// As described before, SPSC queues must be >= -2
118118
-2 => UpSuccess,
119119

120120
// Be sure to preserve the disconnected state, and the return value

library/std/src/sys/unix/thread.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ impl Thread {
137137
unsafe {
138138
// Available since glibc 2.12, musl 1.1.16, and uClibc 1.0.20.
139139
let name = truncate_cstr(name, TASK_COMM_LEN);
140-
libc::pthread_setname_np(libc::pthread_self(), name.as_ptr());
140+
let res = libc::pthread_setname_np(libc::pthread_self(), name.as_ptr());
141+
// We have no good way of propagating errors here, but in debug-builds let's check that this actually worked.
142+
debug_assert_eq!(res, 0);
141143
}
142144
}
143145

@@ -152,19 +154,22 @@ impl Thread {
152154
pub fn set_name(name: &CStr) {
153155
unsafe {
154156
let name = truncate_cstr(name, libc::MAXTHREADNAMESIZE);
155-
libc::pthread_setname_np(name.as_ptr());
157+
let res = libc::pthread_setname_np(name.as_ptr());
158+
// We have no good way of propagating errors here, but in debug-builds let's check that this actually worked.
159+
debug_assert_eq!(res, 0);
156160
}
157161
}
158162

159163
#[cfg(target_os = "netbsd")]
160164
pub fn set_name(name: &CStr) {
161165
unsafe {
162166
let cname = CStr::from_bytes_with_nul_unchecked(b"%s\0".as_slice());
163-
libc::pthread_setname_np(
167+
let res = libc::pthread_setname_np(
164168
libc::pthread_self(),
165169
cname.as_ptr(),
166170
name.as_ptr() as *mut libc::c_void,
167171
);
172+
debug_assert_eq!(res, 0);
168173
}
169174
}
170175

@@ -177,9 +182,8 @@ impl Thread {
177182
}
178183

179184
if let Some(f) = pthread_setname_np.get() {
180-
unsafe {
181-
f(libc::pthread_self(), name.as_ptr());
182-
}
185+
let res = unsafe { f(libc::pthread_self(), name.as_ptr()) };
186+
debug_assert_eq!(res, 0);
183187
}
184188
}
185189

src/librustdoc/html/render/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,6 +1276,15 @@ fn notable_traits_decl(decl: &clean::FnDecl, cx: &Context<'_>) -> String {
12761276

12771277
if let Some((did, ty)) = decl.output.as_return().and_then(|t| Some((t.def_id(cx.cache())?, t)))
12781278
{
1279+
// Box has pass-through impls for Read, Write, Iterator, and Future when the
1280+
// boxed type implements one of those. We don't want to treat every Box return
1281+
// as being notably an Iterator (etc), though, so we exempt it. Pin has the same
1282+
// issue, with a pass-through impl for Future.
1283+
if Some(did) == cx.tcx().lang_items().owned_box()
1284+
|| Some(did) == cx.tcx().lang_items().pin_type()
1285+
{
1286+
return "".to_string();
1287+
}
12791288
if let Some(impls) = cx.cache().impls.get(&did) {
12801289
for i in impls {
12811290
let impl_ = i.inner_impl();

0 commit comments

Comments
 (0)