diff options
Diffstat (limited to 'src')
127 files changed, 813 insertions, 89 deletions
diff --git a/src/doc/rustdoc/src/command-line-arguments.md b/src/doc/rustdoc/src/command-line-arguments.md index d6948622662..9de2e733de7 100644 --- a/src/doc/rustdoc/src/command-line-arguments.md +++ b/src/doc/rustdoc/src/command-line-arguments.md @@ -57,13 +57,13 @@ release: 1.17.0 LLVM version: 3.9 ``` -## `-o`/`--output`: output path +## `-o`/`--out-dir`: output directory path Using this flag looks like this: ```bash $ rustdoc src/lib.rs -o target/doc -$ rustdoc src/lib.rs --output target/doc +$ rustdoc src/lib.rs --out-dir target/doc ``` By default, `rustdoc`'s output appears in a directory named `doc` in diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index 04bcade156a..35df5fa1b74 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(',') { @@ -504,8 +504,18 @@ impl Options { return Err(1); } - let output = - matches.opt_str("o").map(|s| PathBuf::from(&s)).unwrap_or_else(|| PathBuf::from("doc")); + let out_dir = matches.opt_str("out-dir").map(|s| PathBuf::from(&s)); + let output = matches.opt_str("output").map(|s| PathBuf::from(&s)); + let output = match (out_dir, output) { + (Some(_), Some(_)) => { + diag.struct_err("cannot use both 'out-dir' and 'output' at once").emit(); + return Err(1); + } + (Some(out_dir), None) => out_dir, + (None, Some(output)) => output, + (None, None) => PathBuf::from("doc"), + }; + let cfgs = matches.opt_strs("cfg"); let extension_css = matches.opt_str("e").map(|s| PathBuf::from(&s)); diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 1691de93bdd..9943e23b928 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/librustdoc/lib.rs b/src/librustdoc/lib.rs index b6311abb5c3..8699ab20b19 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -278,7 +278,16 @@ fn opts() -> Vec<RustcOptGroup> { o.optopt("r", "input-format", "the input type of the specified file", "[rust]") }), stable("w", |o| o.optopt("w", "output-format", "the output type to write", "[html]")), - stable("o", |o| o.optopt("o", "output", "where to place the output", "PATH")), + stable("output", |o| { + o.optopt( + "", + "output", + "Which directory to place the output. \ + This option is deprecated, use --out-dir instead.", + "PATH", + ) + }), + stable("o", |o| o.optopt("o", "out-dir", "which directory to place the output", "PATH")), stable("crate-name", |o| { o.optopt("", "crate-name", "specify the name of this crate", "NAME") }), diff --git a/src/test/run-make/rustdoc-with-out-dir-option/Makefile b/src/test/run-make/rustdoc-with-out-dir-option/Makefile new file mode 100644 index 00000000000..f79fce8eeea --- /dev/null +++ b/src/test/run-make/rustdoc-with-out-dir-option/Makefile @@ -0,0 +1,8 @@ +-include ../../run-make-fulldeps/tools.mk + +OUTPUT_DIR := "$(TMPDIR)/rustdoc" + +all: + $(RUSTDOC) src/lib.rs --crate-name foobar --crate-type lib --out-dir $(OUTPUT_DIR) + + $(HTMLDOCCK) $(OUTPUT_DIR) src/lib.rs diff --git a/src/test/run-make/rustdoc-with-out-dir-option/src/lib.rs b/src/test/run-make/rustdoc-with-out-dir-option/src/lib.rs new file mode 100644 index 00000000000..044bb6acb19 --- /dev/null +++ b/src/test/run-make/rustdoc-with-out-dir-option/src/lib.rs @@ -0,0 +1,2 @@ +// @has foobar/fn.ok.html +pub fn ok() {} diff --git a/src/test/run-make/rustdoc-with-output-option/Makefile b/src/test/run-make/rustdoc-with-output-option/Makefile new file mode 100644 index 00000000000..654f9672588 --- /dev/null +++ b/src/test/run-make/rustdoc-with-output-option/Makefile @@ -0,0 +1,8 @@ +-include ../../run-make-fulldeps/tools.mk + +OUTPUT_DIR := "$(TMPDIR)/rustdoc" + +all: + $(RUSTDOC) src/lib.rs --crate-name foobar --crate-type lib --output $(OUTPUT_DIR) + + $(HTMLDOCCK) $(OUTPUT_DIR) src/lib.rs diff --git a/src/test/run-make/rustdoc-with-output-option/src/lib.rs b/src/test/run-make/rustdoc-with-output-option/src/lib.rs new file mode 100644 index 00000000000..044bb6acb19 --- /dev/null +++ b/src/test/run-make/rustdoc-with-output-option/src/lib.rs @@ -0,0 +1,2 @@ +// @has foobar/fn.ok.html +pub fn ok() {} diff --git a/src/test/run-make/rustdoc-with-short-out-dir-option/Makefile b/src/test/run-make/rustdoc-with-short-out-dir-option/Makefile new file mode 100644 index 00000000000..1e9ba71de26 --- /dev/null +++ b/src/test/run-make/rustdoc-with-short-out-dir-option/Makefile @@ -0,0 +1,8 @@ +-include ../../run-make-fulldeps/tools.mk + +OUTPUT_DIR := "$(TMPDIR)/rustdoc" + +all: + $(RUSTDOC) src/lib.rs --crate-name foobar --crate-type lib -o $(OUTPUT_DIR) + + $(HTMLDOCCK) $(OUTPUT_DIR) src/lib.rs diff --git a/src/test/run-make/rustdoc-with-short-out-dir-option/src/lib.rs b/src/test/run-make/rustdoc-with-short-out-dir-option/src/lib.rs new file mode 100644 index 00000000000..044bb6acb19 --- /dev/null +++ b/src/test/run-make/rustdoc-with-short-out-dir-option/src/lib.rs @@ -0,0 +1,2 @@ +// @has foobar/fn.ok.html +pub fn ok() {} diff --git a/src/test/rustdoc-ui/issue-91713.rs b/src/test/rustdoc-ui/issue-91713.rs new file mode 100644 index 00000000000..b7057d868c2 --- /dev/null +++ b/src/test/rustdoc-ui/issue-91713.rs @@ -0,0 +1,3 @@ +// check-pass +// compile-flags: --passes list +// error-pattern: the `passes` flag is deprecated diff --git a/src/test/rustdoc-ui/issue-91713.stderr b/src/test/rustdoc-ui/issue-91713.stderr new file mode 100644 index 00000000000..70c22b3c01e --- /dev/null +++ b/src/test/rustdoc-ui/issue-91713.stderr @@ -0,0 +1,4 @@ +warning: the `passes` flag is deprecated + | + = note: see issue #44136 <https://github.com/rust-lang/rust/issues/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 00000000000..d0372d4945f --- /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 diff --git a/src/test/rustdoc-ui/use_both_out_dir_and_output_options.rs b/src/test/rustdoc-ui/use_both_out_dir_and_output_options.rs new file mode 100644 index 00000000000..5037043f19a --- /dev/null +++ b/src/test/rustdoc-ui/use_both_out_dir_and_output_options.rs @@ -0,0 +1 @@ +// compile-flags: --output ./foo diff --git a/src/test/rustdoc-ui/use_both_out_dir_and_output_options.stderr b/src/test/rustdoc-ui/use_both_out_dir_and_output_options.stderr new file mode 100644 index 00000000000..96d2295ac3e --- /dev/null +++ b/src/test/rustdoc-ui/use_both_out_dir_and_output_options.stderr @@ -0,0 +1,2 @@ +error: cannot use both 'out-dir' and 'output' at once + diff --git a/src/test/rustdoc/doc-notable_trait-mut_t_is_not_ref_t.rs b/src/test/rustdoc/doc-notable_trait-mut_t_is_not_ref_t.rs new file mode 100644 index 00000000000..b359dcea0ff --- /dev/null +++ b/src/test/rustdoc/doc-notable_trait-mut_t_is_not_ref_t.rs @@ -0,0 +1,21 @@ +//! Test case for [#78160]. +//! +//! A SomeTrait that is implemented for `&mut T` should not be marked as +//! "notable" for return values that are `&T`. +//! +//! [#78160]: https://github.com/rust-lang/rust/issues/78160 + +#![feature(rustdoc_internals)] + +#[doc(primitive = "reference")] +/// Some useless docs, wouhou! +/// +/// We need to put this in here, because notable traits +/// that are implemented on foreign types don't show up. +mod reference {} + +// @has doc_notable_trait_mut_t_is_not_ref_t/fn.fn_no_matches.html +// @!has - '//code[@class="content"]' "impl<'_, I> Iterator for &'_ mut I" +pub fn fn_no_matches<'a, T: Iterator + 'a>() -> &'a T { + loop {} +} diff --git a/src/test/rustdoc/type-layout.rs b/src/test/rustdoc/type-layout.rs index 0868486fa59..4eea9809ac5 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<u32>); + +// 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 {} 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 c8559d24728..2b3ece67b34 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 e75051caabc..c0ca4587507 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 96497a53d30..b3ae683a8a6 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 4134c623778..3829078aba5 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 2f7178fb3e1..d83c611d3bb 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/asm/aarch64/bad-reg.rs b/src/test/ui/asm/aarch64/bad-reg.rs index 4d7a7fd31fe..e346f8d992a 100644 --- a/src/test/ui/asm/aarch64/bad-reg.rs +++ b/src/test/ui/asm/aarch64/bad-reg.rs @@ -29,8 +29,6 @@ fn main() { //~^ ERROR invalid register `sp`: the stack pointer cannot be used as an operand asm!("", in("xzr") foo); //~^ ERROR invalid register `xzr`: the zero register cannot be used as an operand - asm!("", in("x18") foo); - //~^ ERROR invalid register `x18`: x18 is used as a reserved register on some targets and cannot be used as an operand for inline asm asm!("", in("x19") foo); //~^ ERROR invalid register `x19`: x19 is used internally by LLVM and cannot be used as an operand for inline asm diff --git a/src/test/ui/asm/aarch64/bad-reg.stderr b/src/test/ui/asm/aarch64/bad-reg.stderr index 091e6077ef4..42f2a5d72ec 100644 --- a/src/test/ui/asm/aarch64/bad-reg.stderr +++ b/src/test/ui/asm/aarch64/bad-reg.stderr @@ -74,38 +74,32 @@ error: invalid register `xzr`: the zero register cannot be used as an operand fo LL | asm!("", in("xzr") foo); | ^^^^^^^^^^^^^ -error: invalid register `x18`: x18 is used as a reserved register on some targets and cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:32:18 - | -LL | asm!("", in("x18") foo); - | ^^^^^^^^^^^^^ - error: invalid register `x19`: x19 is used internally by LLVM and cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:34:18 + --> $DIR/bad-reg.rs:32:18 | LL | asm!("", in("x19") foo); | ^^^^^^^^^^^^^ error: register class `preg` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:37:18 + --> $DIR/bad-reg.rs:35:18 | LL | asm!("", in("p0") foo); | ^^^^^^^^^^^^ error: register class `preg` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:40:20 + --> $DIR/bad-reg.rs:38:20 | LL | asm!("{}", in(preg) foo); | ^^^^^^^^^^^^ error: register class `preg` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:42:20 + --> $DIR/bad-reg.rs:40:20 | LL | asm!("{}", out(preg) _); | ^^^^^^^^^^^ error: register `x0` conflicts with register `x0` - --> $DIR/bad-reg.rs:48:32 + --> $DIR/bad-reg.rs:46:32 | LL | asm!("", in("x0") foo, in("w0") bar); | ------------ ^^^^^^^^^^^^ register `x0` @@ -113,7 +107,7 @@ LL | asm!("", in("x0") foo, in("w0") bar); | register `x0` error: register `x0` conflicts with register `x0` - --> $DIR/bad-reg.rs:50:32 + --> $DIR/bad-reg.rs:48:32 | LL | asm!("", in("x0") foo, out("x0") bar); | ------------ ^^^^^^^^^^^^^ register `x0` @@ -121,13 +115,13 @@ LL | asm!("", in("x0") foo, out("x0") bar); | register `x0` | help: use `lateout` instead of `out` to avoid conflict - --> $DIR/bad-reg.rs:50:18 + --> $DIR/bad-reg.rs:48:18 | LL | asm!("", in("x0") foo, out("x0") bar); | ^^^^^^^^^^^^ error: register `v0` conflicts with register `v0` - --> $DIR/bad-reg.rs:53:32 + --> $DIR/bad-reg.rs:51:32 | LL | asm!("", in("v0") foo, in("q0") bar); | ------------ ^^^^^^^^^^^^ register `v0` @@ -135,7 +129,7 @@ LL | asm!("", in("v0") foo, in("q0") bar); | register `v0` error: register `v0` conflicts with register `v0` - --> $DIR/bad-reg.rs:55:32 + --> $DIR/bad-reg.rs:53:32 | LL | asm!("", in("v0") foo, out("q0") bar); | ------------ ^^^^^^^^^^^^^ register `v0` @@ -143,10 +137,10 @@ LL | asm!("", in("v0") foo, out("q0") bar); | register `v0` | help: use `lateout` instead of `out` to avoid conflict - --> $DIR/bad-reg.rs:55:18 + --> $DIR/bad-reg.rs:53:18 | LL | asm!("", in("v0") foo, out("q0") bar); | ^^^^^^^^^^^^ -error: aborting due to 19 previous errors +error: aborting due to 18 previous errors diff --git a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.transmute.stderr b/src/test/ui/associated-types/cache/project-fn-ret-contravariant.transmute.stderr index 0be9b37263a..33f1e0f05b2 100644 --- a/src/test/ui/associated-types/cache/project-fn-ret-contravariant.transmute.stderr +++ b/src/test/ui/associated-types/cache/project-fn-ret-contravariant.transmute.stderr @@ -4,7 +4,7 @@ error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime LL | fn baz<'a,'b>(x: &'a u32) -> &'static u32 { | ------- this data with lifetime `'a`... LL | bar(foo, x) - | ----^^^---- ...is captured and required to live as long as `'static` here + | ^^^ - ...is used and required to live as long as `'static` here error: aborting due to previous error diff --git a/src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.stderr b/src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.stderr index 0a44864b249..609627aaa9e 100644 --- a/src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.stderr +++ b/src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.stderr @@ -5,7 +5,16 @@ LL | fn baz<'a, 'b>(x: Type<'a>) -> Type<'static> { | -------- this data with lifetime `'a`... ... LL | bar(foo, x) - | ----^^^---- ...is captured and required to live as long as `'static` here + | ^^^ - ...is used and required to live as long as `'static` here + | +note: `'static` lifetime requirement introduced by the return type + --> $DIR/project-fn-ret-invariant.rs:45:37 + | +LL | fn baz<'a, 'b>(x: Type<'a>) -> Type<'static> { + | ^^^^^^^ `'static` requirement introduced here +... +LL | bar(foo, x) + | ----------- because of this returned expression error: aborting due to previous error diff --git a/src/test/ui/async-await/generics-and-bounds.rs b/src/test/ui/async-await/generics-and-bounds.rs index 963b19b34a6..90ab0c01f54 100644 --- a/src/test/ui/async-await/generics-and-bounds.rs +++ b/src/test/ui/async-await/generics-and-bounds.rs @@ -2,6 +2,8 @@ // edition:2018 // compile-flags: --crate-type lib +#![feature(in_band_lifetimes)] + use std::future::Future; pub async fn simple_generic<T>() {} @@ -71,6 +73,10 @@ pub fn call_with_ref_block<'a>(f: &'a (impl Foo + 'a)) -> impl Future<Output = ( async move { f.foo() } } +pub fn call_with_ref_block_in_band(f: &'a (impl Foo + 'a)) -> impl Future<Output = ()> + 'a { + async move { f.foo() } +} + pub fn async_block_with_same_generic_params_unifies() { let mut a = call_generic_bound_block(FooType); a = call_generic_bound_block(FooType); @@ -85,4 +91,9 @@ pub fn async_block_with_same_generic_params_unifies() { let f_two = FooType; let mut d = call_with_ref_block(&f_one); d = call_with_ref_block(&f_two); + + let f_one = FooType; + let f_two = FooType; + let mut d = call_with_ref_block_in_band(&f_one); + d = call_with_ref_block_in_band(&f_two); } diff --git a/src/test/ui/async-await/issues/issue-62097.stderr b/src/test/ui/async-await/issues/issue-62097.stderr index 56a28d904b9..e23277543c6 100644 --- a/src/test/ui/async-await/issues/issue-62097.stderr +++ b/src/test/ui/async-await/issues/issue-62097.stderr @@ -2,12 +2,15 @@ error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `' --> $DIR/issue-62097.rs:12:31 | LL | pub async fn run_dummy_fn(&self) { - | ^^^^^ - | | - | this data with an anonymous lifetime `'_`... - | ...is captured here... + | ^^^^^ this data with an anonymous lifetime `'_`... LL | foo(|| self.bar()).await; - | --- ...and is required to live as long as `'static` here + | --- ...is used and required to live as long as `'static` here + | +note: `'static` lifetime requirement introduced by this bound + --> $DIR/issue-62097.rs:4:19 + | +LL | F: FnOnce() + 'static + | ^^^^^^^ error: aborting due to previous error 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 f8caebcb876..5e71229beb5 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/async-await/issues/issue-72312.nll.stderr b/src/test/ui/async-await/issues/issue-72312.nll.stderr new file mode 100644 index 00000000000..068d8c64d68 --- /dev/null +++ b/src/test/ui/async-await/issues/issue-72312.nll.stderr @@ -0,0 +1,21 @@ +error[E0521]: borrowed data escapes outside of associated function + --> $DIR/issue-72312.rs:13:24 + | +LL | pub async fn start(&self) { + | ----- + | | + | `self` is a reference that is only valid in the associated function body + | let's call the lifetime of this reference `'1` +... +LL | require_static(async move { + | ________________________^ +LL | | &self; +LL | | }); + | | ^ + | | | + | |_________`self` escapes the associated function body here + | argument requires that `'1` must outlive `'static` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0521`. diff --git a/src/test/ui/async-await/issues/issue-72312.rs b/src/test/ui/async-await/issues/issue-72312.rs new file mode 100644 index 00000000000..eb7d12e290c --- /dev/null +++ b/src/test/ui/async-await/issues/issue-72312.rs @@ -0,0 +1,19 @@ +// edition:2018 +fn require_static<T: 'static>(val: T) -> T { + //~^ NOTE 'static` lifetime requirement introduced by this bound + val +} + +struct Problem; + +impl Problem { + pub async fn start(&self) { //~ ERROR E0759 + //~^ NOTE this data with an anonymous lifetime `'_` + //~| NOTE in this expansion of desugaring of `async` block or function + require_static(async move { //~ NOTE ...and is required to live as long as `'static` here + &self; //~ NOTE ...is used here... + }); + } +} + +fn main() {} diff --git a/src/test/ui/async-await/issues/issue-72312.stderr b/src/test/ui/async-await/issues/issue-72312.stderr new file mode 100644 index 00000000000..798f755765c --- /dev/null +++ b/src/test/ui/async-await/issues/issue-72312.stderr @@ -0,0 +1,23 @@ +error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement + --> $DIR/issue-72312.rs:10:24 + | +LL | pub async fn start(&self) { + | ^^^^^ this data with an anonymous lifetime `'_`... +... +LL | &self; + | ----- ...is used here... + | +note: ...and is required to live as long as `'static` here + --> $DIR/issue-72312.rs:13:9 + | +LL | require_static(async move { + | ^^^^^^^^^^^^^^ +note: `'static` lifetime requirement introduced by this bound + --> $DIR/issue-72312.rs:2:22 + | +LL | fn require_static<T: 'static>(val: T) -> T { + | ^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0759`. 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 ea4a9e5afa5..684172ca61c 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/binding/issue-53114-safety-checks.stderr b/src/test/ui/binding/issue-53114-safety-checks.stderr index 9e7deea4524..84cdb1453f8 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 <https://github.com/rust-lang/rust/issues/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 <https://github.com/rust-lang/rust/issues/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 <https://github.com/rust-lang/rust/issues/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 <https://github.com/rust-lang/rust/issues/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/borrowck/suggest-local-var-double-mut.rs b/src/test/ui/borrowck/suggest-local-var-double-mut.rs new file mode 100644 index 00000000000..d5996ba68be --- /dev/null +++ b/src/test/ui/borrowck/suggest-local-var-double-mut.rs @@ -0,0 +1,27 @@ +// See issue #77834. + +#![crate_type = "lib"] + +mod method_syntax { + struct Foo; + + impl Foo { + fn foo(&mut self, _: f32) -> i32 { todo!() } + fn bar(&mut self) -> f32 { todo!() } + fn baz(&mut self) { + self.foo(self.bar()); //~ ERROR + } + } +} + +mod fully_qualified_syntax { + struct Foo; + + impl Foo { + fn foo(&mut self, _: f32) -> i32 { todo!() } + fn bar(&mut self) -> f32 { todo!() } + fn baz(&mut self) { + Self::foo(self, Self::bar(self)); //~ ERROR + } + } +} diff --git a/src/test/ui/borrowck/suggest-local-var-double-mut.stderr b/src/test/ui/borrowck/suggest-local-var-double-mut.stderr new file mode 100644 index 00000000000..3a43c18a7ed --- /dev/null +++ b/src/test/ui/borrowck/suggest-local-var-double-mut.stderr @@ -0,0 +1,44 @@ +error[E0499]: cannot borrow `*self` as mutable more than once at a time + --> $DIR/suggest-local-var-double-mut.rs:12:22 + | +LL | self.foo(self.bar()); + | ---------^^^^^^^^^^- + | | | | + | | | second mutable borrow occurs here + | | first borrow later used by call + | first mutable borrow occurs here + | +help: try adding a local storing this argument... + --> $DIR/suggest-local-var-double-mut.rs:12:22 + | +LL | self.foo(self.bar()); + | ^^^^^^^^^^ +help: ...and then using that local as the argument to this call + --> $DIR/suggest-local-var-double-mut.rs:12:13 + | +LL | self.foo(self.bar()); + | ^^^^^^^^^^^^^^^^^^^^ + +error[E0499]: cannot borrow `*self` as mutable more than once at a time + --> $DIR/suggest-local-var-double-mut.rs:24:39 + | +LL | Self::foo(self, Self::bar(self)); + | --------- ---- ^^^^ second mutable borrow occurs here + | | | + | | first mutable borrow occurs here + | first borrow later used by call + | +help: try adding a local storing this argument... + --> $DIR/suggest-local-var-double-mut.rs:24:29 + | +LL | Self::foo(self, Self::bar(self)); + | ^^^^^^^^^^^^^^^ +help: ...and then using that local as the argument to this call + --> $DIR/suggest-local-var-double-mut.rs:24:13 + | +LL | Self::foo(self, Self::bar(self)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/suggest-local-var-imm-and-mut.nll.stderr b/src/test/ui/borrowck/suggest-local-var-imm-and-mut.nll.stderr new file mode 100644 index 00000000000..2ba0b6b28aa --- /dev/null +++ b/src/test/ui/borrowck/suggest-local-var-imm-and-mut.nll.stderr @@ -0,0 +1,33 @@ +error[E0502]: cannot borrow `*self` as mutable because it is also borrowed as immutable + --> $DIR/suggest-local-var-imm-and-mut.rs:12:22 + | +LL | self.foo(self.bar()); + | ---------^^^^^^^^^^- + | | | | + | | | mutable borrow occurs here + | | immutable borrow later used by call + | immutable borrow occurs here + | +help: try adding a local storing this argument... + --> $DIR/suggest-local-var-imm-and-mut.rs:12:22 + | +LL | self.foo(self.bar()); + | ^^^^^^^^^^ +help: ...and then using that local as the argument to this call + --> $DIR/suggest-local-var-imm-and-mut.rs:12:13 + | +LL | self.foo(self.bar()); + | ^^^^^^^^^^^^^^^^^^^^ + +error[E0502]: cannot borrow `*self` as mutable because it is also borrowed as immutable + --> $DIR/suggest-local-var-imm-and-mut.rs:24:39 + | +LL | Self::foo(self, Self::bar(self)); + | --------- ---- ^^^^ mutable borrow occurs here + | | | + | | immutable borrow occurs here + | immutable borrow later used by call + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/suggest-local-var-imm-and-mut.rs b/src/test/ui/borrowck/suggest-local-var-imm-and-mut.rs new file mode 100644 index 00000000000..bf167ba79f3 --- /dev/null +++ b/src/test/ui/borrowck/suggest-local-var-imm-and-mut.rs @@ -0,0 +1,27 @@ +// See issue #77834. + +#![crate_type = "lib"] + +mod method_syntax { + struct Foo; + + impl Foo { + fn foo(&self, _: f32) -> i32 { todo!() } + fn bar(&mut self) -> f32 { todo!() } + fn baz(&mut self) { + self.foo(self.bar()); //~ ERROR + } + } +} + +mod fully_qualified_syntax { + struct Foo; + + impl Foo { + fn foo(&self, _: f32) -> i32 { todo!() } + fn bar(&mut self) -> f32 { todo!() } + fn baz(&mut self) { + Self::foo(self, Self::bar(self)); //~ ERROR + } + } +} diff --git a/src/test/ui/borrowck/suggest-local-var-imm-and-mut.stderr b/src/test/ui/borrowck/suggest-local-var-imm-and-mut.stderr new file mode 100644 index 00000000000..eb934e7b72b --- /dev/null +++ b/src/test/ui/borrowck/suggest-local-var-imm-and-mut.stderr @@ -0,0 +1,22 @@ +error[E0502]: cannot borrow `*self` as mutable because it is also borrowed as immutable + --> $DIR/suggest-local-var-imm-and-mut.rs:12:22 + | +LL | self.foo(self.bar()); + | ---------^^^^^^^^^^- + | | | | + | | | mutable borrow occurs here + | | immutable borrow later used by call + | immutable borrow occurs here + +error[E0502]: cannot borrow `*self` as mutable because it is also borrowed as immutable + --> $DIR/suggest-local-var-imm-and-mut.rs:24:29 + | +LL | Self::foo(self, Self::bar(self)); + | --------- ---- ^^^^^^^^^^^^^^^ mutable borrow occurs here + | | | + | | immutable borrow occurs here + | immutable borrow later used by call + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/two-phase-cannot-nest-mut-self-calls.stderr b/src/test/ui/borrowck/two-phase-cannot-nest-mut-self-calls.stderr index a89bb941532..85c7159952f 100644 --- a/src/test/ui/borrowck/two-phase-cannot-nest-mut-self-calls.stderr +++ b/src/test/ui/borrowck/two-phase-cannot-nest-mut-self-calls.stderr @@ -13,6 +13,23 @@ LL | | LL | | 0 LL | | }); | |______- immutable borrow occurs here + | +help: try adding a local storing this argument... + --> $DIR/two-phase-cannot-nest-mut-self-calls.rs:16:9 + | +LL | vec.push(2); + | ^^^^^^^^^^^ +help: ...and then using that local as the argument to this call + --> $DIR/two-phase-cannot-nest-mut-self-calls.rs:14:5 + | +LL | / vec.get({ +LL | | +LL | | vec.push(2); +LL | | +LL | | +LL | | 0 +LL | | }); + | |______^ error: aborting due to previous error diff --git a/src/test/ui/builtin-clone-unwind.rs b/src/test/ui/builtin-clone-unwind.rs index 2caedb649a3..3623c4a4dd0 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 f181991713b..b31b5cab5b7 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 eadbe44a8e9..6cd3781b760 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/diagnostics/repr_packed.stderr b/src/test/ui/closures/2229_closure_analysis/diagnostics/repr_packed.stderr index 5acf3797ab5..fc0179d2cb4 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 <https://github.com/rust-lang/rust/issues/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/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 7df0dd76b44..89f3931418d 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 d02fac7c669..6b0b1052174 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 74f85b6ebaa..6594ec31653 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/closures/closure-bounds-static-cant-capture-borrowed.stderr b/src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.stderr index d761abdfc6a..af1f908a808 100644 --- a/src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.stderr +++ b/src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.stderr @@ -8,13 +8,18 @@ LL | bar(|| { LL | | LL | | let _ = x; LL | | }) - | |_____^ ...is captured here... + | |_____^ ...is used here... | note: ...and is required to live as long as `'static` here --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:5:5 | LL | bar(|| { | ^^^ +note: `'static` lifetime requirement introduced by this bound + --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:1:39 + | +LL | fn bar<F>(blk: F) where F: FnOnce() + 'static { + | ^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/codemap_tests/one_line.stderr b/src/test/ui/codemap_tests/one_line.stderr index 1ee612184de..6fe6e26135b 100644 --- a/src/test/ui/codemap_tests/one_line.stderr +++ b/src/test/ui/codemap_tests/one_line.stderr @@ -7,6 +7,17 @@ LL | v.push(v.pop().unwrap()); | | | second mutable borrow occurs here | | first borrow later used by call | first mutable borrow occurs here + | +help: try adding a local storing this argument... + --> $DIR/one_line.rs:3:12 + | +LL | v.push(v.pop().unwrap()); + | ^^^^^^^ +help: ...and then using that local as the argument to this call + --> $DIR/one_line.rs:3:5 + | +LL | v.push(v.pop().unwrap()); + | ^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/drop/drop-trait-enum.rs b/src/test/ui/drop/drop-trait-enum.rs index 4ab8f733ad7..d2b77650a9d 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 c0bf0bdf731..13bd71ecb33 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 7bb43d5b503..736123ed119 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 c9cb932e62a..66f267aa7c7 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 74c6e501c91..7a91cbdc2f5 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 bc15fcb0e39..e84ff41b344 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-region-requirements.stderr b/src/test/ui/generator/generator-region-requirements.stderr index b6b9db22426..30d67050b90 100644 --- a/src/test/ui/generator/generator-region-requirements.stderr +++ b/src/test/ui/generator/generator-region-requirements.stderr @@ -5,7 +5,7 @@ LL | fn dangle(x: &mut i32) -> &'static mut i32 { | -------- this data with an anonymous lifetime `'_`... ... LL | x - | ^ ...is captured here... + | ^ ...is used here... ... LL | GeneratorState::Complete(c) => return c, | - ...and is required to live as long as `'static` here diff --git a/src/test/ui/generator/generator-resume-after-panic.rs b/src/test/ui/generator/generator-resume-after-panic.rs index 55704f40e9f..f2e67f1f750 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 29f4788b275..8d8eb6a97b1 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 c9a201725ae..a9de4e7fc7d 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 500a3c9c295..14a0c8dbaf1 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 efed08bd470..538609b981a 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/generic-associated-types/projection-type-lifetime-mismatch.stderr b/src/test/ui/generic-associated-types/projection-type-lifetime-mismatch.stderr index 1ffd205652f..32c5ccf1648 100644 --- a/src/test/ui/generic-associated-types/projection-type-lifetime-mismatch.stderr +++ b/src/test/ui/generic-associated-types/projection-type-lifetime-mismatch.stderr @@ -4,7 +4,9 @@ error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'sta LL | fn f(x: &impl for<'a> X<Y<'a> = &'a ()>) -> &'static () { | ------------------------------- this data with an anonymous lifetime `'_`... LL | x.m() - | --^-- ...is captured and required to live as long as `'static` here + | - ^ + | | + | ...is used and required to live as long as `'static` here error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement --> $DIR/projection-type-lifetime-mismatch.rs:22:7 @@ -12,7 +14,9 @@ error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'sta LL | fn g<T: for<'a> X<Y<'a> = &'a ()>>(x: &T) -> &'static () { | -- this data with an anonymous lifetime `'_`... LL | x.m() - | --^-- ...is captured and required to live as long as `'static` here + | - ^ + | | + | ...is used and required to live as long as `'static` here error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement --> $DIR/projection-type-lifetime-mismatch.rs:27:7 @@ -20,7 +24,9 @@ error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'sta LL | fn h(x: &()) -> &'static () { | --- this data with an anonymous lifetime `'_`... LL | x.m() - | --^-- ...is captured and required to live as long as `'static` here + | - ^ + | | + | ...is used and required to live as long as `'static` here error: aborting due to 3 previous errors diff --git a/src/test/ui/impl-header-lifetime-elision/dyn-trait.stderr b/src/test/ui/impl-header-lifetime-elision/dyn-trait.stderr index b3bef677d19..2307572cc3f 100644 --- a/src/test/ui/impl-header-lifetime-elision/dyn-trait.stderr +++ b/src/test/ui/impl-header-lifetime-elision/dyn-trait.stderr @@ -4,7 +4,7 @@ error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime LL | fn with_dyn_debug_static<'a>(x: Box<dyn Debug + 'a>) { | ------------------- this data with lifetime `'a`... LL | static_val(x); - | ^ ...is captured here... + | ^ ...is used here... | note: ...and is required to live as long as `'static` here --> $DIR/dyn-trait.rs:20:5 diff --git a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr index d65dea7adc9..de5d3b612c9 100644 --- a/src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr +++ b/src/test/ui/impl-trait/must_outlive_least_region_or_bound.stderr @@ -28,7 +28,7 @@ error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'sta --> $DIR/must_outlive_least_region_or_bound.rs:9:46 | LL | fn elided2(x: &i32) -> impl Copy + 'static { x } - | ---- ^ ...is captured here... + | ---- ^ ...is used here... | | | this data with an anonymous lifetime `'_`... | @@ -50,7 +50,7 @@ error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime --> $DIR/must_outlive_least_region_or_bound.rs:11:55 | LL | fn explicit2<'a>(x: &'a i32) -> impl Copy + 'static { x } - | ------- ^ ...is captured here... + | ------- ^ ...is used here... | | | this data with lifetime `'a`... | @@ -80,7 +80,7 @@ error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'sta --> $DIR/must_outlive_least_region_or_bound.rs:24:65 | LL | fn elided5(x: &i32) -> (Box<dyn Debug>, impl Debug) { (Box::new(x), x) } - | ---- this data with an anonymous lifetime `'_`... ^ ...is captured here, requiring it to live as long as `'static` + | ---- this data with an anonymous lifetime `'_`... ^ ...is used and required to live as long as `'static` here | help: to declare that the trait object captures data from argument `x`, you can add an explicit `'_` lifetime bound | @@ -95,7 +95,7 @@ error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime --> $DIR/must_outlive_least_region_or_bound.rs:29:69 | LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x } - | ------- this data with lifetime `'a`... ^ ...is captured here... + | ------- this data with lifetime `'a`... ^ ...is used here... | note: ...and is required to live as long as `'static` here --> $DIR/must_outlive_least_region_or_bound.rs:29:34 @@ -136,10 +136,17 @@ error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'sta --> $DIR/must_outlive_least_region_or_bound.rs:16:50 | LL | fn elided3(x: &i32) -> Box<dyn Debug> { Box::new(x) } - | ---- ^ ...is captured here, requiring it to live as long as `'static` + | ---- ^ ...is used and required to live as long as `'static` here | | | this data with an anonymous lifetime `'_`... | +note: `'static` lifetime requirement introduced by the return type + --> $DIR/must_outlive_least_region_or_bound.rs:16:28 + | +LL | fn elided3(x: &i32) -> Box<dyn Debug> { Box::new(x) } + | ^^^^^^^^^ ----------- because of this returned expression + | | + | `'static` requirement introduced here help: to declare that the trait object captures data from argument `x`, you can add an explicit `'_` lifetime bound | LL | fn elided3(x: &i32) -> Box<dyn Debug + '_> { Box::new(x) } @@ -149,10 +156,17 @@ error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime --> $DIR/must_outlive_least_region_or_bound.rs:18:59 | LL | fn explicit3<'a>(x: &'a i32) -> Box<dyn Debug> { Box::new(x) } - | ------- ^ ...is captured here, requiring it to live as long as `'static` + | ------- ^ ...is used and required to live as long as `'static` here | | | this data with lifetime `'a`... | +note: `'static` lifetime requirement introduced by the return type + --> $DIR/must_outlive_least_region_or_bound.rs:18:37 + | +LL | fn explicit3<'a>(x: &'a i32) -> Box<dyn Debug> { Box::new(x) } + | ^^^^^^^^^ ----------- because of this returned expression + | | + | `'static` requirement introduced here help: to declare that the trait object captures data from argument `x`, you can add an explicit `'a` lifetime bound | LL | fn explicit3<'a>(x: &'a i32) -> Box<dyn Debug + 'a> { Box::new(x) } @@ -162,10 +176,17 @@ error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'sta --> $DIR/must_outlive_least_region_or_bound.rs:20:60 | LL | fn elided4(x: &i32) -> Box<dyn Debug + 'static> { Box::new(x) } - | ---- ^ ...is captured here, requiring it to live as long as `'static` + | ---- ^ ...is used and required to live as long as `'static` here | | | this data with an anonymous lifetime `'_`... | +note: `'static` lifetime requirement introduced by the return type + --> $DIR/must_outlive_least_region_or_bound.rs:20:40 + | +LL | fn elided4(x: &i32) -> Box<dyn Debug + 'static> { Box::new(x) } + | ^^^^^^^ ----------- because of this returned expression + | | + | `'static` requirement introduced here help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `x` | LL | fn elided4(x: &i32) -> Box<dyn Debug + '_> { Box::new(x) } @@ -179,8 +200,15 @@ error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime --> $DIR/must_outlive_least_region_or_bound.rs:22:69 | LL | fn explicit4<'a>(x: &'a i32) -> Box<dyn Debug + 'static> { Box::new(x) } - | ------- this data with lifetime `'a`... ^ ...is captured here, requiring it to live as long as `'static` + | ------- this data with lifetime `'a`... ^ ...is used and required to live as long as `'static` here | +note: `'static` lifetime requirement introduced by the return type + --> $DIR/must_outlive_least_region_or_bound.rs:22:49 + | +LL | fn explicit4<'a>(x: &'a i32) -> Box<dyn Debug + 'static> { Box::new(x) } + | ^^^^^^^ ----------- because of this returned expression + | | + | `'static` requirement introduced here help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `x` | LL | fn explicit4<'a>(x: &'a i32) -> Box<dyn Debug + 'a> { Box::new(x) } diff --git a/src/test/ui/intrinsics/panic-uninitialized-zeroed.rs b/src/test/ui/intrinsics/panic-uninitialized-zeroed.rs index 324bba15e43..a1cfee944c8 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 0d95d168b3d..aaef2aab9fc 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-16922.stderr b/src/test/ui/issues/issue-16922.stderr index 8b09b7d5907..53405a660f8 100644 --- a/src/test/ui/issues/issue-16922.stderr +++ b/src/test/ui/issues/issue-16922.stderr @@ -4,7 +4,7 @@ error[E0759]: `value` has an anonymous lifetime `'_` but it needs to satisfy a ` LL | fn foo<T: Any>(value: &T) -> Box<dyn Any> { | -- this data with an anonymous lifetime `'_`... LL | Box::new(value) as Box<dyn Any> - | ^^^^^ ...is captured here, requiring it to live as long as `'static` + | ^^^^^ ...is used and required to live as long as `'static` here | help: to declare that the trait object captures data from argument `value`, you can add an explicit `'_` lifetime bound | diff --git a/src/test/ui/issues/issue-25089.rs b/src/test/ui/issues/issue-25089.rs index cf261d43c55..0f0f78623a2 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 4c01183a440..cb386c908a4 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 6b2fb7126e3..8d58ee6d92c 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 8ede8143ea6..01c3ec64861 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 50749b0c742..cba3055a221 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 47c3ab59aa2..3162c091c87 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 cca0995d4ca..9bd3c094851 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/issues/issue-46983.stderr b/src/test/ui/issues/issue-46983.stderr index 77fb130f519..ed9f1884c42 100644 --- a/src/test/ui/issues/issue-46983.stderr +++ b/src/test/ui/issues/issue-46983.stderr @@ -4,7 +4,7 @@ error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'sta LL | fn foo(x: &u32) -> &'static u32 { | ---- this data with an anonymous lifetime `'_`... LL | &*x - | ^^^ ...is captured and required to live as long as `'static` here + | ^^^ ...is used and required to live as long as `'static` here error: aborting due to previous error diff --git a/src/test/ui/iterators/iter-count-overflow-debug.rs b/src/test/ui/iterators/iter-count-overflow-debug.rs index 5a0394ae760..15f25f1ca53 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 733ee0c46cc..65124c28241 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 67605d2fcc2..e16f984de79 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 b7667d1bbf6..d8ce43848a7 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 04ca7f8a315..bc8dcbdbb0e 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/lifetimes/auxiliary/issue-91763-aux.rs b/src/test/ui/lifetimes/auxiliary/issue-91763-aux.rs new file mode 100644 index 00000000000..0335f72b784 --- /dev/null +++ b/src/test/ui/lifetimes/auxiliary/issue-91763-aux.rs @@ -0,0 +1,47 @@ +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +//#![feature(proc_macro_diagnostic, proc_macro_span, proc_macro_def_site)] + +extern crate proc_macro; + +use proc_macro::{Delimiter, Group, Ident, Punct, Spacing, Span, TokenStream, TokenTree}; +use std::iter::FromIterator; + +#[proc_macro_attribute] +pub fn repro(_args: TokenStream, input: TokenStream) -> TokenStream { + let call_site = Span::call_site(); + let span = input.into_iter().nth(8).unwrap().span(); + + //fn f(_: &::std::fmt::Formatter) {} + TokenStream::from_iter([ + TokenTree::Ident(Ident::new("fn", call_site)), + TokenTree::Ident(Ident::new("f", call_site)), + TokenTree::Group(Group::new( + Delimiter::Parenthesis, + TokenStream::from_iter([ + TokenTree::Ident(Ident::new("_", call_site)), + TokenTree::Punct(punct(':', Spacing::Alone, call_site)), + TokenTree::Punct(punct('&', Spacing::Alone, call_site)), + TokenTree::Punct(punct(':', Spacing::Joint, span)), + TokenTree::Punct(punct(':', Spacing::Alone, span)), + TokenTree::Ident(Ident::new("std", span)), + TokenTree::Punct(punct(':', Spacing::Joint, span)), + TokenTree::Punct(punct(':', Spacing::Alone, span)), + TokenTree::Ident(Ident::new("fmt", span)), + TokenTree::Punct(punct(':', Spacing::Joint, span)), + TokenTree::Punct(punct(':', Spacing::Alone, span)), + TokenTree::Ident(Ident::new("Formatter", span)), + ]), + )), + TokenTree::Group(Group::new(Delimiter::Brace, TokenStream::new())), + ]) +} + +fn punct(ch: char, spacing: Spacing, span: Span) -> Punct { + let mut punct = Punct::new(ch, spacing); + punct.set_span(span); + punct +} diff --git a/src/test/ui/lifetimes/issue-90600-expected-return-static-indirect.stderr b/src/test/ui/lifetimes/issue-90600-expected-return-static-indirect.stderr index 3f65d3af725..e06255e4ea3 100644 --- a/src/test/ui/lifetimes/issue-90600-expected-return-static-indirect.stderr +++ b/src/test/ui/lifetimes/issue-90600-expected-return-static-indirect.stderr @@ -4,7 +4,7 @@ error[E0759]: `foo` has an anonymous lifetime `'_` but it needs to satisfy a `'s LL | fn inner(mut foo: &[u8]) { | ----- this data with an anonymous lifetime `'_`... LL | let refcell = RefCell::new(&mut foo); - | ^^^^^^^^ ...is captured here... + | ^^^^^^^^ ...is used here... ... LL | read_thing(read); | ---- ...and is required to live as long as `'static` here diff --git a/src/test/ui/lifetimes/issue-91763.rs b/src/test/ui/lifetimes/issue-91763.rs new file mode 100644 index 00000000000..2e8807fe639 --- /dev/null +++ b/src/test/ui/lifetimes/issue-91763.rs @@ -0,0 +1,11 @@ +// aux-build:issue-91763-aux.rs + +#![deny(elided_lifetimes_in_paths)] + +extern crate issue_91763_aux; + +#[issue_91763_aux::repro] +fn f() -> Ptr<Thing>; +//~^ ERROR hidden lifetime parameters in types are deprecated + +fn main() {} diff --git a/src/test/ui/lifetimes/issue-91763.stderr b/src/test/ui/lifetimes/issue-91763.stderr new file mode 100644 index 00000000000..1b1912c8e45 --- /dev/null +++ b/src/test/ui/lifetimes/issue-91763.stderr @@ -0,0 +1,14 @@ +error: hidden lifetime parameters in types are deprecated + --> $DIR/issue-91763.rs:8:20 + | +LL | fn f() -> Ptr<Thing>; + | ^ expected named lifetime parameter + | +note: the lint level is defined here + --> $DIR/issue-91763.rs:3:9 + | +LL | #![deny(elided_lifetimes_in_paths)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/lint/unaligned_references.stderr b/src/test/ui/lint/unaligned_references.stderr index 6a5cc91963d..53c9380fb7e 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 <https://github.com/rust-lang/rust/issues/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 <https://github.com/rust-lang/rust/issues/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 <https://github.com/rust-lang/rust/issues/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 <https://github.com/rust-lang/rust/issues/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 <https://github.com/rust-lang/rust/issues/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 <https://github.com/rust-lang/rust/issues/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 <https://github.com/rust-lang/rust/issues/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 5e84fdca1d3..01e2395049d 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 <https://github.com/rust-lang/rust/issues/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/macros/macro-comma-behavior-rpass.rs b/src/test/ui/macros/macro-comma-behavior-rpass.rs index 780e158fe0b..dfd58b25d08 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 6f13d5612ce..42eaab77da9 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 22c804abf5c..853efb0fed2 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 bf269ee901b..b4093d70415 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 eb76fdff886..2bcd9fac55c 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/nll/user-annotations/constant-in-expr-inherent-1.stderr b/src/test/ui/nll/user-annotations/constant-in-expr-inherent-1.stderr index 1931934a211..4a6378b84f1 100644 --- a/src/test/ui/nll/user-annotations/constant-in-expr-inherent-1.stderr +++ b/src/test/ui/nll/user-annotations/constant-in-expr-inherent-1.stderr @@ -4,7 +4,7 @@ error[E0759]: `fn` parameter has lifetime `'a` but it needs to satisfy a `'stati LL | fn foo<'a>(_: &'a u32) -> &'static u32 { | ------- this data with lifetime `'a`... LL | <Foo<'a>>::C - | ^^^^^^^^^^^^ ...is captured and required to live as long as `'static` here + | ^^^^^^^^^^^^ ...is used and required to live as long as `'static` here error: aborting due to previous error diff --git a/src/test/ui/numbers-arithmetic/int-abs-overflow.rs b/src/test/ui/numbers-arithmetic/int-abs-overflow.rs index 9c6dff7e1a6..d63ba8cb03e 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 101c5d50b20..f857d4f4c7f 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/object-lifetime/object-lifetime-default-from-box-error.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.stderr index e0a8534cd28..1708700f77a 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.stderr @@ -5,8 +5,16 @@ LL | fn load(ss: &mut SomeStruct) -> Box<dyn SomeTrait> { | --------------- this data with an anonymous lifetime `'_`... ... LL | ss.r - | ^^^^ ...is captured and required to live as long as `'static` here + | ^^^^ ...is used and required to live as long as `'static` here | +note: `'static` lifetime requirement introduced by the return type + --> $DIR/object-lifetime-default-from-box-error.rs:14:37 + | +LL | fn load(ss: &mut SomeStruct) -> Box<dyn SomeTrait> { + | ^^^^^^^^^^^^^ `'static` requirement introduced here +... +LL | ss.r + | ---- because of this returned expression help: to declare that the trait object captures data from argument `ss`, you can add an explicit `'_` lifetime bound | LL | fn load(ss: &mut SomeStruct) -> Box<dyn SomeTrait + '_> { diff --git a/src/test/ui/packed/issue-27060.stderr b/src/test/ui/packed/issue-27060.stderr index 09297884ed3..bba056d59f8 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 <https://github.com/rust-lang/rust/issues/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 <https://github.com/rust-lang/rust/issues/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 <https://github.com/rust-lang/rust/issues/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 <https://github.com/rust-lang/rust/issues/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 766d8a72c34..04585b49986 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 <https://github.com/rust-lang/rust/issues/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 5764e951a46..a50b1302001 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 <https://github.com/rust-lang/rust/issues/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 <https://github.com/rust-lang/rust/issues/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 diff --git a/src/test/ui/panics/panic-handler-chain.rs b/src/test/ui/panics/panic-handler-chain.rs index 93044b5cb25..73d6e790dff 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 6badd203842..679dc7de87a 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 0312ed221ca..27445302090 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 caddd942dc0..c0963aa3114 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 7969336ca74..e110d94b656 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 f1e53a0d8b4..1c91541e642 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 418178d0f0e..21a4547d11e 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/regions/region-object-lifetime-in-coercion.stderr b/src/test/ui/regions/region-object-lifetime-in-coercion.stderr index 04d22e58a1d..d8932c067ac 100644 --- a/src/test/ui/regions/region-object-lifetime-in-coercion.stderr +++ b/src/test/ui/regions/region-object-lifetime-in-coercion.stderr @@ -4,7 +4,7 @@ error[E0759]: `v` has an anonymous lifetime `'_` but it needs to satisfy a `'sta LL | fn a(v: &[u8]) -> Box<dyn Foo + 'static> { | ----- this data with an anonymous lifetime `'_`... LL | let x: Box<dyn Foo + 'static> = Box::new(v); - | ^ ...is captured here, requiring it to live as long as `'static` + | ^ ...is used and required to live as long as `'static` here | help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v` | @@ -21,8 +21,15 @@ error[E0759]: `v` has an anonymous lifetime `'_` but it needs to satisfy a `'sta LL | fn b(v: &[u8]) -> Box<dyn Foo + 'static> { | ----- this data with an anonymous lifetime `'_`... LL | Box::new(v) - | ^ ...is captured here, requiring it to live as long as `'static` + | ^ ...is used and required to live as long as `'static` here | +note: `'static` lifetime requirement introduced by the return type + --> $DIR/region-object-lifetime-in-coercion.rs:12:33 + | +LL | fn b(v: &[u8]) -> Box<dyn Foo + 'static> { + | ^^^^^^^ `'static` requirement introduced here +LL | Box::new(v) + | ----------- because of this returned expression help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v` | LL | fn b(v: &[u8]) -> Box<dyn Foo + '_> { @@ -39,8 +46,16 @@ LL | fn c(v: &[u8]) -> Box<dyn Foo> { | ----- this data with an anonymous lifetime `'_`... ... LL | Box::new(v) - | ^ ...is captured here, requiring it to live as long as `'static` + | ^ ...is used and required to live as long as `'static` here + | +note: `'static` lifetime requirement introduced by the return type + --> $DIR/region-object-lifetime-in-coercion.rs:16:23 | +LL | fn c(v: &[u8]) -> Box<dyn Foo> { + | ^^^^^^^ `'static` requirement introduced here +... +LL | Box::new(v) + | ----------- because of this returned expression help: to declare that the trait object captures data from argument `v`, you can add an explicit `'_` lifetime bound | LL | fn c(v: &[u8]) -> Box<dyn Foo + '_> { diff --git a/src/test/ui/regions/regions-addr-of-self.stderr b/src/test/ui/regions/regions-addr-of-self.stderr index 738691fd695..3453c6458f1 100644 --- a/src/test/ui/regions/regions-addr-of-self.stderr +++ b/src/test/ui/regions/regions-addr-of-self.stderr @@ -4,7 +4,7 @@ error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `' LL | pub fn chase_cat(&mut self) { | --------- this data with an anonymous lifetime `'_`... LL | let p: &'static mut usize = &mut self.cats_chased; - | ^^^^^^^^^^^^^^^^^^^^^ ...is captured and required to live as long as `'static` here + | ^^^^^^^^^^^^^^^^^^^^^ ...is used and required to live as long as `'static` here error: aborting due to previous error diff --git a/src/test/ui/regions/regions-close-object-into-object-2.stderr b/src/test/ui/regions/regions-close-object-into-object-2.stderr index 9a7df8c0188..4153f4f29bc 100644 --- a/src/test/ui/regions/regions-close-object-into-object-2.stderr +++ b/src/test/ui/regions/regions-close-object-into-object-2.stderr @@ -4,8 +4,15 @@ error[E0759]: `v` has lifetime `'a` but it needs to satisfy a `'static` lifetime LL | fn g<'a, T: 'static>(v: Box<dyn A<T> + 'a>) -> Box<dyn X + 'static> { | ------------------ this data with lifetime `'a`... LL | Box::new(B(&*v)) as Box<dyn X> - | ^^^ ...is captured here, requiring it to live as long as `'static` + | ^^^ ...is used and required to live as long as `'static` here | +note: `'static` lifetime requirement introduced by the return type + --> $DIR/regions-close-object-into-object-2.rs:8:60 + | +LL | fn g<'a, T: 'static>(v: Box<dyn A<T> + 'a>) -> Box<dyn X + 'static> { + | ^^^^^^^ `'static` requirement introduced here +LL | Box::new(B(&*v)) as Box<dyn X> + | ------------------------------ because of this returned expression help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v` | LL | fn g<'a, T: 'static>(v: Box<dyn A<T> + 'a>) -> Box<dyn X + 'a> { diff --git a/src/test/ui/regions/regions-close-object-into-object-4.stderr b/src/test/ui/regions/regions-close-object-into-object-4.stderr index a7a9b16b080..2ea4b431b38 100644 --- a/src/test/ui/regions/regions-close-object-into-object-4.stderr +++ b/src/test/ui/regions/regions-close-object-into-object-4.stderr @@ -4,8 +4,15 @@ error[E0759]: `v` has lifetime `'a` but it needs to satisfy a `'static` lifetime LL | fn i<'a, T, U>(v: Box<dyn A<U>+'a>) -> Box<dyn X + 'static> { | ---------------- this data with lifetime `'a`... LL | Box::new(B(&*v)) as Box<dyn X> - | ^^^ ...is captured here, requiring it to live as long as `'static` + | ^^^ ...is used and required to live as long as `'static` here | +note: `'static` lifetime requirement introduced by the return type + --> $DIR/regions-close-object-into-object-4.rs:8:52 + | +LL | fn i<'a, T, U>(v: Box<dyn A<U>+'a>) -> Box<dyn X + 'static> { + | ^^^^^^^ `'static` requirement introduced here +LL | Box::new(B(&*v)) as Box<dyn X> + | ------------------------------ because of this returned expression help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `v` | LL | fn i<'a, T, U>(v: Box<dyn A<U>+'a>) -> Box<dyn X + 'a> { diff --git a/src/test/ui/regions/regions-proc-bound-capture.stderr b/src/test/ui/regions/regions-proc-bound-capture.stderr index 50b3748bf40..2ebe874da93 100644 --- a/src/test/ui/regions/regions-proc-bound-capture.stderr +++ b/src/test/ui/regions/regions-proc-bound-capture.stderr @@ -5,8 +5,16 @@ LL | fn static_proc(x: &isize) -> Box<dyn FnMut() -> (isize) + 'static> { | ------ this data with an anonymous lifetime `'_`... LL | // This is illegal, because the region bound on `proc` is 'static. LL | Box::new(move || { *x }) - | ^^^^^^^^^^^^^^ ...is captured here, requiring it to live as long as `'static` + | ^^^^^^^^^^^^^^ ...is used and required to live as long as `'static` here | +note: `'static` lifetime requirement introduced by the return type + --> $DIR/regions-proc-bound-capture.rs:7:59 + | +LL | fn static_proc(x: &isize) -> Box<dyn FnMut() -> (isize) + 'static> { + | ^^^^^^^ `'static` requirement introduced here +LL | // This is illegal, because the region bound on `proc` is 'static. +LL | Box::new(move || { *x }) + | ------------------------ because of this returned expression help: consider changing the trait object's explicit `'static` bound to the lifetime of argument `x` | LL | fn static_proc(x: &isize) -> Box<dyn FnMut() -> (isize) + '_> { diff --git a/src/test/ui/regions/regions-static-bound.stderr b/src/test/ui/regions/regions-static-bound.stderr index 51fe16ca9da..b8e69e02609 100644 --- a/src/test/ui/regions/regions-static-bound.stderr +++ b/src/test/ui/regions/regions-static-bound.stderr @@ -17,7 +17,7 @@ error[E0759]: `u` has an anonymous lifetime `'_` but it needs to satisfy a `'sta LL | fn error(u: &(), v: &()) { | --- this data with an anonymous lifetime `'_`... LL | static_id(&u); - | ^^^^^^^^^ -- ...is captured here... + | ^^^^^^^^^ -- ...is used here... | note: ...and is required to live as long as `'static` here --> $DIR/regions-static-bound.rs:10:5 @@ -32,7 +32,7 @@ LL | fn error(u: &(), v: &()) { | --- this data with an anonymous lifetime `'_`... LL | static_id(&u); LL | static_id_indirect(&v); - | ^^^^^^^^^^^^^^^^^^ -- ...is captured here... + | ^^^^^^^^^^^^^^^^^^ -- ...is used here... | note: ...and is required to live as long as `'static` here --> $DIR/regions-static-bound.rs:11:5 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 0bd7bf3d51a..cd57d9bca94 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 f0850d5c1f1..b067994a5c6 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 7923aa7c0e2..243b7fb6fad 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 dc193582c6a..eb5bf8f67a8 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 50a4e043943..a59e25a273e 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 980fd97e2c6..1e9c269a4d3 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/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.stderr b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.stderr index 2961d8d7eac..63d291ed7cd 100644 --- a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.stderr +++ b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.stderr @@ -22,7 +22,7 @@ error[E0772]: `val` has lifetime `'a` but calling `use_self` introduces an impli LL | fn use_it<'a>(val: Box<dyn ObjectTrait<Assoc = i32> + 'a>) -> &'a () { | -------------------------------------- this data with lifetime `'a`... LL | val.use_self() - | ^^^^^^^^ ...is captured and required to live as long as `'static` here + | ^^^^^^^^ ...is used and required to live as long as `'static` here | note: the used `impl` has a `'static` requirement --> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:60:30 diff --git a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.stderr b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.stderr index 6d9f0811b27..55a1bbf18ab 100644 --- a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.stderr +++ b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.stderr @@ -4,7 +4,7 @@ error[E0759]: `val` has lifetime `'a` but it needs to satisfy a `'static` lifeti LL | fn use_it<'a, T>(val: &'a dyn ObjectTrait<T>) -> impl OtherTrait<'a> + 'a { | ---------------------- this data with lifetime `'a`... LL | val.use_self::<T>() - | ^^^^^^^^ ...is captured and required to live as long as `'static` here + | ^^^^^^^^ ...is used and required to live as long as `'static` here | note: the used `impl` has a `'static` requirement --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:14:32 @@ -24,7 +24,7 @@ error[E0772]: `val` has lifetime `'a` but calling `use_self` introduces an impli LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { | ------------------- this data with lifetime `'a`... LL | val.use_self() - | ^^^^^^^^ ...is captured and required to live as long as `'static` here because of an implicit lifetime bound on the inherent `impl` + | ^^^^^^^^ ...is used and required to live as long as `'static` here because of an implicit lifetime bound on the inherent `impl` | note: the used `impl` has a `'static` requirement --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:64:14 @@ -44,7 +44,7 @@ error[E0759]: `val` has lifetime `'a` but it needs to satisfy a `'static` lifeti LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> { | ------------------- this data with lifetime `'a`... LL | val.use_self() - | ^^^^^^^^ ...is captured and required to live as long as `'static` here + | ^^^^^^^^ ...is used and required to live as long as `'static` here | note: the used `impl` has a `'static` requirement --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:85:26 @@ -69,7 +69,7 @@ error[E0759]: `val` has lifetime `'a` but it needs to satisfy a `'static` lifeti LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a { | ------------------- this data with lifetime `'a`... LL | MyTrait::use_self(val) - | ^^^ ...is captured here... + | ^^^ ...is used here... | note: ...and is required to live as long as `'static` here --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:108:9 @@ -95,7 +95,7 @@ error[E0772]: `val` has lifetime `'a` but calling `use_self` introduces an impli LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> &'a () { | ------------------- this data with lifetime `'a`... LL | val.use_self() - | ^^^^^^^^ ...is captured and required to live as long as `'static` here + | ^^^^^^^^ ...is used and required to live as long as `'static` here | note: the used `impl` has a `'static` requirement --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:31:26 @@ -115,7 +115,7 @@ error[E0772]: `val` has lifetime `'a` but calling `use_self` introduces an impli LL | fn use_it<'a>(val: &'a Box<dyn ObjectTrait + 'a>) -> &'a () { | ----------------------------- this data with lifetime `'a`... LL | val.use_self() - | ^^^^^^^^ ...is captured and required to live as long as `'static` here + | ^^^^^^^^ ...is used and required to live as long as `'static` here | note: the used `impl` has a `'static` requirement --> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:48:30 diff --git a/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.stderr b/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.stderr index 1ca22ebeef4..a5b50634c71 100644 --- a/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.stderr +++ b/src/test/ui/suggestions/lifetimes/trait-object-nested-in-impl-trait.stderr @@ -7,7 +7,7 @@ LL | fn iter(&self) -> impl Iterator<Item = Box<dyn Foo>> { LL | remaining: self.0.iter(), | ------ ^^^^ | | - | ...is captured here... + | ...is used here... | note: ...and is required to live as long as `'static` here --> $DIR/trait-object-nested-in-impl-trait.rs:27:23 @@ -32,7 +32,7 @@ LL | fn iter(&self) -> impl Iterator<Item = Box<dyn Foo>> + '_ { LL | remaining: self.0.iter(), | ------ ^^^^ | | - | ...is captured here... + | ...is used here... | note: ...and is required to live as long as `'static` here --> $DIR/trait-object-nested-in-impl-trait.rs:38:23 @@ -53,7 +53,7 @@ LL | fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo>> + 'a { LL | remaining: self.0.iter(), | ------ ^^^^ | | - | ...is captured here... + | ...is used here... | note: ...and is required to live as long as `'static` here --> $DIR/trait-object-nested-in-impl-trait.rs:49:30 @@ -74,7 +74,7 @@ LL | fn iter<'a>(&'a self) -> impl Iterator<Item = Box<dyn Foo>> { LL | remaining: self.0.iter(), | ------ ^^^^ | | - | ...is captured here... + | ...is used here... | note: ...and is required to live as long as `'static` here --> $DIR/trait-object-nested-in-impl-trait.rs:60:30 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 9fa759f9eb4..3260b6938f0 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 78145e337da..68d226ffbae 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 a063bef0822..6950a9c40d2 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/traits/trait-upcasting/type-checking-test-4.rs b/src/test/ui/traits/trait-upcasting/type-checking-test-4.rs index 9b27fd46f7a..95698fd1e1a 100644 --- a/src/test/ui/traits/trait-upcasting/type-checking-test-4.rs +++ b/src/test/ui/traits/trait-upcasting/type-checking-test-4.rs @@ -29,4 +29,22 @@ fn test_wrong3<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { y.get_b() // ERROR } +fn test_wrong4<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { + <_ as Bar>::get_b(x) // ERROR + //~^ ERROR `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement +} + +fn test_wrong5<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { + <_ as Bar<'_, '_>>::get_b(x) // ERROR + //~^ ERROR `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement +} + +fn test_wrong6<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { + let y = x as &dyn Bar<'_, '_>; + //~^ ERROR `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement + y.get_b(); // ERROR + let z = y; + z.get_b() // ERROR +} + fn main() {} diff --git a/src/test/ui/traits/trait-upcasting/type-checking-test-4.stderr b/src/test/ui/traits/trait-upcasting/type-checking-test-4.stderr index 4967f3dc2c8..d4bb9350b0b 100644 --- a/src/test/ui/traits/trait-upcasting/type-checking-test-4.stderr +++ b/src/test/ui/traits/trait-upcasting/type-checking-test-4.stderr @@ -36,12 +36,88 @@ LL | fn test_wrong3<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { LL | let y = x as &dyn Bar<'_, '_>; | - ^^ | | - | ...is captured here... + | ...is used here... LL | LL | y.get_b() // ERROR - | --------- ...and is required to live as long as `'static` here + | - ...is used here... + | +note: ...and is required to live as long as `'static` here + --> $DIR/type-checking-test-4.rs:29:5 + | +LL | y.get_b() // ERROR + | ^^^^^^^^^ +note: `'static` lifetime requirement introduced by the return type + --> $DIR/type-checking-test-4.rs:26:48 + | +LL | fn test_wrong3<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { + | ^^^^^^^ `'static` requirement introduced here +... +LL | y.get_b() // ERROR + | --------- because of this returned expression + +error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement + --> $DIR/type-checking-test-4.rs:33:5 + | +LL | fn test_wrong4<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { + | ------------ this data with lifetime `'a`... +LL | <_ as Bar>::get_b(x) // ERROR + | ^^^^^^^^^^^^^^^^^ ...is used and required to live as long as `'static` here + | +note: `'static` lifetime requirement introduced by the return type + --> $DIR/type-checking-test-4.rs:32:48 + | +LL | fn test_wrong4<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { + | ^^^^^^^ `'static` requirement introduced here +LL | <_ as Bar>::get_b(x) // ERROR + | -------------------- because of this returned expression + +error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement + --> $DIR/type-checking-test-4.rs:38:15 + | +LL | fn test_wrong5<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { + | ------------ this data with lifetime `'a`... +LL | <_ as Bar<'_, '_>>::get_b(x) // ERROR + | ----------^^------------- ...is used and required to live as long as `'static` here + | +note: `'static` lifetime requirement introduced by the return type + --> $DIR/type-checking-test-4.rs:37:48 + | +LL | fn test_wrong5<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { + | ^^^^^^^ `'static` requirement introduced here +LL | <_ as Bar<'_, '_>>::get_b(x) // ERROR + | ---------------------------- because of this returned expression + +error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement + --> $DIR/type-checking-test-4.rs:43:27 + | +LL | fn test_wrong6<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { + | ------------ this data with lifetime `'a`... +LL | let y = x as &dyn Bar<'_, '_>; + | - ^^ + | | + | ...is used here... +LL | +LL | y.get_b(); // ERROR + | - ...is used here... +LL | let z = y; +LL | z.get_b() // ERROR + | - ...is used here... + | +note: ...and is required to live as long as `'static` here + --> $DIR/type-checking-test-4.rs:47:5 + | +LL | z.get_b() // ERROR + | ^^^^^^^^^ +note: `'static` lifetime requirement introduced by the return type + --> $DIR/type-checking-test-4.rs:42:48 + | +LL | fn test_wrong6<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { + | ^^^^^^^ `'static` requirement introduced here +... +LL | z.get_b() // ERROR + | --------- because of this returned expression -error: aborting due to 3 previous errors +error: aborting due to 6 previous errors Some errors have detailed explanations: E0308, E0759. For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/underscore-lifetime/dyn-trait-underscore.stderr b/src/test/ui/underscore-lifetime/dyn-trait-underscore.stderr index de3a6bbae17..f4285a0f98e 100644 --- a/src/test/ui/underscore-lifetime/dyn-trait-underscore.stderr +++ b/src/test/ui/underscore-lifetime/dyn-trait-underscore.stderr @@ -5,8 +5,18 @@ LL | fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> { | ---- this data with an anonymous lifetime `'_`... LL | // ^^^^^^^^^^^^^^^^^^^^^ bound *here* defaults to `'static` LL | Box::new(items.iter()) - | ---------------^^^^--- ...is captured and required to live as long as `'static` here + | ----- ^^^^ + | | + | ...is used and required to live as long as `'static` here | +note: `'static` lifetime requirement introduced by the return type + --> $DIR/dyn-trait-underscore.rs:6:29 + | +LL | fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> { + | ^^^^^^^^^^^^^^^^^^^^^ `'static` requirement introduced here +LL | // ^^^^^^^^^^^^^^^^^^^^^ bound *here* defaults to `'static` +LL | Box::new(items.iter()) + | ---------------------- because of this returned expression help: to declare that the trait object captures data from argument `items`, you can add an explicit `'_` lifetime bound | LL | fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T> + '_> { diff --git a/src/test/ui/unwind-unique.rs b/src/test/ui/unwind-unique.rs index 7ca53b664ac..50ecf751a86 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; |
