Skip to content

Commit 4a14677

Browse files
committed
Auto merge of #102192 - matthiaskrgr:rollup-0ctjzco, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #102094 (Add missing documentation for `bool::from_str`) - #102115 (Add examples to `bool::then` and `bool::then_some`) - #102134 (Detect panic strategy using `rustc --print cfg`) - #102137 (Don't convert valtree to constvalue during normalization) - #102148 (add regression test for miri issue 2433) - #102158 (rustdoc: clean up CSS/DOM for deprecation warnings) - #102177 (Fix a typo in `std`'s root docs) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 9a963e3 + dfe045a commit 4a14677

File tree

69 files changed

+98
-166
lines changed

Some content is hidden

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

69 files changed

+98
-166
lines changed

compiler/rustc_trait_selection/src/traits/query/normalize.rs

+1-19
Original file line numberDiff line numberDiff line change
@@ -351,25 +351,7 @@ impl<'cx, 'tcx> FallibleTypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
351351
&mut self,
352352
constant: mir::ConstantKind<'tcx>,
353353
) -> Result<mir::ConstantKind<'tcx>, Self::Error> {
354-
Ok(match constant {
355-
mir::ConstantKind::Ty(c) => {
356-
let const_folded = c.try_super_fold_with(self)?;
357-
match const_folded.kind() {
358-
ty::ConstKind::Value(valtree) => {
359-
let tcx = self.infcx.tcx;
360-
let ty = const_folded.ty();
361-
let const_val = tcx.valtree_to_const_val((ty, valtree));
362-
debug!(?ty, ?valtree, ?const_val);
363-
364-
mir::ConstantKind::Val(const_val, ty)
365-
}
366-
_ => mir::ConstantKind::Ty(const_folded),
367-
}
368-
}
369-
mir::ConstantKind::Val(_, _) | mir::ConstantKind::Unevaluated(..) => {
370-
constant.try_super_fold_with(self)?
371-
}
372-
})
354+
constant.try_super_fold_with(self)
373355
}
374356

375357
#[inline]

library/core/src/bool.rs

+23
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@ impl bool {
1818
/// assert_eq!(false.then_some(0), None);
1919
/// assert_eq!(true.then_some(0), Some(0));
2020
/// ```
21+
///
22+
/// ```
23+
/// let mut a = 0;
24+
/// let mut function_with_side_effects = || { a += 1; };
25+
///
26+
/// true.then_some(function_with_side_effects());
27+
/// false.then_some(function_with_side_effects());
28+
///
29+
/// // `a` is incremented twice because the value passed to `then_some` is
30+
/// // evaluated eagerly.
31+
/// assert_eq!(a, 2);
32+
/// ```
2133
#[stable(feature = "bool_to_option", since = "1.62.0")]
2234
#[rustc_const_unstable(feature = "const_bool_to_option", issue = "91917")]
2335
#[inline]
@@ -37,6 +49,17 @@ impl bool {
3749
/// assert_eq!(false.then(|| 0), None);
3850
/// assert_eq!(true.then(|| 0), Some(0));
3951
/// ```
52+
///
53+
/// ```
54+
/// let mut a = 0;
55+
///
56+
/// true.then(|| { a += 1; });
57+
/// false.then(|| { a += 1; });
58+
///
59+
/// // `a` is incremented once because the closure is evaluated lazily by
60+
/// // `then`.
61+
/// assert_eq!(a, 1);
62+
/// ```
4063
#[stable(feature = "lazy_bool_to_option", since = "1.50.0")]
4164
#[rustc_const_unstable(feature = "const_bool_to_option", issue = "91917")]
4265
#[inline]

library/core/src/str/traits.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -573,8 +573,8 @@ impl FromStr for bool {
573573

574574
/// Parse a `bool` from a string.
575575
///
576-
/// Yields a `Result<bool, ParseBoolError>`, because `s` may or may not
577-
/// actually be parseable.
576+
/// The only accepted values are `"true"` and `"false"`. Any other input
577+
/// will return an error.
578578
///
579579
/// # Examples
580580
///

library/std/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@
145145
//! abstracting over differences in common platforms, most notably Windows and
146146
//! Unix derivatives.
147147
//!
148-
//! Common types of I/O, including [files], [TCP], [UDP], are defined in the
149-
//! [`io`], [`fs`], and [`net`] modules.
148+
//! Common types of I/O, including [files], [TCP], and [UDP], are defined in
149+
//! the [`io`], [`fs`], and [`net`] modules.
150150
//!
151151
//! The [`thread`] module contains Rust's threading abstractions. [`sync`]
152152
//! contains further primitive shared memory types, including [`atomic`] and

src/librustdoc/html/markdown.rs

+8-11
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,9 @@ pub(crate) struct MarkdownWithToc<'a>(
111111
pub(crate) Edition,
112112
pub(crate) &'a Option<Playground>,
113113
);
114-
/// A tuple struct like `Markdown` that renders the markdown escaping HTML tags.
115-
pub(crate) struct MarkdownHtml<'a>(
116-
pub(crate) &'a str,
117-
pub(crate) &'a mut IdMap,
118-
pub(crate) ErrorCodes,
119-
pub(crate) Edition,
120-
pub(crate) &'a Option<Playground>,
121-
);
114+
/// A tuple struct like `Markdown` that renders the markdown escaping HTML tags
115+
/// and includes no paragraph tags.
116+
pub(crate) struct MarkdownItemInfo<'a>(pub(crate) &'a str, pub(crate) &'a mut IdMap);
122117
/// A tuple struct like `Markdown` that renders only the first paragraph.
123118
pub(crate) struct MarkdownSummaryLine<'a>(pub &'a str, pub &'a [RenderedLink]);
124119

@@ -1072,9 +1067,9 @@ impl MarkdownWithToc<'_> {
10721067
}
10731068
}
10741069

