Skip to content

Commit df57f7b

Browse files
committed
Auto merge of #103604 - JohnTitor:rollup-q4ns2gh, r=JohnTitor
Rollup of 10 pull requests Successful merges: - #103432 (rustdoc: don't mark Box<T> as Iterator, Read, etc) - #103526 (More dupe typos again) - #103537 (rustdoc: combine shared CSS between `.*-line-numbers`) - #103549 (llvm-16: Don't initialize removed legacy passes) - #103558 (Update cargo) - #103567 (ptr::eq: clarify that comparing dyn Trait is fragile) - #103579 (:arrow_up: rust-analyzer) - #103580 (Fix typo in docs for `guaranteed_ne`) - #103596 (thread::set_name: debug-assert that things went well) - #103598 (rustc_lexer::TokenKind improve docs) Failed merges: - #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

+18-5
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

+2
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

+5-5
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

+5-5
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

+1-1
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

+6-35
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

+1-1
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

+1-1
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

+10-6
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

+9
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();

src/librustdoc/html/static/css/rustdoc.css

+19-32
Original file line numberDiff line numberDiff line change
@@ -549,47 +549,38 @@ ul.block, .block li {
549549
margin-bottom: 0px;
550550
}
551551

552-
pre.example-line-numbers {
553-
overflow: initial;
554-
border: 1px solid;
555-
padding: 13px 8px;
556-
text-align: right;
557-
border-top-left-radius: 5px;
558-
border-bottom-left-radius: 5px;
559-
}
560-
561-
.src-line-numbers {
562-
text-align: right;
563-
}
564-
.rustdoc:not(.source) .example-wrap > pre:not(.example-line-numbers) {
565-
width: 100%;
566-
overflow-x: auto;
567-
}
568-
569-
.rustdoc:not(.source) .example-wrap > pre.src-line-numbers {
570-
width: auto;
571-
overflow-x: visible;
572-
}
573-
574552
.rustdoc .example-wrap > pre {
575553
margin: 0;
554+
flex-grow: 1;
555+
overflow-x: auto;
576556
}
577557

578-
.search-loading {
579-
text-align: center;
580-
}
581-
582-
.content > .example-wrap pre.src-line-numbers {
583-
position: relative;
558+
.rustdoc .example-wrap > pre.example-line-numbers,
559+
.rustdoc .example-wrap > pre.src-line-numbers {
560+
flex-grow: 0;
561+
overflow: initial;
562+
text-align: right;
584563
-webkit-user-select: none;
585564
-moz-user-select: none;
586565
-ms-user-select: none;
587566
user-select: none;
588567
}
568+
569+
.example-line-numbers {
570+
border: 1px solid;
571+
padding: 13px 8px;
572+
border-top-left-radius: 5px;
573+
border-bottom-left-radius: 5px;
574+
}
575+
589576
.src-line-numbers span {
590577
cursor: pointer;
591578
}
592579

580+
.search-loading {
581+
text-align: center;
582+
}
583+
593584
.docblock-short {
594585
overflow-wrap: break-word;
595586
overflow-wrap: anywhere;
@@ -2033,10 +2024,6 @@ in storage.js
20332024
padding-bottom: 0;
20342025
}
20352026

2036-
.scraped-example:not(.expanded) .code-wrapper pre.src-line-numbers {
2037-
overflow-x: hidden;
2038-
}
2039-
20402027
.scraped-example .code-wrapper .prev {
20412028
position: absolute;
20422029
top: 0.25em;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#![feature(doc_notable_trait)]
2+
#![feature(lang_items)]
3+
#![feature(no_core)]
4+
#![no_core]
5+
#[lang = "owned_box"]
6+
pub struct Box<T>;
7+
8+
impl<T> Box<T> {
9+
pub fn new(x: T) -> Box<T> {
10+
Box
11+
}
12+
}
13+
14+
#[doc(notable_trait)]
15+
pub trait FakeIterator {}
16+
17+
impl<I: FakeIterator> FakeIterator for Box<I> {}
18+
19+
#[lang = "pin"]
20+
pub struct Pin<T>;
21+
22+
impl<T> Pin<T> {
23+
pub fn new(x: T) -> Pin<T> {
24+
Pin
25+
}
26+
}
27+
28+
impl<I: FakeIterator> FakeIterator for Pin<I> {}
29+
30+
// @!has doc_notable_trait_box_is_not_an_iterator/fn.foo.html '//*' 'Notable'
31+
pub fn foo<T>(x: T) -> Box<T> {
32+
Box::new(x)
33+
}
34+
35+
// @!has doc_notable_trait_box_is_not_an_iterator/fn.bar.html '//*' 'Notable'
36+
pub fn bar<T>(x: T) -> Pin<T> {
37+
Pin::new(x)
38+
}

src/tools/rust-analyzer/.github/workflows/publish.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ name: publish
22
on:
33
workflow_dispatch: # We can add version input when 1.0 is released and scheduled releases are removed
44

5-
# schedule:
6-
# - cron: "0 0 * * *" # midnight UTC
5+
# schedule:
6+
# - cron: "0 0 * * *" # midnight UTC
77

88
push:
99
branches:
@@ -50,5 +50,7 @@ jobs:
5050
cargo workspaces rename --from test-utils test_utils
5151
cargo workspaces rename --from text-edit text_edit
5252
cargo workspaces rename ra_ap_%n
53+
# Remove library crates from the workspaces so we don't auto-publish them as well
54+
sed -i 's/ "lib\/\*",//' ./Cargo.toml
5355
find crates/rust-analyzer -type f -name '*.rs' -exec sed -i 's/rust_analyzer/ra_ap_rust_analyzer/g' {} +
5456
cargo workspaces publish --yes --force '*' --exact --no-git-commit --allow-dirty --skip-published custom 0.0.$PATCH

0 commit comments

Comments
 (0)