Skip to content

Rollup of 7 pull requests #102192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b4fdc58
Add missing documentation for `bool::from_str`
GuillaumeGomez Sep 21, 2022
758ca9d
Add examples to `bool::then` and `bool::then_some`
vcfxb Sep 21, 2022
804cd84
Remove trailing whitespace
vcfxb Sep 22, 2022
ca26dec
Add missing assertion
vcfxb Sep 22, 2022
a9e657d
don't convert valtree to constvalue during normalization
b-naber Sep 22, 2022
7927f09
add regression test for miri issue 2433
RalfJung Sep 22, 2022
a7cdfaf
make Miri build in stage 0
RalfJung Sep 22, 2022
dedf6fc
rustdoc: clean up CSS/DOM for deprecation warnings
notriddle Sep 22, 2022
51f335d
rustdoc: fix unit tests
notriddle Sep 22, 2022
7bfbaa3
Detect panic strategy using `rustc --print cfg`
flba-eb Sep 22, 2022
0b0027f
Restore ignore tag
flba-eb Sep 22, 2022
10f3657
Adapt test results
flba-eb Sep 22, 2022
0be3cc8
ignore test cases when checking emscripten
flba-eb Sep 23, 2022
ccd19c7
Repair stderr test result to added line
flba-eb Sep 23, 2022
a0eb467
Fix a typo in `std`'s root docs
inquisitivecrystal Sep 23, 2022
ded3eda
fix test
b-naber Sep 23, 2022
986fc4b
Rollup merge of #102094 - GuillaumeGomez:bool-from-str-missing-docs, …
matthiaskrgr Sep 23, 2022
6b001f3
Rollup merge of #102115 - Alfriadox:master, r=thomcc
matthiaskrgr Sep 23, 2022
3de0d67
Rollup merge of #102134 - flba-eb:master, r=bjorn3
matthiaskrgr Sep 23, 2022
3a8bad9
Rollup merge of #102137 - b-naber:lazy-const-val-conversion, r=lcnr
matthiaskrgr Sep 23, 2022
0d01869
Rollup merge of #102148 - RalfJung:miri-test, r=oli-obk
matthiaskrgr Sep 23, 2022
6d6d89b
Rollup merge of #102158 - notriddle:notriddle/stab-p, r=GuillaumeGomez
matthiaskrgr Sep 23, 2022
dfe045a
Rollup merge of #102177 - inquisitivecrystal:std-doc-typo, r=Dylan-DPC
matthiaskrgr Sep 23, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 1 addition & 19 deletions compiler/rustc_trait_selection/src/traits/query/normalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,25 +351,7 @@ impl<'cx, 'tcx> FallibleTypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
&mut self,
constant: mir::ConstantKind<'tcx>,
) -> Result<mir::ConstantKind<'tcx>, Self::Error> {
Ok(match constant {
mir::ConstantKind::Ty(c) => {
let const_folded = c.try_super_fold_with(self)?;
match const_folded.kind() {
ty::ConstKind::Value(valtree) => {
let tcx = self.infcx.tcx;
let ty = const_folded.ty();
let const_val = tcx.valtree_to_const_val((ty, valtree));
debug!(?ty, ?valtree, ?const_val);

mir::ConstantKind::Val(const_val, ty)
}
_ => mir::ConstantKind::Ty(const_folded),
}
}
mir::ConstantKind::Val(_, _) | mir::ConstantKind::Unevaluated(..) => {
constant.try_super_fold_with(self)?
}
})
constant.try_super_fold_with(self)
}

