Skip to content

Commit 26b4cb4

Browse files
committed
Auto merge of #59050 - Centril:rollup, r=Centril
Rollup of 13 pull requests Successful merges: - #58518 (Use early unwraps instead of bubbling up errors just to unwrap in the end) - #58626 (rustdoc: add option to calculate "documentation coverage") - #58629 (rust-lldb: fix crash when printing empty string) - #58660 (MaybeUninit: add read_initialized, add examples) - #58670 (fixes #52482) - #58676 (look for python2 symlinks before bootstrap python) - #58679 (Refactor passes and pass execution to be more parallel) - #58750 (Make `Unique::as_ptr`, `NonNull::dangling` and `NonNull::cast` const) - #58762 (Mention `unwind(aborts)` in diagnostics for `#[unwind]`) - #58924 (Add as_slice() to slice::IterMut and vec::Drain) - #58990 (Actually publish miri in the manifest) - #59018 (std: Delete a by-definition spuriously failing test) - #59045 (Expose new_sub_parser_from_file) Failed merges: r? @ghost
2 parents e1b8898 + 4eb762a commit 26b4cb4

File tree

86 files changed

+1394
-390
lines changed

Some content is hidden

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

86 files changed

+1394
-390
lines changed

config.toml.example

+3
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@
164164
# Python interpreter to use for various tasks throughout the build, notably
165165
# rustdoc tests, the lldb python interpreter, and some dist bits and pieces.
166166
# Note that Python 2 is currently required.
167+
#
168+
# Defaults to python2.7, then python2. If neither executable can be found, then
169+
# it defaults to the Python interpreter used to execute x.py.
167170
#python = "python2.7"
168171

169172
# Force Cargo to check that Cargo.lock describes the precise dependency

