From 37e12e1d247cbd55fa823b6c299a5f2a5030a1a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Thu, 9 Jul 2026 03:19:01 +0000 Subject: [PATCH 01/14] Show sub-parts of types when only interesting part is lifetimes We have a mechanims (`Highlight`) to change the name of inferred lifetimes in types so that we can refer to them by a number. Modify it so that it also avoids printing sub-parts of the type that are irrelevant to the situation at hand. The new behavior will print any sub part that has *any* lifetime (as they might be informative) instead of *just* the lifetimes being replaced. This was found to produce the best effect empirically in the test suite, striking a nice balance between shortening labels and being informative. ``` error: lifetime may not live long enough --> $DIR/wrong-closure-arg-suggestion-125325.rs:46:18 | LL | take(|_| to_fn(|_| self.counter += 1)); | --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'1` must outlive `'2` | | | | | return type of closure `aux::Map<{closure@...}>` contains a lifetime `'2` | lifetime `'1` represents this closure's body | = note: closure implements `Fn`, so references to captured variables can't escape the closure ``` ``` error: implementation of `FnOnce` is not general enough --> $DIR/higher-ranked-auto-trait-15.rs:20:5 | LL | require_send(future); | ^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | = note: closure with signature `fn(&'0 ...) -> std::slice::Iter<'_, i32>` must implement `FnOnce<(&'1 Vec,)>`, for any two lifetimes `'0` and `'1`... = note: ...but it actually implements `FnOnce<(&Vec,)>` ``` Made this change after noticing that the first of the errors above had a corresponding `.stderr` file with lines longer than 150 columns. --- compiler/rustc_middle/src/ty/print/pretty.rs | 27 ++++++++++++++++--- .../nice_region_error/placeholder_error.rs | 21 ++++++++++++--- ...ranked-auto-trait-15.no_assumptions.stderr | 4 +-- ...ted-closure-outlives-borrowed-value.stderr | 2 +- ...5079-missing-move-in-nested-closure.stderr | 2 +- ...n-with-leaking-placeholders.current.stderr | 2 +- ...wrong-closure-arg-suggestion-125325.stderr | 4 +-- .../higher-ranked-lifetime-error.stderr | 2 +- .../self-without-lifetime-constraint.stderr | 8 +++--- 9 files changed, 54 insertions(+), 18 deletions(-) diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 69def782bb67b..830eacc26da9f 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -190,6 +190,10 @@ pub struct RegionHighlightMode<'tcx> { /// instead of the ordinary behavior. highlight_regions: [Option<(ty::Region<'tcx>, usize)>; 3], + /// If set to `true`, types that include regions will always be included in the output, while + /// other types will be free to be trimmed. + pub keep_regions: bool, + /// If enabled, when printing a "free region" that originated from /// the given `ty::BoundRegionKind`, print it as "`'1`". Free regions that would ordinarily /// have names print as normal. @@ -208,6 +212,7 @@ impl<'tcx> RegionHighlightMode<'tcx> { region: Option>, number: Option, ) { + self.keep_regions = true; if let Some(k) = region && let Some(n) = number { @@ -223,6 +228,7 @@ impl<'tcx> RegionHighlightMode<'tcx> { bug!("can only highlight {} placeholders at a time", num_slots,) }); *first_avail_slot = Some((region, number)); + self.keep_regions = true; } /// Convenience wrapper for `highlighting_region`. @@ -2330,12 +2336,27 @@ impl<'tcx> Printer<'tcx> for FmtPrinter<'_, 'tcx> { } fn print_type(&mut self, ty: Ty<'tcx>) -> Result<(), PrintError> { + let has_regions = self.region_highlight_mode.keep_regions + && ty.has_type_flags(ty::TypeFlags::HAS_REGIONS); match ty.kind() { - ty::Tuple(tys) if tys.len() == 0 && self.should_truncate() => { + ty::Tuple(tys) if tys.len() == 0 => { // Don't truncate `()`. + self.pretty_print_type(ty) + } + + ty::Adt(def, args) + if args.types().next().is_none() + && args.consts().next().is_none() + && args.types().count() < 2 + && self.should_truncate() + && self.tcx.item_name(def.did()).as_str().len() < 5 => + { + // Don't fully truncate types that have "short names" and at most one type param. + // FIXME: only mention the name instead of the path? self.printed_type_count += 1; self.pretty_print_type(ty) } + ty::Adt(..) | ty::Foreign(_) | ty::Pat(..) @@ -2351,17 +2372,17 @@ impl<'tcx> Printer<'tcx> for FmtPrinter<'_, 'tcx> { | ty::CoroutineWitness(..) | ty::Tuple(_) | ty::Alias(..) - | ty::Param(_) | ty::Bound(..) | ty::Placeholder(_) | ty::Error(_) - if self.should_truncate() => + if self.should_truncate() && !has_regions => { // We only truncate types that we know are likely to be much longer than 3 chars. // There's no point in replacing `i32` or `!`. write!(self, "_")?; Ok(()) } + ty::Ref(r, ..) if self.should_truncate() && has_regions => self.pretty_print_type(ty), _ => { self.printed_type_count += 1; self.pretty_print_type(ty) diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_error.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_error.rs index f6887c18075a4..7a10b178cd588 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_error.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_error.rs @@ -5,6 +5,7 @@ use rustc_errors::{Applicability, Diag, IntoDiagArg}; use rustc_hir as hir; use rustc_hir::def::Namespace; use rustc_hir::def_id::{CRATE_DEF_ID, DefId}; +use rustc_hir::limit::Limit; use rustc_middle::bug; use rustc_middle::ty::error::ExpectedFound; use rustc_middle::ty::print::{FmtPrinter, Print, PrintTraitRefExt as _, RegionHighlightMode}; @@ -29,7 +30,7 @@ pub(crate) struct Highlighted<'tcx, T> { impl<'tcx, T> IntoDiagArg for Highlighted<'tcx, T> where - T: for<'a> Print>, + T: for<'a> Print> + Copy, { fn into_diag_arg(self, _: &mut Option) -> rustc_errors::DiagArgValue { rustc_errors::DiagArgValue::Str(self.to_string().into()) @@ -44,14 +45,28 @@ impl<'tcx, T> Highlighted<'tcx, T> { impl<'tcx, T> fmt::Display for Highlighted<'tcx, T> where - T: for<'a> Print>, + T: for<'a> Print> + Copy, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let mut p = ty::print::FmtPrinter::new(self.tcx, self.ns); p.region_highlight_mode = self.highlight; self.value.print(&mut p)?; - f.write_str(&p.into_buffer()) + let b = p.into_buffer(); + if b.len() <= 40 || !self.highlight.keep_regions { + // This is a short enough type that can be safely be printed to the user, or we aren't + // showing the type with a particular interest in its lifetimes. + f.write_str(&b)?; + } else { + // We are highlighting lifetimes in the output, we will print out the smallest possible + // portion of the type while keeping the lifetimes visible. + let mut p = FmtPrinter::new_with_limit(self.tcx, self.ns, Limit(0)); + p.region_highlight_mode = self.highlight; + self.value.print(&mut p).expect("could not print type"); + let x = p.into_buffer(); + f.write_str(&x)?; + } + Ok(()) } } diff --git a/tests/ui/async-await/higher-ranked-auto-trait-15.no_assumptions.stderr b/tests/ui/async-await/higher-ranked-auto-trait-15.no_assumptions.stderr index 461b065d55ad3..3773068f46a2a 100644 --- a/tests/ui/async-await/higher-ranked-auto-trait-15.no_assumptions.stderr +++ b/tests/ui/async-await/higher-ranked-auto-trait-15.no_assumptions.stderr @@ -4,7 +4,7 @@ error: implementation of `FnOnce` is not general enough LL | require_send(future); | ^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | - = note: closure with signature `fn(&'0 Vec) -> std::slice::Iter<'_, i32>` must implement `FnOnce<(&'1 Vec,)>`, for any two lifetimes `'0` and `'1`... + = note: closure with signature `fn(&'0 ...) -> std::slice::Iter<'_, i32>` must implement `FnOnce<(&'1 Vec,)>`, for any two lifetimes `'0` and `'1`... = note: ...but it actually implements `FnOnce<(&Vec,)>` help: consider adding an explicit type annotation to the closure's argument | @@ -17,7 +17,7 @@ error: implementation of `FnOnce` is not general enough LL | require_send(future); | ^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | - = note: closure with signature `fn(&'0 Vec) -> std::slice::Iter<'_, i32>` must implement `FnOnce<(&'1 Vec,)>`, for any two lifetimes `'0` and `'1`... + = note: closure with signature `fn(&'0 ...) -> std::slice::Iter<'_, i32>` must implement `FnOnce<(&'1 Vec,)>`, for any two lifetimes `'0` and `'1`... = note: ...but it actually implements `FnOnce<(&Vec,)>` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: consider adding an explicit type annotation to the closure's argument diff --git a/tests/ui/borrowck/issue-53432-nested-closure-outlives-borrowed-value.stderr b/tests/ui/borrowck/issue-53432-nested-closure-outlives-borrowed-value.stderr index 5887752800b55..2fd84517a61bd 100644 --- a/tests/ui/borrowck/issue-53432-nested-closure-outlives-borrowed-value.stderr +++ b/tests/ui/borrowck/issue-53432-nested-closure-outlives-borrowed-value.stderr @@ -4,7 +4,7 @@ error: lifetime may not live long enough LL | let _action = move || { | ------- | | | - | | return type of closure `{closure@$DIR/issue-53432-nested-closure-outlives-borrowed-value.rs:4:9: 4:11}` contains a lifetime `'2` + | | return type of closure `{closure@...}` contains a lifetime `'2` | lifetime `'1` represents this closure's body LL | || f() // The `nested` closure | ^^^^^^ returning this value requires that `'1` must outlive `'2` diff --git a/tests/ui/borrowck/issue-95079-missing-move-in-nested-closure.stderr b/tests/ui/borrowck/issue-95079-missing-move-in-nested-closure.stderr index d7762621cc5c7..c43a983cbf365 100644 --- a/tests/ui/borrowck/issue-95079-missing-move-in-nested-closure.stderr +++ b/tests/ui/borrowck/issue-95079-missing-move-in-nested-closure.stderr @@ -24,7 +24,7 @@ error: lifetime may not live long enough LL | move |()| s.chars().map(|c| format!("{}{}", c, s)) | --------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'1` must outlive `'2` | | | - | | return type of closure `Map, {closure@$DIR/issue-95079-missing-move-in-nested-closure.rs:11:29: 11:32}>` contains a lifetime `'2` + | | return type of closure `Map, {closure@...}>` contains a lifetime `'2` | lifetime `'1` represents this closure's body | = note: closure implements `Fn`, so references to captured variables can't escape the closure diff --git a/tests/ui/closures/deduce-signature/obligation-with-leaking-placeholders.current.stderr b/tests/ui/closures/deduce-signature/obligation-with-leaking-placeholders.current.stderr index eaa0d32e75dff..cdaa16ac9e807 100644 --- a/tests/ui/closures/deduce-signature/obligation-with-leaking-placeholders.current.stderr +++ b/tests/ui/closures/deduce-signature/obligation-with-leaking-placeholders.current.stderr @@ -8,7 +8,7 @@ LL | | x.to_string(); LL | | }); | |______^ implementation of `Foo` is not general enough | - = note: `Wrap<{closure@$DIR/obligation-with-leaking-placeholders.rs:18:15: 18:18}>` must implement `Foo<'0>`, for any lifetime `'0`... + = note: `Wrap<{closure@...}>` must implement `Foo<'0>`, for any lifetime `'0`... = note: ...but it actually implements `Foo<'1>`, for some specific lifetime `'1` error: aborting due to 1 previous error diff --git a/tests/ui/closures/wrong-closure-arg-suggestion-125325.stderr b/tests/ui/closures/wrong-closure-arg-suggestion-125325.stderr index 80da4e7145f95..1b94d59901d22 100644 --- a/tests/ui/closures/wrong-closure-arg-suggestion-125325.stderr +++ b/tests/ui/closures/wrong-closure-arg-suggestion-125325.stderr @@ -43,7 +43,7 @@ error: lifetime may not live long enough LL | take(|_| to_fn(|_| self.counter += 1)); | --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'1` must outlive `'2` | | | - | | return type of closure `aux::Map<{closure@$DIR/wrong-closure-arg-suggestion-125325.rs:46:24: 46:27}>` contains a lifetime `'2` + | | return type of closure `aux::Map<{closure@...}>` contains a lifetime `'2` | lifetime `'1` represents this closure's body | = note: closure implements `Fn`, so references to captured variables can't escape the closure @@ -77,7 +77,7 @@ error: lifetime may not live long enough LL | P.flat_map(|_| P.map(|_| self.counter += 1)); | --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'1` must outlive `'2` | | | - | | return type of closure `aux::Map<{closure@$DIR/wrong-closure-arg-suggestion-125325.rs:54:30: 54:33}>` contains a lifetime `'2` + | | return type of closure `aux::Map<{closure@...}>` contains a lifetime `'2` | lifetime `'1` represents this closure's body | = note: closure implements `Fn`, so references to captured variables can't escape the closure diff --git a/tests/ui/higher-ranked/higher-ranked-lifetime-error.stderr b/tests/ui/higher-ranked/higher-ranked-lifetime-error.stderr index 2e3fd6123346f..e8a9869e3671a 100644 --- a/tests/ui/higher-ranked/higher-ranked-lifetime-error.stderr +++ b/tests/ui/higher-ranked/higher-ranked-lifetime-error.stderr @@ -4,7 +4,7 @@ error: implementation of `FnMut` is not general enough LL | assert_all::<_, &String>(id); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `FnMut` is not general enough | - = note: `for<'a> fn(&'a String) -> &'a String {id}` must implement `FnMut<(&String,)>` + = note: `for<'a> fn(&'a ...) -> &'a ... {id}` must implement `FnMut<(&String,)>` = note: ...but it actually implements `FnMut<(&'0 String,)>`, for some specific lifetime `'0` error: aborting due to 1 previous error diff --git a/tests/ui/traits/self-without-lifetime-constraint.stderr b/tests/ui/traits/self-without-lifetime-constraint.stderr index 8997d2a98b323..1c949c14afa44 100644 --- a/tests/ui/traits/self-without-lifetime-constraint.stderr +++ b/tests/ui/traits/self-without-lifetime-constraint.stderr @@ -2,13 +2,13 @@ error: `impl` item signature doesn't match `trait` item signature --> $DIR/self-without-lifetime-constraint.rs:46:5 | LL | fn column_result(value: ValueRef<'_>) -> FromSqlResult; - | -------------------------------------------------------------------- expected `fn(ValueRef<'1>) -> Result<(&'2 str, &'1 &'2 str), FromSqlError>` + | -------------------------------------------------------------------- expected `fn(ValueRef<'1>) -> Result<(&'2 str, &'1 &'2 str), ...>` ... LL | fn column_result(value: ValueRef<'_>) -> FromSqlResult<&str, &&str> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(ValueRef<'1>) -> Result<(&'1 str, &'1 &'1 str), FromSqlError>` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(ValueRef<'1>) -> Result<(&'1 str, &'1 &'1 str), ...>` | - = note: expected signature `fn(ValueRef<'1>) -> Result<(&'2 str, &'1 &'2 str), FromSqlError>` - found signature `fn(ValueRef<'1>) -> Result<(&'1 str, &'1 &'1 str), FromSqlError>` + = note: expected signature `fn(ValueRef<'1>) -> Result<(&'2 str, &'1 &'2 str), ...>` + found signature `fn(ValueRef<'1>) -> Result<(&'1 str, &'1 &'1 str), ...>` help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait` --> $DIR/self-without-lifetime-constraint.rs:42:60 | From a85f928f3d6d8fba954d077d4aea985d31b97a18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Thu, 9 Jul 2026 03:38:51 +0000 Subject: [PATCH 02/14] Teach async closures and coroutines to print short types --- compiler/rustc_middle/src/ty/print/pretty.rs | 10 ++++++++-- .../higher-ranked-auto-trait-15.no_assumptions.stderr | 4 ++-- .../higher-ranked-auto-trait-16.assumptions.stderr | 4 ++-- .../higher-ranked-auto-trait-16.no_assumptions.stderr | 4 ++-- tests/ui/coroutine/resume-arg-late-bound.stderr | 2 +- .../higher-ranked/higher-ranked-lifetime-error.stderr | 2 +- .../dont-suggest-boxing-async-closure-body.stderr | 2 +- .../ui/traits/self-without-lifetime-constraint.stderr | 8 ++++---- 8 files changed, 21 insertions(+), 15 deletions(-) diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 830eacc26da9f..3a9e0e169f27c 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -899,7 +899,10 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { if !self.should_print_verbose() { write!(self, "{coroutine_kind}")?; - if coroutine_kind.is_fn_like() { + if self.should_truncate() { + write!(self, "@...}}")?; + return Ok(()); + } else if coroutine_kind.is_fn_like() { // If we are printing an `async fn` coroutine type, then give the path // of the fn, instead of its span, because that will in most cases be // more helpful for the reader than just a source location. @@ -1028,7 +1031,10 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { "coroutine from coroutine-closure should have CoroutineSource::Closure" ), } - if let Some(did) = did.as_local() { + if self.should_truncate() { + write!(self, "@...}}")?; + return Ok(()); + } else if let Some(did) = did.as_local() { if self.tcx().sess.opts.unstable_opts.span_free_formats { write!(self, "@")?; self.print_def_path(did.to_def_id(), args)?; diff --git a/tests/ui/async-await/higher-ranked-auto-trait-15.no_assumptions.stderr b/tests/ui/async-await/higher-ranked-auto-trait-15.no_assumptions.stderr index 3773068f46a2a..8f282b128c456 100644 --- a/tests/ui/async-await/higher-ranked-auto-trait-15.no_assumptions.stderr +++ b/tests/ui/async-await/higher-ranked-auto-trait-15.no_assumptions.stderr @@ -4,7 +4,7 @@ error: implementation of `FnOnce` is not general enough LL | require_send(future); | ^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | - = note: closure with signature `fn(&'0 ...) -> std::slice::Iter<'_, i32>` must implement `FnOnce<(&'1 Vec,)>`, for any two lifetimes `'0` and `'1`... + = note: closure with signature `fn(&'0 _) -> std::slice::Iter<'_, i32>` must implement `FnOnce<(&'1 Vec,)>`, for any two lifetimes `'0` and `'1`... = note: ...but it actually implements `FnOnce<(&Vec,)>` help: consider adding an explicit type annotation to the closure's argument | @@ -17,7 +17,7 @@ error: implementation of `FnOnce` is not general enough LL | require_send(future); | ^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | - = note: closure with signature `fn(&'0 ...) -> std::slice::Iter<'_, i32>` must implement `FnOnce<(&'1 Vec,)>`, for any two lifetimes `'0` and `'1`... + = note: closure with signature `fn(&'0 _) -> std::slice::Iter<'_, i32>` must implement `FnOnce<(&'1 Vec,)>`, for any two lifetimes `'0` and `'1`... = note: ...but it actually implements `FnOnce<(&Vec,)>` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: consider adding an explicit type annotation to the closure's argument diff --git a/tests/ui/async-await/higher-ranked-auto-trait-16.assumptions.stderr b/tests/ui/async-await/higher-ranked-auto-trait-16.assumptions.stderr index 412c31b1bd843..dc6183a45cef5 100644 --- a/tests/ui/async-await/higher-ranked-auto-trait-16.assumptions.stderr +++ b/tests/ui/async-await/higher-ranked-auto-trait-16.assumptions.stderr @@ -6,7 +6,7 @@ LL | | commit_if_ok(&mut ctxt, async |_| todo!()).await; LL | | }); | |______^ implementation of `AsyncFnOnce` is not general enough | - = note: `{async closure@$DIR/higher-ranked-auto-trait-16.rs:19:33: 19:42}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... + = note: `{async closure@...}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... = note: ...but it actually implements `AsyncFnOnce<(&mut Ctxt<'_>,)>` error: implementation of `AsyncFnOnce` is not general enough @@ -17,7 +17,7 @@ LL | | commit_if_ok(&mut ctxt, async |_| todo!()).await; LL | | }); | |______^ implementation of `AsyncFnOnce` is not general enough | - = note: `{async closure@$DIR/higher-ranked-auto-trait-16.rs:19:33: 19:42}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... + = note: `{async closure@...}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... = note: ...but it actually implements `AsyncFnOnce<(&mut Ctxt<'_>,)>` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` diff --git a/tests/ui/async-await/higher-ranked-auto-trait-16.no_assumptions.stderr b/tests/ui/async-await/higher-ranked-auto-trait-16.no_assumptions.stderr index 412c31b1bd843..dc6183a45cef5 100644 --- a/tests/ui/async-await/higher-ranked-auto-trait-16.no_assumptions.stderr +++ b/tests/ui/async-await/higher-ranked-auto-trait-16.no_assumptions.stderr @@ -6,7 +6,7 @@ LL | | commit_if_ok(&mut ctxt, async |_| todo!()).await; LL | | }); | |______^ implementation of `AsyncFnOnce` is not general enough | - = note: `{async closure@$DIR/higher-ranked-auto-trait-16.rs:19:33: 19:42}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... + = note: `{async closure@...}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... = note: ...but it actually implements `AsyncFnOnce<(&mut Ctxt<'_>,)>` error: implementation of `AsyncFnOnce` is not general enough @@ -17,7 +17,7 @@ LL | | commit_if_ok(&mut ctxt, async |_| todo!()).await; LL | | }); | |______^ implementation of `AsyncFnOnce` is not general enough | - = note: `{async closure@$DIR/higher-ranked-auto-trait-16.rs:19:33: 19:42}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... + = note: `{async closure@...}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... = note: ...but it actually implements `AsyncFnOnce<(&mut Ctxt<'_>,)>` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` diff --git a/tests/ui/coroutine/resume-arg-late-bound.stderr b/tests/ui/coroutine/resume-arg-late-bound.stderr index 646abaf4f7bde..0a6fb8dfcbb6c 100644 --- a/tests/ui/coroutine/resume-arg-late-bound.stderr +++ b/tests/ui/coroutine/resume-arg-late-bound.stderr @@ -4,7 +4,7 @@ error: implementation of `Coroutine` is not general enough LL | test(gen); | ^^^^^^^^^ implementation of `Coroutine` is not general enough | - = note: `{coroutine@$DIR/resume-arg-late-bound.rs:11:28: 11:44}` must implement `Coroutine<&'1 mut bool>`, for any lifetime `'1`... + = note: `{coroutine@...}` must implement `Coroutine<&'1 mut bool>`, for any lifetime `'1`... = note: ...but it actually implements `Coroutine<&'2 mut bool>`, for some specific lifetime `'2` error: aborting due to 1 previous error diff --git a/tests/ui/higher-ranked/higher-ranked-lifetime-error.stderr b/tests/ui/higher-ranked/higher-ranked-lifetime-error.stderr index e8a9869e3671a..85d95405745e8 100644 --- a/tests/ui/higher-ranked/higher-ranked-lifetime-error.stderr +++ b/tests/ui/higher-ranked/higher-ranked-lifetime-error.stderr @@ -4,7 +4,7 @@ error: implementation of `FnMut` is not general enough LL | assert_all::<_, &String>(id); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `FnMut` is not general enough | - = note: `for<'a> fn(&'a ...) -> &'a ... {id}` must implement `FnMut<(&String,)>` + = note: `for<'a> fn(&'a _) -> &'a _ {id}` must implement `FnMut<(&String,)>` = note: ...but it actually implements `FnMut<(&'0 String,)>`, for some specific lifetime `'0` error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/dont-suggest-boxing-async-closure-body.stderr b/tests/ui/suggestions/dont-suggest-boxing-async-closure-body.stderr index abf8e2d824b5d..430432b99901e 100644 --- a/tests/ui/suggestions/dont-suggest-boxing-async-closure-body.stderr +++ b/tests/ui/suggestions/dont-suggest-boxing-async-closure-body.stderr @@ -18,7 +18,7 @@ error[E0308]: mismatched types --> $DIR/dont-suggest-boxing-async-closure-body.rs:11:9 | LL | bar(async move || {}); - | --- ^^^^^^^^^^^^^^^^ expected `Box _>`, found `{async closure@dont-suggest-boxing-async-closure-body.rs:11:9}` + | --- ^^^^^^^^^^^^^^^^ expected `Box _>`, found `{async closure@...}` | | | arguments to this function are incorrect | diff --git a/tests/ui/traits/self-without-lifetime-constraint.stderr b/tests/ui/traits/self-without-lifetime-constraint.stderr index 1c949c14afa44..a7376e6cf9dc5 100644 --- a/tests/ui/traits/self-without-lifetime-constraint.stderr +++ b/tests/ui/traits/self-without-lifetime-constraint.stderr @@ -2,13 +2,13 @@ error: `impl` item signature doesn't match `trait` item signature --> $DIR/self-without-lifetime-constraint.rs:46:5 | LL | fn column_result(value: ValueRef<'_>) -> FromSqlResult; - | -------------------------------------------------------------------- expected `fn(ValueRef<'1>) -> Result<(&'2 str, &'1 &'2 str), ...>` + | -------------------------------------------------------------------- expected `fn(ValueRef<'1>) -> Result<(&'2 str, &'1 &'2 str), _>` ... LL | fn column_result(value: ValueRef<'_>) -> FromSqlResult<&str, &&str> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(ValueRef<'1>) -> Result<(&'1 str, &'1 &'1 str), ...>` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(ValueRef<'1>) -> Result<(&'1 str, &'1 &'1 str), _>` | - = note: expected signature `fn(ValueRef<'1>) -> Result<(&'2 str, &'1 &'2 str), ...>` - found signature `fn(ValueRef<'1>) -> Result<(&'1 str, &'1 &'1 str), ...>` + = note: expected signature `fn(ValueRef<'1>) -> Result<(&'2 str, &'1 &'2 str), _>` + found signature `fn(ValueRef<'1>) -> Result<(&'1 str, &'1 &'1 str), _>` help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait` --> $DIR/self-without-lifetime-constraint.rs:42:60 | From 00d1b3fee67b8ab351375692036be5d208f46f11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Thu, 9 Jul 2026 23:13:10 +0000 Subject: [PATCH 03/14] Use `Highlight` when naming hidden type in return type ``` error[E0700]: hidden type for `impl Iterator` captures lifetime that does not appear in bounds --> $DIR/static-return-lifetime-infered.rs:11:9 | LL | fn iter_values<'a>(&'a self) -> impl Iterator { | -- ----------------------- opaque type defined here | | | hidden type `Map, {closure@...}>` captures the lifetime `'a` as defined here LL | self.x.iter().map(|a| a.0) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ``` --- .../src/error_reporting/infer/region.rs | 7 ++++++- tests/ui/borrowck/closure-upvar-named-lifetime.stderr | 4 ++-- tests/ui/c-variadic/not-async.stderr | 2 +- .../impl-trait/must_outlive_least_region_or_bound.stderr | 2 +- tests/ui/impl-trait/nested-return-type4.stderr | 2 +- tests/ui/impl-trait/static-return-lifetime-infered.stderr | 4 ++-- tests/ui/inference/note-and-explain-ReVar-124973.stderr | 2 +- tests/ui/iterators/generator_returned_from_fn.stderr | 4 ++-- tests/ui/rfcs/impl-trait/higher-ranked-regions-diag.stderr | 2 +- ...-lifetime-suggestion-in-proper-span-issue-121267.stderr | 2 +- .../lifetimes/missing-lifetimes-in-signature.stderr | 2 +- 11 files changed, 19 insertions(+), 14 deletions(-) diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs index 7e706a9838306..5e906c17c0756 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs @@ -4,13 +4,14 @@ use rustc_data_structures::fx::FxIndexSet; use rustc_errors::{ Applicability, Diag, E0309, E0310, E0311, E0803, Subdiagnostic, msg, struct_span_code_err, }; -use rustc_hir::def::DefKind; +use rustc_hir::def::{DefKind, Namespace}; use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::intravisit::Visitor; use rustc_hir::{self as hir, ParamName}; use rustc_middle::bug; use rustc_middle::traits::ObligationCauseCode; use rustc_middle::ty::error::TypeError; +use rustc_middle::ty::print::RegionHighlightMode; use rustc_middle::ty::{ self, IsSuggestable, Region, Ty, TyCtxt, TypeVisitableExt as _, Upcast as _, }; @@ -25,6 +26,7 @@ use crate::diagnostics::{ }; use crate::error_reporting::TypeErrCtxt; use crate::error_reporting::infer::ObligationCauseExt; +use crate::error_reporting::infer::nice_region_error::placeholder_error::Highlighted; use crate::infer::region_constraints::GenericKind; use crate::infer::{ BoundRegionConversionTime, InferCtxt, RegionResolutionError, RegionVariableOrigin, @@ -1286,6 +1288,9 @@ pub fn unexpected_hidden_region_diagnostic<'a, 'tcx>( ), opaque_ty_span: tcx.def_span(opaque_ty_key.def_id), }); + let mut highlight = RegionHighlightMode::default(); + highlight.keep_regions = true; + let hidden_ty = Highlighted { highlight, ns: Namespace::TypeNS, tcx, value: hidden_ty }; // Explain the region we are capturing. match hidden_region.kind() { diff --git a/tests/ui/borrowck/closure-upvar-named-lifetime.stderr b/tests/ui/borrowck/closure-upvar-named-lifetime.stderr index fc7c59fa97c89..7b90b07b2f985 100644 --- a/tests/ui/borrowck/closure-upvar-named-lifetime.stderr +++ b/tests/ui/borrowck/closure-upvar-named-lifetime.stderr @@ -39,7 +39,7 @@ error[E0700]: hidden type for `impl Fn(RefCell>)` captur --> $DIR/closure-upvar-named-lifetime.rs:17:5 | LL | fn apply<'a>( - | -- hidden type `{closure@$DIR/closure-upvar-named-lifetime.rs:17:5: 17:15}` captures the lifetime `'a` as defined here + | -- hidden type `{closure@...}` captures the lifetime `'a` as defined here LL | f: Arc) + 'a>, LL | ) -> impl Fn(RefCell>) | ----------------------------------------- opaque type defined here @@ -92,7 +92,7 @@ error[E0700]: hidden type for `impl Fn(RefCell>)` captur --> $DIR/closure-upvar-named-lifetime.rs:32:5 | LL | fn apply_box<'a>( - | -- hidden type `{closure@$DIR/closure-upvar-named-lifetime.rs:32:5: 32:15}` captures the lifetime `'a` as defined here + | -- hidden type `{closure@...}` captures the lifetime `'a` as defined here LL | f: Box) + 'a>, LL | ) -> impl Fn(RefCell>) | ----------------------------------------- opaque type defined here diff --git a/tests/ui/c-variadic/not-async.stderr b/tests/ui/c-variadic/not-async.stderr index bb8cc64e15fa4..c6929b3676230 100644 --- a/tests/ui/c-variadic/not-async.stderr +++ b/tests/ui/c-variadic/not-async.stderr @@ -28,7 +28,7 @@ LL | async unsafe extern "C" fn method_cannot_be_async(x: isize, _: ...) {} | | | opaque type defined here | - = note: hidden type `{async fn body of S::method_cannot_be_async()}` captures lifetime `'_` + = note: hidden type `{async fn body@...}` captures lifetime `'_` error: aborting due to 4 previous errors diff --git a/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr b/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr index 53c5568660417..4a364c9eb0c6d 100644 --- a/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr +++ b/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr @@ -112,7 +112,7 @@ error[E0700]: hidden type for `impl Fn(&'a u32)` captures lifetime that does not LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) { | -- ---------------- opaque type defined here | | - | hidden type `{closure@$DIR/must_outlive_least_region_or_bound.rs:42:5: 42:13}` captures the lifetime `'b` as defined here + | hidden type `{closure@...}` captures the lifetime `'b` as defined here LL | move |_| println!("{}", y) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/tests/ui/impl-trait/nested-return-type4.stderr b/tests/ui/impl-trait/nested-return-type4.stderr index 407800eff1894..63f3bfcdda950 100644 --- a/tests/ui/impl-trait/nested-return-type4.stderr +++ b/tests/ui/impl-trait/nested-return-type4.stderr @@ -4,7 +4,7 @@ error[E0700]: hidden type for `impl Future` captures lifeti LL | fn test<'s: 's>(s: &'s str) -> impl std::future::Future { | -- --------------------------------------------- opaque type defined here | | - | hidden type `{async block@$DIR/nested-return-type4.rs:4:5: 4:15}` captures the lifetime `'s` as defined here + | hidden type `{async block@...}` captures the lifetime `'s` as defined here LL | async move { let _s = s; } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/tests/ui/impl-trait/static-return-lifetime-infered.stderr b/tests/ui/impl-trait/static-return-lifetime-infered.stderr index 21e3187d01912..7bdab1da26560 100644 --- a/tests/ui/impl-trait/static-return-lifetime-infered.stderr +++ b/tests/ui/impl-trait/static-return-lifetime-infered.stderr @@ -4,7 +4,7 @@ error[E0700]: hidden type for `impl Iterator` captures lifetime that LL | fn iter_values_anon(&self) -> impl Iterator { | ----- ----------------------- opaque type defined here | | - | hidden type `Map, {closure@$DIR/static-return-lifetime-infered.rs:7:27: 7:30}>` captures the anonymous lifetime defined here + | hidden type `Map, {closure@...}>` captures the anonymous lifetime defined here LL | self.x.iter().map(|a| a.0) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | @@ -19,7 +19,7 @@ error[E0700]: hidden type for `impl Iterator` captures lifetime that LL | fn iter_values<'a>(&'a self) -> impl Iterator { | -- ----------------------- opaque type defined here | | - | hidden type `Map, {closure@$DIR/static-return-lifetime-infered.rs:11:27: 11:30}>` captures the lifetime `'a` as defined here + | hidden type `Map, {closure@...}>` captures the lifetime `'a` as defined here LL | self.x.iter().map(|a| a.0) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/tests/ui/inference/note-and-explain-ReVar-124973.stderr b/tests/ui/inference/note-and-explain-ReVar-124973.stderr index 2b5e79e9a1c64..fa5ba771980f4 100644 --- a/tests/ui/inference/note-and-explain-ReVar-124973.stderr +++ b/tests/ui/inference/note-and-explain-ReVar-124973.stderr @@ -12,7 +12,7 @@ LL | async unsafe extern "C" fn multiple_named_lifetimes<'a, 'b>(_: u8, _: ...) | | | opaque type defined here | - = note: hidden type `{async fn body of multiple_named_lifetimes<'a, 'b>()}` captures lifetime `'_` + = note: hidden type `{async fn body@...}` captures lifetime `'_` error: aborting due to 2 previous errors diff --git a/tests/ui/iterators/generator_returned_from_fn.stderr b/tests/ui/iterators/generator_returned_from_fn.stderr index 8bec119ddbc01..f4620b958f0c6 100644 --- a/tests/ui/iterators/generator_returned_from_fn.stderr +++ b/tests/ui/iterators/generator_returned_from_fn.stderr @@ -28,7 +28,7 @@ error[E0700]: hidden type for `impl FnOnce() -> impl Iterator` captu LL | fn capture_move_once(a: &u32) -> impl FnOnce() -> impl Iterator { | ---- ------------------------------------------ opaque type defined here | | - | hidden type `{gen closure@$DIR/generator_returned_from_fn.rs:43:13: 43:20}` captures the anonymous lifetime defined here + | hidden type `{gen closure@...}` captures the anonymous lifetime defined here LL | iter! { move || { | _____________^ LL | | @@ -49,7 +49,7 @@ error[E0700]: hidden type for `impl Iterator` captures lifetime that LL | fn capture_move_once(a: &u32) -> impl FnOnce() -> impl Iterator { | ---- ------------------------- opaque type defined here | | - | hidden type `{gen closure body@$DIR/generator_returned_from_fn.rs:43:21: 50:6}` captures the anonymous lifetime defined here + | hidden type `{gen closure body@...}` captures the anonymous lifetime defined here LL | iter! { move || { | _____________^ LL | | diff --git a/tests/ui/rfcs/impl-trait/higher-ranked-regions-diag.stderr b/tests/ui/rfcs/impl-trait/higher-ranked-regions-diag.stderr index c177c3bbf00be..7333c3b3bbaf0 100644 --- a/tests/ui/rfcs/impl-trait/higher-ranked-regions-diag.stderr +++ b/tests/ui/rfcs/impl-trait/higher-ranked-regions-diag.stderr @@ -4,7 +4,7 @@ error[E0700]: hidden type for `impl Sized` captures lifetime that does not appea LL | fn bar() -> impl for<'a> Trait<&'a (), Assoc = impl Sized> { | -- ---------- opaque type defined here | | - | hidden type ` Trait<&'a ()> as Trait<&'a ()>>::Assoc` captures the lifetime `'a` as defined here + | hidden type `<... as Trait<&'a ()>>::Assoc` captures the lifetime `'a` as defined here LL | foo() | ^^^^^ diff --git a/tests/ui/suggestions/lifetimes/explicit-lifetime-suggestion-in-proper-span-issue-121267.stderr b/tests/ui/suggestions/lifetimes/explicit-lifetime-suggestion-in-proper-span-issue-121267.stderr index a9b0931499d95..78a84f5f5da66 100644 --- a/tests/ui/suggestions/lifetimes/explicit-lifetime-suggestion-in-proper-span-issue-121267.stderr +++ b/tests/ui/suggestions/lifetimes/explicit-lifetime-suggestion-in-proper-span-issue-121267.stderr @@ -8,7 +8,7 @@ LL | | LL | | .filter_map(|_| foo(src)) | |_________________________________^ | - = note: hidden type `FilterMap, {closure@$DIR/explicit-lifetime-suggestion-in-proper-span-issue-121267.rs:10:21: 10:24}>` captures lifetime `'_` + = note: hidden type `FilterMap, {closure@...}>` captures lifetime `'_` error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr index ab067f2439c67..ac4ba68aa36a6 100644 --- a/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr +++ b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr @@ -15,7 +15,7 @@ error[E0700]: hidden type for `impl FnOnce()` captures lifetime that does not ap LL | fn foo(g: G, dest: &mut T) -> impl FnOnce() | ------ ------------- opaque type defined here | | - | hidden type `{closure@$DIR/missing-lifetimes-in-signature.rs:19:5: 19:12}` captures the anonymous lifetime defined here + | hidden type `{closure@...}` captures the anonymous lifetime defined here ... LL | / move || { LL | | From 76519dc82370fe95af24c431fd4ea898f3203eb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Thu, 9 Jul 2026 23:14:29 +0000 Subject: [PATCH 04/14] Make `Highlighted` take heed of `--verbose` --- .../infer/nice_region_error/placeholder_error.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_error.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_error.rs index 7a10b178cd588..7f452a578778d 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_error.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_error.rs @@ -53,7 +53,7 @@ where self.value.print(&mut p)?; let b = p.into_buffer(); - if b.len() <= 40 || !self.highlight.keep_regions { + if b.len() <= 40 || !self.highlight.keep_regions || self.tcx.sess.opts.verbose { // This is a short enough type that can be safely be printed to the user, or we aren't // showing the type with a particular interest in its lifetimes. f.write_str(&b)?; From 24c30fb0cec99cce808ed22582b403db1e4b20fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 10 Jul 2026 03:24:43 +0000 Subject: [PATCH 05/14] Account for `for<'a>` in ` Trait as Trait>` when shortening types --- compiler/rustc_middle/src/ty/print/pretty.rs | 18 +++++++++++++++++- .../higher-ranked-regions-diag.stderr | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 3a9e0e169f27c..30eb545835709 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -2363,6 +2363,22 @@ impl<'tcx> Printer<'tcx> for FmtPrinter<'_, 'tcx> { self.pretty_print_type(ty) } + ty::Alias(_, alias) + if self.should_truncate() + && let ty::AliasTyKind::Opaque { def_id } = alias.kind + && self.region_highlight_mode.keep_regions + && self + .tcx + .explicit_item_bounds(def_id) + .iter_instantiated_copied(self.tcx, alias.args) + .map(Unnormalized::skip_norm_wip) + .any(|(value, _)| value.has_bound_vars()) => + { + // ` Trait as Trait>` + self.printed_type_count += 1; + self.pretty_print_type(ty) + } + ty::Adt(..) | ty::Foreign(_) | ty::Pat(..) @@ -2388,7 +2404,7 @@ impl<'tcx> Printer<'tcx> for FmtPrinter<'_, 'tcx> { write!(self, "_")?; Ok(()) } - ty::Ref(r, ..) if self.should_truncate() && has_regions => self.pretty_print_type(ty), + ty::Ref(..) if self.should_truncate() && has_regions => self.pretty_print_type(ty), _ => { self.printed_type_count += 1; self.pretty_print_type(ty) diff --git a/tests/ui/rfcs/impl-trait/higher-ranked-regions-diag.stderr b/tests/ui/rfcs/impl-trait/higher-ranked-regions-diag.stderr index 7333c3b3bbaf0..c177c3bbf00be 100644 --- a/tests/ui/rfcs/impl-trait/higher-ranked-regions-diag.stderr +++ b/tests/ui/rfcs/impl-trait/higher-ranked-regions-diag.stderr @@ -4,7 +4,7 @@ error[E0700]: hidden type for `impl Sized` captures lifetime that does not appea LL | fn bar() -> impl for<'a> Trait<&'a (), Assoc = impl Sized> { | -- ---------- opaque type defined here | | - | hidden type `<... as Trait<&'a ()>>::Assoc` captures the lifetime `'a` as defined here + | hidden type ` Trait<&'a ()> as Trait<&'a ()>>::Assoc` captures the lifetime `'a` as defined here LL | foo() | ^^^^^ From e94c07ccc63de75090132248b8adb400fa2b5d59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 10 Jul 2026 03:57:21 +0000 Subject: [PATCH 06/14] Always show full signature on "`impl` doesn't match `trait`" error --- .../rustc_trait_selection/src/diagnostics.rs | 6 ++++-- .../nice_region_error/trait_impl_difference.rs | 18 ++++++++++++++++-- .../static-return-lifetime-infered.stderr | 4 ++-- .../self-without-lifetime-constraint.stderr | 4 ++-- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_trait_selection/src/diagnostics.rs b/compiler/rustc_trait_selection/src/diagnostics.rs index bb2614992adf2..44b5e669d5251 100644 --- a/compiler/rustc_trait_selection/src/diagnostics.rs +++ b/compiler/rustc_trait_selection/src/diagnostics.rs @@ -1203,9 +1203,9 @@ impl Subdiagnostic for ConsiderBorrowingParamHelp { #[diag("`impl` item signature doesn't match `trait` item signature")] pub(crate) struct TraitImplDiff { #[primary_span] - #[label("found `{$found}`")] + #[label("found `{$found_short}`")] pub sp: Span, - #[label("expected `{$expected}`")] + #[label("expected `{$expected_short}`")] pub trait_sp: Span, #[note( "expected signature `{$expected}` @@ -1218,6 +1218,8 @@ pub(crate) struct TraitImplDiff { "verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output" )] pub rel_help: bool, + pub expected_short: String, + pub found_short: String, pub expected: String, pub found: String, } diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/trait_impl_difference.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/trait_impl_difference.rs index eb0b9a0234275..f1be118896b01 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/trait_impl_difference.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/trait_impl_difference.rs @@ -84,7 +84,15 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { } let tcx = self.cx.tcx; - let expected_highlight = HighlightBuilder::build(tcx, expected); + let mut expected_highlight = HighlightBuilder::build(tcx, expected); + let expected_short = Highlighted { + highlight: expected_highlight, + ns: Namespace::TypeNS, + tcx, + value: expected, + } + .to_string(); + expected_highlight.keep_regions = false; let expected = Highlighted { highlight: expected_highlight, ns: Namespace::TypeNS, @@ -92,7 +100,11 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { value: expected, } .to_string(); - let found_highlight = HighlightBuilder::build(tcx, found); + let mut found_highlight = HighlightBuilder::build(tcx, found); + let found_short = + Highlighted { highlight: found_highlight, ns: Namespace::TypeNS, tcx, value: found } + .to_string(); + found_highlight.keep_regions = false; let found = Highlighted { highlight: found_highlight, ns: Namespace::TypeNS, tcx, value: found } .to_string(); @@ -121,6 +133,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { rel_help: visitor.types.is_empty(), expected, found, + expected_short, + found_short, }; let mut diag = self.tcx().dcx().create_err(diag); diff --git a/tests/ui/impl-trait/static-return-lifetime-infered.stderr b/tests/ui/impl-trait/static-return-lifetime-infered.stderr index 7bdab1da26560..8f2b4c7d26616 100644 --- a/tests/ui/impl-trait/static-return-lifetime-infered.stderr +++ b/tests/ui/impl-trait/static-return-lifetime-infered.stderr @@ -4,7 +4,7 @@ error[E0700]: hidden type for `impl Iterator` captures lifetime that LL | fn iter_values_anon(&self) -> impl Iterator { | ----- ----------------------- opaque type defined here | | - | hidden type `Map, {closure@...}>` captures the anonymous lifetime defined here + | hidden type `Map, {closure@...}>` captures the anonymous lifetime defined here LL | self.x.iter().map(|a| a.0) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | @@ -19,7 +19,7 @@ error[E0700]: hidden type for `impl Iterator` captures lifetime that LL | fn iter_values<'a>(&'a self) -> impl Iterator { | -- ----------------------- opaque type defined here | | - | hidden type `Map, {closure@...}>` captures the lifetime `'a` as defined here + | hidden type `Map, {closure@...}>` captures the lifetime `'a` as defined here LL | self.x.iter().map(|a| a.0) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/tests/ui/traits/self-without-lifetime-constraint.stderr b/tests/ui/traits/self-without-lifetime-constraint.stderr index a7376e6cf9dc5..a82ff8eb0c269 100644 --- a/tests/ui/traits/self-without-lifetime-constraint.stderr +++ b/tests/ui/traits/self-without-lifetime-constraint.stderr @@ -7,8 +7,8 @@ LL | fn column_result(value: ValueRef<'_>) -> FromSqlResult; LL | fn column_result(value: ValueRef<'_>) -> FromSqlResult<&str, &&str> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(ValueRef<'1>) -> Result<(&'1 str, &'1 &'1 str), _>` | - = note: expected signature `fn(ValueRef<'1>) -> Result<(&'2 str, &'1 &'2 str), _>` - found signature `fn(ValueRef<'1>) -> Result<(&'1 str, &'1 &'1 str), _>` + = note: expected signature `fn(ValueRef<'1>) -> Result<(&'2 str, &'1 &'2 str), FromSqlError>` + found signature `fn(ValueRef<'1>) -> Result<(&'1 str, &'1 &'1 str), FromSqlError>` help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait` --> $DIR/self-without-lifetime-constraint.rs:42:60 | From d228a8992d10c5bc4b1a3c5480f1baf4499e6df1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 10 Jul 2026 17:32:12 +0000 Subject: [PATCH 07/14] Tweak logic to refer to items by their name instead of path when shortening --- compiler/rustc_middle/src/ty/print/pretty.rs | 43 +++++++++++++++---- ...olved-typeck-results.no_assumptions.stderr | 4 +- ...ranked-auto-trait-15.no_assumptions.stderr | 4 +- .../higher-ranked-lifetime-error.stderr | 2 +- .../static-return-lifetime-infered.stderr | 4 +- ...ismatch-elided-lifetime-issue-65866.stderr | 8 ++-- ...gestion-in-proper-span-issue-121267.stderr | 2 +- 7 files changed, 47 insertions(+), 20 deletions(-) diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 30eb545835709..2d62c36c93376 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -2351,16 +2351,43 @@ impl<'tcx> Printer<'tcx> for FmtPrinter<'_, 'tcx> { } ty::Adt(def, args) - if args.types().next().is_none() - && args.consts().next().is_none() + if self.should_truncate() + && args.consts().count() < 2 && args.types().count() < 2 - && self.should_truncate() - && self.tcx.item_name(def.did()).as_str().len() < 5 => + && { + // We ensure that if there's at most a single type parameter and that type + // *doesn't* have any parameters, to avoid printing all the names in cases + // like `Foo>>`, instead truncating those always to + // `Foo<...>`. + if let Some(arg) = args.types().next() { + if let ty::Adt(_, arg_args) = arg.kind() { + if arg_args.consts().next().is_none() + && arg_args.types().next().is_none() + { + // Single param type with no type or const parameters: + // `Foo>`. + true + } else { + // Single param type with multiple type or const parameters: + // `Foo>`. We don't want to recurse into those, + // we'll replace the whole thing with `...`. + false + } + } else { + // Single type param that *isn't* a type with parameters, like a + // primitive: `Foo`. + true + } + } else { + // No type param: `Foo`. + true + } + } + && self.tcx.item_name(def.did()).as_str().len() < 7 => { - // Don't fully truncate types that have "short names" and at most one type param. - // FIXME: only mention the name instead of the path? - self.printed_type_count += 1; - self.pretty_print_type(ty) + // Don't fully truncate types that have "short names" and at most one type or const + // param. We do use the short path for them (only item name instad of full path). + with_forced_trimmed_paths!(self.pretty_print_type(ty)) } ty::Alias(_, alias) diff --git a/tests/ui/async-await/drop-tracking-unresolved-typeck-results.no_assumptions.stderr b/tests/ui/async-await/drop-tracking-unresolved-typeck-results.no_assumptions.stderr index d5560bf892032..5a5bba352c69b 100644 --- a/tests/ui/async-await/drop-tracking-unresolved-typeck-results.no_assumptions.stderr +++ b/tests/ui/async-await/drop-tracking-unresolved-typeck-results.no_assumptions.stderr @@ -6,7 +6,7 @@ LL | | Next(&Buffered(Map(Empty(PhantomData), ready::<&()>), FuturesOrde LL | | }); | |______^ implementation of `FnOnce` is not general enough | - = note: `fn(&'0 ()) -> std::future::Ready<&'0 ()> {std::future::ready::<&'0 ()>}` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`... + = note: `fn(&'0 ()) -> Ready<&'0 ()> {std::future::ready::<&'0 ()>}` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`... = note: ...but it actually implements `FnOnce<(&(),)>` error: implementation of `FnOnce` is not general enough @@ -17,7 +17,7 @@ LL | | Next(&Buffered(Map(Empty(PhantomData), ready::<&()>), FuturesOrde LL | | }); | |______^ implementation of `FnOnce` is not general enough | - = note: `fn(&'0 ()) -> std::future::Ready<&'0 ()> {std::future::ready::<&'0 ()>}` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`... + = note: `fn(&'0 ()) -> Ready<&'0 ()> {std::future::ready::<&'0 ()>}` must implement `FnOnce<(&'1 (),)>`, for any two lifetimes `'0` and `'1`... = note: ...but it actually implements `FnOnce<(&(),)>` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` diff --git a/tests/ui/async-await/higher-ranked-auto-trait-15.no_assumptions.stderr b/tests/ui/async-await/higher-ranked-auto-trait-15.no_assumptions.stderr index 8f282b128c456..e8d1f585f0256 100644 --- a/tests/ui/async-await/higher-ranked-auto-trait-15.no_assumptions.stderr +++ b/tests/ui/async-await/higher-ranked-auto-trait-15.no_assumptions.stderr @@ -4,7 +4,7 @@ error: implementation of `FnOnce` is not general enough LL | require_send(future); | ^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | - = note: closure with signature `fn(&'0 _) -> std::slice::Iter<'_, i32>` must implement `FnOnce<(&'1 Vec,)>`, for any two lifetimes `'0` and `'1`... + = note: closure with signature `fn(&'0 _) -> Iter<'_, i32>` must implement `FnOnce<(&'1 Vec,)>`, for any two lifetimes `'0` and `'1`... = note: ...but it actually implements `FnOnce<(&Vec,)>` help: consider adding an explicit type annotation to the closure's argument | @@ -17,7 +17,7 @@ error: implementation of `FnOnce` is not general enough LL | require_send(future); | ^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | - = note: closure with signature `fn(&'0 _) -> std::slice::Iter<'_, i32>` must implement `FnOnce<(&'1 Vec,)>`, for any two lifetimes `'0` and `'1`... + = note: closure with signature `fn(&'0 _) -> Iter<'_, i32>` must implement `FnOnce<(&'1 Vec,)>`, for any two lifetimes `'0` and `'1`... = note: ...but it actually implements `FnOnce<(&Vec,)>` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: consider adding an explicit type annotation to the closure's argument diff --git a/tests/ui/higher-ranked/higher-ranked-lifetime-error.stderr b/tests/ui/higher-ranked/higher-ranked-lifetime-error.stderr index 85d95405745e8..2e3fd6123346f 100644 --- a/tests/ui/higher-ranked/higher-ranked-lifetime-error.stderr +++ b/tests/ui/higher-ranked/higher-ranked-lifetime-error.stderr @@ -4,7 +4,7 @@ error: implementation of `FnMut` is not general enough LL | assert_all::<_, &String>(id); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `FnMut` is not general enough | - = note: `for<'a> fn(&'a _) -> &'a _ {id}` must implement `FnMut<(&String,)>` + = note: `for<'a> fn(&'a String) -> &'a String {id}` must implement `FnMut<(&String,)>` = note: ...but it actually implements `FnMut<(&'0 String,)>`, for some specific lifetime `'0` error: aborting due to 1 previous error diff --git a/tests/ui/impl-trait/static-return-lifetime-infered.stderr b/tests/ui/impl-trait/static-return-lifetime-infered.stderr index 8f2b4c7d26616..093bd3d227527 100644 --- a/tests/ui/impl-trait/static-return-lifetime-infered.stderr +++ b/tests/ui/impl-trait/static-return-lifetime-infered.stderr @@ -4,7 +4,7 @@ error[E0700]: hidden type for `impl Iterator` captures lifetime that LL | fn iter_values_anon(&self) -> impl Iterator { | ----- ----------------------- opaque type defined here | | - | hidden type `Map, {closure@...}>` captures the anonymous lifetime defined here + | hidden type `Map, {closure@...}>` captures the anonymous lifetime defined here LL | self.x.iter().map(|a| a.0) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | @@ -19,7 +19,7 @@ error[E0700]: hidden type for `impl Iterator` captures lifetime that LL | fn iter_values<'a>(&'a self) -> impl Iterator { | -- ----------------------- opaque type defined here | | - | hidden type `Map, {closure@...}>` captures the lifetime `'a` as defined here + | hidden type `Map, {closure@...}>` captures the lifetime `'a` as defined here LL | self.x.iter().map(|a| a.0) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/tests/ui/lifetimes/trait-impl-mismatch-elided-lifetime-issue-65866.stderr b/tests/ui/lifetimes/trait-impl-mismatch-elided-lifetime-issue-65866.stderr index db69b4f3656e6..4c4f6032b0f7b 100644 --- a/tests/ui/lifetimes/trait-impl-mismatch-elided-lifetime-issue-65866.stderr +++ b/tests/ui/lifetimes/trait-impl-mismatch-elided-lifetime-issue-65866.stderr @@ -2,10 +2,10 @@ error: `impl` item signature doesn't match `trait` item signature --> $DIR/trait-impl-mismatch-elided-lifetime-issue-65866.rs:17:9 | LL | fn bar(&self, r: &mut Re); - | -------------------------- expected `fn(&'1 plain::Foo, &'2 mut plain::Re<'3>)` + | -------------------------- expected `fn(&'1 Foo, &'2 mut Re<'3>)` ... LL | fn bar<'a, 'b>(&'a self, _r: &'b mut Re<'a>) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 plain::Foo, &'2 mut plain::Re<'1>)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 Foo, &'2 mut Re<'1>)` | = note: expected signature `fn(&'1 plain::Foo, &'2 mut plain::Re<'3>)` found signature `fn(&'1 plain::Foo, &'2 mut plain::Re<'1>)` @@ -21,10 +21,10 @@ error: `impl` item signature doesn't match `trait` item signature --> $DIR/trait-impl-mismatch-elided-lifetime-issue-65866.rs:40:9 | LL | fn bar(&self, r: &mut Re); - | ------------------------------ expected `fn(&'1 with_type_args::Foo, &'2 mut with_type_args::Re<'3, u8>)` + | ------------------------------ expected `fn(&'1 Foo, &'2 mut Re<'3, u8>)` ... LL | fn bar<'a, 'b>(&'a self, _r: &'b mut Re<'a, u8>) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 with_type_args::Foo, &'2 mut with_type_args::Re<'1, u8>)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 Foo, &'2 mut Re<'1, u8>)` | = note: expected signature `fn(&'1 with_type_args::Foo, &'2 mut with_type_args::Re<'3, u8>)` found signature `fn(&'1 with_type_args::Foo, &'2 mut with_type_args::Re<'1, u8>)` diff --git a/tests/ui/suggestions/lifetimes/explicit-lifetime-suggestion-in-proper-span-issue-121267.stderr b/tests/ui/suggestions/lifetimes/explicit-lifetime-suggestion-in-proper-span-issue-121267.stderr index 78a84f5f5da66..e7751de6f51ab 100644 --- a/tests/ui/suggestions/lifetimes/explicit-lifetime-suggestion-in-proper-span-issue-121267.stderr +++ b/tests/ui/suggestions/lifetimes/explicit-lifetime-suggestion-in-proper-span-issue-121267.stderr @@ -8,7 +8,7 @@ LL | | LL | | .filter_map(|_| foo(src)) | |_________________________________^ | - = note: hidden type `FilterMap, {closure@...}>` captures lifetime `'_` + = note: hidden type `FilterMap, {closure@...}>` captures lifetime `'_` error: aborting due to 1 previous error From b8c0562ee14be2d8fc62cf49958647ace28594f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 12 Jul 2026 19:32:15 +0000 Subject: [PATCH 08/14] Fix typo --- compiler/rustc_middle/src/ty/print/pretty.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 2d62c36c93376..360708960c6ca 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -2386,7 +2386,7 @@ impl<'tcx> Printer<'tcx> for FmtPrinter<'_, 'tcx> { && self.tcx.item_name(def.did()).as_str().len() < 7 => { // Don't fully truncate types that have "short names" and at most one type or const - // param. We do use the short path for them (only item name instad of full path). + // param. We do use the short path for them (only item name instaed of full path). with_forced_trimmed_paths!(self.pretty_print_type(ty)) } From 23204b1e6e424e8784c3d6a345f7fa51a996ce9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 12 Jul 2026 19:49:45 +0000 Subject: [PATCH 09/14] address review comments --- compiler/rustc_middle/src/ty/print/pretty.rs | 6 +++--- .../higher-ranked-auto-trait-16.assumptions.stderr | 4 ++-- .../higher-ranked-auto-trait-16.no_assumptions.stderr | 4 ++-- tests/ui/borrowck/closure-upvar-named-lifetime.stderr | 4 ++-- ...ue-53432-nested-closure-outlives-borrowed-value.stderr | 2 +- .../issue-95079-missing-move-in-nested-closure.stderr | 2 +- tests/ui/c-variadic/not-async.stderr | 2 +- .../obligation-with-leaking-placeholders.current.stderr | 2 +- .../closures/wrong-closure-arg-suggestion-125325.stderr | 4 ++-- tests/ui/coercion/coerce-expect-unsized-ascribed.stderr | 6 +++--- tests/ui/coroutine/resume-arg-late-bound.stderr | 2 +- .../higher-ranked/relate-bound-region-ice-144033.stderr | 2 +- .../trait-bounds/hrtb-doesnt-borrow-self-2.stderr | 2 +- .../impl-trait/must_outlive_least_region_or_bound.stderr | 2 +- tests/ui/impl-trait/nested-return-type4.stderr | 2 +- tests/ui/impl-trait/static-return-lifetime-infered.stderr | 4 ++-- tests/ui/inference/note-and-explain-ReVar-124973.stderr | 2 +- tests/ui/iterators/generator_returned_from_fn.stderr | 4 ++-- tests/ui/limits/type-length-limit-enforcement.stderr | 2 +- .../dont-suggest-boxing-async-closure-body.stderr | 2 +- ...lifetime-suggestion-in-proper-span-issue-121267.stderr | 2 +- .../lifetimes/missing-lifetimes-in-signature.stderr | 2 +- tests/ui/suggestions/suggest-collect.stderr | 8 ++++---- tests/ui/typeck/return_type_containing_closure.rs | 2 +- tests/ui/typeck/return_type_containing_closure.stderr | 2 +- 25 files changed, 38 insertions(+), 38 deletions(-) diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 360708960c6ca..05bf4ab293229 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -900,7 +900,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { if !self.should_print_verbose() { write!(self, "{coroutine_kind}")?; if self.should_truncate() { - write!(self, "@...}}")?; + write!(self, "}}")?; return Ok(()); } else if coroutine_kind.is_fn_like() { // If we are printing an `async fn` coroutine type, then give the path @@ -968,7 +968,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { if !self.should_print_verbose() { write!(self, "closure")?; if self.should_truncate() { - write!(self, "@...}}")?; + write!(self, "}}")?; return Ok(()); } else { if let Some(did) = did.as_local() { @@ -1032,7 +1032,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { ), } if self.should_truncate() { - write!(self, "@...}}")?; + write!(self, "}}")?; return Ok(()); } else if let Some(did) = did.as_local() { if self.tcx().sess.opts.unstable_opts.span_free_formats { diff --git a/tests/ui/async-await/higher-ranked-auto-trait-16.assumptions.stderr b/tests/ui/async-await/higher-ranked-auto-trait-16.assumptions.stderr index dc6183a45cef5..5915d0d77b679 100644 --- a/tests/ui/async-await/higher-ranked-auto-trait-16.assumptions.stderr +++ b/tests/ui/async-await/higher-ranked-auto-trait-16.assumptions.stderr @@ -6,7 +6,7 @@ LL | | commit_if_ok(&mut ctxt, async |_| todo!()).await; LL | | }); | |______^ implementation of `AsyncFnOnce` is not general enough | - = note: `{async closure@...}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... + = note: `{async closure}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... = note: ...but it actually implements `AsyncFnOnce<(&mut Ctxt<'_>,)>` error: implementation of `AsyncFnOnce` is not general enough @@ -17,7 +17,7 @@ LL | | commit_if_ok(&mut ctxt, async |_| todo!()).await; LL | | }); | |______^ implementation of `AsyncFnOnce` is not general enough | - = note: `{async closure@...}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... + = note: `{async closure}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... = note: ...but it actually implements `AsyncFnOnce<(&mut Ctxt<'_>,)>` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` diff --git a/tests/ui/async-await/higher-ranked-auto-trait-16.no_assumptions.stderr b/tests/ui/async-await/higher-ranked-auto-trait-16.no_assumptions.stderr index dc6183a45cef5..5915d0d77b679 100644 --- a/tests/ui/async-await/higher-ranked-auto-trait-16.no_assumptions.stderr +++ b/tests/ui/async-await/higher-ranked-auto-trait-16.no_assumptions.stderr @@ -6,7 +6,7 @@ LL | | commit_if_ok(&mut ctxt, async |_| todo!()).await; LL | | }); | |______^ implementation of `AsyncFnOnce` is not general enough | - = note: `{async closure@...}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... + = note: `{async closure}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... = note: ...but it actually implements `AsyncFnOnce<(&mut Ctxt<'_>,)>` error: implementation of `AsyncFnOnce` is not general enough @@ -17,7 +17,7 @@ LL | | commit_if_ok(&mut ctxt, async |_| todo!()).await; LL | | }); | |______^ implementation of `AsyncFnOnce` is not general enough | - = note: `{async closure@...}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... + = note: `{async closure}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... = note: ...but it actually implements `AsyncFnOnce<(&mut Ctxt<'_>,)>` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` diff --git a/tests/ui/borrowck/closure-upvar-named-lifetime.stderr b/tests/ui/borrowck/closure-upvar-named-lifetime.stderr index 7b90b07b2f985..a7e9f101fd6ec 100644 --- a/tests/ui/borrowck/closure-upvar-named-lifetime.stderr +++ b/tests/ui/borrowck/closure-upvar-named-lifetime.stderr @@ -39,7 +39,7 @@ error[E0700]: hidden type for `impl Fn(RefCell>)` captur --> $DIR/closure-upvar-named-lifetime.rs:17:5 | LL | fn apply<'a>( - | -- hidden type `{closure@...}` captures the lifetime `'a` as defined here + | -- hidden type `{closure}` captures the lifetime `'a` as defined here LL | f: Arc) + 'a>, LL | ) -> impl Fn(RefCell>) | ----------------------------------------- opaque type defined here @@ -92,7 +92,7 @@ error[E0700]: hidden type for `impl Fn(RefCell>)` captur --> $DIR/closure-upvar-named-lifetime.rs:32:5 | LL | fn apply_box<'a>( - | -- hidden type `{closure@...}` captures the lifetime `'a` as defined here + | -- hidden type `{closure}` captures the lifetime `'a` as defined here LL | f: Box) + 'a>, LL | ) -> impl Fn(RefCell>) | ----------------------------------------- opaque type defined here diff --git a/tests/ui/borrowck/issue-53432-nested-closure-outlives-borrowed-value.stderr b/tests/ui/borrowck/issue-53432-nested-closure-outlives-borrowed-value.stderr index 2fd84517a61bd..2204a4e449618 100644 --- a/tests/ui/borrowck/issue-53432-nested-closure-outlives-borrowed-value.stderr +++ b/tests/ui/borrowck/issue-53432-nested-closure-outlives-borrowed-value.stderr @@ -4,7 +4,7 @@ error: lifetime may not live long enough LL | let _action = move || { | ------- | | | - | | return type of closure `{closure@...}` contains a lifetime `'2` + | | return type of closure `{closure}` contains a lifetime `'2` | lifetime `'1` represents this closure's body LL | || f() // The `nested` closure | ^^^^^^ returning this value requires that `'1` must outlive `'2` diff --git a/tests/ui/borrowck/issue-95079-missing-move-in-nested-closure.stderr b/tests/ui/borrowck/issue-95079-missing-move-in-nested-closure.stderr index c43a983cbf365..a0ba7ba0c4877 100644 --- a/tests/ui/borrowck/issue-95079-missing-move-in-nested-closure.stderr +++ b/tests/ui/borrowck/issue-95079-missing-move-in-nested-closure.stderr @@ -24,7 +24,7 @@ error: lifetime may not live long enough LL | move |()| s.chars().map(|c| format!("{}{}", c, s)) | --------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'1` must outlive `'2` | | | - | | return type of closure `Map, {closure@...}>` contains a lifetime `'2` + | | return type of closure `Map, {closure}>` contains a lifetime `'2` | lifetime `'1` represents this closure's body | = note: closure implements `Fn`, so references to captured variables can't escape the closure diff --git a/tests/ui/c-variadic/not-async.stderr b/tests/ui/c-variadic/not-async.stderr index c6929b3676230..7f0b3e89cdb81 100644 --- a/tests/ui/c-variadic/not-async.stderr +++ b/tests/ui/c-variadic/not-async.stderr @@ -28,7 +28,7 @@ LL | async unsafe extern "C" fn method_cannot_be_async(x: isize, _: ...) {} | | | opaque type defined here | - = note: hidden type `{async fn body@...}` captures lifetime `'_` + = note: hidden type `{async fn body}` captures lifetime `'_` error: aborting due to 4 previous errors diff --git a/tests/ui/closures/deduce-signature/obligation-with-leaking-placeholders.current.stderr b/tests/ui/closures/deduce-signature/obligation-with-leaking-placeholders.current.stderr index cdaa16ac9e807..af20c6b350cc2 100644 --- a/tests/ui/closures/deduce-signature/obligation-with-leaking-placeholders.current.stderr +++ b/tests/ui/closures/deduce-signature/obligation-with-leaking-placeholders.current.stderr @@ -8,7 +8,7 @@ LL | | x.to_string(); LL | | }); | |______^ implementation of `Foo` is not general enough | - = note: `Wrap<{closure@...}>` must implement `Foo<'0>`, for any lifetime `'0`... + = note: `Wrap<{closure}>` must implement `Foo<'0>`, for any lifetime `'0`... = note: ...but it actually implements `Foo<'1>`, for some specific lifetime `'1` error: aborting due to 1 previous error diff --git a/tests/ui/closures/wrong-closure-arg-suggestion-125325.stderr b/tests/ui/closures/wrong-closure-arg-suggestion-125325.stderr index 1b94d59901d22..7961efbdda8bf 100644 --- a/tests/ui/closures/wrong-closure-arg-suggestion-125325.stderr +++ b/tests/ui/closures/wrong-closure-arg-suggestion-125325.stderr @@ -43,7 +43,7 @@ error: lifetime may not live long enough LL | take(|_| to_fn(|_| self.counter += 1)); | --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'1` must outlive `'2` | | | - | | return type of closure `aux::Map<{closure@...}>` contains a lifetime `'2` + | | return type of closure `aux::Map<{closure}>` contains a lifetime `'2` | lifetime `'1` represents this closure's body | = note: closure implements `Fn`, so references to captured variables can't escape the closure @@ -77,7 +77,7 @@ error: lifetime may not live long enough LL | P.flat_map(|_| P.map(|_| self.counter += 1)); | --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'1` must outlive `'2` | | | - | | return type of closure `aux::Map<{closure@...}>` contains a lifetime `'2` + | | return type of closure `aux::Map<{closure}>` contains a lifetime `'2` | lifetime `'1` represents this closure's body | = note: closure implements `Fn`, so references to captured variables can't escape the closure diff --git a/tests/ui/coercion/coerce-expect-unsized-ascribed.stderr b/tests/ui/coercion/coerce-expect-unsized-ascribed.stderr index b682bdac0341d..9927bcf7b2072 100644 --- a/tests/ui/coercion/coerce-expect-unsized-ascribed.stderr +++ b/tests/ui/coercion/coerce-expect-unsized-ascribed.stderr @@ -29,7 +29,7 @@ error[E0308]: mismatched types --> $DIR/coerce-expect-unsized-ascribed.rs:14:27 | LL | let _ = type_ascribe!(Box::new( { |x| (x as u8) }), Box _>); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Box u8>`, found `Box<{closure@...}>` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Box u8>`, found `Box<{closure}>` | = note: expected struct `Box u8>` found struct `Box<{closure@$DIR/coerce-expect-unsized-ascribed.rs:14:39: 14:42}>` @@ -85,7 +85,7 @@ error[E0308]: mismatched types --> $DIR/coerce-expect-unsized-ascribed.rs:22:27 | LL | let _ = type_ascribe!(&{ |x| (x as u8) }, &dyn Fn(i32) -> _); - | ^^^^^^^^^^^^^^^^^^ expected `&dyn Fn(i32) -> u8`, found `&{closure@...}` + | ^^^^^^^^^^^^^^^^^^ expected `&dyn Fn(i32) -> u8`, found `&{closure}` | = note: expected reference `&dyn Fn(i32) -> u8` found reference `&{closure@$DIR/coerce-expect-unsized-ascribed.rs:22:30: 22:33}` @@ -123,7 +123,7 @@ error[E0308]: mismatched types --> $DIR/coerce-expect-unsized-ascribed.rs:27:27 | LL | let _ = type_ascribe!(Box::new(|x| (x as u8)), Box _>); - | ^^^^^^^^^^^^^^^^^^^^^^^ expected `Box u8>`, found `Box<{closure@...}>` + | ^^^^^^^^^^^^^^^^^^^^^^^ expected `Box u8>`, found `Box<{closure}>` | = note: expected struct `Box u8>` found struct `Box<{closure@$DIR/coerce-expect-unsized-ascribed.rs:27:36: 27:39}>` diff --git a/tests/ui/coroutine/resume-arg-late-bound.stderr b/tests/ui/coroutine/resume-arg-late-bound.stderr index 0a6fb8dfcbb6c..dcd812ae4388b 100644 --- a/tests/ui/coroutine/resume-arg-late-bound.stderr +++ b/tests/ui/coroutine/resume-arg-late-bound.stderr @@ -4,7 +4,7 @@ error: implementation of `Coroutine` is not general enough LL | test(gen); | ^^^^^^^^^ implementation of `Coroutine` is not general enough | - = note: `{coroutine@...}` must implement `Coroutine<&'1 mut bool>`, for any lifetime `'1`... + = note: `{coroutine}` must implement `Coroutine<&'1 mut bool>`, for any lifetime `'1`... = note: ...but it actually implements `Coroutine<&'2 mut bool>`, for some specific lifetime `'2` error: aborting due to 1 previous error diff --git a/tests/ui/higher-ranked/relate-bound-region-ice-144033.stderr b/tests/ui/higher-ranked/relate-bound-region-ice-144033.stderr index e9ec3e9dc0707..ec8cff940ac5b 100644 --- a/tests/ui/higher-ranked/relate-bound-region-ice-144033.stderr +++ b/tests/ui/higher-ranked/relate-bound-region-ice-144033.stderr @@ -35,7 +35,7 @@ LL | fn bar(self, _: I) LL | let collection = std::iter::empty::<()>().map(|_| &()); | --- the found closure LL | self.bar(collection) - | --- ^^^^^^^^^^ expected type parameter `I`, found `Map, {closure@...}>` + | --- ^^^^^^^^^^ expected type parameter `I`, found `Map, {closure}>` | | | arguments to this method are incorrect | diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-2.stderr b/tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-2.stderr index 91e65b2b07318..886e102c6452f 100644 --- a/tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-2.stderr +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-2.stderr @@ -1,4 +1,4 @@ -error[E0599]: the method `countx` exists for struct `Filter &u64 {identity::}>, {closure@...}>`, but its trait bounds were not satisfied +error[E0599]: the method `countx` exists for struct `Filter &u64 {identity::}>, {closure}>`, but its trait bounds were not satisfied --> $DIR/hrtb-doesnt-borrow-self-2.rs:112:24 | LL | pub struct Filter { diff --git a/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr b/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr index 4a364c9eb0c6d..5fcbe2f557580 100644 --- a/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr +++ b/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr @@ -112,7 +112,7 @@ error[E0700]: hidden type for `impl Fn(&'a u32)` captures lifetime that does not LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) { | -- ---------------- opaque type defined here | | - | hidden type `{closure@...}` captures the lifetime `'b` as defined here + | hidden type `{closure}` captures the lifetime `'b` as defined here LL | move |_| println!("{}", y) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/tests/ui/impl-trait/nested-return-type4.stderr b/tests/ui/impl-trait/nested-return-type4.stderr index 63f3bfcdda950..cc35e1c8c4a31 100644 --- a/tests/ui/impl-trait/nested-return-type4.stderr +++ b/tests/ui/impl-trait/nested-return-type4.stderr @@ -4,7 +4,7 @@ error[E0700]: hidden type for `impl Future` captures lifeti LL | fn test<'s: 's>(s: &'s str) -> impl std::future::Future { | -- --------------------------------------------- opaque type defined here | | - | hidden type `{async block@...}` captures the lifetime `'s` as defined here + | hidden type `{async block}` captures the lifetime `'s` as defined here LL | async move { let _s = s; } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/tests/ui/impl-trait/static-return-lifetime-infered.stderr b/tests/ui/impl-trait/static-return-lifetime-infered.stderr index 093bd3d227527..17e975f9d19bf 100644 --- a/tests/ui/impl-trait/static-return-lifetime-infered.stderr +++ b/tests/ui/impl-trait/static-return-lifetime-infered.stderr @@ -4,7 +4,7 @@ error[E0700]: hidden type for `impl Iterator` captures lifetime that LL | fn iter_values_anon(&self) -> impl Iterator { | ----- ----------------------- opaque type defined here | | - | hidden type `Map, {closure@...}>` captures the anonymous lifetime defined here + | hidden type `Map, {closure}>` captures the anonymous lifetime defined here LL | self.x.iter().map(|a| a.0) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | @@ -19,7 +19,7 @@ error[E0700]: hidden type for `impl Iterator` captures lifetime that LL | fn iter_values<'a>(&'a self) -> impl Iterator { | -- ----------------------- opaque type defined here | | - | hidden type `Map, {closure@...}>` captures the lifetime `'a` as defined here + | hidden type `Map, {closure}>` captures the lifetime `'a` as defined here LL | self.x.iter().map(|a| a.0) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/tests/ui/inference/note-and-explain-ReVar-124973.stderr b/tests/ui/inference/note-and-explain-ReVar-124973.stderr index fa5ba771980f4..d9a049eaa424e 100644 --- a/tests/ui/inference/note-and-explain-ReVar-124973.stderr +++ b/tests/ui/inference/note-and-explain-ReVar-124973.stderr @@ -12,7 +12,7 @@ LL | async unsafe extern "C" fn multiple_named_lifetimes<'a, 'b>(_: u8, _: ...) | | | opaque type defined here | - = note: hidden type `{async fn body@...}` captures lifetime `'_` + = note: hidden type `{async fn body}` captures lifetime `'_` error: aborting due to 2 previous errors diff --git a/tests/ui/iterators/generator_returned_from_fn.stderr b/tests/ui/iterators/generator_returned_from_fn.stderr index f4620b958f0c6..8b62790102e5c 100644 --- a/tests/ui/iterators/generator_returned_from_fn.stderr +++ b/tests/ui/iterators/generator_returned_from_fn.stderr @@ -28,7 +28,7 @@ error[E0700]: hidden type for `impl FnOnce() -> impl Iterator` captu LL | fn capture_move_once(a: &u32) -> impl FnOnce() -> impl Iterator { | ---- ------------------------------------------ opaque type defined here | | - | hidden type `{gen closure@...}` captures the anonymous lifetime defined here + | hidden type `{gen closure}` captures the anonymous lifetime defined here LL | iter! { move || { | _____________^ LL | | @@ -49,7 +49,7 @@ error[E0700]: hidden type for `impl Iterator` captures lifetime that LL | fn capture_move_once(a: &u32) -> impl FnOnce() -> impl Iterator { | ---- ------------------------- opaque type defined here | | - | hidden type `{gen closure body@...}` captures the anonymous lifetime defined here + | hidden type `{gen closure body}` captures the anonymous lifetime defined here LL | iter! { move || { | _____________^ LL | | diff --git a/tests/ui/limits/type-length-limit-enforcement.stderr b/tests/ui/limits/type-length-limit-enforcement.stderr index 0313f212d3f7e..8ceca20c6abe0 100644 --- a/tests/ui/limits/type-length-limit-enforcement.stderr +++ b/tests/ui/limits/type-length-limit-enforcement.stderr @@ -8,7 +8,7 @@ LL | drop::>(None); = note: the full name for the type has been written to '$TEST_BUILD_DIR/type-length-limit-enforcement.long-type-$LONG_TYPE_HASH.txt' = note: consider using `--verbose` to print the full type name to the console -error: reached the type-length limit while instantiating `<{closure@...} as FnMut<()>>::call_mut` +error: reached the type-length limit while instantiating `<{closure} as FnMut<()>>::call_mut` | = help: consider adding a `#![type_length_limit="10"]` attribute to your crate = note: the full name for the type has been written to '$TEST_BUILD_DIR/type-length-limit-enforcement.long-type-$LONG_TYPE_HASH.txt' diff --git a/tests/ui/suggestions/dont-suggest-boxing-async-closure-body.stderr b/tests/ui/suggestions/dont-suggest-boxing-async-closure-body.stderr index 430432b99901e..50bc92c85b179 100644 --- a/tests/ui/suggestions/dont-suggest-boxing-async-closure-body.stderr +++ b/tests/ui/suggestions/dont-suggest-boxing-async-closure-body.stderr @@ -18,7 +18,7 @@ error[E0308]: mismatched types --> $DIR/dont-suggest-boxing-async-closure-body.rs:11:9 | LL | bar(async move || {}); - | --- ^^^^^^^^^^^^^^^^ expected `Box _>`, found `{async closure@...}` + | --- ^^^^^^^^^^^^^^^^ expected `Box _>`, found `{async closure}` | | | arguments to this function are incorrect | diff --git a/tests/ui/suggestions/lifetimes/explicit-lifetime-suggestion-in-proper-span-issue-121267.stderr b/tests/ui/suggestions/lifetimes/explicit-lifetime-suggestion-in-proper-span-issue-121267.stderr index e7751de6f51ab..6d1bc74e4bd66 100644 --- a/tests/ui/suggestions/lifetimes/explicit-lifetime-suggestion-in-proper-span-issue-121267.stderr +++ b/tests/ui/suggestions/lifetimes/explicit-lifetime-suggestion-in-proper-span-issue-121267.stderr @@ -8,7 +8,7 @@ LL | | LL | | .filter_map(|_| foo(src)) | |_________________________________^ | - = note: hidden type `FilterMap, {closure@...}>` captures lifetime `'_` + = note: hidden type `FilterMap, {closure}>` captures lifetime `'_` error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr index ac4ba68aa36a6..26115c749383f 100644 --- a/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr +++ b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr @@ -15,7 +15,7 @@ error[E0700]: hidden type for `impl FnOnce()` captures lifetime that does not ap LL | fn foo(g: G, dest: &mut T) -> impl FnOnce() | ------ ------------- opaque type defined here | | - | hidden type `{closure@...}` captures the anonymous lifetime defined here + | hidden type `{closure}` captures the anonymous lifetime defined here ... LL | / move || { LL | | diff --git a/tests/ui/suggestions/suggest-collect.stderr b/tests/ui/suggestions/suggest-collect.stderr index a7bca2bbcaa7b..d053166817072 100644 --- a/tests/ui/suggestions/suggest-collect.stderr +++ b/tests/ui/suggestions/suggest-collect.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/suggest-collect.rs:2:22 | LL | let _x: String = "hello".chars().map(|c| c); - | ------ ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `String`, found `Map, {closure@...}>` + | ------ ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `String`, found `Map, {closure}>` | | | expected due to this | @@ -17,7 +17,7 @@ error[E0308]: mismatched types --> $DIR/suggest-collect.rs:6:24 | LL | let _y: Vec = vec![1, 2, 3].into_iter().map(|x| x); - | -------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Vec`, found `Map, {closure@...}>` + | -------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Vec`, found `Map, {closure}>` | | | expected due to this | @@ -32,7 +32,7 @@ error[E0308]: mismatched types --> $DIR/suggest-collect.rs:10:36 | LL | let res: Result, _> = ["1", "2"].into_iter().map(|s| s.parse::()); - | ------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Result, _>`, found `Map, {closure@...}>` + | ------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Result, _>`, found `Map, {closure}>` | | | expected due to this | @@ -47,7 +47,7 @@ error[E0308]: mismatched types --> $DIR/suggest-collect.rs:13:40 | LL | let (a, b): (Vec, Vec) = vec![1, 2].into_iter().map(|x| (x, x)); - | -------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `(Vec, Vec)`, found `Map, {closure@...}>` + | -------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `(Vec, Vec)`, found `Map, {closure}>` | | | expected due to this | diff --git a/tests/ui/typeck/return_type_containing_closure.rs b/tests/ui/typeck/return_type_containing_closure.rs index a9bb89bae2d6a..6ac7ca2296001 100644 --- a/tests/ui/typeck/return_type_containing_closure.rs +++ b/tests/ui/typeck/return_type_containing_closure.rs @@ -2,7 +2,7 @@ fn foo() { //~ HELP try adding a return type vec!['a'].iter().map(|c| c) //~^ ERROR mismatched types [E0308] - //~| NOTE expected `()`, found `Map, {closure@...}>` + //~| NOTE expected `()`, found `Map, {closure}>` //~| NOTE expected unit type `()` //~| HELP consider using a semicolon here } diff --git a/tests/ui/typeck/return_type_containing_closure.stderr b/tests/ui/typeck/return_type_containing_closure.stderr index a60bf79a57b8a..075f131dcdf19 100644 --- a/tests/ui/typeck/return_type_containing_closure.stderr +++ b/tests/ui/typeck/return_type_containing_closure.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/return_type_containing_closure.rs:3:5 | LL | vec!['a'].iter().map(|c| c) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `Map, {closure@...}>` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `Map, {closure}>` | = note: expected unit type `()` found struct `Map, {closure@$DIR/return_type_containing_closure.rs:3:26: 3:29}>` From ec430cbf951955236999e8243cb595339f154b7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 12 Jul 2026 22:00:38 +0000 Subject: [PATCH 10/14] tidy --- compiler/rustc_middle/src/ty/print/pretty.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 05bf4ab293229..6fd3255b46b54 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -2386,7 +2386,7 @@ impl<'tcx> Printer<'tcx> for FmtPrinter<'_, 'tcx> { && self.tcx.item_name(def.did()).as_str().len() < 7 => { // Don't fully truncate types that have "short names" and at most one type or const - // param. We do use the short path for them (only item name instaed of full path). + // param. We do use the short path for them (only item name instead of full path). with_forced_trimmed_paths!(self.pretty_print_type(ty)) } From fa69dbd44b810e312df4f613a48e052bf10d5c70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 13 Jul 2026 17:06:19 +0000 Subject: [PATCH 11/14] Do not change closure short type rendering --- compiler/rustc_middle/src/ty/print/pretty.rs | 12 +++--------- .../higher-ranked-auto-trait-16.assumptions.stderr | 4 ++-- ...higher-ranked-auto-trait-16.no_assumptions.stderr | 4 ++-- .../ui/borrowck/closure-upvar-named-lifetime.stderr | 4 ++-- ...432-nested-closure-outlives-borrowed-value.stderr | 2 +- ...issue-95079-missing-move-in-nested-closure.stderr | 2 +- tests/ui/c-variadic/not-async.stderr | 2 +- ...ligation-with-leaking-placeholders.current.stderr | 2 +- .../wrong-closure-arg-suggestion-125325.stderr | 4 ++-- .../coercion/coerce-expect-unsized-ascribed.stderr | 6 +++--- tests/ui/coroutine/resume-arg-late-bound.stderr | 2 +- .../relate-bound-region-ice-144033.stderr | 2 +- .../trait-bounds/hrtb-doesnt-borrow-self-2.stderr | 2 +- .../must_outlive_least_region_or_bound.stderr | 2 +- tests/ui/impl-trait/nested-return-type4.stderr | 2 +- .../impl-trait/static-return-lifetime-infered.stderr | 4 ++-- .../inference/note-and-explain-ReVar-124973.stderr | 2 +- tests/ui/iterators/generator_returned_from_fn.stderr | 4 ++-- tests/ui/limits/type-length-limit-enforcement.stderr | 2 +- .../dont-suggest-boxing-async-closure-body.stderr | 2 +- ...ime-suggestion-in-proper-span-issue-121267.stderr | 2 +- .../lifetimes/missing-lifetimes-in-signature.stderr | 2 +- tests/ui/suggestions/suggest-collect.stderr | 8 ++++---- tests/ui/typeck/return_type_containing_closure.rs | 2 +- .../ui/typeck/return_type_containing_closure.stderr | 2 +- 25 files changed, 38 insertions(+), 44 deletions(-) diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 6fd3255b46b54..f336e4ce9af24 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -899,10 +899,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { if !self.should_print_verbose() { write!(self, "{coroutine_kind}")?; - if self.should_truncate() { - write!(self, "}}")?; - return Ok(()); - } else if coroutine_kind.is_fn_like() { + if coroutine_kind.is_fn_like() { // If we are printing an `async fn` coroutine type, then give the path // of the fn, instead of its span, because that will in most cases be // more helpful for the reader than just a source location. @@ -968,7 +965,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { if !self.should_print_verbose() { write!(self, "closure")?; if self.should_truncate() { - write!(self, "}}")?; + write!(self, "@...}}")?; return Ok(()); } else { if let Some(did) = did.as_local() { @@ -1031,10 +1028,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { "coroutine from coroutine-closure should have CoroutineSource::Closure" ), } - if self.should_truncate() { - write!(self, "}}")?; - return Ok(()); - } else if let Some(did) = did.as_local() { + if let Some(did) = did.as_local() { if self.tcx().sess.opts.unstable_opts.span_free_formats { write!(self, "@")?; self.print_def_path(did.to_def_id(), args)?; diff --git a/tests/ui/async-await/higher-ranked-auto-trait-16.assumptions.stderr b/tests/ui/async-await/higher-ranked-auto-trait-16.assumptions.stderr index 5915d0d77b679..412c31b1bd843 100644 --- a/tests/ui/async-await/higher-ranked-auto-trait-16.assumptions.stderr +++ b/tests/ui/async-await/higher-ranked-auto-trait-16.assumptions.stderr @@ -6,7 +6,7 @@ LL | | commit_if_ok(&mut ctxt, async |_| todo!()).await; LL | | }); | |______^ implementation of `AsyncFnOnce` is not general enough | - = note: `{async closure}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... + = note: `{async closure@$DIR/higher-ranked-auto-trait-16.rs:19:33: 19:42}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... = note: ...but it actually implements `AsyncFnOnce<(&mut Ctxt<'_>,)>` error: implementation of `AsyncFnOnce` is not general enough @@ -17,7 +17,7 @@ LL | | commit_if_ok(&mut ctxt, async |_| todo!()).await; LL | | }); | |______^ implementation of `AsyncFnOnce` is not general enough | - = note: `{async closure}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... + = note: `{async closure@$DIR/higher-ranked-auto-trait-16.rs:19:33: 19:42}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... = note: ...but it actually implements `AsyncFnOnce<(&mut Ctxt<'_>,)>` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` diff --git a/tests/ui/async-await/higher-ranked-auto-trait-16.no_assumptions.stderr b/tests/ui/async-await/higher-ranked-auto-trait-16.no_assumptions.stderr index 5915d0d77b679..412c31b1bd843 100644 --- a/tests/ui/async-await/higher-ranked-auto-trait-16.no_assumptions.stderr +++ b/tests/ui/async-await/higher-ranked-auto-trait-16.no_assumptions.stderr @@ -6,7 +6,7 @@ LL | | commit_if_ok(&mut ctxt, async |_| todo!()).await; LL | | }); | |______^ implementation of `AsyncFnOnce` is not general enough | - = note: `{async closure}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... + = note: `{async closure@$DIR/higher-ranked-auto-trait-16.rs:19:33: 19:42}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... = note: ...but it actually implements `AsyncFnOnce<(&mut Ctxt<'_>,)>` error: implementation of `AsyncFnOnce` is not general enough @@ -17,7 +17,7 @@ LL | | commit_if_ok(&mut ctxt, async |_| todo!()).await; LL | | }); | |______^ implementation of `AsyncFnOnce` is not general enough | - = note: `{async closure}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... + = note: `{async closure@$DIR/higher-ranked-auto-trait-16.rs:19:33: 19:42}` must implement `AsyncFnOnce<(&mut Ctxt<'1>,)>`, for any two lifetimes `'0` and `'1`... = note: ...but it actually implements `AsyncFnOnce<(&mut Ctxt<'_>,)>` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` diff --git a/tests/ui/borrowck/closure-upvar-named-lifetime.stderr b/tests/ui/borrowck/closure-upvar-named-lifetime.stderr index a7e9f101fd6ec..7b90b07b2f985 100644 --- a/tests/ui/borrowck/closure-upvar-named-lifetime.stderr +++ b/tests/ui/borrowck/closure-upvar-named-lifetime.stderr @@ -39,7 +39,7 @@ error[E0700]: hidden type for `impl Fn(RefCell>)` captur --> $DIR/closure-upvar-named-lifetime.rs:17:5 | LL | fn apply<'a>( - | -- hidden type `{closure}` captures the lifetime `'a` as defined here + | -- hidden type `{closure@...}` captures the lifetime `'a` as defined here LL | f: Arc) + 'a>, LL | ) -> impl Fn(RefCell>) | ----------------------------------------- opaque type defined here @@ -92,7 +92,7 @@ error[E0700]: hidden type for `impl Fn(RefCell>)` captur --> $DIR/closure-upvar-named-lifetime.rs:32:5 | LL | fn apply_box<'a>( - | -- hidden type `{closure}` captures the lifetime `'a` as defined here + | -- hidden type `{closure@...}` captures the lifetime `'a` as defined here LL | f: Box) + 'a>, LL | ) -> impl Fn(RefCell>) | ----------------------------------------- opaque type defined here diff --git a/tests/ui/borrowck/issue-53432-nested-closure-outlives-borrowed-value.stderr b/tests/ui/borrowck/issue-53432-nested-closure-outlives-borrowed-value.stderr index 2204a4e449618..2fd84517a61bd 100644 --- a/tests/ui/borrowck/issue-53432-nested-closure-outlives-borrowed-value.stderr +++ b/tests/ui/borrowck/issue-53432-nested-closure-outlives-borrowed-value.stderr @@ -4,7 +4,7 @@ error: lifetime may not live long enough LL | let _action = move || { | ------- | | | - | | return type of closure `{closure}` contains a lifetime `'2` + | | return type of closure `{closure@...}` contains a lifetime `'2` | lifetime `'1` represents this closure's body LL | || f() // The `nested` closure | ^^^^^^ returning this value requires that `'1` must outlive `'2` diff --git a/tests/ui/borrowck/issue-95079-missing-move-in-nested-closure.stderr b/tests/ui/borrowck/issue-95079-missing-move-in-nested-closure.stderr index a0ba7ba0c4877..c43a983cbf365 100644 --- a/tests/ui/borrowck/issue-95079-missing-move-in-nested-closure.stderr +++ b/tests/ui/borrowck/issue-95079-missing-move-in-nested-closure.stderr @@ -24,7 +24,7 @@ error: lifetime may not live long enough LL | move |()| s.chars().map(|c| format!("{}{}", c, s)) | --------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'1` must outlive `'2` | | | - | | return type of closure `Map, {closure}>` contains a lifetime `'2` + | | return type of closure `Map, {closure@...}>` contains a lifetime `'2` | lifetime `'1` represents this closure's body | = note: closure implements `Fn`, so references to captured variables can't escape the closure diff --git a/tests/ui/c-variadic/not-async.stderr b/tests/ui/c-variadic/not-async.stderr index 7f0b3e89cdb81..bb8cc64e15fa4 100644 --- a/tests/ui/c-variadic/not-async.stderr +++ b/tests/ui/c-variadic/not-async.stderr @@ -28,7 +28,7 @@ LL | async unsafe extern "C" fn method_cannot_be_async(x: isize, _: ...) {} | | | opaque type defined here | - = note: hidden type `{async fn body}` captures lifetime `'_` + = note: hidden type `{async fn body of S::method_cannot_be_async()}` captures lifetime `'_` error: aborting due to 4 previous errors diff --git a/tests/ui/closures/deduce-signature/obligation-with-leaking-placeholders.current.stderr b/tests/ui/closures/deduce-signature/obligation-with-leaking-placeholders.current.stderr index af20c6b350cc2..cdaa16ac9e807 100644 --- a/tests/ui/closures/deduce-signature/obligation-with-leaking-placeholders.current.stderr +++ b/tests/ui/closures/deduce-signature/obligation-with-leaking-placeholders.current.stderr @@ -8,7 +8,7 @@ LL | | x.to_string(); LL | | }); | |______^ implementation of `Foo` is not general enough | - = note: `Wrap<{closure}>` must implement `Foo<'0>`, for any lifetime `'0`... + = note: `Wrap<{closure@...}>` must implement `Foo<'0>`, for any lifetime `'0`... = note: ...but it actually implements `Foo<'1>`, for some specific lifetime `'1` error: aborting due to 1 previous error diff --git a/tests/ui/closures/wrong-closure-arg-suggestion-125325.stderr b/tests/ui/closures/wrong-closure-arg-suggestion-125325.stderr index 7961efbdda8bf..1b94d59901d22 100644 --- a/tests/ui/closures/wrong-closure-arg-suggestion-125325.stderr +++ b/tests/ui/closures/wrong-closure-arg-suggestion-125325.stderr @@ -43,7 +43,7 @@ error: lifetime may not live long enough LL | take(|_| to_fn(|_| self.counter += 1)); | --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'1` must outlive `'2` | | | - | | return type of closure `aux::Map<{closure}>` contains a lifetime `'2` + | | return type of closure `aux::Map<{closure@...}>` contains a lifetime `'2` | lifetime `'1` represents this closure's body | = note: closure implements `Fn`, so references to captured variables can't escape the closure @@ -77,7 +77,7 @@ error: lifetime may not live long enough LL | P.flat_map(|_| P.map(|_| self.counter += 1)); | --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'1` must outlive `'2` | | | - | | return type of closure `aux::Map<{closure}>` contains a lifetime `'2` + | | return type of closure `aux::Map<{closure@...}>` contains a lifetime `'2` | lifetime `'1` represents this closure's body | = note: closure implements `Fn`, so references to captured variables can't escape the closure diff --git a/tests/ui/coercion/coerce-expect-unsized-ascribed.stderr b/tests/ui/coercion/coerce-expect-unsized-ascribed.stderr index 9927bcf7b2072..b682bdac0341d 100644 --- a/tests/ui/coercion/coerce-expect-unsized-ascribed.stderr +++ b/tests/ui/coercion/coerce-expect-unsized-ascribed.stderr @@ -29,7 +29,7 @@ error[E0308]: mismatched types --> $DIR/coerce-expect-unsized-ascribed.rs:14:27 | LL | let _ = type_ascribe!(Box::new( { |x| (x as u8) }), Box _>); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Box u8>`, found `Box<{closure}>` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Box u8>`, found `Box<{closure@...}>` | = note: expected struct `Box u8>` found struct `Box<{closure@$DIR/coerce-expect-unsized-ascribed.rs:14:39: 14:42}>` @@ -85,7 +85,7 @@ error[E0308]: mismatched types --> $DIR/coerce-expect-unsized-ascribed.rs:22:27 | LL | let _ = type_ascribe!(&{ |x| (x as u8) }, &dyn Fn(i32) -> _); - | ^^^^^^^^^^^^^^^^^^ expected `&dyn Fn(i32) -> u8`, found `&{closure}` + | ^^^^^^^^^^^^^^^^^^ expected `&dyn Fn(i32) -> u8`, found `&{closure@...}` | = note: expected reference `&dyn Fn(i32) -> u8` found reference `&{closure@$DIR/coerce-expect-unsized-ascribed.rs:22:30: 22:33}` @@ -123,7 +123,7 @@ error[E0308]: mismatched types --> $DIR/coerce-expect-unsized-ascribed.rs:27:27 | LL | let _ = type_ascribe!(Box::new(|x| (x as u8)), Box _>); - | ^^^^^^^^^^^^^^^^^^^^^^^ expected `Box u8>`, found `Box<{closure}>` + | ^^^^^^^^^^^^^^^^^^^^^^^ expected `Box u8>`, found `Box<{closure@...}>` | = note: expected struct `Box u8>` found struct `Box<{closure@$DIR/coerce-expect-unsized-ascribed.rs:27:36: 27:39}>` diff --git a/tests/ui/coroutine/resume-arg-late-bound.stderr b/tests/ui/coroutine/resume-arg-late-bound.stderr index dcd812ae4388b..646abaf4f7bde 100644 --- a/tests/ui/coroutine/resume-arg-late-bound.stderr +++ b/tests/ui/coroutine/resume-arg-late-bound.stderr @@ -4,7 +4,7 @@ error: implementation of `Coroutine` is not general enough LL | test(gen); | ^^^^^^^^^ implementation of `Coroutine` is not general enough | - = note: `{coroutine}` must implement `Coroutine<&'1 mut bool>`, for any lifetime `'1`... + = note: `{coroutine@$DIR/resume-arg-late-bound.rs:11:28: 11:44}` must implement `Coroutine<&'1 mut bool>`, for any lifetime `'1`... = note: ...but it actually implements `Coroutine<&'2 mut bool>`, for some specific lifetime `'2` error: aborting due to 1 previous error diff --git a/tests/ui/higher-ranked/relate-bound-region-ice-144033.stderr b/tests/ui/higher-ranked/relate-bound-region-ice-144033.stderr index ec8cff940ac5b..e9ec3e9dc0707 100644 --- a/tests/ui/higher-ranked/relate-bound-region-ice-144033.stderr +++ b/tests/ui/higher-ranked/relate-bound-region-ice-144033.stderr @@ -35,7 +35,7 @@ LL | fn bar(self, _: I) LL | let collection = std::iter::empty::<()>().map(|_| &()); | --- the found closure LL | self.bar(collection) - | --- ^^^^^^^^^^ expected type parameter `I`, found `Map, {closure}>` + | --- ^^^^^^^^^^ expected type parameter `I`, found `Map, {closure@...}>` | | | arguments to this method are incorrect | diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-2.stderr b/tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-2.stderr index 886e102c6452f..91e65b2b07318 100644 --- a/tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-2.stderr +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-2.stderr @@ -1,4 +1,4 @@ -error[E0599]: the method `countx` exists for struct `Filter &u64 {identity::}>, {closure}>`, but its trait bounds were not satisfied +error[E0599]: the method `countx` exists for struct `Filter &u64 {identity::}>, {closure@...}>`, but its trait bounds were not satisfied --> $DIR/hrtb-doesnt-borrow-self-2.rs:112:24 | LL | pub struct Filter { diff --git a/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr b/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr index 5fcbe2f557580..4a364c9eb0c6d 100644 --- a/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr +++ b/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr @@ -112,7 +112,7 @@ error[E0700]: hidden type for `impl Fn(&'a u32)` captures lifetime that does not LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) { | -- ---------------- opaque type defined here | | - | hidden type `{closure}` captures the lifetime `'b` as defined here + | hidden type `{closure@...}` captures the lifetime `'b` as defined here LL | move |_| println!("{}", y) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/tests/ui/impl-trait/nested-return-type4.stderr b/tests/ui/impl-trait/nested-return-type4.stderr index cc35e1c8c4a31..407800eff1894 100644 --- a/tests/ui/impl-trait/nested-return-type4.stderr +++ b/tests/ui/impl-trait/nested-return-type4.stderr @@ -4,7 +4,7 @@ error[E0700]: hidden type for `impl Future` captures lifeti LL | fn test<'s: 's>(s: &'s str) -> impl std::future::Future { | -- --------------------------------------------- opaque type defined here | | - | hidden type `{async block}` captures the lifetime `'s` as defined here + | hidden type `{async block@$DIR/nested-return-type4.rs:4:5: 4:15}` captures the lifetime `'s` as defined here LL | async move { let _s = s; } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/tests/ui/impl-trait/static-return-lifetime-infered.stderr b/tests/ui/impl-trait/static-return-lifetime-infered.stderr index 17e975f9d19bf..093bd3d227527 100644 --- a/tests/ui/impl-trait/static-return-lifetime-infered.stderr +++ b/tests/ui/impl-trait/static-return-lifetime-infered.stderr @@ -4,7 +4,7 @@ error[E0700]: hidden type for `impl Iterator` captures lifetime that LL | fn iter_values_anon(&self) -> impl Iterator { | ----- ----------------------- opaque type defined here | | - | hidden type `Map, {closure}>` captures the anonymous lifetime defined here + | hidden type `Map, {closure@...}>` captures the anonymous lifetime defined here LL | self.x.iter().map(|a| a.0) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | @@ -19,7 +19,7 @@ error[E0700]: hidden type for `impl Iterator` captures lifetime that LL | fn iter_values<'a>(&'a self) -> impl Iterator { | -- ----------------------- opaque type defined here | | - | hidden type `Map, {closure}>` captures the lifetime `'a` as defined here + | hidden type `Map, {closure@...}>` captures the lifetime `'a` as defined here LL | self.x.iter().map(|a| a.0) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/tests/ui/inference/note-and-explain-ReVar-124973.stderr b/tests/ui/inference/note-and-explain-ReVar-124973.stderr index d9a049eaa424e..2b5e79e9a1c64 100644 --- a/tests/ui/inference/note-and-explain-ReVar-124973.stderr +++ b/tests/ui/inference/note-and-explain-ReVar-124973.stderr @@ -12,7 +12,7 @@ LL | async unsafe extern "C" fn multiple_named_lifetimes<'a, 'b>(_: u8, _: ...) | | | opaque type defined here | - = note: hidden type `{async fn body}` captures lifetime `'_` + = note: hidden type `{async fn body of multiple_named_lifetimes<'a, 'b>()}` captures lifetime `'_` error: aborting due to 2 previous errors diff --git a/tests/ui/iterators/generator_returned_from_fn.stderr b/tests/ui/iterators/generator_returned_from_fn.stderr index 8b62790102e5c..8bec119ddbc01 100644 --- a/tests/ui/iterators/generator_returned_from_fn.stderr +++ b/tests/ui/iterators/generator_returned_from_fn.stderr @@ -28,7 +28,7 @@ error[E0700]: hidden type for `impl FnOnce() -> impl Iterator` captu LL | fn capture_move_once(a: &u32) -> impl FnOnce() -> impl Iterator { | ---- ------------------------------------------ opaque type defined here | | - | hidden type `{gen closure}` captures the anonymous lifetime defined here + | hidden type `{gen closure@$DIR/generator_returned_from_fn.rs:43:13: 43:20}` captures the anonymous lifetime defined here LL | iter! { move || { | _____________^ LL | | @@ -49,7 +49,7 @@ error[E0700]: hidden type for `impl Iterator` captures lifetime that LL | fn capture_move_once(a: &u32) -> impl FnOnce() -> impl Iterator { | ---- ------------------------- opaque type defined here | | - | hidden type `{gen closure body}` captures the anonymous lifetime defined here + | hidden type `{gen closure body@$DIR/generator_returned_from_fn.rs:43:21: 50:6}` captures the anonymous lifetime defined here LL | iter! { move || { | _____________^ LL | | diff --git a/tests/ui/limits/type-length-limit-enforcement.stderr b/tests/ui/limits/type-length-limit-enforcement.stderr index 8ceca20c6abe0..0313f212d3f7e 100644 --- a/tests/ui/limits/type-length-limit-enforcement.stderr +++ b/tests/ui/limits/type-length-limit-enforcement.stderr @@ -8,7 +8,7 @@ LL | drop::>(None); = note: the full name for the type has been written to '$TEST_BUILD_DIR/type-length-limit-enforcement.long-type-$LONG_TYPE_HASH.txt' = note: consider using `--verbose` to print the full type name to the console -error: reached the type-length limit while instantiating `<{closure} as FnMut<()>>::call_mut` +error: reached the type-length limit while instantiating `<{closure@...} as FnMut<()>>::call_mut` | = help: consider adding a `#![type_length_limit="10"]` attribute to your crate = note: the full name for the type has been written to '$TEST_BUILD_DIR/type-length-limit-enforcement.long-type-$LONG_TYPE_HASH.txt' diff --git a/tests/ui/suggestions/dont-suggest-boxing-async-closure-body.stderr b/tests/ui/suggestions/dont-suggest-boxing-async-closure-body.stderr index 50bc92c85b179..abf8e2d824b5d 100644 --- a/tests/ui/suggestions/dont-suggest-boxing-async-closure-body.stderr +++ b/tests/ui/suggestions/dont-suggest-boxing-async-closure-body.stderr @@ -18,7 +18,7 @@ error[E0308]: mismatched types --> $DIR/dont-suggest-boxing-async-closure-body.rs:11:9 | LL | bar(async move || {}); - | --- ^^^^^^^^^^^^^^^^ expected `Box _>`, found `{async closure}` + | --- ^^^^^^^^^^^^^^^^ expected `Box _>`, found `{async closure@dont-suggest-boxing-async-closure-body.rs:11:9}` | | | arguments to this function are incorrect | diff --git a/tests/ui/suggestions/lifetimes/explicit-lifetime-suggestion-in-proper-span-issue-121267.stderr b/tests/ui/suggestions/lifetimes/explicit-lifetime-suggestion-in-proper-span-issue-121267.stderr index 6d1bc74e4bd66..e7751de6f51ab 100644 --- a/tests/ui/suggestions/lifetimes/explicit-lifetime-suggestion-in-proper-span-issue-121267.stderr +++ b/tests/ui/suggestions/lifetimes/explicit-lifetime-suggestion-in-proper-span-issue-121267.stderr @@ -8,7 +8,7 @@ LL | | LL | | .filter_map(|_| foo(src)) | |_________________________________^ | - = note: hidden type `FilterMap, {closure}>` captures lifetime `'_` + = note: hidden type `FilterMap, {closure@...}>` captures lifetime `'_` error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr index 26115c749383f..ac4ba68aa36a6 100644 --- a/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr +++ b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr @@ -15,7 +15,7 @@ error[E0700]: hidden type for `impl FnOnce()` captures lifetime that does not ap LL | fn foo(g: G, dest: &mut T) -> impl FnOnce() | ------ ------------- opaque type defined here | | - | hidden type `{closure}` captures the anonymous lifetime defined here + | hidden type `{closure@...}` captures the anonymous lifetime defined here ... LL | / move || { LL | | diff --git a/tests/ui/suggestions/suggest-collect.stderr b/tests/ui/suggestions/suggest-collect.stderr index d053166817072..a7bca2bbcaa7b 100644 --- a/tests/ui/suggestions/suggest-collect.stderr +++ b/tests/ui/suggestions/suggest-collect.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/suggest-collect.rs:2:22 | LL | let _x: String = "hello".chars().map(|c| c); - | ------ ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `String`, found `Map, {closure}>` + | ------ ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `String`, found `Map, {closure@...}>` | | | expected due to this | @@ -17,7 +17,7 @@ error[E0308]: mismatched types --> $DIR/suggest-collect.rs:6:24 | LL | let _y: Vec = vec![1, 2, 3].into_iter().map(|x| x); - | -------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Vec`, found `Map, {closure}>` + | -------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Vec`, found `Map, {closure@...}>` | | | expected due to this | @@ -32,7 +32,7 @@ error[E0308]: mismatched types --> $DIR/suggest-collect.rs:10:36 | LL | let res: Result, _> = ["1", "2"].into_iter().map(|s| s.parse::()); - | ------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Result, _>`, found `Map, {closure}>` + | ------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Result, _>`, found `Map, {closure@...}>` | | | expected due to this | @@ -47,7 +47,7 @@ error[E0308]: mismatched types --> $DIR/suggest-collect.rs:13:40 | LL | let (a, b): (Vec, Vec) = vec![1, 2].into_iter().map(|x| (x, x)); - | -------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `(Vec, Vec)`, found `Map, {closure}>` + | -------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `(Vec, Vec)`, found `Map, {closure@...}>` | | | expected due to this | diff --git a/tests/ui/typeck/return_type_containing_closure.rs b/tests/ui/typeck/return_type_containing_closure.rs index 6ac7ca2296001..a9bb89bae2d6a 100644 --- a/tests/ui/typeck/return_type_containing_closure.rs +++ b/tests/ui/typeck/return_type_containing_closure.rs @@ -2,7 +2,7 @@ fn foo() { //~ HELP try adding a return type vec!['a'].iter().map(|c| c) //~^ ERROR mismatched types [E0308] - //~| NOTE expected `()`, found `Map, {closure}>` + //~| NOTE expected `()`, found `Map, {closure@...}>` //~| NOTE expected unit type `()` //~| HELP consider using a semicolon here } diff --git a/tests/ui/typeck/return_type_containing_closure.stderr b/tests/ui/typeck/return_type_containing_closure.stderr index 075f131dcdf19..a60bf79a57b8a 100644 --- a/tests/ui/typeck/return_type_containing_closure.stderr +++ b/tests/ui/typeck/return_type_containing_closure.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/return_type_containing_closure.rs:3:5 | LL | vec!['a'].iter().map(|c| c) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `Map, {closure}>` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `Map, {closure@...}>` | = note: expected unit type `()` found struct `Map, {closure@$DIR/return_type_containing_closure.rs:3:26: 3:29}>` From 247cf33cfad65ac56d9bd85678569cce6c227398 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 13 Jul 2026 18:25:58 +0000 Subject: [PATCH 12/14] Add missing backticks --- compiler/rustc_borrowck/src/diagnostics/region_name.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_borrowck/src/diagnostics/region_name.rs b/compiler/rustc_borrowck/src/diagnostics/region_name.rs index 0e07de31c2baa..57fd18107a414 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_name.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_name.rs @@ -147,7 +147,7 @@ impl RegionName { )) => { diag.span_label( *span, - format!("lifetime `{self}` appears in the type {type_name}"), + format!("lifetime `{self}` appears in the type `{type_name}`"), ); } RegionNameSource::AnonRegionFromOutput( From f43dbc203811e7e934def76dc1c966d76f44f96a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 13 Jul 2026 18:36:36 +0000 Subject: [PATCH 13/14] Shorten `Highlighted` types when looking at regions, but never shorten the *root* type This means that when we encounter a closure, we never hide it's path from the rendering, but if the closure is in a type parameter, it will get shortened. This should be fine for most lifetime errors to be understandable. --- .../infer/nice_region_error/placeholder_error.rs | 2 +- .../higher-ranked-auto-trait-15.no_assumptions.stderr | 4 ++-- tests/ui/borrowck/closure-upvar-named-lifetime.stderr | 4 ++-- ...ue-53432-nested-closure-outlives-borrowed-value.stderr | 2 +- .../impl-trait/must_outlive_least_region_or_bound.stderr | 2 +- tests/ui/impl-trait/static-return-lifetime-infered.stderr | 4 ++-- ...trait-impl-mismatch-elided-lifetime-issue-65866.stderr | 8 ++++---- ...lifetime-suggestion-in-proper-span-issue-121267.stderr | 2 +- .../lifetimes/missing-lifetimes-in-signature.stderr | 2 +- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_error.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_error.rs index 7f452a578778d..caa109d9e1d66 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_error.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_error.rs @@ -60,7 +60,7 @@ where } else { // We are highlighting lifetimes in the output, we will print out the smallest possible // portion of the type while keeping the lifetimes visible. - let mut p = FmtPrinter::new_with_limit(self.tcx, self.ns, Limit(0)); + let mut p = FmtPrinter::new_with_limit(self.tcx, self.ns, Limit(1)); p.region_highlight_mode = self.highlight; self.value.print(&mut p).expect("could not print type"); let x = p.into_buffer(); diff --git a/tests/ui/async-await/higher-ranked-auto-trait-15.no_assumptions.stderr b/tests/ui/async-await/higher-ranked-auto-trait-15.no_assumptions.stderr index e8d1f585f0256..274108ef503d4 100644 --- a/tests/ui/async-await/higher-ranked-auto-trait-15.no_assumptions.stderr +++ b/tests/ui/async-await/higher-ranked-auto-trait-15.no_assumptions.stderr @@ -4,7 +4,7 @@ error: implementation of `FnOnce` is not general enough LL | require_send(future); | ^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | - = note: closure with signature `fn(&'0 _) -> Iter<'_, i32>` must implement `FnOnce<(&'1 Vec,)>`, for any two lifetimes `'0` and `'1`... + = note: closure with signature `fn(&'0 Vec) -> Iter<'_, i32>` must implement `FnOnce<(&'1 Vec,)>`, for any two lifetimes `'0` and `'1`... = note: ...but it actually implements `FnOnce<(&Vec,)>` help: consider adding an explicit type annotation to the closure's argument | @@ -17,7 +17,7 @@ error: implementation of `FnOnce` is not general enough LL | require_send(future); | ^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | - = note: closure with signature `fn(&'0 _) -> Iter<'_, i32>` must implement `FnOnce<(&'1 Vec,)>`, for any two lifetimes `'0` and `'1`... + = note: closure with signature `fn(&'0 Vec) -> Iter<'_, i32>` must implement `FnOnce<(&'1 Vec,)>`, for any two lifetimes `'0` and `'1`... = note: ...but it actually implements `FnOnce<(&Vec,)>` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: consider adding an explicit type annotation to the closure's argument diff --git a/tests/ui/borrowck/closure-upvar-named-lifetime.stderr b/tests/ui/borrowck/closure-upvar-named-lifetime.stderr index 7b90b07b2f985..fc7c59fa97c89 100644 --- a/tests/ui/borrowck/closure-upvar-named-lifetime.stderr +++ b/tests/ui/borrowck/closure-upvar-named-lifetime.stderr @@ -39,7 +39,7 @@ error[E0700]: hidden type for `impl Fn(RefCell>)` captur --> $DIR/closure-upvar-named-lifetime.rs:17:5 | LL | fn apply<'a>( - | -- hidden type `{closure@...}` captures the lifetime `'a` as defined here + | -- hidden type `{closure@$DIR/closure-upvar-named-lifetime.rs:17:5: 17:15}` captures the lifetime `'a` as defined here LL | f: Arc) + 'a>, LL | ) -> impl Fn(RefCell>) | ----------------------------------------- opaque type defined here @@ -92,7 +92,7 @@ error[E0700]: hidden type for `impl Fn(RefCell>)` captur --> $DIR/closure-upvar-named-lifetime.rs:32:5 | LL | fn apply_box<'a>( - | -- hidden type `{closure@...}` captures the lifetime `'a` as defined here + | -- hidden type `{closure@$DIR/closure-upvar-named-lifetime.rs:32:5: 32:15}` captures the lifetime `'a` as defined here LL | f: Box) + 'a>, LL | ) -> impl Fn(RefCell>) | ----------------------------------------- opaque type defined here diff --git a/tests/ui/borrowck/issue-53432-nested-closure-outlives-borrowed-value.stderr b/tests/ui/borrowck/issue-53432-nested-closure-outlives-borrowed-value.stderr index 2fd84517a61bd..5887752800b55 100644 --- a/tests/ui/borrowck/issue-53432-nested-closure-outlives-borrowed-value.stderr +++ b/tests/ui/borrowck/issue-53432-nested-closure-outlives-borrowed-value.stderr @@ -4,7 +4,7 @@ error: lifetime may not live long enough LL | let _action = move || { | ------- | | | - | | return type of closure `{closure@...}` contains a lifetime `'2` + | | return type of closure `{closure@$DIR/issue-53432-nested-closure-outlives-borrowed-value.rs:4:9: 4:11}` contains a lifetime `'2` | lifetime `'1` represents this closure's body LL | || f() // The `nested` closure | ^^^^^^ returning this value requires that `'1` must outlive `'2` diff --git a/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr b/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr index 4a364c9eb0c6d..53c5568660417 100644 --- a/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr +++ b/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr @@ -112,7 +112,7 @@ error[E0700]: hidden type for `impl Fn(&'a u32)` captures lifetime that does not LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) { | -- ---------------- opaque type defined here | | - | hidden type `{closure@...}` captures the lifetime `'b` as defined here + | hidden type `{closure@$DIR/must_outlive_least_region_or_bound.rs:42:5: 42:13}` captures the lifetime `'b` as defined here LL | move |_| println!("{}", y) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/tests/ui/impl-trait/static-return-lifetime-infered.stderr b/tests/ui/impl-trait/static-return-lifetime-infered.stderr index 093bd3d227527..8f2b4c7d26616 100644 --- a/tests/ui/impl-trait/static-return-lifetime-infered.stderr +++ b/tests/ui/impl-trait/static-return-lifetime-infered.stderr @@ -4,7 +4,7 @@ error[E0700]: hidden type for `impl Iterator` captures lifetime that LL | fn iter_values_anon(&self) -> impl Iterator { | ----- ----------------------- opaque type defined here | | - | hidden type `Map, {closure@...}>` captures the anonymous lifetime defined here + | hidden type `Map, {closure@...}>` captures the anonymous lifetime defined here LL | self.x.iter().map(|a| a.0) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | @@ -19,7 +19,7 @@ error[E0700]: hidden type for `impl Iterator` captures lifetime that LL | fn iter_values<'a>(&'a self) -> impl Iterator { | -- ----------------------- opaque type defined here | | - | hidden type `Map, {closure@...}>` captures the lifetime `'a` as defined here + | hidden type `Map, {closure@...}>` captures the lifetime `'a` as defined here LL | self.x.iter().map(|a| a.0) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/tests/ui/lifetimes/trait-impl-mismatch-elided-lifetime-issue-65866.stderr b/tests/ui/lifetimes/trait-impl-mismatch-elided-lifetime-issue-65866.stderr index 4c4f6032b0f7b..25dee68a80e67 100644 --- a/tests/ui/lifetimes/trait-impl-mismatch-elided-lifetime-issue-65866.stderr +++ b/tests/ui/lifetimes/trait-impl-mismatch-elided-lifetime-issue-65866.stderr @@ -2,10 +2,10 @@ error: `impl` item signature doesn't match `trait` item signature --> $DIR/trait-impl-mismatch-elided-lifetime-issue-65866.rs:17:9 | LL | fn bar(&self, r: &mut Re); - | -------------------------- expected `fn(&'1 Foo, &'2 mut Re<'3>)` + | -------------------------- expected `fn(&'1 plain::Foo, &'2 mut Re<'3>)` ... LL | fn bar<'a, 'b>(&'a self, _r: &'b mut Re<'a>) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 Foo, &'2 mut Re<'1>)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 plain::Foo, &'2 mut Re<'1>)` | = note: expected signature `fn(&'1 plain::Foo, &'2 mut plain::Re<'3>)` found signature `fn(&'1 plain::Foo, &'2 mut plain::Re<'1>)` @@ -21,10 +21,10 @@ error: `impl` item signature doesn't match `trait` item signature --> $DIR/trait-impl-mismatch-elided-lifetime-issue-65866.rs:40:9 | LL | fn bar(&self, r: &mut Re); - | ------------------------------ expected `fn(&'1 Foo, &'2 mut Re<'3, u8>)` + | ------------------------------ expected `fn(&'1 with_type_args::Foo, &'2 mut Re<'3, u8>)` ... LL | fn bar<'a, 'b>(&'a self, _r: &'b mut Re<'a, u8>) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 Foo, &'2 mut Re<'1, u8>)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 with_type_args::Foo, &'2 mut Re<'1, u8>)` | = note: expected signature `fn(&'1 with_type_args::Foo, &'2 mut with_type_args::Re<'3, u8>)` found signature `fn(&'1 with_type_args::Foo, &'2 mut with_type_args::Re<'1, u8>)` diff --git a/tests/ui/suggestions/lifetimes/explicit-lifetime-suggestion-in-proper-span-issue-121267.stderr b/tests/ui/suggestions/lifetimes/explicit-lifetime-suggestion-in-proper-span-issue-121267.stderr index e7751de6f51ab..78a84f5f5da66 100644 --- a/tests/ui/suggestions/lifetimes/explicit-lifetime-suggestion-in-proper-span-issue-121267.stderr +++ b/tests/ui/suggestions/lifetimes/explicit-lifetime-suggestion-in-proper-span-issue-121267.stderr @@ -8,7 +8,7 @@ LL | | LL | | .filter_map(|_| foo(src)) | |_________________________________^ | - = note: hidden type `FilterMap, {closure@...}>` captures lifetime `'_` + = note: hidden type `FilterMap, {closure@...}>` captures lifetime `'_` error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr index ac4ba68aa36a6..ab067f2439c67 100644 --- a/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr +++ b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr @@ -15,7 +15,7 @@ error[E0700]: hidden type for `impl FnOnce()` captures lifetime that does not ap LL | fn foo(g: G, dest: &mut T) -> impl FnOnce() | ------ ------------- opaque type defined here | | - | hidden type `{closure@...}` captures the anonymous lifetime defined here + | hidden type `{closure@$DIR/missing-lifetimes-in-signature.rs:19:5: 19:12}` captures the anonymous lifetime defined here ... LL | / move || { LL | | From c6f56924a338772736607e45ac706b0a71635036 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 13 Jul 2026 19:34:04 +0000 Subject: [PATCH 14/14] Tweak shortened closure logic --- compiler/rustc_middle/src/ty/print/pretty.rs | 2 +- .../infer/nice_region_error/placeholder_error.rs | 2 +- .../higher-ranked-auto-trait-15.no_assumptions.stderr | 4 ++-- tests/ui/codegen/overflow-during-mono.stderr | 4 ++-- tests/ui/impl-trait/static-return-lifetime-infered.stderr | 4 ++-- ...trait-impl-mismatch-elided-lifetime-issue-65866.stderr | 8 ++++---- tests/ui/limits/type-length-limit-enforcement.stderr | 2 +- tests/ui/recursion/issue-83150.stderr | 2 +- ...lifetime-suggestion-in-proper-span-issue-121267.stderr | 2 +- tests/ui/traits/issue-91949-hangs-on-recursion.stderr | 2 +- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index f336e4ce9af24..21ba71333ec36 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -2409,7 +2409,6 @@ impl<'tcx> Printer<'tcx> for FmtPrinter<'_, 'tcx> { | ty::FnPtr(..) | ty::UnsafeBinder(..) | ty::Dynamic(..) - | ty::Closure(..) | ty::CoroutineClosure(..) | ty::Coroutine(..) | ty::CoroutineWitness(..) @@ -2426,6 +2425,7 @@ impl<'tcx> Printer<'tcx> for FmtPrinter<'_, 'tcx> { Ok(()) } ty::Ref(..) if self.should_truncate() && has_regions => self.pretty_print_type(ty), + ty::Closure(..) => self.pretty_print_type(ty), _ => { self.printed_type_count += 1; self.pretty_print_type(ty) diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_error.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_error.rs index caa109d9e1d66..7f452a578778d 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_error.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_error.rs @@ -60,7 +60,7 @@ where } else { // We are highlighting lifetimes in the output, we will print out the smallest possible // portion of the type while keeping the lifetimes visible. - let mut p = FmtPrinter::new_with_limit(self.tcx, self.ns, Limit(1)); + let mut p = FmtPrinter::new_with_limit(self.tcx, self.ns, Limit(0)); p.region_highlight_mode = self.highlight; self.value.print(&mut p).expect("could not print type"); let x = p.into_buffer(); diff --git a/tests/ui/async-await/higher-ranked-auto-trait-15.no_assumptions.stderr b/tests/ui/async-await/higher-ranked-auto-trait-15.no_assumptions.stderr index 274108ef503d4..e8d1f585f0256 100644 --- a/tests/ui/async-await/higher-ranked-auto-trait-15.no_assumptions.stderr +++ b/tests/ui/async-await/higher-ranked-auto-trait-15.no_assumptions.stderr @@ -4,7 +4,7 @@ error: implementation of `FnOnce` is not general enough LL | require_send(future); | ^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | - = note: closure with signature `fn(&'0 Vec) -> Iter<'_, i32>` must implement `FnOnce<(&'1 Vec,)>`, for any two lifetimes `'0` and `'1`... + = note: closure with signature `fn(&'0 _) -> Iter<'_, i32>` must implement `FnOnce<(&'1 Vec,)>`, for any two lifetimes `'0` and `'1`... = note: ...but it actually implements `FnOnce<(&Vec,)>` help: consider adding an explicit type annotation to the closure's argument | @@ -17,7 +17,7 @@ error: implementation of `FnOnce` is not general enough LL | require_send(future); | ^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | - = note: closure with signature `fn(&'0 Vec) -> Iter<'_, i32>` must implement `FnOnce<(&'1 Vec,)>`, for any two lifetimes `'0` and `'1`... + = note: closure with signature `fn(&'0 _) -> Iter<'_, i32>` must implement `FnOnce<(&'1 Vec,)>`, for any two lifetimes `'0` and `'1`... = note: ...but it actually implements `FnOnce<(&Vec,)>` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: consider adding an explicit type annotation to the closure's argument diff --git a/tests/ui/codegen/overflow-during-mono.stderr b/tests/ui/codegen/overflow-during-mono.stderr index 4d631e255afe5..a5f5aafb7c7c2 100644 --- a/tests/ui/codegen/overflow-during-mono.stderr +++ b/tests/ui/codegen/overflow-during-mono.stderr @@ -3,8 +3,8 @@ error[E0275]: overflow evaluating the requirement `for<'a> {closure@$DIR/overflo = help: consider increasing the recursion limit by adding a `#![recursion_limit = "64"]` attribute to your crate (`overflow_during_mono`) = note: required for `Filter, {closure@overflow-during-mono.rs:14:41}>` to implement `Iterator` = note: 31 redundant requirements hidden - = note: required for `Filter, _>, _>, _>, _>, _>` to implement `Iterator` - = note: required for `Filter, _>, _>, _>, _>, _>` to implement `IntoIterator` + = note: required for `Filter, {closure@...}>, {closure@...}>` to implement `Iterator` + = note: required for `Filter, {closure@...}>, {closure@...}>` to implement `IntoIterator` = note: the full name for the type has been written to '$TEST_BUILD_DIR/overflow-during-mono.long-type-$LONG_TYPE_HASH.txt' = note: consider using `--verbose` to print the full type name to the console diff --git a/tests/ui/impl-trait/static-return-lifetime-infered.stderr b/tests/ui/impl-trait/static-return-lifetime-infered.stderr index 8f2b4c7d26616..093bd3d227527 100644 --- a/tests/ui/impl-trait/static-return-lifetime-infered.stderr +++ b/tests/ui/impl-trait/static-return-lifetime-infered.stderr @@ -4,7 +4,7 @@ error[E0700]: hidden type for `impl Iterator` captures lifetime that LL | fn iter_values_anon(&self) -> impl Iterator { | ----- ----------------------- opaque type defined here | | - | hidden type `Map, {closure@...}>` captures the anonymous lifetime defined here + | hidden type `Map, {closure@...}>` captures the anonymous lifetime defined here LL | self.x.iter().map(|a| a.0) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | @@ -19,7 +19,7 @@ error[E0700]: hidden type for `impl Iterator` captures lifetime that LL | fn iter_values<'a>(&'a self) -> impl Iterator { | -- ----------------------- opaque type defined here | | - | hidden type `Map, {closure@...}>` captures the lifetime `'a` as defined here + | hidden type `Map, {closure@...}>` captures the lifetime `'a` as defined here LL | self.x.iter().map(|a| a.0) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/tests/ui/lifetimes/trait-impl-mismatch-elided-lifetime-issue-65866.stderr b/tests/ui/lifetimes/trait-impl-mismatch-elided-lifetime-issue-65866.stderr index 25dee68a80e67..4c4f6032b0f7b 100644 --- a/tests/ui/lifetimes/trait-impl-mismatch-elided-lifetime-issue-65866.stderr +++ b/tests/ui/lifetimes/trait-impl-mismatch-elided-lifetime-issue-65866.stderr @@ -2,10 +2,10 @@ error: `impl` item signature doesn't match `trait` item signature --> $DIR/trait-impl-mismatch-elided-lifetime-issue-65866.rs:17:9 | LL | fn bar(&self, r: &mut Re); - | -------------------------- expected `fn(&'1 plain::Foo, &'2 mut Re<'3>)` + | -------------------------- expected `fn(&'1 Foo, &'2 mut Re<'3>)` ... LL | fn bar<'a, 'b>(&'a self, _r: &'b mut Re<'a>) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 plain::Foo, &'2 mut Re<'1>)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 Foo, &'2 mut Re<'1>)` | = note: expected signature `fn(&'1 plain::Foo, &'2 mut plain::Re<'3>)` found signature `fn(&'1 plain::Foo, &'2 mut plain::Re<'1>)` @@ -21,10 +21,10 @@ error: `impl` item signature doesn't match `trait` item signature --> $DIR/trait-impl-mismatch-elided-lifetime-issue-65866.rs:40:9 | LL | fn bar(&self, r: &mut Re); - | ------------------------------ expected `fn(&'1 with_type_args::Foo, &'2 mut Re<'3, u8>)` + | ------------------------------ expected `fn(&'1 Foo, &'2 mut Re<'3, u8>)` ... LL | fn bar<'a, 'b>(&'a self, _r: &'b mut Re<'a, u8>) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 with_type_args::Foo, &'2 mut Re<'1, u8>)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 Foo, &'2 mut Re<'1, u8>)` | = note: expected signature `fn(&'1 with_type_args::Foo, &'2 mut with_type_args::Re<'3, u8>)` found signature `fn(&'1 with_type_args::Foo, &'2 mut with_type_args::Re<'1, u8>)` diff --git a/tests/ui/limits/type-length-limit-enforcement.stderr b/tests/ui/limits/type-length-limit-enforcement.stderr index 0313f212d3f7e..637a626fc4e7e 100644 --- a/tests/ui/limits/type-length-limit-enforcement.stderr +++ b/tests/ui/limits/type-length-limit-enforcement.stderr @@ -8,7 +8,7 @@ LL | drop::>(None); = note: the full name for the type has been written to '$TEST_BUILD_DIR/type-length-limit-enforcement.long-type-$LONG_TYPE_HASH.txt' = note: consider using `--verbose` to print the full type name to the console -error: reached the type-length limit while instantiating `<{closure@...} as FnMut<()>>::call_mut` +error: reached the type-length limit while instantiating `<{closure@lang_start<()>::{closure#0}} as FnMut<()>>::call_mut` | = help: consider adding a `#![type_length_limit="10"]` attribute to your crate = note: the full name for the type has been written to '$TEST_BUILD_DIR/type-length-limit-enforcement.long-type-$LONG_TYPE_HASH.txt' diff --git a/tests/ui/recursion/issue-83150.stderr b/tests/ui/recursion/issue-83150.stderr index 9ec187f055018..a01f14b66794c 100644 --- a/tests/ui/recursion/issue-83150.stderr +++ b/tests/ui/recursion/issue-83150.stderr @@ -15,7 +15,7 @@ error[E0275]: overflow evaluating the requirement `Map<&mut std::ops::Range, = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_83150`) = note: required for `&mut Map<&mut Range, {closure@issue-83150.rs:12:24}>` to implement `Iterator` = note: 65 redundant requirements hidden - = note: required for `&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<_, _>, _>, _>, _>, _>` to implement `Iterator` + = note: required for `&mut Map<&mut Map<&mut _, {closure@...}>, {closure@...}>` to implement `Iterator` = note: the full name for the type has been written to '$TEST_BUILD_DIR/issue-83150.long-type-$LONG_TYPE_HASH.txt' = note: consider using `--verbose` to print the full type name to the console diff --git a/tests/ui/suggestions/lifetimes/explicit-lifetime-suggestion-in-proper-span-issue-121267.stderr b/tests/ui/suggestions/lifetimes/explicit-lifetime-suggestion-in-proper-span-issue-121267.stderr index 78a84f5f5da66..e7751de6f51ab 100644 --- a/tests/ui/suggestions/lifetimes/explicit-lifetime-suggestion-in-proper-span-issue-121267.stderr +++ b/tests/ui/suggestions/lifetimes/explicit-lifetime-suggestion-in-proper-span-issue-121267.stderr @@ -8,7 +8,7 @@ LL | | LL | | .filter_map(|_| foo(src)) | |_________________________________^ | - = note: hidden type `FilterMap, {closure@...}>` captures lifetime `'_` + = note: hidden type `FilterMap, {closure@...}>` captures lifetime `'_` error: aborting due to 1 previous error diff --git a/tests/ui/traits/issue-91949-hangs-on-recursion.stderr b/tests/ui/traits/issue-91949-hangs-on-recursion.stderr index 3eff2944b472f..de16865629f89 100644 --- a/tests/ui/traits/issue-91949-hangs-on-recursion.stderr +++ b/tests/ui/traits/issue-91949-hangs-on-recursion.stderr @@ -24,7 +24,7 @@ LL | impl> Iterator for IteratorOfWrapped { | | | unsatisfied trait bound introduced here = note: 256 redundant requirements hidden - = note: required for `IteratorOfWrapped<(), Map>, _>>` to implement `Iterator` + = note: required for `IteratorOfWrapped<(), Map, {closure@...}>>` to implement `Iterator` = note: the full name for the type has been written to '$TEST_BUILD_DIR/issue-91949-hangs-on-recursion.long-type-$LONG_TYPE_HASH.txt' = note: consider using `--verbose` to print the full type name to the console