#[inline]
Expand Down
23 changes: 23 additions & 0 deletions library/core/src/bool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ impl bool {
/// assert_eq!(false.then_some(0), None);
/// assert_eq!(true.then_some(0), Some(0));
/// ```
///
/// ```
/// let mut a = 0;
/// let mut function_with_side_effects = || { a += 1; };
///
/// true.then_some(function_with_side_effects());
/// false.then_some(function_with_side_effects());
///
/// // `a` is incremented twice because the value passed to `then_some` is
/// // evaluated eagerly.
/// assert_eq!(a, 2);
/// ```
#[stable(feature = "bool_to_option", since = "1.62.0")]
#[rustc_const_unstable(feature = "const_bool_to_option", issue = "91917")]
#[inline]
Expand All @@ -37,6 +49,17 @@ impl bool {
/// assert_eq!(false.then(|| 0), None);
/// assert_eq!(true.then(|| 0), Some(0));
/// ```
///
/// ```
/// let mut a = 0;
///
/// true.then(|| { a += 1; });
/// false.then(|| { a += 1; });
///
/// // `a` is incremented once because the closure is evaluated lazily by
/// // `then`.
/// assert_eq!(a, 1);
/// ```
#[stable(feature = "lazy_bool_to_option", since = "1.50.0")]
#[rustc_const_unstable(feature = "const_bool_to_option", issue = "91917")]
#[inline]
Expand Down
4 changes: 2 additions & 2 deletions library/core/src/str/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,8 +573,8 @@ impl FromStr for bool {

/// Parse a `bool` from a string.
///
/// Yields a `Result<bool, ParseBoolError>`, because `s` may or may not
/// actually be parseable.
/// The only accepted values are `"true"` and `"false"`. Any other input
/// will return an error.
///
/// # Examples
///
Expand Down
4 changes: 2 additions & 2 deletions library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@
//! abstracting over differences in common platforms, most notably Windows and
//! Unix derivatives.
//!
//! Common types of I/O, including [files], [TCP], [UDP], are defined in the
//! [`io`], [`fs`], and [`net`] modules.
//! Common types of I/O, including [files], [TCP], and [UDP], are defined in
//! the [`io`], [`fs`], and [`net`] modules.
//!
//! The [`thread`] module contains Rust's threading abstractions. [`sync`]
//! contains further primitive shared memory types, including [`atomic`] and
Expand Down
19 changes: 8 additions & 11 deletions src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,9 @@ pub(crate) struct MarkdownWithToc<'a>(
pub(crate) Edition,
pub(crate) &'a Option<Playground>,
);
/// A tuple struct like `Markdown` that renders the markdown escaping HTML tags.
pub(crate) struct MarkdownHtml<'a>(
pub(crate) &'a str,
pub(crate) &'a mut IdMap,
pub(crate) ErrorCodes,
pub(crate) Edition,
pub(crate) &'a Option<Playground>,
);
/// A tuple struct like `Markdown` that renders the markdown escaping HTML tags
/// and includes no paragraph tags.
pub(crate) struct MarkdownItemInfo<'a>(pub(crate) &'a str, pub(crate) &'a mut IdMap);
/// A tuple struct like `Markdown` that renders only the first paragraph.
pub(crate) struct MarkdownSummaryLine<'a>(pub &'a str, pub &'a [RenderedLink]);

Expand Down Expand Up @@ -1072,9 +1067,9 @@ impl MarkdownWithToc<'_> {
}
}

