Skip to content

Commit 09b06f9

Browse files
committed
Auto merge of #75966 - Dylan-DPC:rollup-srfpces, r=Dylan-DPC
Rollup of 10 pull requests Successful merges: - #74730 (Hexagon libstd: update type defs) - #75758 (Fixes for VxWorks) - #75780 (Unconfuse Unpin docs a bit) - #75806 (Prevent automatic page change when using history) - #75818 (Update docs for SystemTime Windows implementation) - #75837 (Fix font color for help button in ayu and dark themes) - #75870 (Unify theme choices border color in ayu theme) - #75875 (Shorten liballoc vec resize intra-doc link) - #75953 (Fix swapped stability attributes for rustdoc lints) - #75958 (Avoid function-scoping global variables) Failed merges: r? @ghost
2 parents 45a83e9 + 8fd73aa commit 09b06f9

File tree

14 files changed

+86
-79
lines changed

14 files changed

+86
-79
lines changed

library/alloc/src/vec.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -1456,9 +1456,9 @@ impl<T> Vec<T> {
14561456
/// If `new_len` is less than `len`, the `Vec` is simply truncated.
14571457
///
14581458
/// This method uses a closure to create new values on every push. If
1459-
/// you'd rather [`Clone`] a given value, use [`resize`]. If you want
1460-
/// to use the [`Default`] trait to generate values, you can pass
1461-
/// [`Default::default()`] as the second argument.
1459+
/// you'd rather [`Clone`] a given value, use [`Vec::resize`]. If you
1460+
/// want to use the [`Default`] trait to generate values, you can
1461+
/// pass [`Default::default`] as the second argument.
14621462
///
14631463
/// # Examples
14641464
///
@@ -1472,8 +1472,6 @@ impl<T> Vec<T> {
14721472
/// vec.resize_with(4, || { p *= 2; p });
14731473
/// assert_eq!(vec, [2, 4, 8, 16]);
14741474
/// ```
1475-
///
1476-
/// [`resize`]: Vec::resize
14771475
#[stable(feature = "vec_resize_with", since = "1.33.0")]
14781476
pub fn resize_with<F>(&mut self, new_len: usize, f: F)
14791477
where

library/core/src/marker.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -728,23 +728,23 @@ unsafe impl<T: ?Sized> Freeze for &mut T {}
728728

729729
/// Types that can be safely moved after being pinned.
730730
///
731-
/// Since Rust itself has no notion of immovable types, and considers moves
732-
/// (e.g., through assignment or [`mem::replace`]) to always be safe,
733-
/// this trait cannot prevent types from moving by itself.
731+
/// Rust itself has no notion of immovable types, and considers moves (e.g.,
732+
/// through assignment or [`mem::replace`]) to always be safe.
734733
///
735-
/// Instead it is used to prevent moves through the type system,
736-
/// by controlling the behavior of pointers `P` wrapped in the [`Pin<P>`] wrapper,
737-
/// which "pin" the type in place by not allowing it to be moved out of them.
738-
/// See the [`pin module`] documentation for more information on pinning.
734+
/// The [`Pin`][Pin] type is used instead to prevent moves through the type
735+
/// system. Pointers `P<T>` wrapped in the [`Pin<P<T>>`][Pin] wrapper can't be
736+
/// moved out of. See the [`pin module`] documentation for more information on
737+
/// pinning.
739738
///
740-
/// Implementing this trait lifts the restrictions of pinning off a type,
741-
/// which then allows it to move out with functions such as [`mem::replace`].
739+
/// Implementing the `Unpin` trait for `T` lifts the restrictions of pinning off
740+
/// the type, which then allows moving `T` out of [`Pin<P<T>>`][Pin] with
741+
/// functions such as [`mem::replace`].
742742
///
743743
/// `Unpin` has no consequence at all for non-pinned data. In particular,
744744
/// [`mem::replace`] happily moves `!Unpin` data (it works for any `&mut T`, not
745-
/// just when `T: Unpin`). However, you cannot use
746-
/// [`mem::replace`] on data wrapped inside a [`Pin<P>`] because you cannot get the
747-
/// `&mut T` you need for that, and *that* is what makes this system work.
745+
/// just when `T: Unpin`). However, you cannot use [`mem::replace`] on data
746+
/// wrapped inside a [`Pin<P<T>>`][Pin] because you cannot get the `&mut T` you
747+
/// need for that, and *that* is what makes this system work.
748748
///
749749
/// So this, for example, can only be done on types implementing `Unpin`:
750750
///
@@ -765,8 +765,8 @@ unsafe impl<T: ?Sized> Freeze for &mut T {}
765765
/// This trait is automatically implemented for almost every type.
766766
///
767767
/// [`mem::replace`]: ../../std/mem/fn.replace.html
768-
/// [`Pin<P>`]: ../pin/struct.Pin.html
769-
/// [`pin module`]: ../../std/pin/index.html
768+
/// [Pin]: crate::pin::Pin
769+
/// [`pin module`]: crate::pin
770770
#[stable(feature = "pin", since = "1.33.0")]
771771
#[rustc_on_unimplemented(
772772
on(_Self = "std::future::Future", note = "consider using `Box::pin`",),

library/std/src/os/linux/raw.rs

+24-24
Original file line numberDiff line numberDiff line change
@@ -170,63 +170,63 @@ mod arch {
170170

171171
#[cfg(target_arch = "hexagon")]
172172
mod arch {
173-
use crate::os::raw::{c_int, c_long, c_longlong, c_ulonglong};
173+
use crate::os::raw::{c_int, c_long, c_uint};
174174

175175
#[stable(feature = "raw_ext", since = "1.1.0")]
176-
pub type blkcnt_t = c_longlong;
176+
pub type blkcnt_t = i64;
177177
#[stable(feature = "raw_ext", since = "1.1.0")]
178178
pub type blksize_t = c_long;
179179
#[stable(feature = "raw_ext", since = "1.1.0")]
180-
pub type ino_t = c_ulonglong;
180+
pub type ino_t = u64;
181181
#[stable(feature = "raw_ext", since = "1.1.0")]
182182
pub type nlink_t = c_uint;
183183
#[stable(feature = "raw_ext", since = "1.1.0")]
184-
pub type off_t = c_longlong;
184+
pub type off_t = i64;
185185
#[stable(feature = "raw_ext", since = "1.1.0")]
186-
pub type time_t = c_long;
186+
pub type time_t = i64;
187187

188188
#[repr(C)]
189189
#[derive(Clone)]
190190
#[stable(feature = "raw_ext", since = "1.1.0")]
191191
pub struct stat {
192192
#[stable(feature = "raw_ext", since = "1.1.0")]
193-
pub st_dev: ::dev_t,
193+
pub st_dev: u64,
194194
#[stable(feature = "raw_ext", since = "1.1.0")]
195-
pub st_ino: ::c_ulonglong,
195+
pub st_ino: u64,
196196
#[stable(feature = "raw_ext", since = "1.1.0")]
197-
pub st_mode: ::c_uint,
197+
pub st_mode: u32,
198198
#[stable(feature = "raw_ext", since = "1.1.0")]
199-
pub st_nlink: ::c_uint,
199+
pub st_nlink: u32,
200200
#[stable(feature = "raw_ext", since = "1.1.0")]
201-
pub st_uid: ::c_uint,
201+
pub st_uid: u32,
202202
#[stable(feature = "raw_ext", since = "1.1.0")]
203-
pub st_gid: ::c_uint,
203+
pub st_gid: u32,
204204
#[stable(feature = "raw_ext", since = "1.1.0")]
205-
pub st_rdev: ::c_ulonglong,
205+
pub st_rdev: u64,
206206
#[stable(feature = "raw_ext", since = "1.1.0")]
207-
pub __pad1: ::c_ulong,
207+
pub __pad1: u32,
208208
#[stable(feature = "raw_ext", since = "1.1.0")]
209-
pub st_size: ::c_longlong,
209+
pub st_size: i64,
210210
#[stable(feature = "raw_ext", since = "1.1.0")]
211-
pub st_blksize: ::blksize_t,
211+
pub st_blksize: i32,
212212
#[stable(feature = "raw_ext", since = "1.1.0")]
213-
pub __pad2: ::c_int,
213+
pub __pad2: i32,
214214
#[stable(feature = "raw_ext", since = "1.1.0")]
215-
pub st_blocks: ::blkcnt_t,
215+
pub st_blocks: i64,
216216
#[stable(feature = "raw_ext", since = "1.1.0")]
217-
pub st_atime: ::time_t,
217+
pub st_atime: i64,
218218
#[stable(feature = "raw_ext", since = "1.1.0")]
219-
pub st_atime_nsec: ::c_long,
219+
pub st_atime_nsec: c_long,
220220
#[stable(feature = "raw_ext", since = "1.1.0")]
221-
pub st_mtime: ::time_t,
221+
pub st_mtime: i64,
222222
#[stable(feature = "raw_ext", since = "1.1.0")]
223-
pub st_mtime_nsec: ::c_long,
223+
pub st_mtime_nsec: c_long,
224224
#[stable(feature = "raw_ext", since = "1.1.0")]
225-
pub st_ctime: ::time_t,
225+
pub st_ctime: i64,
226226
#[stable(feature = "raw_ext", since = "1.1.0")]
227-
pub st_ctime_nsec: ::c_long,
227+
pub st_ctime_nsec: c_long,
228228
#[stable(feature = "raw_ext", since = "1.1.0")]
229-
pub __pad3: [::c_int; 2],
229+
pub __pad3: [c_int; 2],
230230
}
231231
}
232232

library/std/src/sys/vxworks/fd.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl FileDesc {
5353
}
5454

5555
#[inline]
56-
fn is_read_vectored(&self) -> bool {
56+
pub fn is_read_vectored(&self) -> bool {
5757
true
5858
}
5959

library/std/src/sys/vxworks/process/process_common.rs

+3-12
Original file line numberDiff line numberDiff line change
@@ -351,28 +351,19 @@ impl ExitStatus {
351351
}
352352

353353
fn exited(&self) -> bool {
354-
/*unsafe*/
355-
{ libc::WIFEXITED(self.0) }
354+
libc::WIFEXITED(self.0)
356355
}
357356

358357
pub fn success(&self) -> bool {
359358
self.code() == Some(0)
360359
}
361360

362361
pub fn code(&self) -> Option<i32> {
363-
if self.exited() {
364-
Some(/*unsafe*/ { libc::WEXITSTATUS(self.0) })
365-
} else {
366-
None
367-
}
362+
if self.exited() { Some(libc::WEXITSTATUS(self.0)) } else { None }
368363
}
369364

370365
pub fn signal(&self) -> Option<i32> {
371-
if !self.exited() {
372-
Some(/*unsafe*/ { libc::WTERMSIG(self.0) })
373-
} else {
374-
None
375-
}
366+
if !self.exited() { Some(libc::WTERMSIG(self.0)) } else { None }
376367
}
377368
}
378369

library/std/src/sys/vxworks/thread_local_dtor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
#![unstable(feature = "thread_local_internals", issue = "none")]
33

44
pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) {
5-
use crate::sys_common::thread_local::register_dtor_fallback;
5+
use crate::sys_common::thread_local_dtor::register_dtor_fallback;
66
register_dtor_fallback(t, dtor);
77
}

library/std/src/time.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,15 @@ pub struct Instant(time::Instant);
159159
/// | DARWIN | [gettimeofday] |
160160
/// | VXWorks | [clock_gettime (Realtime Clock)] |
161161
/// | WASI | [__wasi_clock_time_get (Realtime Clock)] |
162-
/// | Windows | [GetSystemTimeAsFileTime] |
162+
/// | Windows | [GetSystemTimePreciseAsFileTime] / [GetSystemTimeAsFileTime] |
163163
///
164164
/// [clock_time_get (Realtime Clock)]: https://nuxi.nl/cloudabi/#clock_time_get
165165
/// [`insecure_time` usercall]: https://edp.fortanix.com/docs/api/fortanix_sgx_abi/struct.Usercalls.html#method.insecure_time
166166
/// [timekeeping in SGX]: https://edp.fortanix.com/docs/concepts/rust-std/#codestdtimecode
167167
/// [gettimeofday]: http://man7.org/linux/man-pages/man2/gettimeofday.2.html
168168
/// [clock_gettime (Realtime Clock)]: https://linux.die.net/man/3/clock_gettime
169169
/// [__wasi_clock_time_get (Realtime Clock)]: https://github.com/WebAssembly/WASI/blob/master/phases/snapshot/docs.md#clock_time_get
170+
/// [GetSystemTimePreciseAsFileTime]: https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtimepreciseasfiletime
170171
/// [GetSystemTimeAsFileTime]: https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtimeasfiletime
171172
///
172173
/// **Disclaimer:** These system calls might change over time.

src/bootstrap/cc_detect.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ pub fn find(build: &mut Build) {
132132
false
133133
};
134134

135-
if cxx_configured {
135+
// for VxWorks, record CXX compiler which will be used in lib.rs:linker()
136+
if cxx_configured || target.contains("vxworks") {
136137
let compiler = cfg.get_compiler();
137138
build.cxx.insert(target, compiler);
138139
}

src/bootstrap/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,10 @@ impl Build {
854854
if let Some(linker) = self.config.target_config.get(&target).and_then(|c| c.linker.as_ref())
855855
{
856856
Some(linker)
857+
} else if target.contains("vxworks") {
858+
// need to use CXX compiler as linker to resolve the exception functions
859+
// that are only existed in CXX libraries
860+
Some(self.cxx[&target].path())
857861
} else if target != self.config.build
858862
&& util::use_host_linker(target)
859863
&& !target.contains("msvc")

src/librustdoc/html/static/main.js

+14-4
Original file line numberDiff line numberDiff line change
@@ -1576,14 +1576,21 @@ function defocusSearchBar() {
15761576
}
15771577

15781578
function showResults(results) {
1579-
if (results.others.length === 1 &&
1580-
getCurrentValue("rustdoc-go-to-only-result") === "true") {
1579+
var search = getSearchElement();
1580+
if (results.others.length === 1
1581+
&& getCurrentValue("rustdoc-go-to-only-result") === "true"
1582+
// By default, the search DOM element is "empty" (meaning it has no children not
1583+
// text content). Once a search has been run, it won't be empty, even if you press
1584+
// ESC or empty the search input (which also "cancels" the search).
1585+
&& (!search.firstChild || search.firstChild.innerText !== getSearchLoadingText()))
1586+
{
15811587
var elem = document.createElement("a");
15821588
elem.href = results.others[0].href;
15831589
elem.style.display = "none";
15841590
// For firefox, we need the element to be in the DOM so it can be clicked.
15851591
document.body.appendChild(elem);
15861592
elem.click();
1593+
return;
15871594
}
15881595
var query = getQuery(search_input.value);
15891596

@@ -1602,7 +1609,6 @@ function defocusSearchBar() {
16021609
"</div><div id=\"results\">" +
16031610
ret_others[0] + ret_in_args[0] + ret_returned[0] + "</div>";
16041611

1605-
var search = getSearchElement();
16061612
search.innerHTML = output;
16071613
showSearchResults(search);
16081614
var tds = search.getElementsByTagName("td");
@@ -2679,6 +2685,10 @@ function defocusSearchBar() {
26792685
}
26802686
}
26812687

2688+
function getSearchLoadingText() {
2689+
return "Loading search results...";
2690+
}
2691+
26822692
if (search_input) {
26832693
search_input.onfocus = function() {
26842694
putBackSearch(this);
@@ -2688,7 +2698,7 @@ function defocusSearchBar() {
26882698
var params = getQueryStringParams();
26892699
if (params && params.search) {
26902700
var search = getSearchElement();
2691-
search.innerHTML = "<h3 style=\"text-align: center;\">Loading search results...</h3>";
2701+
search.innerHTML = "<h3 style=\"text-align: center;\">" + getSearchLoadingText() + "</h3>";
26922702
showSearchResults(search);
26932703
}
26942704

src/librustdoc/html/static/themes/ayu.css

+2-1
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,7 @@ kbd {
495495
#theme-picker, #settings-menu, .help-button {
496496
border-color: #5c6773;
497497
background-color: #0f1419;
498+
color: #fff;
498499
}
499500

500501
#theme-picker > img, #settings-menu > img {
@@ -513,7 +514,7 @@ kbd {
513514
}
514515

515516
#theme-choices > button:not(:first-child) {
516-
border-top-color: #c5c5c5;
517+
border-top-color: #5c6773;
517518
}
518519

519520
#theme-choices > button:hover, #theme-choices > button:focus {

src/librustdoc/html/static/themes/dark.css

+1
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ kbd {
389389
#theme-picker, #settings-menu, .help-button {
390390
border-color: #e0e0e0;
391391
background: #f0f0f0;
392+
color: #000;
392393
}
393394

394395
#theme-picker:hover, #theme-picker:focus,

src/librustdoc/passes/doc_test_lints.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! This pass is overloaded and runs two different lints.
22
//!
3-
//! - MISSING_DOC_CODE_EXAMPLES: this looks for public items missing doc-tests
4-
//! - PRIVATE_DOC_TESTS: this looks for private items with doc-tests.
3+
//! - MISSING_DOC_CODE_EXAMPLES: this lint is **UNSTABLE** and looks for public items missing doc-tests
4+
//! - PRIVATE_DOC_TESTS: this lint is **STABLE** and looks for private items with doc-tests.
55
66
use super::{span_of_attrs, Pass};
77
use crate::clean;
@@ -89,7 +89,9 @@ pub fn look_for_tests<'tcx>(cx: &DocContext<'tcx>, dox: &str, item: &Item) {
8989

9090
find_testable_code(&dox, &mut tests, ErrorCodes::No, false, None);
9191

92-
if tests.found_tests == 0 {
92+
if tests.found_tests == 0
93+
&& rustc_feature::UnstableFeatures::from_environment().is_nightly_build()
94+
{
9395
if should_have_doc_example(&item.inner) {
9496
debug!("reporting error for {:?} (hir_id={:?})", item, hir_id);
9597
let sp = span_of_attrs(&item.attrs).unwrap_or(item.source.span());
@@ -100,9 +102,7 @@ pub fn look_for_tests<'tcx>(cx: &DocContext<'tcx>, dox: &str, item: &Item) {
100102
|lint| lint.build("missing code example in this documentation").emit(),
101103
);
102104
}
103-
} else if rustc_feature::UnstableFeatures::from_environment().is_nightly_build()
104-
&& tests.found_tests > 0
105-
&& !cx.renderinfo.borrow().access_levels.is_public(item.def_id)
105+
} else if tests.found_tests > 0 && !cx.renderinfo.borrow().access_levels.is_public(item.def_id)
106106
{
107107
cx.tcx.struct_span_lint_hir(
108108
lint::builtin::PRIVATE_DOC_TESTS,

src/tools/publish_toolstate.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,12 @@ def update_latest(
275275
return message
276276

277277

278-
def main():
278+
# Warning: Do not try to add a function containing the body of this try block.
279+
# There are variables declared within that are implicitly global; it is unknown
280+
# which ones precisely but at least this is true for `github_token`.
281+
try:
282+
if __name__ != '__main__':
283+
exit(0)
279284
repo = os.environ.get('TOOLSTATE_VALIDATE_MAINTAINERS_REPO')
280285
if repo:
281286
github_token = os.environ.get('TOOLSTATE_REPO_ACCESS_TOKEN')
@@ -342,11 +347,6 @@ def main():
342347
}
343348
))
344349
response.read()
345-
346-
347-
if __name__ == '__main__':
348-
try:
349-
main()
350-
except urllib2.HTTPError as e:
351-
print("HTTPError: %s\n%s" % (e, e.read()))
352-
raise
350+
except urllib2.HTTPError as e:
351+
print("HTTPError: %s\n%s" % (e, e.read()))
352+
raise

0 commit comments

Comments
 (0)