From 5b3f391404a50d5af270ce766aca8889bf9d918d Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Mon, 20 Jun 2022 19:25:52 -0700 Subject: [PATCH 1/9] Mention first and last macro in backtrace --- compiler/rustc_errors/src/emitter.rs | 25 ++++++++++++++----- compiler/rustc_errors/src/lib.rs | 1 + src/test/ui/borrowck/borrowck-and-init.stderr | 2 +- .../borrowck/borrowck-break-uninit-2.stderr | 2 +- .../ui/borrowck/borrowck-break-uninit.stderr | 2 +- src/test/ui/borrowck/borrowck-or-init.stderr | 2 +- .../ui/borrowck/borrowck-while-break.stderr | 2 +- .../ui/borrowck/issue-24267-flow-exit.stderr | 4 +-- src/test/ui/borrowck/issue-64453.stderr | 2 +- src/test/ui/borrowck/issue-81899.stderr | 2 +- .../issue-88434-minimal-example.stderr | 2 +- ...-88434-removal-index-should-be-less.stderr | 2 +- .../ui/borrowck/move-error-snippets.stderr | 2 +- .../diagnostics/arrays.stderr | 2 +- .../diagnostics/box.stderr | 2 +- .../diagnostics/repr_packed.stderr | 4 +-- .../simple-struct-min-capture.stderr | 2 +- .../ui/codemap_tests/bad-format-args.stderr | 2 +- src/test/ui/codemap_tests/tab_3.stderr | 2 +- .../conditional_array_execution.stderr | 4 +-- .../ui/consts/const-eval/const_panic.stderr | 20 +++++++-------- .../consts/const-eval/const_panic_2021.stderr | 16 ++++++------ .../const-eval/const_panic_libcore_bin.stderr | 4 +-- src/test/ui/consts/const-eval/format.stderr | 14 +++++------ .../ui/consts/const-eval/issue-43197.stderr | 8 +++--- .../ui/consts/const-eval/issue-44578.stderr | 2 +- .../ui/consts/const-eval/issue-85907.stderr | 2 +- .../const-eval/panic-assoc-never-type.stderr | 2 +- .../consts/const-eval/panic-never-type.stderr | 2 +- .../ui/consts/const-eval/unwind-abort.stderr | 2 +- .../const-float-bits-reject-conv.stderr | 8 +++--- src/test/ui/consts/issue-32829.stderr | 2 +- .../issue-66693-panic-in-array-len.stderr | 4 +-- src/test/ui/consts/issue-66693.stderr | 6 ++--- src/test/ui/consts/issue-76064.stderr | 2 +- .../cross-crate-macro-backtrace/main.stderr | 2 +- src/test/ui/expr/if/if-let.stderr | 2 +- src/test/ui/fmt/ifmt-bad-arg.stderr | 4 +-- src/test/ui/fmt/ifmt-unimpl.stderr | 2 +- src/test/ui/for-loop-while/while-let-2.stderr | 2 +- .../yield-while-ref-reborrowed.stderr | 2 +- src/test/ui/internal/internal-unstable.stderr | 2 +- src/test/ui/issues/issue-16966.stderr | 2 +- src/test/ui/issues/issue-42796.stderr | 2 +- src/test/ui/issues/issue-47646.stderr | 2 +- src/test/ui/issues/issue-69455.stderr | 2 +- src/test/ui/limits/issue-55878.stderr | 4 +-- .../ui/liveness/liveness-move-in-while.stderr | 2 +- .../liveness/liveness-use-after-move.stderr | 2 +- .../liveness/liveness-use-after-send.stderr | 2 +- src/test/ui/loops/loop-proper-liveness.stderr | 2 +- .../ui/macro_backtrace/main.default.stderr | 4 +-- src/test/ui/macros/format-parse-errors.stderr | 2 +- .../ui/macros/macro-backtrace-nested.stderr | 4 +-- .../ui/macros/macro-backtrace-println.stderr | 2 +- .../macros/macro-local-data-key-priv.stderr | 2 +- .../macros/restricted-shadowing-legacy.stderr | 10 ++++---- .../macros/restricted-shadowing-modern.stderr | 8 +++--- ...nreachable-format-args.edition_2015.stderr | 2 +- ...es-based-on-type-capture-clause-bad.stderr | 2 +- src/test/ui/on-unimplemented/no-debug.stderr | 8 +++--- .../ui/parser/macro/pub-item-macro.stderr | 2 +- src/test/ui/proc-macro/mixed-site-span.stderr | 2 +- .../ui/proc-macro/parent-source-spans.stderr | 10 ++++---- src/test/ui/proc-macro/weird-hygiene.stderr | 2 +- .../dbg-macro-requires-debug.stderr | 2 +- .../ui/suggestions/bound-suggestions.stderr | 12 ++++----- ...gest-deref-inside-macro-issue-58298.stderr | 2 +- src/test/ui/suggestions/issue-97760.stderr | 2 +- src/test/ui/suggestions/path-display.stderr | 4 +-- .../try-block-maybe-bad-lifetime.stderr | 2 +- .../ui/type-alias-impl-trait/nested.stderr | 2 +- .../ui/type/ascription/issue-47666.stderr | 2 +- .../use/use-after-move-based-on-type.stderr | 2 +- src/test/ui/walk-struct-literal-with.stderr | 2 +- 75 files changed, 152 insertions(+), 138 deletions(-) diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 8b2a995f1c58e..3dc0ad4c11a59 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -389,11 +389,11 @@ pub trait Emitter { ) { // Check for spans in macros, before `fix_multispans_in_extern_macros` // has a chance to replace them. - let has_macro_spans = iter::once(&*span) + let has_macro_spans: Vec<_> = iter::once(&*span) .chain(children.iter().map(|child| &child.span)) .flat_map(|span| span.primary_spans()) .flat_map(|sp| sp.macro_backtrace()) - .find_map(|expn_data| { + .filter_map(|expn_data| { match expn_data.kind { ExpnKind::Root => None, @@ -403,7 +403,8 @@ pub trait Emitter { ExpnKind::Macro(macro_kind, name) => Some((macro_kind, name)), } - }); + }) + .collect(); if !backtrace { self.fix_multispans_in_extern_macros(source_map, span, children); @@ -412,11 +413,23 @@ pub trait Emitter { self.render_multispans_macro_backtrace(span, children, backtrace); if !backtrace { - if let Some((macro_kind, name)) = has_macro_spans { - let descr = macro_kind.descr(); + if let Some((macro_kind, name)) = has_macro_spans.last() { + // Mark the actual macro this originates from + let and_then = if let Some((macro_kind, first_name)) = has_macro_spans.first() + && first_name != name + { + let descr = macro_kind.descr(); + format!( + " which{} expands to {descr} `{first_name}`", + if has_macro_spans.len() > 2 { " eventually" } else { "" } + ) + } else { + "".to_string() + }; + let descr = macro_kind.descr(); let msg = format!( - "this {level} originates in the {descr} `{name}` \ + "this {level} originates in the {descr} `{name}`{and_then} \ (in Nightly builds, run with -Z macro-backtrace for more info)", ); diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 78b0892b3bc17..c5f1dac86461f 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -6,6 +6,7 @@ #![feature(drain_filter)] #![feature(backtrace)] #![feature(if_let_guard)] +#![feature(let_chains)] #![feature(let_else)] #![feature(never_type)] #![feature(adt_const_params)] diff --git a/src/test/ui/borrowck/borrowck-and-init.stderr b/src/test/ui/borrowck/borrowck-and-init.stderr index d2c7473c036b8..46d65e7341792 100644 --- a/src/test/ui/borrowck/borrowck-and-init.stderr +++ b/src/test/ui/borrowck/borrowck-and-init.stderr @@ -4,7 +4,7 @@ error[E0381]: borrow of possibly-uninitialized variable: `i` LL | println!("{}", i); | ^ use of possibly-uninitialized `i` | - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-break-uninit-2.stderr b/src/test/ui/borrowck/borrowck-break-uninit-2.stderr index b134f5cc2d8e3..b02bed3efc309 100644 --- a/src/test/ui/borrowck/borrowck-break-uninit-2.stderr +++ b/src/test/ui/borrowck/borrowck-break-uninit-2.stderr @@ -4,7 +4,7 @@ error[E0381]: borrow of possibly-uninitialized variable: `x` LL | println!("{}", x); | ^ use of possibly-uninitialized `x` | - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-break-uninit.stderr b/src/test/ui/borrowck/borrowck-break-uninit.stderr index 652d7d3076fbd..bbd50ca212b97 100644 --- a/src/test/ui/borrowck/borrowck-break-uninit.stderr +++ b/src/test/ui/borrowck/borrowck-break-uninit.stderr @@ -4,7 +4,7 @@ error[E0381]: borrow of possibly-uninitialized variable: `x` LL | println!("{}", x); | ^ use of possibly-uninitialized `x` | - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-or-init.stderr b/src/test/ui/borrowck/borrowck-or-init.stderr index 6c757759f7134..08094fe52b794 100644 --- a/src/test/ui/borrowck/borrowck-or-init.stderr +++ b/src/test/ui/borrowck/borrowck-or-init.stderr @@ -4,7 +4,7 @@ error[E0381]: borrow of possibly-uninitialized variable: `i` LL | println!("{}", i); | ^ use of possibly-uninitialized `i` | - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-while-break.stderr b/src/test/ui/borrowck/borrowck-while-break.stderr index fc144a066bb27..36390ee9c0f7b 100644 --- a/src/test/ui/borrowck/borrowck-while-break.stderr +++ b/src/test/ui/borrowck/borrowck-while-break.stderr @@ -4,7 +4,7 @@ error[E0381]: borrow of possibly-uninitialized variable: `v` LL | println!("{}", v); | ^ use of possibly-uninitialized `v` | - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/borrowck/issue-24267-flow-exit.stderr b/src/test/ui/borrowck/issue-24267-flow-exit.stderr index e29cf7a1a7519..3434df07f8eeb 100644 --- a/src/test/ui/borrowck/issue-24267-flow-exit.stderr +++ b/src/test/ui/borrowck/issue-24267-flow-exit.stderr @@ -4,7 +4,7 @@ error[E0381]: borrow of possibly-uninitialized variable: `x` LL | println!("{}", x); | ^ use of possibly-uninitialized `x` | - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0381]: borrow of possibly-uninitialized variable: `x` --> $DIR/issue-24267-flow-exit.rs:18:20 @@ -12,7 +12,7 @@ error[E0381]: borrow of possibly-uninitialized variable: `x` LL | println!("{}", x); | ^ use of possibly-uninitialized `x` | - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/issue-64453.stderr b/src/test/ui/borrowck/issue-64453.stderr index f3436fbec66a6..51dd0964cb56f 100644 --- a/src/test/ui/borrowck/issue-64453.stderr +++ b/src/test/ui/borrowck/issue-64453.stderr @@ -5,7 +5,7 @@ LL | static settings_dir: String = format!(""); | ^^^^^^^^^^^ | = help: add `#![feature(const_fmt_arguments_new)]` to the crate attributes to enable - = note: this error originates in the macro `$crate::__export::format_args` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `format` which expands to macro `$crate::__export::format_args` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0015]: cannot call non-const fn `format` in statics --> $DIR/issue-64453.rs:4:31 diff --git a/src/test/ui/borrowck/issue-81899.stderr b/src/test/ui/borrowck/issue-81899.stderr index e7345ff3f9a64..5b0c666770e38 100644 --- a/src/test/ui/borrowck/issue-81899.stderr +++ b/src/test/ui/borrowck/issue-81899.stderr @@ -10,7 +10,7 @@ LL | panic!() | the evaluated program panicked at 'explicit panic', $DIR/issue-81899.rs:12:5 | inside `f::<[closure@$DIR/issue-81899.rs:4:31: 4:37]>` at $SRC_DIR/std/src/panic.rs:LL:COL | - = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `panic` which expands to macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) error: any use of this value will cause an error --> $DIR/issue-81899.rs:4:23 diff --git a/src/test/ui/borrowck/issue-88434-minimal-example.stderr b/src/test/ui/borrowck/issue-88434-minimal-example.stderr index 47d83c6535583..6087532e30b4d 100644 --- a/src/test/ui/borrowck/issue-88434-minimal-example.stderr +++ b/src/test/ui/borrowck/issue-88434-minimal-example.stderr @@ -10,7 +10,7 @@ LL | panic!() | the evaluated program panicked at 'explicit panic', $DIR/issue-88434-minimal-example.rs:11:5 | inside `f::<[closure@$DIR/issue-88434-minimal-example.rs:3:25: 3:31]>` at $SRC_DIR/std/src/panic.rs:LL:COL | - = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `panic` which expands to macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) error: any use of this value will cause an error --> $DIR/issue-88434-minimal-example.rs:3:21 diff --git a/src/test/ui/borrowck/issue-88434-removal-index-should-be-less.stderr b/src/test/ui/borrowck/issue-88434-removal-index-should-be-less.stderr index b08a7cfc7fe1a..ebe1340734aa1 100644 --- a/src/test/ui/borrowck/issue-88434-removal-index-should-be-less.stderr +++ b/src/test/ui/borrowck/issue-88434-removal-index-should-be-less.stderr @@ -10,7 +10,7 @@ LL | panic!() | the evaluated program panicked at 'explicit panic', $DIR/issue-88434-removal-index-should-be-less.rs:11:5 | inside `f::<[closure@$DIR/issue-88434-removal-index-should-be-less.rs:3:31: 3:37]>` at $SRC_DIR/std/src/panic.rs:LL:COL | - = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `panic` which expands to macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) error: any use of this value will cause an error --> $DIR/issue-88434-removal-index-should-be-less.rs:3:23 diff --git a/src/test/ui/borrowck/move-error-snippets.stderr b/src/test/ui/borrowck/move-error-snippets.stderr index 78f99e9041522..fb3d49054449a 100644 --- a/src/test/ui/borrowck/move-error-snippets.stderr +++ b/src/test/ui/borrowck/move-error-snippets.stderr @@ -12,7 +12,7 @@ LL | let a = $c; LL | sss!(); | ------ in this macro invocation | - = note: this error originates in the macro `aaa` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `sss` which expands to macro `aaa` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/closures/2229_closure_analysis/diagnostics/arrays.stderr b/src/test/ui/closures/2229_closure_analysis/diagnostics/arrays.stderr index f6c2190183211..695131ea390f9 100644 --- a/src/test/ui/closures/2229_closure_analysis/diagnostics/arrays.stderr +++ b/src/test/ui/closures/2229_closure_analysis/diagnostics/arrays.stderr @@ -82,7 +82,7 @@ LL | println!("{}", arr[3]); LL | c(); | - mutable borrow later used here | - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0502]: cannot borrow `arr` as immutable because it is also borrowed as mutable --> $DIR/arrays.rs:73:24 diff --git a/src/test/ui/closures/2229_closure_analysis/diagnostics/box.stderr b/src/test/ui/closures/2229_closure_analysis/diagnostics/box.stderr index 29228d85324ef..641bbae9e27c5 100644 --- a/src/test/ui/closures/2229_closure_analysis/diagnostics/box.stderr +++ b/src/test/ui/closures/2229_closure_analysis/diagnostics/box.stderr @@ -26,7 +26,7 @@ LL | LL | c(); | - mutable borrow later used here | - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0506]: cannot assign to `e.0.0.m.x` because it is borrowed --> $DIR/box.rs:55:5 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 8629837ba8d34..8ec3693ca8076 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 @@ -9,7 +9,7 @@ LL | println!("{}", foo.x); = note: for more information, see issue #82523 = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error @@ -25,5 +25,5 @@ LL | println!("{}", foo.x); = note: for more information, see issue #82523 = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/src/test/ui/closures/2229_closure_analysis/diagnostics/simple-struct-min-capture.stderr b/src/test/ui/closures/2229_closure_analysis/diagnostics/simple-struct-min-capture.stderr index 4f9fdbd368a88..014d00dc48548 100644 --- a/src/test/ui/closures/2229_closure_analysis/diagnostics/simple-struct-min-capture.stderr +++ b/src/test/ui/closures/2229_closure_analysis/diagnostics/simple-struct-min-capture.stderr @@ -14,7 +14,7 @@ LL | LL | c(); | - mutable borrow later used here | - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/codemap_tests/bad-format-args.stderr b/src/test/ui/codemap_tests/bad-format-args.stderr index ba056cccf997d..3cf995489efba 100644 --- a/src/test/ui/codemap_tests/bad-format-args.stderr +++ b/src/test/ui/codemap_tests/bad-format-args.stderr @@ -4,7 +4,7 @@ error: requires at least a format string argument LL | format!(); | ^^^^^^^^^ | - = note: this error originates in the macro `$crate::__export::format_args` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `format` which expands to macro `$crate::__export::format_args` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected `,`, found `1` --> $DIR/bad-format-args.rs:3:16 diff --git a/src/test/ui/codemap_tests/tab_3.stderr b/src/test/ui/codemap_tests/tab_3.stderr index ceb91142ac826..ea4124e39e196 100644 --- a/src/test/ui/codemap_tests/tab_3.stderr +++ b/src/test/ui/codemap_tests/tab_3.stderr @@ -14,7 +14,7 @@ note: this function takes ownership of the receiver `self`, which moves `some_ve | LL | fn into_iter(self) -> Self::IntoIter; | ^^^^ - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/consts/const-eval/conditional_array_execution.stderr b/src/test/ui/consts/const-eval/conditional_array_execution.stderr index f88bf4454260b..9211cf5f53715 100644 --- a/src/test/ui/consts/const-eval/conditional_array_execution.stderr +++ b/src/test/ui/consts/const-eval/conditional_array_execution.stderr @@ -28,7 +28,7 @@ LL | println!("{}", FOO); | = 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 #71800 - = note: this warning originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error; 2 warnings emitted @@ -64,5 +64,5 @@ LL | #![warn(const_err)] | ^^^^^^^^^ = 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 #71800 - = note: this warning originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/src/test/ui/consts/const-eval/const_panic.stderr b/src/test/ui/consts/const-eval/const_panic.stderr index 2955f11716c41..f5a0a125131d5 100644 --- a/src/test/ui/consts/const-eval/const_panic.stderr +++ b/src/test/ui/consts/const-eval/const_panic.stderr @@ -4,7 +4,7 @@ error[E0080]: evaluation of constant value failed LL | const Z: () = std::panic!("cheese"); | ^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'cheese', $DIR/const_panic.rs:6:15 | - = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `std::panic` which expands to macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation of constant value failed --> $DIR/const_panic.rs:9:16 @@ -12,7 +12,7 @@ error[E0080]: evaluation of constant value failed LL | const Z2: () = std::panic!(); | ^^^^^^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:9:16 | - = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `std::panic` which expands to macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation of constant value failed --> $DIR/const_panic.rs:12:15 @@ -20,7 +20,7 @@ error[E0080]: evaluation of constant value failed LL | const Y: () = std::unreachable!(); | ^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:12:15 | - = note: this error originates in the macro `$crate::panic::unreachable_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `std::unreachable` which expands to macro `$crate::panic::unreachable_2015` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation of constant value failed --> $DIR/const_panic.rs:15:15 @@ -36,7 +36,7 @@ error[E0080]: evaluation of constant value failed LL | const W: () = std::panic!(MSG); | ^^^^^^^^^^^^^^^^ the evaluated program panicked at 'hello', $DIR/const_panic.rs:18:15 | - = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `std::panic` which expands to macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation of constant value failed --> $DIR/const_panic.rs:21:16 @@ -44,7 +44,7 @@ error[E0080]: evaluation of constant value failed LL | const W2: () = std::panic!("{}", MSG); | ^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'hello', $DIR/const_panic.rs:21:16 | - = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `std::panic` which expands to macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation of constant value failed --> $DIR/const_panic.rs:24:20 @@ -52,7 +52,7 @@ error[E0080]: evaluation of constant value failed LL | const Z_CORE: () = core::panic!("cheese"); | ^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'cheese', $DIR/const_panic.rs:24:20 | - = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `core::panic` which expands to macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation of constant value failed --> $DIR/const_panic.rs:27:21 @@ -60,7 +60,7 @@ error[E0080]: evaluation of constant value failed LL | const Z2_CORE: () = core::panic!(); | ^^^^^^^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:27:21 | - = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `core::panic` which expands to macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation of constant value failed --> $DIR/const_panic.rs:30:20 @@ -68,7 +68,7 @@ error[E0080]: evaluation of constant value failed LL | const Y_CORE: () = core::unreachable!(); | ^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:30:20 | - = note: this error originates in the macro `$crate::panic::unreachable_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `core::unreachable` which expands to macro `$crate::panic::unreachable_2015` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation of constant value failed --> $DIR/const_panic.rs:33:20 @@ -84,7 +84,7 @@ error[E0080]: evaluation of constant value failed LL | const W_CORE: () = core::panic!(MSG); | ^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'hello', $DIR/const_panic.rs:36:20 | - = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `core::panic` which expands to macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation of constant value failed --> $DIR/const_panic.rs:39:21 @@ -92,7 +92,7 @@ error[E0080]: evaluation of constant value failed LL | const W2_CORE: () = core::panic!("{}", MSG); | ^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'hello', $DIR/const_panic.rs:39:21 | - = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `core::panic` which expands to macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 12 previous errors diff --git a/src/test/ui/consts/const-eval/const_panic_2021.stderr b/src/test/ui/consts/const-eval/const_panic_2021.stderr index cb3b08e0e0999..d617839c09734 100644 --- a/src/test/ui/consts/const-eval/const_panic_2021.stderr +++ b/src/test/ui/consts/const-eval/const_panic_2021.stderr @@ -4,7 +4,7 @@ error[E0080]: evaluation of constant value failed LL | const A: () = std::panic!("blåhaj"); | ^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'blåhaj', $DIR/const_panic_2021.rs:6:15 | - = note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `std::panic` which expands to macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation of constant value failed --> $DIR/const_panic_2021.rs:9:15 @@ -12,7 +12,7 @@ error[E0080]: evaluation of constant value failed LL | const B: () = std::panic!(); | ^^^^^^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/const_panic_2021.rs:9:15 | - = note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `std::panic` which expands to macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation of constant value failed --> $DIR/const_panic_2021.rs:12:15 @@ -20,7 +20,7 @@ error[E0080]: evaluation of constant value failed LL | const C: () = std::unreachable!(); | ^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_2021.rs:12:15 | - = note: this error originates in the macro `$crate::panic::unreachable_2021` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `std::unreachable` which expands to macro `$crate::panic::unreachable_2021` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation of constant value failed --> $DIR/const_panic_2021.rs:15:15 @@ -36,7 +36,7 @@ error[E0080]: evaluation of constant value failed LL | const E: () = std::panic!("{}", MSG); | ^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'hello', $DIR/const_panic_2021.rs:18:15 | - = note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `std::panic` which expands to macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation of constant value failed --> $DIR/const_panic_2021.rs:21:20 @@ -44,7 +44,7 @@ error[E0080]: evaluation of constant value failed LL | const A_CORE: () = core::panic!("shark"); | ^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'shark', $DIR/const_panic_2021.rs:21:20 | - = note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `core::panic` which expands to macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation of constant value failed --> $DIR/const_panic_2021.rs:24:20 @@ -52,7 +52,7 @@ error[E0080]: evaluation of constant value failed LL | const B_CORE: () = core::panic!(); | ^^^^^^^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/const_panic_2021.rs:24:20 | - = note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `core::panic` which expands to macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation of constant value failed --> $DIR/const_panic_2021.rs:27:20 @@ -60,7 +60,7 @@ error[E0080]: evaluation of constant value failed LL | const C_CORE: () = core::unreachable!(); | ^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_2021.rs:27:20 | - = note: this error originates in the macro `$crate::panic::unreachable_2021` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `core::unreachable` which expands to macro `$crate::panic::unreachable_2021` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation of constant value failed --> $DIR/const_panic_2021.rs:30:20 @@ -76,7 +76,7 @@ error[E0080]: evaluation of constant value failed LL | const E_CORE: () = core::panic!("{}", MSG); | ^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'hello', $DIR/const_panic_2021.rs:33:20 | - = note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `core::panic` which expands to macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 10 previous errors diff --git a/src/test/ui/consts/const-eval/const_panic_libcore_bin.stderr b/src/test/ui/consts/const-eval/const_panic_libcore_bin.stderr index 417120c453e92..b59318a4508a1 100644 --- a/src/test/ui/consts/const-eval/const_panic_libcore_bin.stderr +++ b/src/test/ui/consts/const-eval/const_panic_libcore_bin.stderr @@ -4,7 +4,7 @@ error[E0080]: evaluation of constant value failed LL | const Z: () = panic!("cheese"); | ^^^^^^^^^^^^^^^^ the evaluated program panicked at 'cheese', $DIR/const_panic_libcore_bin.rs:8:15 | - = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `panic` which expands to macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation of constant value failed --> $DIR/const_panic_libcore_bin.rs:11:15 @@ -12,7 +12,7 @@ error[E0080]: evaluation of constant value failed LL | const Y: () = unreachable!(); | ^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_libcore_bin.rs:11:15 | - = note: this error originates in the macro `$crate::panic::unreachable_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `unreachable` which expands to macro `$crate::panic::unreachable_2015` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation of constant value failed --> $DIR/const_panic_libcore_bin.rs:14:15 diff --git a/src/test/ui/consts/const-eval/format.stderr b/src/test/ui/consts/const-eval/format.stderr index b00cadcea991f..190dac41de299 100644 --- a/src/test/ui/consts/const-eval/format.stderr +++ b/src/test/ui/consts/const-eval/format.stderr @@ -5,7 +5,7 @@ LL | panic!("{:?}", 0); | ^ | = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - = note: this error originates in the macro `$crate::const_format_args` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `panic` which eventually expands to macro `$crate::const_format_args` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0015]: cannot call non-const formatting macro in constant functions --> $DIR/format.rs:11:22 @@ -14,7 +14,7 @@ LL | println!("{:?}", 0); | ^ | = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error: `Arguments::<'a>::new_v1` is not yet stable as a const fn --> $DIR/format.rs:11:5 @@ -23,7 +23,7 @@ LL | println!("{:?}", 0); | ^^^^^^^^^^^^^^^^^^^ | = help: add `#![feature(const_fmt_arguments_new)]` to the crate attributes to enable - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0015]: cannot call non-const fn `_print` in constant functions --> $DIR/format.rs:11:5 @@ -52,7 +52,7 @@ LL | panic!("{:?}", 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 #71800 - = note: this error originates in the macro `$crate::const_format_args` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `panic` which eventually expands to macro `$crate::const_format_args` (in Nightly builds, run with -Z macro-backtrace for more info) error: erroneous constant used --> $DIR/format.rs:11:14 @@ -71,7 +71,7 @@ LL | println!("{:?}", 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 #71800 - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 8 previous errors @@ -97,7 +97,7 @@ LL | panic!("{:?}", 0); = note: `#[deny(const_err)]` on by default = 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 #71800 - = note: this error originates in the macro `$crate::const_format_args` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `panic` which eventually expands to macro `$crate::const_format_args` (in Nightly builds, run with -Z macro-backtrace for more info) Future breakage diagnostic: error: erroneous constant used @@ -120,5 +120,5 @@ LL | println!("{:?}", 0); = note: `#[deny(const_err)]` on by default = 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 #71800 - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/src/test/ui/consts/const-eval/issue-43197.stderr b/src/test/ui/consts/const-eval/issue-43197.stderr index 53ed32638ced2..42ebee28cc5cb 100644 --- a/src/test/ui/consts/const-eval/issue-43197.stderr +++ b/src/test/ui/consts/const-eval/issue-43197.stderr @@ -39,7 +39,7 @@ LL | println!("{} {}", X, Y); | = 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 #71800 - = note: this warning originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation of constant value failed --> $DIR/issue-43197.rs:16:26 @@ -55,7 +55,7 @@ LL | println!("{} {}", X, Y); | = 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 #71800 - = note: this warning originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors; 4 warnings emitted @@ -108,7 +108,7 @@ LL | #![warn(const_err)] | ^^^^^^^^^ = 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 #71800 - = note: this warning originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) Future breakage diagnostic: warning: erroneous constant used @@ -124,5 +124,5 @@ LL | #![warn(const_err)] | ^^^^^^^^^ = 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 #71800 - = note: this warning originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/src/test/ui/consts/const-eval/issue-44578.stderr b/src/test/ui/consts/const-eval/issue-44578.stderr index 5ecdb7ef5568b..d9987efbe3302 100644 --- a/src/test/ui/consts/const-eval/issue-44578.stderr +++ b/src/test/ui/consts/const-eval/issue-44578.stderr @@ -38,5 +38,5 @@ LL | #![allow(const_err)] | ^^^^^^^^^ = 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 #71800 - = note: this warning originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/src/test/ui/consts/const-eval/issue-85907.stderr b/src/test/ui/consts/const-eval/issue-85907.stderr index 381f2fd1114ec..86b576b92516d 100644 --- a/src/test/ui/consts/const-eval/issue-85907.stderr +++ b/src/test/ui/consts/const-eval/issue-85907.stderr @@ -4,7 +4,7 @@ error: argument to `panic!()` in a const context must have type `&str` LL | panic!(123); | ^^^^^^^^^^^ | - = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `panic` which expands to macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr b/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr index 0116a83910d6c..ad394574e209a 100644 --- a/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr +++ b/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr @@ -4,7 +4,7 @@ error[E0080]: evaluation of constant value failed LL | const VOID: ! = panic!(); | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/panic-assoc-never-type.rs:10:21 | - = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `panic` which expands to macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: erroneous constant used --> $DIR/panic-assoc-never-type.rs:15:13 diff --git a/src/test/ui/consts/const-eval/panic-never-type.stderr b/src/test/ui/consts/const-eval/panic-never-type.stderr index 8f312d673a175..2882b0a91010b 100644 --- a/src/test/ui/consts/const-eval/panic-never-type.stderr +++ b/src/test/ui/consts/const-eval/panic-never-type.stderr @@ -4,7 +4,7 @@ error[E0080]: evaluation of constant value failed LL | const VOID: ! = panic!(); | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/panic-never-type.rs:5:17 | - = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `panic` which expands to macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/consts/const-eval/unwind-abort.stderr b/src/test/ui/consts/const-eval/unwind-abort.stderr index 78ebd36abd86b..0c85c81758b07 100644 --- a/src/test/ui/consts/const-eval/unwind-abort.stderr +++ b/src/test/ui/consts/const-eval/unwind-abort.stderr @@ -10,7 +10,7 @@ LL | panic!() LL | const _: () = foo(); | ----- inside `_` at $DIR/unwind-abort.rs:7:15 | - = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `panic` which expands to macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/consts/const-float-bits-reject-conv.stderr b/src/test/ui/consts/const-float-bits-reject-conv.stderr index d822171df7234..fb149800377a9 100644 --- a/src/test/ui/consts/const-float-bits-reject-conv.stderr +++ b/src/test/ui/consts/const-float-bits-reject-conv.stderr @@ -25,7 +25,7 @@ LL | called_in_const.call_once(arg) LL | const MASKED_NAN1: u32 = f32::NAN.to_bits() ^ 0x002A_AAAA; | ------------------ inside `f32::MASKED_NAN1` at $DIR/const-float-bits-reject-conv.rs:27:30 | - = note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `panic` which expands to macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/num/f32.rs:LL:COL @@ -54,7 +54,7 @@ LL | called_in_const.call_once(arg) LL | const MASKED_NAN2: u32 = f32::NAN.to_bits() ^ 0x0055_5555; | ------------------ inside `f32::MASKED_NAN2` at $DIR/const-float-bits-reject-conv.rs:28:30 | - = note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `panic` which expands to macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info) error: any use of this value will cause an error --> $DIR/const-float-bits-reject-conv.rs:30:34 @@ -132,7 +132,7 @@ LL | called_in_const.call_once(arg) LL | const MASKED_NAN1: u64 = f64::NAN.to_bits() ^ 0x000A_AAAA_AAAA_AAAA; | ------------------ inside `f64::MASKED_NAN1` at $DIR/const-float-bits-reject-conv.rs:54:30 | - = note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `panic` which expands to macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/num/f64.rs:LL:COL @@ -161,7 +161,7 @@ LL | called_in_const.call_once(arg) LL | const MASKED_NAN2: u64 = f64::NAN.to_bits() ^ 0x0005_5555_5555_5555; | ------------------ inside `f64::MASKED_NAN2` at $DIR/const-float-bits-reject-conv.rs:55:30 | - = note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `panic` which expands to macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info) error: any use of this value will cause an error --> $DIR/const-float-bits-reject-conv.rs:57:34 diff --git a/src/test/ui/consts/issue-32829.stderr b/src/test/ui/consts/issue-32829.stderr index 6155c935a5f6c..f5f53659af7ec 100644 --- a/src/test/ui/consts/issue-32829.stderr +++ b/src/test/ui/consts/issue-32829.stderr @@ -4,7 +4,7 @@ error[E0080]: could not evaluate static initializer LL | static S : u64 = { { panic!("foo"); 0 } }; | ^^^^^^^^^^^^^ the evaluated program panicked at 'foo', $DIR/issue-32829.rs:1:22 | - = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `panic` which expands to macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/consts/issue-66693-panic-in-array-len.stderr b/src/test/ui/consts/issue-66693-panic-in-array-len.stderr index 4ccbeb73c8a25..57b4441e9c019 100644 --- a/src/test/ui/consts/issue-66693-panic-in-array-len.stderr +++ b/src/test/ui/consts/issue-66693-panic-in-array-len.stderr @@ -4,7 +4,7 @@ error: argument to `panic!()` in a const context must have type `&str` LL | let _ = [0i32; panic!(2f32)]; | ^^^^^^^^^^^^ | - = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `panic` which expands to macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation of constant value failed --> $DIR/issue-66693-panic-in-array-len.rs:10:21 @@ -12,7 +12,7 @@ error[E0080]: evaluation of constant value failed LL | let _ = [false; panic!()]; | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/issue-66693-panic-in-array-len.rs:10:21 | - = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `panic` which expands to macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors diff --git a/src/test/ui/consts/issue-66693.stderr b/src/test/ui/consts/issue-66693.stderr index 929f905ae918b..b6428a5c12735 100644 --- a/src/test/ui/consts/issue-66693.stderr +++ b/src/test/ui/consts/issue-66693.stderr @@ -4,7 +4,7 @@ error: argument to `panic!()` in a const context must have type `&str` LL | const _: () = panic!(1); | ^^^^^^^^^ | - = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `panic` which expands to macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) error: argument to `panic!()` in a const context must have type `&str` --> $DIR/issue-66693.rs:7:19 @@ -12,7 +12,7 @@ error: argument to `panic!()` in a const context must have type `&str` LL | static _FOO: () = panic!(true); | ^^^^^^^^^^^^ | - = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `panic` which expands to macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) error: argument to `panic!()` in a const context must have type `&str` --> $DIR/issue-66693.rs:11:5 @@ -20,7 +20,7 @@ error: argument to `panic!()` in a const context must have type `&str` LL | panic!(&1); | ^^^^^^^^^^ | - = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `panic` which expands to macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) error: erroneous constant used --> $DIR/issue-66693.rs:11:12 diff --git a/src/test/ui/consts/issue-76064.stderr b/src/test/ui/consts/issue-76064.stderr index ef9d140536a3d..3a747387bb77e 100644 --- a/src/test/ui/consts/issue-76064.stderr +++ b/src/test/ui/consts/issue-76064.stderr @@ -4,7 +4,7 @@ error[E0080]: evaluation of constant value failed LL | struct Bug([u8; panic!("panic")]); | ^^^^^^^^^^^^^^^ the evaluated program panicked at 'panic', $DIR/issue-76064.rs:1:17 | - = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `panic` which expands to macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/cross/cross-crate-macro-backtrace/main.stderr b/src/test/ui/cross/cross-crate-macro-backtrace/main.stderr index 6e2a1d3bbc4df..fe12afb11137e 100644 --- a/src/test/ui/cross/cross-crate-macro-backtrace/main.stderr +++ b/src/test/ui/cross/cross-crate-macro-backtrace/main.stderr @@ -4,7 +4,7 @@ error: 1 positional argument in format string, but no arguments were given LL | myprintln!("{}"); | ^^^^^^^^^^^^^^^^ | - = note: this error originates in the macro `concat` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `myprintln` which expands to macro `concat` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/expr/if/if-let.stderr b/src/test/ui/expr/if/if-let.stderr index 3f3a224583424..ad4b7ac72391d 100644 --- a/src/test/ui/expr/if/if-let.stderr +++ b/src/test/ui/expr/if/if-let.stderr @@ -27,7 +27,7 @@ LL | | }); | = note: this pattern will always match, so the `if let` is useless = help: consider replacing the `if let` with a `let` - = note: this warning originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `bar` which expands to macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) warning: irrefutable `if let` pattern --> $DIR/if-let.rs:26:8 diff --git a/src/test/ui/fmt/ifmt-bad-arg.stderr b/src/test/ui/fmt/ifmt-bad-arg.stderr index c25da900951cc..bb67ced432afc 100644 --- a/src/test/ui/fmt/ifmt-bad-arg.stderr +++ b/src/test/ui/fmt/ifmt-bad-arg.stderr @@ -308,7 +308,7 @@ note: associated function defined here | LL | pub fn from_usize(x: &usize) -> ArgumentV1<'_> { | ^^^^^^^^^^ - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0308]: mismatched types --> $DIR/ifmt-bad-arg.rs:81:35 @@ -326,7 +326,7 @@ note: associated function defined here | LL | pub fn from_usize(x: &usize) -> ArgumentV1<'_> { | ^^^^^^^^^^ - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 36 previous errors diff --git a/src/test/ui/fmt/ifmt-unimpl.stderr b/src/test/ui/fmt/ifmt-unimpl.stderr index 5204afa4e6bc5..dde2d09b944bc 100644 --- a/src/test/ui/fmt/ifmt-unimpl.stderr +++ b/src/test/ui/fmt/ifmt-unimpl.stderr @@ -20,7 +20,7 @@ note: required by a bound in `ArgumentV1::<'a>::new_upper_hex` | LL | arg_new!(new_upper_hex, UpperHex); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `ArgumentV1::<'a>::new_upper_hex` - = note: this error originates in the macro `$crate::__export::format_args` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `arg_new` which eventually expands to macro `$crate::__export::format_args` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/for-loop-while/while-let-2.stderr b/src/test/ui/for-loop-while/while-let-2.stderr index cb1abd435710e..7a9dfc674a669 100644 --- a/src/test/ui/for-loop-while/while-let-2.stderr +++ b/src/test/ui/for-loop-while/while-let-2.stderr @@ -27,7 +27,7 @@ LL | | }); | = note: this pattern will always match, so the loop will never exit = help: consider instead using a `loop { ... }` with a `let` inside it - = note: this warning originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this warning originates in the macro `bar` which expands to macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) warning: irrefutable `while let` pattern --> $DIR/while-let-2.rs:27:11 diff --git a/src/test/ui/generator/yield-while-ref-reborrowed.stderr b/src/test/ui/generator/yield-while-ref-reborrowed.stderr index 67cd1f64d94aa..88bc9cf83834a 100644 --- a/src/test/ui/generator/yield-while-ref-reborrowed.stderr +++ b/src/test/ui/generator/yield-while-ref-reborrowed.stderr @@ -11,7 +11,7 @@ LL | println!("{}", x); LL | Pin::new(&mut b).resume(()); | ------ first borrow later used here | - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/internal/internal-unstable.stderr b/src/test/ui/internal/internal-unstable.stderr index b973ea67bf7a3..e70f77ab2ad89 100644 --- a/src/test/ui/internal/internal-unstable.stderr +++ b/src/test/ui/internal/internal-unstable.stderr @@ -40,7 +40,7 @@ LL | bar!(internal_unstable::unstable()); | ----------------------------------- in this macro invocation | = help: add `#![feature(function)]` to the crate attributes to enable - = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `bar` which expands to macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 5 previous errors diff --git a/src/test/ui/issues/issue-16966.stderr b/src/test/ui/issues/issue-16966.stderr index 6eb56ca5516bf..41cfa3c7b1347 100644 --- a/src/test/ui/issues/issue-16966.stderr +++ b/src/test/ui/issues/issue-16966.stderr @@ -4,7 +4,7 @@ error[E0282]: type annotations needed LL | panic!(std::default::Default::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `M` declared on the function `begin_panic` | - = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `panic` which expands to macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider specifying the generic argument --> $SRC_DIR/std/src/panic.rs:LL:COL | diff --git a/src/test/ui/issues/issue-42796.stderr b/src/test/ui/issues/issue-42796.stderr index 4a1debf37a079..949a4f8e8fde7 100644 --- a/src/test/ui/issues/issue-42796.stderr +++ b/src/test/ui/issues/issue-42796.stderr @@ -9,7 +9,7 @@ LL | let mut s_copy = s; LL | println!("{}", s); | ^ value borrowed here after move | - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/issues/issue-47646.stderr b/src/test/ui/issues/issue-47646.stderr index 4e28874e140a4..517eacd0874ec 100644 --- a/src/test/ui/issues/issue-47646.stderr +++ b/src/test/ui/issues/issue-47646.stderr @@ -13,7 +13,7 @@ LL | println!("{:?}", heap); LL | }; | - ... and the mutable borrow might be used here, when that temporary is dropped and runs the destructor for type `(Option>, ())` | - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/issues/issue-69455.stderr b/src/test/ui/issues/issue-69455.stderr index 6c4eafbc8b3a1..72817ee57f713 100644 --- a/src/test/ui/issues/issue-69455.stderr +++ b/src/test/ui/issues/issue-69455.stderr @@ -4,7 +4,7 @@ error[E0282]: type annotations needed LL | println!("{}", 23u64.test(xs.iter().sum())); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the associated function `new_display` | - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider specifying the generic argument | LL | println!("{}", 23u64.test(xs.iter().sum())::); diff --git a/src/test/ui/limits/issue-55878.stderr b/src/test/ui/limits/issue-55878.stderr index 1402d1387037e..6c4f040f1c19c 100644 --- a/src/test/ui/limits/issue-55878.stderr +++ b/src/test/ui/limits/issue-55878.stderr @@ -18,7 +18,7 @@ LL | println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>()); = note: `#[deny(const_err)]` on by default = 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 #71800 - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors @@ -33,5 +33,5 @@ LL | println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>()); = note: `#[deny(const_err)]` on by default = 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 #71800 - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/src/test/ui/liveness/liveness-move-in-while.stderr b/src/test/ui/liveness/liveness-move-in-while.stderr index ff6c02f2110f6..469aa8ea508fe 100644 --- a/src/test/ui/liveness/liveness-move-in-while.stderr +++ b/src/test/ui/liveness/liveness-move-in-while.stderr @@ -29,7 +29,7 @@ LL | println!("{}", y); LL | while true { while true { while true { x = y; x.clone(); } } } | - value moved here, in previous iteration of loop | - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error; 3 warnings emitted diff --git a/src/test/ui/liveness/liveness-use-after-move.stderr b/src/test/ui/liveness/liveness-use-after-move.stderr index f7d131109ea8f..ad0903381887b 100644 --- a/src/test/ui/liveness/liveness-use-after-move.stderr +++ b/src/test/ui/liveness/liveness-use-after-move.stderr @@ -9,7 +9,7 @@ LL | LL | println!("{}", *x); | ^^ value borrowed here after move | - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/liveness/liveness-use-after-send.stderr b/src/test/ui/liveness/liveness-use-after-send.stderr index becede1ceb6b3..5baf8364a5339 100644 --- a/src/test/ui/liveness/liveness-use-after-send.stderr +++ b/src/test/ui/liveness/liveness-use-after-send.stderr @@ -8,7 +8,7 @@ LL | send(ch, message); LL | println!("{}", message); | ^^^^^^^ value borrowed here after move | - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/loops/loop-proper-liveness.stderr b/src/test/ui/loops/loop-proper-liveness.stderr index 20d5c66a3f205..f1b7cd6f507e4 100644 --- a/src/test/ui/loops/loop-proper-liveness.stderr +++ b/src/test/ui/loops/loop-proper-liveness.stderr @@ -4,7 +4,7 @@ error[E0381]: borrow of possibly-uninitialized variable: `x` LL | println!("{:?}", x); | ^ use of possibly-uninitialized `x` | - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/macro_backtrace/main.default.stderr b/src/test/ui/macro_backtrace/main.default.stderr index fa9b4090ddfd3..43c9e63a83cf1 100644 --- a/src/test/ui/macro_backtrace/main.default.stderr +++ b/src/test/ui/macro_backtrace/main.default.stderr @@ -18,7 +18,7 @@ LL | () => { syntax error }; LL | ping!(); | ------- in this macro invocation | - = note: this error originates in the macro `pong` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `ping` which expands to macro `pong` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `error` --> $DIR/main.rs:10:20 @@ -29,7 +29,7 @@ LL | () => { syntax error }; LL | deep!(); | ------- in this macro invocation | - = note: this error originates in the macro `pong` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `deep` which eventually expands to macro `pong` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 3 previous errors diff --git a/src/test/ui/macros/format-parse-errors.stderr b/src/test/ui/macros/format-parse-errors.stderr index c0e766681fed6..323e4e3591599 100644 --- a/src/test/ui/macros/format-parse-errors.stderr +++ b/src/test/ui/macros/format-parse-errors.stderr @@ -4,7 +4,7 @@ error: requires at least a format string argument LL | format!(); | ^^^^^^^^^ | - = note: this error originates in the macro `$crate::__export::format_args` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `format` which expands to macro `$crate::__export::format_args` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected expression, found keyword `struct` --> $DIR/format-parse-errors.rs:5:13 diff --git a/src/test/ui/macros/macro-backtrace-nested.stderr b/src/test/ui/macros/macro-backtrace-nested.stderr index 38b52e1a12909..f12679a42a870 100644 --- a/src/test/ui/macros/macro-backtrace-nested.stderr +++ b/src/test/ui/macros/macro-backtrace-nested.stderr @@ -7,7 +7,7 @@ LL | () => (fake) LL | 1 + call_nested_expr!(); | ------------------- in this macro invocation | - = note: this error originates in the macro `nested_expr` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `call_nested_expr` which expands to macro `nested_expr` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0425]: cannot find value `fake` in this scope --> $DIR/macro-backtrace-nested.rs:5:12 @@ -18,7 +18,7 @@ LL | () => (fake) LL | call_nested_expr_sum!(); | ----------------------- in this macro invocation | - = note: this error originates in the macro `nested_expr` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `call_nested_expr_sum` which expands to macro `nested_expr` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors diff --git a/src/test/ui/macros/macro-backtrace-println.stderr b/src/test/ui/macros/macro-backtrace-println.stderr index bc00e0db83ed5..9f356fa0d8ac9 100644 --- a/src/test/ui/macros/macro-backtrace-println.stderr +++ b/src/test/ui/macros/macro-backtrace-println.stderr @@ -7,7 +7,7 @@ LL | ($fmt:expr) => (myprint!(concat!($fmt, "\n"))); LL | myprintln!("{}"); | ---------------- in this macro invocation | - = note: this error originates in the macro `concat` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `myprintln` which expands to macro `concat` (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-local-data-key-priv.stderr b/src/test/ui/macros/macro-local-data-key-priv.stderr index b449e34736820..4a567b605bd13 100644 --- a/src/test/ui/macros/macro-local-data-key-priv.stderr +++ b/src/test/ui/macros/macro-local-data-key-priv.stderr @@ -9,7 +9,7 @@ note: the constant `baz` is defined here | LL | thread_local!(static baz: f64 = 0.0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: this error originates in the macro `$crate::__thread_local_inner` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `thread_local` which expands to macro `$crate::__thread_local_inner` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/macros/restricted-shadowing-legacy.stderr b/src/test/ui/macros/restricted-shadowing-legacy.stderr index 99b27a5cab123..ebcb29da9ab70 100644 --- a/src/test/ui/macros/restricted-shadowing-legacy.stderr +++ b/src/test/ui/macros/restricted-shadowing-legacy.stderr @@ -24,7 +24,7 @@ LL | macro_rules! m { () => {} } ... LL | include!(); | ---------- in this macro invocation - = note: this error originates in the macro `gen_gen_inner_invoc` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `include` which eventually expands to macro `gen_gen_inner_invoc` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0659]: `m` is ambiguous --> $DIR/restricted-shadowing-legacy.rs:139:42 @@ -52,7 +52,7 @@ LL | macro_rules! m { () => {} } ... LL | include!(); | ---------- in this macro invocation - = note: this error originates in the macro `gen_invoc` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `include` which eventually expands to macro `gen_invoc` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0659]: `m` is ambiguous --> $DIR/restricted-shadowing-legacy.rs:148:9 @@ -136,7 +136,7 @@ LL | macro_rules! m { () => { Wrong } } ... LL | include!(); | ---------- in this macro invocation - = note: this error originates in the macro `gen_gen_inner_invoc` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `include` which eventually expands to macro `gen_gen_inner_invoc` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0659]: `m` is ambiguous --> $DIR/restricted-shadowing-legacy.rs:218:42 @@ -164,7 +164,7 @@ LL | macro_rules! m { () => { Wrong } } ... LL | include!(); | ---------- in this macro invocation - = note: this error originates in the macro `gen_invoc` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `include` which eventually expands to macro `gen_invoc` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0659]: `m` is ambiguous --> $DIR/restricted-shadowing-legacy.rs:232:9 @@ -220,7 +220,7 @@ LL | macro_rules! m { () => {} } ... LL | include!(); | ---------- in this macro invocation - = note: this error originates in the macro `gen_invoc` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `include` which eventually expands to macro `gen_invoc` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 8 previous errors diff --git a/src/test/ui/macros/restricted-shadowing-modern.stderr b/src/test/ui/macros/restricted-shadowing-modern.stderr index b169e63132e45..ee4fe035c65b3 100644 --- a/src/test/ui/macros/restricted-shadowing-modern.stderr +++ b/src/test/ui/macros/restricted-shadowing-modern.stderr @@ -24,7 +24,7 @@ LL | macro m() {} ... LL | include!(); | ---------- in this macro invocation - = note: this error originates in the macro `gen_gen_inner_invoc` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `include` which eventually expands to macro `gen_gen_inner_invoc` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0659]: `m` is ambiguous --> $DIR/restricted-shadowing-modern.rs:147:33 @@ -52,7 +52,7 @@ LL | macro m() {} ... LL | include!(); | ---------- in this macro invocation - = note: this error originates in the macro `gen_invoc` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `include` which eventually expands to macro `gen_invoc` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0659]: `m` is ambiguous --> $DIR/restricted-shadowing-modern.rs:156:13 @@ -136,7 +136,7 @@ LL | macro m() { Wrong } ... LL | include!(); | ---------- in this macro invocation - = note: this error originates in the macro `gen_gen_inner_invoc` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `include` which eventually expands to macro `gen_gen_inner_invoc` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0659]: `m` is ambiguous --> $DIR/restricted-shadowing-modern.rs:233:33 @@ -164,7 +164,7 @@ LL | macro m() { Wrong } ... LL | include!(); | ---------- in this macro invocation - = note: this error originates in the macro `gen_invoc` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `include` which eventually expands to macro `gen_invoc` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 6 previous errors diff --git a/src/test/ui/macros/unreachable-format-args.edition_2015.stderr b/src/test/ui/macros/unreachable-format-args.edition_2015.stderr index dda45d14a3f1b..f89cf0012800e 100644 --- a/src/test/ui/macros/unreachable-format-args.edition_2015.stderr +++ b/src/test/ui/macros/unreachable-format-args.edition_2015.stderr @@ -6,7 +6,7 @@ LL | unreachable!("x is {x} and y is {y}", y = 0); | = note: did you intend to capture a variable `x` from the surrounding scope? = note: to avoid ambiguity, `format_args!` cannot capture variables when the format string is expanded from a macro - = note: this error originates in the macro `$crate::concat` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `unreachable` which eventually expands to macro `$crate::concat` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/moves/moves-based-on-type-capture-clause-bad.stderr b/src/test/ui/moves/moves-based-on-type-capture-clause-bad.stderr index ac921c18e07d5..9759ceda76854 100644 --- a/src/test/ui/moves/moves-based-on-type-capture-clause-bad.stderr +++ b/src/test/ui/moves/moves-based-on-type-capture-clause-bad.stderr @@ -11,7 +11,7 @@ LL | }); LL | println!("{}", x); | ^ value borrowed here after move | - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/on-unimplemented/no-debug.stderr b/src/test/ui/on-unimplemented/no-debug.stderr index 417e01e491b47..942d40b907cd9 100644 --- a/src/test/ui/on-unimplemented/no-debug.stderr +++ b/src/test/ui/on-unimplemented/no-debug.stderr @@ -6,7 +6,7 @@ LL | println!("{:?} {:?}", Foo, Bar); | = help: the trait `Debug` is not implemented for `Foo` = note: add `#[derive(Debug)]` to `Foo` or manually `impl Debug for Foo` - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Foo` with `#[derive(Debug)]` | LL | #[derive(Debug)] @@ -19,7 +19,7 @@ LL | println!("{:?} {:?}", Foo, Bar); | ^^^ `Bar` cannot be formatted using `{:?}` because it doesn't implement `Debug` | = help: the trait `Debug` is not implemented for `Bar` - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: `Foo` doesn't implement `std::fmt::Display` --> $DIR/no-debug.rs:11:23 @@ -29,7 +29,7 @@ LL | println!("{} {}", Foo, Bar); | = help: the trait `std::fmt::Display` is not implemented for `Foo` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: `Bar` doesn't implement `std::fmt::Display` --> $DIR/no-debug.rs:11:28 @@ -39,7 +39,7 @@ LL | println!("{} {}", Foo, Bar); | = help: the trait `std::fmt::Display` is not implemented for `Bar` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 4 previous errors diff --git a/src/test/ui/parser/macro/pub-item-macro.stderr b/src/test/ui/parser/macro/pub-item-macro.stderr index 4f82acf38e109..4a20fc4b5b43a 100644 --- a/src/test/ui/parser/macro/pub-item-macro.stderr +++ b/src/test/ui/parser/macro/pub-item-macro.stderr @@ -24,7 +24,7 @@ LL | static x: u32 = 0; ... LL | pub_x!(); | -------- in this macro invocation - = note: this error originates in the macro `priv_x` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `pub_x` which expands to macro `priv_x` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors diff --git a/src/test/ui/proc-macro/mixed-site-span.stderr b/src/test/ui/proc-macro/mixed-site-span.stderr index 60f082d177a9e..4f11790109d88 100644 --- a/src/test/ui/proc-macro/mixed-site-span.stderr +++ b/src/test/ui/proc-macro/mixed-site-span.stderr @@ -26,7 +26,7 @@ error[E0412]: cannot find type `ItemUse` in crate `$crate` LL | pass_dollar_crate!(); | ^^^^^^^^^^^^^^^^^^^^ not found in `$crate` | - = note: this error originates in the macro `proc_macro_rules` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `pass_dollar_crate` which expands to macro `proc_macro_rules` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 4 previous errors diff --git a/src/test/ui/proc-macro/parent-source-spans.stderr b/src/test/ui/proc-macro/parent-source-spans.stderr index 4548269b50793..f4a903094a636 100644 --- a/src/test/ui/proc-macro/parent-source-spans.stderr +++ b/src/test/ui/proc-macro/parent-source-spans.stderr @@ -7,7 +7,7 @@ LL | three!($a, $b); LL | one!("hello", "world"); | ---------------------- in this macro invocation | - = note: this error originates in the macro `two` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `one` which expands to macro `two` (in Nightly builds, run with -Z macro-backtrace for more info) error: second final: "world" --> $DIR/parent-source-spans.rs:16:16 @@ -18,7 +18,7 @@ LL | three!($a, $b); LL | one!("hello", "world"); | ---------------------- in this macro invocation | - = note: this error originates in the macro `two` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `one` which expands to macro `two` (in Nightly builds, run with -Z macro-backtrace for more info) error: first parent: "hello" --> $DIR/parent-source-spans.rs:10:5 @@ -150,7 +150,7 @@ LL | one!("hello", "world"); LL | Ok(#[stable(feature = "rust1", since = "1.0.0")] T), | --------------------------------------------------- similarly named tuple variant `Ok` defined here | - = note: this error originates in the macro `parent_source_spans` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `one` which eventually expands to macro `parent_source_spans` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0425]: cannot find value `ok` in this scope --> $DIR/parent-source-spans.rs:29:5 @@ -166,7 +166,7 @@ LL | two!("yay", "rust"); LL | Ok(#[stable(feature = "rust1", since = "1.0.0")] T), | --------------------------------------------------- similarly named tuple variant `Ok` defined here | - = note: this error originates in the macro `parent_source_spans` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `two` which eventually expands to macro `parent_source_spans` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0425]: cannot find value `ok` in this scope --> $DIR/parent-source-spans.rs:29:5 @@ -182,7 +182,7 @@ LL | three!("hip", "hop"); LL | Ok(#[stable(feature = "rust1", since = "1.0.0")] T), | --------------------------------------------------- similarly named tuple variant `Ok` defined here | - = note: this error originates in the macro `parent_source_spans` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `three` which eventually expands to macro `parent_source_spans` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 21 previous errors diff --git a/src/test/ui/proc-macro/weird-hygiene.stderr b/src/test/ui/proc-macro/weird-hygiene.stderr index b4e7fe444acce..0bdb52959a86f 100644 --- a/src/test/ui/proc-macro/weird-hygiene.stderr +++ b/src/test/ui/proc-macro/weird-hygiene.stderr @@ -7,7 +7,7 @@ LL | Value = (stringify!($tokens + hidden_ident), 1).1 LL | other!(50); | ---------- in this macro invocation | - = note: this error originates in the macro `inner` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `other` which expands to macro `inner` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0425]: cannot find value `hidden_ident` in this scope --> $DIR/weird-hygiene.rs:34:13 diff --git a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr index ea1f66d78a378..7c6f0e9e3459f 100644 --- a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr +++ b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr @@ -6,7 +6,7 @@ LL | let _: NotDebug = dbg!(NotDebug); | = help: the trait `Debug` is not implemented for `NotDebug` = note: add `#[derive(Debug)]` to `NotDebug` or manually `impl Debug for NotDebug` - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `dbg` which eventually expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `NotDebug` with `#[derive(Debug)]` | LL | #[derive(Debug)] diff --git a/src/test/ui/suggestions/bound-suggestions.stderr b/src/test/ui/suggestions/bound-suggestions.stderr index e5e19444d2435..e5887b98b6d0e 100644 --- a/src/test/ui/suggestions/bound-suggestions.stderr +++ b/src/test/ui/suggestions/bound-suggestions.stderr @@ -4,7 +4,7 @@ error[E0277]: `impl Sized` doesn't implement `Debug` LL | println!("{:?}", t); | ^ `impl Sized` cannot be formatted using `{:?}` because it doesn't implement `Debug` | - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider further restricting this bound | LL | fn test_impl(t: impl Sized + std::fmt::Debug) { @@ -16,7 +16,7 @@ error[E0277]: `T` doesn't implement `Debug` LL | println!("{:?}", t); | ^ `T` cannot be formatted using `{:?}` because it doesn't implement `Debug` | - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider restricting type parameter `T` | LL | fn test_no_bounds(t: T) { @@ -28,7 +28,7 @@ error[E0277]: `T` doesn't implement `Debug` LL | println!("{:?}", t); | ^ `T` cannot be formatted using `{:?}` because it doesn't implement `Debug` | - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider further restricting this bound | LL | fn test_one_bound(t: T) { @@ -40,7 +40,7 @@ error[E0277]: `Y` doesn't implement `Debug` LL | println!("{:?} {:?}", x, y); | ^ `Y` cannot be formatted using `{:?}` because it doesn't implement `Debug` | - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider further restricting type parameter `Y` | LL | fn test_no_bounds_where(x: X, y: Y) where X: std::fmt::Debug, Y: std::fmt::Debug { @@ -52,7 +52,7 @@ error[E0277]: `X` doesn't implement `Debug` LL | println!("{:?}", x); | ^ `X` cannot be formatted using `{:?}` because it doesn't implement `Debug` | - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider further restricting this bound | LL | fn test_one_bound_where(x: X) where X: Sized + std::fmt::Debug { @@ -64,7 +64,7 @@ error[E0277]: `X` doesn't implement `Debug` LL | println!("{:?}", x); | ^ `X` cannot be formatted using `{:?}` because it doesn't implement `Debug` | - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider further restricting this bound | LL | fn test_many_bounds_where(x: X) where X: Sized + std::fmt::Debug, X: Sized { diff --git a/src/test/ui/suggestions/dont-suggest-deref-inside-macro-issue-58298.stderr b/src/test/ui/suggestions/dont-suggest-deref-inside-macro-issue-58298.stderr index 3599d53d2a11f..24fd13e04efc9 100644 --- a/src/test/ui/suggestions/dont-suggest-deref-inside-macro-issue-58298.stderr +++ b/src/test/ui/suggestions/dont-suggest-deref-inside-macro-issue-58298.stderr @@ -6,7 +6,7 @@ LL | | "abc" LL | | }; | |_____^ expected `&str`, found struct `String` | - = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `intrinsic_match` which expands to macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/suggestions/issue-97760.stderr b/src/test/ui/suggestions/issue-97760.stderr index 459556bddaee5..fa452ea0f2cbb 100644 --- a/src/test/ui/suggestions/issue-97760.stderr +++ b/src/test/ui/suggestions/issue-97760.stderr @@ -6,7 +6,7 @@ LL | println!("{x}"); | = help: the trait `std::fmt::Display` is not implemented for `::Item` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) help: introduce a type parameter with a trait bound instead of using `impl Trait` | LL ~ pub fn print_values(values: &I) diff --git a/src/test/ui/suggestions/path-display.stderr b/src/test/ui/suggestions/path-display.stderr index 5e718d79307a8..a1b320771e96c 100644 --- a/src/test/ui/suggestions/path-display.stderr +++ b/src/test/ui/suggestions/path-display.stderr @@ -6,7 +6,7 @@ LL | println!("{}", path); | = help: the trait `std::fmt::Display` is not implemented for `Path` = note: call `.display()` or `.to_string_lossy()` to safely print paths, as they may contain non-Unicode data - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: `PathBuf` doesn't implement `std::fmt::Display` --> $DIR/path-display.rs:9:20 @@ -16,7 +16,7 @@ LL | println!("{}", path); | = help: the trait `std::fmt::Display` is not implemented for `PathBuf` = note: call `.display()` or `.to_string_lossy()` to safely print paths, as they may contain non-Unicode data - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors diff --git a/src/test/ui/try-block/try-block-maybe-bad-lifetime.stderr b/src/test/ui/try-block/try-block-maybe-bad-lifetime.stderr index d6822d94ca8c9..91a2fe41a03b7 100644 --- a/src/test/ui/try-block/try-block-maybe-bad-lifetime.stderr +++ b/src/test/ui/try-block/try-block-maybe-bad-lifetime.stderr @@ -22,7 +22,7 @@ LL | }; LL | println!("{}", x); | ^ value borrowed here after move | - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0506]: cannot assign to `i` because it is borrowed --> $DIR/try-block-maybe-bad-lifetime.rs:40:9 diff --git a/src/test/ui/type-alias-impl-trait/nested.stderr b/src/test/ui/type-alias-impl-trait/nested.stderr index cf4d23656e0e1..9b35e27dbc7e4 100644 --- a/src/test/ui/type-alias-impl-trait/nested.stderr +++ b/src/test/ui/type-alias-impl-trait/nested.stderr @@ -5,7 +5,7 @@ LL | println!("{:?}", bar()); | ^^^^^ `Bar` cannot be formatted using `{:?}` because it doesn't implement `Debug` | = help: the trait `Debug` is not implemented for `Bar` - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/type/ascription/issue-47666.stderr b/src/test/ui/type/ascription/issue-47666.stderr index b59a73af9f93b..90a4704a600a9 100644 --- a/src/test/ui/type/ascription/issue-47666.stderr +++ b/src/test/ui/type/ascription/issue-47666.stderr @@ -10,7 +10,7 @@ LL | let _ = Option:Some(vec![0, 1]); | help: maybe write a path separator here: `::` | = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `: ` - = note: this error originates in the macro `$crate::__rust_force_expr` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `vec` which expands to macro `$crate::__rust_force_expr` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/use/use-after-move-based-on-type.stderr b/src/test/ui/use/use-after-move-based-on-type.stderr index 361a6e2d8c278..0c9912e7e7af1 100644 --- a/src/test/ui/use/use-after-move-based-on-type.stderr +++ b/src/test/ui/use/use-after-move-based-on-type.stderr @@ -8,7 +8,7 @@ LL | let _y = x; LL | println!("{}", x); | ^ value borrowed here after move | - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/walk-struct-literal-with.stderr b/src/test/ui/walk-struct-literal-with.stderr index 377a807445891..b53b218901963 100644 --- a/src/test/ui/walk-struct-literal-with.stderr +++ b/src/test/ui/walk-struct-literal-with.stderr @@ -13,7 +13,7 @@ note: this function takes ownership of the receiver `self`, which moves `start` | LL | fn make_string_bar(mut self) -> Mine{ | ^^^^ - = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` which expands to macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error From 524d2b3178c7fab77894b942f328abb32f6b2776 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Fri, 27 May 2022 19:31:10 +0000 Subject: [PATCH 2/9] Make RPIT and TAIT work exactly the same --- .../rustc_infer/src/infer/opaque_types.rs | 33 ++++++---- compiler/rustc_typeck/src/check/check.rs | 4 +- compiler/rustc_typeck/src/check/closure.rs | 63 +++++++++++-------- .../assoc-type-eq-with-dyn-atb-fail.rs | 2 +- .../assoc-type-eq-with-dyn-atb-fail.stderr | 8 +-- src/test/ui/async-await/issues/issue-65159.rs | 1 + .../ui/async-await/issues/issue-65159.stderr | 16 ++++- .../issue-82126-mismatched-subst-and-hir.rs | 1 + ...ssue-82126-mismatched-subst-and-hir.stderr | 18 ++++-- src/test/ui/chalkify/bugs/async.stderr | 9 +-- .../bugs/issue-89008.stderr | 8 +-- src/test/ui/impl-trait/issue-55872-1.rs | 4 +- src/test/ui/impl-trait/issue-55872-1.stderr | 12 ++-- src/test/ui/impl-trait/issue-55872-3.rs | 2 +- src/test/ui/impl-trait/issue-55872-3.stderr | 6 +- src/test/ui/impl-trait/issues/issue-70877.rs | 2 +- .../ui/impl-trait/issues/issue-70877.stderr | 17 +---- src/test/ui/impl-trait/issues/issue-78722.rs | 3 +- .../ui/impl-trait/issues/issue-78722.stderr | 10 +-- src/test/ui/impl-trait/issues/issue-83919.rs | 3 +- .../ui/impl-trait/issues/issue-83919.stderr | 11 +--- .../impl-trait/nested-return-type2-tait2.rs | 2 +- .../nested-return-type2-tait2.stderr | 8 +-- .../impl-trait/nested-return-type2-tait3.rs | 2 +- .../nested-return-type2-tait3.stderr | 8 +-- .../ui/lazy-type-alias-impl-trait/branches.rs | 3 +- .../branches.stderr | 16 ----- .../lazy-type-alias-impl-trait/branches2.rs | 2 +- .../lazy-type-alias-impl-trait/branches3.rs | 36 +++++++++++ .../branches3.stderr | 51 +++++++++++++++ .../lazy-type-alias-impl-trait/recursion2.rs | 4 +- .../recursion2.stderr | 16 ----- .../ui/never_type/impl_trait_fallback2.rs | 1 + .../ui/never_type/impl_trait_fallback2.stderr | 10 ++- .../ui/never_type/impl_trait_fallback3.rs | 2 +- .../ui/never_type/impl_trait_fallback3.stderr | 11 ++-- .../closures_in_branches.rs | 2 +- .../closures_in_branches.stderr | 14 ++++- src/test/ui/type-alias-impl-trait/fallback.rs | 2 +- .../ui/type-alias-impl-trait/fallback.stderr | 15 +++++ .../issue-53398-cyclic-types.rs | 3 +- .../issue-53398-cyclic-types.stderr | 6 +- .../type-alias-impl-trait/issue-60371.stderr | 2 +- .../ui/type-alias-impl-trait/issue-63279.rs | 1 + .../type-alias-impl-trait/issue-63279.stderr | 32 ++++++---- .../type-alias-impl-trait/issue-74280.stderr | 8 +-- .../ui/type-alias-impl-trait/issue-94429.rs | 3 +- .../type-alias-impl-trait/issue-94429.stderr | 10 ++- .../multiple-def-uses-in-one-fn.rs | 2 +- .../multiple-def-uses-in-one-fn.stderr | 6 +- .../multiple-def-uses-in-one-fn3.stderr | 7 +-- .../self-referential-2.rs | 2 +- .../self-referential-2.stderr | 6 +- .../self-referential-4.rs | 6 +- .../self-referential-4.stderr | 18 ++++-- .../type-alias-impl-trait/self-referential.rs | 9 ++- .../self-referential.stderr | 21 +++++-- 57 files changed, 359 insertions(+), 221 deletions(-) delete mode 100644 src/test/ui/lazy-type-alias-impl-trait/branches.stderr create mode 100644 src/test/ui/lazy-type-alias-impl-trait/branches3.rs create mode 100644 src/test/ui/lazy-type-alias-impl-trait/branches3.stderr delete mode 100644 src/test/ui/lazy-type-alias-impl-trait/recursion2.stderr create mode 100644 src/test/ui/type-alias-impl-trait/fallback.stderr diff --git a/compiler/rustc_infer/src/infer/opaque_types.rs b/compiler/rustc_infer/src/infer/opaque_types.rs index ebb8d4434215f..7d7fa9f294194 100644 --- a/compiler/rustc_infer/src/infer/opaque_types.rs +++ b/compiler/rustc_infer/src/infer/opaque_types.rs @@ -38,6 +38,15 @@ pub struct OpaqueTypeDecl<'tcx> { pub origin: hir::OpaqueTyOrigin, } +pub enum ReplaceOpaqueTypes { + /// Closures can't create hidden types for opaque types of their parent, as they + /// do not have all the outlives information available. Also `type_of` looks for + /// hidden types in the owner (so the closure's parent), so it would not find these + /// definitions. + OnlyForRPIT, + All, +} + impl<'a, 'tcx> InferCtxt<'a, 'tcx> { pub fn replace_opaque_types_with_inference_vars( &self, @@ -46,27 +55,29 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { span: Span, code: ObligationCauseCode<'tcx>, param_env: ty::ParamEnv<'tcx>, + replace: ReplaceOpaqueTypes, ) -> InferOk<'tcx, Ty<'tcx>> { if !ty.has_opaque_types() { return InferOk { value: ty, obligations: vec![] }; } let mut obligations = vec![]; + let replace_opaque_type = |def_id| match self.opaque_type_origin(def_id, span) { + None => false, + Some(OpaqueTyOrigin::FnReturn(..)) => true, + // Not using `==` or `matches!` here to make sure we exhaustively match variants. + Some(_) => match replace { + ReplaceOpaqueTypes::OnlyForRPIT => false, + ReplaceOpaqueTypes::All => true, + }, + }; let value = ty.fold_with(&mut ty::fold::BottomUpFolder { tcx: self.tcx, lt_op: |lt| lt, ct_op: |ct| ct, ty_op: |ty| match *ty.kind() { - // Closures can't create hidden types for opaque types of their parent, as they - // do not have all the outlives information available. Also `type_of` looks for - // hidden types in the owner (so the closure's parent), so it would not find these - // definitions. - ty::Opaque(def_id, _substs) - if matches!( - self.opaque_type_origin(def_id, span), - Some(OpaqueTyOrigin::FnReturn(..)) - ) => - { - let span = if span.is_dummy() { self.tcx.def_span(def_id) } else { span }; + ty::Opaque(def_id, _substs) if replace_opaque_type(def_id) => { + let def_span = self.tcx.def_span(def_id); + let span = if span.contains(def_span) { def_span } else { span }; let cause = ObligationCause::new(span, body_id, code.clone()); // FIXME(compiler-errors): We probably should add a new TypeVariableOriginKind // for opaque types, and then use that kind to fix the spans for type errors diff --git a/compiler/rustc_typeck/src/check/check.rs b/compiler/rustc_typeck/src/check/check.rs index 8ffffbed93c26..184bc4188c5c8 100644 --- a/compiler/rustc_typeck/src/check/check.rs +++ b/compiler/rustc_typeck/src/check/check.rs @@ -13,6 +13,7 @@ use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::intravisit::Visitor; use rustc_hir::lang_items::LangItem; use rustc_hir::{ItemKind, Node, PathSegment}; +use rustc_infer::infer::opaque_types::ReplaceOpaqueTypes; use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; use rustc_infer::infer::{RegionVariableOrigin, TyCtxtInferExt}; use rustc_infer::traits::Obligation; @@ -95,9 +96,10 @@ pub(super) fn check_fn<'a, 'tcx>( fcx.register_infer_ok_obligations(fcx.infcx.replace_opaque_types_with_inference_vars( declared_ret_ty, body.value.hir_id, - DUMMY_SP, + decl.output.span(), traits::ObligationCauseCode::OpaqueReturnType(None), param_env, + ReplaceOpaqueTypes::All, )); // If we replaced declared_ret_ty with infer vars, then we must be infering // an opaque type, so set a flag so we can improve diagnostics. diff --git a/compiler/rustc_typeck/src/check/closure.rs b/compiler/rustc_typeck/src/check/closure.rs index cce1130511944..918a42cf02b1d 100644 --- a/compiler/rustc_typeck/src/check/closure.rs +++ b/compiler/rustc_typeck/src/check/closure.rs @@ -7,6 +7,7 @@ use crate::rustc_middle::ty::subst::Subst; use rustc_hir as hir; use rustc_hir::def_id::DefId; use rustc_hir::lang_items::LangItem; +use rustc_infer::infer::opaque_types::ReplaceOpaqueTypes; use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; use rustc_infer::infer::LateBoundRegionConversionTime; use rustc_infer::infer::{InferOk, InferResult}; @@ -645,6 +646,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { result } + /// Closures can't create hidden types for opaque types of their parent, as they + /// do not have all the outlives information available. Also `type_of` looks for + /// hidden types in the owner (so the closure's parent), so it would not find these + /// definitions. fn hide_parent_opaque_types(&self, ty: Ty<'tcx>, span: Span, body_id: hir::HirId) -> Ty<'tcx> { let InferOk { value, obligations } = self.replace_opaque_types_with_inference_vars( ty, @@ -652,6 +657,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { span, ObligationCauseCode::MiscObligation, self.param_env, + ReplaceOpaqueTypes::OnlyForRPIT, ); self.register_predicates(obligations); value @@ -671,8 +677,37 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let ret_ty = ret_coercion.borrow().expected_ty(); let ret_ty = self.inh.infcx.shallow_resolve(ret_ty); - let (def_id, substs) = match *ret_ty.kind() { - ty::Opaque(def_id, substs) => (def_id, substs), + + let get_future_output = |predicate: ty::Predicate<'tcx>, span| { + // Search for a pending obligation like + // + // `::Output = T` + // + // where R is the return type we are expecting. This type `T` + // will be our output. + let bound_predicate = predicate.kind(); + if let ty::PredicateKind::Projection(proj_predicate) = bound_predicate.skip_binder() { + self.deduce_future_output_from_projection( + span, + bound_predicate.rebind(proj_predicate), + ) + } else { + None + } + }; + + let output_ty = match *ret_ty.kind() { + ty::Infer(ty::TyVar(ret_vid)) => { + self.obligations_for_self_ty(ret_vid).find_map(|(_, obligation)| { + get_future_output(obligation.predicate, obligation.cause.span) + }) + } + ty::Opaque(def_id, substs) => self + .tcx + .bound_explicit_item_bounds(def_id) + .transpose_iter() + .map(|e| e.map_bound(|e| *e).transpose_tuple2()) + .find_map(|(p, s)| get_future_output(p.subst(self.tcx, substs), s.0)), ty::Error(_) => return None, _ => span_bug!( self.tcx.def_span(expr_def_id), @@ -680,30 +715,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ), }; - let item_bounds = self.tcx.bound_explicit_item_bounds(def_id); - - // Search for a pending obligation like - // - // `::Output = T` - // - // where R is the return type we are expecting. This type `T` - // will be our output. - let output_ty = item_bounds - .transpose_iter() - .map(|e| e.map_bound(|e| *e).transpose_tuple2()) - .find_map(|(predicate, span)| { - let bound_predicate = predicate.subst(self.tcx, substs).kind(); - if let ty::PredicateKind::Projection(proj_predicate) = bound_predicate.skip_binder() - { - self.deduce_future_output_from_projection( - span.0, - bound_predicate.rebind(proj_predicate), - ) - } else { - None - } - }); - debug!("deduce_future_output_from_obligations: output_ty={:?}", output_ty); output_ty } diff --git a/src/test/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.rs b/src/test/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.rs index 67b97c21805e6..4c36289f47b85 100644 --- a/src/test/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.rs +++ b/src/test/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.rs @@ -30,7 +30,7 @@ impl Thing for AssocNoCopy { type Out = Box>; fn func() -> Self::Out { - Box::new(AssocNoCopy) //~^ ERROR the trait bound `String: Copy` is not satisfied + Box::new(AssocNoCopy) } } diff --git a/src/test/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.stderr b/src/test/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.stderr index f40e6585b38b1..a32ab453152a0 100644 --- a/src/test/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.stderr +++ b/src/test/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.stderr @@ -1,10 +1,8 @@ error[E0277]: the trait bound `String: Copy` is not satisfied - --> $DIR/assoc-type-eq-with-dyn-atb-fail.rs:33:9 + --> $DIR/assoc-type-eq-with-dyn-atb-fail.rs:32:18 | -LL | Box::new(AssocNoCopy) - | ^^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String` - | - = note: required for the cast from `AssocNoCopy` to the object type `dyn Bar::Out::{opaque#0}>` +LL | fn func() -> Self::Out { + | ^^^^^^^^^ the trait `Copy` is not implemented for `String` error: aborting due to previous error diff --git a/src/test/ui/async-await/issues/issue-65159.rs b/src/test/ui/async-await/issues/issue-65159.rs index df2ca025705d3..1dbf5db6c32ed 100644 --- a/src/test/ui/async-await/issues/issue-65159.rs +++ b/src/test/ui/async-await/issues/issue-65159.rs @@ -6,6 +6,7 @@ async fn copy() -> Result<()> //~^ ERROR this enum takes 2 generic arguments { Ok(()) + //~^ ERROR type annotations needed } fn main() { } diff --git a/src/test/ui/async-await/issues/issue-65159.stderr b/src/test/ui/async-await/issues/issue-65159.stderr index 45f5ec40cd758..9918f569cbc89 100644 --- a/src/test/ui/async-await/issues/issue-65159.stderr +++ b/src/test/ui/async-await/issues/issue-65159.stderr @@ -16,6 +16,18 @@ help: add missing generic argument LL | async fn copy() -> Result<(), E> | +++ -error: aborting due to previous error +error[E0282]: type annotations needed + --> $DIR/issue-65159.rs:8:5 + | +LL | Ok(()) + | ^^ cannot infer type of the type parameter `E` declared on the enum `Result` + | +help: consider specifying the generic arguments + | +LL | Ok::<(), E>(()) + | +++++++++ + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0107`. +Some errors have detailed explanations: E0107, E0282. +For more information about an error, try `rustc --explain E0107`. diff --git a/src/test/ui/borrowck/issue-82126-mismatched-subst-and-hir.rs b/src/test/ui/borrowck/issue-82126-mismatched-subst-and-hir.rs index dd0320bc53ba7..2c8a700bc2ea3 100644 --- a/src/test/ui/borrowck/issue-82126-mismatched-subst-and-hir.rs +++ b/src/test/ui/borrowck/issue-82126-mismatched-subst-and-hir.rs @@ -17,6 +17,7 @@ async fn buy_lock(generator: &Mutex) -> LockedMarket<'_> { //~^ ERROR this struct takes 0 lifetime arguments but 1 lifetime argument was supplied //~^^ ERROR this struct takes 1 generic argument but 0 generic arguments were supplied LockedMarket(generator.lock().unwrap().buy()) + //~^ ERROR cannot return value referencing temporary } struct LockedMarket(T); diff --git a/src/test/ui/borrowck/issue-82126-mismatched-subst-and-hir.stderr b/src/test/ui/borrowck/issue-82126-mismatched-subst-and-hir.stderr index d2b927fb664c6..4bd0667304397 100644 --- a/src/test/ui/borrowck/issue-82126-mismatched-subst-and-hir.stderr +++ b/src/test/ui/borrowck/issue-82126-mismatched-subst-and-hir.stderr @@ -7,7 +7,7 @@ LL | async fn buy_lock(generator: &Mutex) -> LockedMarket<'_> | expected 0 lifetime arguments | note: struct defined here, with 0 lifetime parameters - --> $DIR/issue-82126-mismatched-subst-and-hir.rs:22:8 + --> $DIR/issue-82126-mismatched-subst-and-hir.rs:23:8 | LL | struct LockedMarket(T); | ^^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | async fn buy_lock(generator: &Mutex) -> LockedMarket<'_> | ^^^^^^^^^^^^ expected 1 generic argument | note: struct defined here, with 1 generic parameter: `T` - --> $DIR/issue-82126-mismatched-subst-and-hir.rs:22:8 + --> $DIR/issue-82126-mismatched-subst-and-hir.rs:23:8 | LL | struct LockedMarket(T); | ^^^^^^^^^^^^ - @@ -28,6 +28,16 @@ help: add missing generic argument LL | async fn buy_lock(generator: &Mutex) -> LockedMarket<'_, T> { | +++ -error: aborting due to 2 previous errors +error[E0515]: cannot return value referencing temporary value + --> $DIR/issue-82126-mismatched-subst-and-hir.rs:19:5 + | +LL | LockedMarket(generator.lock().unwrap().buy()) + | ^^^^^^^^^^^^^-------------------------^^^^^^^ + | | | + | | temporary value created here + | returns a value referencing data owned by the current function + +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0107`. +Some errors have detailed explanations: E0107, E0515. +For more information about an error, try `rustc --explain E0107`. diff --git a/src/test/ui/chalkify/bugs/async.stderr b/src/test/ui/chalkify/bugs/async.stderr index 5b7ca8d46cf44..f53ed53f73c49 100644 --- a/src/test/ui/chalkify/bugs/async.stderr +++ b/src/test/ui/chalkify/bugs/async.stderr @@ -29,13 +29,10 @@ LL | T: Generator, | ^^^^^^^^^^ required by this bound in `std::future::from_generator` error[E0280]: the requirement ` as Future>::Output == u32` is not satisfied - --> $DIR/async.rs:7:29 + --> $DIR/async.rs:7:25 | -LL | async fn foo(x: u32) -> u32 { - | _____________________________^ -LL | | x -LL | | } - | |_^ +LL | async fn foo(x: u32) -> u32 { + | ^^^ error: aborting due to 3 previous errors diff --git a/src/test/ui/generic-associated-types/bugs/issue-89008.stderr b/src/test/ui/generic-associated-types/bugs/issue-89008.stderr index 5cbadfacc1b60..50844fdc14d94 100644 --- a/src/test/ui/generic-associated-types/bugs/issue-89008.stderr +++ b/src/test/ui/generic-associated-types/bugs/issue-89008.stderr @@ -1,10 +1,10 @@ error[E0271]: type mismatch resolving ` as Stream>::Item == Repr` - --> $DIR/issue-89008.rs:40:9 + --> $DIR/issue-89008.rs:39:43 | LL | fn line_stream<'a, Repr>(&'a self) -> Self::LineStreamFut<'a, Repr> { - | ---- this type parameter -LL | async {empty()} - | ^^^^^^^^^^^^^^^ type mismatch resolving ` as Stream>::Item == Repr` + | ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving ` as Stream>::Item == Repr` + | | + | this type parameter | note: expected this to be `()` --> $DIR/issue-89008.rs:18:17 diff --git a/src/test/ui/impl-trait/issue-55872-1.rs b/src/test/ui/impl-trait/issue-55872-1.rs index a75b9b43b3e8b..22ff7ffa23cb3 100644 --- a/src/test/ui/impl-trait/issue-55872-1.rs +++ b/src/test/ui/impl-trait/issue-55872-1.rs @@ -11,9 +11,9 @@ impl Bar for S { fn foo() -> Self::E { //~^ ERROR impl has stricter requirements than trait - (S::default(), T::default()) - //~^ ERROR the trait bound `S: Copy` is not satisfied in `(S, T)` [E0277] + //~| ERROR the trait bound `S: Copy` is not satisfied in `(S, T)` [E0277] //~| ERROR the trait bound `T: Copy` is not satisfied in `(S, T)` [E0277] + (S::default(), T::default()) } } diff --git a/src/test/ui/impl-trait/issue-55872-1.stderr b/src/test/ui/impl-trait/issue-55872-1.stderr index efc57da746132..8912cce1b4b5b 100644 --- a/src/test/ui/impl-trait/issue-55872-1.stderr +++ b/src/test/ui/impl-trait/issue-55872-1.stderr @@ -8,10 +8,10 @@ LL | fn foo() -> Self::E { | ^^^^^^^ impl has extra requirement `T: Default` error[E0277]: the trait bound `S: Copy` is not satisfied in `(S, T)` - --> $DIR/issue-55872-1.rs:14:9 + --> $DIR/issue-55872-1.rs:12:29 | -LL | (S::default(), T::default()) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `(S, T)`, the trait `Copy` is not implemented for `S` +LL | fn foo() -> Self::E { + | ^^^^^^^ within `(S, T)`, the trait `Copy` is not implemented for `S` | = note: required because it appears within the type `(S, T)` help: consider further restricting this bound @@ -20,10 +20,10 @@ LL | impl Bar for S { | +++++++++++++++++++ error[E0277]: the trait bound `T: Copy` is not satisfied in `(S, T)` - --> $DIR/issue-55872-1.rs:14:9 + --> $DIR/issue-55872-1.rs:12:29 | -LL | (S::default(), T::default()) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `(S, T)`, the trait `Copy` is not implemented for `T` +LL | fn foo() -> Self::E { + | ^^^^^^^ within `(S, T)`, the trait `Copy` is not implemented for `T` | = note: required because it appears within the type `(S, T)` help: consider further restricting this bound diff --git a/src/test/ui/impl-trait/issue-55872-3.rs b/src/test/ui/impl-trait/issue-55872-3.rs index 36d9fdede109e..3ffce85e61ba4 100644 --- a/src/test/ui/impl-trait/issue-55872-3.rs +++ b/src/test/ui/impl-trait/issue-55872-3.rs @@ -12,8 +12,8 @@ pub trait Bar { impl Bar for S { type E = impl std::marker::Copy; fn foo() -> Self::E { + //~^ ERROR the trait bound `impl Future: Copy` is not satisfied [E0277] async {} - //~^ ERROR the trait bound `impl Future: Copy` is not satisfied [E0277] } } diff --git a/src/test/ui/impl-trait/issue-55872-3.stderr b/src/test/ui/impl-trait/issue-55872-3.stderr index e7023e8127c3d..6ab540e875162 100644 --- a/src/test/ui/impl-trait/issue-55872-3.stderr +++ b/src/test/ui/impl-trait/issue-55872-3.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `impl Future: Copy` is not satisfied - --> $DIR/issue-55872-3.rs:15:9 + --> $DIR/issue-55872-3.rs:14:20 | -LL | async {} - | ^^^^^^^^ the trait `Copy` is not implemented for `impl Future` +LL | fn foo() -> Self::E { + | ^^^^^^^ the trait `Copy` is not implemented for `impl Future` error: aborting due to previous error diff --git a/src/test/ui/impl-trait/issues/issue-70877.rs b/src/test/ui/impl-trait/issues/issue-70877.rs index 1a86fa00ed1a0..8169cfafac711 100644 --- a/src/test/ui/impl-trait/issues/issue-70877.rs +++ b/src/test/ui/impl-trait/issues/issue-70877.rs @@ -13,7 +13,7 @@ impl Iterator for Bar { type Item = FooItem; fn next(&mut self) -> Option { - Some(Box::new(quux)) //~ ERROR mismatched types + Some(Box::new(quux)) } } diff --git a/src/test/ui/impl-trait/issues/issue-70877.stderr b/src/test/ui/impl-trait/issues/issue-70877.stderr index 7cbd58bdabf2f..8813bff3c353e 100644 --- a/src/test/ui/impl-trait/issues/issue-70877.stderr +++ b/src/test/ui/impl-trait/issues/issue-70877.stderr @@ -1,17 +1,3 @@ -error[E0308]: mismatched types - --> $DIR/issue-70877.rs:16:9 - | -LL | type FooRet = impl std::fmt::Debug; - | -------------------- the expected opaque type -... -LL | fn next(&mut self) -> Option { - | ------------------ expected `Option Fn(&'r (dyn ToString + 'r)) -> FooRet + 'static)>>` because of return type -LL | Some(Box::new(quux)) - | ^^^^^^^^^^^^^^^^^^^^ expected trait object `dyn Fn`, found fn item - | - = note: expected enum `Option Fn(&'r (dyn ToString + 'r)) -> FooRet + 'static)>>` - found enum `Option fn(&'r (dyn ToString + 'r)) -> FooRet {quux}>>` - error: opaque type's hidden type cannot be another opaque type from the same scope --> $DIR/issue-70877.rs:31:12 | @@ -29,6 +15,5 @@ note: opaque type being used as hidden type LL | type FooRet = impl std::fmt::Debug; | ^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to previous error -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/impl-trait/issues/issue-78722.rs b/src/test/ui/impl-trait/issues/issue-78722.rs index 5498793bc28da..002e4cde40abe 100644 --- a/src/test/ui/impl-trait/issues/issue-78722.rs +++ b/src/test/ui/impl-trait/issues/issue-78722.rs @@ -7,7 +7,8 @@ type F = impl core::future::Future; struct Bug { V1: [(); { fn concrete_use() -> F { - async {} //~ ERROR type mismatch + //~^ ERROR type mismatch + async {} } let f: F = async { 1 }; //~^ ERROR `async` blocks are not allowed in constants diff --git a/src/test/ui/impl-trait/issues/issue-78722.stderr b/src/test/ui/impl-trait/issues/issue-78722.stderr index 7a057c7f51b8c..690d6abc76663 100644 --- a/src/test/ui/impl-trait/issues/issue-78722.stderr +++ b/src/test/ui/impl-trait/issues/issue-78722.stderr @@ -1,5 +1,5 @@ error[E0658]: `async` blocks are not allowed in constants - --> $DIR/issue-78722.rs:12:20 + --> $DIR/issue-78722.rs:13:20 | LL | let f: F = async { 1 }; | ^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | let f: F = async { 1 }; = help: add `#![feature(const_async_blocks)]` to the crate attributes to enable error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/issue-78722.rs:12:13 + --> $DIR/issue-78722.rs:13:13 | LL | let f: F = async { 1 }; | ^ constants cannot evaluate destructors @@ -17,10 +17,10 @@ LL | }], | - value is dropped here error[E0271]: type mismatch resolving ` as Future>::Output == u8` - --> $DIR/issue-78722.rs:10:13 + --> $DIR/issue-78722.rs:9:30 | -LL | async {} - | ^^^^^^^^ expected `()`, found `u8` +LL | fn concrete_use() -> F { + | ^ expected `()`, found `u8` error: aborting due to 3 previous errors diff --git a/src/test/ui/impl-trait/issues/issue-83919.rs b/src/test/ui/impl-trait/issues/issue-83919.rs index 58aca77fdf19f..e76443a65dbf9 100644 --- a/src/test/ui/impl-trait/issues/issue-83919.rs +++ b/src/test/ui/impl-trait/issues/issue-83919.rs @@ -19,8 +19,9 @@ impl Foo for Implementor { type Fut = impl Future; fn get_fut(&self) -> Self::Fut { + //~^ ERROR `{integer}` is not a future async move { - 42 //~^ ERROR `{integer}` is not a future + 42 // 42 does not impl Future and rustc does actually point out the error, // but rustc used to panic. // Putting a valid Future here always worked fine. diff --git a/src/test/ui/impl-trait/issues/issue-83919.stderr b/src/test/ui/impl-trait/issues/issue-83919.stderr index ebd0130be8d06..d39dcf7fbf5d9 100644 --- a/src/test/ui/impl-trait/issues/issue-83919.stderr +++ b/src/test/ui/impl-trait/issues/issue-83919.stderr @@ -1,13 +1,8 @@ error[E0277]: `{integer}` is not a future - --> $DIR/issue-83919.rs:22:9 + --> $DIR/issue-83919.rs:21:26 | -LL | / async move { -LL | | 42 -LL | | // 42 does not impl Future and rustc does actually point out the error, -LL | | // but rustc used to panic. -LL | | // Putting a valid Future here always worked fine. -LL | | } - | |_________^ `{integer}` is not a future +LL | fn get_fut(&self) -> Self::Fut { + | ^^^^^^^^^ `{integer}` is not a future | = help: the trait `Future` is not implemented for `{integer}` = note: {integer} must be a future or must implement `IntoFuture` to be awaited diff --git a/src/test/ui/impl-trait/nested-return-type2-tait2.rs b/src/test/ui/impl-trait/nested-return-type2-tait2.rs index af8e066305471..fcc077ec18ece 100644 --- a/src/test/ui/impl-trait/nested-return-type2-tait2.rs +++ b/src/test/ui/impl-trait/nested-return-type2-tait2.rs @@ -24,8 +24,8 @@ type Traitable = impl Trait; // var to make it uphold the `: Duh` bound on `Trait::Assoc`. The opaque // type does not implement `Duh`, even if its hidden type does. So we error out. fn foo() -> Traitable { - || 42 //~^ ERROR `Sendable: Duh` is not satisfied + || 42 } fn main() { diff --git a/src/test/ui/impl-trait/nested-return-type2-tait2.stderr b/src/test/ui/impl-trait/nested-return-type2-tait2.stderr index 42e65e692488d..3e19ad7b5c6cf 100644 --- a/src/test/ui/impl-trait/nested-return-type2-tait2.stderr +++ b/src/test/ui/impl-trait/nested-return-type2-tait2.stderr @@ -1,11 +1,11 @@ error[E0277]: the trait bound `Sendable: Duh` is not satisfied - --> $DIR/nested-return-type2-tait2.rs:27:5 + --> $DIR/nested-return-type2-tait2.rs:26:13 | -LL | || 42 - | ^^^^^ the trait `Duh` is not implemented for `Sendable` +LL | fn foo() -> Traitable { + | ^^^^^^^^^ the trait `Duh` is not implemented for `Sendable` | = help: the trait `Duh` is implemented for `i32` -note: required because of the requirements on the impl of `Trait` for `[closure@$DIR/nested-return-type2-tait2.rs:27:5: 27:10]` +note: required because of the requirements on the impl of `Trait` for `[closure@$DIR/nested-return-type2-tait2.rs:28:5: 28:10]` --> $DIR/nested-return-type2-tait2.rs:14:31 | LL | impl R> Trait for F { diff --git a/src/test/ui/impl-trait/nested-return-type2-tait3.rs b/src/test/ui/impl-trait/nested-return-type2-tait3.rs index 74fd8a9dda0bf..665c7a8cab91f 100644 --- a/src/test/ui/impl-trait/nested-return-type2-tait3.rs +++ b/src/test/ui/impl-trait/nested-return-type2-tait3.rs @@ -23,8 +23,8 @@ type Traitable = impl Trait; // var to make it uphold the `: Duh` bound on `Trait::Assoc`. The opaque // type does not implement `Duh`, even if its hidden type does. So we error out. fn foo() -> Traitable { - || 42 //~^ ERROR `impl Send: Duh` is not satisfied + || 42 } fn main() { diff --git a/src/test/ui/impl-trait/nested-return-type2-tait3.stderr b/src/test/ui/impl-trait/nested-return-type2-tait3.stderr index 4d3691d0e07fa..6185e4872a5e3 100644 --- a/src/test/ui/impl-trait/nested-return-type2-tait3.stderr +++ b/src/test/ui/impl-trait/nested-return-type2-tait3.stderr @@ -1,11 +1,11 @@ error[E0277]: the trait bound `impl Send: Duh` is not satisfied - --> $DIR/nested-return-type2-tait3.rs:26:5 + --> $DIR/nested-return-type2-tait3.rs:25:13 | -LL | || 42 - | ^^^^^ the trait `Duh` is not implemented for `impl Send` +LL | fn foo() -> Traitable { + | ^^^^^^^^^ the trait `Duh` is not implemented for `impl Send` | = help: the trait `Duh` is implemented for `i32` -note: required because of the requirements on the impl of `Trait` for `[closure@$DIR/nested-return-type2-tait3.rs:26:5: 26:10]` +note: required because of the requirements on the impl of `Trait` for `[closure@$DIR/nested-return-type2-tait3.rs:27:5: 27:10]` --> $DIR/nested-return-type2-tait3.rs:14:31 | LL | impl R> Trait for F { diff --git a/src/test/ui/lazy-type-alias-impl-trait/branches.rs b/src/test/ui/lazy-type-alias-impl-trait/branches.rs index aa172f3f19b6b..e7db10bd7cd2d 100644 --- a/src/test/ui/lazy-type-alias-impl-trait/branches.rs +++ b/src/test/ui/lazy-type-alias-impl-trait/branches.rs @@ -1,5 +1,7 @@ #![feature(type_alias_impl_trait)] +// check-pass + type Foo = impl std::fmt::Debug; fn foo(b: bool) -> Foo { @@ -7,7 +9,6 @@ fn foo(b: bool) -> Foo { vec![42_i32] } else { std::iter::empty().collect() - //~^ ERROR `Foo` cannot be built from an iterator over elements of type `_` } } diff --git a/src/test/ui/lazy-type-alias-impl-trait/branches.stderr b/src/test/ui/lazy-type-alias-impl-trait/branches.stderr deleted file mode 100644 index c3902f34706bd..0000000000000 --- a/src/test/ui/lazy-type-alias-impl-trait/branches.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0277]: a value of type `Foo` cannot be built from an iterator over elements of type `_` - --> $DIR/branches.rs:9:28 - | -LL | std::iter::empty().collect() - | ^^^^^^^ value of type `Foo` cannot be built from `std::iter::Iterator` - | - = help: the trait `FromIterator<_>` is not implemented for `Foo` -note: required by a bound in `collect` - --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL - | -LL | fn collect>(self) -> B - | ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `collect` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/lazy-type-alias-impl-trait/branches2.rs b/src/test/ui/lazy-type-alias-impl-trait/branches2.rs index af605e4d8062d..04218f5643d1c 100644 --- a/src/test/ui/lazy-type-alias-impl-trait/branches2.rs +++ b/src/test/ui/lazy-type-alias-impl-trait/branches2.rs @@ -1,6 +1,6 @@ #![feature(type_alias_impl_trait)] -// run-pass +// check-pass type Foo = impl std::iter::FromIterator + PartialEq> + std::fmt::Debug; diff --git a/src/test/ui/lazy-type-alias-impl-trait/branches3.rs b/src/test/ui/lazy-type-alias-impl-trait/branches3.rs new file mode 100644 index 0000000000000..30c0af8a5dc97 --- /dev/null +++ b/src/test/ui/lazy-type-alias-impl-trait/branches3.rs @@ -0,0 +1,36 @@ +#![feature(type_alias_impl_trait)] + +type Foo = impl for<'a> FnOnce(&'a str) -> usize; +type Bar = impl FnOnce(&'static str) -> usize; + +fn foo() -> Foo { + if true { + |s| s.len() //~ ERROR type annotations needed + } else { + panic!() + } +} +fn bar() -> Bar { + if true { + |s| s.len() //~ ERROR type annotations needed + } else { + panic!() + } +} + +fn foo2() -> impl for<'a> FnOnce(&'a str) -> usize { + if true { + |s| s.len() //~ ERROR type annotations needed + } else { + panic!() + } +} +fn bar2() -> impl FnOnce(&'static str) -> usize { + if true { + |s| s.len() //~ ERROR type annotations needed + } else { + panic!() + } +} + +fn main() {} diff --git a/src/test/ui/lazy-type-alias-impl-trait/branches3.stderr b/src/test/ui/lazy-type-alias-impl-trait/branches3.stderr new file mode 100644 index 0000000000000..77ce1d48480ad --- /dev/null +++ b/src/test/ui/lazy-type-alias-impl-trait/branches3.stderr @@ -0,0 +1,51 @@ +error[E0282]: type annotations needed + --> $DIR/branches3.rs:8:10 + | +LL | |s| s.len() + | ^ + | + = note: type must be known at this point +help: consider giving this closure parameter an explicit type + | +LL | |s: _| s.len() + | +++ + +error[E0282]: type annotations needed + --> $DIR/branches3.rs:15:10 + | +LL | |s| s.len() + | ^ + | + = note: type must be known at this point +help: consider giving this closure parameter an explicit type + | +LL | |s: _| s.len() + | +++ + +error[E0282]: type annotations needed + --> $DIR/branches3.rs:23:10 + | +LL | |s| s.len() + | ^ + | + = note: type must be known at this point +help: consider giving this closure parameter an explicit type + | +LL | |s: _| s.len() + | +++ + +error[E0282]: type annotations needed + --> $DIR/branches3.rs:30:10 + | +LL | |s| s.len() + | ^ + | + = note: type must be known at this point +help: consider giving this closure parameter an explicit type + | +LL | |s: _| s.len() + | +++ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0282`. diff --git a/src/test/ui/lazy-type-alias-impl-trait/recursion2.rs b/src/test/ui/lazy-type-alias-impl-trait/recursion2.rs index 1cc64ea17e79e..6b3d9ff4cdec8 100644 --- a/src/test/ui/lazy-type-alias-impl-trait/recursion2.rs +++ b/src/test/ui/lazy-type-alias-impl-trait/recursion2.rs @@ -1,5 +1,7 @@ #![feature(type_alias_impl_trait)] +// check-pass + type Foo = impl std::fmt::Debug; fn foo(b: bool) -> Foo { @@ -7,7 +9,7 @@ fn foo(b: bool) -> Foo { return vec![]; } let x: Vec = foo(false); - std::iter::empty().collect() //~ ERROR `Foo` cannot be built from an iterator + std::iter::empty().collect() } fn bar(b: bool) -> impl std::fmt::Debug { diff --git a/src/test/ui/lazy-type-alias-impl-trait/recursion2.stderr b/src/test/ui/lazy-type-alias-impl-trait/recursion2.stderr deleted file mode 100644 index 1f6201a8300c6..0000000000000 --- a/src/test/ui/lazy-type-alias-impl-trait/recursion2.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0277]: a value of type `Foo` cannot be built from an iterator over elements of type `_` - --> $DIR/recursion2.rs:10:24 - | -LL | std::iter::empty().collect() - | ^^^^^^^ value of type `Foo` cannot be built from `std::iter::Iterator` - | - = help: the trait `FromIterator<_>` is not implemented for `Foo` -note: required by a bound in `collect` - --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL - | -LL | fn collect>(self) -> B - | ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `collect` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/never_type/impl_trait_fallback2.rs b/src/test/ui/never_type/impl_trait_fallback2.rs index f73d953bdbd0b..12c187b9e82aa 100644 --- a/src/test/ui/never_type/impl_trait_fallback2.rs +++ b/src/test/ui/never_type/impl_trait_fallback2.rs @@ -13,6 +13,7 @@ fn should_ret_unit() -> impl T { type Foo = impl T; fn a() -> Foo { + //~^ ERROR `(): T` is not satisfied panic!() } diff --git a/src/test/ui/never_type/impl_trait_fallback2.stderr b/src/test/ui/never_type/impl_trait_fallback2.stderr index 4a78e73e5f6d5..78cc83bdbfadb 100644 --- a/src/test/ui/never_type/impl_trait_fallback2.stderr +++ b/src/test/ui/never_type/impl_trait_fallback2.stderr @@ -6,6 +6,14 @@ LL | fn should_ret_unit() -> impl T { | = help: the trait `T` is implemented for `i32` -error: aborting due to previous error +error[E0277]: the trait bound `(): T` is not satisfied + --> $DIR/impl_trait_fallback2.rs:15:11 + | +LL | fn a() -> Foo { + | ^^^ the trait `T` is not implemented for `()` + | + = help: the trait `T` is implemented for `i32` + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/never_type/impl_trait_fallback3.rs b/src/test/ui/never_type/impl_trait_fallback3.rs index 26ce9b93105e6..ed645b82394a0 100644 --- a/src/test/ui/never_type/impl_trait_fallback3.rs +++ b/src/test/ui/never_type/impl_trait_fallback3.rs @@ -7,9 +7,9 @@ trait T { } type Foo = impl T; -//~^ ERROR unconstrained opaque type fn a() -> Foo { + //~^ ERROR the trait bound `(): T` is not satisfied // This is not a defining use, it doesn't actually constrain the opaque type. panic!() } diff --git a/src/test/ui/never_type/impl_trait_fallback3.stderr b/src/test/ui/never_type/impl_trait_fallback3.stderr index 121019d5f69ae..5d5d216fb9bcc 100644 --- a/src/test/ui/never_type/impl_trait_fallback3.stderr +++ b/src/test/ui/never_type/impl_trait_fallback3.stderr @@ -1,10 +1,9 @@ -error: unconstrained opaque type - --> $DIR/impl_trait_fallback3.rs:9:12 +error[E0277]: the trait bound `(): T` is not satisfied + --> $DIR/impl_trait_fallback3.rs:11:11 | -LL | type Foo = impl T; - | ^^^^^^ - | - = note: `Foo` must be used in combination with a concrete type within the same module +LL | fn a() -> Foo { + | ^^^ the trait `T` is not implemented for `()` error: aborting due to previous error +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/type-alias-impl-trait/closures_in_branches.rs b/src/test/ui/type-alias-impl-trait/closures_in_branches.rs index a1a9401acc2c4..7bb490bbec818 100644 --- a/src/test/ui/type-alias-impl-trait/closures_in_branches.rs +++ b/src/test/ui/type-alias-impl-trait/closures_in_branches.rs @@ -4,7 +4,7 @@ type Foo = impl std::ops::FnOnce(String) -> usize; fn foo(b: bool) -> Foo { if b { - |x| x.len() + |x| x.len() //~ ERROR type annotations needed } else { panic!() } diff --git a/src/test/ui/type-alias-impl-trait/closures_in_branches.stderr b/src/test/ui/type-alias-impl-trait/closures_in_branches.stderr index b3ca260894bc8..b7a7871143c63 100644 --- a/src/test/ui/type-alias-impl-trait/closures_in_branches.stderr +++ b/src/test/ui/type-alias-impl-trait/closures_in_branches.stderr @@ -1,3 +1,15 @@ +error[E0282]: type annotations needed + --> $DIR/closures_in_branches.rs:7:10 + | +LL | |x| x.len() + | ^ + | + = note: type must be known at this point +help: consider giving this closure parameter an explicit type + | +LL | |x: _| x.len() + | +++ + error[E0282]: type annotations needed --> $DIR/closures_in_branches.rs:21:10 | @@ -10,6 +22,6 @@ help: consider giving this closure parameter an explicit type LL | |x: _| x.len() | +++ -error: aborting due to previous error +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0282`. diff --git a/src/test/ui/type-alias-impl-trait/fallback.rs b/src/test/ui/type-alias-impl-trait/fallback.rs index d7e93335f47fa..d8cf7d71fef74 100644 --- a/src/test/ui/type-alias-impl-trait/fallback.rs +++ b/src/test/ui/type-alias-impl-trait/fallback.rs @@ -1,7 +1,6 @@ // Tests that we correctly handle opaque types being used opaquely, // even within their defining scope. // -// check-pass #![feature(type_alias_impl_trait)] type Foo = impl Copy; @@ -23,6 +22,7 @@ fn constrained_foo() -> Foo { // constraints on it. fn unconstrained_foo() -> Wrapper { Wrapper::Second + //~^ ERROR: type annotations needed } fn main() {} diff --git a/src/test/ui/type-alias-impl-trait/fallback.stderr b/src/test/ui/type-alias-impl-trait/fallback.stderr new file mode 100644 index 0000000000000..e009399a60abf --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/fallback.stderr @@ -0,0 +1,15 @@ +error[E0283]: type annotations needed + --> $DIR/fallback.rs:24:5 + | +LL | Wrapper::Second + | ^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the enum `Wrapper` + | + = note: cannot satisfy `_: Copy` +help: consider specifying the generic argument + | +LL | Wrapper::::Second + | +++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0283`. diff --git a/src/test/ui/type-alias-impl-trait/issue-53398-cyclic-types.rs b/src/test/ui/type-alias-impl-trait/issue-53398-cyclic-types.rs index 6c838f410036a..377ce85e8b221 100644 --- a/src/test/ui/type-alias-impl-trait/issue-53398-cyclic-types.rs +++ b/src/test/ui/type-alias-impl-trait/issue-53398-cyclic-types.rs @@ -3,7 +3,8 @@ type Foo = impl Fn() -> Foo; fn foo() -> Foo { - foo //~ ERROR: overflow evaluating the requirement `fn() -> Foo {foo}: Sized` +//~^ ERROR: overflow evaluating the requirement `fn() -> Foo {foo}: Sized` + foo } fn main() {} diff --git a/src/test/ui/type-alias-impl-trait/issue-53398-cyclic-types.stderr b/src/test/ui/type-alias-impl-trait/issue-53398-cyclic-types.stderr index a9c2c18630c01..d20b1cc6d851b 100644 --- a/src/test/ui/type-alias-impl-trait/issue-53398-cyclic-types.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-53398-cyclic-types.stderr @@ -1,8 +1,8 @@ error[E0275]: overflow evaluating the requirement `fn() -> Foo {foo}: Sized` - --> $DIR/issue-53398-cyclic-types.rs:6:5 + --> $DIR/issue-53398-cyclic-types.rs:5:13 | -LL | foo - | ^^^ +LL | fn foo() -> Foo { + | ^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_53398_cyclic_types`) diff --git a/src/test/ui/type-alias-impl-trait/issue-60371.stderr b/src/test/ui/type-alias-impl-trait/issue-60371.stderr index d0c04371bd793..082b0f0c30973 100644 --- a/src/test/ui/type-alias-impl-trait/issue-60371.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-60371.stderr @@ -11,7 +11,7 @@ error[E0277]: the trait bound `(): Bug` is not satisfied --> $DIR/issue-60371.rs:10:40 | LL | const FUN: fn() -> Self::Item = || (); - | ^^ the trait `Bug` is not implemented for `()` + | ^ the trait `Bug` is not implemented for `()` | = help: the trait `Bug` is implemented for `&()` diff --git a/src/test/ui/type-alias-impl-trait/issue-63279.rs b/src/test/ui/type-alias-impl-trait/issue-63279.rs index 057a908bbee74..97332e16d84a2 100644 --- a/src/test/ui/type-alias-impl-trait/issue-63279.rs +++ b/src/test/ui/type-alias-impl-trait/issue-63279.rs @@ -5,6 +5,7 @@ type Closure = impl FnOnce(); fn c() -> Closure { + //~^ ERROR: expected a `FnOnce<()>` closure, found `()` || -> Closure { || () } //~^ ERROR: mismatched types //~| ERROR: mismatched types diff --git a/src/test/ui/type-alias-impl-trait/issue-63279.stderr b/src/test/ui/type-alias-impl-trait/issue-63279.stderr index ab39ee74be442..57fc660901cd8 100644 --- a/src/test/ui/type-alias-impl-trait/issue-63279.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-63279.stderr @@ -1,5 +1,14 @@ error[E0277]: expected a `FnOnce<()>` closure, found `()` - --> $DIR/issue-63279.rs:8:11 + --> $DIR/issue-63279.rs:7:11 + | +LL | fn c() -> Closure { + | ^^^^^^^ expected an `FnOnce<()>` closure, found `()` + | + = help: the trait `FnOnce<()>` is not implemented for `()` + = note: wrap the `()` in a closure with no arguments: `|| { /* code */ }` + +error[E0277]: expected a `FnOnce<()>` closure, found `()` + --> $DIR/issue-63279.rs:9:11 | LL | || -> Closure { || () } | ^^^^^^^ expected an `FnOnce<()>` closure, found `()` @@ -8,33 +17,32 @@ LL | || -> Closure { || () } = note: wrap the `()` in a closure with no arguments: `|| { /* code */ }` error[E0308]: mismatched types - --> $DIR/issue-63279.rs:8:21 + --> $DIR/issue-63279.rs:9:21 | LL | || -> Closure { || () } | ^^^^^ expected `()`, found closure | = note: expected unit type `()` - found closure `[closure@$DIR/issue-63279.rs:8:21: 8:26]` + found closure `[closure@$DIR/issue-63279.rs:9:21: 9:26]` help: use parentheses to call this closure | LL | || -> Closure { (|| ())() } | + +++ error[E0308]: mismatched types - --> $DIR/issue-63279.rs:8:5 + --> $DIR/issue-63279.rs:9:5 | -LL | type Closure = impl FnOnce(); - | ------------- the expected opaque type -LL | -LL | fn c() -> Closure { - | ------- expected `Closure` because of return type LL | || -> Closure { || () } | ^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found closure | - = note: expected opaque type `Closure` - found closure `[closure@$DIR/issue-63279.rs:8:5: 8:28]` + = note: expected unit type `()` + found closure `[closure@$DIR/issue-63279.rs:9:5: 9:28]` +help: use parentheses to call this closure + | +LL | (|| -> Closure { || () })() + | + +++ -error: aborting due to 3 previous errors +error: aborting due to 4 previous errors Some errors have detailed explanations: E0277, E0308. For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/type-alias-impl-trait/issue-74280.stderr b/src/test/ui/type-alias-impl-trait/issue-74280.stderr index 573e691b4cc07..5ed29e0ac94ff 100644 --- a/src/test/ui/type-alias-impl-trait/issue-74280.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-74280.stderr @@ -1,17 +1,11 @@ error[E0308]: mismatched types --> $DIR/issue-74280.rs:9:5 | -LL | type Test = impl Copy; - | --------- the expected opaque type -LL | LL | fn test() -> Test { - | ---- expected `Test` because of return type + | ---- expected `_` because of return type LL | let y = || -> Test { () }; LL | 7 | ^ expected `()`, found integer - | - = note: expected opaque type `Test` - found type `{integer}` error: aborting due to previous error diff --git a/src/test/ui/type-alias-impl-trait/issue-94429.rs b/src/test/ui/type-alias-impl-trait/issue-94429.rs index 51d69c1271e02..2c965b875a00b 100644 --- a/src/test/ui/type-alias-impl-trait/issue-94429.rs +++ b/src/test/ui/type-alias-impl-trait/issue-94429.rs @@ -13,7 +13,8 @@ impl Runnable for Implementor { type Gen = impl Generator; fn run(&mut self) -> Self::Gen { - move || { //~ ERROR: type mismatch resolving + //~^ ERROR: type mismatch resolving + move || { yield 1; } } diff --git a/src/test/ui/type-alias-impl-trait/issue-94429.stderr b/src/test/ui/type-alias-impl-trait/issue-94429.stderr index 4546f82b83b85..57550104087f7 100644 --- a/src/test/ui/type-alias-impl-trait/issue-94429.stderr +++ b/src/test/ui/type-alias-impl-trait/issue-94429.stderr @@ -1,10 +1,8 @@ -error[E0271]: type mismatch resolving `<[generator@$DIR/issue-94429.rs:16:9: 18:10] as Generator>::Yield == ()` - --> $DIR/issue-94429.rs:16:9 +error[E0271]: type mismatch resolving `<[generator@$DIR/issue-94429.rs:17:9: 19:10] as Generator>::Yield == ()` + --> $DIR/issue-94429.rs:15:26 | -LL | / move || { -LL | | yield 1; -LL | | } - | |_________^ expected integer, found `()` +LL | fn run(&mut self) -> Self::Gen { + | ^^^^^^^^^ expected integer, found `()` error: aborting due to previous error diff --git a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.rs b/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.rs index 46bac5a34f5c0..da845e86147b7 100644 --- a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.rs +++ b/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.rs @@ -7,8 +7,8 @@ type X = impl Into<&'static A>; fn f(a: &'static A, b: B) -> (X, X) { - (a, a) //~^ ERROR the trait bound `&'static B: From<&A>` is not satisfied + (a, a) } fn main() { diff --git a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.stderr b/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.stderr index 198f3e26393d4..cdaae99e28621 100644 --- a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.stderr +++ b/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `&'static B: From<&A>` is not satisfied - --> $DIR/multiple-def-uses-in-one-fn.rs:10:9 + --> $DIR/multiple-def-uses-in-one-fn.rs:9:45 | -LL | (a, a) - | ^ the trait `From<&A>` is not implemented for `&'static B` +LL | fn f(a: &'static A, b: B) -> (X, X) { + | ^^^^^^^^^^^^^^^^^^ the trait `From<&A>` is not implemented for `&'static B` | = note: required because of the requirements on the impl of `Into<&'static B>` for `&A` help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement diff --git a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn3.stderr b/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn3.stderr index db4b60461ef38..bbe709dccab4e 100644 --- a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn3.stderr +++ b/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn3.stderr @@ -1,9 +1,6 @@ error[E0308]: mismatched types --> $DIR/multiple-def-uses-in-one-fn3.rs:14:9 | -LL | type X = impl ToString; - | ------------- the expected opaque type -... LL | fn g(a: A, b: B) -> (X, X) { | - - found type parameter | | @@ -11,8 +8,8 @@ LL | fn g(a: A, b: B) -> (X, X` - found type parameter `B` + = note: expected type parameter `A` + found type parameter `B` = note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters diff --git a/src/test/ui/type-alias-impl-trait/self-referential-2.rs b/src/test/ui/type-alias-impl-trait/self-referential-2.rs index dc7054da5ec19..8781196c39fa1 100644 --- a/src/test/ui/type-alias-impl-trait/self-referential-2.rs +++ b/src/test/ui/type-alias-impl-trait/self-referential-2.rs @@ -4,7 +4,7 @@ type Foo = impl std::fmt::Debug; type Bar = impl PartialEq; fn bar() -> Bar { - 42_i32 //~ ERROR can't compare `i32` with `Foo` + 42_i32 //~^ ERROR can't compare `i32` with `Foo` } fn main() {} diff --git a/src/test/ui/type-alias-impl-trait/self-referential-2.stderr b/src/test/ui/type-alias-impl-trait/self-referential-2.stderr index 348696f25e3b5..2b505d30730a3 100644 --- a/src/test/ui/type-alias-impl-trait/self-referential-2.stderr +++ b/src/test/ui/type-alias-impl-trait/self-referential-2.stderr @@ -1,8 +1,10 @@ error[E0277]: can't compare `i32` with `Foo` - --> $DIR/self-referential-2.rs:7:5 + --> $DIR/self-referential-2.rs:6:13 | +LL | fn bar() -> Bar { + | ^^^ no implementation for `i32 == Foo` LL | 42_i32 - | ^^^^^^ no implementation for `i32 == Foo` + | ------ return type was inferred to be `i32` here | = help: the trait `PartialEq` is not implemented for `i32` = help: the following other types implement trait `PartialEq`: diff --git a/src/test/ui/type-alias-impl-trait/self-referential-4.rs b/src/test/ui/type-alias-impl-trait/self-referential-4.rs index 697ec56825a9c..36742c8ad57fc 100644 --- a/src/test/ui/type-alias-impl-trait/self-referential-4.rs +++ b/src/test/ui/type-alias-impl-trait/self-referential-4.rs @@ -3,19 +3,19 @@ type Bar<'a, 'b> = impl PartialEq> + std::fmt::Debug; fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> { - i //~ ERROR can't compare `&i32` with `Bar<'b, 'static>` + i //~^ ERROR can't compare `&i32` with `Bar<'b, 'static>` } type Foo<'a, 'b> = impl PartialEq> + std::fmt::Debug; fn foo<'a, 'b>(i: &'a i32) -> Foo<'a, 'b> { - i //~ ERROR can't compare `&i32` with `Foo<'static, 'b>` + i //~^ ERROR can't compare `&i32` with `Foo<'static, 'b>` } type Moo<'a, 'b> = impl PartialEq> + std::fmt::Debug; fn moo<'a, 'b>(i: &'a i32) -> Moo<'a, 'b> { - i //~ ERROR can't compare `&i32` with `Moo<'static, 'a>` + i //~^ ERROR can't compare `&i32` with `Moo<'static, 'a>` } fn main() { diff --git a/src/test/ui/type-alias-impl-trait/self-referential-4.stderr b/src/test/ui/type-alias-impl-trait/self-referential-4.stderr index 838264794194c..27880f792f462 100644 --- a/src/test/ui/type-alias-impl-trait/self-referential-4.stderr +++ b/src/test/ui/type-alias-impl-trait/self-referential-4.stderr @@ -1,8 +1,10 @@ error[E0277]: can't compare `&i32` with `Bar<'b, 'static>` - --> $DIR/self-referential-4.rs:6:5 + --> $DIR/self-referential-4.rs:5:31 | +LL | fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> { + | ^^^^^^^^^^^ no implementation for `&i32 == Bar<'b, 'static>` LL | i - | ^ no implementation for `&i32 == Bar<'b, 'static>` + | - return type was inferred to be `&i32` here | = help: the trait `PartialEq>` is not implemented for `&i32` = help: the following other types implement trait `PartialEq`: @@ -17,10 +19,12 @@ LL | i and 6 others error[E0277]: can't compare `&i32` with `Foo<'static, 'b>` - --> $DIR/self-referential-4.rs:12:5 + --> $DIR/self-referential-4.rs:11:31 | +LL | fn foo<'a, 'b>(i: &'a i32) -> Foo<'a, 'b> { + | ^^^^^^^^^^^ no implementation for `&i32 == Foo<'static, 'b>` LL | i - | ^ no implementation for `&i32 == Foo<'static, 'b>` + | - return type was inferred to be `&i32` here | = help: the trait `PartialEq>` is not implemented for `&i32` = help: the following other types implement trait `PartialEq`: @@ -35,10 +39,12 @@ LL | i and 6 others error[E0277]: can't compare `&i32` with `Moo<'static, 'a>` - --> $DIR/self-referential-4.rs:18:5 + --> $DIR/self-referential-4.rs:17:31 | +LL | fn moo<'a, 'b>(i: &'a i32) -> Moo<'a, 'b> { + | ^^^^^^^^^^^ no implementation for `&i32 == Moo<'static, 'a>` LL | i - | ^ no implementation for `&i32 == Moo<'static, 'a>` + | - return type was inferred to be `&i32` here | = help: the trait `PartialEq>` is not implemented for `&i32` = help: the following other types implement trait `PartialEq`: diff --git a/src/test/ui/type-alias-impl-trait/self-referential.rs b/src/test/ui/type-alias-impl-trait/self-referential.rs index 4974ac72dad18..3ff5406a38270 100644 --- a/src/test/ui/type-alias-impl-trait/self-referential.rs +++ b/src/test/ui/type-alias-impl-trait/self-referential.rs @@ -3,19 +3,22 @@ type Bar<'a, 'b> = impl PartialEq> + std::fmt::Debug; fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> { - i //~ ERROR can't compare `&i32` with `Bar<'b, 'a>` + //~^ ERROR can't compare `&i32` with `Bar<'b, 'a>` + i } type Foo<'a, 'b> = (i32, impl PartialEq> + std::fmt::Debug); fn foo<'a, 'b>(i: &'a i32) -> Foo<'a, 'b> { - (42, i) //~ ERROR can't compare `&i32` with `(i32, &i32)` + //~^ ERROR can't compare `&i32` with `(i32, &i32)` + (42, i) } type Moo<'a, 'b> = (i32, impl PartialEq> + std::fmt::Debug); fn moo<'a, 'b>(i: &'a i32) -> Moo<'a, 'b> { - (42, i) //~ ERROR can't compare `&i32` with `(i32, Moo<'b, 'a>::{opaque#0})` + //~^ ERROR can't compare `&i32` with `(i32, Moo<'b, 'a>::{opaque#0})` + (42, i) } fn main() { diff --git a/src/test/ui/type-alias-impl-trait/self-referential.stderr b/src/test/ui/type-alias-impl-trait/self-referential.stderr index 2ebb15b880308..97d510f6830af 100644 --- a/src/test/ui/type-alias-impl-trait/self-referential.stderr +++ b/src/test/ui/type-alias-impl-trait/self-referential.stderr @@ -1,8 +1,11 @@ error[E0277]: can't compare `&i32` with `Bar<'b, 'a>` - --> $DIR/self-referential.rs:6:5 + --> $DIR/self-referential.rs:5:31 | +LL | fn bar<'a, 'b>(i: &'a i32) -> Bar<'a, 'b> { + | ^^^^^^^^^^^ no implementation for `&i32 == Bar<'b, 'a>` +LL | LL | i - | ^ no implementation for `&i32 == Bar<'b, 'a>` + | - return type was inferred to be `&i32` here | = help: the trait `PartialEq>` is not implemented for `&i32` = help: the following other types implement trait `PartialEq`: @@ -17,10 +20,13 @@ LL | i and 6 others error[E0277]: can't compare `&i32` with `(i32, &i32)` - --> $DIR/self-referential.rs:12:10 + --> $DIR/self-referential.rs:12:31 | +LL | fn foo<'a, 'b>(i: &'a i32) -> Foo<'a, 'b> { + | ^^^^^^^^^^^ no implementation for `&i32 == (i32, &i32)` +LL | LL | (42, i) - | ^ no implementation for `&i32 == (i32, &i32)` + | ------- return type was inferred to be `(i32, &i32)` here | = help: the trait `PartialEq<(i32, &i32)>` is not implemented for `&i32` = help: the following other types implement trait `PartialEq`: @@ -35,10 +41,13 @@ LL | (42, i) and 6 others error[E0277]: can't compare `&i32` with `(i32, Moo<'b, 'a>::{opaque#0})` - --> $DIR/self-referential.rs:18:10 + --> $DIR/self-referential.rs:19:31 | +LL | fn moo<'a, 'b>(i: &'a i32) -> Moo<'a, 'b> { + | ^^^^^^^^^^^ no implementation for `&i32 == (i32, Moo<'b, 'a>::{opaque#0})` +LL | LL | (42, i) - | ^ no implementation for `&i32 == (i32, Moo<'b, 'a>::{opaque#0})` + | ------- return type was inferred to be `(i32, &i32)` here | = help: the trait `PartialEq<(i32, Moo<'b, 'a>::{opaque#0})>` is not implemented for `&i32` = help: the following other types implement trait `PartialEq`: From 77e88a7c7afce2389b16b385f494be2f836c43ff Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 29 Jun 2022 08:27:14 +0000 Subject: [PATCH 3/9] Add more tests --- .../ui/lazy-type-alias-impl-trait/branches.rs | 14 ++++++++++++-- .../lazy-type-alias-impl-trait/branches.stderr | 16 ++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 src/test/ui/lazy-type-alias-impl-trait/branches.stderr diff --git a/src/test/ui/lazy-type-alias-impl-trait/branches.rs b/src/test/ui/lazy-type-alias-impl-trait/branches.rs index e7db10bd7cd2d..95239e2e341c8 100644 --- a/src/test/ui/lazy-type-alias-impl-trait/branches.rs +++ b/src/test/ui/lazy-type-alias-impl-trait/branches.rs @@ -1,7 +1,5 @@ #![feature(type_alias_impl_trait)] -// check-pass - type Foo = impl std::fmt::Debug; fn foo(b: bool) -> Foo { @@ -12,4 +10,16 @@ fn foo(b: bool) -> Foo { } } +type Bar = impl std::fmt::Debug; + +fn bar(b: bool) -> Bar { + let x: Bar = if b { + vec![42_i32] + } else { + std::iter::empty().collect() + //~^ ERROR a value of type `Bar` cannot be built from an iterator over elements of type `_` + }; + x +} + fn main() {} diff --git a/src/test/ui/lazy-type-alias-impl-trait/branches.stderr b/src/test/ui/lazy-type-alias-impl-trait/branches.stderr new file mode 100644 index 0000000000000..6b87da0c040d5 --- /dev/null +++ b/src/test/ui/lazy-type-alias-impl-trait/branches.stderr @@ -0,0 +1,16 @@ +error[E0277]: a value of type `Bar` cannot be built from an iterator over elements of type `_` + --> $DIR/branches.rs:19:28 + | +LL | std::iter::empty().collect() + | ^^^^^^^ value of type `Bar` cannot be built from `std::iter::Iterator` + | + = help: the trait `FromIterator<_>` is not implemented for `Bar` +note: required by a bound in `collect` + --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL + | +LL | fn collect>(self) -> B + | ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `collect` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. From c33b127d7c25977817faaae5eee84d57cde37c68 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 29 Jun 2022 08:52:19 +0000 Subject: [PATCH 4/9] The only reason we had to replace opaque types in closures was due to async fn desugaring, make that explicit --- .../rustc_infer/src/infer/opaque_types.rs | 26 +------ compiler/rustc_typeck/src/check/check.rs | 3 - compiler/rustc_typeck/src/check/closure.rs | 73 ++++++++----------- 3 files changed, 35 insertions(+), 67 deletions(-) diff --git a/compiler/rustc_infer/src/infer/opaque_types.rs b/compiler/rustc_infer/src/infer/opaque_types.rs index 7d7fa9f294194..cc36d6a0a4fbe 100644 --- a/compiler/rustc_infer/src/infer/opaque_types.rs +++ b/compiler/rustc_infer/src/infer/opaque_types.rs @@ -5,7 +5,7 @@ use hir::{HirId, OpaqueTyOrigin}; use rustc_data_structures::sync::Lrc; use rustc_data_structures::vec_map::VecMap; use rustc_hir as hir; -use rustc_middle::traits::{ObligationCause, ObligationCauseCode}; +use rustc_middle::traits::ObligationCause; use rustc_middle::ty::fold::BottomUpFolder; use rustc_middle::ty::subst::{GenericArgKind, Subst}; use rustc_middle::ty::{ @@ -38,38 +38,19 @@ pub struct OpaqueTypeDecl<'tcx> { pub origin: hir::OpaqueTyOrigin, } -pub enum ReplaceOpaqueTypes { - /// Closures can't create hidden types for opaque types of their parent, as they - /// do not have all the outlives information available. Also `type_of` looks for - /// hidden types in the owner (so the closure's parent), so it would not find these - /// definitions. - OnlyForRPIT, - All, -} - impl<'a, 'tcx> InferCtxt<'a, 'tcx> { pub fn replace_opaque_types_with_inference_vars( &self, ty: Ty<'tcx>, body_id: HirId, span: Span, - code: ObligationCauseCode<'tcx>, param_env: ty::ParamEnv<'tcx>, - replace: ReplaceOpaqueTypes, ) -> InferOk<'tcx, Ty<'tcx>> { if !ty.has_opaque_types() { return InferOk { value: ty, obligations: vec![] }; } let mut obligations = vec![]; - let replace_opaque_type = |def_id| match self.opaque_type_origin(def_id, span) { - None => false, - Some(OpaqueTyOrigin::FnReturn(..)) => true, - // Not using `==` or `matches!` here to make sure we exhaustively match variants. - Some(_) => match replace { - ReplaceOpaqueTypes::OnlyForRPIT => false, - ReplaceOpaqueTypes::All => true, - }, - }; + let replace_opaque_type = |def_id| self.opaque_type_origin(def_id, span).is_some(); let value = ty.fold_with(&mut ty::fold::BottomUpFolder { tcx: self.tcx, lt_op: |lt| lt, @@ -78,7 +59,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { ty::Opaque(def_id, _substs) if replace_opaque_type(def_id) => { let def_span = self.tcx.def_span(def_id); let span = if span.contains(def_span) { def_span } else { span }; - let cause = ObligationCause::new(span, body_id, code.clone()); + let code = traits::ObligationCauseCode::OpaqueReturnType(None); + let cause = ObligationCause::new(span, body_id, code); // FIXME(compiler-errors): We probably should add a new TypeVariableOriginKind // for opaque types, and then use that kind to fix the spans for type errors // that we see later on. diff --git a/compiler/rustc_typeck/src/check/check.rs b/compiler/rustc_typeck/src/check/check.rs index 184bc4188c5c8..1cd66d1426dbe 100644 --- a/compiler/rustc_typeck/src/check/check.rs +++ b/compiler/rustc_typeck/src/check/check.rs @@ -13,7 +13,6 @@ use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::intravisit::Visitor; use rustc_hir::lang_items::LangItem; use rustc_hir::{ItemKind, Node, PathSegment}; -use rustc_infer::infer::opaque_types::ReplaceOpaqueTypes; use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; use rustc_infer::infer::{RegionVariableOrigin, TyCtxtInferExt}; use rustc_infer::traits::Obligation; @@ -97,9 +96,7 @@ pub(super) fn check_fn<'a, 'tcx>( declared_ret_ty, body.value.hir_id, decl.output.span(), - traits::ObligationCauseCode::OpaqueReturnType(None), param_env, - ReplaceOpaqueTypes::All, )); // If we replaced declared_ret_ty with infer vars, then we must be infering // an opaque type, so set a flag so we can improve diagnostics. diff --git a/compiler/rustc_typeck/src/check/closure.rs b/compiler/rustc_typeck/src/check/closure.rs index 918a42cf02b1d..131e594ed94f7 100644 --- a/compiler/rustc_typeck/src/check/closure.rs +++ b/compiler/rustc_typeck/src/check/closure.rs @@ -7,16 +7,13 @@ use crate::rustc_middle::ty::subst::Subst; use rustc_hir as hir; use rustc_hir::def_id::DefId; use rustc_hir::lang_items::LangItem; -use rustc_infer::infer::opaque_types::ReplaceOpaqueTypes; use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; use rustc_infer::infer::LateBoundRegionConversionTime; use rustc_infer::infer::{InferOk, InferResult}; -use rustc_infer::traits::ObligationCauseCode; use rustc_middle::ty::fold::TypeFoldable; use rustc_middle::ty::subst::InternalSubsts; use rustc_middle::ty::{self, Ty}; use rustc_span::source_map::Span; -use rustc_span::DUMMY_SP; use rustc_target::spec::abi::Abi; use rustc_trait_selection::traits::error_reporting::ArgKind; use rustc_trait_selection::traits::error_reporting::InferCtxtExt as _; @@ -430,14 +427,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // in this binder we are creating. assert!(!expected_sig.sig.skip_binder().has_vars_bound_above(ty::INNERMOST)); let bound_sig = expected_sig.sig.map_bound(|sig| { - let output = self.hide_parent_opaque_types( - sig.output(), - expected_sig.cause_span.unwrap_or(DUMMY_SP), - body.id().hir_id, - ); self.tcx.mk_fn_sig( sig.inputs().iter().cloned(), - output, + sig.output(), sig.c_variadic, hir::Unsafety::Normal, Abi::RustCall, @@ -609,23 +601,22 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // function. Some(hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Fn)) => { debug!("closure is async fn body"); - self.deduce_future_output_from_obligations(expr_def_id).unwrap_or_else(|| { - // AFAIK, deducing the future output - // always succeeds *except* in error cases - // like #65159. I'd like to return Error - // here, but I can't because I can't - // easily (and locally) prove that we - // *have* reported an - // error. --nikomatsakis - astconv.ty_infer(None, decl.output.span()) - }) + self.deduce_future_output_from_obligations(expr_def_id, body.id().hir_id) + .unwrap_or_else(|| { + // AFAIK, deducing the future output + // always succeeds *except* in error cases + // like #65159. I'd like to return Error + // here, but I can't because I can't + // easily (and locally) prove that we + // *have* reported an + // error. --nikomatsakis + astconv.ty_infer(None, decl.output.span()) + }) } _ => astconv.ty_infer(None, decl.output.span()), }, }; - let supplied_return = - self.hide_parent_opaque_types(supplied_return, decl.output.span(), body.id().hir_id); let result = ty::Binder::bind_with_vars( self.tcx.mk_fn_sig( @@ -646,23 +637,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { result } - /// Closures can't create hidden types for opaque types of their parent, as they - /// do not have all the outlives information available. Also `type_of` looks for - /// hidden types in the owner (so the closure's parent), so it would not find these - /// definitions. - fn hide_parent_opaque_types(&self, ty: Ty<'tcx>, span: Span, body_id: hir::HirId) -> Ty<'tcx> { - let InferOk { value, obligations } = self.replace_opaque_types_with_inference_vars( - ty, - body_id, - span, - ObligationCauseCode::MiscObligation, - self.param_env, - ReplaceOpaqueTypes::OnlyForRPIT, - ); - self.register_predicates(obligations); - value - } - /// Invoked when we are translating the generator that results /// from desugaring an `async fn`. Returns the "sugared" return /// type of the `async fn` -- that is, the return type that the @@ -670,7 +644,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// Future`, so we do this by searching through the /// obligations to extract the `T`. #[instrument(skip(self), level = "debug")] - fn deduce_future_output_from_obligations(&self, expr_def_id: DefId) -> Option> { + fn deduce_future_output_from_obligations( + &self, + expr_def_id: DefId, + body_id: hir::HirId, + ) -> Option> { let ret_coercion = self.ret_coercion.as_ref().unwrap_or_else(|| { span_bug!(self.tcx.def_span(expr_def_id), "async fn generator outside of a fn") }); @@ -700,14 +678,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ty::Infer(ty::TyVar(ret_vid)) => { self.obligations_for_self_ty(ret_vid).find_map(|(_, obligation)| { get_future_output(obligation.predicate, obligation.cause.span) - }) + })? } ty::Opaque(def_id, substs) => self .tcx .bound_explicit_item_bounds(def_id) .transpose_iter() .map(|e| e.map_bound(|e| *e).transpose_tuple2()) - .find_map(|(p, s)| get_future_output(p.subst(self.tcx, substs), s.0)), + .find_map(|(p, s)| get_future_output(p.subst(self.tcx, substs), s.0))?, ty::Error(_) => return None, _ => span_bug!( self.tcx.def_span(expr_def_id), @@ -715,8 +693,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ), }; + // async fn that have opaque types in their return type need to redo the conversion to inference variables + // as they fetch the still opaque version from the signature. + let InferOk { value: output_ty, obligations } = self + .replace_opaque_types_with_inference_vars( + output_ty, + body_id, + self.tcx.def_span(expr_def_id), + self.param_env, + ); + self.register_predicates(obligations); + debug!("deduce_future_output_from_obligations: output_ty={:?}", output_ty); - output_ty + Some(output_ty) } /// Given a projection like From ba87c934ea86476bbd75909eb18cbf7627c12c81 Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Wed, 29 Jun 2022 20:34:56 +0200 Subject: [PATCH 5/9] rustdoc-json: Make default value of blanket impl assoc types work --- src/librustdoc/json/conversions.rs | 2 +- src/test/rustdoc-json/blanket_impls.rs | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 src/test/rustdoc-json/blanket_impls.rs diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index afc84cc0a97aa..316554808c201 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -255,7 +255,7 @@ fn from_clean_item(item: clean::Item, tcx: TyCtxt<'_>) -> ItemEnum { AssocTypeItem(t, b) => ItemEnum::AssocType { generics: t.generics.into_tcx(tcx), bounds: b.into_iter().map(|x| x.into_tcx(tcx)).collect(), - default: t.item_type.map(|ty| ty.into_tcx(tcx)), + default: Some(t.item_type.unwrap_or(t.type_).into_tcx(tcx)), }, // `convert_item` early returns `None` for striped items and keywords. StrippedItem(_) | KeywordItem(_) => unreachable!(), diff --git a/src/test/rustdoc-json/blanket_impls.rs b/src/test/rustdoc-json/blanket_impls.rs new file mode 100644 index 0000000000000..edf1a9fe2fcf9 --- /dev/null +++ b/src/test/rustdoc-json/blanket_impls.rs @@ -0,0 +1,9 @@ +// Regression test for + +#![no_std] + +// @has blanket_impls.json +// @has - "$.index[*][?(@.name=='Error')].kind" \"assoc_type\" +// @has - "$.index[*][?(@.name=='Error')].inner.default.kind" \"resolved_path\" +// @has - "$.index[*][?(@.name=='Error')].inner.default.inner.name" \"Infallible\" +pub struct ForBlanketTryFromImpl; From 726d6136e3b39fd2456c26fc8c3894dd45a10272 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Wed, 29 Jun 2022 21:30:19 +0200 Subject: [PATCH 6/9] add tests for ICE 94432 Fixes #94432 --- src/test/ui/generics/issue-94432-garbage-ice.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/test/ui/generics/issue-94432-garbage-ice.rs diff --git a/src/test/ui/generics/issue-94432-garbage-ice.rs b/src/test/ui/generics/issue-94432-garbage-ice.rs new file mode 100644 index 0000000000000..d0709e2d2a46c --- /dev/null +++ b/src/test/ui/generics/issue-94432-garbage-ice.rs @@ -0,0 +1,10 @@ +// check-fail +// dont-check-compiler-stdout +// dont-check-compiler-stderr + +fn�a(){fn�p(){e}} //~ ERROR unknown start of token: \u{fffd} +//~^ ERROR unknown start of token: \u{fffd} +//~^^ ERROR can't use generic parameters from outer function [E0401] +//~^^^ WARN type parameter `e` should have an upper camel case name + +fn main(){} From 5f75e7104a811c8cf4cc0f540d5c11abcdad7710 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Wed, 29 Jun 2022 21:38:42 +0200 Subject: [PATCH 7/9] add test for ice 68875 Fixes #68875 --- src/test/ui/const-generics/ice-68875.rs | 11 +++++++++++ src/test/ui/const-generics/ice-68875.stderr | 8 ++++++++ 2 files changed, 19 insertions(+) create mode 100644 src/test/ui/const-generics/ice-68875.rs create mode 100644 src/test/ui/const-generics/ice-68875.stderr diff --git a/src/test/ui/const-generics/ice-68875.rs b/src/test/ui/const-generics/ice-68875.rs new file mode 100644 index 0000000000000..2ef7cfdbe2735 --- /dev/null +++ b/src/test/ui/const-generics/ice-68875.rs @@ -0,0 +1,11 @@ +// check-fail + +struct DataWrapper<'a> { + data: &'a [u8; Self::SIZE], //~ ERROR generic `Self` types are currently not permitted in anonymous constants +} + +impl DataWrapper<'_> { + const SIZE: usize = 14; +} + +pub fn main() {} diff --git a/src/test/ui/const-generics/ice-68875.stderr b/src/test/ui/const-generics/ice-68875.stderr new file mode 100644 index 0000000000000..1db62c57fd438 --- /dev/null +++ b/src/test/ui/const-generics/ice-68875.stderr @@ -0,0 +1,8 @@ +error: generic `Self` types are currently not permitted in anonymous constants + --> $DIR/ice-68875.rs:4:20 + | +LL | data: &'a [u8; Self::SIZE], + | ^^^^ + +error: aborting due to previous error + From be0b1121e9ede0cc3b322aba8d8a2a9bb48572f6 Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Wed, 29 Jun 2022 13:04:43 -0700 Subject: [PATCH 8/9] Replace `sort_modules_alphabetically` boolean with enum This fixes the long-standing FIXME there and makes the code easier to understand. The reference to modules in both the old and new names seems potentially wrong since I believe it applies to all items. --- src/librustdoc/config.rs | 23 +++++++++++++++-------- src/librustdoc/html/render/context.rs | 17 ++++++++++------- src/librustdoc/html/render/print_item.rs | 8 ++++++-- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index 6e3651665c8c4..50d154dd278a1 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -218,12 +218,9 @@ pub(crate) struct RenderOptions { /// /// Be aware: This option can come both from the CLI and from crate attributes! pub(crate) playground_url: Option, - /// Whether to sort modules alphabetically on a module page instead of using declaration order. - /// `true` by default. - // - // FIXME(misdreavus): the flag name is `--sort-modules-by-appearance` but the meaning is - // inverted once read. - pub(crate) sort_modules_alphabetically: bool, + /// What sorting mode to use for module pages. + /// `ModuleSorting::Alphabetical` by default. + pub(crate) module_sorting: ModuleSorting, /// List of themes to extend the docs with. Original argument name is included to assist in /// displaying errors if it fails a theme check. pub(crate) themes: Vec, @@ -281,6 +278,12 @@ pub(crate) struct RenderOptions { pub(crate) no_emit_shared: bool, } +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub(crate) enum ModuleSorting { + DeclarationOrder, + Alphabetical, +} + #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub(crate) enum EmitType { Unversioned, @@ -650,7 +653,11 @@ impl Options { let proc_macro_crate = crate_types.contains(&CrateType::ProcMacro); let playground_url = matches.opt_str("playground-url"); let maybe_sysroot = matches.opt_str("sysroot").map(PathBuf::from); - let sort_modules_alphabetically = !matches.opt_present("sort-modules-by-appearance"); + let module_sorting = if matches.opt_present("sort-modules-by-appearance") { + ModuleSorting::DeclarationOrder + } else { + ModuleSorting::Alphabetical + }; let resource_suffix = matches.opt_str("resource-suffix").unwrap_or_default(); let enable_minification = !matches.opt_present("disable-minification"); let markdown_no_toc = matches.opt_present("markdown-no-toc"); @@ -731,7 +738,7 @@ impl Options { external_html, id_map, playground_url, - sort_modules_alphabetically, + module_sorting, themes, extension_css, extern_html_root_urls, diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs index bfdc44c7e4534..2ed7a6f1bb144 100644 --- a/src/librustdoc/html/render/context.rs +++ b/src/librustdoc/html/render/context.rs @@ -22,7 +22,7 @@ use super::{ }; use crate::clean::{self, types::ExternalLocation, ExternalCrate}; -use crate::config::RenderOptions; +use crate::config::{ModuleSorting, RenderOptions}; use crate::docfs::{DocFS, PathError}; use crate::error::Error; use crate::formats::cache::Cache; @@ -95,7 +95,7 @@ pub(crate) struct SharedContext<'tcx> { created_dirs: RefCell>, /// This flag indicates whether listings of modules (in the side bar and documentation itself) /// should be ordered alphabetically or in order of appearance (in the source code). - pub(super) sort_modules_alphabetically: bool, + pub(super) module_sorting: ModuleSorting, /// Additional CSS files to be added to the generated docs. pub(crate) style_files: Vec, /// Suffix to be added on resource files (if suffix is "-v2" then "light.css" becomes @@ -280,10 +280,13 @@ impl<'tcx> Context<'tcx> { } } - if self.shared.sort_modules_alphabetically { - for items in map.values_mut() { - items.sort(); + match self.shared.module_sorting { + ModuleSorting::Alphabetical => { + for items in map.values_mut() { + items.sort(); + } } + ModuleSorting::DeclarationOrder => {} } map } @@ -394,7 +397,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> { external_html, id_map, playground_url, - sort_modules_alphabetically, + module_sorting, themes: style_files, default_settings, extension_css, @@ -476,7 +479,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> { issue_tracker_base_url, layout, created_dirs: Default::default(), - sort_modules_alphabetically, + module_sorting, style_files, resource_suffix, static_root_path, diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index d115185562ce4..0fe99463f1d6e 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -23,6 +23,7 @@ use super::{ AssocItemLink, Context, ImplRenderingParameters, }; use crate::clean; +use crate::config::ModuleSorting; use crate::formats::item_type::ItemType; use crate::formats::{AssocItemRender, Impl, RenderMode}; use crate::html::escape::Escape; @@ -246,8 +247,11 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items: compare_names(lhs.as_str(), rhs.as_str()) } - if cx.shared.sort_modules_alphabetically { - indices.sort_by(|&i1, &i2| cmp(&items[i1], &items[i2], i1, i2, cx.tcx())); + match cx.shared.module_sorting { + ModuleSorting::Alphabetical => { + indices.sort_by(|&i1, &i2| cmp(&items[i1], &items[i2], i1, i2, cx.tcx())); + } + ModuleSorting::DeclarationOrder => {} } // This call is to remove re-export duplicates in cases such as: // From c9f2865472e28a5233e9fb9dc42d41b4ece27219 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Wed, 29 Jun 2022 22:27:18 +0200 Subject: [PATCH 9/9] add test for 47814 not sure if the issue should actually get closed though, hm r? @compiler-errors --- src/test/ui/associated-types/issue-47814.rs | 13 +++++++++++++ src/test/ui/associated-types/issue-47814.stderr | 14 ++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 src/test/ui/associated-types/issue-47814.rs create mode 100644 src/test/ui/associated-types/issue-47814.stderr diff --git a/src/test/ui/associated-types/issue-47814.rs b/src/test/ui/associated-types/issue-47814.rs new file mode 100644 index 0000000000000..90e8a3bc2f2f4 --- /dev/null +++ b/src/test/ui/associated-types/issue-47814.rs @@ -0,0 +1,13 @@ +struct ArpIPv4<'a> { + s: &'a u8 +} + +impl<'a> ArpIPv4<'a> { + const LENGTH: usize = 20; + + pub fn to_buffer() -> [u8; Self::LENGTH] { //~ ERROR generic `Self` types are currently not permitted in anonymous constants + unimplemented!() + } +} + +pub fn main() {} diff --git a/src/test/ui/associated-types/issue-47814.stderr b/src/test/ui/associated-types/issue-47814.stderr new file mode 100644 index 0000000000000..2e4ddb81166b4 --- /dev/null +++ b/src/test/ui/associated-types/issue-47814.stderr @@ -0,0 +1,14 @@ +error: generic `Self` types are currently not permitted in anonymous constants + --> $DIR/issue-47814.rs:8:32 + | +LL | pub fn to_buffer() -> [u8; Self::LENGTH] { + | ^^^^ + | +note: not a concrete type + --> $DIR/issue-47814.rs:5:10 + | +LL | impl<'a> ArpIPv4<'a> { + | ^^^^^^^^^^^ + +error: aborting due to previous error +