From acd39ff0feb91a2f119e30710af0e0c021599fe1 Mon Sep 17 00:00:00 2001 From: Alan Egerton Date: Wed, 1 Dec 2021 17:57:09 +0000 Subject: [PATCH 1/8] Make IdFunctor::try_map_id panic-safe --- compiler/rustc_data_structures/src/functor.rs | 53 ++++++++++--------- compiler/rustc_data_structures/src/lib.rs | 1 + 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/compiler/rustc_data_structures/src/functor.rs b/compiler/rustc_data_structures/src/functor.rs index 71ff762c714bf..a3d3f988344c6 100644 --- a/compiler/rustc_data_structures/src/functor.rs +++ b/compiler/rustc_data_structures/src/functor.rs @@ -34,38 +34,43 @@ impl IdFunctor for Vec { type Inner = T; #[inline] - fn try_map_id(mut self, mut f: F) -> Result + fn try_map_id(self, mut f: F) -> Result where F: FnMut(Self::Inner) -> Result, { - // FIXME: We don't really care about panics here and leak - // far more than we should, but that should be fine for now. - let len = self.len(); - unsafe { - self.set_len(0); - let start = self.as_mut_ptr(); - for i in 0..len { - let p = start.add(i); - match f(p.read()) { - Ok(val) => p.write(val), - Err(err) => { - // drop all other elements in self - // (current element was "moved" into the call to f) - for j in (0..i).chain(i + 1..len) { - start.add(j).drop_in_place(); - } + struct HoleVec { + vec: Vec>, + hole: Option, + } - // returning will drop self, releasing the allocation - // (len is 0 so elements will not be re-dropped) - return Err(err); + impl Drop for HoleVec { + fn drop(&mut self) { + unsafe { + for (index, slot) in self.vec.iter_mut().enumerate() { + if self.hole != Some(index) { + mem::ManuallyDrop::drop(slot); + } } } } - // Even if we encountered an error, set the len back - // so we don't leak memory. - self.set_len(len); } - Ok(self) + + unsafe { + let (ptr, length, capacity) = self.into_raw_parts(); + let vec = Vec::from_raw_parts(ptr.cast(), length, capacity); + let mut hole_vec = HoleVec { vec, hole: None }; + + for (index, slot) in hole_vec.vec.iter_mut().enumerate() { + hole_vec.hole = Some(index); + let original = mem::ManuallyDrop::take(slot); + let mapped = f(original)?; + *slot = mem::ManuallyDrop::new(mapped); + hole_vec.hole = None; + } + + mem::forget(hole_vec); + Ok(Vec::from_raw_parts(ptr, length, capacity)) + } } } diff --git a/compiler/rustc_data_structures/src/lib.rs b/compiler/rustc_data_structures/src/lib.rs index e17724b72f8b8..181e5180d53d5 100644 --- a/compiler/rustc_data_structures/src/lib.rs +++ b/compiler/rustc_data_structures/src/lib.rs @@ -23,6 +23,7 @@ #![feature(once_cell)] #![feature(test)] #![feature(thread_id_value)] +#![feature(vec_into_raw_parts)] #![allow(rustc::default_hash_types)] #![deny(unaligned_references)] From e36da67a5ea12cdc0dd589f89b57b21d70385720 Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Wed, 8 Dec 2021 16:05:31 -0800 Subject: [PATCH 2/8] rustdoc: Show type layout for type aliases At first, you might think, "Why not just click through to the aliased type?" But, if a type alias instantiates all of the generic parameters of the aliased type, then it can show layout info even though the aliased type cannot (because we can't compute layout for generic types). So, I think it's useful to show layout info for type aliases. This is a followup of 78d4b453ad2e19d44011b26fc55c949bff5dba3d (originally part of #83501). --- src/librustdoc/html/render/print_item.rs | 1 + src/test/rustdoc/type-layout.rs | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index e139ac8581e72..2fae5495b0af1 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -976,6 +976,7 @@ fn item_typedef( // associated items from the aliased type (see discussion in #32077), but // we need #14072 to make sense of the generics. render_assoc_items(w, cx, it, def_id, AssocItemRender::All); + document_type_layout(w, cx, def_id); } fn item_union(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::Union) { diff --git a/src/test/rustdoc/type-layout.rs b/src/test/rustdoc/type-layout.rs index 0868486fa59cd..4eea9809ac58f 100644 --- a/src/test/rustdoc/type-layout.rs +++ b/src/test/rustdoc/type-layout.rs @@ -50,6 +50,18 @@ pub struct GenericLifetimes<'a>(&'a str); // @has - '(unsized)' pub struct Unsized([u8]); +// @has type_layout/type.TypeAlias.html 'Size: ' +// @has - ' bytes' +pub type TypeAlias = X; + +// @has type_layout/type.GenericTypeAlias.html 'Size: ' +// @has - '8 bytes' +pub type GenericTypeAlias = (Generic<(u32, ())>, Generic); + +// Regression test for the rustdoc equivalent of #85103. +// @has type_layout/type.Edges.html 'Encountered an error during type layout; the type failed to be normalized.' +pub type Edges<'a, E> = std::borrow::Cow<'a, [E]>; + // @!has type_layout/trait.MyTrait.html 'Size: ' pub trait MyTrait {} From 769a70726963647c2be6b5a470547bf74088bcbe Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 7 Dec 2021 13:29:20 +1100 Subject: [PATCH 3/8] Improve the readability of `List`. This commit does the following. - Expands on some of the things already mentioned in comments. - Describes the uniqueness assumption, which is critical but wasn't mentioned at all. - Rewrites `empty()` into a clearer form, as provided by Daniel Henry-Mantilla on Zulip. - Reorders things slightly so that more important things are higher up, and incidental things are lower down, which makes reading the code easier. --- compiler/rustc_middle/src/ty/list.rs | 140 +++++++++++++++++---------- 1 file changed, 89 insertions(+), 51 deletions(-) diff --git a/compiler/rustc_middle/src/ty/list.rs b/compiler/rustc_middle/src/ty/list.rs index 1dceda6c7aad0..adba7d131592e 100644 --- a/compiler/rustc_middle/src/ty/list.rs +++ b/compiler/rustc_middle/src/ty/list.rs @@ -1,7 +1,5 @@ use crate::arena::Arena; - use rustc_serialize::{Encodable, Encoder}; - use std::alloc::Layout; use std::cmp::Ordering; use std::fmt; @@ -12,49 +10,69 @@ use std::ops::Deref; use std::ptr; use std::slice; -extern "C" { - /// A dummy type used to force `List` to be unsized while not requiring references to it be wide - /// pointers. - type OpaqueListContents; -} - -/// A wrapper for slices with the additional invariant -/// that the slice is interned and no other slice with -/// the same contents can exist in the same context. -/// This means we can use pointer for both -/// equality comparisons and hashing. -/// -/// Unlike slices, the types contained in `List` are expected to be `Copy` -/// and iterating over a `List` returns `T` instead of a reference. -/// -/// Note: `Slice` was already taken by the `Ty`. +/// `List` is a bit like `&[T]`, but with some critical differences. +/// - IMPORTANT: Every `List` is *required* to have unique contents. The +/// type's correctness relies on this, *but it does not enforce it*. +/// Therefore, any code that creates a `List` must ensure uniqueness +/// itself. In practice this is achieved by interning. +/// - The length is stored within the `List`, so `&List` is a thin +/// pointer. +/// - Because of this, you cannot get a `List` that is a sub-list of another +/// `List`. You can get a sub-slice `&[T]`, however. +/// - `List` can be used with `CopyTaggedPtr`, which is useful within +/// structs whose size must be minimized. +/// - Because of the uniqueness assumption, we can use the address of a +/// `List` for faster equality comparisons and hashing. +/// - `T` must be `Copy`. This lets `List` be stored in a dropless arena and +/// iterators return a `T` rather than a `&T`. +/// - `T` must not be zero-sized. #[repr(C)] pub struct List { len: usize, + + /// Although this claims to be a zero-length array, in practice `len` + /// elements are actually present. data: [T; 0], + opaque: OpaqueListContents, } -unsafe impl<'a, T: 'a> rustc_data_structures::tagged_ptr::Pointer for &'a List { - const BITS: usize = std::mem::align_of::().trailing_zeros() as usize; - #[inline] - fn into_usize(self) -> usize { - self as *const List as usize - } - #[inline] - unsafe fn from_usize(ptr: usize) -> Self { - &*(ptr as *const List) - } - unsafe fn with_ref R>(ptr: usize, f: F) -> R { - // Self: Copy so this is fine - let ptr = Self::from_usize(ptr); - f(&ptr) - } +extern "C" { + /// A dummy type used to force `List` to be unsized while not requiring + /// references to it be wide pointers. + type OpaqueListContents; } -unsafe impl Sync for List {} +impl List { + /// Returns a reference to the (unique, static) empty list. + #[inline(always)] + pub fn empty<'a>() -> &'a List { + #[repr(align(64))] + struct MaxAlign; + + assert!(mem::align_of::() <= mem::align_of::()); + + #[repr(C)] + struct InOrder(T, U); + + // The empty slice is static and contains a single `0` usize (for the + // length) that is 64-byte aligned, thus featuring the necessary + // trailing padding for elements with up to 64-byte alignment. + static EMPTY_SLICE: InOrder = InOrder(0, MaxAlign); + unsafe { &*(&EMPTY_SLICE as *const _ as *const List) } + } +} impl List { + /// Allocates a list from `arena` and copies the contents of `slice` into it. + /// + /// WARNING: the contents *must be unique*, such that no list with these + /// contents has been previously created. If not, operations such as `eq` + /// and `hash` might give incorrect results. + /// + /// Panics if `T` is `Drop`, or `T` is zero-sized, or the slice is empty + /// (because the empty list exists statically, and is available via + /// `empty()`). #[inline] pub(super) fn from_arena<'tcx>(arena: &'tcx Arena<'tcx>, slice: &[T]) -> &'tcx List { assert!(!mem::needs_drop::()); @@ -73,7 +91,7 @@ impl List { .cast::() .copy_from_nonoverlapping(slice.as_ptr(), slice.len()); - &mut *mem + &*mem } } @@ -107,11 +125,24 @@ impl> Encodable for &List { } } +impl PartialEq for List { + #[inline] + fn eq(&self, other: &List) -> bool { + // Pointer equality implies list equality (due to the unique contents + // assumption). + ptr::eq(self, other) + } +} + +impl Eq for List {} + impl Ord for List where T: Ord, { fn cmp(&self, other: &List) -> Ordering { + // Pointer equality implies list equality (due to the unique contents + // assumption), but the contents must be compared otherwise. if self == other { Ordering::Equal } else { <[T] as Ord>::cmp(&**self, &**other) } } } @@ -121,6 +152,8 @@ where T: PartialOrd, { fn partial_cmp(&self, other: &List) -> Option { + // Pointer equality implies list equality (due to the unique contents + // assumption), but the contents must be compared otherwise. if self == other { Some(Ordering::Equal) } else { @@ -129,17 +162,11 @@ where } } -impl PartialEq for List { - #[inline] - fn eq(&self, other: &List) -> bool { - ptr::eq(self, other) - } -} -impl Eq for List {} - impl Hash for List { #[inline] fn hash(&self, s: &mut H) { + // Pointer hashing is sufficient (due to the unique contents + // assumption). (self as *const List).hash(s) } } @@ -168,13 +195,24 @@ impl<'a, T: Copy> IntoIterator for &'a List { } } -impl List { - #[inline(always)] - pub fn empty<'a>() -> &'a List { - #[repr(align(64), C)] - struct EmptySlice([u8; 64]); - static EMPTY_SLICE: EmptySlice = EmptySlice([0; 64]); - assert!(mem::align_of::() <= 64); - unsafe { &*(&EMPTY_SLICE as *const _ as *const List) } +unsafe impl Sync for List {} + +unsafe impl<'a, T: 'a> rustc_data_structures::tagged_ptr::Pointer for &'a List { + const BITS: usize = std::mem::align_of::().trailing_zeros() as usize; + + #[inline] + fn into_usize(self) -> usize { + self as *const List as usize + } + + #[inline] + unsafe fn from_usize(ptr: usize) -> &'a List { + &*(ptr as *const List) + } + + unsafe fn with_ref R>(ptr: usize, f: F) -> R { + // `Self` is `&'a List` which impls `Copy`, so this is fine. + let ptr = Self::from_usize(ptr); + f(&ptr) } } From 258fd8974e66ae4e5bb243954bcf856ddd9204d4 Mon Sep 17 00:00:00 2001 From: Shivani Bhardwaj Date: Thu, 9 Dec 2021 23:05:08 +0530 Subject: [PATCH 4/8] Add deprecation warning for --passes --- src/librustdoc/config.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index 04bcade156a9d..2c917e0f49687 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -327,6 +327,19 @@ impl Options { return Err(0); } + let color = config::parse_color(matches); + let config::JsonConfig { json_rendered, json_unused_externs, .. } = + config::parse_json(matches); + let error_format = config::parse_error_format(matches, color, json_rendered); + + let codegen_options = CodegenOptions::build(matches, error_format); + let debugging_opts = DebuggingOptions::build(matches, error_format); + + let diag = new_handler(error_format, None, &debugging_opts); + + // check for deprecated options + check_deprecated_options(matches, &diag); + if matches.opt_strs("passes") == ["list"] { println!("Available passes for running rustdoc:"); for pass in passes::PASSES { @@ -359,19 +372,6 @@ impl Options { return Err(0); } - let color = config::parse_color(matches); - let config::JsonConfig { json_rendered, json_unused_externs, .. } = - config::parse_json(matches); - let error_format = config::parse_error_format(matches, color, json_rendered); - - let codegen_options = CodegenOptions::build(matches, error_format); - let debugging_opts = DebuggingOptions::build(matches, error_format); - - let diag = new_handler(error_format, None, &debugging_opts); - - // check for deprecated options - check_deprecated_options(matches, &diag); - let mut emit = Vec::new(); for list in matches.opt_strs("emit") { for kind in list.split(',') { From e472fea0789f202c0a1019e08b7fa041d36c355b Mon Sep 17 00:00:00 2001 From: Shivani Bhardwaj Date: Thu, 9 Dec 2021 23:46:13 +0530 Subject: [PATCH 5/8] Add test for deprecation warning for --passes --- src/test/rustdoc-ui/issue-91713.rs | 2 ++ src/test/rustdoc-ui/issue-91713.stderr | 4 ++++ src/test/rustdoc-ui/issue-91713.stdout | 31 ++++++++++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 src/test/rustdoc-ui/issue-91713.rs create mode 100644 src/test/rustdoc-ui/issue-91713.stderr create mode 100644 src/test/rustdoc-ui/issue-91713.stdout diff --git a/src/test/rustdoc-ui/issue-91713.rs b/src/test/rustdoc-ui/issue-91713.rs new file mode 100644 index 0000000000000..a7f8270e4be88 --- /dev/null +++ b/src/test/rustdoc-ui/issue-91713.rs @@ -0,0 +1,2 @@ +// check-pass +// compile-flags: --passes list diff --git a/src/test/rustdoc-ui/issue-91713.stderr b/src/test/rustdoc-ui/issue-91713.stderr new file mode 100644 index 0000000000000..70c22b3c01e9e --- /dev/null +++ b/src/test/rustdoc-ui/issue-91713.stderr @@ -0,0 +1,4 @@ +warning: the `passes` flag is deprecated + | + = note: see issue #44136 for more information + diff --git a/src/test/rustdoc-ui/issue-91713.stdout b/src/test/rustdoc-ui/issue-91713.stdout new file mode 100644 index 0000000000000..d0372d4945f3a --- /dev/null +++ b/src/test/rustdoc-ui/issue-91713.stdout @@ -0,0 +1,31 @@ +Available passes for running rustdoc: +check_doc_test_visibility - run various visibility-related lints on doctests + strip-hidden - strips all `#[doc(hidden)]` items from the output + unindent-comments - removes excess indentation on comments in order for markdown to like it + strip-private - strips all private items from a crate which cannot be seen externally, implies strip-priv-imports + strip-priv-imports - strips all private import statements (`use`, `extern crate`) from a crate + propagate-doc-cfg - propagates `#[doc(cfg(...))]` to child items +collect-intra-doc-links - resolves intra-doc links +check-code-block-syntax - validates syntax inside Rust code blocks + collect-trait-impls - retrieves trait impls for items in the crate +calculate-doc-coverage - counts the number of items with and without documentation +check-invalid-html-tags - detects invalid HTML tags in doc comments + check-bare-urls - detects URLs that are not hyperlinks + +Default passes for rustdoc: + collect-trait-impls + unindent-comments +check_doc_test_visibility + strip-hidden (when not --document-hidden-items) + strip-private (when not --document-private-items) + strip-priv-imports (when --document-private-items) +collect-intra-doc-links +check-code-block-syntax +check-invalid-html-tags + propagate-doc-cfg + check-bare-urls + +Passes run with `--show-coverage`: + strip-hidden (when not --document-hidden-items) + strip-private (when not --document-private-items) +calculate-doc-coverage From 2b6987d91fda4d47415914acc54afc26be837ac2 Mon Sep 17 00:00:00 2001 From: Shivani Bhardwaj <57791542+inashivb@users.noreply.github.com> Date: Fri, 10 Dec 2021 00:08:24 +0530 Subject: [PATCH 6/8] Update src/test/rustdoc-ui/issue-91713.rs Co-authored-by: Joshua Nelson --- src/test/rustdoc-ui/issue-91713.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/rustdoc-ui/issue-91713.rs b/src/test/rustdoc-ui/issue-91713.rs index a7f8270e4be88..b7057d868c275 100644 --- a/src/test/rustdoc-ui/issue-91713.rs +++ b/src/test/rustdoc-ui/issue-91713.rs @@ -1,2 +1,3 @@ // check-pass // compile-flags: --passes list +// error-pattern: the `passes` flag is deprecated From 7d18a456cafa4bc09fe6ac014b208e3f9570f18b Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 9 Dec 2021 12:45:00 -0500 Subject: [PATCH 7/8] give more help in the unaligned_references lint --- compiler/rustc_mir_transform/src/check_packed_ref.rs | 5 +++++ src/test/ui/binding/issue-53114-safety-checks.stderr | 4 ++++ .../2229_closure_analysis/diagnostics/repr_packed.stderr | 1 + src/test/ui/lint/unaligned_references.stderr | 7 +++++++ .../ui/lint/unaligned_references_external_macro.stderr | 1 + src/test/ui/packed/issue-27060.stderr | 4 ++++ .../ui/packed/packed-struct-borrow-element-64bit.stderr | 1 + src/test/ui/packed/packed-struct-borrow-element.stderr | 2 ++ 8 files changed, 25 insertions(+) diff --git a/compiler/rustc_mir_transform/src/check_packed_ref.rs b/compiler/rustc_mir_transform/src/check_packed_ref.rs index c6661e9c74e9b..23d59c8007135 100644 --- a/compiler/rustc_mir_transform/src/check_packed_ref.rs +++ b/compiler/rustc_mir_transform/src/check_packed_ref.rs @@ -105,6 +105,11 @@ impl<'tcx> Visitor<'tcx> for PackedRefChecker<'_, 'tcx> { a misaligned reference is undefined behavior (even if that \ reference is never dereferenced)", ) + .help( + "copy the field contents to a local variable, or replace the \ + reference with a raw pointer and use `read_unaligned`/`write_unaligned` \ + (loads and stores via `*p` must be properly aligned even when using raw pointers)" + ) .emit() }, ); diff --git a/src/test/ui/binding/issue-53114-safety-checks.stderr b/src/test/ui/binding/issue-53114-safety-checks.stderr index 9e7deea4524cb..84cdb1453f82d 100644 --- a/src/test/ui/binding/issue-53114-safety-checks.stderr +++ b/src/test/ui/binding/issue-53114-safety-checks.stderr @@ -8,6 +8,7 @@ LL | let _ = &p.b; = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #82523 = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) warning: reference to packed field is unaligned --> $DIR/issue-53114-safety-checks.rs:29:17 @@ -18,6 +19,7 @@ LL | let (_,) = (&p.b,); = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #82523 = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) warning: reference to packed field is unaligned --> $DIR/issue-53114-safety-checks.rs:39:11 @@ -28,6 +30,7 @@ LL | match &p.b { _ => { } } = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #82523 = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) warning: reference to packed field is unaligned --> $DIR/issue-53114-safety-checks.rs:45:12 @@ -38,6 +41,7 @@ LL | match (&p.b,) { (_,) => { } } = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #82523 = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0133]: access to union field is unsafe and requires unsafe function or block --> $DIR/issue-53114-safety-checks.rs:26:13 diff --git a/src/test/ui/closures/2229_closure_analysis/diagnostics/repr_packed.stderr b/src/test/ui/closures/2229_closure_analysis/diagnostics/repr_packed.stderr index 5acf3797ab53f..fc0179d2cb4ca 100644 --- a/src/test/ui/closures/2229_closure_analysis/diagnostics/repr_packed.stderr +++ b/src/test/ui/closures/2229_closure_analysis/diagnostics/repr_packed.stderr @@ -8,6 +8,7 @@ LL | println!("{}", foo.x); = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #82523 = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) = note: this warning originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) warning: 1 warning emitted diff --git a/src/test/ui/lint/unaligned_references.stderr b/src/test/ui/lint/unaligned_references.stderr index 6a5cc91963da0..53c9380fb7efb 100644 --- a/src/test/ui/lint/unaligned_references.stderr +++ b/src/test/ui/lint/unaligned_references.stderr @@ -12,6 +12,7 @@ LL | #![deny(unaligned_references)] = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #82523 = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error: reference to packed field is unaligned --> $DIR/unaligned_references.rs:24:17 @@ -22,6 +23,7 @@ LL | let _ = &good.data; = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #82523 = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error: reference to packed field is unaligned --> $DIR/unaligned_references.rs:27:17 @@ -32,6 +34,7 @@ LL | let _ = &good.data as *const _; = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #82523 = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error: reference to packed field is unaligned --> $DIR/unaligned_references.rs:29:27 @@ -42,6 +45,7 @@ LL | let _: *const _ = &good.data; = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #82523 = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error: reference to packed field is unaligned --> $DIR/unaligned_references.rs:32:17 @@ -52,6 +56,7 @@ LL | let _ = good.data.clone(); = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #82523 = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error: reference to packed field is unaligned --> $DIR/unaligned_references.rs:35:17 @@ -62,6 +67,7 @@ LL | let _ = &good.data2[0]; = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #82523 = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error: reference to packed field is unaligned --> $DIR/unaligned_references.rs:45:17 @@ -72,6 +78,7 @@ LL | let _ = &packed2.x; = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #82523 = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error: aborting due to 7 previous errors diff --git a/src/test/ui/lint/unaligned_references_external_macro.stderr b/src/test/ui/lint/unaligned_references_external_macro.stderr index 5e84fdca1d3ce..01e2395049df4 100644 --- a/src/test/ui/lint/unaligned_references_external_macro.stderr +++ b/src/test/ui/lint/unaligned_references_external_macro.stderr @@ -24,6 +24,7 @@ LL | | } = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #82523 = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) = note: this error originates in the macro `unaligned_references_external_crate::mac` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/packed/issue-27060.stderr b/src/test/ui/packed/issue-27060.stderr index 09297884ed377..bba056d59f831 100644 --- a/src/test/ui/packed/issue-27060.stderr +++ b/src/test/ui/packed/issue-27060.stderr @@ -12,6 +12,7 @@ LL | #[deny(unaligned_references)] = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #82523 = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error: reference to packed field is unaligned --> $DIR/issue-27060.rs:18:13 @@ -22,6 +23,7 @@ LL | let _ = &good.data2[0]; = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #82523 = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error: reference to packed field is unaligned --> $DIR/issue-27060.rs:21:13 @@ -32,6 +34,7 @@ LL | let _ = &good.data; = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #82523 = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error: reference to packed field is unaligned --> $DIR/issue-27060.rs:23:13 @@ -42,6 +45,7 @@ LL | let _ = &good.data2[0]; = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #82523 = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error: aborting due to 4 previous errors diff --git a/src/test/ui/packed/packed-struct-borrow-element-64bit.stderr b/src/test/ui/packed/packed-struct-borrow-element-64bit.stderr index 766d8a72c349e..04585b499862b 100644 --- a/src/test/ui/packed/packed-struct-borrow-element-64bit.stderr +++ b/src/test/ui/packed/packed-struct-borrow-element-64bit.stderr @@ -8,6 +8,7 @@ LL | let brw = &foo.baz; = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #82523 = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) warning: 1 warning emitted diff --git a/src/test/ui/packed/packed-struct-borrow-element.stderr b/src/test/ui/packed/packed-struct-borrow-element.stderr index 5764e951a4600..a50b130200151 100644 --- a/src/test/ui/packed/packed-struct-borrow-element.stderr +++ b/src/test/ui/packed/packed-struct-borrow-element.stderr @@ -8,6 +8,7 @@ LL | let brw = &foo.baz; = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #82523 = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) warning: reference to packed field is unaligned --> $DIR/packed-struct-borrow-element.rs:30:15 @@ -18,6 +19,7 @@ LL | let brw = &foo.baz; = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #82523 = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) warning: 2 warnings emitted From ea68758299a89556e67f0bfffffb19c0c8346e8a Mon Sep 17 00:00:00 2001 From: David Koloski Date: Fri, 3 Dec 2021 15:32:51 +0000 Subject: [PATCH 8/8] Add needs-unwind to tests that depend on panicking This directive isn't automatically set by compiletest or x.py, but can be turned on manually for targets that require it. --- src/test/ui/array-slice-vec/box-of-array-of-drop-1.rs | 1 + src/test/ui/array-slice-vec/box-of-array-of-drop-2.rs | 1 + src/test/ui/array-slice-vec/nested-vec-3.rs | 1 + src/test/ui/array-slice-vec/slice-panic-1.rs | 1 + src/test/ui/array-slice-vec/slice-panic-2.rs | 1 + .../issue-65419/issue-65419-async-fn-resume-after-panic.rs | 1 + src/test/ui/binding/fn-arg-incomplete-pattern-drop-order.rs | 1 + src/test/ui/builtin-clone-unwind.rs | 1 + src/test/ui/catch-unwind-bang.rs | 1 + src/test/ui/cleanup-rvalue-temp-during-incomplete-alloc.rs | 1 + .../2229_closure_analysis/migrations/mir_calls_to_shims.fixed | 1 + .../2229_closure_analysis/migrations/mir_calls_to_shims.rs | 1 + .../migrations/mir_calls_to_shims.stderr | 4 ++-- src/test/ui/drop/drop-trait-enum.rs | 1 + src/test/ui/drop/dynamic-drop-async.rs | 1 + src/test/ui/drop/dynamic-drop.rs | 1 + src/test/ui/drop/terminate-in-initializer.rs | 1 + .../issue-64655-allow-unwind-when-calling-panic-directly.rs | 1 + .../ui/extern/issue-64655-extern-rust-must-allow-unwind.rs | 1 + src/test/ui/generator/generator-resume-after-panic.rs | 1 + src/test/ui/generator/panic-drops-resume.rs | 1 + src/test/ui/generator/panic-drops.rs | 1 + src/test/ui/generator/panic-safe.rs | 1 + src/test/ui/generator/resume-after-return.rs | 1 + src/test/ui/intrinsics/panic-uninitialized-zeroed.rs | 1 + src/test/ui/issues/issue-14875.rs | 1 + src/test/ui/issues/issue-25089.rs | 1 + src/test/ui/issues/issue-26655.rs | 1 + src/test/ui/issues/issue-29485.rs | 1 + src/test/ui/issues/issue-29948.rs | 1 + src/test/ui/issues/issue-30018-panic.rs | 1 + src/test/ui/issues/issue-43853.rs | 1 + src/test/ui/issues/issue-46519.rs | 1 + src/test/ui/iterators/iter-count-overflow-debug.rs | 1 + src/test/ui/iterators/iter-position-overflow-debug.rs | 1 + src/test/ui/iterators/iter-step-overflow-debug.rs | 1 + src/test/ui/iterators/iter-sum-overflow-debug.rs | 1 + src/test/ui/iterators/iter-sum-overflow-overflow-checks.rs | 1 + src/test/ui/macros/macro-comma-behavior-rpass.rs | 1 + src/test/ui/mir/mir_calls_to_shims.rs | 1 + src/test/ui/mir/mir_drop_order.rs | 1 + src/test/ui/mir/mir_drop_panics.rs | 1 + src/test/ui/mir/mir_dynamic_drops_3.rs | 1 + src/test/ui/numbers-arithmetic/int-abs-overflow.rs | 1 + .../ui/numbers-arithmetic/next-power-of-two-overflow-debug.rs | 1 + src/test/ui/panics/panic-handler-chain.rs | 1 + src/test/ui/panics/panic-handler-flail-wildly.rs | 1 + src/test/ui/panics/panic-handler-set-twice.rs | 1 + src/test/ui/panics/panic-in-dtor-drops-fields.rs | 1 + src/test/ui/panics/panic-recover-propagate.rs | 1 + src/test/ui/privacy/reachable-unnameable-items.rs | 1 + src/test/ui/proc-macro/expand-with-a-macro.rs | 1 + .../rfc-1937-termination-trait/termination-trait-in-test.rs | 1 + src/test/ui/rfc-2091-track-caller/std-panic-locations.rs | 1 + src/test/ui/rfcs/rfc1857-drop-order.rs | 1 + src/test/ui/runtime/rt-explody-panic-payloads.rs | 1 + src/test/ui/sepcomp/sepcomp-unwind.rs | 1 + src/test/ui/structs-enums/unit-like-struct-drop-run.rs | 1 + src/test/ui/test-attrs/test-should-fail-good-message.rs | 1 + src/test/ui/threads-sendsync/task-stderr.rs | 1 + src/test/ui/threads-sendsync/unwind-resource.rs | 1 + src/test/ui/unwind-unique.rs | 1 + 62 files changed, 63 insertions(+), 2 deletions(-) diff --git a/src/test/ui/array-slice-vec/box-of-array-of-drop-1.rs b/src/test/ui/array-slice-vec/box-of-array-of-drop-1.rs index c8559d2472824..2b3ece67b34a0 100644 --- a/src/test/ui/array-slice-vec/box-of-array-of-drop-1.rs +++ b/src/test/ui/array-slice-vec/box-of-array-of-drop-1.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind #![allow(overflowing_literals)] // Test that we cleanup a fixed size Box<[D; k]> properly when D has a diff --git a/src/test/ui/array-slice-vec/box-of-array-of-drop-2.rs b/src/test/ui/array-slice-vec/box-of-array-of-drop-2.rs index e75051caabcc3..c0ca458750776 100644 --- a/src/test/ui/array-slice-vec/box-of-array-of-drop-2.rs +++ b/src/test/ui/array-slice-vec/box-of-array-of-drop-2.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind #![allow(overflowing_literals)] // Test that we cleanup dynamic sized Box<[D]> properly when D has a diff --git a/src/test/ui/array-slice-vec/nested-vec-3.rs b/src/test/ui/array-slice-vec/nested-vec-3.rs index 96497a53d308e..b3ae683a8a61a 100644 --- a/src/test/ui/array-slice-vec/nested-vec-3.rs +++ b/src/test/ui/array-slice-vec/nested-vec-3.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind #![allow(overflowing_literals)] // ignore-emscripten no threads support diff --git a/src/test/ui/array-slice-vec/slice-panic-1.rs b/src/test/ui/array-slice-vec/slice-panic-1.rs index 4134c62377835..3829078aba592 100644 --- a/src/test/ui/array-slice-vec/slice-panic-1.rs +++ b/src/test/ui/array-slice-vec/slice-panic-1.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind // ignore-emscripten no threads support diff --git a/src/test/ui/array-slice-vec/slice-panic-2.rs b/src/test/ui/array-slice-vec/slice-panic-2.rs index 2f7178fb3e132..d83c611d3bb55 100644 --- a/src/test/ui/array-slice-vec/slice-panic-2.rs +++ b/src/test/ui/array-slice-vec/slice-panic-2.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind // ignore-emscripten no threads support diff --git a/src/test/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-panic.rs b/src/test/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-panic.rs index f8caebcb8764e..5e71229beb5f9 100644 --- a/src/test/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-panic.rs +++ b/src/test/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-panic.rs @@ -2,6 +2,7 @@ // be talking about `async fn`s instead. Should also test what happens when it panics. // run-fail +// needs-unwind // error-pattern: thread 'main' panicked at '`async fn` resumed after panicking' // edition:2018 // ignore-wasm no panic or subprocess support diff --git a/src/test/ui/binding/fn-arg-incomplete-pattern-drop-order.rs b/src/test/ui/binding/fn-arg-incomplete-pattern-drop-order.rs index ea4a9e5afa501..684172ca61cca 100644 --- a/src/test/ui/binding/fn-arg-incomplete-pattern-drop-order.rs +++ b/src/test/ui/binding/fn-arg-incomplete-pattern-drop-order.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind // Check that partially moved from function parameters are dropped after the // named bindings that move from them. diff --git a/src/test/ui/builtin-clone-unwind.rs b/src/test/ui/builtin-clone-unwind.rs index 2caedb649a35a..3623c4a4dd05d 100644 --- a/src/test/ui/builtin-clone-unwind.rs +++ b/src/test/ui/builtin-clone-unwind.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind #![allow(unused_variables)] #![allow(unused_imports)] diff --git a/src/test/ui/catch-unwind-bang.rs b/src/test/ui/catch-unwind-bang.rs index f181991713b2c..b31b5cab5b724 100644 --- a/src/test/ui/catch-unwind-bang.rs +++ b/src/test/ui/catch-unwind-bang.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind // ignore-wasm32-bare compiled with panic=abort by default fn worker() -> ! { diff --git a/src/test/ui/cleanup-rvalue-temp-during-incomplete-alloc.rs b/src/test/ui/cleanup-rvalue-temp-during-incomplete-alloc.rs index eadbe44a8e9de..6cd3781b76055 100644 --- a/src/test/ui/cleanup-rvalue-temp-during-incomplete-alloc.rs +++ b/src/test/ui/cleanup-rvalue-temp-during-incomplete-alloc.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind #![allow(unused_must_use)] #![allow(dead_code)] diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.fixed b/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.fixed index 7df0dd76b4456..89f3931418dac 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.fixed +++ b/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.fixed @@ -1,4 +1,5 @@ // run-rustfix +// needs-unwind #![deny(rust_2021_incompatible_closure_captures)] //~^ NOTE: the lint level is defined here diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.rs b/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.rs index d02fac7c66952..6b0b10521740e 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.rs +++ b/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.rs @@ -1,4 +1,5 @@ // run-rustfix +// needs-unwind #![deny(rust_2021_incompatible_closure_captures)] //~^ NOTE: the lint level is defined here diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.stderr b/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.stderr index 74f85b6ebaac5..6594ec316532a 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.stderr +++ b/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.stderr @@ -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:20:38 + --> $DIR/mir_calls_to_shims.rs:21:38 | LL | let result = panic::catch_unwind(move || { | ^^^^^^^ @@ -11,7 +11,7 @@ LL | f.0() | --- in Rust 2018, this closure captures all of `f`, but in Rust 2021, it will only capture `f.0` | note: the lint level is defined here - --> $DIR/mir_calls_to_shims.rs:3:9 + --> $DIR/mir_calls_to_shims.rs:4:9 | LL | #![deny(rust_2021_incompatible_closure_captures)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/drop/drop-trait-enum.rs b/src/test/ui/drop/drop-trait-enum.rs index 4ab8f733ad75a..d2b77650a9d5c 100644 --- a/src/test/ui/drop/drop-trait-enum.rs +++ b/src/test/ui/drop/drop-trait-enum.rs @@ -3,6 +3,7 @@ #![allow(unused_assignments)] #![allow(unused_variables)] // ignore-emscripten no threads support +// needs-unwind use std::thread; use std::sync::mpsc::{channel, Sender}; diff --git a/src/test/ui/drop/dynamic-drop-async.rs b/src/test/ui/drop/dynamic-drop-async.rs index c0bf0bdf731e6..13bd71ecb3389 100644 --- a/src/test/ui/drop/dynamic-drop-async.rs +++ b/src/test/ui/drop/dynamic-drop-async.rs @@ -4,6 +4,7 @@ // * Dropping one of the values panics while dropping the future. // run-pass +// needs-unwind // edition:2018 // ignore-wasm32-bare compiled with panic=abort by default diff --git a/src/test/ui/drop/dynamic-drop.rs b/src/test/ui/drop/dynamic-drop.rs index 7bb43d5b50360..736123ed1198f 100644 --- a/src/test/ui/drop/dynamic-drop.rs +++ b/src/test/ui/drop/dynamic-drop.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind // ignore-wasm32-bare compiled with panic=abort by default #![feature(generators, generator_trait)] diff --git a/src/test/ui/drop/terminate-in-initializer.rs b/src/test/ui/drop/terminate-in-initializer.rs index c9cb932e62af0..66f267aa7c7d8 100644 --- a/src/test/ui/drop/terminate-in-initializer.rs +++ b/src/test/ui/drop/terminate-in-initializer.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind // ignore-emscripten no threads support // Issue #787 diff --git a/src/test/ui/extern/issue-64655-allow-unwind-when-calling-panic-directly.rs b/src/test/ui/extern/issue-64655-allow-unwind-when-calling-panic-directly.rs index 74c6e501c9136..7a91cbdc2f5d4 100644 --- a/src/test/ui/extern/issue-64655-allow-unwind-when-calling-panic-directly.rs +++ b/src/test/ui/extern/issue-64655-allow-unwind-when-calling-panic-directly.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind // ignore-wasm32-bare compiled with panic=abort by default // ignore-emscripten no threads support diff --git a/src/test/ui/extern/issue-64655-extern-rust-must-allow-unwind.rs b/src/test/ui/extern/issue-64655-extern-rust-must-allow-unwind.rs index bc15fcb0e3996..e84ff41b344a7 100644 --- a/src/test/ui/extern/issue-64655-extern-rust-must-allow-unwind.rs +++ b/src/test/ui/extern/issue-64655-extern-rust-must-allow-unwind.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind // ignore-wasm32-bare compiled with panic=abort by default // ignore-emscripten no threads support diff --git a/src/test/ui/generator/generator-resume-after-panic.rs b/src/test/ui/generator/generator-resume-after-panic.rs index 55704f40e9f2b..f2e67f1f750cc 100644 --- a/src/test/ui/generator/generator-resume-after-panic.rs +++ b/src/test/ui/generator/generator-resume-after-panic.rs @@ -1,4 +1,5 @@ // run-fail +// needs-unwind // error-pattern:generator resumed after panicking // ignore-emscripten no processes diff --git a/src/test/ui/generator/panic-drops-resume.rs b/src/test/ui/generator/panic-drops-resume.rs index 29f4788b2757f..8d8eb6a97b15a 100644 --- a/src/test/ui/generator/panic-drops-resume.rs +++ b/src/test/ui/generator/panic-drops-resume.rs @@ -1,6 +1,7 @@ //! Tests that panics inside a generator will correctly drop the initial resume argument. // run-pass +// needs-unwind // ignore-wasm no unwind support // ignore-emscripten no unwind support diff --git a/src/test/ui/generator/panic-drops.rs b/src/test/ui/generator/panic-drops.rs index c9a201725aea2..a9de4e7fc7d25 100644 --- a/src/test/ui/generator/panic-drops.rs +++ b/src/test/ui/generator/panic-drops.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind // ignore-wasm32-bare compiled with panic=abort by default diff --git a/src/test/ui/generator/panic-safe.rs b/src/test/ui/generator/panic-safe.rs index 500a3c9c2950e..14a0c8dbaf1da 100644 --- a/src/test/ui/generator/panic-safe.rs +++ b/src/test/ui/generator/panic-safe.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind // ignore-wasm32-bare compiled with panic=abort by default diff --git a/src/test/ui/generator/resume-after-return.rs b/src/test/ui/generator/resume-after-return.rs index efed08bd4708f..538609b981adf 100644 --- a/src/test/ui/generator/resume-after-return.rs +++ b/src/test/ui/generator/resume-after-return.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind // ignore-wasm32-bare compiled with panic=abort by default diff --git a/src/test/ui/intrinsics/panic-uninitialized-zeroed.rs b/src/test/ui/intrinsics/panic-uninitialized-zeroed.rs index 324bba15e4350..a1cfee944c8bd 100644 --- a/src/test/ui/intrinsics/panic-uninitialized-zeroed.rs +++ b/src/test/ui/intrinsics/panic-uninitialized-zeroed.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind // ignore-wasm32-bare compiled with panic=abort by default // revisions: mir thir // [thir]compile-flags: -Zthir-unsafeck diff --git a/src/test/ui/issues/issue-14875.rs b/src/test/ui/issues/issue-14875.rs index 0d95d168b3db3..aaef2aab9fc76 100644 --- a/src/test/ui/issues/issue-14875.rs +++ b/src/test/ui/issues/issue-14875.rs @@ -1,4 +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) diff --git a/src/test/ui/issues/issue-25089.rs b/src/test/ui/issues/issue-25089.rs index cf261d43c55cb..0f0f78623a212 100644 --- a/src/test/ui/issues/issue-25089.rs +++ b/src/test/ui/issues/issue-25089.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind // ignore-emscripten no threads support use std::thread; diff --git a/src/test/ui/issues/issue-26655.rs b/src/test/ui/issues/issue-26655.rs index 4c01183a44060..cb386c908a489 100644 --- a/src/test/ui/issues/issue-26655.rs +++ b/src/test/ui/issues/issue-26655.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind // ignore-emscripten no threads support // Check that the destructors of simple enums are run on unwinding diff --git a/src/test/ui/issues/issue-29485.rs b/src/test/ui/issues/issue-29485.rs index 6b2fb7126e3df..8d58ee6d92c4b 100644 --- a/src/test/ui/issues/issue-29485.rs +++ b/src/test/ui/issues/issue-29485.rs @@ -1,6 +1,7 @@ // run-pass #![allow(unused_attributes)] // aux-build:issue-29485.rs +// needs-unwind // ignore-emscripten no threads #[feature(recover)] diff --git a/src/test/ui/issues/issue-29948.rs b/src/test/ui/issues/issue-29948.rs index 8ede8143ea657..01c3ec64861fe 100644 --- a/src/test/ui/issues/issue-29948.rs +++ b/src/test/ui/issues/issue-29948.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind // ignore-wasm32-bare compiled with panic=abort by default use std::panic; diff --git a/src/test/ui/issues/issue-30018-panic.rs b/src/test/ui/issues/issue-30018-panic.rs index 50749b0c742f2..cba3055a22111 100644 --- a/src/test/ui/issues/issue-30018-panic.rs +++ b/src/test/ui/issues/issue-30018-panic.rs @@ -4,6 +4,7 @@ // spawned thread to isolate the expected error result from the // SIGTRAP injected by the drop-flag consistency checking. +// needs-unwind // ignore-emscripten no threads support struct Foo; diff --git a/src/test/ui/issues/issue-43853.rs b/src/test/ui/issues/issue-43853.rs index 47c3ab59aa2eb..3162c091c8786 100644 --- a/src/test/ui/issues/issue-43853.rs +++ b/src/test/ui/issues/issue-43853.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind // ignore-wasm32-bare compiled with panic=abort by default use std::panic; diff --git a/src/test/ui/issues/issue-46519.rs b/src/test/ui/issues/issue-46519.rs index cca0995d4ca10..9bd3c0948517b 100644 --- a/src/test/ui/issues/issue-46519.rs +++ b/src/test/ui/issues/issue-46519.rs @@ -1,6 +1,7 @@ // run-pass // compile-flags:--test -O +// needs-unwind // ignore-wasm32-bare compiled with panic=abort by default #[test] diff --git a/src/test/ui/iterators/iter-count-overflow-debug.rs b/src/test/ui/iterators/iter-count-overflow-debug.rs index 5a0394ae760e9..15f25f1ca5373 100644 --- a/src/test/ui/iterators/iter-count-overflow-debug.rs +++ b/src/test/ui/iterators/iter-count-overflow-debug.rs @@ -1,5 +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 diff --git a/src/test/ui/iterators/iter-position-overflow-debug.rs b/src/test/ui/iterators/iter-position-overflow-debug.rs index 733ee0c46cc3d..65124c282412c 100644 --- a/src/test/ui/iterators/iter-position-overflow-debug.rs +++ b/src/test/ui/iterators/iter-position-overflow-debug.rs @@ -1,5 +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 diff --git a/src/test/ui/iterators/iter-step-overflow-debug.rs b/src/test/ui/iterators/iter-step-overflow-debug.rs index 67605d2fcc253..e16f984de79a6 100644 --- a/src/test/ui/iterators/iter-step-overflow-debug.rs +++ b/src/test/ui/iterators/iter-step-overflow-debug.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind // ignore-wasm32-bare compiled with panic=abort by default // compile-flags: -C debug_assertions=yes diff --git a/src/test/ui/iterators/iter-sum-overflow-debug.rs b/src/test/ui/iterators/iter-sum-overflow-debug.rs index b7667d1bbf6d9..d8ce43848a77e 100644 --- a/src/test/ui/iterators/iter-sum-overflow-debug.rs +++ b/src/test/ui/iterators/iter-sum-overflow-debug.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind // ignore-wasm32-bare compiled with panic=abort by default // compile-flags: -C debug_assertions=yes diff --git a/src/test/ui/iterators/iter-sum-overflow-overflow-checks.rs b/src/test/ui/iterators/iter-sum-overflow-overflow-checks.rs index 04ca7f8a31534..bc8dcbdbb0e03 100644 --- a/src/test/ui/iterators/iter-sum-overflow-overflow-checks.rs +++ b/src/test/ui/iterators/iter-sum-overflow-overflow-checks.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind // ignore-wasm32-bare compiled with panic=abort by default // compile-flags: -C overflow-checks diff --git a/src/test/ui/macros/macro-comma-behavior-rpass.rs b/src/test/ui/macros/macro-comma-behavior-rpass.rs index 780e158fe0b8f..dfd58b25d089d 100644 --- a/src/test/ui/macros/macro-comma-behavior-rpass.rs +++ b/src/test/ui/macros/macro-comma-behavior-rpass.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind #![allow(unused_imports)] // Ideally, any macro call with a trailing comma should behave // identically to a call without the comma. diff --git a/src/test/ui/mir/mir_calls_to_shims.rs b/src/test/ui/mir/mir_calls_to_shims.rs index 6f13d5612ce51..42eaab77da9f1 100644 --- a/src/test/ui/mir/mir_calls_to_shims.rs +++ b/src/test/ui/mir/mir_calls_to_shims.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind // ignore-wasm32-bare compiled with panic=abort by default #![feature(fn_traits)] diff --git a/src/test/ui/mir/mir_drop_order.rs b/src/test/ui/mir/mir_drop_order.rs index 22c804abf5cc8..853efb0fed2b9 100644 --- a/src/test/ui/mir/mir_drop_order.rs +++ b/src/test/ui/mir/mir_drop_order.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind // ignore-wasm32-bare compiled with panic=abort by default use std::cell::RefCell; diff --git a/src/test/ui/mir/mir_drop_panics.rs b/src/test/ui/mir/mir_drop_panics.rs index bf269ee901b93..b4093d704150a 100644 --- a/src/test/ui/mir/mir_drop_panics.rs +++ b/src/test/ui/mir/mir_drop_panics.rs @@ -1,4 +1,5 @@ // run-fail +// needs-unwind // error-pattern:panic 1 // error-pattern:drop 2 // ignore-emscripten no processes diff --git a/src/test/ui/mir/mir_dynamic_drops_3.rs b/src/test/ui/mir/mir_dynamic_drops_3.rs index eb76fdff88647..2bcd9fac55cd5 100644 --- a/src/test/ui/mir/mir_dynamic_drops_3.rs +++ b/src/test/ui/mir/mir_dynamic_drops_3.rs @@ -1,4 +1,5 @@ // run-fail +// needs-unwind // error-pattern:unwind happens // error-pattern:drop 3 // error-pattern:drop 2 diff --git a/src/test/ui/numbers-arithmetic/int-abs-overflow.rs b/src/test/ui/numbers-arithmetic/int-abs-overflow.rs index 9c6dff7e1a6ca..d63ba8cb03e9a 100644 --- a/src/test/ui/numbers-arithmetic/int-abs-overflow.rs +++ b/src/test/ui/numbers-arithmetic/int-abs-overflow.rs @@ -1,6 +1,7 @@ // run-pass // compile-flags: -C overflow-checks=on // ignore-emscripten no threads support +// needs-unwind use std::thread; diff --git a/src/test/ui/numbers-arithmetic/next-power-of-two-overflow-debug.rs b/src/test/ui/numbers-arithmetic/next-power-of-two-overflow-debug.rs index 101c5d50b20b9..f857d4f4c7f27 100644 --- a/src/test/ui/numbers-arithmetic/next-power-of-two-overflow-debug.rs +++ b/src/test/ui/numbers-arithmetic/next-power-of-two-overflow-debug.rs @@ -1,5 +1,6 @@ // run-pass // compile-flags: -C debug_assertions=yes +// needs-unwind // ignore-wasm32-bare compiled with panic=abort by default // ignore-emscripten dies with an LLVM error diff --git a/src/test/ui/panics/panic-handler-chain.rs b/src/test/ui/panics/panic-handler-chain.rs index 93044b5cb2591..73d6e790dff57 100644 --- a/src/test/ui/panics/panic-handler-chain.rs +++ b/src/test/ui/panics/panic-handler-chain.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind #![allow(stable_features)] // ignore-emscripten no threads support diff --git a/src/test/ui/panics/panic-handler-flail-wildly.rs b/src/test/ui/panics/panic-handler-flail-wildly.rs index 6badd203842ff..679dc7de87aba 100644 --- a/src/test/ui/panics/panic-handler-flail-wildly.rs +++ b/src/test/ui/panics/panic-handler-flail-wildly.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind #![allow(stable_features)] #![allow(unused_must_use)] diff --git a/src/test/ui/panics/panic-handler-set-twice.rs b/src/test/ui/panics/panic-handler-set-twice.rs index 0312ed221ca35..2744530209026 100644 --- a/src/test/ui/panics/panic-handler-set-twice.rs +++ b/src/test/ui/panics/panic-handler-set-twice.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind #![allow(unused_variables)] #![allow(stable_features)] diff --git a/src/test/ui/panics/panic-in-dtor-drops-fields.rs b/src/test/ui/panics/panic-in-dtor-drops-fields.rs index caddd942dc0a0..c0963aa3114dc 100644 --- a/src/test/ui/panics/panic-in-dtor-drops-fields.rs +++ b/src/test/ui/panics/panic-in-dtor-drops-fields.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind #![allow(dead_code)] #![allow(non_upper_case_globals)] diff --git a/src/test/ui/panics/panic-recover-propagate.rs b/src/test/ui/panics/panic-recover-propagate.rs index 7969336ca749b..e110d94b65614 100644 --- a/src/test/ui/panics/panic-recover-propagate.rs +++ b/src/test/ui/panics/panic-recover-propagate.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind // ignore-emscripten no threads support use std::sync::atomic::{AtomicUsize, Ordering}; diff --git a/src/test/ui/privacy/reachable-unnameable-items.rs b/src/test/ui/privacy/reachable-unnameable-items.rs index f1e53a0d8b426..1c91541e64229 100644 --- a/src/test/ui/privacy/reachable-unnameable-items.rs +++ b/src/test/ui/privacy/reachable-unnameable-items.rs @@ -1,5 +1,6 @@ // run-pass // ignore-wasm32-bare compiled with panic=abort by default +// needs-unwind // aux-build:reachable-unnameable-items.rs extern crate reachable_unnameable_items; diff --git a/src/test/ui/proc-macro/expand-with-a-macro.rs b/src/test/ui/proc-macro/expand-with-a-macro.rs index 418178d0f0ead..21a4547d11e1c 100644 --- a/src/test/ui/proc-macro/expand-with-a-macro.rs +++ b/src/test/ui/proc-macro/expand-with-a-macro.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind // aux-build:expand-with-a-macro.rs // ignore-wasm32-bare compiled with panic=abort by default diff --git a/src/test/ui/rfc-1937-termination-trait/termination-trait-in-test.rs b/src/test/ui/rfc-1937-termination-trait/termination-trait-in-test.rs index 0bd7bf3d51a78..cd57d9bca9429 100644 --- a/src/test/ui/rfc-1937-termination-trait/termination-trait-in-test.rs +++ b/src/test/ui/rfc-1937-termination-trait/termination-trait-in-test.rs @@ -1,5 +1,6 @@ // compile-flags: --test // run-pass +// needs-unwind // ignore-wasm32-bare compiled with panic=abort by default diff --git a/src/test/ui/rfc-2091-track-caller/std-panic-locations.rs b/src/test/ui/rfc-2091-track-caller/std-panic-locations.rs index f0850d5c1f1e9..b067994a5c6d8 100644 --- a/src/test/ui/rfc-2091-track-caller/std-panic-locations.rs +++ b/src/test/ui/rfc-2091-track-caller/std-panic-locations.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind // ignore-wasm32-bare compiled with panic=abort by default // revisions: default mir-opt //[mir-opt] compile-flags: -Zmir-opt-level=4 diff --git a/src/test/ui/rfcs/rfc1857-drop-order.rs b/src/test/ui/rfcs/rfc1857-drop-order.rs index 7923aa7c0e22f..243b7fb6fadec 100644 --- a/src/test/ui/rfcs/rfc1857-drop-order.rs +++ b/src/test/ui/rfcs/rfc1857-drop-order.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind // ignore-wasm32-bare compiled with panic=abort by default #![allow(dead_code, unreachable_code)] diff --git a/src/test/ui/runtime/rt-explody-panic-payloads.rs b/src/test/ui/runtime/rt-explody-panic-payloads.rs index dc193582c6a50..eb5bf8f67a849 100644 --- a/src/test/ui/runtime/rt-explody-panic-payloads.rs +++ b/src/test/ui/runtime/rt-explody-panic-payloads.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind // ignore-emscripten no processes // ignore-sgx no processes // ignore-wasm32-bare no unwinding panic diff --git a/src/test/ui/sepcomp/sepcomp-unwind.rs b/src/test/ui/sepcomp/sepcomp-unwind.rs index 50a4e043943f0..a59e25a273e70 100644 --- a/src/test/ui/sepcomp/sepcomp-unwind.rs +++ b/src/test/ui/sepcomp/sepcomp-unwind.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind #![allow(dead_code)] // compile-flags: -C codegen-units=3 // ignore-emscripten no threads support diff --git a/src/test/ui/structs-enums/unit-like-struct-drop-run.rs b/src/test/ui/structs-enums/unit-like-struct-drop-run.rs index 980fd97e2c678..1e9c269a4d375 100644 --- a/src/test/ui/structs-enums/unit-like-struct-drop-run.rs +++ b/src/test/ui/structs-enums/unit-like-struct-drop-run.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind // ignore-emscripten no threads support // Make sure the destructor is run for unit-like structs. diff --git a/src/test/ui/test-attrs/test-should-fail-good-message.rs b/src/test/ui/test-attrs/test-should-fail-good-message.rs index 9fa759f9eb483..3260b6938f07d 100644 --- a/src/test/ui/test-attrs/test-should-fail-good-message.rs +++ b/src/test/ui/test-attrs/test-should-fail-good-message.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind // ignore-wasm32-bare compiled with panic=abort by default // compile-flags: --test #[test] diff --git a/src/test/ui/threads-sendsync/task-stderr.rs b/src/test/ui/threads-sendsync/task-stderr.rs index 78145e337dafb..68d226ffbaee3 100644 --- a/src/test/ui/threads-sendsync/task-stderr.rs +++ b/src/test/ui/threads-sendsync/task-stderr.rs @@ -1,5 +1,6 @@ // run-pass // ignore-emscripten no threads support +// needs-unwind #![feature(internal_output_capture)] diff --git a/src/test/ui/threads-sendsync/unwind-resource.rs b/src/test/ui/threads-sendsync/unwind-resource.rs index a063bef0822f2..6950a9c40d27d 100644 --- a/src/test/ui/threads-sendsync/unwind-resource.rs +++ b/src/test/ui/threads-sendsync/unwind-resource.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind #![allow(non_camel_case_types)] // ignore-emscripten no threads support diff --git a/src/test/ui/unwind-unique.rs b/src/test/ui/unwind-unique.rs index 7ca53b664ac6c..50ecf751a86db 100644 --- a/src/test/ui/unwind-unique.rs +++ b/src/test/ui/unwind-unique.rs @@ -1,4 +1,5 @@ // run-pass +// needs-unwind // ignore-emscripten no threads support use std::thread;