impl MarkdownHtml<'_> {
impl MarkdownItemInfo<'_> {
pub(crate) fn into_string(self) -> String {
let MarkdownHtml(md, ids, codes, edition, playground) = self;
let MarkdownItemInfo(md, ids) = self;

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

s
Expand Down
11 changes: 5 additions & 6 deletions src/librustdoc/html/markdown/tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::{find_testable_code, plain_text_summary, short_markdown_summary};
use super::{ErrorCodes, HeadingOffset, IdMap, Ignore, LangString, Markdown, MarkdownHtml};
use super::{ErrorCodes, HeadingOffset, IdMap, Ignore, LangString, Markdown, MarkdownItemInfo};
use rustc_span::edition::{Edition, DEFAULT_EDITION};

#[test]
Expand Down Expand Up @@ -279,14 +279,13 @@ fn test_plain_text_summary() {
fn test_markdown_html_escape() {
fn t(input: &str, expect: &str) {
let mut idmap = IdMap::new();
let output =
MarkdownHtml(input, &mut idmap, ErrorCodes::Yes, DEFAULT_EDITION, &None).into_string();
let output = MarkdownItemInfo(input, &mut idmap).into_string();
assert_eq!(output, expect, "original: {}", input);
}

t("`Struct<'a, T>`", "<p><code>Struct&lt;'a, T&gt;</code></p>\n");
t("Struct<'a, T>", "<p>Struct&lt;’a, T&gt;</p>\n");
t("Struct<br>", "<p>Struct&lt;br&gt;</p>\n");
t("`Struct<'a, T>`", "<code>Struct&lt;'a, T&gt;</code>");
t("Struct<'a, T>", "Struct&lt;’a, T&gt;");
t("Struct<br>", "Struct&lt;br&gt;");
}

#[test]
Expand Down
13 changes: 4 additions & 9 deletions src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ use crate::html::format::{
PrintWithSpace,
};
use crate::html::highlight;
use crate::html::markdown::{HeadingOffset, IdMap, Markdown, MarkdownHtml, MarkdownSummaryLine};
use crate::html::markdown::{
HeadingOffset, IdMap, Markdown, MarkdownItemInfo, MarkdownSummaryLine,
};
use crate::html::sources;
use crate::html::static_files::SCRAPE_EXAMPLES_HELP_MD;
use crate::scrape_examples::{CallData, CallLocation};
Expand Down Expand Up @@ -584,7 +586,6 @@ fn short_item_info(
parent: Option<&clean::Item>,
) -> Vec<String> {
let mut extra_info = vec![];
let error_codes = cx.shared.codes;

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

if let Some(note) = note {
let note = note.as_str();
let html = MarkdownHtml(
note,
&mut cx.id_map,
error_codes,
cx.shared.edition(),
&cx.shared.playground,
);
let html = MarkdownItemInfo(note, &mut cx.id_map);
message.push_str(&format!(": {}", html.into_string()));
}
extra_info.push(format!(
Expand Down
4 changes: 0 additions & 4 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -1068,10 +1068,6 @@ so that we can apply CSS-filters to change the arrow color in themes */
font-size: 0.875rem;
font-weight: normal;
}
.stab p {
display: inline;
margin: 0;
}

.stab .emoji {
font-size: 1.25rem;
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/async-await/async-fn-size-moved-locals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//
// See issue #59123 for a full explanation.

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// error-pattern: thread 'main' panicked at '`async fn` resumed after panicking'
// edition:2018
// ignore-wasm no panic or subprocess support
// ignore-emscripten no panic or subprocess support

#![feature(generators, generator_trait)]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// Check that partially moved from function parameters are dropped after the
// named bindings that move from them.

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

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

Expand Down
1 change: 0 additions & 1 deletion src/test/ui/builtin-clone-unwind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

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

// Test that builtin implementations of `Clone` cleanup everything
// in case of unwinding.
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/catch-unwind-bang.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// run-pass
// needs-unwind
// ignore-wasm32-bare compiled with panic=abort by default

fn worker() -> ! {
panic!()
Expand Down
3 changes: 0 additions & 3 deletions src/test/ui/cfg/cfg-panic.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// build-pass
// compile-flags: -C panic=unwind
// needs-unwind
// ignore-emscripten no panic_unwind implementation
// ignore-wasm32 no panic_unwind implementation
// ignore-wasm64 no panic_unwind implementation


#[cfg(panic = "abort")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: changes to closure capture in Rust 2021 will affect which traits the closure implements
--> $DIR/mir_calls_to_shims.rs:21:38
--> $DIR/mir_calls_to_shims.rs:20:38
|
LL | let result = panic::catch_unwind(move || {
| ^^^^^^^
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/drop/dynamic-drop-async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// run-pass
// needs-unwind
// edition:2018
// ignore-wasm32-bare compiled with panic=abort by default

#![allow(unused)]

Expand Down
1 change: 0 additions & 1 deletion src/test/ui/drop/dynamic-drop.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// run-pass
// needs-unwind
// ignore-wasm32-bare compiled with panic=abort by default

#![feature(generators, generator_trait)]

Expand Down
3 changes: 0 additions & 3 deletions src/test/ui/drop/repeat-drop.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// run-pass
// needs-unwind
// ignore-wasm32-bare no unwinding panic
// ignore-avr no unwinding panic
// ignore-nvptx64 no unwinding panic

static mut CHECK: usize = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/extern-flag/empty-extern-arg.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// compile-flags: --extern std=
// error-pattern: extern location for std does not exist
// needs-unwind since it affects the error output
// ignore-emscripten compiled with panic=abort, personality not required
// ignore-emscripten missing eh_catch_typeinfo lang item

fn main() {}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// run-pass
// needs-unwind
// ignore-wasm32-bare compiled with panic=abort by default
// ignore-emscripten no threads support

// rust-lang/rust#64655: with panic=unwind, a panic from a subroutine
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// run-pass
// needs-unwind
// ignore-wasm32-bare compiled with panic=abort by default
// ignore-emscripten no threads support

// rust-lang/rust#64655: with panic=unwind, a panic from a subroutine
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/generator/panic-drops-resume.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// run-pass
// needs-unwind
// ignore-wasm no unwind support
// ignore-emscripten no unwind support

#![feature(generators, generator_trait)]

Expand Down
1 change: 0 additions & 1 deletion src/test/ui/generator/panic-drops.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// run-pass
// needs-unwind

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

#![feature(generators, generator_trait)]

Expand Down
1 change: 0 additions & 1 deletion src/test/ui/generator/panic-safe.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// run-pass
// needs-unwind

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

#![feature(generators, generator_trait)]

Expand Down
1 change: 0 additions & 1 deletion src/test/ui/generator/resume-after-return.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// run-pass
// needs-unwind

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

#![feature(generators, generator_trait)]

Expand Down
1 change: 0 additions & 1 deletion src/test/ui/intrinsics/panic-uninitialized-zeroed.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// run-pass
// needs-unwind
// ignore-wasm32-bare compiled with panic=abort by default
// revisions: mir thir strict
// [thir]compile-flags: -Zthir-unsafeck
// [strict]compile-flags: -Zstrict-init-checks
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/issues/issue-14875.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// run-pass
// needs-unwind
// ignore-wasm32-bare compiled with panic=abort by default

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

Expand Down
1 change: 0 additions & 1 deletion src/test/ui/issues/issue-29948.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// run-pass
// needs-unwind
// ignore-wasm32-bare compiled with panic=abort by default

use std::panic;

Expand Down
1 change: 0 additions & 1 deletion src/test/ui/issues/issue-43853.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// run-pass
// needs-unwind
// ignore-wasm32-bare compiled with panic=abort by default

use std::panic;

Expand Down
1 change: 0 additions & 1 deletion src/test/ui/issues/issue-46519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// compile-flags:--test -O

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

#[test]
#[should_panic(expected = "creating inhabited type")]
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/iterators/iter-count-overflow-debug.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// run-pass
// only-32bit too impatient for 2⁶⁴ items
// needs-unwind
// ignore-wasm32-bare compiled with panic=abort by default
// compile-flags: -C debug_assertions=yes -C opt-level=3

use std::panic;
Expand Down
Loading