1075-
impl MarkdownHtml<'_> {
1070+
impl MarkdownItemInfo<'_> {
10761071
pub(crate) fn into_string(self) -> String {
1077-
let MarkdownHtml(md, ids, codes, edition, playground) = self;
1072+
let MarkdownItemInfo(md, ids) = self;
10781073

10791074
// This is actually common enough to special-case
10801075
if md.is_empty() {
@@ -1093,7 +1088,9 @@ impl MarkdownHtml<'_> {
10931088
let p = HeadingLinks::new(p, None, ids, HeadingOffset::H1);
10941089
let p = Footnotes::new(p);
10951090
let p = TableWrapper::new(p.map(|(ev, _)| ev));
1096-
let p = CodeBlocks::new(p, codes, edition, playground);
1091+
let p = p.filter(|event| {
1092+
!matches!(event, Event::Start(Tag::Paragraph) | Event::End(Tag::Paragraph))
1093+
});
10971094
html::push_html(&mut s, p);
10981095

10991096
s

src/librustdoc/html/markdown/tests.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use super::{find_testable_code, plain_text_summary, short_markdown_summary};
2-
use super::{ErrorCodes, HeadingOffset, IdMap, Ignore, LangString, Markdown, MarkdownHtml};
2+
use super::{ErrorCodes, HeadingOffset, IdMap, Ignore, LangString, Markdown, MarkdownItemInfo};
33
use rustc_span::edition::{Edition, DEFAULT_EDITION};
44

55
#[test]
@@ -279,14 +279,13 @@ fn test_plain_text_summary() {
279279
fn test_markdown_html_escape() {
280280
fn t(input: &str, expect: &str) {
281281
let mut idmap = IdMap::new();
282-
let output =
283-
MarkdownHtml(input, &mut idmap, ErrorCodes::Yes, DEFAULT_EDITION, &None).into_string();
282+
let output = MarkdownItemInfo(input, &mut idmap).into_string();
284283
assert_eq!(output, expect, "original: {}", input);
285284
}
286285

287-
t("`Struct<'a, T>`", "<p><code>Struct&lt;'a, T&gt;</code></p>\n");
288-
t("Struct<'a, T>", "<p>Struct&lt;’a, T&gt;</p>\n");
289-
t("Struct<br>", "<p>Struct&lt;br&gt;</p>\n");
286+
t("`Struct<'a, T>`", "<code>Struct&lt;'a, T&gt;</code>");
287+
t("Struct<'a, T>", "Struct&lt;’a, T&gt;");
288+
t("Struct<br>", "Struct&lt;br&gt;");
290289
}
291290

292291
#[test]

src/librustdoc/html/render/mod.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ use crate::html::format::{
7474
PrintWithSpace,
7575
};
7676
use crate::html::highlight;
77-
use crate::html::markdown::{HeadingOffset, IdMap, Markdown, MarkdownHtml, MarkdownSummaryLine};
77+
use crate::html::markdown::{
78+
HeadingOffset, IdMap, Markdown, MarkdownItemInfo, MarkdownSummaryLine,
79+
};
7880
use crate::html::sources;
7981
use crate::html::static_files::SCRAPE_EXAMPLES_HELP_MD;
8082
use crate::scrape_examples::{CallData, CallLocation};
@@ -584,7 +586,6 @@ fn short_item_info(
584586
parent: Option<&clean::Item>,
585587
) -> Vec<String> {
586588
let mut extra_info = vec![];
587-
let error_codes = cx.shared.codes;
588589

589590
if let Some(depr @ Deprecation { note, since, is_since_rustc_version: _, suggestion: _ }) =
590591
item.deprecation(cx.tcx())
@@ -608,13 +609,7 @@ fn short_item_info(
608609

609610
if let Some(note) = note {
610611
let note = note.as_str();
611-
let html = MarkdownHtml(
612-
note,
613-
&mut cx.id_map,
614-
error_codes,
615-
cx.shared.edition(),
616-
&cx.shared.playground,
617-
);
612+
let html = MarkdownItemInfo(note, &mut cx.id_map);
618613
message.push_str(&format!(": {}", html.into_string()));
619614
}
620615
extra_info.push(format!(

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

-4
Original file line numberDiff line numberDiff line change
@@ -1068,10 +1068,6 @@ so that we can apply CSS-filters to change the arrow color in themes */
10681068
font-size: 0.875rem;
10691069
font-weight: normal;
10701070
}
1071-
.stab p {
1072-
display: inline;
1073-
margin: 0;
1074-
}
10751071

10761072
.stab .emoji {
10771073
font-size: 1.25rem;

src/test/ui/async-await/async-fn-size-moved-locals.rs

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
//
88
// See issue #59123 for a full explanation.
99

10-
// ignore-emscripten (sizes don't match)
1110
// needs-unwind Size of Futures change on panic=abort
1211
// run-pass
1312

src/test/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-panic.rs

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
// error-pattern: thread 'main' panicked at '`async fn` resumed after panicking'
77
// edition:2018
88
// ignore-wasm no panic or subprocess support
9-
// ignore-emscripten no panic or subprocess support
109

1110
#![feature(generators, generator_trait)]
1211

src/test/ui/binding/fn-arg-incomplete-pattern-drop-order.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// Check that partially moved from function parameters are dropped after the
44
// named bindings that move from them.
55

6-
// ignore-wasm32-bare compiled with panic=abort by default
76

87
use std::{panic, cell::RefCell};
98

src/test/ui/builtin-clone-unwind.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
#![allow(unused_variables)]
55
#![allow(unused_imports)]
6-
// ignore-wasm32-bare compiled with panic=abort by default
76

87
// Test that builtin implementations of `Clone` cleanup everything
98
// in case of unwinding.

src/test/ui/catch-unwind-bang.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// run-pass
22
// needs-unwind
3-
// ignore-wasm32-bare compiled with panic=abort by default
43

54
fn worker() -> ! {
65
panic!()

src/test/ui/cfg/cfg-panic.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
// build-pass
22
// compile-flags: -C panic=unwind
33
// needs-unwind
4-
// ignore-emscripten no panic_unwind implementation
5-
// ignore-wasm32 no panic_unwind implementation
6-
// ignore-wasm64 no panic_unwind implementation
74

85

96
#[cfg(panic = "abort")]

src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.fixed

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
#![deny(rust_2021_incompatible_closure_captures)]
55
//~^ NOTE: the lint level is defined here
6-
// ignore-wasm32-bare compiled with panic=abort by default
76
#![feature(fn_traits)]
87
#![feature(never_type)]
98

src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
#![deny(rust_2021_incompatible_closure_captures)]
55
//~^ NOTE: the lint level is defined here
6-
// ignore-wasm32-bare compiled with panic=abort by default
76
#![feature(fn_traits)]
87
#![feature(never_type)]
98

src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: changes to closure capture in Rust 2021 will affect which traits the closure implements
2-
--> $DIR/mir_calls_to_shims.rs:21:38
2+
--> $DIR/mir_calls_to_shims.rs:20:38
33
|
44
LL | let result = panic::catch_unwind(move || {
55
| ^^^^^^^

src/test/ui/drop/dynamic-drop-async.rs

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
// run-pass
77
// needs-unwind
88
// edition:2018
9-
// ignore-wasm32-bare compiled with panic=abort by default
109

1110
#![allow(unused)]
1211

src/test/ui/drop/dynamic-drop.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// run-pass
22
// needs-unwind
3-
// ignore-wasm32-bare compiled with panic=abort by default
43

54
#![feature(generators, generator_trait)]
65

src/test/ui/drop/repeat-drop.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
// run-pass
22
// needs-unwind
3-
// ignore-wasm32-bare no unwinding panic
4-
// ignore-avr no unwinding panic
5-
// ignore-nvptx64 no unwinding panic
63

74
static mut CHECK: usize = 0;
85

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// compile-flags: --extern std=
22
// error-pattern: extern location for std does not exist
33
// needs-unwind since it affects the error output
4-
// ignore-emscripten compiled with panic=abort, personality not required
4+
// ignore-emscripten missing eh_catch_typeinfo lang item
55

66
fn main() {}

src/test/ui/extern/issue-64655-allow-unwind-when-calling-panic-directly.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// run-pass
22
// needs-unwind
3-
// ignore-wasm32-bare compiled with panic=abort by default
43
// ignore-emscripten no threads support
54

65
// rust-lang/rust#64655: with panic=unwind, a panic from a subroutine

src/test/ui/extern/issue-64655-extern-rust-must-allow-unwind.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// run-pass
22
// needs-unwind
3-
// ignore-wasm32-bare compiled with panic=abort by default
43
// ignore-emscripten no threads support
54

65
// rust-lang/rust#64655: with panic=unwind, a panic from a subroutine

src/test/ui/generator/panic-drops-resume.rs

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
33
// run-pass
44
// needs-unwind
5-
// ignore-wasm no unwind support
6-
// ignore-emscripten no unwind support
75

86
#![feature(generators, generator_trait)]
97

src/test/ui/generator/panic-drops.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// run-pass
22
// needs-unwind
33

4-
// ignore-wasm32-bare compiled with panic=abort by default
54

65
#![feature(generators, generator_trait)]
76

src/test/ui/generator/panic-safe.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// run-pass
22
// needs-unwind
33

4-
// ignore-wasm32-bare compiled with panic=abort by default
54

65
#![feature(generators, generator_trait)]
76

src/test/ui/generator/resume-after-return.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// run-pass
22
// needs-unwind
33

4-
// ignore-wasm32-bare compiled with panic=abort by default
54

65
#![feature(generators, generator_trait)]
76

src/test/ui/intrinsics/panic-uninitialized-zeroed.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// run-pass
22
// needs-unwind
3-
// ignore-wasm32-bare compiled with panic=abort by default
43
// revisions: mir thir strict
54
// [thir]compile-flags: -Zthir-unsafeck
65
// [strict]compile-flags: -Zstrict-init-checks

src/test/ui/issues/issue-14875.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// run-pass
22
// needs-unwind
3-
// ignore-wasm32-bare compiled with panic=abort by default
43

54
// Check that values are not leaked when a dtor panics (#14875)
65

src/test/ui/issues/issue-29948.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// run-pass
22
// needs-unwind
3-
// ignore-wasm32-bare compiled with panic=abort by default
43

54
use std::panic;
65

src/test/ui/issues/issue-43853.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// run-pass
22
// needs-unwind
3-
// ignore-wasm32-bare compiled with panic=abort by default
43

54
use std::panic;
65

src/test/ui/issues/issue-46519.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// compile-flags:--test -O
33

44
// needs-unwind
5-
// ignore-wasm32-bare compiled with panic=abort by default
65

76
#[test]
87
#[should_panic(expected = "creating inhabited type")]

src/test/ui/iterators/iter-count-overflow-debug.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// run-pass
22
// only-32bit too impatient for 2⁶⁴ items
33
// needs-unwind
4-
// ignore-wasm32-bare compiled with panic=abort by default
54
// compile-flags: -C debug_assertions=yes -C opt-level=3
65

76
use std::panic;

0 commit comments

Comments
 (0)