1
Fork 0

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
This commit is contained in:
bors 2022-09-23 16:44:06 +00:00
commit 4a14677239
69 changed files with 98 additions and 166 deletions

View file

@ -351,25 +351,7 @@ impl<'cx, 'tcx> FallibleTypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
&mut self, &mut self,
constant: mir::ConstantKind<'tcx>, constant: mir::ConstantKind<'tcx>,
) -> Result<mir::ConstantKind<'tcx>, Self::Error> { ) -> Result<mir::ConstantKind<'tcx>, Self::Error> {
Ok(match constant { constant.try_super_fold_with(self)
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)?
}
})
} }
#[inline] #[inline]

View file

@ -18,6 +18,18 @@ impl bool {
/// assert_eq!(false.then_some(0), None); /// assert_eq!(false.then_some(0), None);
/// assert_eq!(true.then_some(0), Some(0)); /// 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")] #[stable(feature = "bool_to_option", since = "1.62.0")]
#[rustc_const_unstable(feature = "const_bool_to_option", issue = "91917")] #[rustc_const_unstable(feature = "const_bool_to_option", issue = "91917")]
#[inline] #[inline]
@ -37,6 +49,17 @@ impl bool {
/// assert_eq!(false.then(|| 0), None); /// assert_eq!(false.then(|| 0), None);
/// assert_eq!(true.then(|| 0), Some(0)); /// 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")] #[stable(feature = "lazy_bool_to_option", since = "1.50.0")]
#[rustc_const_unstable(feature = "const_bool_to_option", issue = "91917")] #[rustc_const_unstable(feature = "const_bool_to_option", issue = "91917")]
#[inline] #[inline]

View file

@ -573,8 +573,8 @@ impl FromStr for bool {
/// Parse a `bool` from a string. /// Parse a `bool` from a string.
/// ///
/// Yields a `Result<bool, ParseBoolError>`, because `s` may or may not /// The only accepted values are `"true"` and `"false"`. Any other input
/// actually be parseable. /// will return an error.
/// ///
/// # Examples /// # Examples
/// ///

View file

@ -145,8 +145,8 @@
//! abstracting over differences in common platforms, most notably Windows and //! abstracting over differences in common platforms, most notably Windows and
//! Unix derivatives. //! Unix derivatives.
//! //!
//! Common types of I/O, including [files], [TCP], [UDP], are defined in the //! Common types of I/O, including [files], [TCP], and [UDP], are defined in
//! [`io`], [`fs`], and [`net`] modules. //! the [`io`], [`fs`], and [`net`] modules.
//! //!
//! The [`thread`] module contains Rust's threading abstractions. [`sync`] //! The [`thread`] module contains Rust's threading abstractions. [`sync`]
//! contains further primitive shared memory types, including [`atomic`] and //! contains further primitive shared memory types, including [`atomic`] and

View file

@ -111,14 +111,9 @@ pub(crate) struct MarkdownWithToc<'a>(
pub(crate) Edition, pub(crate) Edition,
pub(crate) &'a Option<Playground>, pub(crate) &'a Option<Playground>,
); );
/// A tuple struct like `Markdown` that renders the markdown escaping HTML tags. /// A tuple struct like `Markdown` that renders the markdown escaping HTML tags
pub(crate) struct MarkdownHtml<'a>( /// and includes no paragraph tags.
pub(crate) &'a str, pub(crate) struct MarkdownItemInfo<'a>(pub(crate) &'a str, pub(crate) &'a mut IdMap);
pub(crate) &'a mut IdMap,
pub(crate) ErrorCodes,
pub(crate) Edition,
pub(crate) &'a Option<Playground>,
);
/// A tuple struct like `Markdown` that renders only the first paragraph. /// A tuple struct like `Markdown` that renders only the first paragraph.
pub(crate) struct MarkdownSummaryLine<'a>(pub &'a str, pub &'a [RenderedLink]); pub(crate) struct MarkdownSummaryLine<'a>(pub &'a str, pub &'a [RenderedLink]);
@ -1072,9 +1067,9 @@ impl MarkdownWithToc<'_> {
} }
} }
impl MarkdownHtml<'_> { impl MarkdownItemInfo<'_> {
pub(crate) fn into_string(self) -> String { 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 // This is actually common enough to special-case
if md.is_empty() { if md.is_empty() {
@ -1093,7 +1088,9 @@ impl MarkdownHtml<'_> {
let p = HeadingLinks::new(p, None, ids, HeadingOffset::H1); let p = HeadingLinks::new(p, None, ids, HeadingOffset::H1);
let p = Footnotes::new(p); let p = Footnotes::new(p);
let p = TableWrapper::new(p.map(|(ev, _)| ev)); 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); html::push_html(&mut s, p);
s s

View file

@ -1,5 +1,5 @@
use super::{find_testable_code, plain_text_summary, short_markdown_summary}; 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}; use rustc_span::edition::{Edition, DEFAULT_EDITION};
#[test] #[test]
@ -279,14 +279,13 @@ fn test_plain_text_summary() {
fn test_markdown_html_escape() { fn test_markdown_html_escape() {
fn t(input: &str, expect: &str) { fn t(input: &str, expect: &str) {
let mut idmap = IdMap::new(); let mut idmap = IdMap::new();
let output = let output = MarkdownItemInfo(input, &mut idmap).into_string();
MarkdownHtml(input, &mut idmap, ErrorCodes::Yes, DEFAULT_EDITION, &None).into_string();
assert_eq!(output, expect, "original: {}", input); assert_eq!(output, expect, "original: {}", input);
} }
t("`Struct<'a, T>`", "<p><code>Struct&lt;'a, T&gt;</code></p>\n"); t("`Struct<'a, T>`", "<code>Struct&lt;'a, T&gt;</code>");
t("Struct<'a, T>", "<p>Struct&lt;a, T&gt;</p>\n"); t("Struct<'a, T>", "Struct&lt;a, T&gt;");
t("Struct<br>", "<p>Struct&lt;br&gt;</p>\n"); t("Struct<br>", "Struct&lt;br&gt;");
} }
#[test] #[test]

View file

@ -74,7 +74,9 @@ use crate::html::format::{
PrintWithSpace, PrintWithSpace,
}; };
use crate::html::highlight; 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::sources;
use crate::html::static_files::SCRAPE_EXAMPLES_HELP_MD; use crate::html::static_files::SCRAPE_EXAMPLES_HELP_MD;
use crate::scrape_examples::{CallData, CallLocation}; use crate::scrape_examples::{CallData, CallLocation};
@ -584,7 +586,6 @@ fn short_item_info(
parent: Option<&clean::Item>, parent: Option<&clean::Item>,
) -> Vec<String> { ) -> Vec<String> {
let mut extra_info = vec![]; let mut extra_info = vec![];
let error_codes = cx.shared.codes;
if let Some(depr @ Deprecation { note, since, is_since_rustc_version: _, suggestion: _ }) = if let Some(depr @ Deprecation { note, since, is_since_rustc_version: _, suggestion: _ }) =
item.deprecation(cx.tcx()) item.deprecation(cx.tcx())
@ -608,13 +609,7 @@ fn short_item_info(
if let Some(note) = note { if let Some(note) = note {
let note = note.as_str(); let note = note.as_str();
let html = MarkdownHtml( let html = MarkdownItemInfo(note, &mut cx.id_map);
note,
&mut cx.id_map,
error_codes,
cx.shared.edition(),
&cx.shared.playground,
);
message.push_str(&format!(": {}", html.into_string())); message.push_str(&format!(": {}", html.into_string()));
} }
extra_info.push(format!( extra_info.push(format!(

View file

@ -1068,10 +1068,6 @@ so that we can apply CSS-filters to change the arrow color in themes */
font-size: 0.875rem; font-size: 0.875rem;
font-weight: normal; font-weight: normal;
} }
.stab p {
display: inline;
margin: 0;
}
.stab .emoji { .stab .emoji {
font-size: 1.25rem; font-size: 1.25rem;

View file

@ -7,7 +7,6 @@
// //
// See issue #59123 for a full explanation. // See issue #59123 for a full explanation.
// ignore-emscripten (sizes don't match)
// needs-unwind Size of Futures change on panic=abort // needs-unwind Size of Futures change on panic=abort
// run-pass // run-pass

View file

@ -6,7 +6,6 @@
// error-pattern: thread 'main' panicked at '`async fn` resumed after panicking' // error-pattern: thread 'main' panicked at '`async fn` resumed after panicking'
// edition:2018 // edition:2018
// ignore-wasm no panic or subprocess support // ignore-wasm no panic or subprocess support
// ignore-emscripten no panic or subprocess support
#![feature(generators, generator_trait)] #![feature(generators, generator_trait)]

View file

@ -3,7 +3,6 @@
// Check that partially moved from function parameters are dropped after the // Check that partially moved from function parameters are dropped after the
// named bindings that move from them. // named bindings that move from them.
// ignore-wasm32-bare compiled with panic=abort by default
use std::{panic, cell::RefCell}; use std::{panic, cell::RefCell};

View file

@ -3,7 +3,6 @@
#![allow(unused_variables)] #![allow(unused_variables)]
#![allow(unused_imports)] #![allow(unused_imports)]
// ignore-wasm32-bare compiled with panic=abort by default
// Test that builtin implementations of `Clone` cleanup everything // Test that builtin implementations of `Clone` cleanup everything
// in case of unwinding. // in case of unwinding.

View file

@ -1,6 +1,5 @@
// run-pass // run-pass
// needs-unwind // needs-unwind
// ignore-wasm32-bare compiled with panic=abort by default
fn worker() -> ! { fn worker() -> ! {
panic!() panic!()

View file

@ -1,9 +1,6 @@
// build-pass // build-pass
// compile-flags: -C panic=unwind // compile-flags: -C panic=unwind
// needs-unwind // needs-unwind
// ignore-emscripten no panic_unwind implementation
// ignore-wasm32 no panic_unwind implementation
// ignore-wasm64 no panic_unwind implementation
#[cfg(panic = "abort")] #[cfg(panic = "abort")]

View file

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

View file

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

View file

@ -1,5 +1,5 @@
error: changes to closure capture in Rust 2021 will affect which traits the closure implements 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 || { LL | let result = panic::catch_unwind(move || {
| ^^^^^^^ | ^^^^^^^

View file

@ -6,7 +6,6 @@
// run-pass // run-pass
// needs-unwind // needs-unwind
// edition:2018 // edition:2018
// ignore-wasm32-bare compiled with panic=abort by default
#![allow(unused)] #![allow(unused)]

View file

@ -1,6 +1,5 @@
// run-pass // run-pass
// needs-unwind // needs-unwind
// ignore-wasm32-bare compiled with panic=abort by default
#![feature(generators, generator_trait)] #![feature(generators, generator_trait)]

View file

@ -1,8 +1,5 @@
// run-pass // run-pass
// needs-unwind // needs-unwind
// ignore-wasm32-bare no unwinding panic
// ignore-avr no unwinding panic
// ignore-nvptx64 no unwinding panic
static mut CHECK: usize = 0; static mut CHECK: usize = 0;

View file

@ -1,6 +1,6 @@
// compile-flags: --extern std= // compile-flags: --extern std=
// error-pattern: extern location for std does not exist // error-pattern: extern location for std does not exist
// needs-unwind since it affects the error output // 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() {} fn main() {}

View file

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

View file

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

View file

@ -2,8 +2,6 @@
// run-pass // run-pass
// needs-unwind // needs-unwind
// ignore-wasm no unwind support
// ignore-emscripten no unwind support
#![feature(generators, generator_trait)] #![feature(generators, generator_trait)]

View file

@ -1,7 +1,6 @@
// run-pass // run-pass
// needs-unwind // needs-unwind
// ignore-wasm32-bare compiled with panic=abort by default
#![feature(generators, generator_trait)] #![feature(generators, generator_trait)]

View file

@ -1,7 +1,6 @@
// run-pass // run-pass
// needs-unwind // needs-unwind
// ignore-wasm32-bare compiled with panic=abort by default
#![feature(generators, generator_trait)] #![feature(generators, generator_trait)]

View file

@ -1,7 +1,6 @@
// run-pass // run-pass
// needs-unwind // needs-unwind
// ignore-wasm32-bare compiled with panic=abort by default
#![feature(generators, generator_trait)] #![feature(generators, generator_trait)]

View file

@ -1,6 +1,5 @@
// run-pass // run-pass
// needs-unwind // needs-unwind
// ignore-wasm32-bare compiled with panic=abort by default
// revisions: mir thir strict // revisions: mir thir strict
// [thir]compile-flags: -Zthir-unsafeck // [thir]compile-flags: -Zthir-unsafeck
// [strict]compile-flags: -Zstrict-init-checks // [strict]compile-flags: -Zstrict-init-checks

View file

@ -1,6 +1,5 @@
// run-pass // run-pass
// needs-unwind // needs-unwind
// ignore-wasm32-bare compiled with panic=abort by default
// Check that values are not leaked when a dtor panics (#14875) // Check that values are not leaked when a dtor panics (#14875)

View file

@ -1,6 +1,5 @@
// run-pass // run-pass
// needs-unwind // needs-unwind
// ignore-wasm32-bare compiled with panic=abort by default
use std::panic; use std::panic;

View file

@ -1,6 +1,5 @@
// run-pass // run-pass
// needs-unwind // needs-unwind
// ignore-wasm32-bare compiled with panic=abort by default
use std::panic; use std::panic;

View file

@ -2,7 +2,6 @@
// compile-flags:--test -O // compile-flags:--test -O
// needs-unwind // needs-unwind
// ignore-wasm32-bare compiled with panic=abort by default
#[test] #[test]
#[should_panic(expected = "creating inhabited type")] #[should_panic(expected = "creating inhabited type")]

View file

@ -1,7 +1,6 @@
// run-pass // run-pass
// only-32bit too impatient for 2⁶⁴ items // only-32bit too impatient for 2⁶⁴ items
// needs-unwind // needs-unwind
// ignore-wasm32-bare compiled with panic=abort by default
// compile-flags: -C debug_assertions=yes -C opt-level=3 // compile-flags: -C debug_assertions=yes -C opt-level=3
use std::panic; use std::panic;

View file

@ -1,7 +1,6 @@
// run-pass // run-pass
// only-32bit too impatient for 2⁶⁴ items // only-32bit too impatient for 2⁶⁴ items
// needs-unwind // needs-unwind
// ignore-wasm32-bare compiled with panic=abort by default
// compile-flags: -C debug_assertions=yes -C opt-level=3 // compile-flags: -C debug_assertions=yes -C opt-level=3
use std::panic; use std::panic;

View file

@ -1,6 +1,5 @@
// run-pass // run-pass
// needs-unwind // needs-unwind
// ignore-wasm32-bare compiled with panic=abort by default
// compile-flags: -C debug_assertions=yes // compile-flags: -C debug_assertions=yes
use std::panic; use std::panic;

View file

@ -1,6 +1,5 @@
// run-pass // run-pass
// needs-unwind // needs-unwind
// ignore-wasm32-bare compiled with panic=abort by default
// compile-flags: -C debug_assertions=yes // compile-flags: -C debug_assertions=yes
use std::panic; use std::panic;

View file

@ -1,6 +1,5 @@
// run-pass // run-pass
// needs-unwind // needs-unwind
// ignore-wasm32-bare compiled with panic=abort by default
// compile-flags: -C overflow-checks // compile-flags: -C overflow-checks
use std::panic; use std::panic;

View file

@ -14,7 +14,6 @@
// compile-flags: --test -C debug_assertions=yes // compile-flags: --test -C debug_assertions=yes
// revisions: std core // revisions: std core
// ignore-wasm32-bare compiled with panic=abort by default
#![cfg_attr(core, no_std)] #![cfg_attr(core, no_std)]
#[cfg(core)] #[cfg(core)]

View file

@ -1,6 +1,5 @@
// run-pass // run-pass
// needs-unwind // needs-unwind
// ignore-wasm32-bare compiled with panic=abort by default
#![feature(fn_traits)] #![feature(fn_traits)]
#![feature(never_type)] #![feature(never_type)]

View file

@ -1,7 +1,6 @@
// run-fail // run-fail
// error-pattern:diverging_fn called // error-pattern:diverging_fn called
// error-pattern:0 dropped // error-pattern:0 dropped
// ignore-emscripten no processes
// needs-unwind this test checks that a destructor is called after panicking // needs-unwind this test checks that a destructor is called after panicking
struct Droppable(u8); struct Droppable(u8);

View file

@ -1,6 +1,5 @@
// run-pass // run-pass
// needs-unwind // needs-unwind
// ignore-wasm32-bare compiled with panic=abort by default
use std::cell::RefCell; use std::cell::RefCell;
use std::panic; use std::panic;

View file

@ -2,7 +2,6 @@
// needs-unwind // needs-unwind
// error-pattern:panic 1 // error-pattern:panic 1
// error-pattern:drop 2 // error-pattern:drop 2
// ignore-emscripten no processes
struct Droppable(u32); struct Droppable(u32);
impl Drop for Droppable { impl Drop for Droppable {

View file

@ -1,6 +1,5 @@
// run-pass // run-pass
// needs-unwind // needs-unwind
// ignore-wasm32-bare compiled with panic=abort by default
// See `mir_drop_order.rs` for more information // See `mir_drop_order.rs` for more information

View file

@ -1,7 +1,6 @@
// run-pass // run-pass
// compile-flags: -C debug_assertions=yes // compile-flags: -C debug_assertions=yes
// needs-unwind // needs-unwind
// ignore-wasm32-bare compiled with panic=abort by default
// ignore-emscripten dies with an LLVM error // ignore-emscripten dies with an LLVM error
use std::panic; use std::panic;

View file

@ -2,7 +2,7 @@
// error-pattern: `#[panic_handler]` function required, but not found // error-pattern: `#[panic_handler]` function required, but not found
// error-pattern: language item required, but not found: `eh_personality` // error-pattern: language item required, but not found: `eh_personality`
// needs-unwind since it affects the error output // 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
#![no_std] #![no_std]

View file

@ -2,7 +2,6 @@
// needs-unwind // needs-unwind
// error-pattern:is incompatible with this crate's strategy of `unwind` // error-pattern:is incompatible with this crate's strategy of `unwind`
// aux-build:needs-abort.rs // aux-build:needs-abort.rs
// ignore-wasm32-bare compiled with panic=abort by default
extern crate needs_abort; extern crate needs_abort;

View file

@ -6,7 +6,6 @@
// aux-build:wants-panic-runtime-abort.rs // aux-build:wants-panic-runtime-abort.rs
// aux-build:panic-runtime-lang-items.rs // aux-build:panic-runtime-lang-items.rs
// error-pattern: is not compiled with this crate's panic strategy `unwind` // error-pattern: is not compiled with this crate's panic strategy `unwind`
// ignore-wasm32-bare compiled with panic=abort by default
#![no_std] #![no_std]
#![no_main] #![no_main]

View file

@ -3,7 +3,6 @@
// error-pattern:is not compiled with this crate's panic strategy `unwind` // error-pattern:is not compiled with this crate's panic strategy `unwind`
// aux-build:panic-runtime-abort.rs // aux-build:panic-runtime-abort.rs
// aux-build:panic-runtime-lang-items.rs // aux-build:panic-runtime-lang-items.rs
// ignore-wasm32-bare compiled with panic=abort by default
#![no_std] #![no_std]
#![no_main] #![no_main]

View file

@ -4,7 +4,6 @@
// aux-build:panic-runtime-abort.rs // aux-build:panic-runtime-abort.rs
// aux-build:wants-panic-runtime-abort.rs // aux-build:wants-panic-runtime-abort.rs
// aux-build:panic-runtime-lang-items.rs // aux-build:panic-runtime-lang-items.rs
// ignore-wasm32-bare compiled with panic=abort by default
#![no_std] #![no_std]
#![no_main] #![no_main]

View file

@ -1,6 +1,5 @@
// run-pass // run-pass
// needs-unwind // needs-unwind
// ignore-emscripten no subprocess support
#![feature(internal_output_capture)] #![feature(internal_output_capture)]

View file

@ -1,5 +1,4 @@
// run-pass // run-pass
// ignore-wasm32-bare compiled with panic=abort by default
// needs-unwind // needs-unwind
// aux-build:reachable-unnameable-items.rs // aux-build:reachable-unnameable-items.rs

View file

@ -2,7 +2,6 @@
// needs-unwind // needs-unwind
// aux-build:expand-with-a-macro.rs // aux-build:expand-with-a-macro.rs
// ignore-wasm32-bare compiled with panic=abort by default
#![deny(warnings)] #![deny(warnings)]

View file

@ -2,7 +2,6 @@
// run-pass // run-pass
// needs-unwind // needs-unwind
// ignore-wasm32-bare compiled with panic=abort by default
#![feature(test)] #![feature(test)]

View file

@ -1,6 +1,5 @@
// run-pass // run-pass
// needs-unwind // needs-unwind
// ignore-wasm32-bare compiled with panic=abort by default
// revisions: default mir-opt // revisions: default mir-opt
//[mir-opt] compile-flags: -Zmir-opt-level=4 //[mir-opt] compile-flags: -Zmir-opt-level=4

View file

@ -1,6 +1,5 @@
// run-pass // run-pass
// needs-unwind // needs-unwind
// ignore-wasm32-bare compiled with panic=abort by default
#![allow(dead_code, unreachable_code)] #![allow(dead_code, unreachable_code)]

View file

@ -2,9 +2,6 @@
// needs-unwind // needs-unwind
// ignore-emscripten no processes // ignore-emscripten no processes
// ignore-sgx no processes // ignore-sgx no processes
// ignore-wasm32-bare no unwinding panic
// ignore-avr no unwinding panic
// ignore-nvptx64 no unwinding panic
use std::env; use std::env;
use std::process::Command; use std::process::Command;

View file

@ -1,7 +1,6 @@
// compile-flags:--test // compile-flags:--test
// run-pass // run-pass
// needs-unwind // needs-unwind
// ignore-emscripten no subprocess support
use std::fmt; use std::fmt;
use std::fmt::{Display, Formatter}; use std::fmt::{Display, Formatter};

View file

@ -1,6 +1,5 @@
// run-pass // run-pass
// needs-unwind // needs-unwind
// ignore-wasm32-bare compiled with panic=abort by default
// compile-flags: --test // compile-flags: --test
#[test] #[test]
#[should_panic(expected = "foo")] #[should_panic(expected = "foo")]

View file

@ -24,10 +24,6 @@ mod assert {
Src, Src,
Context, Context,
{ from_options(ASSUME_ALIGNMENT, ASSUME_LIFETIMES, ASSUME_SAFETY, ASSUME_VALIDITY) } { from_options(ASSUME_ALIGNMENT, ASSUME_LIFETIMES, ASSUME_SAFETY, ASSUME_VALIDITY) }
//~^ ERROR E0080
//~| ERROR E0080
//~| ERROR E0080
//~| ERROR E0080
>, >,
{} {}

View file

@ -1,52 +1,27 @@
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/wrong-type-assume.rs:53:51 --> $DIR/wrong-type-assume.rs:49:51
| |
LL | assert::is_transmutable::<Src, Dst, Context, {0u8}, false, false, false>(); LL | assert::is_transmutable::<Src, Dst, Context, {0u8}, false, false, false>();
| ^^^ expected `bool`, found `u8` | ^^^ expected `bool`, found `u8`
error[E0080]: evaluation of `assert::is_transmutable::<test::Src, test::Dst, test::Context, {0u8}, false, false, false>::{constant#0}` failed
--> $DIR/wrong-type-assume.rs:26:15
|
LL | { from_options(ASSUME_ALIGNMENT, ASSUME_LIFETIMES, ASSUME_SAFETY, ASSUME_VALIDITY) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/wrong-type-assume.rs:54:58 --> $DIR/wrong-type-assume.rs:50:58
| |
LL | assert::is_transmutable::<Src, Dst, Context, false, {0u8}, false, false>(); LL | assert::is_transmutable::<Src, Dst, Context, false, {0u8}, false, false>();
| ^^^ expected `bool`, found `u8` | ^^^ expected `bool`, found `u8`
error[E0080]: evaluation of `assert::is_transmutable::<test::Src, test::Dst, test::Context, false, {0u8}, false, false>::{constant#0}` failed
--> $DIR/wrong-type-assume.rs:26:15
|
LL | { from_options(ASSUME_ALIGNMENT, ASSUME_LIFETIMES, ASSUME_SAFETY, ASSUME_VALIDITY) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/wrong-type-assume.rs:55:65 --> $DIR/wrong-type-assume.rs:51:65
| |
LL | assert::is_transmutable::<Src, Dst, Context, false, false, {0u8}, false>(); LL | assert::is_transmutable::<Src, Dst, Context, false, false, {0u8}, false>();
| ^^^ expected `bool`, found `u8` | ^^^ expected `bool`, found `u8`
error[E0080]: evaluation of `assert::is_transmutable::<test::Src, test::Dst, test::Context, false, false, {0u8}, false>::{constant#0}` failed
--> $DIR/wrong-type-assume.rs:26:15
|
LL | { from_options(ASSUME_ALIGNMENT, ASSUME_LIFETIMES, ASSUME_SAFETY, ASSUME_VALIDITY) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/wrong-type-assume.rs:56:72 --> $DIR/wrong-type-assume.rs:52:72
| |
LL | assert::is_transmutable::<Src, Dst, Context, false, false, false, {0u8}>(); LL | assert::is_transmutable::<Src, Dst, Context, false, false, false, {0u8}>();
| ^^^ expected `bool`, found `u8` | ^^^ expected `bool`, found `u8`
error[E0080]: evaluation of `assert::is_transmutable::<test::Src, test::Dst, test::Context, false, false, false, {0u8}>::{constant#0}` failed error: aborting due to 4 previous errors
--> $DIR/wrong-type-assume.rs:26:15
|
LL | { from_options(ASSUME_ALIGNMENT, ASSUME_LIFETIMES, ASSUME_SAFETY, ASSUME_VALIDITY) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
error: aborting due to 8 previous errors For more information about this error, try `rustc --explain E0308`.
Some errors have detailed explanations: E0080, E0308.
For more information about an error, try `rustc --explain E0080`.

View file

@ -1,6 +1,5 @@
// build-pass // build-pass
// needs-unwind // needs-unwind
// ignore-wasm32-bare compiled with panic=abort by default
#![feature(c_unwind)] #![feature(c_unwind)]
#![warn(ffi_unwind_calls)] #![warn(ffi_unwind_calls)]

View file

@ -1,17 +1,17 @@
warning: call to foreign function with FFI-unwind ABI warning: call to foreign function with FFI-unwind ABI
--> $DIR/ffi-unwind-calls-lint.rs:21:14 --> $DIR/ffi-unwind-calls-lint.rs:20:14
| |
LL | unsafe { foo(); } LL | unsafe { foo(); }
| ^^^^^ call to foreign function with FFI-unwind ABI | ^^^^^ call to foreign function with FFI-unwind ABI
| |
note: the lint level is defined here note: the lint level is defined here
--> $DIR/ffi-unwind-calls-lint.rs:6:9 --> $DIR/ffi-unwind-calls-lint.rs:5:9
| |
LL | #![warn(ffi_unwind_calls)] LL | #![warn(ffi_unwind_calls)]
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^
warning: call to function pointer with FFI-unwind ABI warning: call to function pointer with FFI-unwind ABI
--> $DIR/ffi-unwind-calls-lint.rs:25:5 --> $DIR/ffi-unwind-calls-lint.rs:24:5
| |
LL | ptr(); LL | ptr();
| ^^^^^ call to function pointer with FFI-unwind ABI | ^^^^^ call to function pointer with FFI-unwind ABI

View file

@ -1,7 +1,6 @@
// run-pass // run-pass
// needs-unwind // needs-unwind
// ignore-windows target requires uwtable // ignore-windows target requires uwtable
// ignore-wasm32-bare no proper panic=unwind support
// compile-flags: -C panic=unwind -C force-unwind-tables=n // compile-flags: -C panic=unwind -C force-unwind-tables=n
use std::panic::{self, AssertUnwindSafe}; use std::panic::{self, AssertUnwindSafe};

View file

@ -278,10 +278,6 @@ pub struct Config {
/// override this setting. /// override this setting.
pub optimize_tests: bool, pub optimize_tests: bool,
/// What panic strategy the target is built with. Unwind supports Abort, but
/// not vice versa.
pub target_panic: PanicStrategy,
/// Target system to be tested /// Target system to be tested
pub target: String, pub target: String,
@ -426,6 +422,10 @@ impl Config {
*&self.target_cfg().pointer_width *&self.target_cfg().pointer_width
} }
pub fn can_unwind(&self) -> bool {
self.target_cfg().panic == PanicStrategy::Unwind
}
pub fn has_asm_support(&self) -> bool { pub fn has_asm_support(&self) -> bool {
static ASM_SUPPORTED_ARCHS: &[&str] = &[ static ASM_SUPPORTED_ARCHS: &[&str] = &[
"x86", "x86_64", "arm", "aarch64", "riscv32", "x86", "x86_64", "arm", "aarch64", "riscv32",
@ -446,6 +446,7 @@ pub struct TargetCfg {
families: Vec<String>, families: Vec<String>,
pointer_width: u32, pointer_width: u32,
endian: Endian, endian: Endian,
panic: PanicStrategy,
} }
#[derive(Eq, PartialEq, Clone, Debug)] #[derive(Eq, PartialEq, Clone, Debug)]
@ -481,6 +482,7 @@ impl TargetCfg {
let mut families = Vec::new(); let mut families = Vec::new();
let mut pointer_width = None; let mut pointer_width = None;
let mut endian = None; let mut endian = None;
let mut panic = None;
for line in print_cfg.lines() { for line in print_cfg.lines() {
if let Some((name, value)) = line.split_once('=') { if let Some((name, value)) = line.split_once('=') {
let value = value.trim_matches('"'); let value = value.trim_matches('"');
@ -498,6 +500,13 @@ impl TargetCfg {
s => panic!("unexpected {s}"), s => panic!("unexpected {s}"),
}) })
} }
"panic" => {
panic = match value {
"abort" => Some(PanicStrategy::Abort),
"unwind" => Some(PanicStrategy::Unwind),
s => panic!("unexpected {s}"),
}
}
_ => {} _ => {}
} }
} }
@ -510,6 +519,7 @@ impl TargetCfg {
families, families,
pointer_width: pointer_width.unwrap(), pointer_width: pointer_width.unwrap(),
endian: endian.unwrap(), endian: endian.unwrap(),
panic: panic.unwrap(),
} }
} }
} }

View file

@ -7,7 +7,7 @@ use std::path::{Path, PathBuf};
use tracing::*; use tracing::*;
use crate::common::{CompareMode, Config, Debugger, FailMode, Mode, PanicStrategy, PassMode}; use crate::common::{CompareMode, Config, Debugger, FailMode, Mode, PassMode};
use crate::util; use crate::util;
use crate::{extract_cdb_version, extract_gdb_version}; use crate::{extract_cdb_version, extract_gdb_version};
@ -949,8 +949,7 @@ pub fn make_test_description<R: Read>(
ignore |= !has_memtag && config.parse_name_directive(ln, "needs-sanitizer-memtag"); ignore |= !has_memtag && config.parse_name_directive(ln, "needs-sanitizer-memtag");
ignore |= !has_shadow_call_stack ignore |= !has_shadow_call_stack
&& config.parse_name_directive(ln, "needs-sanitizer-shadow-call-stack"); && config.parse_name_directive(ln, "needs-sanitizer-shadow-call-stack");
ignore |= config.target_panic == PanicStrategy::Abort ignore |= !config.can_unwind() && config.parse_name_directive(ln, "needs-unwind");
&& config.parse_name_directive(ln, "needs-unwind");
ignore |= config.target == "wasm32-unknown-unknown" ignore |= config.target == "wasm32-unknown-unknown"
&& config.parse_name_directive(ln, directives::CHECK_RUN_RESULTS); && config.parse_name_directive(ln, directives::CHECK_RUN_RESULTS);
ignore |= config.debugger == Some(Debugger::Cdb) && ignore_cdb(config, ln); ignore |= config.debugger == Some(Debugger::Cdb) && ignore_cdb(config, ln);

View file

@ -5,9 +5,7 @@
extern crate test; extern crate test;
use crate::common::{ use crate::common::{expected_output_path, output_base_dir, output_relative_path, UI_EXTENSIONS};
expected_output_path, output_base_dir, output_relative_path, PanicStrategy, UI_EXTENSIONS,
};
use crate::common::{CompareMode, Config, Debugger, Mode, PassMode, TestPaths}; use crate::common::{CompareMode, Config, Debugger, Mode, PassMode, TestPaths};
use crate::util::logv; use crate::util::logv;
use getopts::Options; use getopts::Options;
@ -105,7 +103,6 @@ pub fn parse_config(args: Vec<String>) -> Config {
.optmulti("", "host-rustcflags", "flags to pass to rustc for host", "FLAGS") .optmulti("", "host-rustcflags", "flags to pass to rustc for host", "FLAGS")
.optmulti("", "target-rustcflags", "flags to pass to rustc for target", "FLAGS") .optmulti("", "target-rustcflags", "flags to pass to rustc for target", "FLAGS")
.optflag("", "optimize-tests", "run tests with optimizations enabled") .optflag("", "optimize-tests", "run tests with optimizations enabled")
.optopt("", "target-panic", "what panic strategy the target supports", "unwind | abort")
.optflag("", "verbose", "run tests verbosely, showing all output") .optflag("", "verbose", "run tests verbosely, showing all output")
.optflag( .optflag(
"", "",
@ -258,11 +255,6 @@ pub fn parse_config(args: Vec<String>) -> Config {
host_rustcflags: Some(matches.opt_strs("host-rustcflags").join(" ")), host_rustcflags: Some(matches.opt_strs("host-rustcflags").join(" ")),
target_rustcflags: Some(matches.opt_strs("target-rustcflags").join(" ")), target_rustcflags: Some(matches.opt_strs("target-rustcflags").join(" ")),
optimize_tests: matches.opt_present("optimize-tests"), optimize_tests: matches.opt_present("optimize-tests"),
target_panic: match matches.opt_str("target-panic").as_deref() {
Some("unwind") | None => PanicStrategy::Unwind,
Some("abort") => PanicStrategy::Abort,
_ => panic!("unknown `--target-panic` option `{}` given", mode),
},
target, target,
host: opt_str2(matches.opt_str("host")), host: opt_str2(matches.opt_str("host")),
cdb, cdb,

View file

@ -1,3 +1,4 @@
#![cfg_attr(bootstrap, feature(let_else))]
#![allow(clippy::useless_format, clippy::derive_partial_eq_without_eq, rustc::internal)] #![allow(clippy::useless_format, clippy::derive_partial_eq_without_eq, rustc::internal)]
#[macro_use] #[macro_use]

View file

@ -10,6 +10,7 @@
#![feature(is_some_with)] #![feature(is_some_with)]
#![feature(nonzero_ops)] #![feature(nonzero_ops)]
#![feature(local_key_cell_methods)] #![feature(local_key_cell_methods)]
#![cfg_attr(bootstrap, feature(let_else))]
// Configure clippy and other lints // Configure clippy and other lints
#![allow( #![allow(
clippy::collapsible_else_if, clippy::collapsible_else_if,

View file

@ -0,0 +1,22 @@
#![feature(type_alias_impl_trait)]
trait T { type Item; }
type Alias<'a> = impl T<Item = &'a ()>;
struct S;
impl<'a> T for &'a S {
type Item = &'a ();
}
fn filter_positive<'a>() -> Alias<'a> {
&S
}
fn with_positive(fun: impl Fn(Alias<'_>)) {
fun(filter_positive());
}
fn main() {
with_positive(|_| ());
}