src/bootstrap/sanity.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,17 @@ impl Finder {
3434

3535
fn maybe_have<S: AsRef<OsStr>>(&mut self, cmd: S) -> Option<PathBuf> {
3636
let cmd: OsString = cmd.as_ref().into();
37-
let path = self.path.clone();
37+
let path = &self.path;
3838
self.cache.entry(cmd.clone()).or_insert_with(|| {
39-
for path in env::split_paths(&path) {
39+
for path in env::split_paths(path) {
4040
let target = path.join(&cmd);
41-
let mut cmd_alt = cmd.clone();
42-
cmd_alt.push(".exe");
43-
if target.is_file() || // some/path/git
44-
target.with_extension("exe").exists() || // some/path/git.exe
45-
target.join(&cmd_alt).exists() { // some/path/git/git.exe
41+
let mut cmd_exe = cmd.clone();
42+
cmd_exe.push(".exe");
43+
44+
if target.is_file() // some/path/git
45+
|| path.join(&cmd_exe).exists() // some/path/git.exe
46+
|| target.join(&cmd_exe).exists() // some/path/git/git.exe
47+
{
4648
return Some(target);
4749
}
4850
}
@@ -107,9 +109,9 @@ pub fn check(build: &mut Build) {
107109
}
108110

109111
build.config.python = build.config.python.take().map(|p| cmd_finder.must_have(p))
110-
.or_else(|| env::var_os("BOOTSTRAP_PYTHON").map(PathBuf::from)) // set by bootstrap.py
111112
.or_else(|| cmd_finder.maybe_have("python2.7"))
112113
.or_else(|| cmd_finder.maybe_have("python2"))
114+
.or_else(|| env::var_os("BOOTSTRAP_PYTHON").map(PathBuf::from)) // set by bootstrap.py
113115
.or_else(|| Some(cmd_finder.must_have("python")));
114116

115117
build.config.nodejs = build.config.nodejs.take().map(|p| cmd_finder.must_have(p))

src/doc/rustdoc/src/unstable-features.md

+31-4
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ For example, in the following code:
5353
```rust
5454
/// Does the thing.
5555
pub fn do_the_thing(_: SomeType) {
56-
println!("Let's do the thing!");
56+
println!("Let's do the thing!");
5757
}
5858

5959
/// Token you use to [`do_the_thing`].
@@ -66,15 +66,15 @@ target out also works:
6666

6767
```rust
6868
pub mod some_module {
69-
/// Token you use to do the thing.
70-
pub struct SomeStruct;
69+
/// Token you use to do the thing.
70+
pub struct SomeStruct;
7171
}
7272

7373
/// Does the thing. Requires one [`SomeStruct`] for the thing to work.
7474
///
7575
/// [`SomeStruct`]: some_module::SomeStruct
7676
pub fn do_the_thing(_: some_module::SomeStruct) {
77-
println!("Let's do the thing!");
77+
println!("Let's do the thing!");
7878
}
7979
```
8080

@@ -428,3 +428,30 @@ $ rustdoc src/lib.rs --test -Z unstable-options --persist-doctests target/rustdo
428428
This flag allows you to keep doctest executables around after they're compiled or run.
429429
Usually, rustdoc will immediately discard a compiled doctest after it's been tested, but
430430
with this option, you can keep those binaries around for farther testing.
431+
432+
### `--show-coverage`: calculate the percentage of items with documentation
433+
434+
Using this flag looks like this:
435+
436+
```bash
437+
$ rustdoc src/lib.rs -Z unstable-options --show-coverage
438+
```
439+
440+
If you want to determine how many items in your crate are documented, pass this flag to rustdoc.
441+
When it receives this flag, it will count the public items in your crate that have documentation,
442+
and print out the counts and a percentage instead of generating docs.
443+
444+
Some methodology notes about what rustdoc counts in this metric:
445+
446+
* Rustdoc will only count items from your crate (i.e. items re-exported from other crates don't
447+
count).
448+
* Docs written directly onto inherent impl blocks are not counted, even though their doc comments
449+
are displayed, because the common pattern in Rust code is to write all inherent methods into the
450+
same impl block.
451+
* Items in a trait implementation are not counted, as those impls will inherit any docs from the
452+
trait itself.
453+
* By default, only public items are counted. To count private items as well, pass
454+
`--document-private-items` at the same time.
455+
456+
Public items that are not documented can be seen with the built-in `missing_docs` lint. Private
457+
items that are not documented can be seen with Clippy's `missing_docs_in_private_items` lint.

src/etc/lldb_rust_formatters.py

+2
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@ def render_element(i):
290290

291291

292292
def read_utf8_string(ptr_val, byte_count):
293+
if byte_count == 0:
294+
return '""'
293295
error = lldb.SBError()
294296
process = ptr_val.get_wrapped_value().GetProcess()
295297
data = process.ReadMemory(ptr_val.as_integer(), byte_count, error)

src/liballoc/vec.rs

+19
Original file line numberDiff line numberDiff line change
@@ -2468,6 +2468,25 @@ impl<T: fmt::Debug> fmt::Debug for Drain<'_, T> {
24682468
}
24692469
}
24702470

2471+
impl<'a, T> Drain<'a, T> {
2472+
/// Returns the remaining items of this iterator as a slice.
2473+
///
2474+
/// # Examples
2475+
///
2476+
/// ```
2477+
/// # #![feature(vec_drain_as_slice)]
2478+
/// let mut vec = vec!['a', 'b', 'c'];
2479+
/// let mut drain = vec.drain(..);
2480+
/// assert_eq!(drain.as_slice(), &['a', 'b', 'c']);
2481+
/// let _ = drain.next().unwrap();
2482+
/// assert_eq!(drain.as_slice(), &['b', 'c']);
2483+
/// ```
2484+
#[unstable(feature = "vec_drain_as_slice", reason = "recently added", issue = "58957")]
2485+
pub fn as_slice(&self) -> &[T] {
2486+
self.iter.as_slice()
2487+
}
2488+
}
2489+
24712490
#[stable(feature = "drain", since = "1.6.0")]
24722491
unsafe impl<T: Sync> Sync for Drain<'_, T> {}
24732492
#[stable(feature = "drain", since = "1.6.0")]

src/libcore/fmt/float.rs

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ fn float_to_decimal_common_exact<T>(fmt: &mut Formatter, num: &T,
1515
// FIXME(#53491): Technically, this is calling `get_mut` on an uninitialized
1616
// `MaybeUninit` (here and elsewhere in this file). Revisit this once
1717
// we decided whether that is valid or not.
18+
// Using `freeze` is *not enough*; `flt2dec::Part` is an enum!
1819
let formatted = flt2dec::to_exact_fixed_str(flt2dec::strategy::grisu::format_exact,
1920
*num, sign, precision,
2021
false, buf.get_mut(), parts.get_mut());
@@ -33,6 +34,7 @@ fn float_to_decimal_common_shortest<T>(fmt: &mut Formatter, num: &T,
3334
// enough for f32 and f64
3435
let mut buf = MaybeUninit::<[u8; flt2dec::MAX_SIG_DIGITS]>::uninitialized();
3536
let mut parts = MaybeUninit::<[flt2dec::Part; 4]>::uninitialized();
37+
// FIXME(#53491)
3638
let formatted = flt2dec::to_shortest_str(flt2dec::strategy::grisu::format_shortest, *num,
3739
sign, precision, false, buf.get_mut(),
3840
parts.get_mut());
@@ -71,6 +73,7 @@ fn float_to_exponential_common_exact<T>(fmt: &mut Formatter, num: &T,
7173
unsafe {
7274
let mut buf = MaybeUninit::<[u8; 1024]>::uninitialized(); // enough for f32 and f64
7375
let mut parts = MaybeUninit::<[flt2dec::Part; 6]>::uninitialized();
76+
// FIXME(#53491)
7477
let formatted = flt2dec::to_exact_exp_str(flt2dec::strategy::grisu::format_exact,
7578
*num, sign, precision,
7679
upper, buf.get_mut(), parts.get_mut());
@@ -90,6 +93,7 @@ fn float_to_exponential_common_shortest<T>(fmt: &mut Formatter,
9093
// enough for f32 and f64
9194
let mut buf = MaybeUninit::<[u8; flt2dec::MAX_SIG_DIGITS]>::uninitialized();
9295
let mut parts = MaybeUninit::<[flt2dec::Part; 6]>::uninitialized();
96+
// FIXME(#53491)
9397
let formatted = flt2dec::to_shortest_exp_str(flt2dec::strategy::grisu::format_shortest,
9498
*num, sign, (0, 0), upper,
9599
buf.get_mut(), parts.get_mut());

0 commit comments

Comments
 (0)