From b558c2b9b16fbbd1b3ba2668c243c61eee4a7fe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 16 Jul 2025 19:45:07 +0000 Subject: [PATCH 01/13] Use `tcx.short_string()` in more diagnostics `TyCtxt::short_string` ensures that user visible type paths aren't overwhelming on the terminal output, and properly saves the long name to disk as a side-channel. We already use these throughout the compiler and have been using them as needed when users find cases where the output is verbose. This is a proactive search of some cases to use `short_string`. We add support for shortening the path of "trait path only". Every manual use of `short_string` is a bright marker that that error should be using structured diagnostics instead (as they have proper handling of long types without the maintainer having to think abou tthem). --- .../src/hir_ty_lowering/mod.rs | 5 +- .../rustc_hir_typeck/src/method/suggest.rs | 13 ++- compiler/rustc_middle/src/ty/print/pretty.rs | 2 +- .../traits/fulfillment_errors.rs | 110 ++++++++++++------ .../src/error_reporting/traits/suggestions.rs | 29 +++-- tests/ui/codegen/overflow-during-mono.rs | 3 +- tests/ui/codegen/overflow-during-mono.stderr | 10 +- .../ui/confuse-field-and-method/issue-2392.rs | 4 + .../issue-2392.stderr | 27 +++-- .../dropck_no_diverge_on_nonregular_1.rs | 1 + .../dropck_no_diverge_on_nonregular_1.stderr | 6 +- .../never-type-fallback-breaking.e2024.stderr | 8 +- tests/ui/error-codes/E0275.rs | 1 + tests/ui/error-codes/E0275.stderr | 8 +- .../trait-bounds/hrtb-doesnt-borrow-self-2.rs | 2 + .../hrtb-doesnt-borrow-self-2.stderr | 16 +-- .../auto-trait-leakage/auto-trait-leak2.rs | 7 ++ .../auto-trait-leak2.stderr | 20 ++-- ...et-binding-without-sufficient-type-info.rs | 1 + ...inding-without-sufficient-type-info.stderr | 5 +- .../interior-mutability.rs | 3 + .../interior-mutability.stderr | 6 +- tests/ui/methods/inherent-bound-in-probe.rs | 1 + .../ui/methods/inherent-bound-in-probe.stderr | 12 +- .../methods/probe-error-on-infinite-deref.rs | 1 + .../probe-error-on-infinite-deref.stderr | 8 +- .../defaulted-never-note.fallback.stderr | 2 +- tests/ui/never_type/defaulted-never-note.rs | 2 +- ...diverging-fallback-no-leak.fallback.stderr | 2 +- tests/ui/recursion/issue-23122-2.rs | 1 + tests/ui/recursion/issue-23122-2.stderr | 8 +- ...ssue-38591-non-regular-dropck-recursion.rs | 1 + ...-38591-non-regular-dropck-recursion.stderr | 6 +- tests/ui/recursion/issue-83150.rs | 2 +- tests/ui/recursion/issue-83150.stderr | 6 +- .../traits/issue-91949-hangs-on-recursion.rs | 2 +- .../issue-91949-hangs-on-recursion.stderr | 4 +- 37 files changed, 226 insertions(+), 119 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs index d768799835867..092e22e4b68a6 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs @@ -1135,9 +1135,10 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { ); } } else { + let trait_ = + tcx.short_string(bound.print_only_trait_path(), err.long_ty_path()); err.note(format!( - "associated {assoc_kind_str} `{assoc_ident}` could derive from `{}`", - bound.print_only_trait_path(), + "associated {assoc_kind_str} `{assoc_ident}` could derive from `{trait_}`", )); } } diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index e64af8fb7b38f..2a7a344db1584 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -376,8 +376,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - fn suggest_missing_writer(&self, rcvr_ty: Ty<'tcx>, rcvr_expr: &hir::Expr<'tcx>) -> Diag<'_> { - let mut file = None; + fn suggest_missing_writer( + &self, + rcvr_ty: Ty<'tcx>, + rcvr_expr: &hir::Expr<'tcx>, + mut file: Option, + ) -> Diag<'_> { let mut err = struct_span_code_err!( self.dcx(), rcvr_expr.span, @@ -683,7 +687,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { || tcx.is_diagnostic_item(sym::writeln_macro, def_id) }) && item_ident.name == sym::write_fmt; let mut err = if is_write && let SelfSource::MethodCall(rcvr_expr) = source { - self.suggest_missing_writer(rcvr_ty, rcvr_expr) + self.suggest_missing_writer(rcvr_ty, rcvr_expr, ty_file) } else { let mut err = self.dcx().create_err(NoAssociatedItem { span, @@ -698,6 +702,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ty_str: ty_str_reported.clone(), trait_missing_method, }); + *err.long_ty_path() = ty_file; if is_method { self.suggest_use_shadowed_binding_with_method( @@ -1339,7 +1344,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } let OnUnimplementedNote { message, label, notes, .. } = self .err_ctxt() - .on_unimplemented_note(trait_ref, &obligation, &mut ty_file); + .on_unimplemented_note(trait_ref, &obligation, err.long_ty_path()); (message, label, notes) }) .unwrap() diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 5c44b10ba71cb..74eb6f6844efe 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -3039,7 +3039,7 @@ impl<'tcx> ty::Binder<'tcx, ty::TraitRef<'tcx>> { } } -#[derive(Copy, Clone, TypeFoldable, TypeVisitable, Lift)] +#[derive(Copy, Clone, TypeFoldable, TypeVisitable, Lift, Hash)] pub struct TraitPredPrintModifiersAndPath<'tcx>(ty::TraitPredicate<'tcx>); impl<'tcx> fmt::Debug for TraitPredPrintModifiersAndPath<'tcx> { diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs index 1ac309da101f1..faf08d264c9ab 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs @@ -208,16 +208,19 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { performs a conversion on the error value \ using the `From` trait"; let (message, notes, append_const_msg) = if is_try_conversion { + let ty = self.tcx.short_string( + main_trait_predicate.skip_binder().self_ty(), + &mut long_ty_file, + ); // We have a `-> Result<_, E1>` and `gives_E2()?`. ( - Some(format!( - "`?` couldn't convert the error to `{}`", - main_trait_predicate.skip_binder().self_ty(), - )), + Some(format!("`?` couldn't convert the error to `{ty}`")), vec![question_mark_message.to_owned()], Some(AppendConstMessage::Default), ) } else if is_question_mark { + let main_trait_predicate = + self.tcx.short_string(main_trait_predicate, &mut long_ty_file); // Similar to the case above, but in this case the conversion is for a // trait object: `-> Result<_, Box` and `gives_E()?` when // `E: Error` isn't met. @@ -233,7 +236,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { (message, notes, append_const_msg) }; - let err_msg = self.get_standard_error_message( + let err_msg = || self.get_standard_error_message( main_trait_predicate, message, None, @@ -258,7 +261,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { ); } GetSafeTransmuteErrorAndReason::Default => { - (err_msg, None) + (err_msg(), None) } GetSafeTransmuteErrorAndReason::Error { err_msg, @@ -266,7 +269,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { } => (err_msg, safe_transmute_explanation), } } else { - (err_msg, None) + (err_msg(), None) }; let mut err = struct_span_code_err!(self.dcx(), span, E0277, "{}", err_msg); @@ -279,15 +282,21 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { if let Some(ret_span) = self.return_type_span(&obligation) { if is_try_conversion { + let ty = self.tcx.short_string( + main_trait_predicate.skip_binder().self_ty(), + err.long_ty_path(), + ); err.span_label( ret_span, - format!( - "expected `{}` because of this", - main_trait_predicate.skip_binder().self_ty() - ), + format!("expected `{ty}` because of this"), ); } else if is_question_mark { - err.span_label(ret_span, format!("required `{main_trait_predicate}` because of this")); + let main_trait_predicate = + self.tcx.short_string(main_trait_predicate, err.long_ty_path()); + err.span_label( + ret_span, + format!("required `{main_trait_predicate}` because of this"), + ); } } @@ -414,11 +423,12 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { } else { vec![(span.shrink_to_hi(), format!(" as {}", cand.self_ty()))] }; + let trait_ = self.tcx.short_string(cand.print_trait_sugared(), err.long_ty_path()); + let ty = self.tcx.short_string(cand.self_ty(), err.long_ty_path()); err.multipart_suggestion( format!( - "the trait `{}` is implemented for fn pointer `{}`, try casting using `as`", - cand.print_trait_sugared(), - cand.self_ty(), + "the trait `{trait_}` is implemented for fn pointer \ + `{ty}`, try casting using `as`", ), suggestion, Applicability::MaybeIncorrect, @@ -522,7 +532,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { \ for more information)", ); - err.help("did you intend to use the type `()` here instead?"); + err.help("you might have intended to use the type `()` here instead"); } } @@ -722,10 +732,13 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { } SelectionError::ConstArgHasWrongType { ct, ct_ty, expected_ty } => { + let expected_ty_str = self.tcx.short_string(expected_ty, &mut long_ty_file); + let ct_str = self.tcx.short_string(ct, &mut long_ty_file); let mut diag = self.dcx().struct_span_err( span, - format!("the constant `{ct}` is not of type `{expected_ty}`"), + format!("the constant `{ct_str}` is not of type `{expected_ty_str}`"), ); + diag.long_ty_path = long_ty_file; self.note_type_err( &mut diag, @@ -1118,9 +1131,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { .must_apply_modulo_regions() { if !suggested { + let err_ty = self.tcx.short_string(err_ty, err.long_ty_path()); err.span_label(span, format!("this has type `Result<_, {err_ty}>`")); } } else { + let err_ty = self.tcx.short_string(err_ty, err.long_ty_path()); err.span_label( span, format!( @@ -1156,12 +1171,13 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { ); } (ty::Adt(def, _), None) if def.did().is_local() => { + let trait_path = self.tcx.short_string( + trait_pred.skip_binder().trait_ref.print_only_trait_path(), + err.long_ty_path(), + ); err.span_note( self.tcx.def_span(def.did()), - format!( - "`{self_ty}` needs to implement `{}`", - trait_pred.skip_binder().trait_ref.print_only_trait_path(), - ), + format!("`{self_ty}` needs to implement `{trait_path}`"), ); } (ty::Adt(def, _), Some(ty)) if def.did().is_local() => { @@ -1195,13 +1211,15 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { bug!() }; + let mut file = None; + let ty_str = self.tcx.short_string(ty, &mut file); let mut diag = match ty.kind() { ty::Float(_) => { struct_span_code_err!( self.dcx(), span, E0741, - "`{ty}` is forbidden as the type of a const generic parameter", + "`{ty_str}` is forbidden as the type of a const generic parameter", ) } ty::FnPtr(..) => { @@ -1226,7 +1244,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { self.dcx(), span, E0741, - "`{ty}` must implement `ConstParamTy` to be used as the type of a const generic parameter", + "`{ty_str}` must implement `ConstParamTy` to be used as the type of a const generic parameter", ); // Only suggest derive if this isn't a derived obligation, // and the struct is local. @@ -1258,21 +1276,22 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { self.dcx(), span, E0741, - "`{ty}` can't be used as a const parameter type", + "`{ty_str}` can't be used as a const parameter type", ) } }; + diag.long_ty_path = file; let mut code = obligation.cause.code(); let mut pred = obligation.predicate.as_trait_clause(); while let Some((next_code, next_pred)) = code.parent_with_predicate() { if let Some(pred) = pred { self.enter_forall(pred, |pred| { - diag.note(format!( - "`{}` must implement `{}`, but it does not", - pred.self_ty(), - pred.print_modifiers_and_trait_path() - )); + let ty = self.tcx.short_string(pred.self_ty(), diag.long_ty_path()); + let trait_path = self + .tcx + .short_string(pred.print_modifiers_and_trait_path(), diag.long_ty_path()); + diag.note(format!("`{ty}` must implement `{trait_path}`, but it does not")); }) } code = next_code; @@ -1626,15 +1645,23 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { ty::FnDef(def, _) => self.tcx.item_name(*def).to_string(), _ => self.tcx.short_string(self_ty, file), }; + let expected_ty = self.tcx.short_string(expected_ty, file); + let normalized_ty = self.tcx.short_string(normalized_ty, file); Some((format!( "expected `{item}` to return `{expected_ty}`, but it returns `{normalized_ty}`", ), span, closure_span)) } else if self.tcx.is_lang_item(trait_def_id, LangItem::Future) { + let self_ty = self.tcx.short_string(self_ty, file); + let expected_ty = self.tcx.short_string(expected_ty, file); + let normalized_ty = self.tcx.short_string(normalized_ty, file); Some((format!( "expected `{self_ty}` to be a future that resolves to `{expected_ty}`, but it \ resolves to `{normalized_ty}`" ), span, None)) } else if Some(trait_def_id) == self.tcx.get_diagnostic_item(sym::Iterator) { + let self_ty = self.tcx.short_string(self_ty, file); + let expected_ty = self.tcx.short_string(expected_ty, file); + let normalized_ty = self.tcx.short_string(normalized_ty, file); Some((format!( "expected `{self_ty}` to be an iterator that yields `{expected_ty}`, but it \ yields `{normalized_ty}`" @@ -2097,12 +2124,15 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { if let [TypeError::Sorts(exp_found)] = &terrs[..] { let exp_found = self.resolve_vars_if_possible(*exp_found); + let expected = + self.tcx.short_string(exp_found.expected, err.long_ty_path()); + let found = self.tcx.short_string(exp_found.found, err.long_ty_path()); err.highlighted_help(vec![ StringPart::normal("for that trait implementation, "), StringPart::normal("expected `"), - StringPart::highlighted(exp_found.expected.to_string()), + StringPart::highlighted(expected), StringPart::normal("`, found `"), - StringPart::highlighted(exp_found.found.to_string()), + StringPart::highlighted(found), StringPart::normal("`"), ]); self.suggest_function_pointers_impl(None, &exp_found, err); @@ -2135,11 +2165,13 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { (ty::FnPtr(..), _) => (" implemented for fn pointer `", ""), _ => (" implemented for `", ""), }; + let trait_ = self.tcx.short_string(cand.print_trait_sugared(), err.long_ty_path()); + let self_ty = self.tcx.short_string(cand.self_ty(), err.long_ty_path()); err.highlighted_help(vec![ - StringPart::normal(format!("the trait `{}` ", cand.print_trait_sugared())), + StringPart::normal(format!("the trait `{trait_}` ",)), StringPart::highlighted("is"), StringPart::normal(desc), - StringPart::highlighted(cand.self_ty().to_string()), + StringPart::highlighted(self_ty), StringPart::normal("`"), StringPart::normal(mention_castable), ]); @@ -2159,9 +2191,13 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { .into_iter() .map(|c| { if all_traits_equal { - format!("\n {}", c.self_ty()) + format!("\n {}", self.tcx.short_string(c.self_ty(), err.long_ty_path())) } else { - format!("\n `{}` implements `{}`", c.self_ty(), c.print_only_trait_path()) + format!( + "\n `{}` implements `{}`", + self.tcx.short_string(c.self_ty(), err.long_ty_path()), + self.tcx.short_string(c.print_only_trait_path(), err.long_ty_path()), + ) } }) .collect(); @@ -2608,8 +2644,8 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { dst_min_align, } => { format!( - "the minimum alignment of `{src}` ({src_min_align}) should \ - be greater than that of `{dst}` ({dst_min_align})" + "the minimum alignment of `{src}` ({src_min_align}) should be \ + greater than that of `{dst}` ({dst_min_align})" ) } rustc_transmute::Reason::DstIsMoreUnique => { diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs index c182fd99b17bd..3cc97769e215d 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs @@ -3441,7 +3441,10 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { } let self_ty_str = tcx.short_string(parent_trait_pred.skip_binder().self_ty(), err.long_ty_path()); - let trait_name = parent_trait_pred.print_modifiers_and_trait_path().to_string(); + let trait_name = tcx.short_string( + parent_trait_pred.print_modifiers_and_trait_path(), + err.long_ty_path(), + ); let msg = format!("required for `{self_ty_str}` to implement `{trait_name}`"); let mut is_auto_trait = false; match tcx.hir_get_if_local(data.impl_or_alias_def_id) { @@ -3539,10 +3542,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { parent_trait_pred.skip_binder().self_ty(), err.long_ty_path(), ); - err.note(format!( - "required for `{self_ty}` to implement `{}`", - parent_trait_pred.print_modifiers_and_trait_path() - )); + let trait_path = tcx.short_string( + parent_trait_pred.print_modifiers_and_trait_path(), + err.long_ty_path(), + ); + err.note(format!("required for `{self_ty}` to implement `{trait_path}`")); } // #74711: avoid a stack overflow ensure_sufficient_stack(|| { @@ -3558,15 +3562,20 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { }); } ObligationCauseCode::ImplDerivedHost(ref data) => { - let self_ty = - self.resolve_vars_if_possible(data.derived.parent_host_pred.self_ty()); - let msg = format!( - "required for `{self_ty}` to implement `{} {}`", - data.derived.parent_host_pred.skip_binder().constness, + let self_ty = tcx.short_string( + self.resolve_vars_if_possible(data.derived.parent_host_pred.self_ty()), + err.long_ty_path(), + ); + let trait_path = tcx.short_string( data.derived .parent_host_pred .map_bound(|pred| pred.trait_ref) .print_only_trait_path(), + err.long_ty_path(), + ); + let msg = format!( + "required for `{self_ty}` to implement `{} {trait_path}`", + data.derived.parent_host_pred.skip_binder().constness, ); match tcx.hir_get_if_local(data.impl_def_id) { Some(Node::Item(hir::Item { diff --git a/tests/ui/codegen/overflow-during-mono.rs b/tests/ui/codegen/overflow-during-mono.rs index a9045840173e7..3aafe05ba0537 100644 --- a/tests/ui/codegen/overflow-during-mono.rs +++ b/tests/ui/codegen/overflow-during-mono.rs @@ -1,5 +1,6 @@ -//~ ERROR overflow evaluating the requirement `for<'a> {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}: FnMut(&'a _)` +//~ ERROR overflow evaluating the requirement `for<'a> {closure@$DIR/overflow-during-mono.rs:14:41: 14:44}: FnMut(&'a _)` //@ build-fail +//@ compile-flags: -Zwrite-long-types-to-disk=yes #![recursion_limit = "32"] diff --git a/tests/ui/codegen/overflow-during-mono.stderr b/tests/ui/codegen/overflow-during-mono.stderr index 74d98fde285bb..1559de757e7ba 100644 --- a/tests/ui/codegen/overflow-during-mono.stderr +++ b/tests/ui/codegen/overflow-during-mono.stderr @@ -1,10 +1,12 @@ -error[E0275]: overflow evaluating the requirement `for<'a> {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}: FnMut(&'a _)` +error[E0275]: overflow evaluating the requirement `for<'a> {closure@$DIR/overflow-during-mono.rs:14:41: 14:44}: FnMut(&'a _)` | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "64"]` attribute to your crate (`overflow_during_mono`) - = note: required for `Filter, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>` to implement `Iterator` + = note: required for `Filter, {closure@overflow-during-mono.rs:14:41}>` to implement `Iterator` = note: 31 redundant requirements hidden - = note: required for `Filter, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>` to implement `Iterator` - = note: required for `Filter, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>` to implement `IntoIterator` + = note: required for `Filter, ...>, ...>, ...>, ...>` to implement `Iterator` + = note: required for `Filter, ...>, ...>, ...>, ...>` 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 error: aborting due to 1 previous error diff --git a/tests/ui/confuse-field-and-method/issue-2392.rs b/tests/ui/confuse-field-and-method/issue-2392.rs index 8aef091fe3186..c878b69384768 100644 --- a/tests/ui/confuse-field-and-method/issue-2392.rs +++ b/tests/ui/confuse-field-and-method/issue-2392.rs @@ -1,3 +1,7 @@ +// FIXME(estebank): diagnostics with long type paths that don't print out the full path anywhere +// still prints the note explaining where the type was written to. +//@ compile-flags: -Zwrite-long-types-to-disk=yes + struct FuncContainer { f1: fn(data: u8), f2: extern "C" fn(data: u8), diff --git a/tests/ui/confuse-field-and-method/issue-2392.stderr b/tests/ui/confuse-field-and-method/issue-2392.stderr index 77930de44a770..aa456fb3282b3 100644 --- a/tests/ui/confuse-field-and-method/issue-2392.stderr +++ b/tests/ui/confuse-field-and-method/issue-2392.stderr @@ -1,5 +1,5 @@ error[E0599]: no method named `closure` found for struct `Obj` in the current scope - --> $DIR/issue-2392.rs:36:15 + --> $DIR/issue-2392.rs:40:15 | LL | struct Obj where F: FnOnce() -> u32 { | ------------- method `closure` not found for this struct @@ -7,13 +7,15 @@ LL | struct Obj where F: FnOnce() -> u32 { LL | o_closure.closure(); | ^^^^^^^ field, not a method | + = note: the full name for the type has been written to '$TEST_BUILD_DIR/issue-2392.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console help: to call the closure stored in `closure`, surround the field access with parentheses | LL | (o_closure.closure)(); | + + error[E0599]: no method named `not_closure` found for struct `Obj` in the current scope - --> $DIR/issue-2392.rs:38:15 + --> $DIR/issue-2392.rs:42:15 | LL | struct Obj where F: FnOnce() -> u32 { | ------------- method `not_closure` not found for this struct @@ -22,9 +24,12 @@ LL | o_closure.not_closure(); | ^^^^^^^^^^^-- help: remove the arguments | | | field, not a method + | + = note: the full name for the type has been written to '$TEST_BUILD_DIR/issue-2392.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error[E0599]: no method named `closure` found for struct `Obj` in the current scope - --> $DIR/issue-2392.rs:42:12 + --> $DIR/issue-2392.rs:46:12 | LL | struct Obj where F: FnOnce() -> u32 { | ------------- method `closure` not found for this struct @@ -38,7 +43,7 @@ LL | (o_func.closure)(); | + + error[E0599]: no method named `boxed_closure` found for struct `BoxedObj` in the current scope - --> $DIR/issue-2392.rs:45:14 + --> $DIR/issue-2392.rs:49:14 | LL | struct BoxedObj { | --------------- method `boxed_closure` not found for this struct @@ -52,7 +57,7 @@ LL | (boxed_fn.boxed_closure)(); | + + error[E0599]: no method named `boxed_closure` found for struct `BoxedObj` in the current scope - --> $DIR/issue-2392.rs:48:19 + --> $DIR/issue-2392.rs:52:19 | LL | struct BoxedObj { | --------------- method `boxed_closure` not found for this struct @@ -66,7 +71,7 @@ LL | (boxed_closure.boxed_closure)(); | + + error[E0599]: no method named `closure` found for struct `Obj` in the current scope - --> $DIR/issue-2392.rs:53:12 + --> $DIR/issue-2392.rs:57:12 | LL | struct Obj where F: FnOnce() -> u32 { | ------------- method `closure` not found for this struct @@ -80,7 +85,7 @@ LL | (w.wrap.closure)(); | + + error[E0599]: no method named `not_closure` found for struct `Obj` in the current scope - --> $DIR/issue-2392.rs:55:12 + --> $DIR/issue-2392.rs:59:12 | LL | struct Obj where F: FnOnce() -> u32 { | ------------- method `not_closure` not found for this struct @@ -91,7 +96,7 @@ LL | w.wrap.not_closure(); | field, not a method error[E0599]: no method named `closure` found for struct `Obj` in the current scope - --> $DIR/issue-2392.rs:58:24 + --> $DIR/issue-2392.rs:62:24 | LL | struct Obj where F: FnOnce() -> u32 { | ------------- method `closure` not found for this struct @@ -105,7 +110,7 @@ LL | (check_expression().closure)(); | + + error[E0599]: no method named `f1` found for struct `FuncContainer` in the current scope - --> $DIR/issue-2392.rs:64:31 + --> $DIR/issue-2392.rs:68:31 | LL | struct FuncContainer { | -------------------- method `f1` not found for this struct @@ -119,7 +124,7 @@ LL | ((*self.container).f1)(1); | + + error[E0599]: no method named `f2` found for struct `FuncContainer` in the current scope - --> $DIR/issue-2392.rs:65:31 + --> $DIR/issue-2392.rs:69:31 | LL | struct FuncContainer { | -------------------- method `f2` not found for this struct @@ -133,7 +138,7 @@ LL | ((*self.container).f2)(1); | + + error[E0599]: no method named `f3` found for struct `FuncContainer` in the current scope - --> $DIR/issue-2392.rs:66:31 + --> $DIR/issue-2392.rs:70:31 | LL | struct FuncContainer { | -------------------- method `f3` not found for this struct diff --git a/tests/ui/dropck/dropck_no_diverge_on_nonregular_1.rs b/tests/ui/dropck/dropck_no_diverge_on_nonregular_1.rs index 17b76b6c8321a..2bb82a2ebf207 100644 --- a/tests/ui/dropck/dropck_no_diverge_on_nonregular_1.rs +++ b/tests/ui/dropck/dropck_no_diverge_on_nonregular_1.rs @@ -1,5 +1,6 @@ // Issue 22443: Reject code using non-regular types that would // otherwise cause dropck to loop infinitely. +//@ compile-flags: -Zwrite-long-types-to-disk=yes use std::marker::PhantomData; diff --git a/tests/ui/dropck/dropck_no_diverge_on_nonregular_1.stderr b/tests/ui/dropck/dropck_no_diverge_on_nonregular_1.stderr index 9360f4a98e9b9..330a40d925bb1 100644 --- a/tests/ui/dropck/dropck_no_diverge_on_nonregular_1.stderr +++ b/tests/ui/dropck/dropck_no_diverge_on_nonregular_1.stderr @@ -1,10 +1,12 @@ error[E0320]: overflow while adding drop-check rules for `FingerTree` - --> $DIR/dropck_no_diverge_on_nonregular_1.rs:24:9 + --> $DIR/dropck_no_diverge_on_nonregular_1.rs:25:9 | LL | let ft = | ^^ | - = note: overflowed on `FingerTree>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: overflowed on `FingerTree>>>>>>>>>` + = note: the full name for the type has been written to '$TEST_BUILD_DIR/dropck_no_diverge_on_nonregular_1.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error: aborting due to 1 previous error diff --git a/tests/ui/editions/never-type-fallback-breaking.e2024.stderr b/tests/ui/editions/never-type-fallback-breaking.e2024.stderr index 2daf00f7804ff..f0d4de364fbd0 100644 --- a/tests/ui/editions/never-type-fallback-breaking.e2024.stderr +++ b/tests/ui/editions/never-type-fallback-breaking.e2024.stderr @@ -5,7 +5,7 @@ LL | true => Default::default(), | ^^^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `!` | = note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 for more information) - = help: did you intend to use the type `()` here instead? + = help: you might have intended to use the type `()` here instead error[E0277]: the trait bound `!: Default` is not satisfied --> $DIR/never-type-fallback-breaking.rs:37:5 @@ -14,7 +14,7 @@ LL | deserialize()?; | ^^^^^^^^^^^^^ the trait `Default` is not implemented for `!` | = note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 for more information) - = help: did you intend to use the type `()` here instead? + = help: you might have intended to use the type `()` here instead note: required by a bound in `deserialize` --> $DIR/never-type-fallback-breaking.rs:33:23 | @@ -51,7 +51,7 @@ LL | takes_apit(|| Default::default())?; | ^^^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `!` | = note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 for more information) - = help: did you intend to use the type `()` here instead? + = help: you might have intended to use the type `()` here instead error[E0277]: the trait bound `!: Default` is not satisfied --> $DIR/never-type-fallback-breaking.rs:76:17 @@ -62,7 +62,7 @@ LL | takes_apit2(mk()?); | required by a bound introduced by this call | = note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 for more information) - = help: did you intend to use the type `()` here instead? + = help: you might have intended to use the type `()` here instead note: required by a bound in `takes_apit2` --> $DIR/never-type-fallback-breaking.rs:71:25 | diff --git a/tests/ui/error-codes/E0275.rs b/tests/ui/error-codes/E0275.rs index 28a9676f03e39..98d4a3c01b9a2 100644 --- a/tests/ui/error-codes/E0275.rs +++ b/tests/ui/error-codes/E0275.rs @@ -1,3 +1,4 @@ +//@ compile-flags: -Zwrite-long-types-to-disk=yes trait Foo {} struct Bar(T); diff --git a/tests/ui/error-codes/E0275.stderr b/tests/ui/error-codes/E0275.stderr index 3b31c87320ae9..755404c1e1698 100644 --- a/tests/ui/error-codes/E0275.stderr +++ b/tests/ui/error-codes/E0275.stderr @@ -1,17 +1,19 @@ error[E0275]: overflow evaluating the requirement `Bar>>>>>>: Foo` - --> $DIR/E0275.rs:5:33 + --> $DIR/E0275.rs:6:33 | LL | impl Foo for T where Bar: Foo {} | ^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`E0275`) -note: required for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` to implement `Foo` - --> $DIR/E0275.rs:5:9 +note: required for `Bar>>>>>>>>>>>>` to implement `Foo` + --> $DIR/E0275.rs:6:9 | LL | impl Foo for T where Bar: Foo {} | ^^^ ^ --- unsatisfied trait bound introduced here = note: 126 redundant requirements hidden = note: required for `Bar` to implement `Foo` + = note: the full name for the type has been written to '$TEST_BUILD_DIR/E0275.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error: aborting due to 1 previous error diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-2.rs b/tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-2.rs index d8a1f3fa69e4b..d2793afdd0646 100644 --- a/tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-2.rs +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-doesnt-borrow-self-2.rs @@ -6,6 +6,8 @@ // This tests double-checks that we do not allow such behavior to leak // through again. +//@ compile-flags: -Zwrite-long-types-to-disk=yes + pub trait Stream { type Item; fn next(self) -> Option; 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 23b979e2ef0bb..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,5 +1,5 @@ -error[E0599]: the method `countx` exists for struct `Filter fn(&'a u64) -> &'a u64 {identity::}>, {closure@$DIR/hrtb-doesnt-borrow-self-2.rs:109:30: 109:37}>`, but its trait bounds were not satisfied - --> $DIR/hrtb-doesnt-borrow-self-2.rs:110:24 +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 { | ----------------------- method `countx` not found for this struct because it doesn't satisfy `_: StreamExt` @@ -8,19 +8,21 @@ LL | let count = filter.countx(); | ^^^^^^ method cannot be called due to unsatisfied trait bounds | note: the following trait bounds were not satisfied: - `&'a mut &Filter fn(&'a u64) -> &'a u64 {identity::}>, {closure@$DIR/hrtb-doesnt-borrow-self-2.rs:109:30: 109:37}>: Stream` - `&'a mut &mut Filter fn(&'a u64) -> &'a u64 {identity::}>, {closure@$DIR/hrtb-doesnt-borrow-self-2.rs:109:30: 109:37}>: Stream` - `&'a mut Filter fn(&'a u64) -> &'a u64 {identity::}>, {closure@$DIR/hrtb-doesnt-borrow-self-2.rs:109:30: 109:37}>: Stream` - --> $DIR/hrtb-doesnt-borrow-self-2.rs:96:50 + `&'a mut &Filter fn(&'a u64) -> &'a u64 {identity::}>, {closure@$DIR/hrtb-doesnt-borrow-self-2.rs:111:30: 111:37}>: Stream` + `&'a mut &mut Filter fn(&'a u64) -> &'a u64 {identity::}>, {closure@$DIR/hrtb-doesnt-borrow-self-2.rs:111:30: 111:37}>: Stream` + `&'a mut Filter fn(&'a u64) -> &'a u64 {identity::}>, {closure@$DIR/hrtb-doesnt-borrow-self-2.rs:111:30: 111:37}>: Stream` + --> $DIR/hrtb-doesnt-borrow-self-2.rs:98:50 | LL | impl StreamExt for T where for<'a> &'a mut T: Stream {} | --------- - ^^^^^^ unsatisfied trait bound introduced here = help: items from traits can only be used if the trait is implemented and in scope note: `StreamExt` defines an item `countx`, perhaps you need to implement it - --> $DIR/hrtb-doesnt-borrow-self-2.rs:64:1 + --> $DIR/hrtb-doesnt-borrow-self-2.rs:66:1 | LL | pub trait StreamExt | ^^^^^^^^^^^^^^^^^^^ + = note: the full name for the type has been written to '$TEST_BUILD_DIR/hrtb-doesnt-borrow-self-2.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error: aborting due to 1 previous error diff --git a/tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak2.rs b/tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak2.rs index 09450089adaa8..a5e5bb8df1fb3 100644 --- a/tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak2.rs +++ b/tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak2.rs @@ -1,3 +1,6 @@ +// FIXME(estebank): diagnostics with long type paths that don't print out the full path anywhere +// still prints the note explaining where the type was written to. +//@ compile-flags: -Zwrite-long-types-to-disk=yes use std::cell::Cell; use std::rc::Rc; @@ -21,11 +24,15 @@ fn main() { //~^ ERROR `Rc>` cannot be sent between threads safely //~| NOTE `Rc>` cannot be sent between threads safely //~| NOTE required by a bound + //~| NOTE the full name for the type has been written + //~| NOTE consider using `--verbose` send(after()); //~^ ERROR `Rc>` cannot be sent between threads safely //~| NOTE `Rc>` cannot be sent between threads safely //~| NOTE required by a bound + //~| NOTE the full name for the type has been written + //~| NOTE consider using `--verbose` } // Deferred path, main has to wait until typeck finishes, diff --git a/tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak2.stderr b/tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak2.stderr index 52fa28145d664..1c65d236a1142 100644 --- a/tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak2.stderr +++ b/tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak2.stderr @@ -1,5 +1,5 @@ error[E0277]: `Rc>` cannot be sent between threads safely - --> $DIR/auto-trait-leak2.rs:20:10 + --> $DIR/auto-trait-leak2.rs:23:10 | LL | fn before() -> impl Fn(i32) { | ------------ within this `impl Fn(i32)` @@ -11,23 +11,25 @@ LL | send(before()); | = help: within `impl Fn(i32)`, the trait `Send` is not implemented for `Rc>` note: required because it's used within this closure - --> $DIR/auto-trait-leak2.rs:10:5 + --> $DIR/auto-trait-leak2.rs:13:5 | LL | move |x| p.set(x) | ^^^^^^^^ note: required because it appears within the type `impl Fn(i32)` - --> $DIR/auto-trait-leak2.rs:5:16 + --> $DIR/auto-trait-leak2.rs:8:16 | LL | fn before() -> impl Fn(i32) { | ^^^^^^^^^^^^ note: required by a bound in `send` - --> $DIR/auto-trait-leak2.rs:13:12 + --> $DIR/auto-trait-leak2.rs:16:12 | LL | fn send(_: T) {} | ^^^^ required by this bound in `send` + = note: the full name for the type has been written to '$TEST_BUILD_DIR/auto-trait-leak2.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error[E0277]: `Rc>` cannot be sent between threads safely - --> $DIR/auto-trait-leak2.rs:25:10 + --> $DIR/auto-trait-leak2.rs:30:10 | LL | send(after()); | ---- ^^^^^^^ `Rc>` cannot be sent between threads safely @@ -39,20 +41,22 @@ LL | fn after() -> impl Fn(i32) { | = help: within `impl Fn(i32)`, the trait `Send` is not implemented for `Rc>` note: required because it's used within this closure - --> $DIR/auto-trait-leak2.rs:38:5 + --> $DIR/auto-trait-leak2.rs:45:5 | LL | move |x| p.set(x) | ^^^^^^^^ note: required because it appears within the type `impl Fn(i32)` - --> $DIR/auto-trait-leak2.rs:33:15 + --> $DIR/auto-trait-leak2.rs:40:15 | LL | fn after() -> impl Fn(i32) { | ^^^^^^^^^^^^ note: required by a bound in `send` - --> $DIR/auto-trait-leak2.rs:13:12 + --> $DIR/auto-trait-leak2.rs:16:12 | LL | fn send(_: T) {} | ^^^^ required by this bound in `send` + = note: the full name for the type has been written to '$TEST_BUILD_DIR/auto-trait-leak2.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error: aborting due to 2 previous errors diff --git a/tests/ui/inference/really-long-type-in-let-binding-without-sufficient-type-info.rs b/tests/ui/inference/really-long-type-in-let-binding-without-sufficient-type-info.rs index 4fd15eea9e0f1..f1353f1805d8f 100644 --- a/tests/ui/inference/really-long-type-in-let-binding-without-sufficient-type-info.rs +++ b/tests/ui/inference/really-long-type-in-let-binding-without-sufficient-type-info.rs @@ -1,3 +1,4 @@ +//@ compile-flags: -Zwrite-long-types-to-disk=yes type A = (i32, i32, i32, i32); type B = (A, A, A, A); type C = (B, B, B, B); diff --git a/tests/ui/inference/really-long-type-in-let-binding-without-sufficient-type-info.stderr b/tests/ui/inference/really-long-type-in-let-binding-without-sufficient-type-info.stderr index 65fe2ffcb7f16..fc05d9b94d9e5 100644 --- a/tests/ui/inference/really-long-type-in-let-binding-without-sufficient-type-info.stderr +++ b/tests/ui/inference/really-long-type-in-let-binding-without-sufficient-type-info.stderr @@ -1,9 +1,10 @@ -error[E0282]: type annotations needed for `Result<_, ((((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32))), (((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32))), (((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32))), (((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32)), ((i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32), (i32, i32, i32, i32))))>` - --> $DIR/really-long-type-in-let-binding-without-sufficient-type-info.rs:7:9 +error[E0282]: type annotations needed for `Result<_, (((..., ..., ..., ...), ..., ..., ...), ..., ..., ...)>` + --> $DIR/really-long-type-in-let-binding-without-sufficient-type-info.rs:8:9 | LL | let y = Err(x); | ^ ------ type must be known at this point | + = note: the full type name has been written to '$TEST_BUILD_DIR/really-long-type-in-let-binding-without-sufficient-type-info.long-type-$LONG_TYPE_HASH.txt' help: consider giving `y` an explicit type, where the type for type parameter `T` is specified | LL | let y: Result = Err(x); diff --git a/tests/ui/interior-mutability/interior-mutability.rs b/tests/ui/interior-mutability/interior-mutability.rs index c704acc22af6b..f162d19966008 100644 --- a/tests/ui/interior-mutability/interior-mutability.rs +++ b/tests/ui/interior-mutability/interior-mutability.rs @@ -1,3 +1,6 @@ +// FIXME(estebank): diagnostics with long type paths that don't print out the full path anywhere +// still prints the note explaining where the type was written to. +//@ compile-flags: -Zwrite-long-types-to-disk=yes use std::cell::Cell; use std::panic::catch_unwind; fn main() { diff --git a/tests/ui/interior-mutability/interior-mutability.stderr b/tests/ui/interior-mutability/interior-mutability.stderr index cfc64445bf3be..50ea6d0f5dc8c 100644 --- a/tests/ui/interior-mutability/interior-mutability.stderr +++ b/tests/ui/interior-mutability/interior-mutability.stderr @@ -1,5 +1,5 @@ error[E0277]: the type `UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary - --> $DIR/interior-mutability.rs:5:18 + --> $DIR/interior-mutability.rs:8:18 | LL | catch_unwind(|| { x.set(23); }); | ------------ ^^^^^^^^^^^^^^^^^ `UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary @@ -11,12 +11,14 @@ note: required because it appears within the type `Cell` --> $SRC_DIR/core/src/cell.rs:LL:COL = note: required for `&Cell` to implement `UnwindSafe` note: required because it's used within this closure - --> $DIR/interior-mutability.rs:5:18 + --> $DIR/interior-mutability.rs:8:18 | LL | catch_unwind(|| { x.set(23); }); | ^^ note: required by a bound in `std::panic::catch_unwind` --> $SRC_DIR/std/src/panic.rs:LL:COL + = note: the full name for the type has been written to '$TEST_BUILD_DIR/interior-mutability.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error: aborting due to 1 previous error diff --git a/tests/ui/methods/inherent-bound-in-probe.rs b/tests/ui/methods/inherent-bound-in-probe.rs index 4add93e808d22..39b4ba983e442 100644 --- a/tests/ui/methods/inherent-bound-in-probe.rs +++ b/tests/ui/methods/inherent-bound-in-probe.rs @@ -1,3 +1,4 @@ +//@ compile-flags: -Zwrite-long-types-to-disk=yes // Fixes #110131 // // The issue is that we were constructing an `ImplDerived` cause code for the diff --git a/tests/ui/methods/inherent-bound-in-probe.stderr b/tests/ui/methods/inherent-bound-in-probe.stderr index 77aed390c9ace..b7751ca471436 100644 --- a/tests/ui/methods/inherent-bound-in-probe.stderr +++ b/tests/ui/methods/inherent-bound-in-probe.stderr @@ -1,5 +1,5 @@ error[E0277]: `Helper<'a, T>` is not an iterator - --> $DIR/inherent-bound-in-probe.rs:38:21 + --> $DIR/inherent-bound-in-probe.rs:39:21 | LL | type IntoIter = Helper<'a, T>; | ^^^^^^^^^^^^^ `Helper<'a, T>` is not an iterator @@ -9,14 +9,14 @@ note: required by a bound in `std::iter::IntoIterator::IntoIter` --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL error[E0275]: overflow evaluating the requirement `&_: IntoIterator` - --> $DIR/inherent-bound-in-probe.rs:42:9 + --> $DIR/inherent-bound-in-probe.rs:43:9 | LL | Helper::new(&self.0) | ^^^^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`inherent_bound_in_probe`) note: required for `&BitReaderWrapper<_>` to implement `IntoIterator` - --> $DIR/inherent-bound-in-probe.rs:32:13 + --> $DIR/inherent-bound-in-probe.rs:33:13 | LL | impl<'a, T> IntoIterator for &'a BitReaderWrapper | ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^ @@ -24,15 +24,17 @@ LL | where LL | &'a T: IntoIterator, | ------------- unsatisfied trait bound introduced here = note: 126 redundant requirements hidden - = note: required for `&BitReaderWrapper>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` to implement `IntoIterator` + = note: required for `&BitReaderWrapper>>` to implement `IntoIterator` note: required by a bound in `Helper` - --> $DIR/inherent-bound-in-probe.rs:16:12 + --> $DIR/inherent-bound-in-probe.rs:17:12 | LL | struct Helper<'a, T> | ------ required by a bound in this struct LL | where LL | &'a T: IntoIterator, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Helper` + = note: the full name for the type has been written to '$TEST_BUILD_DIR/inherent-bound-in-probe.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error: aborting due to 2 previous errors diff --git a/tests/ui/methods/probe-error-on-infinite-deref.rs b/tests/ui/methods/probe-error-on-infinite-deref.rs index 85c1c0c09c13e..196d026438be8 100644 --- a/tests/ui/methods/probe-error-on-infinite-deref.rs +++ b/tests/ui/methods/probe-error-on-infinite-deref.rs @@ -1,3 +1,4 @@ +//@ compile-flags: -Zwrite-long-types-to-disk=yes use std::ops::Deref; // Make sure that method probe error reporting doesn't get too tangled up diff --git a/tests/ui/methods/probe-error-on-infinite-deref.stderr b/tests/ui/methods/probe-error-on-infinite-deref.stderr index 57a9ca2eaa80f..6148b00116302 100644 --- a/tests/ui/methods/probe-error-on-infinite-deref.stderr +++ b/tests/ui/methods/probe-error-on-infinite-deref.stderr @@ -1,13 +1,15 @@ -error[E0055]: reached the recursion limit while auto-dereferencing `Wrap>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - --> $DIR/probe-error-on-infinite-deref.rs:13:13 +error[E0055]: reached the recursion limit while auto-dereferencing `Wrap>>>>>>>>>>` + --> $DIR/probe-error-on-infinite-deref.rs:14:13 | LL | Wrap(1).lmao(); | ^^^^ deref recursion limit reached | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`probe_error_on_infinite_deref`) + = note: the full name for the type has been written to '$TEST_BUILD_DIR/probe-error-on-infinite-deref.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error[E0599]: no method named `lmao` found for struct `Wrap<{integer}>` in the current scope - --> $DIR/probe-error-on-infinite-deref.rs:13:13 + --> $DIR/probe-error-on-infinite-deref.rs:14:13 | LL | struct Wrap(T); | -------------- method `lmao` not found for this struct diff --git a/tests/ui/never_type/defaulted-never-note.fallback.stderr b/tests/ui/never_type/defaulted-never-note.fallback.stderr index fe9a924f64a0f..7526a399bf177 100644 --- a/tests/ui/never_type/defaulted-never-note.fallback.stderr +++ b/tests/ui/never_type/defaulted-never-note.fallback.stderr @@ -8,7 +8,7 @@ LL | foo(_x); | = help: the trait `ImplementedForUnitButNotNever` is implemented for `()` = note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 for more information) - = help: did you intend to use the type `()` here instead? + = help: you might have intended to use the type `()` here instead note: required by a bound in `foo` --> $DIR/defaulted-never-note.rs:25:11 | diff --git a/tests/ui/never_type/defaulted-never-note.rs b/tests/ui/never_type/defaulted-never-note.rs index badb5d4c51d83..71f0d9fa5bb5f 100644 --- a/tests/ui/never_type/defaulted-never-note.rs +++ b/tests/ui/never_type/defaulted-never-note.rs @@ -35,7 +35,7 @@ fn smeg() { //[fallback]~| HELP trait `ImplementedForUnitButNotNever` is implemented for `()` //[fallback]~| NOTE this error might have been caused //[fallback]~| NOTE required by a bound introduced by this call - //[fallback]~| HELP did you intend + //[fallback]~| HELP you might have intended to use the type `()` } fn main() { diff --git a/tests/ui/never_type/diverging-fallback-no-leak.fallback.stderr b/tests/ui/never_type/diverging-fallback-no-leak.fallback.stderr index c5463814475c7..610c687194b76 100644 --- a/tests/ui/never_type/diverging-fallback-no-leak.fallback.stderr +++ b/tests/ui/never_type/diverging-fallback-no-leak.fallback.stderr @@ -10,7 +10,7 @@ LL | unconstrained_arg(return); () i32 = note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 for more information) - = help: did you intend to use the type `()` here instead? + = help: you might have intended to use the type `()` here instead note: required by a bound in `unconstrained_arg` --> $DIR/diverging-fallback-no-leak.rs:12:25 | diff --git a/tests/ui/recursion/issue-23122-2.rs b/tests/ui/recursion/issue-23122-2.rs index 95e1f60d8b029..d4f13e9fa5587 100644 --- a/tests/ui/recursion/issue-23122-2.rs +++ b/tests/ui/recursion/issue-23122-2.rs @@ -1,3 +1,4 @@ +//@ compile-flags: -Zwrite-long-types-to-disk=yes trait Next { type Next: Next; } diff --git a/tests/ui/recursion/issue-23122-2.stderr b/tests/ui/recursion/issue-23122-2.stderr index c5774cc188829..de402d65e6d6a 100644 --- a/tests/ui/recursion/issue-23122-2.stderr +++ b/tests/ui/recursion/issue-23122-2.stderr @@ -1,17 +1,19 @@ error[E0275]: overflow evaluating the requirement `<<<<<<<... as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next: Sized` - --> $DIR/issue-23122-2.rs:10:17 + --> $DIR/issue-23122-2.rs:11:17 | LL | type Next = as Next>::Next; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_23122_2`) -note: required for `GetNext<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next>` to implement `Next` - --> $DIR/issue-23122-2.rs:9:15 +note: required for `GetNext<<<<... as Next>::Next as Next>::Next as Next>::Next>` to implement `Next` + --> $DIR/issue-23122-2.rs:10:15 | LL | impl Next for GetNext { | - ^^^^ ^^^^^^^^^^ | | | unsatisfied trait bound introduced here + = note: the full name for the type has been written to '$TEST_BUILD_DIR/issue-23122-2.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error: aborting due to 1 previous error diff --git a/tests/ui/recursion/issue-38591-non-regular-dropck-recursion.rs b/tests/ui/recursion/issue-38591-non-regular-dropck-recursion.rs index 7b7b1a9580bdc..c219a920bb4f1 100644 --- a/tests/ui/recursion/issue-38591-non-regular-dropck-recursion.rs +++ b/tests/ui/recursion/issue-38591-non-regular-dropck-recursion.rs @@ -1,3 +1,4 @@ +//@ compile-flags: -Zwrite-long-types-to-disk=yes // `S` is infinitely recursing so it's not possible to generate a finite // drop impl. // diff --git a/tests/ui/recursion/issue-38591-non-regular-dropck-recursion.stderr b/tests/ui/recursion/issue-38591-non-regular-dropck-recursion.stderr index 409f63b91b64d..cf3bc4578a727 100644 --- a/tests/ui/recursion/issue-38591-non-regular-dropck-recursion.stderr +++ b/tests/ui/recursion/issue-38591-non-regular-dropck-recursion.stderr @@ -1,10 +1,12 @@ error[E0320]: overflow while adding drop-check rules for `S` - --> $DIR/issue-38591-non-regular-dropck-recursion.rs:11:6 + --> $DIR/issue-38591-non-regular-dropck-recursion.rs:12:6 | LL | fn f(x: S) {} | ^ | - = note: overflowed on `S` + = note: overflowed on `S` + = note: the full name for the type has been written to '$TEST_BUILD_DIR/issue-38591-non-regular-dropck-recursion.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error: aborting due to 1 previous error diff --git a/tests/ui/recursion/issue-83150.rs b/tests/ui/recursion/issue-83150.rs index b720c168187b8..9194ce1ab17a8 100644 --- a/tests/ui/recursion/issue-83150.rs +++ b/tests/ui/recursion/issue-83150.rs @@ -1,6 +1,6 @@ //~ ERROR overflow evaluating the requirement `Map<&mut std::ops::Range, {closure@$DIR/issue-83150.rs:12:24: 12:27}>: Iterator` //@ build-fail -//@ compile-flags: -Copt-level=0 +//@ compile-flags: -Copt-level=0 -Zwrite-long-types-to-disk=yes fn main() { let mut iter = 0u8..1; diff --git a/tests/ui/recursion/issue-83150.stderr b/tests/ui/recursion/issue-83150.stderr index 600922f1e57a7..a245b001badef 100644 --- a/tests/ui/recursion/issue-83150.stderr +++ b/tests/ui/recursion/issue-83150.stderr @@ -13,9 +13,11 @@ LL | func(&mut iter.map(|x| x + 1)) error[E0275]: overflow evaluating the requirement `Map<&mut std::ops::Range, {closure@$DIR/issue-83150.rs:12:24: 12:27}>: Iterator` | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_83150`) - = note: required for `&mut Map<&mut std::ops::Range, {closure@$DIR/issue-83150.rs:12:24: 12:27}>` to implement `Iterator` + = 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<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut Map<&mut std::ops::Range, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>` to implement `Iterator` + = note: required for `&mut Map<&mut Map<&mut Map<&mut Map<&mut ..., ...>, ...>, ...>, ...>` 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 error: aborting due to 1 previous error; 1 warning emitted diff --git a/tests/ui/traits/issue-91949-hangs-on-recursion.rs b/tests/ui/traits/issue-91949-hangs-on-recursion.rs index 7c9ae09349aab..434cf00fc4b4b 100644 --- a/tests/ui/traits/issue-91949-hangs-on-recursion.rs +++ b/tests/ui/traits/issue-91949-hangs-on-recursion.rs @@ -1,6 +1,6 @@ //~ ERROR overflow evaluating the requirement ` as Iterator>::Item == ()` //@ build-fail -//@ compile-flags: -Zinline-mir=no +//@ compile-flags: -Zinline-mir=no -Zwrite-long-types-to-disk=yes // Regression test for #91949. // This hanged *forever* on 1.56, fixed by #90423. diff --git a/tests/ui/traits/issue-91949-hangs-on-recursion.stderr b/tests/ui/traits/issue-91949-hangs-on-recursion.stderr index c2f09371cf7fc..a179107885ab2 100644 --- a/tests/ui/traits/issue-91949-hangs-on-recursion.stderr +++ b/tests/ui/traits/issue-91949-hangs-on-recursion.stderr @@ -24,7 +24,9 @@ LL | impl> Iterator for IteratorOfWrapped { | | | unsatisfied trait bound introduced here = note: 256 redundant requirements hidden - = note: required for `IteratorOfWrapped<(), Map>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>, {closure@$DIR/issue-91949-hangs-on-recursion.rs:26:45: 26:48}>>` to implement `Iterator` + = note: required for `IteratorOfWrapped<(), Map>, ...>>` 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 error: aborting due to 1 previous error; 1 warning emitted From 7b79e47a02a26044025f1cc90fe533e3084306fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 16 Jul 2025 20:09:59 +0000 Subject: [PATCH 02/13] Remove useless `note` When we don't actually print out a shortened type we don't need the "use `--verbose`" note. --- .../src/error_reporting/traits/suggestions.rs | 25 ++++++++++++------- .../auto-trait-leakage/auto-trait-leak2.rs | 6 ----- .../auto-trait-leak2.stderr | 20 ++++++--------- .../interior-mutability.rs | 2 -- .../interior-mutability.stderr | 6 ++--- 5 files changed, 26 insertions(+), 33 deletions(-) diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs index 3cc97769e215d..d350f4ff73ac5 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs @@ -3333,17 +3333,22 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { tcx.async_fn_trait_kind_from_def_id(data.parent_trait_pred.def_id()).is_some(); if !is_upvar_tys_infer_tuple && !is_builtin_async_fn_trait { - let ty_str = tcx.short_string(ty, err.long_ty_path()); - let msg = format!("required because it appears within the type `{ty_str}`"); + let mut msg = || { + let ty_str = tcx.short_string(ty, err.long_ty_path()); + format!("required because it appears within the type `{ty_str}`") + }; match ty.kind() { - ty::Adt(def, _) => match tcx.opt_item_ident(def.did()) { - Some(ident) => { - err.span_note(ident.span, msg); - } - None => { - err.note(msg); + ty::Adt(def, _) => { + let msg = msg(); + match tcx.opt_item_ident(def.did()) { + Some(ident) => { + err.span_note(ident.span, msg); + } + None => { + err.note(msg); + } } - }, + } ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) => { // If the previous type is async fn, this is the future generated by the body of an async function. // Avoid printing it twice (it was already printed in the `ty::Coroutine` arm below). @@ -3363,6 +3368,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { { // See comment above; skip printing twice. } else { + let msg = msg(); err.span_note(tcx.def_span(def_id), msg); } } @@ -3392,6 +3398,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { err.note("`str` is considered to contain a `[u8]` slice for auto trait purposes"); } _ => { + let msg = msg(); err.note(msg); } }; diff --git a/tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak2.rs b/tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak2.rs index a5e5bb8df1fb3..ead81bf337469 100644 --- a/tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak2.rs +++ b/tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak2.rs @@ -1,5 +1,3 @@ -// FIXME(estebank): diagnostics with long type paths that don't print out the full path anywhere -// still prints the note explaining where the type was written to. //@ compile-flags: -Zwrite-long-types-to-disk=yes use std::cell::Cell; use std::rc::Rc; @@ -24,15 +22,11 @@ fn main() { //~^ ERROR `Rc>` cannot be sent between threads safely //~| NOTE `Rc>` cannot be sent between threads safely //~| NOTE required by a bound - //~| NOTE the full name for the type has been written - //~| NOTE consider using `--verbose` send(after()); //~^ ERROR `Rc>` cannot be sent between threads safely //~| NOTE `Rc>` cannot be sent between threads safely //~| NOTE required by a bound - //~| NOTE the full name for the type has been written - //~| NOTE consider using `--verbose` } // Deferred path, main has to wait until typeck finishes, diff --git a/tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak2.stderr b/tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak2.stderr index 1c65d236a1142..ba76d9ba2b8fc 100644 --- a/tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak2.stderr +++ b/tests/ui/impl-trait/auto-trait-leakage/auto-trait-leak2.stderr @@ -1,5 +1,5 @@ error[E0277]: `Rc>` cannot be sent between threads safely - --> $DIR/auto-trait-leak2.rs:23:10 + --> $DIR/auto-trait-leak2.rs:21:10 | LL | fn before() -> impl Fn(i32) { | ------------ within this `impl Fn(i32)` @@ -11,25 +11,23 @@ LL | send(before()); | = help: within `impl Fn(i32)`, the trait `Send` is not implemented for `Rc>` note: required because it's used within this closure - --> $DIR/auto-trait-leak2.rs:13:5 + --> $DIR/auto-trait-leak2.rs:11:5 | LL | move |x| p.set(x) | ^^^^^^^^ note: required because it appears within the type `impl Fn(i32)` - --> $DIR/auto-trait-leak2.rs:8:16 + --> $DIR/auto-trait-leak2.rs:6:16 | LL | fn before() -> impl Fn(i32) { | ^^^^^^^^^^^^ note: required by a bound in `send` - --> $DIR/auto-trait-leak2.rs:16:12 + --> $DIR/auto-trait-leak2.rs:14:12 | LL | fn send(_: T) {} | ^^^^ required by this bound in `send` - = note: the full name for the type has been written to '$TEST_BUILD_DIR/auto-trait-leak2.long-type-$LONG_TYPE_HASH.txt' - = note: consider using `--verbose` to print the full type name to the console error[E0277]: `Rc>` cannot be sent between threads safely - --> $DIR/auto-trait-leak2.rs:30:10 + --> $DIR/auto-trait-leak2.rs:26:10 | LL | send(after()); | ---- ^^^^^^^ `Rc>` cannot be sent between threads safely @@ -41,22 +39,20 @@ LL | fn after() -> impl Fn(i32) { | = help: within `impl Fn(i32)`, the trait `Send` is not implemented for `Rc>` note: required because it's used within this closure - --> $DIR/auto-trait-leak2.rs:45:5 + --> $DIR/auto-trait-leak2.rs:39:5 | LL | move |x| p.set(x) | ^^^^^^^^ note: required because it appears within the type `impl Fn(i32)` - --> $DIR/auto-trait-leak2.rs:40:15 + --> $DIR/auto-trait-leak2.rs:34:15 | LL | fn after() -> impl Fn(i32) { | ^^^^^^^^^^^^ note: required by a bound in `send` - --> $DIR/auto-trait-leak2.rs:16:12 + --> $DIR/auto-trait-leak2.rs:14:12 | LL | fn send(_: T) {} | ^^^^ required by this bound in `send` - = note: the full name for the type has been written to '$TEST_BUILD_DIR/auto-trait-leak2.long-type-$LONG_TYPE_HASH.txt' - = note: consider using `--verbose` to print the full type name to the console error: aborting due to 2 previous errors diff --git a/tests/ui/interior-mutability/interior-mutability.rs b/tests/ui/interior-mutability/interior-mutability.rs index f162d19966008..7e4fe76852d76 100644 --- a/tests/ui/interior-mutability/interior-mutability.rs +++ b/tests/ui/interior-mutability/interior-mutability.rs @@ -1,5 +1,3 @@ -// FIXME(estebank): diagnostics with long type paths that don't print out the full path anywhere -// still prints the note explaining where the type was written to. //@ compile-flags: -Zwrite-long-types-to-disk=yes use std::cell::Cell; use std::panic::catch_unwind; diff --git a/tests/ui/interior-mutability/interior-mutability.stderr b/tests/ui/interior-mutability/interior-mutability.stderr index 50ea6d0f5dc8c..5a959d14c8a91 100644 --- a/tests/ui/interior-mutability/interior-mutability.stderr +++ b/tests/ui/interior-mutability/interior-mutability.stderr @@ -1,5 +1,5 @@ error[E0277]: the type `UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary - --> $DIR/interior-mutability.rs:8:18 + --> $DIR/interior-mutability.rs:6:18 | LL | catch_unwind(|| { x.set(23); }); | ------------ ^^^^^^^^^^^^^^^^^ `UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary @@ -11,14 +11,12 @@ note: required because it appears within the type `Cell` --> $SRC_DIR/core/src/cell.rs:LL:COL = note: required for `&Cell` to implement `UnwindSafe` note: required because it's used within this closure - --> $DIR/interior-mutability.rs:8:18 + --> $DIR/interior-mutability.rs:6:18 | LL | catch_unwind(|| { x.set(23); }); | ^^ note: required by a bound in `std::panic::catch_unwind` --> $SRC_DIR/std/src/panic.rs:LL:COL - = note: the full name for the type has been written to '$TEST_BUILD_DIR/interior-mutability.long-type-$LONG_TYPE_HASH.txt' - = note: consider using `--verbose` to print the full type name to the console error: aborting due to 1 previous error From 6404466ddc9f65b09007d0cd25652110d2aac0f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 16 Jul 2025 21:57:59 +0000 Subject: [PATCH 03/13] Tweak use of `short_string` in method errors --- compiler/rustc_hir_typeck/messages.ftl | 4 +- compiler/rustc_hir_typeck/src/errors.rs | 8 +- .../rustc_hir_typeck/src/method/suggest.rs | 115 ++++++++---------- .../rustc_confusables_std_cases.stderr | 4 +- .../issue-18343.stderr | 2 +- .../ui/confuse-field-and-method/issue-2392.rs | 2 - .../issue-2392.stderr | 34 +++--- ...y_owner_parent_found_in_diagnostics.stderr | 2 +- tests/ui/issues/issue-41880.stderr | 2 +- .../methods/call_method_unknown_referent.rs | 2 +- .../call_method_unknown_referent.stderr | 2 +- ...ethod-not-found-generic-arg-elision.stderr | 8 +- tests/ui/methods/untrimmed-path-type.stderr | 2 +- ...itrary_self_type_infinite_recursion.stderr | 2 +- ..._types_not_allow_call_with_no_deref.stderr | 4 +- ...arbitrary_self_types_pin_needing_borrow.rs | 2 +- ...trary_self_types_pin_needing_borrow.stderr | 2 +- tests/ui/simd/libm_no_std_cant_float.stderr | 12 +- tests/ui/suggestions/enum-method-probe.fixed | 12 +- tests/ui/suggestions/enum-method-probe.rs | 12 +- tests/ui/suggestions/enum-method-probe.stderr | 12 +- tests/ui/suggestions/field-has-method.rs | 2 +- tests/ui/suggestions/field-has-method.stderr | 2 +- tests/ui/suggestions/inner_type.fixed | 10 +- tests/ui/suggestions/inner_type.rs | 10 +- tests/ui/suggestions/inner_type.stderr | 10 +- tests/ui/suggestions/inner_type2.rs | 4 +- tests/ui/suggestions/inner_type2.stderr | 4 +- 28 files changed, 137 insertions(+), 150 deletions(-) diff --git a/compiler/rustc_hir_typeck/messages.ftl b/compiler/rustc_hir_typeck/messages.ftl index bac4d70103c3d..1ed0756fdd6a7 100644 --- a/compiler/rustc_hir_typeck/messages.ftl +++ b/compiler/rustc_hir_typeck/messages.ftl @@ -159,7 +159,7 @@ hir_typeck_lossy_provenance_ptr2int = .suggestion = use `.addr()` to obtain the address of a pointer .help = if you can't comply with strict provenance and need to expose the pointer provenance you can use `.expose_provenance()` instead -hir_typeck_missing_parentheses_in_range = can't call method `{$method_name}` on type `{$ty_str}` +hir_typeck_missing_parentheses_in_range = can't call method `{$method_name}` on type `{$ty}` hir_typeck_naked_asm_outside_naked_fn = the `naked_asm!` macro can only be used in functions marked with `#[unsafe(naked)]` @@ -184,7 +184,7 @@ hir_typeck_never_type_fallback_flowing_into_unsafe_path = never type fallback af hir_typeck_never_type_fallback_flowing_into_unsafe_union_field = never type fallback affects this union access .help = specify the type explicitly -hir_typeck_no_associated_item = no {$item_kind} named `{$item_ident}` found for {$ty_prefix} `{$ty_str}`{$trait_missing_method -> +hir_typeck_no_associated_item = no {$item_kind} named `{$item_ident}` found for {$ty_prefix} `{$ty}`{$trait_missing_method -> [true] {""} *[other] {" "}in the current scope } diff --git a/compiler/rustc_hir_typeck/src/errors.rs b/compiler/rustc_hir_typeck/src/errors.rs index a8bb6956f1016..d15d092b7d3da 100644 --- a/compiler/rustc_hir_typeck/src/errors.rs +++ b/compiler/rustc_hir_typeck/src/errors.rs @@ -200,11 +200,11 @@ pub(crate) enum ExplicitDestructorCallSugg { #[derive(Diagnostic)] #[diag(hir_typeck_missing_parentheses_in_range, code = E0689)] -pub(crate) struct MissingParenthesesInRange { +pub(crate) struct MissingParenthesesInRange<'tcx> { #[primary_span] #[label(hir_typeck_missing_parentheses_in_range)] pub span: Span, - pub ty_str: String, + pub ty: Ty<'tcx>, pub method_name: String, #[subdiagnostic] pub add_missing_parentheses: Option, @@ -828,13 +828,13 @@ pub(crate) struct UnlabeledCfInWhileCondition<'a> { #[derive(Diagnostic)] #[diag(hir_typeck_no_associated_item, code = E0599)] -pub(crate) struct NoAssociatedItem { +pub(crate) struct NoAssociatedItem<'tcx> { #[primary_span] pub span: Span, pub item_kind: &'static str, pub item_ident: Ident, pub ty_prefix: Cow<'static, str>, - pub ty_str: String, + pub ty: Ty<'tcx>, pub trait_missing_method: bool, } diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index 2a7a344db1584..3d1ce77bc0641 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -407,7 +407,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { &self, self_source: SelfSource<'tcx>, method_name: Ident, - ty_str_reported: &str, + unsatisfied_predicates: &[( + ty::Predicate<'tcx>, + Option>, + Option>, + )], + ty: Ty<'tcx>, err: &mut Diag<'_>, ) { #[derive(Debug)] @@ -570,17 +575,44 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut span = MultiSpan::from_span(sugg_let.span); span.push_span_label(sugg_let.span, format!("`{rcvr_name}` of type `{self_ty}` that has method `{method_name}` defined earlier here")); + + // Don't show generic arguments when the method can't be found in any implementation (#81576). + let mut ty_str = None; + if let ty::Adt(_, generics) = ty.kind() { + if generics.len() > 0 { + let mut autoderef = self.autoderef(DUMMY_SP, ty).silence_errors(); + let candidate_found = autoderef.any(|(ty, _)| { + if let ty::Adt(adt_def, _) = ty.kind() { + self.tcx.inherent_impls(adt_def.did()).into_iter().any( + |def_id| { + self.associated_value(*def_id, method_name).is_some() + }, + ) + } else { + false + } + }); + let has_deref = autoderef.step_count() > 0; + if !candidate_found && !has_deref && unsatisfied_predicates.is_empty() { + let t = with_forced_trimmed_paths!(ty.to_string()); + if let Some((path_string, _)) = t.split_once('<') { + ty_str = Some(path_string.to_string()); + } + } + } + } + + let ty = + ty_str.unwrap_or_else(|| self.tcx.short_string(ty, err.long_ty_path())); span.push_span_label( self.tcx.hir_span(recv_id), - format!( - "earlier `{rcvr_name}` shadowed here with type `{ty_str_reported}`" - ), + format!("earlier `{rcvr_name}` shadowed here with type `{ty}`"), ); err.span_note( span, format!( "there's an earlier shadowed binding `{rcvr_name}` of type `{self_ty}` \ - that has method `{method_name}` available" + that has method `{method_name}` available" ), ); } @@ -606,15 +638,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let tcx = self.tcx; let rcvr_ty = self.resolve_vars_if_possible(rcvr_ty); let mut ty_file = None; - let (ty_str, short_ty_str) = - if trait_missing_method && let ty::Dynamic(predicates, _, _) = rcvr_ty.kind() { - (predicates.to_string(), with_forced_trimmed_paths!(predicates.to_string())) - } else { - ( - tcx.short_string(rcvr_ty, &mut ty_file), - with_forced_trimmed_paths!(rcvr_ty.to_string()), - ) - }; let is_method = mode == Mode::MethodCall; let unsatisfied_predicates = &no_match_data.unsatisfied_predicates; let similar_candidate = no_match_data.similar_candidate; @@ -633,15 +656,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // We could pass the file for long types into these two, but it isn't strictly necessary // given how targeted they are. - if let Err(guar) = self.report_failed_method_call_on_range_end( - tcx, - rcvr_ty, - source, - span, - item_ident, - &short_ty_str, - &mut ty_file, - ) { + if let Err(guar) = + self.report_failed_method_call_on_range_end(tcx, rcvr_ty, source, span, item_ident) + { return guar; } if let Err(guar) = self.report_failed_method_call_on_numerical_infer_var( @@ -651,37 +668,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { span, item_kind, item_ident, - &short_ty_str, &mut ty_file, ) { return guar; } span = item_ident.span; - // Don't show generic arguments when the method can't be found in any implementation (#81576). - let mut ty_str_reported = ty_str.clone(); - if let ty::Adt(_, generics) = rcvr_ty.kind() { - if generics.len() > 0 { - let mut autoderef = self.autoderef(span, rcvr_ty).silence_errors(); - let candidate_found = autoderef.any(|(ty, _)| { - if let ty::Adt(adt_def, _) = ty.kind() { - self.tcx - .inherent_impls(adt_def.did()) - .into_iter() - .any(|def_id| self.associated_value(*def_id, item_ident).is_some()) - } else { - false - } - }); - let has_deref = autoderef.step_count() > 0; - if !candidate_found && !has_deref && unsatisfied_predicates.is_empty() { - if let Some((path_string, _)) = ty_str.split_once('<') { - ty_str_reported = path_string.to_string(); - } - } - } - } - let is_write = sugg_span.ctxt().outer_expn_data().macro_def_id.is_some_and(|def_id| { tcx.is_diagnostic_item(sym::write_macro, def_id) || tcx.is_diagnostic_item(sym::writeln_macro, def_id) @@ -699,16 +691,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } else { rcvr_ty.prefix_string(self.tcx) }, - ty_str: ty_str_reported.clone(), + ty: rcvr_ty, trait_missing_method, }); - *err.long_ty_path() = ty_file; if is_method { self.suggest_use_shadowed_binding_with_method( source, item_ident, - &ty_str_reported, + &unsatisfied_predicates, + rcvr_ty, &mut err, ); } @@ -739,6 +731,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { err }; + if tcx.sess.source_map().is_multiline(sugg_span) { err.span_label(sugg_span.with_hi(span.lo()), ""); } @@ -755,6 +748,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } if tcx.ty_is_opaque_future(rcvr_ty) && item_ident.name == sym::poll { + let ty_str = self.tcx.short_string(rcvr_ty, err.long_ty_path()); err.help(format!( "method `poll` found on `Pin<&mut {ty_str}>`, \ see documentation for `std::pin::Pin`" @@ -1352,6 +1346,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { (None, None, Vec::new()) }; let primary_message = primary_message.unwrap_or_else(|| { + let ty_str = self.tcx.short_string(rcvr_ty, err.long_ty_path()); format!( "the {item_kind} `{item_ident}` exists for {actual_prefix} `{ty_str}`, \ but its trait bounds were not satisfied" @@ -1414,6 +1409,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut find_candidate_for_method = false; let mut label_span_not_found = |err: &mut Diag<'_>| { + let ty_str = self.tcx.short_string(rcvr_ty, err.long_ty_path()); if unsatisfied_predicates.is_empty() { err.span_label(span, format!("{item_kind} not found in `{ty_str}`")); let is_string_or_ref_str = match rcvr_ty.kind() { @@ -2525,8 +2521,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { source: SelfSource<'tcx>, span: Span, item_name: Ident, - ty_str: &str, - long_ty_path: &mut Option, ) -> Result<(), ErrorGuaranteed> { if let SelfSource::MethodCall(expr) = source { for (_, parent) in tcx.hir_parent_iter(expr.hir_id).take(5) { @@ -2588,18 +2582,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); if pick.is_ok() { let range_span = parent_expr.span.with_hi(expr.span.hi()); - let mut err = self.dcx().create_err(errors::MissingParenthesesInRange { + return Err(self.dcx().emit_err(errors::MissingParenthesesInRange { span, - ty_str: ty_str.to_string(), + ty: actual, method_name: item_name.as_str().to_string(), add_missing_parentheses: Some(errors::AddMissingParenthesesInRange { func_name: item_name.name.as_str().to_string(), left: range_span.shrink_to_lo(), right: range_span.shrink_to_hi(), }), - }); - *err.long_ty_path() = long_ty_path.take(); - return Err(err.emit()); + })); } } } @@ -2615,7 +2607,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { span: Span, item_kind: &str, item_name: Ident, - ty_str: &str, long_ty_path: &mut Option, ) -> Result<(), ErrorGuaranteed> { let found_candidate = all_traits(self.tcx) @@ -2648,14 +2639,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { && !actual.has_concrete_skeleton() && let SelfSource::MethodCall(expr) = source { + let ty_str = self.tcx.short_string(actual, long_ty_path); let mut err = struct_span_code_err!( self.dcx(), span, E0689, - "can't call {} `{}` on ambiguous numeric type `{}`", - item_kind, - item_name, - ty_str + "can't call {item_kind} `{item_name}` on ambiguous numeric type `{ty_str}`" ); *err.long_ty_path() = long_ty_path.take(); let concrete_type = if actual.is_integral() { "i32" } else { "f32" }; diff --git a/tests/ui/attributes/rustc_confusables_std_cases.stderr b/tests/ui/attributes/rustc_confusables_std_cases.stderr index f2d9ebe2c0eae..9129393a3033d 100644 --- a/tests/ui/attributes/rustc_confusables_std_cases.stderr +++ b/tests/ui/attributes/rustc_confusables_std_cases.stderr @@ -1,4 +1,4 @@ -error[E0599]: no method named `push` found for struct `BTreeSet` in the current scope +error[E0599]: no method named `push` found for struct `BTreeSet<_>` in the current scope --> $DIR/rustc_confusables_std_cases.rs:6:7 | LL | x.push(1); @@ -22,7 +22,7 @@ LL - x.push_back(1); LL + x.push(1); | -error[E0599]: no method named `push` found for struct `VecDeque` in the current scope +error[E0599]: no method named `push` found for struct `VecDeque<_>` in the current scope --> $DIR/rustc_confusables_std_cases.rs:12:7 | LL | x.push(1); diff --git a/tests/ui/confuse-field-and-method/issue-18343.stderr b/tests/ui/confuse-field-and-method/issue-18343.stderr index e50c971d837b8..6444681e499fd 100644 --- a/tests/ui/confuse-field-and-method/issue-18343.stderr +++ b/tests/ui/confuse-field-and-method/issue-18343.stderr @@ -1,4 +1,4 @@ -error[E0599]: no method named `closure` found for struct `Obj` in the current scope +error[E0599]: no method named `closure` found for struct `Obj<{closure@$DIR/issue-18343.rs:6:28: 6:30}>` in the current scope --> $DIR/issue-18343.rs:7:7 | LL | struct Obj where F: FnMut() -> u32 { diff --git a/tests/ui/confuse-field-and-method/issue-2392.rs b/tests/ui/confuse-field-and-method/issue-2392.rs index c878b69384768..0f1a162a8c1ef 100644 --- a/tests/ui/confuse-field-and-method/issue-2392.rs +++ b/tests/ui/confuse-field-and-method/issue-2392.rs @@ -1,5 +1,3 @@ -// FIXME(estebank): diagnostics with long type paths that don't print out the full path anywhere -// still prints the note explaining where the type was written to. //@ compile-flags: -Zwrite-long-types-to-disk=yes struct FuncContainer { diff --git a/tests/ui/confuse-field-and-method/issue-2392.stderr b/tests/ui/confuse-field-and-method/issue-2392.stderr index aa456fb3282b3..7dccdd3627df1 100644 --- a/tests/ui/confuse-field-and-method/issue-2392.stderr +++ b/tests/ui/confuse-field-and-method/issue-2392.stderr @@ -1,5 +1,5 @@ -error[E0599]: no method named `closure` found for struct `Obj` in the current scope - --> $DIR/issue-2392.rs:40:15 +error[E0599]: no method named `closure` found for struct `Obj<{closure@issue-2392.rs:37:36}>` in the current scope + --> $DIR/issue-2392.rs:38:15 | LL | struct Obj where F: FnOnce() -> u32 { | ------------- method `closure` not found for this struct @@ -14,8 +14,8 @@ help: to call the closure stored in `closure`, surround the field access with pa LL | (o_closure.closure)(); | + + -error[E0599]: no method named `not_closure` found for struct `Obj` in the current scope - --> $DIR/issue-2392.rs:42:15 +error[E0599]: no method named `not_closure` found for struct `Obj<{closure@issue-2392.rs:37:36}>` in the current scope + --> $DIR/issue-2392.rs:40:15 | LL | struct Obj where F: FnOnce() -> u32 { | ------------- method `not_closure` not found for this struct @@ -28,8 +28,8 @@ LL | o_closure.not_closure(); = note: the full name for the type has been written to '$TEST_BUILD_DIR/issue-2392.long-type-$LONG_TYPE_HASH.txt' = note: consider using `--verbose` to print the full type name to the console -error[E0599]: no method named `closure` found for struct `Obj` in the current scope - --> $DIR/issue-2392.rs:46:12 +error[E0599]: no method named `closure` found for struct `Obj u32 {func}>` in the current scope + --> $DIR/issue-2392.rs:44:12 | LL | struct Obj where F: FnOnce() -> u32 { | ------------- method `closure` not found for this struct @@ -43,7 +43,7 @@ LL | (o_func.closure)(); | + + error[E0599]: no method named `boxed_closure` found for struct `BoxedObj` in the current scope - --> $DIR/issue-2392.rs:49:14 + --> $DIR/issue-2392.rs:47:14 | LL | struct BoxedObj { | --------------- method `boxed_closure` not found for this struct @@ -57,7 +57,7 @@ LL | (boxed_fn.boxed_closure)(); | + + error[E0599]: no method named `boxed_closure` found for struct `BoxedObj` in the current scope - --> $DIR/issue-2392.rs:52:19 + --> $DIR/issue-2392.rs:50:19 | LL | struct BoxedObj { | --------------- method `boxed_closure` not found for this struct @@ -70,8 +70,8 @@ help: to call the trait object stored in `boxed_closure`, surround the field acc LL | (boxed_closure.boxed_closure)(); | + + -error[E0599]: no method named `closure` found for struct `Obj` in the current scope - --> $DIR/issue-2392.rs:57:12 +error[E0599]: no method named `closure` found for struct `Obj u32 {func}>` in the current scope + --> $DIR/issue-2392.rs:55:12 | LL | struct Obj where F: FnOnce() -> u32 { | ------------- method `closure` not found for this struct @@ -84,8 +84,8 @@ help: to call the function stored in `closure`, surround the field access with p LL | (w.wrap.closure)(); | + + -error[E0599]: no method named `not_closure` found for struct `Obj` in the current scope - --> $DIR/issue-2392.rs:59:12 +error[E0599]: no method named `not_closure` found for struct `Obj u32 {func}>` in the current scope + --> $DIR/issue-2392.rs:57:12 | LL | struct Obj where F: FnOnce() -> u32 { | ------------- method `not_closure` not found for this struct @@ -95,8 +95,8 @@ LL | w.wrap.not_closure(); | | | field, not a method -error[E0599]: no method named `closure` found for struct `Obj` in the current scope - --> $DIR/issue-2392.rs:62:24 +error[E0599]: no method named `closure` found for struct `Obj u32 + 'static)>>` in the current scope + --> $DIR/issue-2392.rs:60:24 | LL | struct Obj where F: FnOnce() -> u32 { | ------------- method `closure` not found for this struct @@ -110,7 +110,7 @@ LL | (check_expression().closure)(); | + + error[E0599]: no method named `f1` found for struct `FuncContainer` in the current scope - --> $DIR/issue-2392.rs:68:31 + --> $DIR/issue-2392.rs:66:31 | LL | struct FuncContainer { | -------------------- method `f1` not found for this struct @@ -124,7 +124,7 @@ LL | ((*self.container).f1)(1); | + + error[E0599]: no method named `f2` found for struct `FuncContainer` in the current scope - --> $DIR/issue-2392.rs:69:31 + --> $DIR/issue-2392.rs:67:31 | LL | struct FuncContainer { | -------------------- method `f2` not found for this struct @@ -138,7 +138,7 @@ LL | ((*self.container).f2)(1); | + + error[E0599]: no method named `f3` found for struct `FuncContainer` in the current scope - --> $DIR/issue-2392.rs:70:31 + --> $DIR/issue-2392.rs:68:31 | LL | struct FuncContainer { | -------------------- method `f3` not found for this struct diff --git a/tests/ui/delegation/correct_body_owner_parent_found_in_diagnostics.stderr b/tests/ui/delegation/correct_body_owner_parent_found_in_diagnostics.stderr index 61e2a8f64dd52..5ac1745875e76 100644 --- a/tests/ui/delegation/correct_body_owner_parent_found_in_diagnostics.stderr +++ b/tests/ui/delegation/correct_body_owner_parent_found_in_diagnostics.stderr @@ -43,7 +43,7 @@ help: consider introducing lifetime `'a` here LL | impl<'a> Trait for Z { | ++++ -error[E0599]: no function or associated item named `new` found for struct `InvariantRef` in the current scope +error[E0599]: no function or associated item named `new` found for struct `InvariantRef<'_, _>` in the current scope --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:9:41 | LL | pub struct InvariantRef<'a, T: ?Sized>(&'a T, PhantomData<&'a mut &'a T>); diff --git a/tests/ui/issues/issue-41880.stderr b/tests/ui/issues/issue-41880.stderr index 1936c0aebd40d..8d9b3e48c23a5 100644 --- a/tests/ui/issues/issue-41880.stderr +++ b/tests/ui/issues/issue-41880.stderr @@ -1,4 +1,4 @@ -error[E0599]: no method named `iter` found for struct `Iterate` in the current scope +error[E0599]: no method named `iter` found for struct `Iterate<{integer}, {closure@$DIR/issue-41880.rs:26:24: 26:27}>` in the current scope --> $DIR/issue-41880.rs:27:24 | LL | pub struct Iterate { diff --git a/tests/ui/methods/call_method_unknown_referent.rs b/tests/ui/methods/call_method_unknown_referent.rs index b01e2d80f7f80..739fd67472d82 100644 --- a/tests/ui/methods/call_method_unknown_referent.rs +++ b/tests/ui/methods/call_method_unknown_referent.rs @@ -44,5 +44,5 @@ fn main() { // our resolution logic needs to be able to call methods such as foo() // on the outer type even if the inner type is ambiguous. let _c = (ptr as SmartPtr<_>).read(); - //~^ ERROR no method named `read` found for struct `SmartPtr` + //~^ ERROR no method named `read` found for struct `SmartPtr } diff --git a/tests/ui/methods/call_method_unknown_referent.stderr b/tests/ui/methods/call_method_unknown_referent.stderr index 748b02b52b577..30095d57e54dc 100644 --- a/tests/ui/methods/call_method_unknown_referent.stderr +++ b/tests/ui/methods/call_method_unknown_referent.stderr @@ -10,7 +10,7 @@ error[E0282]: type annotations needed LL | let _b = (rc as std::rc::Rc<_>).read(); | ^^^^ cannot infer type -error[E0599]: no method named `read` found for struct `SmartPtr` in the current scope +error[E0599]: no method named `read` found for struct `SmartPtr<_>` in the current scope --> $DIR/call_method_unknown_referent.rs:46:35 | LL | struct SmartPtr(T); diff --git a/tests/ui/methods/method-not-found-generic-arg-elision.stderr b/tests/ui/methods/method-not-found-generic-arg-elision.stderr index 8429c3aebac2f..3095e665701f0 100644 --- a/tests/ui/methods/method-not-found-generic-arg-elision.stderr +++ b/tests/ui/methods/method-not-found-generic-arg-elision.stderr @@ -10,7 +10,7 @@ LL | let d = point_i32.distance(); = note: the method was found for - `Point` -error[E0599]: no method named `other` found for struct `Point` in the current scope +error[E0599]: no method named `other` found for struct `Point` in the current scope --> $DIR/method-not-found-generic-arg-elision.rs:84:23 | LL | struct Point { @@ -19,7 +19,7 @@ LL | struct Point { LL | let d = point_i32.other(); | ^^^^^ method not found in `Point` -error[E0599]: no method named `extend` found for struct `Map` in the current scope +error[E0599]: no method named `extend` found for struct `Map, Box Fn(&'a i32) -> i32>>` in the current scope --> $DIR/method-not-found-generic-arg-elision.rs:87:67 | LL | v.iter().map(Box::new(|x| x * x) as Box i32>).extend(std::iter::once(100)); @@ -41,7 +41,7 @@ LL | wrapper.method(); - `Wrapper` and 2 more types -error[E0599]: no method named `other` found for struct `Wrapper` in the current scope +error[E0599]: no method named `other` found for struct `Wrapper` in the current scope --> $DIR/method-not-found-generic-arg-elision.rs:92:13 | LL | struct Wrapper(T); @@ -64,7 +64,7 @@ LL | wrapper.method(); - `Wrapper2<'a, i32, C>` - `Wrapper2<'a, i8, C>` -error[E0599]: no method named `other` found for struct `Wrapper2` in the current scope +error[E0599]: no method named `other` found for struct `Wrapper2<'_, bool, 3>` in the current scope --> $DIR/method-not-found-generic-arg-elision.rs:98:13 | LL | struct Wrapper2<'a, T, const C: usize> { diff --git a/tests/ui/methods/untrimmed-path-type.stderr b/tests/ui/methods/untrimmed-path-type.stderr index 1f3101ff4e78f..8022c5366cdba 100644 --- a/tests/ui/methods/untrimmed-path-type.stderr +++ b/tests/ui/methods/untrimmed-path-type.stderr @@ -1,4 +1,4 @@ -error[E0599]: no method named `unknown` found for enum `Result` in the current scope +error[E0599]: no method named `unknown` found for enum `Result<(), std::io::Error>` in the current scope --> $DIR/untrimmed-path-type.rs:5:11 | LL | meow().unknown(); diff --git a/tests/ui/self/arbitrary_self_type_infinite_recursion.stderr b/tests/ui/self/arbitrary_self_type_infinite_recursion.stderr index 5e652efb36454..10e4fa8fdd727 100644 --- a/tests/ui/self/arbitrary_self_type_infinite_recursion.stderr +++ b/tests/ui/self/arbitrary_self_type_infinite_recursion.stderr @@ -32,7 +32,7 @@ LL | p.method(); | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`arbitrary_self_type_infinite_recursion`) -error[E0599]: no method named `method` found for struct `MySmartPtr` in the current scope +error[E0599]: no method named `method` found for struct `MySmartPtr` in the current scope --> $DIR/arbitrary_self_type_infinite_recursion.rs:21:5 | LL | struct MySmartPtr(T); diff --git a/tests/ui/self/arbitrary_self_types_not_allow_call_with_no_deref.stderr b/tests/ui/self/arbitrary_self_types_not_allow_call_with_no_deref.stderr index a30cf605829f8..40fd93032a93b 100644 --- a/tests/ui/self/arbitrary_self_types_not_allow_call_with_no_deref.stderr +++ b/tests/ui/self/arbitrary_self_types_not_allow_call_with_no_deref.stderr @@ -1,4 +1,4 @@ -error[E0599]: no method named `frobnicate_ref` found for struct `CppRef` in the current scope +error[E0599]: no method named `frobnicate_ref` found for struct `CppRef` in the current scope --> $DIR/arbitrary_self_types_not_allow_call_with_no_deref.rs:29:17 | LL | struct CppRef(T); @@ -16,7 +16,7 @@ help: there is a method `frobnicate_cpp_ref` with a similar name LL | foo_cpp_ref.frobnicate_cpp_ref(); | ++++ -error[E0599]: no method named `frobnicate_self` found for struct `CppRef` in the current scope +error[E0599]: no method named `frobnicate_self` found for struct `CppRef` in the current scope --> $DIR/arbitrary_self_types_not_allow_call_with_no_deref.rs:32:17 | LL | struct CppRef(T); diff --git a/tests/ui/self/arbitrary_self_types_pin_needing_borrow.rs b/tests/ui/self/arbitrary_self_types_pin_needing_borrow.rs index d877dbe60754d..0af88878f644c 100644 --- a/tests/ui/self/arbitrary_self_types_pin_needing_borrow.rs +++ b/tests/ui/self/arbitrary_self_types_pin_needing_borrow.rs @@ -9,5 +9,5 @@ impl S { fn main() { Pin::new(S).x(); //~^ ERROR the trait bound `S: Deref` is not satisfied - //~| ERROR no method named `x` found for struct `Pin` in the current scope + //~| ERROR no method named `x` found for struct `Pin` in the current scope } diff --git a/tests/ui/self/arbitrary_self_types_pin_needing_borrow.stderr b/tests/ui/self/arbitrary_self_types_pin_needing_borrow.stderr index 1811cd6753ffe..c8b3119b1ee4e 100644 --- a/tests/ui/self/arbitrary_self_types_pin_needing_borrow.stderr +++ b/tests/ui/self/arbitrary_self_types_pin_needing_borrow.stderr @@ -15,7 +15,7 @@ LL | Pin::new(&S).x(); LL | Pin::new(&mut S).x(); | ++++ -error[E0599]: no method named `x` found for struct `Pin` in the current scope +error[E0599]: no method named `x` found for struct `Pin` in the current scope --> $DIR/arbitrary_self_types_pin_needing_borrow.rs:10:17 | LL | Pin::new(S).x(); diff --git a/tests/ui/simd/libm_no_std_cant_float.stderr b/tests/ui/simd/libm_no_std_cant_float.stderr index 97e0b7efe2abc..82510c9b99138 100644 --- a/tests/ui/simd/libm_no_std_cant_float.stderr +++ b/tests/ui/simd/libm_no_std_cant_float.stderr @@ -1,34 +1,34 @@ -error[E0599]: no method named `ceil` found for struct `Simd` in the current scope +error[E0599]: no method named `ceil` found for struct `Simd` in the current scope --> $DIR/libm_no_std_cant_float.rs:15:17 | LL | let _xc = x.ceil(); | ^^^^ method not found in `Simd` -error[E0599]: no method named `floor` found for struct `Simd` in the current scope +error[E0599]: no method named `floor` found for struct `Simd` in the current scope --> $DIR/libm_no_std_cant_float.rs:16:17 | LL | let _xf = x.floor(); | ^^^^^ method not found in `Simd` -error[E0599]: no method named `round` found for struct `Simd` in the current scope +error[E0599]: no method named `round` found for struct `Simd` in the current scope --> $DIR/libm_no_std_cant_float.rs:17:17 | LL | let _xr = x.round(); | ^^^^^ method not found in `Simd` -error[E0599]: no method named `trunc` found for struct `Simd` in the current scope +error[E0599]: no method named `trunc` found for struct `Simd` in the current scope --> $DIR/libm_no_std_cant_float.rs:18:17 | LL | let _xt = x.trunc(); | ^^^^^ method not found in `Simd` -error[E0599]: no method named `mul_add` found for struct `Simd` in the current scope +error[E0599]: no method named `mul_add` found for struct `Simd` in the current scope --> $DIR/libm_no_std_cant_float.rs:19:19 | LL | let _xfma = x.mul_add(x, x); | ^^^^^^^ method not found in `Simd` -error[E0599]: no method named `sqrt` found for struct `Simd` in the current scope +error[E0599]: no method named `sqrt` found for struct `Simd` in the current scope --> $DIR/libm_no_std_cant_float.rs:20:20 | LL | let _xsqrt = x.sqrt(); diff --git a/tests/ui/suggestions/enum-method-probe.fixed b/tests/ui/suggestions/enum-method-probe.fixed index b7fd6f112d586..a4ce98a6046c1 100644 --- a/tests/ui/suggestions/enum-method-probe.fixed +++ b/tests/ui/suggestions/enum-method-probe.fixed @@ -14,7 +14,7 @@ impl Foo { fn test_result_in_result() -> Result<(), ()> { let res: Result<_, ()> = Ok(Foo); res?.get(); - //~^ ERROR no method named `get` found for enum `Result` in the current scope + //~^ ERROR no method named `get` found for enum `Result` in the current scope //~| HELP use the `?` operator Ok(()) } @@ -22,7 +22,7 @@ fn test_result_in_result() -> Result<(), ()> { async fn async_test_result_in_result() -> Result<(), ()> { let res: Result<_, ()> = Ok(Foo); res?.get(); - //~^ ERROR no method named `get` found for enum `Result` in the current scope + //~^ ERROR no method named `get` found for enum `Result` in the current scope //~| HELP use the `?` operator Ok(()) } @@ -30,21 +30,21 @@ async fn async_test_result_in_result() -> Result<(), ()> { fn test_result_in_unit_return() { let res: Result<_, ()> = Ok(Foo); res.expect("REASON").get(); - //~^ ERROR no method named `get` found for enum `Result` in the current scope + //~^ ERROR no method named `get` found for enum `Result` in the current scope //~| HELP consider using `Result::expect` to unwrap the `Foo` value, panicking if the value is a `Result::Err` } async fn async_test_result_in_unit_return() { let res: Result<_, ()> = Ok(Foo); res.expect("REASON").get(); - //~^ ERROR no method named `get` found for enum `Result` in the current scope + //~^ ERROR no method named `get` found for enum `Result` in the current scope //~| HELP consider using `Result::expect` to unwrap the `Foo` value, panicking if the value is a `Result::Err` } fn test_option_in_option() -> Option<()> { let res: Option<_> = Some(Foo); res?.get(); - //~^ ERROR no method named `get` found for enum `Option` in the current scope + //~^ ERROR no method named `get` found for enum `Option` in the current scope //~| HELP use the `?` operator Some(()) } @@ -52,7 +52,7 @@ fn test_option_in_option() -> Option<()> { fn test_option_in_unit_return() { let res: Option<_> = Some(Foo); res.expect("REASON").get(); - //~^ ERROR no method named `get` found for enum `Option` in the current scope + //~^ ERROR no method named `get` found for enum `Option` in the current scope //~| HELP consider using `Option::expect` to unwrap the `Foo` value, panicking if the value is an `Option::None` } diff --git a/tests/ui/suggestions/enum-method-probe.rs b/tests/ui/suggestions/enum-method-probe.rs index cbb819b7c8c09..c9e1c1e9e70e5 100644 --- a/tests/ui/suggestions/enum-method-probe.rs +++ b/tests/ui/suggestions/enum-method-probe.rs @@ -14,7 +14,7 @@ impl Foo { fn test_result_in_result() -> Result<(), ()> { let res: Result<_, ()> = Ok(Foo); res.get(); - //~^ ERROR no method named `get` found for enum `Result` in the current scope + //~^ ERROR no method named `get` found for enum `Result` in the current scope //~| HELP use the `?` operator Ok(()) } @@ -22,7 +22,7 @@ fn test_result_in_result() -> Result<(), ()> { async fn async_test_result_in_result() -> Result<(), ()> { let res: Result<_, ()> = Ok(Foo); res.get(); - //~^ ERROR no method named `get` found for enum `Result` in the current scope + //~^ ERROR no method named `get` found for enum `Result` in the current scope //~| HELP use the `?` operator Ok(()) } @@ -30,21 +30,21 @@ async fn async_test_result_in_result() -> Result<(), ()> { fn test_result_in_unit_return() { let res: Result<_, ()> = Ok(Foo); res.get(); - //~^ ERROR no method named `get` found for enum `Result` in the current scope + //~^ ERROR no method named `get` found for enum `Result` in the current scope //~| HELP consider using `Result::expect` to unwrap the `Foo` value, panicking if the value is a `Result::Err` } async fn async_test_result_in_unit_return() { let res: Result<_, ()> = Ok(Foo); res.get(); - //~^ ERROR no method named `get` found for enum `Result` in the current scope + //~^ ERROR no method named `get` found for enum `Result` in the current scope //~| HELP consider using `Result::expect` to unwrap the `Foo` value, panicking if the value is a `Result::Err` } fn test_option_in_option() -> Option<()> { let res: Option<_> = Some(Foo); res.get(); - //~^ ERROR no method named `get` found for enum `Option` in the current scope + //~^ ERROR no method named `get` found for enum `Option` in the current scope //~| HELP use the `?` operator Some(()) } @@ -52,7 +52,7 @@ fn test_option_in_option() -> Option<()> { fn test_option_in_unit_return() { let res: Option<_> = Some(Foo); res.get(); - //~^ ERROR no method named `get` found for enum `Option` in the current scope + //~^ ERROR no method named `get` found for enum `Option` in the current scope //~| HELP consider using `Option::expect` to unwrap the `Foo` value, panicking if the value is an `Option::None` } diff --git a/tests/ui/suggestions/enum-method-probe.stderr b/tests/ui/suggestions/enum-method-probe.stderr index e66973d9d954b..b4a97dd100fdb 100644 --- a/tests/ui/suggestions/enum-method-probe.stderr +++ b/tests/ui/suggestions/enum-method-probe.stderr @@ -1,4 +1,4 @@ -error[E0599]: no method named `get` found for enum `Result` in the current scope +error[E0599]: no method named `get` found for enum `Result` in the current scope --> $DIR/enum-method-probe.rs:24:9 | LL | res.get(); @@ -14,7 +14,7 @@ help: use the `?` operator to extract the `Foo` value, propagating a `Result::Er LL | res?.get(); | + -error[E0599]: no method named `get` found for enum `Result` in the current scope +error[E0599]: no method named `get` found for enum `Result` in the current scope --> $DIR/enum-method-probe.rs:39:9 | LL | res.get(); @@ -30,7 +30,7 @@ help: consider using `Result::expect` to unwrap the `Foo` value, panicking if th LL | res.expect("REASON").get(); | +++++++++++++++++ -error[E0599]: no method named `get` found for enum `Result` in the current scope +error[E0599]: no method named `get` found for enum `Result` in the current scope --> $DIR/enum-method-probe.rs:16:9 | LL | res.get(); @@ -46,7 +46,7 @@ help: use the `?` operator to extract the `Foo` value, propagating a `Result::Er LL | res?.get(); | + -error[E0599]: no method named `get` found for enum `Result` in the current scope +error[E0599]: no method named `get` found for enum `Result` in the current scope --> $DIR/enum-method-probe.rs:32:9 | LL | res.get(); @@ -62,7 +62,7 @@ help: consider using `Result::expect` to unwrap the `Foo` value, panicking if th LL | res.expect("REASON").get(); | +++++++++++++++++ -error[E0599]: no method named `get` found for enum `Option` in the current scope +error[E0599]: no method named `get` found for enum `Option` in the current scope --> $DIR/enum-method-probe.rs:46:9 | LL | res.get(); @@ -78,7 +78,7 @@ help: use the `?` operator to extract the `Foo` value, propagating an `Option::N LL | res?.get(); | + -error[E0599]: no method named `get` found for enum `Option` in the current scope +error[E0599]: no method named `get` found for enum `Option` in the current scope --> $DIR/enum-method-probe.rs:54:9 | LL | res.get(); diff --git a/tests/ui/suggestions/field-has-method.rs b/tests/ui/suggestions/field-has-method.rs index d28b6ba546c4a..72ac48cf02ff0 100644 --- a/tests/ui/suggestions/field-has-method.rs +++ b/tests/ui/suggestions/field-has-method.rs @@ -17,7 +17,7 @@ struct InferOk { fn foo(i: InferOk) { let k = i.kind(); - //~^ ERROR no method named `kind` found for struct `InferOk` in the current scope + //~^ ERROR no method named `kind` found for struct `InferOk` in the current scope } fn main() {} diff --git a/tests/ui/suggestions/field-has-method.stderr b/tests/ui/suggestions/field-has-method.stderr index daff2db64189a..045dec87050f1 100644 --- a/tests/ui/suggestions/field-has-method.stderr +++ b/tests/ui/suggestions/field-has-method.stderr @@ -1,4 +1,4 @@ -error[E0599]: no method named `kind` found for struct `InferOk` in the current scope +error[E0599]: no method named `kind` found for struct `InferOk` in the current scope --> $DIR/field-has-method.rs:19:15 | LL | struct InferOk { diff --git a/tests/ui/suggestions/inner_type.fixed b/tests/ui/suggestions/inner_type.fixed index 175a2a02acdf8..3058a5a737ae0 100644 --- a/tests/ui/suggestions/inner_type.fixed +++ b/tests/ui/suggestions/inner_type.fixed @@ -15,26 +15,26 @@ fn main() { let other_item = std::cell::RefCell::new(Struct { p: 42_u32 }); other_item.borrow().method(); - //~^ ERROR no method named `method` found for struct `RefCell` in the current scope [E0599] + //~^ ERROR no method named `method` found for struct `RefCell>` in the current scope [E0599] //~| HELP use `.borrow()` to borrow the `Struct`, panicking if a mutable borrow exists other_item.borrow_mut().some_mutable_method(); - //~^ ERROR no method named `some_mutable_method` found for struct `RefCell` in the current scope [E0599] + //~^ ERROR no method named `some_mutable_method` found for struct `RefCell>` in the current scope [E0599] //~| HELP .borrow_mut()` to mutably borrow the `Struct`, panicking if any borrows exist let another_item = std::sync::Mutex::new(Struct { p: 42_u32 }); another_item.lock().unwrap().method(); - //~^ ERROR no method named `method` found for struct `std::sync::Mutex` in the current scope [E0599] + //~^ ERROR no method named `method` found for struct `std::sync::Mutex>` in the current scope [E0599] //~| HELP use `.lock().unwrap()` to borrow the `Struct`, blocking the current thread until it can be acquired let another_item = std::sync::RwLock::new(Struct { p: 42_u32 }); another_item.read().unwrap().method(); - //~^ ERROR no method named `method` found for struct `RwLock` in the current scope [E0599] + //~^ ERROR no method named `method` found for struct `RwLock>` in the current scope [E0599] //~| HELP use `.read().unwrap()` to borrow the `Struct`, blocking the current thread until it can be acquired another_item.write().unwrap().some_mutable_method(); - //~^ ERROR no method named `some_mutable_method` found for struct `RwLock` in the current scope [E0599] + //~^ ERROR no method named `some_mutable_method` found for struct `RwLock>` in the current scope [E0599] //~| HELP use `.write().unwrap()` to mutably borrow the `Struct`, blocking the current thread until it can be acquired } diff --git a/tests/ui/suggestions/inner_type.rs b/tests/ui/suggestions/inner_type.rs index ab021414f56ce..6652eb6a9370f 100644 --- a/tests/ui/suggestions/inner_type.rs +++ b/tests/ui/suggestions/inner_type.rs @@ -15,26 +15,26 @@ fn main() { let other_item = std::cell::RefCell::new(Struct { p: 42_u32 }); other_item.method(); - //~^ ERROR no method named `method` found for struct `RefCell` in the current scope [E0599] + //~^ ERROR no method named `method` found for struct `RefCell>` in the current scope [E0599] //~| HELP use `.borrow()` to borrow the `Struct`, panicking if a mutable borrow exists other_item.some_mutable_method(); - //~^ ERROR no method named `some_mutable_method` found for struct `RefCell` in the current scope [E0599] + //~^ ERROR no method named `some_mutable_method` found for struct `RefCell>` in the current scope [E0599] //~| HELP .borrow_mut()` to mutably borrow the `Struct`, panicking if any borrows exist let another_item = std::sync::Mutex::new(Struct { p: 42_u32 }); another_item.method(); - //~^ ERROR no method named `method` found for struct `std::sync::Mutex` in the current scope [E0599] + //~^ ERROR no method named `method` found for struct `std::sync::Mutex>` in the current scope [E0599] //~| HELP use `.lock().unwrap()` to borrow the `Struct`, blocking the current thread until it can be acquired let another_item = std::sync::RwLock::new(Struct { p: 42_u32 }); another_item.method(); - //~^ ERROR no method named `method` found for struct `RwLock` in the current scope [E0599] + //~^ ERROR no method named `method` found for struct `RwLock>` in the current scope [E0599] //~| HELP use `.read().unwrap()` to borrow the `Struct`, blocking the current thread until it can be acquired another_item.some_mutable_method(); - //~^ ERROR no method named `some_mutable_method` found for struct `RwLock` in the current scope [E0599] + //~^ ERROR no method named `some_mutable_method` found for struct `RwLock>` in the current scope [E0599] //~| HELP use `.write().unwrap()` to mutably borrow the `Struct`, blocking the current thread until it can be acquired } diff --git a/tests/ui/suggestions/inner_type.stderr b/tests/ui/suggestions/inner_type.stderr index 67ebb5789b70c..ed1b509dcac20 100644 --- a/tests/ui/suggestions/inner_type.stderr +++ b/tests/ui/suggestions/inner_type.stderr @@ -1,4 +1,4 @@ -error[E0599]: no method named `method` found for struct `RefCell` in the current scope +error[E0599]: no method named `method` found for struct `RefCell>` in the current scope --> $DIR/inner_type.rs:17:16 | LL | other_item.method(); @@ -14,7 +14,7 @@ help: use `.borrow()` to borrow the `Struct`, panicking if a mutable borrow LL | other_item.borrow().method(); | +++++++++ -error[E0599]: no method named `some_mutable_method` found for struct `RefCell` in the current scope +error[E0599]: no method named `some_mutable_method` found for struct `RefCell>` in the current scope --> $DIR/inner_type.rs:21:16 | LL | other_item.some_mutable_method(); @@ -30,7 +30,7 @@ help: use `.borrow_mut()` to mutably borrow the `Struct`, panicking if any LL | other_item.borrow_mut().some_mutable_method(); | +++++++++++++ -error[E0599]: no method named `method` found for struct `std::sync::Mutex` in the current scope +error[E0599]: no method named `method` found for struct `std::sync::Mutex>` in the current scope --> $DIR/inner_type.rs:27:18 | LL | another_item.method(); @@ -46,7 +46,7 @@ help: use `.lock().unwrap()` to borrow the `Struct`, blocking the current t LL | another_item.lock().unwrap().method(); | ++++++++++++++++ -error[E0599]: no method named `method` found for struct `RwLock` in the current scope +error[E0599]: no method named `method` found for struct `RwLock>` in the current scope --> $DIR/inner_type.rs:33:18 | LL | another_item.method(); @@ -62,7 +62,7 @@ help: use `.read().unwrap()` to borrow the `Struct`, blocking the current t LL | another_item.read().unwrap().method(); | ++++++++++++++++ -error[E0599]: no method named `some_mutable_method` found for struct `RwLock` in the current scope +error[E0599]: no method named `some_mutable_method` found for struct `RwLock>` in the current scope --> $DIR/inner_type.rs:37:18 | LL | another_item.some_mutable_method(); diff --git a/tests/ui/suggestions/inner_type2.rs b/tests/ui/suggestions/inner_type2.rs index fac68c053eb4f..80d91bd51776f 100644 --- a/tests/ui/suggestions/inner_type2.rs +++ b/tests/ui/suggestions/inner_type2.rs @@ -16,11 +16,11 @@ thread_local! { fn main() { STRUCT.method(); - //~^ ERROR no method named `method` found for struct `LocalKey` in the current scope [E0599] + //~^ ERROR no method named `method` found for struct `LocalKey>` in the current scope [E0599] //~| HELP use `with` or `try_with` to access thread local storage let item = std::mem::MaybeUninit::new(Struct { p: 42_u32 }); item.method(); - //~^ ERROR no method named `method` found for union `MaybeUninit` in the current scope [E0599] + //~^ ERROR no method named `method` found for union `MaybeUninit>` in the current scope [E0599] //~| HELP if this `MaybeUninit>` has been initialized, use one of the `assume_init` methods to access the inner value } diff --git a/tests/ui/suggestions/inner_type2.stderr b/tests/ui/suggestions/inner_type2.stderr index 984366123c827..170fe5eff0966 100644 --- a/tests/ui/suggestions/inner_type2.stderr +++ b/tests/ui/suggestions/inner_type2.stderr @@ -1,4 +1,4 @@ -error[E0599]: no method named `method` found for struct `LocalKey` in the current scope +error[E0599]: no method named `method` found for struct `LocalKey>` in the current scope --> $DIR/inner_type2.rs:18:12 | LL | STRUCT.method(); @@ -11,7 +11,7 @@ note: the method `method` exists on the type `Struct` LL | pub fn method(&self) {} | ^^^^^^^^^^^^^^^^^^^^ -error[E0599]: no method named `method` found for union `MaybeUninit` in the current scope +error[E0599]: no method named `method` found for union `MaybeUninit>` in the current scope --> $DIR/inner_type2.rs:23:10 | LL | item.method(); From 33d65fc9772d584612759ee80c3d6bf051475986 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 16 Jul 2025 22:05:59 +0000 Subject: [PATCH 04/13] Mark test to use short type paths This test seems to have improper use of `TyCtxt::short_string`. --- tests/ui/methods/filter-relevant-fn-bounds.rs | 3 +++ .../methods/filter-relevant-fn-bounds.stderr | 20 ++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/tests/ui/methods/filter-relevant-fn-bounds.rs b/tests/ui/methods/filter-relevant-fn-bounds.rs index 6233c9db53a0b..704f64380bd57 100644 --- a/tests/ui/methods/filter-relevant-fn-bounds.rs +++ b/tests/ui/methods/filter-relevant-fn-bounds.rs @@ -1,3 +1,6 @@ +// FIXME(estebank): diagnostics with long type paths that don't print out the full path anywhere +// still prints the note explaining where the type was written to. +//@ compile-flags: -Zwrite-long-types-to-disk=yes trait Output<'a> { type Type; } diff --git a/tests/ui/methods/filter-relevant-fn-bounds.stderr b/tests/ui/methods/filter-relevant-fn-bounds.stderr index 82103e62ddfeb..dd6cdc22f6f51 100644 --- a/tests/ui/methods/filter-relevant-fn-bounds.stderr +++ b/tests/ui/methods/filter-relevant-fn-bounds.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `for<'a> F: Output<'a>` is not satisfied - --> $DIR/filter-relevant-fn-bounds.rs:8:5 + --> $DIR/filter-relevant-fn-bounds.rs:11:5 | LL | / fn do_something_wrapper(self, _: F) LL | | @@ -13,7 +13,7 @@ LL | F: for<'a> FnOnce(>::Type) + for<'a> Output<'a>, | ++++++++++++++++++++ error[E0277]: the trait bound `for<'a> F: Output<'a>` is not satisfied - --> $DIR/filter-relevant-fn-bounds.rs:11:12 + --> $DIR/filter-relevant-fn-bounds.rs:14:12 | LL | F: for<'a> FnOnce(>::Type), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> Output<'a>` is not implemented for `F` @@ -24,7 +24,7 @@ LL | F: for<'a> FnOnce(>::Type) + for<'a> Output<'a>, | ++++++++++++++++++++ error[E0277]: the trait bound `for<'a> F: Output<'a>` is not satisfied - --> $DIR/filter-relevant-fn-bounds.rs:11:20 + --> $DIR/filter-relevant-fn-bounds.rs:14:20 | LL | F: for<'a> FnOnce(>::Type), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> Output<'a>` is not implemented for `F` @@ -34,28 +34,30 @@ help: consider further restricting type parameter `F` with trait `Output` LL | F: for<'a> FnOnce(>::Type) + for<'a> Output<'a>, | ++++++++++++++++++++ -error[E0277]: expected a `FnOnce(<{closure@$DIR/filter-relevant-fn-bounds.rs:20:34: 20:41} as Output<'a>>::Type)` closure, found `{closure@$DIR/filter-relevant-fn-bounds.rs:20:34: 20:41}` - --> $DIR/filter-relevant-fn-bounds.rs:20:34 +error[E0277]: expected a `FnOnce(<{closure@$DIR/filter-relevant-fn-bounds.rs:23:34: 23:41} as Output<'a>>::Type)` closure, found `{closure@$DIR/filter-relevant-fn-bounds.rs:23:34: 23:41}` + --> $DIR/filter-relevant-fn-bounds.rs:23:34 | LL | wrapper.do_something_wrapper(|value| ()); - | -------------------- ^^^^^^^^^^ expected an `FnOnce(<{closure@$DIR/filter-relevant-fn-bounds.rs:20:34: 20:41} as Output<'a>>::Type)` closure, found `{closure@$DIR/filter-relevant-fn-bounds.rs:20:34: 20:41}` + | -------------------- ^^^^^^^^^^ expected an `FnOnce(<{closure@$DIR/filter-relevant-fn-bounds.rs:23:34: 23:41} as Output<'a>>::Type)` closure, found `{closure@$DIR/filter-relevant-fn-bounds.rs:23:34: 23:41}` | | | required by a bound introduced by this call | - = help: the trait `for<'a> Output<'a>` is not implemented for closure `{closure@$DIR/filter-relevant-fn-bounds.rs:20:34: 20:41}` + = help: the trait `for<'a> Output<'a>` is not implemented for closure `{closure@$DIR/filter-relevant-fn-bounds.rs:23:34: 23:41}` help: this trait has no implementations, consider adding one - --> $DIR/filter-relevant-fn-bounds.rs:1:1 + --> $DIR/filter-relevant-fn-bounds.rs:4:1 | LL | trait Output<'a> { | ^^^^^^^^^^^^^^^^ note: required by a bound in `Wrapper::do_something_wrapper` - --> $DIR/filter-relevant-fn-bounds.rs:11:12 + --> $DIR/filter-relevant-fn-bounds.rs:14:12 | LL | fn do_something_wrapper(self, _: F) | -------------------- required by a bound in this associated function ... LL | F: for<'a> FnOnce(>::Type), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Wrapper::do_something_wrapper` + = note: the full name for the type has been written to '$TEST_BUILD_DIR/filter-relevant-fn-bounds.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error: aborting due to 4 previous errors From 35e31fc801753b906002fcd9d95e74423b47842a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 16 Jul 2025 22:37:39 +0000 Subject: [PATCH 05/13] Minor fixes of `short_string` handling --- .../error_reporting/traits/fulfillment_errors.rs | 1 + .../src/error_reporting/traits/suggestions.rs | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs index faf08d264c9ab..3c4764e4cc500 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs @@ -312,6 +312,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { &obligation, leaf_trait_predicate, pre_message, + err.long_ty_path(), ); self.check_for_binding_assigned_block_without_tail_expression( diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs index d350f4ff73ac5..53d99d9a24b18 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs @@ -3,6 +3,7 @@ use std::assert_matches::debug_assert_matches; use std::borrow::Cow; use std::iter; +use std::path::PathBuf; use itertools::{EitherOrBoth, Itertools}; use rustc_abi::ExternAbi; @@ -1369,6 +1370,10 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { ); let self_ty_str = self.tcx.short_string(old_pred.self_ty().skip_binder(), err.long_ty_path()); + let trait_path = self + .tcx + .short_string(old_pred.print_modifiers_and_trait_path(), err.long_ty_path()); + if has_custom_message { err.note(msg); } else { @@ -1376,10 +1381,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { } err.span_label( span, - format!( - "the trait `{}` is not implemented for `{self_ty_str}`", - old_pred.print_modifiers_and_trait_path() - ), + format!("the trait `{trait_path}` is not implemented for `{self_ty_str}`"), ); }; @@ -5366,6 +5368,7 @@ pub(super) fn get_explanation_based_on_obligation<'tcx>( obligation: &PredicateObligation<'tcx>, trait_predicate: ty::PolyTraitPredicate<'tcx>, pre_message: String, + file: &mut Option, ) -> String { if let ObligationCauseCode::MainFunctionType = obligation.cause.code() { "consider using `()`, or a `Result`".to_owned() @@ -5384,7 +5387,7 @@ pub(super) fn get_explanation_based_on_obligation<'tcx>( format!( "{pre_message}the trait `{}` is not implemented for{desc} `{}`", trait_predicate.print_modifiers_and_trait_path(), - tcx.short_string(trait_predicate.self_ty().skip_binder(), &mut None), + tcx.short_string(trait_predicate.self_ty().skip_binder(), file), ) } else { // "the trait bound `T: !Send` is not satisfied" reads better than "`!Send` is From 98542e7e29987667ea80c6dc38dc19a71a82f00d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 18 Jul 2025 16:59:09 +0000 Subject: [PATCH 06/13] Revert change to one test because of inconsistent output in aarc64 --- .../ui/confuse-field-and-method/issue-2392.rs | 2 -- .../issue-2392.stderr | 31 ++++++++----------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/tests/ui/confuse-field-and-method/issue-2392.rs b/tests/ui/confuse-field-and-method/issue-2392.rs index 0f1a162a8c1ef..8aef091fe3186 100644 --- a/tests/ui/confuse-field-and-method/issue-2392.rs +++ b/tests/ui/confuse-field-and-method/issue-2392.rs @@ -1,5 +1,3 @@ -//@ compile-flags: -Zwrite-long-types-to-disk=yes - struct FuncContainer { f1: fn(data: u8), f2: extern "C" fn(data: u8), diff --git a/tests/ui/confuse-field-and-method/issue-2392.stderr b/tests/ui/confuse-field-and-method/issue-2392.stderr index 7dccdd3627df1..0b13e94c96b28 100644 --- a/tests/ui/confuse-field-and-method/issue-2392.stderr +++ b/tests/ui/confuse-field-and-method/issue-2392.stderr @@ -1,5 +1,5 @@ -error[E0599]: no method named `closure` found for struct `Obj<{closure@issue-2392.rs:37:36}>` in the current scope - --> $DIR/issue-2392.rs:38:15 +error[E0599]: no method named `closure` found for struct `Obj<{closure@$DIR/issue-2392.rs:35:36: 35:38}>` in the current scope + --> $DIR/issue-2392.rs:36:15 | LL | struct Obj where F: FnOnce() -> u32 { | ------------- method `closure` not found for this struct @@ -7,15 +7,13 @@ LL | struct Obj where F: FnOnce() -> u32 { LL | o_closure.closure(); | ^^^^^^^ field, not a method | - = note: the full name for the type has been written to '$TEST_BUILD_DIR/issue-2392.long-type-$LONG_TYPE_HASH.txt' - = note: consider using `--verbose` to print the full type name to the console help: to call the closure stored in `closure`, surround the field access with parentheses | LL | (o_closure.closure)(); | + + -error[E0599]: no method named `not_closure` found for struct `Obj<{closure@issue-2392.rs:37:36}>` in the current scope - --> $DIR/issue-2392.rs:40:15 +error[E0599]: no method named `not_closure` found for struct `Obj<{closure@$DIR/issue-2392.rs:35:36: 35:38}>` in the current scope + --> $DIR/issue-2392.rs:38:15 | LL | struct Obj where F: FnOnce() -> u32 { | ------------- method `not_closure` not found for this struct @@ -24,12 +22,9 @@ LL | o_closure.not_closure(); | ^^^^^^^^^^^-- help: remove the arguments | | | field, not a method - | - = note: the full name for the type has been written to '$TEST_BUILD_DIR/issue-2392.long-type-$LONG_TYPE_HASH.txt' - = note: consider using `--verbose` to print the full type name to the console error[E0599]: no method named `closure` found for struct `Obj u32 {func}>` in the current scope - --> $DIR/issue-2392.rs:44:12 + --> $DIR/issue-2392.rs:42:12 | LL | struct Obj where F: FnOnce() -> u32 { | ------------- method `closure` not found for this struct @@ -43,7 +38,7 @@ LL | (o_func.closure)(); | + + error[E0599]: no method named `boxed_closure` found for struct `BoxedObj` in the current scope - --> $DIR/issue-2392.rs:47:14 + --> $DIR/issue-2392.rs:45:14 | LL | struct BoxedObj { | --------------- method `boxed_closure` not found for this struct @@ -57,7 +52,7 @@ LL | (boxed_fn.boxed_closure)(); | + + error[E0599]: no method named `boxed_closure` found for struct `BoxedObj` in the current scope - --> $DIR/issue-2392.rs:50:19 + --> $DIR/issue-2392.rs:48:19 | LL | struct BoxedObj { | --------------- method `boxed_closure` not found for this struct @@ -71,7 +66,7 @@ LL | (boxed_closure.boxed_closure)(); | + + error[E0599]: no method named `closure` found for struct `Obj u32 {func}>` in the current scope - --> $DIR/issue-2392.rs:55:12 + --> $DIR/issue-2392.rs:53:12 | LL | struct Obj where F: FnOnce() -> u32 { | ------------- method `closure` not found for this struct @@ -85,7 +80,7 @@ LL | (w.wrap.closure)(); | + + error[E0599]: no method named `not_closure` found for struct `Obj u32 {func}>` in the current scope - --> $DIR/issue-2392.rs:57:12 + --> $DIR/issue-2392.rs:55:12 | LL | struct Obj where F: FnOnce() -> u32 { | ------------- method `not_closure` not found for this struct @@ -96,7 +91,7 @@ LL | w.wrap.not_closure(); | field, not a method error[E0599]: no method named `closure` found for struct `Obj u32 + 'static)>>` in the current scope - --> $DIR/issue-2392.rs:60:24 + --> $DIR/issue-2392.rs:58:24 | LL | struct Obj where F: FnOnce() -> u32 { | ------------- method `closure` not found for this struct @@ -110,7 +105,7 @@ LL | (check_expression().closure)(); | + + error[E0599]: no method named `f1` found for struct `FuncContainer` in the current scope - --> $DIR/issue-2392.rs:66:31 + --> $DIR/issue-2392.rs:64:31 | LL | struct FuncContainer { | -------------------- method `f1` not found for this struct @@ -124,7 +119,7 @@ LL | ((*self.container).f1)(1); | + + error[E0599]: no method named `f2` found for struct `FuncContainer` in the current scope - --> $DIR/issue-2392.rs:67:31 + --> $DIR/issue-2392.rs:65:31 | LL | struct FuncContainer { | -------------------- method `f2` not found for this struct @@ -138,7 +133,7 @@ LL | ((*self.container).f2)(1); | + + error[E0599]: no method named `f3` found for struct `FuncContainer` in the current scope - --> $DIR/issue-2392.rs:68:31 + --> $DIR/issue-2392.rs:66:31 | LL | struct FuncContainer { | -------------------- method `f3` not found for this struct From d22f77d437a383ad094abc3a9a0c2efd929324e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 21 Jul 2025 20:14:47 +0000 Subject: [PATCH 07/13] review comment: rename `err_msg` closure to `default_err_msg` --- .../src/error_reporting/traits/fulfillment_errors.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs index 3c4764e4cc500..1e8af423f261a 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs @@ -236,7 +236,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { (message, notes, append_const_msg) }; - let err_msg = || self.get_standard_error_message( + let default_err_msg = || self.get_standard_error_message( main_trait_predicate, message, None, @@ -261,7 +261,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { ); } GetSafeTransmuteErrorAndReason::Default => { - (err_msg(), None) + (default_err_msg(), None) } GetSafeTransmuteErrorAndReason::Error { err_msg, @@ -269,7 +269,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { } => (err_msg, safe_transmute_explanation), } } else { - (err_msg(), None) + (default_err_msg(), None) }; let mut err = struct_span_code_err!(self.dcx(), span, E0277, "{}", err_msg); From 70f21b6872296fe147c4cbd2c8c60e5dcf583c9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Thu, 24 Jul 2025 16:46:29 +0000 Subject: [PATCH 08/13] On E0599 show type identity to avoid expanding the receiver's generic parameters --- .../rustc_hir_typeck/src/method/suggest.rs | 31 ++++++++++++++++--- .../rustc_confusables_std_cases.stderr | 4 +-- .../issue-18343.stderr | 2 +- .../issue-2392.stderr | 12 +++---- ...y_owner_parent_found_in_diagnostics.stderr | 2 +- tests/ui/issues/issue-41880.stderr | 2 +- .../call_method_unknown_referent.stderr | 2 +- ...ethod-not-found-generic-arg-elision.stderr | 8 ++--- tests/ui/methods/untrimmed-path-type.stderr | 2 +- ...itrary_self_type_infinite_recursion.stderr | 2 +- ..._types_not_allow_call_with_no_deref.stderr | 4 +-- ...arbitrary_self_types_pin_needing_borrow.rs | 2 +- ...trary_self_types_pin_needing_borrow.stderr | 2 +- tests/ui/simd/libm_no_std_cant_float.stderr | 12 +++---- tests/ui/suggestions/enum-method-probe.fixed | 12 +++---- tests/ui/suggestions/enum-method-probe.rs | 12 +++---- tests/ui/suggestions/enum-method-probe.stderr | 12 +++---- tests/ui/suggestions/field-has-method.rs | 2 +- tests/ui/suggestions/field-has-method.stderr | 2 +- tests/ui/suggestions/inner_type.fixed | 10 +++--- tests/ui/suggestions/inner_type.rs | 10 +++--- tests/ui/suggestions/inner_type.stderr | 10 +++--- tests/ui/suggestions/inner_type2.rs | 4 +-- tests/ui/suggestions/inner_type2.stderr | 4 +-- 24 files changed, 94 insertions(+), 71 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index 3d1ce77bc0641..fd1771ebb5e25 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -380,16 +380,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { &self, rcvr_ty: Ty<'tcx>, rcvr_expr: &hir::Expr<'tcx>, - mut file: Option, + mut long_ty_path: Option, ) -> Diag<'_> { let mut err = struct_span_code_err!( self.dcx(), rcvr_expr.span, E0599, "cannot write into `{}`", - self.tcx.short_string(rcvr_ty, &mut file), + self.tcx.short_string(rcvr_ty, &mut long_ty_path), ); - *err.long_ty_path() = file; + *err.long_ty_path() = long_ty_path; err.span_note( rcvr_expr.span, "must implement `io::Write`, `fmt::Write`, or have a `write_fmt` method", @@ -681,6 +681,29 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut err = if is_write && let SelfSource::MethodCall(rcvr_expr) = source { self.suggest_missing_writer(rcvr_ty, rcvr_expr, ty_file) } else { + // Don't show expanded generic arguments when the method can't be found in any + // implementation (#81576). + let mut ty = rcvr_ty; + if let ty::Adt(def, generics) = rcvr_ty.kind() { + if generics.len() > 0 { + let mut autoderef = self.autoderef(span, rcvr_ty).silence_errors(); + let candidate_found = autoderef.any(|(ty, _)| { + if let ty::Adt(adt_def, _) = ty.kind() { + self.tcx + .inherent_impls(adt_def.did()) + .into_iter() + .any(|def_id| self.associated_value(*def_id, item_ident).is_some()) + } else { + false + } + }); + let has_deref = autoderef.step_count() > 0; + if !candidate_found && !has_deref && unsatisfied_predicates.is_empty() { + ty = self.tcx.at(span).type_of(def.did()).instantiate_identity(); + } + } + } + let mut err = self.dcx().create_err(NoAssociatedItem { span, item_kind, @@ -691,7 +714,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } else { rcvr_ty.prefix_string(self.tcx) }, - ty: rcvr_ty, + ty, trait_missing_method, }); diff --git a/tests/ui/attributes/rustc_confusables_std_cases.stderr b/tests/ui/attributes/rustc_confusables_std_cases.stderr index 9129393a3033d..5655c8bba55fe 100644 --- a/tests/ui/attributes/rustc_confusables_std_cases.stderr +++ b/tests/ui/attributes/rustc_confusables_std_cases.stderr @@ -1,4 +1,4 @@ -error[E0599]: no method named `push` found for struct `BTreeSet<_>` in the current scope +error[E0599]: no method named `push` found for struct `BTreeSet` in the current scope --> $DIR/rustc_confusables_std_cases.rs:6:7 | LL | x.push(1); @@ -22,7 +22,7 @@ LL - x.push_back(1); LL + x.push(1); | -error[E0599]: no method named `push` found for struct `VecDeque<_>` in the current scope +error[E0599]: no method named `push` found for struct `VecDeque` in the current scope --> $DIR/rustc_confusables_std_cases.rs:12:7 | LL | x.push(1); diff --git a/tests/ui/confuse-field-and-method/issue-18343.stderr b/tests/ui/confuse-field-and-method/issue-18343.stderr index 6444681e499fd..9517617fe34cc 100644 --- a/tests/ui/confuse-field-and-method/issue-18343.stderr +++ b/tests/ui/confuse-field-and-method/issue-18343.stderr @@ -1,4 +1,4 @@ -error[E0599]: no method named `closure` found for struct `Obj<{closure@$DIR/issue-18343.rs:6:28: 6:30}>` in the current scope +error[E0599]: no method named `closure` found for struct `Obj` in the current scope --> $DIR/issue-18343.rs:7:7 | LL | struct Obj where F: FnMut() -> u32 { diff --git a/tests/ui/confuse-field-and-method/issue-2392.stderr b/tests/ui/confuse-field-and-method/issue-2392.stderr index 0b13e94c96b28..e1ad24df80f70 100644 --- a/tests/ui/confuse-field-and-method/issue-2392.stderr +++ b/tests/ui/confuse-field-and-method/issue-2392.stderr @@ -1,4 +1,4 @@ -error[E0599]: no method named `closure` found for struct `Obj<{closure@$DIR/issue-2392.rs:35:36: 35:38}>` in the current scope +error[E0599]: no method named `closure` found for struct `Obj` in the current scope --> $DIR/issue-2392.rs:36:15 | LL | struct Obj where F: FnOnce() -> u32 { @@ -12,7 +12,7 @@ help: to call the closure stored in `closure`, surround the field access with pa LL | (o_closure.closure)(); | + + -error[E0599]: no method named `not_closure` found for struct `Obj<{closure@$DIR/issue-2392.rs:35:36: 35:38}>` in the current scope +error[E0599]: no method named `not_closure` found for struct `Obj` in the current scope --> $DIR/issue-2392.rs:38:15 | LL | struct Obj where F: FnOnce() -> u32 { @@ -23,7 +23,7 @@ LL | o_closure.not_closure(); | | | field, not a method -error[E0599]: no method named `closure` found for struct `Obj u32 {func}>` in the current scope +error[E0599]: no method named `closure` found for struct `Obj` in the current scope --> $DIR/issue-2392.rs:42:12 | LL | struct Obj where F: FnOnce() -> u32 { @@ -65,7 +65,7 @@ help: to call the trait object stored in `boxed_closure`, surround the field acc LL | (boxed_closure.boxed_closure)(); | + + -error[E0599]: no method named `closure` found for struct `Obj u32 {func}>` in the current scope +error[E0599]: no method named `closure` found for struct `Obj` in the current scope --> $DIR/issue-2392.rs:53:12 | LL | struct Obj where F: FnOnce() -> u32 { @@ -79,7 +79,7 @@ help: to call the function stored in `closure`, surround the field access with p LL | (w.wrap.closure)(); | + + -error[E0599]: no method named `not_closure` found for struct `Obj u32 {func}>` in the current scope +error[E0599]: no method named `not_closure` found for struct `Obj` in the current scope --> $DIR/issue-2392.rs:55:12 | LL | struct Obj where F: FnOnce() -> u32 { @@ -90,7 +90,7 @@ LL | w.wrap.not_closure(); | | | field, not a method -error[E0599]: no method named `closure` found for struct `Obj u32 + 'static)>>` in the current scope +error[E0599]: no method named `closure` found for struct `Obj` in the current scope --> $DIR/issue-2392.rs:58:24 | LL | struct Obj where F: FnOnce() -> u32 { diff --git a/tests/ui/delegation/correct_body_owner_parent_found_in_diagnostics.stderr b/tests/ui/delegation/correct_body_owner_parent_found_in_diagnostics.stderr index 5ac1745875e76..b0bfc72065878 100644 --- a/tests/ui/delegation/correct_body_owner_parent_found_in_diagnostics.stderr +++ b/tests/ui/delegation/correct_body_owner_parent_found_in_diagnostics.stderr @@ -43,7 +43,7 @@ help: consider introducing lifetime `'a` here LL | impl<'a> Trait for Z { | ++++ -error[E0599]: no function or associated item named `new` found for struct `InvariantRef<'_, _>` in the current scope +error[E0599]: no function or associated item named `new` found for struct `InvariantRef<'a, T>` in the current scope --> $DIR/correct_body_owner_parent_found_in_diagnostics.rs:9:41 | LL | pub struct InvariantRef<'a, T: ?Sized>(&'a T, PhantomData<&'a mut &'a T>); diff --git a/tests/ui/issues/issue-41880.stderr b/tests/ui/issues/issue-41880.stderr index 8d9b3e48c23a5..2f1ebee7ca5a3 100644 --- a/tests/ui/issues/issue-41880.stderr +++ b/tests/ui/issues/issue-41880.stderr @@ -1,4 +1,4 @@ -error[E0599]: no method named `iter` found for struct `Iterate<{integer}, {closure@$DIR/issue-41880.rs:26:24: 26:27}>` in the current scope +error[E0599]: no method named `iter` found for struct `Iterate` in the current scope --> $DIR/issue-41880.rs:27:24 | LL | pub struct Iterate { diff --git a/tests/ui/methods/call_method_unknown_referent.stderr b/tests/ui/methods/call_method_unknown_referent.stderr index 30095d57e54dc..5d6974a00c695 100644 --- a/tests/ui/methods/call_method_unknown_referent.stderr +++ b/tests/ui/methods/call_method_unknown_referent.stderr @@ -10,7 +10,7 @@ error[E0282]: type annotations needed LL | let _b = (rc as std::rc::Rc<_>).read(); | ^^^^ cannot infer type -error[E0599]: no method named `read` found for struct `SmartPtr<_>` in the current scope +error[E0599]: no method named `read` found for struct `SmartPtr` in the current scope --> $DIR/call_method_unknown_referent.rs:46:35 | LL | struct SmartPtr(T); diff --git a/tests/ui/methods/method-not-found-generic-arg-elision.stderr b/tests/ui/methods/method-not-found-generic-arg-elision.stderr index 3095e665701f0..75fabc27b0f7d 100644 --- a/tests/ui/methods/method-not-found-generic-arg-elision.stderr +++ b/tests/ui/methods/method-not-found-generic-arg-elision.stderr @@ -10,7 +10,7 @@ LL | let d = point_i32.distance(); = note: the method was found for - `Point` -error[E0599]: no method named `other` found for struct `Point` in the current scope +error[E0599]: no method named `other` found for struct `Point` in the current scope --> $DIR/method-not-found-generic-arg-elision.rs:84:23 | LL | struct Point { @@ -19,7 +19,7 @@ LL | struct Point { LL | let d = point_i32.other(); | ^^^^^ method not found in `Point` -error[E0599]: no method named `extend` found for struct `Map, Box Fn(&'a i32) -> i32>>` in the current scope +error[E0599]: no method named `extend` found for struct `Map` in the current scope --> $DIR/method-not-found-generic-arg-elision.rs:87:67 | LL | v.iter().map(Box::new(|x| x * x) as Box i32>).extend(std::iter::once(100)); @@ -41,7 +41,7 @@ LL | wrapper.method(); - `Wrapper` and 2 more types -error[E0599]: no method named `other` found for struct `Wrapper` in the current scope +error[E0599]: no method named `other` found for struct `Wrapper` in the current scope --> $DIR/method-not-found-generic-arg-elision.rs:92:13 | LL | struct Wrapper(T); @@ -64,7 +64,7 @@ LL | wrapper.method(); - `Wrapper2<'a, i32, C>` - `Wrapper2<'a, i8, C>` -error[E0599]: no method named `other` found for struct `Wrapper2<'_, bool, 3>` in the current scope +error[E0599]: no method named `other` found for struct `Wrapper2<'a, T, C>` in the current scope --> $DIR/method-not-found-generic-arg-elision.rs:98:13 | LL | struct Wrapper2<'a, T, const C: usize> { diff --git a/tests/ui/methods/untrimmed-path-type.stderr b/tests/ui/methods/untrimmed-path-type.stderr index 8022c5366cdba..ee07e2daa1e1d 100644 --- a/tests/ui/methods/untrimmed-path-type.stderr +++ b/tests/ui/methods/untrimmed-path-type.stderr @@ -1,4 +1,4 @@ -error[E0599]: no method named `unknown` found for enum `Result<(), std::io::Error>` in the current scope +error[E0599]: no method named `unknown` found for enum `Result` in the current scope --> $DIR/untrimmed-path-type.rs:5:11 | LL | meow().unknown(); diff --git a/tests/ui/self/arbitrary_self_type_infinite_recursion.stderr b/tests/ui/self/arbitrary_self_type_infinite_recursion.stderr index 10e4fa8fdd727..2dadc5c2d33bb 100644 --- a/tests/ui/self/arbitrary_self_type_infinite_recursion.stderr +++ b/tests/ui/self/arbitrary_self_type_infinite_recursion.stderr @@ -32,7 +32,7 @@ LL | p.method(); | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`arbitrary_self_type_infinite_recursion`) -error[E0599]: no method named `method` found for struct `MySmartPtr` in the current scope +error[E0599]: no method named `method` found for struct `MySmartPtr` in the current scope --> $DIR/arbitrary_self_type_infinite_recursion.rs:21:5 | LL | struct MySmartPtr(T); diff --git a/tests/ui/self/arbitrary_self_types_not_allow_call_with_no_deref.stderr b/tests/ui/self/arbitrary_self_types_not_allow_call_with_no_deref.stderr index 40fd93032a93b..5d7f614209391 100644 --- a/tests/ui/self/arbitrary_self_types_not_allow_call_with_no_deref.stderr +++ b/tests/ui/self/arbitrary_self_types_not_allow_call_with_no_deref.stderr @@ -1,4 +1,4 @@ -error[E0599]: no method named `frobnicate_ref` found for struct `CppRef` in the current scope +error[E0599]: no method named `frobnicate_ref` found for struct `CppRef` in the current scope --> $DIR/arbitrary_self_types_not_allow_call_with_no_deref.rs:29:17 | LL | struct CppRef(T); @@ -16,7 +16,7 @@ help: there is a method `frobnicate_cpp_ref` with a similar name LL | foo_cpp_ref.frobnicate_cpp_ref(); | ++++ -error[E0599]: no method named `frobnicate_self` found for struct `CppRef` in the current scope +error[E0599]: no method named `frobnicate_self` found for struct `CppRef` in the current scope --> $DIR/arbitrary_self_types_not_allow_call_with_no_deref.rs:32:17 | LL | struct CppRef(T); diff --git a/tests/ui/self/arbitrary_self_types_pin_needing_borrow.rs b/tests/ui/self/arbitrary_self_types_pin_needing_borrow.rs index 0af88878f644c..288458902782a 100644 --- a/tests/ui/self/arbitrary_self_types_pin_needing_borrow.rs +++ b/tests/ui/self/arbitrary_self_types_pin_needing_borrow.rs @@ -9,5 +9,5 @@ impl S { fn main() { Pin::new(S).x(); //~^ ERROR the trait bound `S: Deref` is not satisfied - //~| ERROR no method named `x` found for struct `Pin` in the current scope + //~| ERROR no method named `x` found for struct `Pin` in the current scope } diff --git a/tests/ui/self/arbitrary_self_types_pin_needing_borrow.stderr b/tests/ui/self/arbitrary_self_types_pin_needing_borrow.stderr index c8b3119b1ee4e..df226a9366a3c 100644 --- a/tests/ui/self/arbitrary_self_types_pin_needing_borrow.stderr +++ b/tests/ui/self/arbitrary_self_types_pin_needing_borrow.stderr @@ -15,7 +15,7 @@ LL | Pin::new(&S).x(); LL | Pin::new(&mut S).x(); | ++++ -error[E0599]: no method named `x` found for struct `Pin` in the current scope +error[E0599]: no method named `x` found for struct `Pin` in the current scope --> $DIR/arbitrary_self_types_pin_needing_borrow.rs:10:17 | LL | Pin::new(S).x(); diff --git a/tests/ui/simd/libm_no_std_cant_float.stderr b/tests/ui/simd/libm_no_std_cant_float.stderr index 82510c9b99138..cc9aefaad5ef3 100644 --- a/tests/ui/simd/libm_no_std_cant_float.stderr +++ b/tests/ui/simd/libm_no_std_cant_float.stderr @@ -1,34 +1,34 @@ -error[E0599]: no method named `ceil` found for struct `Simd` in the current scope +error[E0599]: no method named `ceil` found for struct `Simd` in the current scope --> $DIR/libm_no_std_cant_float.rs:15:17 | LL | let _xc = x.ceil(); | ^^^^ method not found in `Simd` -error[E0599]: no method named `floor` found for struct `Simd` in the current scope +error[E0599]: no method named `floor` found for struct `Simd` in the current scope --> $DIR/libm_no_std_cant_float.rs:16:17 | LL | let _xf = x.floor(); | ^^^^^ method not found in `Simd` -error[E0599]: no method named `round` found for struct `Simd` in the current scope +error[E0599]: no method named `round` found for struct `Simd` in the current scope --> $DIR/libm_no_std_cant_float.rs:17:17 | LL | let _xr = x.round(); | ^^^^^ method not found in `Simd` -error[E0599]: no method named `trunc` found for struct `Simd` in the current scope +error[E0599]: no method named `trunc` found for struct `Simd` in the current scope --> $DIR/libm_no_std_cant_float.rs:18:17 | LL | let _xt = x.trunc(); | ^^^^^ method not found in `Simd` -error[E0599]: no method named `mul_add` found for struct `Simd` in the current scope +error[E0599]: no method named `mul_add` found for struct `Simd` in the current scope --> $DIR/libm_no_std_cant_float.rs:19:19 | LL | let _xfma = x.mul_add(x, x); | ^^^^^^^ method not found in `Simd` -error[E0599]: no method named `sqrt` found for struct `Simd` in the current scope +error[E0599]: no method named `sqrt` found for struct `Simd` in the current scope --> $DIR/libm_no_std_cant_float.rs:20:20 | LL | let _xsqrt = x.sqrt(); diff --git a/tests/ui/suggestions/enum-method-probe.fixed b/tests/ui/suggestions/enum-method-probe.fixed index a4ce98a6046c1..1ce6a943c5bba 100644 --- a/tests/ui/suggestions/enum-method-probe.fixed +++ b/tests/ui/suggestions/enum-method-probe.fixed @@ -14,7 +14,7 @@ impl Foo { fn test_result_in_result() -> Result<(), ()> { let res: Result<_, ()> = Ok(Foo); res?.get(); - //~^ ERROR no method named `get` found for enum `Result` in the current scope + //~^ ERROR no method named `get` found for enum `Result` in the current scope //~| HELP use the `?` operator Ok(()) } @@ -22,7 +22,7 @@ fn test_result_in_result() -> Result<(), ()> { async fn async_test_result_in_result() -> Result<(), ()> { let res: Result<_, ()> = Ok(Foo); res?.get(); - //~^ ERROR no method named `get` found for enum `Result` in the current scope + //~^ ERROR no method named `get` found for enum `Result` in the current scope //~| HELP use the `?` operator Ok(()) } @@ -30,21 +30,21 @@ async fn async_test_result_in_result() -> Result<(), ()> { fn test_result_in_unit_return() { let res: Result<_, ()> = Ok(Foo); res.expect("REASON").get(); - //~^ ERROR no method named `get` found for enum `Result` in the current scope + //~^ ERROR no method named `get` found for enum `Result` in the current scope //~| HELP consider using `Result::expect` to unwrap the `Foo` value, panicking if the value is a `Result::Err` } async fn async_test_result_in_unit_return() { let res: Result<_, ()> = Ok(Foo); res.expect("REASON").get(); - //~^ ERROR no method named `get` found for enum `Result` in the current scope + //~^ ERROR no method named `get` found for enum `Result` in the current scope //~| HELP consider using `Result::expect` to unwrap the `Foo` value, panicking if the value is a `Result::Err` } fn test_option_in_option() -> Option<()> { let res: Option<_> = Some(Foo); res?.get(); - //~^ ERROR no method named `get` found for enum `Option` in the current scope + //~^ ERROR no method named `get` found for enum `Option` in the current scope //~| HELP use the `?` operator Some(()) } @@ -52,7 +52,7 @@ fn test_option_in_option() -> Option<()> { fn test_option_in_unit_return() { let res: Option<_> = Some(Foo); res.expect("REASON").get(); - //~^ ERROR no method named `get` found for enum `Option` in the current scope + //~^ ERROR no method named `get` found for enum `Option` in the current scope //~| HELP consider using `Option::expect` to unwrap the `Foo` value, panicking if the value is an `Option::None` } diff --git a/tests/ui/suggestions/enum-method-probe.rs b/tests/ui/suggestions/enum-method-probe.rs index c9e1c1e9e70e5..dd3addbd0a3fb 100644 --- a/tests/ui/suggestions/enum-method-probe.rs +++ b/tests/ui/suggestions/enum-method-probe.rs @@ -14,7 +14,7 @@ impl Foo { fn test_result_in_result() -> Result<(), ()> { let res: Result<_, ()> = Ok(Foo); res.get(); - //~^ ERROR no method named `get` found for enum `Result` in the current scope + //~^ ERROR no method named `get` found for enum `Result` in the current scope //~| HELP use the `?` operator Ok(()) } @@ -22,7 +22,7 @@ fn test_result_in_result() -> Result<(), ()> { async fn async_test_result_in_result() -> Result<(), ()> { let res: Result<_, ()> = Ok(Foo); res.get(); - //~^ ERROR no method named `get` found for enum `Result` in the current scope + //~^ ERROR no method named `get` found for enum `Result` in the current scope //~| HELP use the `?` operator Ok(()) } @@ -30,21 +30,21 @@ async fn async_test_result_in_result() -> Result<(), ()> { fn test_result_in_unit_return() { let res: Result<_, ()> = Ok(Foo); res.get(); - //~^ ERROR no method named `get` found for enum `Result` in the current scope + //~^ ERROR no method named `get` found for enum `Result` in the current scope //~| HELP consider using `Result::expect` to unwrap the `Foo` value, panicking if the value is a `Result::Err` } async fn async_test_result_in_unit_return() { let res: Result<_, ()> = Ok(Foo); res.get(); - //~^ ERROR no method named `get` found for enum `Result` in the current scope + //~^ ERROR no method named `get` found for enum `Result` in the current scope //~| HELP consider using `Result::expect` to unwrap the `Foo` value, panicking if the value is a `Result::Err` } fn test_option_in_option() -> Option<()> { let res: Option<_> = Some(Foo); res.get(); - //~^ ERROR no method named `get` found for enum `Option` in the current scope + //~^ ERROR no method named `get` found for enum `Option` in the current scope //~| HELP use the `?` operator Some(()) } @@ -52,7 +52,7 @@ fn test_option_in_option() -> Option<()> { fn test_option_in_unit_return() { let res: Option<_> = Some(Foo); res.get(); - //~^ ERROR no method named `get` found for enum `Option` in the current scope + //~^ ERROR no method named `get` found for enum `Option` in the current scope //~| HELP consider using `Option::expect` to unwrap the `Foo` value, panicking if the value is an `Option::None` } diff --git a/tests/ui/suggestions/enum-method-probe.stderr b/tests/ui/suggestions/enum-method-probe.stderr index b4a97dd100fdb..5aa0fc44c7b50 100644 --- a/tests/ui/suggestions/enum-method-probe.stderr +++ b/tests/ui/suggestions/enum-method-probe.stderr @@ -1,4 +1,4 @@ -error[E0599]: no method named `get` found for enum `Result` in the current scope +error[E0599]: no method named `get` found for enum `Result` in the current scope --> $DIR/enum-method-probe.rs:24:9 | LL | res.get(); @@ -14,7 +14,7 @@ help: use the `?` operator to extract the `Foo` value, propagating a `Result::Er LL | res?.get(); | + -error[E0599]: no method named `get` found for enum `Result` in the current scope +error[E0599]: no method named `get` found for enum `Result` in the current scope --> $DIR/enum-method-probe.rs:39:9 | LL | res.get(); @@ -30,7 +30,7 @@ help: consider using `Result::expect` to unwrap the `Foo` value, panicking if th LL | res.expect("REASON").get(); | +++++++++++++++++ -error[E0599]: no method named `get` found for enum `Result` in the current scope +error[E0599]: no method named `get` found for enum `Result` in the current scope --> $DIR/enum-method-probe.rs:16:9 | LL | res.get(); @@ -46,7 +46,7 @@ help: use the `?` operator to extract the `Foo` value, propagating a `Result::Er LL | res?.get(); | + -error[E0599]: no method named `get` found for enum `Result` in the current scope +error[E0599]: no method named `get` found for enum `Result` in the current scope --> $DIR/enum-method-probe.rs:32:9 | LL | res.get(); @@ -62,7 +62,7 @@ help: consider using `Result::expect` to unwrap the `Foo` value, panicking if th LL | res.expect("REASON").get(); | +++++++++++++++++ -error[E0599]: no method named `get` found for enum `Option` in the current scope +error[E0599]: no method named `get` found for enum `Option` in the current scope --> $DIR/enum-method-probe.rs:46:9 | LL | res.get(); @@ -78,7 +78,7 @@ help: use the `?` operator to extract the `Foo` value, propagating an `Option::N LL | res?.get(); | + -error[E0599]: no method named `get` found for enum `Option` in the current scope +error[E0599]: no method named `get` found for enum `Option` in the current scope --> $DIR/enum-method-probe.rs:54:9 | LL | res.get(); diff --git a/tests/ui/suggestions/field-has-method.rs b/tests/ui/suggestions/field-has-method.rs index 72ac48cf02ff0..6e584d7833879 100644 --- a/tests/ui/suggestions/field-has-method.rs +++ b/tests/ui/suggestions/field-has-method.rs @@ -17,7 +17,7 @@ struct InferOk { fn foo(i: InferOk) { let k = i.kind(); - //~^ ERROR no method named `kind` found for struct `InferOk` in the current scope + //~^ ERROR no method named `kind` found for struct `InferOk` in the current scope } fn main() {} diff --git a/tests/ui/suggestions/field-has-method.stderr b/tests/ui/suggestions/field-has-method.stderr index 045dec87050f1..adcb723e4f126 100644 --- a/tests/ui/suggestions/field-has-method.stderr +++ b/tests/ui/suggestions/field-has-method.stderr @@ -1,4 +1,4 @@ -error[E0599]: no method named `kind` found for struct `InferOk` in the current scope +error[E0599]: no method named `kind` found for struct `InferOk` in the current scope --> $DIR/field-has-method.rs:19:15 | LL | struct InferOk { diff --git a/tests/ui/suggestions/inner_type.fixed b/tests/ui/suggestions/inner_type.fixed index 3058a5a737ae0..8174f8e204e5c 100644 --- a/tests/ui/suggestions/inner_type.fixed +++ b/tests/ui/suggestions/inner_type.fixed @@ -15,26 +15,26 @@ fn main() { let other_item = std::cell::RefCell::new(Struct { p: 42_u32 }); other_item.borrow().method(); - //~^ ERROR no method named `method` found for struct `RefCell>` in the current scope [E0599] + //~^ ERROR no method named `method` found for struct `RefCell` in the current scope [E0599] //~| HELP use `.borrow()` to borrow the `Struct`, panicking if a mutable borrow exists other_item.borrow_mut().some_mutable_method(); - //~^ ERROR no method named `some_mutable_method` found for struct `RefCell>` in the current scope [E0599] + //~^ ERROR no method named `some_mutable_method` found for struct `RefCell` in the current scope [E0599] //~| HELP .borrow_mut()` to mutably borrow the `Struct`, panicking if any borrows exist let another_item = std::sync::Mutex::new(Struct { p: 42_u32 }); another_item.lock().unwrap().method(); - //~^ ERROR no method named `method` found for struct `std::sync::Mutex>` in the current scope [E0599] + //~^ ERROR no method named `method` found for struct `std::sync::Mutex` in the current scope [E0599] //~| HELP use `.lock().unwrap()` to borrow the `Struct`, blocking the current thread until it can be acquired let another_item = std::sync::RwLock::new(Struct { p: 42_u32 }); another_item.read().unwrap().method(); - //~^ ERROR no method named `method` found for struct `RwLock>` in the current scope [E0599] + //~^ ERROR no method named `method` found for struct `RwLock` in the current scope [E0599] //~| HELP use `.read().unwrap()` to borrow the `Struct`, blocking the current thread until it can be acquired another_item.write().unwrap().some_mutable_method(); - //~^ ERROR no method named `some_mutable_method` found for struct `RwLock>` in the current scope [E0599] + //~^ ERROR no method named `some_mutable_method` found for struct `RwLock` in the current scope [E0599] //~| HELP use `.write().unwrap()` to mutably borrow the `Struct`, blocking the current thread until it can be acquired } diff --git a/tests/ui/suggestions/inner_type.rs b/tests/ui/suggestions/inner_type.rs index 6652eb6a9370f..e4eaf07ca8b7a 100644 --- a/tests/ui/suggestions/inner_type.rs +++ b/tests/ui/suggestions/inner_type.rs @@ -15,26 +15,26 @@ fn main() { let other_item = std::cell::RefCell::new(Struct { p: 42_u32 }); other_item.method(); - //~^ ERROR no method named `method` found for struct `RefCell>` in the current scope [E0599] + //~^ ERROR no method named `method` found for struct `RefCell` in the current scope [E0599] //~| HELP use `.borrow()` to borrow the `Struct`, panicking if a mutable borrow exists other_item.some_mutable_method(); - //~^ ERROR no method named `some_mutable_method` found for struct `RefCell>` in the current scope [E0599] + //~^ ERROR no method named `some_mutable_method` found for struct `RefCell` in the current scope [E0599] //~| HELP .borrow_mut()` to mutably borrow the `Struct`, panicking if any borrows exist let another_item = std::sync::Mutex::new(Struct { p: 42_u32 }); another_item.method(); - //~^ ERROR no method named `method` found for struct `std::sync::Mutex>` in the current scope [E0599] + //~^ ERROR no method named `method` found for struct `std::sync::Mutex` in the current scope [E0599] //~| HELP use `.lock().unwrap()` to borrow the `Struct`, blocking the current thread until it can be acquired let another_item = std::sync::RwLock::new(Struct { p: 42_u32 }); another_item.method(); - //~^ ERROR no method named `method` found for struct `RwLock>` in the current scope [E0599] + //~^ ERROR no method named `method` found for struct `RwLock` in the current scope [E0599] //~| HELP use `.read().unwrap()` to borrow the `Struct`, blocking the current thread until it can be acquired another_item.some_mutable_method(); - //~^ ERROR no method named `some_mutable_method` found for struct `RwLock>` in the current scope [E0599] + //~^ ERROR no method named `some_mutable_method` found for struct `RwLock` in the current scope [E0599] //~| HELP use `.write().unwrap()` to mutably borrow the `Struct`, blocking the current thread until it can be acquired } diff --git a/tests/ui/suggestions/inner_type.stderr b/tests/ui/suggestions/inner_type.stderr index ed1b509dcac20..017ddb5ad6dee 100644 --- a/tests/ui/suggestions/inner_type.stderr +++ b/tests/ui/suggestions/inner_type.stderr @@ -1,4 +1,4 @@ -error[E0599]: no method named `method` found for struct `RefCell>` in the current scope +error[E0599]: no method named `method` found for struct `RefCell` in the current scope --> $DIR/inner_type.rs:17:16 | LL | other_item.method(); @@ -14,7 +14,7 @@ help: use `.borrow()` to borrow the `Struct`, panicking if a mutable borrow LL | other_item.borrow().method(); | +++++++++ -error[E0599]: no method named `some_mutable_method` found for struct `RefCell>` in the current scope +error[E0599]: no method named `some_mutable_method` found for struct `RefCell` in the current scope --> $DIR/inner_type.rs:21:16 | LL | other_item.some_mutable_method(); @@ -30,7 +30,7 @@ help: use `.borrow_mut()` to mutably borrow the `Struct`, panicking if any LL | other_item.borrow_mut().some_mutable_method(); | +++++++++++++ -error[E0599]: no method named `method` found for struct `std::sync::Mutex>` in the current scope +error[E0599]: no method named `method` found for struct `std::sync::Mutex` in the current scope --> $DIR/inner_type.rs:27:18 | LL | another_item.method(); @@ -46,7 +46,7 @@ help: use `.lock().unwrap()` to borrow the `Struct`, blocking the current t LL | another_item.lock().unwrap().method(); | ++++++++++++++++ -error[E0599]: no method named `method` found for struct `RwLock>` in the current scope +error[E0599]: no method named `method` found for struct `RwLock` in the current scope --> $DIR/inner_type.rs:33:18 | LL | another_item.method(); @@ -62,7 +62,7 @@ help: use `.read().unwrap()` to borrow the `Struct`, blocking the current t LL | another_item.read().unwrap().method(); | ++++++++++++++++ -error[E0599]: no method named `some_mutable_method` found for struct `RwLock>` in the current scope +error[E0599]: no method named `some_mutable_method` found for struct `RwLock` in the current scope --> $DIR/inner_type.rs:37:18 | LL | another_item.some_mutable_method(); diff --git a/tests/ui/suggestions/inner_type2.rs b/tests/ui/suggestions/inner_type2.rs index 80d91bd51776f..7082862f409e7 100644 --- a/tests/ui/suggestions/inner_type2.rs +++ b/tests/ui/suggestions/inner_type2.rs @@ -16,11 +16,11 @@ thread_local! { fn main() { STRUCT.method(); - //~^ ERROR no method named `method` found for struct `LocalKey>` in the current scope [E0599] + //~^ ERROR no method named `method` found for struct `LocalKey` in the current scope [E0599] //~| HELP use `with` or `try_with` to access thread local storage let item = std::mem::MaybeUninit::new(Struct { p: 42_u32 }); item.method(); - //~^ ERROR no method named `method` found for union `MaybeUninit>` in the current scope [E0599] + //~^ ERROR no method named `method` found for union `MaybeUninit` in the current scope [E0599] //~| HELP if this `MaybeUninit>` has been initialized, use one of the `assume_init` methods to access the inner value } diff --git a/tests/ui/suggestions/inner_type2.stderr b/tests/ui/suggestions/inner_type2.stderr index 170fe5eff0966..e6cb2048522fd 100644 --- a/tests/ui/suggestions/inner_type2.stderr +++ b/tests/ui/suggestions/inner_type2.stderr @@ -1,4 +1,4 @@ -error[E0599]: no method named `method` found for struct `LocalKey>` in the current scope +error[E0599]: no method named `method` found for struct `LocalKey` in the current scope --> $DIR/inner_type2.rs:18:12 | LL | STRUCT.method(); @@ -11,7 +11,7 @@ note: the method `method` exists on the type `Struct` LL | pub fn method(&self) {} | ^^^^^^^^^^^^^^^^^^^^ -error[E0599]: no method named `method` found for union `MaybeUninit>` in the current scope +error[E0599]: no method named `method` found for union `MaybeUninit` in the current scope --> $DIR/inner_type2.rs:23:10 | LL | item.method(); From 2de4cd8c2244ce4ab95777dd0439d40cafd8b52e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Thu, 24 Jul 2025 22:43:05 +0000 Subject: [PATCH 09/13] Unify wording on `long_ty_path` everywhere --- .../src/error_reporting/infer/mod.rs | 15 ++++++------ .../traits/fulfillment_errors.rs | 24 +++++++++---------- .../traits/on_unimplemented.rs | 4 ++-- .../src/error_reporting/traits/suggestions.rs | 4 ++-- 4 files changed, 24 insertions(+), 23 deletions(-) diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs index b9acadc406e9c..ee2868e2a72a5 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs @@ -1928,7 +1928,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { &self, trace: &TypeTrace<'tcx>, terr: TypeError<'tcx>, - path: &mut Option, + long_ty_path: &mut Option, ) -> Vec { let mut suggestions = Vec::new(); let span = trace.cause.span; @@ -2007,7 +2007,8 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { }) | ObligationCauseCode::BlockTailExpression(.., source)) = code && let hir::MatchSource::TryDesugar(_) = source - && let Some((expected_ty, found_ty)) = self.values_str(trace.values, &trace.cause, path) + && let Some((expected_ty, found_ty)) = + self.values_str(trace.values, &trace.cause, long_ty_path) { suggestions.push(TypeErrorAdditionalDiags::TryCannotConvert { found: found_ty.content(), @@ -2137,11 +2138,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { &self, values: ValuePairs<'tcx>, cause: &ObligationCause<'tcx>, - file: &mut Option, + long_ty_path: &mut Option, ) -> Option<(DiagStyledString, DiagStyledString)> { match values { ValuePairs::Regions(exp_found) => self.expected_found_str(exp_found), - ValuePairs::Terms(exp_found) => self.expected_found_str_term(exp_found, file), + ValuePairs::Terms(exp_found) => self.expected_found_str_term(exp_found, long_ty_path), ValuePairs::Aliases(exp_found) => self.expected_found_str(exp_found), ValuePairs::ExistentialTraitRef(exp_found) => self.expected_found_str(exp_found), ValuePairs::ExistentialProjection(exp_found) => self.expected_found_str(exp_found), @@ -2181,7 +2182,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { fn expected_found_str_term( &self, exp_found: ty::error::ExpectedFound>, - path: &mut Option, + long_ty_path: &mut Option, ) -> Option<(DiagStyledString, DiagStyledString)> { let exp_found = self.resolve_vars_if_possible(exp_found); if exp_found.references_error() { @@ -2198,11 +2199,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { let exp_s = exp.content(); let fnd_s = fnd.content(); if exp_s.len() > len { - let exp_s = self.tcx.short_string(expected, path); + let exp_s = self.tcx.short_string(expected, long_ty_path); exp = DiagStyledString::highlighted(exp_s); } if fnd_s.len() > len { - let fnd_s = self.tcx.short_string(found, path); + let fnd_s = self.tcx.short_string(found, long_ty_path); fnd = DiagStyledString::highlighted(fnd_s); } (exp, fnd) diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs index 1e8af423f261a..38f1c94ed0153 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs @@ -1604,7 +1604,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { projection_term: ty::AliasTerm<'tcx>, normalized_ty: ty::Term<'tcx>, expected_ty: ty::Term<'tcx>, - file: &mut Option, + long_ty_path: &mut Option, ) -> Option<(String, Span, Option)> { let trait_def_id = projection_term.trait_def_id(self.tcx); let self_ty = projection_term.self_ty(); @@ -1644,25 +1644,25 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { }; let item = match self_ty.kind() { ty::FnDef(def, _) => self.tcx.item_name(*def).to_string(), - _ => self.tcx.short_string(self_ty, file), + _ => self.tcx.short_string(self_ty, long_ty_path), }; - let expected_ty = self.tcx.short_string(expected_ty, file); - let normalized_ty = self.tcx.short_string(normalized_ty, file); + let expected_ty = self.tcx.short_string(expected_ty, long_ty_path); + let normalized_ty = self.tcx.short_string(normalized_ty, long_ty_path); Some((format!( "expected `{item}` to return `{expected_ty}`, but it returns `{normalized_ty}`", ), span, closure_span)) } else if self.tcx.is_lang_item(trait_def_id, LangItem::Future) { - let self_ty = self.tcx.short_string(self_ty, file); - let expected_ty = self.tcx.short_string(expected_ty, file); - let normalized_ty = self.tcx.short_string(normalized_ty, file); + let self_ty = self.tcx.short_string(self_ty, long_ty_path); + let expected_ty = self.tcx.short_string(expected_ty, long_ty_path); + let normalized_ty = self.tcx.short_string(normalized_ty, long_ty_path); Some((format!( "expected `{self_ty}` to be a future that resolves to `{expected_ty}`, but it \ resolves to `{normalized_ty}`" ), span, None)) } else if Some(trait_def_id) == self.tcx.get_diagnostic_item(sym::Iterator) { - let self_ty = self.tcx.short_string(self_ty, file); - let expected_ty = self.tcx.short_string(expected_ty, file); - let normalized_ty = self.tcx.short_string(normalized_ty, file); + let self_ty = self.tcx.short_string(self_ty, long_ty_path); + let expected_ty = self.tcx.short_string(expected_ty, long_ty_path); + let normalized_ty = self.tcx.short_string(normalized_ty, long_ty_path); Some((format!( "expected `{self_ty}` to be an iterator that yields `{expected_ty}`, but it \ yields `{normalized_ty}`" @@ -2514,7 +2514,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { predicate_constness: Option, append_const_msg: Option, post_message: String, - long_ty_file: &mut Option, + long_ty_path: &mut Option, ) -> String { message .and_then(|cannot_do_this| { @@ -2540,7 +2540,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { "the trait bound `{}` is not satisfied{post_message}", self.tcx.short_string( trait_predicate.print_with_bound_constness(predicate_constness), - long_ty_file, + long_ty_path, ), ) }) diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented.rs index 5765dfd891d4f..bb5c6469f34b4 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented.rs @@ -99,7 +99,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { &self, trait_pred: ty::PolyTraitPredicate<'tcx>, obligation: &PredicateObligation<'tcx>, - long_ty_file: &mut Option, + long_ty_path: &mut Option, ) -> OnUnimplementedNote { if trait_pred.polarity() != ty::PredicatePolarity::Positive { return OnUnimplementedNote::default(); @@ -281,7 +281,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { GenericParamDefKind::Type { .. } | GenericParamDefKind::Const { .. } => { if let Some(ty) = trait_pred.trait_ref.args[param.index as usize].as_type() { - self.tcx.short_string(ty, long_ty_file) + self.tcx.short_string(ty, long_ty_path) } else { trait_pred.trait_ref.args[param.index as usize].to_string() } diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs index 53d99d9a24b18..80e8c02191d75 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs @@ -5368,7 +5368,7 @@ pub(super) fn get_explanation_based_on_obligation<'tcx>( obligation: &PredicateObligation<'tcx>, trait_predicate: ty::PolyTraitPredicate<'tcx>, pre_message: String, - file: &mut Option, + long_ty_path: &mut Option, ) -> String { if let ObligationCauseCode::MainFunctionType = obligation.cause.code() { "consider using `()`, or a `Result`".to_owned() @@ -5387,7 +5387,7 @@ pub(super) fn get_explanation_based_on_obligation<'tcx>( format!( "{pre_message}the trait `{}` is not implemented for{desc} `{}`", trait_predicate.print_modifiers_and_trait_path(), - tcx.short_string(trait_predicate.self_ty().skip_binder(), file), + tcx.short_string(trait_predicate.self_ty().skip_binder(), long_ty_path), ) } else { // "the trait bound `T: !Send` is not satisfied" reads better than "`!Send` is From 4942e38bcdfc5e40a94eb2e46e3edd912b9567bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 28 Jul 2025 02:37:21 +0000 Subject: [PATCH 10/13] remove unnecessary code --- .../rustc_hir_typeck/src/method/suggest.rs | 42 ++----------------- .../rustc_confusables_std_cases.stderr | 2 +- 2 files changed, 4 insertions(+), 40 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index fd1771ebb5e25..0b78b08af5338 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -407,11 +407,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { &self, self_source: SelfSource<'tcx>, method_name: Ident, - unsatisfied_predicates: &[( - ty::Predicate<'tcx>, - Option>, - Option>, - )], ty: Ty<'tcx>, err: &mut Diag<'_>, ) { @@ -487,7 +482,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } // If the shadowed binding has an itializer expression, - // use the initializer expression'ty to try to find the method again. + // use the initializer expression's ty to try to find the method again. // For example like: `let mut x = Vec::new();`, // `Vec::new()` is the itializer expression. if let Some(self_ty) = self.fcx.node_ty_opt(binding.init_hir_id) @@ -576,34 +571,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { span.push_span_label(sugg_let.span, format!("`{rcvr_name}` of type `{self_ty}` that has method `{method_name}` defined earlier here")); - // Don't show generic arguments when the method can't be found in any implementation (#81576). - let mut ty_str = None; - if let ty::Adt(_, generics) = ty.kind() { - if generics.len() > 0 { - let mut autoderef = self.autoderef(DUMMY_SP, ty).silence_errors(); - let candidate_found = autoderef.any(|(ty, _)| { - if let ty::Adt(adt_def, _) = ty.kind() { - self.tcx.inherent_impls(adt_def.did()).into_iter().any( - |def_id| { - self.associated_value(*def_id, method_name).is_some() - }, - ) - } else { - false - } - }); - let has_deref = autoderef.step_count() > 0; - if !candidate_found && !has_deref && unsatisfied_predicates.is_empty() { - let t = with_forced_trimmed_paths!(ty.to_string()); - if let Some((path_string, _)) = t.split_once('<') { - ty_str = Some(path_string.to_string()); - } - } - } - } - - let ty = - ty_str.unwrap_or_else(|| self.tcx.short_string(ty, err.long_ty_path())); + let ty = self.tcx.short_string(ty, err.long_ty_path()); span.push_span_label( self.tcx.hir_span(recv_id), format!("earlier `{rcvr_name}` shadowed here with type `{ty}`"), @@ -720,11 +688,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if is_method { self.suggest_use_shadowed_binding_with_method( - source, - item_ident, - &unsatisfied_predicates, - rcvr_ty, - &mut err, + source, item_ident, rcvr_ty, &mut err, ); } diff --git a/tests/ui/attributes/rustc_confusables_std_cases.stderr b/tests/ui/attributes/rustc_confusables_std_cases.stderr index 5655c8bba55fe..771c0c6dfe98e 100644 --- a/tests/ui/attributes/rustc_confusables_std_cases.stderr +++ b/tests/ui/attributes/rustc_confusables_std_cases.stderr @@ -35,7 +35,7 @@ LL | let mut x = Vec::new(); | ^^^^^ `x` of type `Vec<_>` that has method `push` defined earlier here ... LL | let mut x = VecDeque::new(); - | ----- earlier `x` shadowed here with type `VecDeque` + | ----- earlier `x` shadowed here with type `VecDeque<_>` help: you might have meant to use `push_back` | LL | x.push_back(1); From e1128f883cbbb528173d95513001eae63b85d642 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 28 Jul 2025 19:02:40 +0000 Subject: [PATCH 11/13] Remove redundant code and rename bindings for consistency --- compiler/rustc_errors/src/diagnostic.rs | 5 ++ compiler/rustc_trait_selection/messages.ftl | 2 - .../error_reporting/infer/need_type_info.rs | 32 ++++------- .../src/error_reporting/traits/ambiguity.rs | 57 ++++++++++--------- compiler/rustc_trait_selection/src/errors.rs | 11 ---- ...inding-without-sufficient-type-info.stderr | 3 +- 6 files changed, 48 insertions(+), 62 deletions(-) diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index 96c7ba6ed27b9..5a5563c7bb2c8 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -1382,6 +1382,11 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> { &mut self.long_ty_path } + pub fn with_long_ty_path(mut self, long_ty_path: Option) -> Self { + self.long_ty_path = long_ty_path; + self + } + /// Most `emit_producing_guarantee` functions use this as a starting point. fn emit_producing_nothing(mut self) { let diag = self.take_diag(); diff --git a/compiler/rustc_trait_selection/messages.ftl b/compiler/rustc_trait_selection/messages.ftl index 8232da4df43ec..fcb250250871e 100644 --- a/compiler/rustc_trait_selection/messages.ftl +++ b/compiler/rustc_trait_selection/messages.ftl @@ -171,8 +171,6 @@ trait_selection_fps_remove_ref = consider removing the reference trait_selection_fps_use_ref = consider using a reference trait_selection_fulfill_req_lifetime = the type `{$ty}` does not fulfill the required lifetime -trait_selection_full_type_written = the full type name has been written to '{$path}' - trait_selection_ignored_diagnostic_option = `{$option_name}` is ignored due to previous definition of `{$option_name}` .other_label = `{$option_name}` is first declared here .label = `{$option_name}` is already declared here diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs index 022d549a9df80..4287f0f7b2aa8 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs @@ -436,8 +436,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { infer_subdiags, multi_suggestions, bad_label, - was_written: false, - path: Default::default(), }), TypeAnnotationNeeded::E0283 => self.dcx().create_err(AmbiguousImpl { span, @@ -447,8 +445,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { infer_subdiags, multi_suggestions, bad_label, - was_written: false, - path: Default::default(), }), TypeAnnotationNeeded::E0284 => self.dcx().create_err(AmbiguousReturn { span, @@ -458,8 +454,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { infer_subdiags, multi_suggestions, bad_label, - was_written: false, - path: Default::default(), }), } } @@ -496,7 +490,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { return self.bad_inference_failure_err(failure_span, arg_data, error_code); }; - let (source_kind, name, path) = kind.ty_localized_msg(self); + let (source_kind, name, long_ty_path) = kind.ty_localized_msg(self); let failure_span = if should_label_span && !failure_span.overlaps(span) { Some(failure_span) } else { @@ -629,7 +623,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { } } } - match error_code { + let mut err = match error_code { TypeAnnotationNeeded::E0282 => self.dcx().create_err(AnnotationRequired { span, source_kind, @@ -638,8 +632,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { infer_subdiags, multi_suggestions, bad_label: None, - was_written: path.is_some(), - path: path.unwrap_or_default(), }), TypeAnnotationNeeded::E0283 => self.dcx().create_err(AmbiguousImpl { span, @@ -649,8 +641,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { infer_subdiags, multi_suggestions, bad_label: None, - was_written: path.is_some(), - path: path.unwrap_or_default(), }), TypeAnnotationNeeded::E0284 => self.dcx().create_err(AmbiguousReturn { span, @@ -660,10 +650,10 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { infer_subdiags, multi_suggestions, bad_label: None, - was_written: path.is_some(), - path: path.unwrap_or_default(), }), - } + }; + *err.long_ty_path() = long_ty_path; + err } } @@ -727,22 +717,24 @@ impl<'tcx> InferSource<'tcx> { impl<'tcx> InferSourceKind<'tcx> { fn ty_localized_msg(&self, infcx: &InferCtxt<'tcx>) -> (&'static str, String, Option) { - let mut path = None; + let mut long_ty_path = None; match *self { InferSourceKind::LetBinding { ty, .. } | InferSourceKind::ClosureArg { ty, .. } | InferSourceKind::ClosureReturn { ty, .. } => { if ty.is_closure() { - ("closure", closure_as_fn_str(infcx, ty), path) + ("closure", closure_as_fn_str(infcx, ty), long_ty_path) } else if !ty.is_ty_or_numeric_infer() { - ("normal", infcx.tcx.short_string(ty, &mut path), path) + ("normal", infcx.tcx.short_string(ty, &mut long_ty_path), long_ty_path) } else { - ("other", String::new(), path) + ("other", String::new(), long_ty_path) } } // FIXME: We should be able to add some additional info here. InferSourceKind::GenericArg { .. } - | InferSourceKind::FullyQualifiedMethodCall { .. } => ("other", String::new(), path), + | InferSourceKind::FullyQualifiedMethodCall { .. } => { + ("other", String::new(), long_ty_path) + } } } } diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/ambiguity.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/ambiguity.rs index cdf1402252aa0..af912227ce4e4 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/ambiguity.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/ambiguity.rs @@ -169,7 +169,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { let predicate = self.resolve_vars_if_possible(obligation.predicate); let span = obligation.cause.span; - let mut file = None; + let mut long_ty_path = None; debug!(?predicate, obligation.cause.code = ?obligation.cause.code()); @@ -211,19 +211,18 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { self.tcx.as_lang_item(trait_pred.def_id()), Some(LangItem::Sized | LangItem::MetaSized) ) { - match self.tainted_by_errors() { - None => { - let err = self.emit_inference_failure_err( + return match self.tainted_by_errors() { + None => self + .emit_inference_failure_err( obligation.cause.body_id, span, trait_pred.self_ty().skip_binder().into(), TypeAnnotationNeeded::E0282, false, - ); - return err.emit(); - } - Some(e) => return e, - } + ) + .emit(), + Some(e) => e, + }; } // Typically, this ambiguity should only happen if @@ -260,8 +259,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { span, E0283, "type annotations needed: cannot satisfy `{}`", - self.tcx.short_string(predicate, &mut file), + self.tcx.short_string(predicate, &mut long_ty_path), ) + .with_long_ty_path(long_ty_path) }; let mut ambiguities = compute_applicable_impls_for_diagnostics( @@ -307,7 +307,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { err.cancel(); return e; } - let pred = self.tcx.short_string(predicate, &mut file); + let pred = self.tcx.short_string(predicate, &mut err.long_ty_path()); err.note(format!("cannot satisfy `{pred}`")); let impl_candidates = self.find_similar_impl_candidates(predicate.as_trait_clause().unwrap()); @@ -512,6 +512,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { true, ) } + ty::PredicateKind::Clause(ty::ClauseKind::Projection(data)) => { if let Err(e) = predicate.error_reported() { return e; @@ -536,7 +537,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { .filter_map(ty::GenericArg::as_term) .chain([data.term]) .find(|g| g.has_non_region_infer()); - let predicate = self.tcx.short_string(predicate, &mut file); + let predicate = self.tcx.short_string(predicate, &mut long_ty_path); if let Some(term) = term { self.emit_inference_failure_err( obligation.cause.body_id, @@ -546,6 +547,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { true, ) .with_note(format!("cannot satisfy `{predicate}`")) + .with_long_ty_path(long_ty_path) } else { // If we can't find a generic parameter, just print a generic error struct_span_code_err!( @@ -555,6 +557,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { "type annotations needed: cannot satisfy `{predicate}`", ) .with_span_label(span, format!("cannot satisfy `{predicate}`")) + .with_long_ty_path(long_ty_path) } } @@ -568,17 +571,16 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { let term = data.walk().filter_map(ty::GenericArg::as_term).find(|term| term.is_infer()); if let Some(term) = term { - let err = self.emit_inference_failure_err( + self.emit_inference_failure_err( obligation.cause.body_id, span, term, TypeAnnotationNeeded::E0284, true, - ); - err + ) } else { // If we can't find a generic parameter, just print a generic error - let predicate = self.tcx.short_string(predicate, &mut file); + let predicate = self.tcx.short_string(predicate, &mut long_ty_path); struct_span_code_err!( self.dcx(), span, @@ -586,6 +588,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { "type annotations needed: cannot satisfy `{predicate}`", ) .with_span_label(span, format!("cannot satisfy `{predicate}`")) + .with_long_ty_path(long_ty_path) } } @@ -597,13 +600,14 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { TypeAnnotationNeeded::E0284, true, ), + ty::PredicateKind::NormalizesTo(ty::NormalizesTo { alias, term }) if term.is_infer() => { if let Some(e) = self.tainted_by_errors() { return e; } - let alias = self.tcx.short_string(alias, &mut file); + let alias = self.tcx.short_string(alias, &mut long_ty_path); struct_span_code_err!( self.dcx(), span, @@ -611,37 +615,34 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { "type annotations needed: cannot normalize `{alias}`", ) .with_span_label(span, format!("cannot normalize `{alias}`")) + .with_long_ty_path(long_ty_path) } + ty::PredicateKind::Clause(ty::ClauseKind::UnstableFeature(sym)) => { if let Some(e) = self.tainted_by_errors() { return e; } - let mut err; - if self.tcx.features().staged_api() { - err = self.dcx().struct_span_err( + self.dcx().struct_span_err( span, format!("unstable feature `{sym}` is used without being enabled."), - ); - - err.help(format!("The feature can be enabled by marking the current item with `#[unstable_feature_bound({sym})]`")); + ).with_help(format!("The feature can be enabled by marking the current item with `#[unstable_feature_bound({sym})]`")) } else { - err = feature_err_unstable_feature_bound( + feature_err_unstable_feature_bound( &self.tcx.sess, sym, span, format!("use of unstable library feature `{sym}`"), - ); + ) } - err } _ => { if let Some(e) = self.tainted_by_errors() { return e; } - let predicate = self.tcx.short_string(predicate, &mut file); + let predicate = self.tcx.short_string(predicate, &mut long_ty_path); struct_span_code_err!( self.dcx(), span, @@ -649,9 +650,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { "type annotations needed: cannot satisfy `{predicate}`", ) .with_span_label(span, format!("cannot satisfy `{predicate}`")) + .with_long_ty_path(long_ty_path) } }; - *err.long_ty_path() = file; self.note_obligation_cause(&mut err, obligation); err.emit() } diff --git a/compiler/rustc_trait_selection/src/errors.rs b/compiler/rustc_trait_selection/src/errors.rs index 7901d52dffb61..af241099c0149 100644 --- a/compiler/rustc_trait_selection/src/errors.rs +++ b/compiler/rustc_trait_selection/src/errors.rs @@ -1,5 +1,3 @@ -use std::path::PathBuf; - use rustc_ast::Path; use rustc_data_structures::fx::{FxHashSet, FxIndexSet}; use rustc_errors::codes::*; @@ -224,9 +222,6 @@ pub struct AnnotationRequired<'a> { pub infer_subdiags: Vec>, #[subdiagnostic] pub multi_suggestions: Vec>, - #[note(trait_selection_full_type_written)] - pub was_written: bool, - pub path: PathBuf, } // Copy of `AnnotationRequired` for E0283 @@ -245,9 +240,6 @@ pub struct AmbiguousImpl<'a> { pub infer_subdiags: Vec>, #[subdiagnostic] pub multi_suggestions: Vec>, - #[note(trait_selection_full_type_written)] - pub was_written: bool, - pub path: PathBuf, } // Copy of `AnnotationRequired` for E0284 @@ -266,9 +258,6 @@ pub struct AmbiguousReturn<'a> { pub infer_subdiags: Vec>, #[subdiagnostic] pub multi_suggestions: Vec>, - #[note(trait_selection_full_type_written)] - pub was_written: bool, - pub path: PathBuf, } // Used when a better one isn't available diff --git a/tests/ui/inference/really-long-type-in-let-binding-without-sufficient-type-info.stderr b/tests/ui/inference/really-long-type-in-let-binding-without-sufficient-type-info.stderr index fc05d9b94d9e5..5c4a1a7582931 100644 --- a/tests/ui/inference/really-long-type-in-let-binding-without-sufficient-type-info.stderr +++ b/tests/ui/inference/really-long-type-in-let-binding-without-sufficient-type-info.stderr @@ -4,7 +4,8 @@ error[E0282]: type annotations needed for `Result<_, (((..., ..., ..., ...), ... LL | let y = Err(x); | ^ ------ type must be known at this point | - = note: the full type name has been written to '$TEST_BUILD_DIR/really-long-type-in-let-binding-without-sufficient-type-info.long-type-$LONG_TYPE_HASH.txt' + = note: the full name for the type has been written to '$TEST_BUILD_DIR/really-long-type-in-let-binding-without-sufficient-type-info.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console help: consider giving `y` an explicit type, where the type for type parameter `T` is specified | LL | let y: Result = Err(x); From 017dc154c6fb94c923f37e733a5e2c7140600206 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 29 Jul 2025 01:13:50 +0000 Subject: [PATCH 12/13] Add support for shortening `Instance` and use it Replace ad-hoc type path shortening logic for recursive mono instantiation errors to use `tcx.short_string()` instead. --- compiler/rustc_middle/messages.ftl | 4 +- compiler/rustc_middle/src/error.rs | 11 ++- compiler/rustc_middle/src/ty/diagnostics.rs | 11 ++- compiler/rustc_middle/src/ty/instance.rs | 24 +------ compiler/rustc_middle/src/ty/mod.rs | 2 +- compiler/rustc_middle/src/ty/print/mod.rs | 69 ++++++++++--------- compiler/rustc_monomorphize/messages.ftl | 9 +-- compiler/rustc_monomorphize/src/collector.rs | 46 ++++++------- compiler/rustc_monomorphize/src/errors.rs | 23 ++++--- .../post-mono-higher-ranked-hang-2.stderr | 2 +- .../post-mono-higher-ranked-hang.stderr | 2 +- .../index-out-of-bounds-never-type.stderr | 2 +- .../const-eval/issue-50814-2.normal.stderr | 2 +- tests/ui/consts/const-eval/issue-50814.stderr | 2 +- tests/ui/consts/const-eval/issue-85155.stderr | 2 +- .../mono-reachable-invalid-const.stderr | 2 +- .../collect-in-called-fn.noopt.stderr | 2 +- .../collect-in-called-fn.opt.stderr | 2 +- .../collect-in-dead-closure.noopt.stderr | 2 +- .../collect-in-dead-closure.opt.stderr | 2 +- .../collect-in-dead-drop.noopt.stderr | 2 +- .../collect-in-dead-drop.opt.stderr | 2 +- ...-in-dead-fn-behind-assoc-type.noopt.stderr | 2 +- ...ct-in-dead-fn-behind-assoc-type.opt.stderr | 2 +- ...ect-in-dead-fn-behind-generic.noopt.stderr | 2 +- ...llect-in-dead-fn-behind-generic.opt.stderr | 2 +- ...in-dead-fn-behind-opaque-type.noopt.stderr | 2 +- ...t-in-dead-fn-behind-opaque-type.opt.stderr | 2 +- .../collect-in-dead-fn.noopt.stderr | 2 +- .../collect-in-dead-fn.opt.stderr | 2 +- ...ollect-in-dead-fnptr-in-const.noopt.stderr | 2 +- .../collect-in-dead-fnptr-in-const.opt.stderr | 2 +- .../collect-in-dead-fnptr.noopt.stderr | 2 +- .../collect-in-dead-fnptr.opt.stderr | 2 +- .../collect-in-dead-move.noopt.stderr | 2 +- .../collect-in-dead-move.opt.stderr | 2 +- .../collect-in-dead-vtable.noopt.stderr | 2 +- .../collect-in-dead-vtable.opt.stderr | 2 +- .../collect-in-promoted-const.noopt.stderr | 2 +- .../collect-in-promoted-const.opt.stderr | 2 +- .../post_monomorphization_error_backtrace.rs | 4 +- ...st_monomorphization_error_backtrace.stderr | 4 +- ...te-instantiation-struct-tail-ice-114484.rs | 3 +- ...nstantiation-struct-tail-ice-114484.stderr | 28 +++++--- tests/ui/infinite/infinite-instantiation.rs | 3 +- .../ui/infinite/infinite-instantiation.stderr | 9 +-- .../const-expr-generic-err.stderr | 4 +- tests/ui/issues/issue-22638.stderr | 2 +- .../issue-37311.rs | 1 + .../issue-37311.stderr | 9 +-- tests/ui/issues/issue-8727.rs | 3 +- tests/ui/issues/issue-8727.stderr | 11 +-- tests/ui/layout/post-mono-layout-cycle.stderr | 2 +- .../limits/type-length-limit-enforcement.rs | 2 +- .../type-length-limit-enforcement.stderr | 5 +- tests/ui/recursion/recursion.rs | 2 +- tests/ui/recursion/recursion.stderr | 5 +- ...ursive-impl-trait-iterator-by-ref-67552.rs | 2 +- ...ve-impl-trait-iterator-by-ref-67552.stderr | 5 +- .../ui/simd/const-err-trumps-simd-err.stderr | 2 +- .../post-mono.indirect.stderr | 2 +- 61 files changed, 191 insertions(+), 178 deletions(-) diff --git a/compiler/rustc_middle/messages.ftl b/compiler/rustc_middle/messages.ftl index 69aa4383f135a..69adb2fe3919f 100644 --- a/compiler/rustc_middle/messages.ftl +++ b/compiler/rustc_middle/messages.ftl @@ -122,8 +122,6 @@ middle_strict_coherence_needs_negative_coherence = to use `strict_coherence` on this trait, the `with_negative_coherence` feature must be enabled .label = due to this attribute -middle_type_length_limit = reached the type-length limit while instantiating `{$shrunk}` +middle_type_length_limit = reached the type-length limit while instantiating `{$instance}` middle_unsupported_union = we don't support unions yet: '{$ty_name}' - -middle_written_to_path = the full type name has been written to '{$path}' diff --git a/compiler/rustc_middle/src/error.rs b/compiler/rustc_middle/src/error.rs index f36ae83165319..7520bc262c6bc 100644 --- a/compiler/rustc_middle/src/error.rs +++ b/compiler/rustc_middle/src/error.rs @@ -1,4 +1,4 @@ -use std::path::{Path, PathBuf}; +use std::path::Path; use std::{fmt, io}; use rustc_errors::codes::*; @@ -6,7 +6,7 @@ use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage}; use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_span::{Span, Symbol}; -use crate::ty::Ty; +use crate::ty::{Instance, Ty}; #[derive(Diagnostic)] #[diag(middle_drop_check_overflow, code = E0320)] @@ -161,13 +161,10 @@ pub(crate) struct ErroneousConstant { #[derive(Diagnostic)] #[diag(middle_type_length_limit)] #[help(middle_consider_type_length_limit)] -pub(crate) struct TypeLengthLimit { +pub(crate) struct TypeLengthLimit<'tcx> { #[primary_span] pub span: Span, - pub shrunk: String, - #[note(middle_written_to_path)] - pub was_written: bool, - pub path: PathBuf, + pub instance: Instance<'tcx>, pub type_length: usize, } diff --git a/compiler/rustc_middle/src/ty/diagnostics.rs b/compiler/rustc_middle/src/ty/diagnostics.rs index b122ada0925d6..6dcda44798e95 100644 --- a/compiler/rustc_middle/src/ty/diagnostics.rs +++ b/compiler/rustc_middle/src/ty/diagnostics.rs @@ -14,7 +14,7 @@ use rustc_span::{BytePos, Span}; use rustc_type_ir::TyKind::*; use crate::ty::{ - self, AliasTy, Const, ConstKind, FallibleTypeFolder, InferConst, InferTy, Opaque, + self, AliasTy, Const, ConstKind, FallibleTypeFolder, InferConst, InferTy, Instance, Opaque, PolyTraitPredicate, Projection, Ty, TyCtxt, TypeFoldable, TypeSuperFoldable, TypeSuperVisitable, TypeVisitable, TypeVisitor, }; @@ -28,6 +28,15 @@ impl IntoDiagArg for Ty<'_> { } } +impl IntoDiagArg for Instance<'_> { + fn into_diag_arg(self, path: &mut Option) -> rustc_errors::DiagArgValue { + ty::tls::with(|tcx| { + let instance = tcx.short_string(self, path); + rustc_errors::DiagArgValue::Str(std::borrow::Cow::Owned(instance)) + }) + } +} + into_diag_arg_using_display! { ty::Region<'_>, } diff --git a/compiler/rustc_middle/src/ty/instance.rs b/compiler/rustc_middle/src/ty/instance.rs index d5767ca3786e8..7b99cd3a8ea29 100644 --- a/compiler/rustc_middle/src/ty/instance.rs +++ b/compiler/rustc_middle/src/ty/instance.rs @@ -1,6 +1,5 @@ use std::assert_matches::assert_matches; use std::fmt; -use std::path::PathBuf; use rustc_data_structures::fx::FxHashMap; use rustc_errors::ErrorGuaranteed; @@ -17,7 +16,7 @@ use tracing::{debug, instrument}; use crate::error; use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags; use crate::ty::normalize_erasing_regions::NormalizationError; -use crate::ty::print::{FmtPrinter, Printer, shrunk_instance_name}; +use crate::ty::print::{FmtPrinter, Printer}; use crate::ty::{ self, EarlyBinder, GenericArgs, GenericArgsRef, Ty, TyCtxt, TypeFoldable, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor, @@ -431,14 +430,6 @@ pub fn fmt_instance( } } -pub struct ShortInstance<'tcx>(pub Instance<'tcx>, pub usize); - -impl<'tcx> fmt::Display for ShortInstance<'tcx> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt_instance(f, self.0, Some(rustc_session::Limit(self.1))) - } -} - impl<'tcx> fmt::Display for Instance<'tcx> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt_instance(f, *self, None) @@ -610,23 +601,12 @@ impl<'tcx> Instance<'tcx> { Ok(None) => { let type_length = type_length(args); if !tcx.type_length_limit().value_within_limit(type_length) { - let (shrunk, written_to_path) = - shrunk_instance_name(tcx, Instance::new_raw(def_id, args)); - let mut path = PathBuf::new(); - let was_written = if let Some(path2) = written_to_path { - path = path2; - true - } else { - false - }; tcx.dcx().emit_fatal(error::TypeLengthLimit { // We don't use `def_span(def_id)` so that diagnostics point // to the crate root during mono instead of to foreign items. // This is arguably better. span: span_or_local_def_span(), - shrunk, - was_written, - path, + instance: Instance::new_raw(def_id, args), type_length, }); } else { diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index bb70c61cd1417..de1bd28e28a29 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -82,7 +82,7 @@ pub use self::context::{ TyCtxtFeed, tls, }; pub use self::fold::*; -pub use self::instance::{Instance, InstanceKind, ReifyReason, ShortInstance, UnusedGenericParams}; +pub use self::instance::{Instance, InstanceKind, ReifyReason, UnusedGenericParams}; pub use self::list::{List, ListWithCachedTypeInfo}; pub use self::opaque_types::OpaqueTypeKey; pub use self::parameterized::ParameterizedOverTcx; diff --git a/compiler/rustc_middle/src/ty/print/mod.rs b/compiler/rustc_middle/src/ty/print/mod.rs index 9172c5d3ab752..bb822d28311b3 100644 --- a/compiler/rustc_middle/src/ty/print/mod.rs +++ b/compiler/rustc_middle/src/ty/print/mod.rs @@ -1,5 +1,3 @@ -use std::path::PathBuf; - use hir::def::Namespace; use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::sso::SsoHashSet; @@ -8,7 +6,7 @@ use rustc_hir::def_id::{CrateNum, DefId, LocalDefId}; use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData}; use tracing::{debug, instrument, trace}; -use crate::ty::{self, GenericArg, ShortInstance, Ty, TyCtxt}; +use crate::ty::{self, GenericArg, Ty, TyCtxt}; // `pretty` is a separate module only for organization. mod pretty; @@ -323,6 +321,43 @@ impl<'tcx, P: Printer<'tcx>> Print<'tcx, P> for Ty<'tcx> { } } +impl<'tcx, P: Printer<'tcx> + std::fmt::Write> Print<'tcx, P> for ty::Instance<'tcx> { + fn print(&self, cx: &mut P) -> Result<(), PrintError> { + cx.print_def_path(self.def_id(), self.args)?; + match self.def { + ty::InstanceKind::Item(_) => {} + ty::InstanceKind::VTableShim(_) => cx.write_str(" - shim(vtable)")?, + ty::InstanceKind::ReifyShim(_, None) => cx.write_str(" - shim(reify)")?, + ty::InstanceKind::ReifyShim(_, Some(ty::ReifyReason::FnPtr)) => { + cx.write_str(" - shim(reify-fnptr)")? + } + ty::InstanceKind::ReifyShim(_, Some(ty::ReifyReason::Vtable)) => { + cx.write_str(" - shim(reify-vtable)")? + } + ty::InstanceKind::ThreadLocalShim(_) => cx.write_str(" - shim(tls)")?, + ty::InstanceKind::Intrinsic(_) => cx.write_str(" - intrinsic")?, + ty::InstanceKind::Virtual(_, num) => cx.write_str(&format!(" - virtual#{num}"))?, + ty::InstanceKind::FnPtrShim(_, ty) => cx.write_str(&format!(" - shim({ty})"))?, + ty::InstanceKind::ClosureOnceShim { .. } => cx.write_str(" - shim")?, + ty::InstanceKind::ConstructCoroutineInClosureShim { .. } => cx.write_str(" - shim")?, + ty::InstanceKind::DropGlue(_, None) => cx.write_str(" - shim(None)")?, + ty::InstanceKind::DropGlue(_, Some(ty)) => { + cx.write_str(&format!(" - shim(Some({ty}))"))? + } + ty::InstanceKind::CloneShim(_, ty) => cx.write_str(&format!(" - shim({ty})"))?, + ty::InstanceKind::FnPtrAddrShim(_, ty) => cx.write_str(&format!(" - shim({ty})"))?, + ty::InstanceKind::FutureDropPollShim(_, proxy_ty, impl_ty) => { + cx.write_str(&format!(" - dropshim({proxy_ty}-{impl_ty})"))? + } + ty::InstanceKind::AsyncDropGlue(_, ty) => cx.write_str(&format!(" - shim({ty})"))?, + ty::InstanceKind::AsyncDropGlueCtorShim(_, ty) => { + cx.write_str(&format!(" - shim(Some({ty}))"))? + } + }; + Ok(()) + } +} + impl<'tcx, P: Printer<'tcx>> Print<'tcx, P> for &'tcx ty::List> { fn print(&self, cx: &mut P) -> Result<(), PrintError> { cx.print_dyn_existential(self) @@ -362,31 +397,3 @@ where with_no_trimmed_paths!(Self::print(t, fmt)) } } - -/// Format instance name that is already known to be too long for rustc. -/// Show only the first 2 types if it is longer than 32 characters to avoid blasting -/// the user's terminal with thousands of lines of type-name. -/// -/// If the type name is longer than before+after, it will be written to a file. -pub fn shrunk_instance_name<'tcx>( - tcx: TyCtxt<'tcx>, - instance: ty::Instance<'tcx>, -) -> (String, Option) { - let s = instance.to_string(); - - // Only use the shrunk version if it's really shorter. - // This also avoids the case where before and after slices overlap. - if s.chars().nth(33).is_some() { - let shrunk = format!("{}", ShortInstance(instance, 4)); - if shrunk == s { - return (s, None); - } - - let path = tcx.output_filenames(()).temp_path_for_diagnostic("long-type.txt"); - let written_to_path = std::fs::write(&path, s).ok().map(|_| path); - - (shrunk, written_to_path) - } else { - (s, None) - } -} diff --git a/compiler/rustc_monomorphize/messages.ftl b/compiler/rustc_monomorphize/messages.ftl index 2bd19e81b01c2..9595a5b5ac7fb 100644 --- a/compiler/rustc_monomorphize/messages.ftl +++ b/compiler/rustc_monomorphize/messages.ftl @@ -40,7 +40,10 @@ monomorphize_couldnt_dump_mono_stats = unexpected error occurred while dumping monomorphization stats: {$error} monomorphize_encountered_error_while_instantiating = - the above error was encountered while instantiating `{$formatted_item}` + the above error was encountered while instantiating `{$kind} {$instance}` + +monomorphize_encountered_error_while_instantiating_global_asm = + the above error was encountered while instantiating `global_asm` monomorphize_large_assignments = moving {$size} bytes @@ -52,12 +55,10 @@ monomorphize_no_optimized_mir = .note = missing optimized MIR for this item (was the crate `{$crate_name}` compiled with `--emit=metadata`?) monomorphize_recursion_limit = - reached the recursion limit while instantiating `{$shrunk}` + reached the recursion limit while instantiating `{$instance}` .note = `{$def_path_str}` defined here monomorphize_start_not_found = using `fn main` requires the standard library .help = use `#![no_main]` to bypass the Rust generated entrypoint and declare a platform specific entrypoint yourself, usually with `#[no_mangle]` monomorphize_symbol_already_defined = symbol `{$symbol}` is already defined - -monomorphize_written_to_path = the full type name has been written to '{$path}' diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index 1bfd83d97ac42..af9b09f67bc15 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -206,7 +206,6 @@ //! regardless of whether it is actually needed or not. use std::cell::OnceCell; -use std::path::PathBuf; use rustc_attr_data_structures::InlineAttr; use rustc_data_structures::fx::FxIndexMap; @@ -224,7 +223,6 @@ use rustc_middle::mir::{self, Location, MentionedItem, traversal}; use rustc_middle::query::TyCtxtAt; use rustc_middle::ty::adjustment::{CustomCoerceUnsized, PointerCoercion}; use rustc_middle::ty::layout::ValidityRequirement; -use rustc_middle::ty::print::{shrunk_instance_name, with_no_trimmed_paths}; use rustc_middle::ty::{ self, GenericArgs, GenericParamDefKind, Instance, InstanceKind, Ty, TyCtxt, TypeFoldable, TypeVisitableExt, VtblEntry, @@ -237,7 +235,10 @@ use rustc_span::source_map::{Spanned, dummy_spanned, respan}; use rustc_span::{DUMMY_SP, Span}; use tracing::{debug, instrument, trace}; -use crate::errors::{self, EncounteredErrorWhileInstantiating, NoOptimizedMir, RecursionLimit}; +use crate::errors::{ + self, EncounteredErrorWhileInstantiating, EncounteredErrorWhileInstantiatingGlobalAsm, + NoOptimizedMir, RecursionLimit, +}; #[derive(PartialEq)] pub(crate) enum MonoItemCollectionStrategy { @@ -525,11 +526,23 @@ fn collect_items_rec<'tcx>( && starting_item.node.is_generic_fn() && starting_item.node.is_user_defined() { - let formatted_item = with_no_trimmed_paths!(starting_item.node.to_string()); - tcx.dcx().emit_note(EncounteredErrorWhileInstantiating { - span: starting_item.span, - formatted_item, - }); + match starting_item.node { + MonoItem::Fn(instance) => tcx.dcx().emit_note(EncounteredErrorWhileInstantiating { + span: starting_item.span, + kind: "fn", + instance, + }), + MonoItem::Static(def_id) => tcx.dcx().emit_note(EncounteredErrorWhileInstantiating { + span: starting_item.span, + kind: "static", + instance: Instance::new_raw(def_id, GenericArgs::empty()), + }), + MonoItem::GlobalAsm(_) => { + tcx.dcx().emit_note(EncounteredErrorWhileInstantiatingGlobalAsm { + span: starting_item.span, + }) + } + } } // Only updating `usage_map` for used items as otherwise we may be inserting the same item // multiple times (if it is first 'mentioned' and then later actually used), and the usage map @@ -612,22 +625,7 @@ fn check_recursion_limit<'tcx>( if !recursion_limit.value_within_limit(adjusted_recursion_depth) { let def_span = tcx.def_span(def_id); let def_path_str = tcx.def_path_str(def_id); - let (shrunk, written_to_path) = shrunk_instance_name(tcx, instance); - let mut path = PathBuf::new(); - let was_written = if let Some(written_to_path) = written_to_path { - path = written_to_path; - true - } else { - false - }; - tcx.dcx().emit_fatal(RecursionLimit { - span, - shrunk, - def_span, - def_path_str, - was_written, - path, - }); + tcx.dcx().emit_fatal(RecursionLimit { span, instance, def_span, def_path_str }); } recursion_depths.insert(def_id, recursion_depth + 1); diff --git a/compiler/rustc_monomorphize/src/errors.rs b/compiler/rustc_monomorphize/src/errors.rs index 938c427b56c8f..89a78897dea91 100644 --- a/compiler/rustc_monomorphize/src/errors.rs +++ b/compiler/rustc_monomorphize/src/errors.rs @@ -1,21 +1,16 @@ -use std::path::PathBuf; - use rustc_macros::{Diagnostic, LintDiagnostic}; -use rustc_middle::ty::Ty; +use rustc_middle::ty::{Instance, Ty}; use rustc_span::{Span, Symbol}; #[derive(Diagnostic)] #[diag(monomorphize_recursion_limit)] -pub(crate) struct RecursionLimit { +pub(crate) struct RecursionLimit<'tcx> { #[primary_span] pub span: Span, - pub shrunk: String, + pub instance: Instance<'tcx>, #[note] pub def_span: Span, pub def_path_str: String, - #[note(monomorphize_written_to_path)] - pub was_written: bool, - pub path: PathBuf, } #[derive(Diagnostic)] @@ -53,10 +48,18 @@ pub(crate) struct CouldntDumpMonoStats { #[derive(Diagnostic)] #[diag(monomorphize_encountered_error_while_instantiating)] -pub(crate) struct EncounteredErrorWhileInstantiating { +pub(crate) struct EncounteredErrorWhileInstantiating<'tcx> { + #[primary_span] + pub span: Span, + pub kind: &'static str, + pub instance: Instance<'tcx>, +} + +#[derive(Diagnostic)] +#[diag(monomorphize_encountered_error_while_instantiating_global_asm)] +pub(crate) struct EncounteredErrorWhileInstantiatingGlobalAsm { #[primary_span] pub span: Span, - pub formatted_item: String, } #[derive(Diagnostic)] diff --git a/tests/ui/async-await/async-closures/post-mono-higher-ranked-hang-2.stderr b/tests/ui/async-await/async-closures/post-mono-higher-ranked-hang-2.stderr index 64f4665225ffe..64d80a692e7cd 100644 --- a/tests/ui/async-await/async-closures/post-mono-higher-ranked-hang-2.stderr +++ b/tests/ui/async-await/async-closures/post-mono-higher-ranked-hang-2.stderr @@ -1,4 +1,4 @@ -error: reached the recursion limit while instantiating `recur::<{async closure@$DIR/post-mono-higher-ranked-hang-2.rs:13:24: 13:32}>` +error: reached the recursion limit while instantiating `recur<{async closure@$DIR/post-mono-higher-ranked-hang-2.rs:13:24: 13:32}>` --> $DIR/post-mono-higher-ranked-hang-2.rs:13:17 | LL | let _ = recur(&async || { diff --git a/tests/ui/async-await/async-closures/post-mono-higher-ranked-hang.stderr b/tests/ui/async-await/async-closures/post-mono-higher-ranked-hang.stderr index 486e5f9416550..efb061f054fb3 100644 --- a/tests/ui/async-await/async-closures/post-mono-higher-ranked-hang.stderr +++ b/tests/ui/async-await/async-closures/post-mono-higher-ranked-hang.stderr @@ -1,4 +1,4 @@ -error: reached the recursion limit while instantiating `ToChain::<'_, '_>::perm_pairs::<{async closure@$DIR/post-mono-higher-ranked-hang.rs:43:45: 43:67}>` +error: reached the recursion limit while instantiating `ToChain<'_, '_>::perm_pairs<{async closure@$DIR/post-mono-higher-ranked-hang.rs:43:45: 43:67}>` --> $DIR/post-mono-higher-ranked-hang.rs:43:21 | LL | / self.perm_pairs(l, &mut async move |left_pair| { diff --git a/tests/ui/consts/const-eval/index-out-of-bounds-never-type.stderr b/tests/ui/consts/const-eval/index-out-of-bounds-never-type.stderr index 7e57e16aa4f03..f408f48ffb094 100644 --- a/tests/ui/consts/const-eval/index-out-of-bounds-never-type.stderr +++ b/tests/ui/consts/const-eval/index-out-of-bounds-never-type.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = PrintName::::VOID; | ^^^^^^^^^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn f::<()>` +note: the above error was encountered while instantiating `fn f<()>` --> $DIR/index-out-of-bounds-never-type.rs:20:5 | LL | f::<()>(); diff --git a/tests/ui/consts/const-eval/issue-50814-2.normal.stderr b/tests/ui/consts/const-eval/issue-50814-2.normal.stderr index 749c9dde1ce19..d24b7014b8949 100644 --- a/tests/ui/consts/const-eval/issue-50814-2.normal.stderr +++ b/tests/ui/consts/const-eval/issue-50814-2.normal.stderr @@ -24,7 +24,7 @@ LL | & as Foo>::BAR | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -note: the above error was encountered while instantiating `fn foo::<()>` +note: the above error was encountered while instantiating `fn foo<()>` --> $DIR/issue-50814-2.rs:33:22 | LL | println!("{:x}", foo::<()>() as *const usize as usize); diff --git a/tests/ui/consts/const-eval/issue-50814.stderr b/tests/ui/consts/const-eval/issue-50814.stderr index 1287c83ae0ff8..c22c4e73ff63c 100644 --- a/tests/ui/consts/const-eval/issue-50814.stderr +++ b/tests/ui/consts/const-eval/issue-50814.stderr @@ -40,7 +40,7 @@ LL | &Sum::::MAX | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -note: the above error was encountered while instantiating `fn foo::` +note: the above error was encountered while instantiating `fn foo` --> $DIR/issue-50814.rs:27:5 | LL | foo(0); diff --git a/tests/ui/consts/const-eval/issue-85155.stderr b/tests/ui/consts/const-eval/issue-85155.stderr index f7777bfac0206..91149aa505f21 100644 --- a/tests/ui/consts/const-eval/issue-85155.stderr +++ b/tests/ui/consts/const-eval/issue-85155.stderr @@ -12,7 +12,7 @@ LL | static_assert_imm1!(IMM1); | = note: this note originates in the macro `static_assert_imm1` (in Nightly builds, run with -Z macro-backtrace for more info) -note: the above error was encountered while instantiating `fn post_monomorphization_error::stdarch_intrinsic::<2>` +note: the above error was encountered while instantiating `fn stdarch_intrinsic<2>` --> $DIR/issue-85155.rs:19:5 | LL | post_monomorphization_error::stdarch_intrinsic::<2>(); diff --git a/tests/ui/consts/mono-reachable-invalid-const.stderr b/tests/ui/consts/mono-reachable-invalid-const.stderr index e357fd096fdfa..c80b24f8b96bc 100644 --- a/tests/ui/consts/mono-reachable-invalid-const.stderr +++ b/tests/ui/consts/mono-reachable-invalid-const.stderr @@ -18,7 +18,7 @@ LL | let val = Self::ASSERT; | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -note: the above error was encountered while instantiating `fn Bar::<0>::assert` +note: the above error was encountered while instantiating `fn Bar<0>::assert` --> $DIR/mono-reachable-invalid-const.rs:21:5 | LL | Bar::<0>::assert(); diff --git a/tests/ui/consts/required-consts/collect-in-called-fn.noopt.stderr b/tests/ui/consts/required-consts/collect-in-called-fn.noopt.stderr index 7d7bbbc5e36c7..bb87252108cd6 100644 --- a/tests/ui/consts/required-consts/collect-in-called-fn.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-called-fn.noopt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn called::` +note: the above error was encountered while instantiating `fn called` --> $DIR/collect-in-called-fn.rs:24:5 | LL | called::(); diff --git a/tests/ui/consts/required-consts/collect-in-called-fn.opt.stderr b/tests/ui/consts/required-consts/collect-in-called-fn.opt.stderr index 7d7bbbc5e36c7..bb87252108cd6 100644 --- a/tests/ui/consts/required-consts/collect-in-called-fn.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-called-fn.opt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn called::` +note: the above error was encountered while instantiating `fn called` --> $DIR/collect-in-called-fn.rs:24:5 | LL | called::(); diff --git a/tests/ui/consts/required-consts/collect-in-dead-closure.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-closure.noopt.stderr index 239e9cb147238..c3f46eb5acde7 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-closure.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-closure.noopt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn not_called::` +note: the above error was encountered while instantiating `fn not_called` --> $DIR/collect-in-dead-closure.rs:24:33 | LL | let _closure: fn() = || not_called::(); diff --git a/tests/ui/consts/required-consts/collect-in-dead-closure.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-closure.opt.stderr index 239e9cb147238..c3f46eb5acde7 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-closure.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-closure.opt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn not_called::` +note: the above error was encountered while instantiating `fn not_called` --> $DIR/collect-in-dead-closure.rs:24:33 | LL | let _closure: fn() = || not_called::(); diff --git a/tests/ui/consts/required-consts/collect-in-dead-drop.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-drop.noopt.stderr index 7c6219ccf9344..38e169c97016d 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-drop.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-drop.noopt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn as std::ops::Drop>::drop` +note: the above error was encountered while instantiating `fn as Drop>::drop` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL error: aborting due to 1 previous error diff --git a/tests/ui/consts/required-consts/collect-in-dead-drop.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-drop.opt.stderr index 7c6219ccf9344..38e169c97016d 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-drop.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-drop.opt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn as std::ops::Drop>::drop` +note: the above error was encountered while instantiating `fn as Drop>::drop` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL error: aborting due to 1 previous error diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.noopt.stderr index e1a82fd52310b..75c74dcf06a6c 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.noopt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn not_called::` +note: the above error was encountered while instantiating `fn not_called` --> $SRC_DIR/core/src/ops/function.rs:LL:COL error: aborting due to 1 previous error diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.opt.stderr index e1a82fd52310b..75c74dcf06a6c 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.opt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn not_called::` +note: the above error was encountered while instantiating `fn not_called` --> $SRC_DIR/core/src/ops/function.rs:LL:COL error: aborting due to 1 previous error diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.noopt.stderr index 1d2af342a4435..950bac2fe9282 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.noopt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn not_called::` +note: the above error was encountered while instantiating `fn not_called` --> $SRC_DIR/core/src/ops/function.rs:LL:COL error: aborting due to 1 previous error diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.opt.stderr index 1d2af342a4435..950bac2fe9282 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.opt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn not_called::` +note: the above error was encountered while instantiating `fn not_called` --> $SRC_DIR/core/src/ops/function.rs:LL:COL error: aborting due to 1 previous error diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.noopt.stderr index a480a8c5a3996..1d23c6b90cbdb 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.noopt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn m::not_called::` +note: the above error was encountered while instantiating `fn not_called` --> $SRC_DIR/core/src/ops/function.rs:LL:COL error: aborting due to 1 previous error diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.opt.stderr index a480a8c5a3996..1d23c6b90cbdb 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.opt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn m::not_called::` +note: the above error was encountered while instantiating `fn not_called` --> $SRC_DIR/core/src/ops/function.rs:LL:COL error: aborting due to 1 previous error diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn.noopt.stderr index f253a7cbbee38..94112a47b270c 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn.noopt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn not_called::` +note: the above error was encountered while instantiating `fn not_called` --> $DIR/collect-in-dead-fn.rs:26:9 | LL | not_called::(); diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn.opt.stderr index f253a7cbbee38..94112a47b270c 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn.opt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn not_called::` +note: the above error was encountered while instantiating `fn not_called` --> $DIR/collect-in-dead-fn.rs:26:9 | LL | not_called::(); diff --git a/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.noopt.stderr index b962630ca016c..e4182379398d1 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.noopt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | const FNPTR: fn() = || Self::FAIL; | ^^^^^^^^^^ -note: the above error was encountered while instantiating `fn Late::::FNPTR::{closure#0}` +note: the above error was encountered while instantiating `fn Late::FNPTR::{closure#0}` --> $SRC_DIR/core/src/ops/function.rs:LL:COL error: aborting due to 1 previous error diff --git a/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.opt.stderr index b962630ca016c..e4182379398d1 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.opt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | const FNPTR: fn() = || Self::FAIL; | ^^^^^^^^^^ -note: the above error was encountered while instantiating `fn Late::::FNPTR::{closure#0}` +note: the above error was encountered while instantiating `fn Late::FNPTR::{closure#0}` --> $SRC_DIR/core/src/ops/function.rs:LL:COL error: aborting due to 1 previous error diff --git a/tests/ui/consts/required-consts/collect-in-dead-fnptr.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fnptr.noopt.stderr index 29e6711153c9e..365d4eb274c99 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fnptr.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fnptr.noopt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn not_called::` +note: the above error was encountered while instantiating `fn not_called` --> $DIR/collect-in-dead-fnptr.rs:27:28 | LL | let _fnptr: fn() = not_called::; diff --git a/tests/ui/consts/required-consts/collect-in-dead-fnptr.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fnptr.opt.stderr index 29e6711153c9e..365d4eb274c99 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fnptr.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fnptr.opt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn not_called::` +note: the above error was encountered while instantiating `fn not_called` --> $DIR/collect-in-dead-fnptr.rs:27:28 | LL | let _fnptr: fn() = not_called::; diff --git a/tests/ui/consts/required-consts/collect-in-dead-move.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-move.noopt.stderr index 6c8edc00260dd..9f652e26f242f 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-move.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-move.noopt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn as std::ops::Drop>::drop` +note: the above error was encountered while instantiating `fn as Drop>::drop` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL error: aborting due to 1 previous error diff --git a/tests/ui/consts/required-consts/collect-in-dead-move.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-move.opt.stderr index 6c8edc00260dd..9f652e26f242f 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-move.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-move.opt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn as std::ops::Drop>::drop` +note: the above error was encountered while instantiating `fn as Drop>::drop` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL error: aborting due to 1 previous error diff --git a/tests/ui/consts/required-consts/collect-in-dead-vtable.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-vtable.noopt.stderr index 4e35beadbf484..0c12c0de19747 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-vtable.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-vtable.noopt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn as MyTrait>::not_called` +note: the above error was encountered while instantiating `fn as MyTrait>::not_called` --> $DIR/collect-in-dead-vtable.rs:31:40 | LL | let gen_vtable: &dyn MyTrait = &v; // vtable is "mentioned" here diff --git a/tests/ui/consts/required-consts/collect-in-dead-vtable.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-vtable.opt.stderr index 4e35beadbf484..0c12c0de19747 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-vtable.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-vtable.opt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn as MyTrait>::not_called` +note: the above error was encountered while instantiating `fn as MyTrait>::not_called` --> $DIR/collect-in-dead-vtable.rs:31:40 | LL | let gen_vtable: &dyn MyTrait = &v; // vtable is "mentioned" here diff --git a/tests/ui/consts/required-consts/collect-in-promoted-const.noopt.stderr b/tests/ui/consts/required-consts/collect-in-promoted-const.noopt.stderr index 67f5009c4ffcf..eb1ae14a38d9b 100644 --- a/tests/ui/consts/required-consts/collect-in-promoted-const.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-promoted-const.noopt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _val = &Fail::::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn f::` +note: the above error was encountered while instantiating `fn f` --> $DIR/collect-in-promoted-const.rs:25:5 | LL | f::(); diff --git a/tests/ui/consts/required-consts/collect-in-promoted-const.opt.stderr b/tests/ui/consts/required-consts/collect-in-promoted-const.opt.stderr index 5c3edf68d95f7..d8ae1460569d3 100644 --- a/tests/ui/consts/required-consts/collect-in-promoted-const.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-promoted-const.opt.stderr @@ -24,7 +24,7 @@ LL | let _val = &Fail::::C; | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -note: the above error was encountered while instantiating `fn f::` +note: the above error was encountered while instantiating `fn f` --> $DIR/collect-in-promoted-const.rs:25:5 | LL | f::(); diff --git a/tests/ui/generics/post_monomorphization_error_backtrace.rs b/tests/ui/generics/post_monomorphization_error_backtrace.rs index 9f53751584b1e..5ff2eca756d5c 100644 --- a/tests/ui/generics/post_monomorphization_error_backtrace.rs +++ b/tests/ui/generics/post_monomorphization_error_backtrace.rs @@ -19,8 +19,8 @@ fn assert_zst() { fn foo() { assert_zst::() - //~^ NOTE: the above error was encountered while instantiating `fn assert_zst::` - //~| NOTE: the above error was encountered while instantiating `fn assert_zst::` + //~^ NOTE: the above error was encountered while instantiating `fn assert_zst` + //~| NOTE: the above error was encountered while instantiating `fn assert_zst` } fn bar() { diff --git a/tests/ui/generics/post_monomorphization_error_backtrace.stderr b/tests/ui/generics/post_monomorphization_error_backtrace.stderr index 6953414f0c235..fad0858698634 100644 --- a/tests/ui/generics/post_monomorphization_error_backtrace.stderr +++ b/tests/ui/generics/post_monomorphization_error_backtrace.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | F::::V; | ^^^^^^^^^ -note: the above error was encountered while instantiating `fn assert_zst::` +note: the above error was encountered while instantiating `fn assert_zst` --> $DIR/post_monomorphization_error_backtrace.rs:21:5 | LL | assert_zst::() @@ -30,7 +30,7 @@ LL | F::::V; | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -note: the above error was encountered while instantiating `fn assert_zst::` +note: the above error was encountered while instantiating `fn assert_zst` --> $DIR/post_monomorphization_error_backtrace.rs:21:5 | LL | assert_zst::() diff --git a/tests/ui/infinite/infinite-instantiation-struct-tail-ice-114484.rs b/tests/ui/infinite/infinite-instantiation-struct-tail-ice-114484.rs index f50c4a5207a5f..f7117368ece7b 100644 --- a/tests/ui/infinite/infinite-instantiation-struct-tail-ice-114484.rs +++ b/tests/ui/infinite/infinite-instantiation-struct-tail-ice-114484.rs @@ -1,5 +1,6 @@ -//~ ERROR reached the recursion limit while instantiating ` as Pointee>::Metadata` as a rigid projection after reaching the recursion diff --git a/tests/ui/infinite/infinite-instantiation-struct-tail-ice-114484.stderr b/tests/ui/infinite/infinite-instantiation-struct-tail-ice-114484.stderr index 59addc5cc4a7d..fb2ff6f7327fb 100644 --- a/tests/ui/infinite/infinite-instantiation-struct-tail-ice-114484.stderr +++ b/tests/ui/infinite/infinite-instantiation-struct-tail-ice-114484.stderr @@ -17,11 +17,14 @@ error: reached the recursion limit finding the struct tail for `[u8; 256]` = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -note: the above error was encountered while instantiating `fn virtualize_my_trait::, 0>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>>` - --> $DIR/infinite-instantiation-struct-tail-ice-114484.rs:24:18 +note: the above error was encountered while instantiating `fn virtualize_my_trait>` + --> $DIR/infinite-instantiation-struct-tail-ice-114484.rs:25:18 | LL | unsafe { virtualize_my_trait(L, self) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the full name for the type has been written to '$TEST_BUILD_DIR/infinite-instantiation-struct-tail-ice-114484.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error: reached the recursion limit finding the struct tail for `SomeData<256>` | @@ -42,11 +45,14 @@ error: reached the recursion limit finding the struct tail for `SomeData<256>` = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -note: the above error was encountered while instantiating `fn virtualize_my_trait::, 0>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>>` - --> $DIR/infinite-instantiation-struct-tail-ice-114484.rs:24:18 +note: the above error was encountered while instantiating `fn virtualize_my_trait>` + --> $DIR/infinite-instantiation-struct-tail-ice-114484.rs:25:18 | LL | unsafe { virtualize_my_trait(L, self) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the full name for the type has been written to '$TEST_BUILD_DIR/infinite-instantiation-struct-tail-ice-114484.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error: reached the recursion limit finding the struct tail for `VirtualWrapper, 0>` | @@ -67,20 +73,24 @@ error: reached the recursion limit finding the struct tail for `VirtualWrapper, 0>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>, 1>>` - --> $DIR/infinite-instantiation-struct-tail-ice-114484.rs:24:18 +note: the above error was encountered while instantiating `fn virtualize_my_trait>` + --> $DIR/infinite-instantiation-struct-tail-ice-114484.rs:25:18 | LL | unsafe { virtualize_my_trait(L, self) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the full name for the type has been written to '$TEST_BUILD_DIR/infinite-instantiation-struct-tail-ice-114484.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console -error: reached the recursion limit while instantiating `, 1>, 1>, 1>, 1> as MyTrait>::virtualize` +error: reached the recursion limit while instantiating ` as MyTrait>::virtualize` | note: ` as MyTrait>::virtualize` defined here - --> $DIR/infinite-instantiation-struct-tail-ice-114484.rs:23:5 + --> $DIR/infinite-instantiation-struct-tail-ice-114484.rs:24:5 | LL | fn virtualize(&self) -> &dyn MyTrait { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: the full type name has been written to '$TEST_BUILD_DIR/infinite-instantiation-struct-tail-ice-114484.long-type.txt' + = note: the full name for the type has been written to '$TEST_BUILD_DIR/infinite-instantiation-struct-tail-ice-114484.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error: aborting due to 13 previous errors diff --git a/tests/ui/infinite/infinite-instantiation.rs b/tests/ui/infinite/infinite-instantiation.rs index 7898cc1ffc106..83cd8c55210d5 100644 --- a/tests/ui/infinite/infinite-instantiation.rs +++ b/tests/ui/infinite/infinite-instantiation.rs @@ -1,4 +1,5 @@ //@ build-fail +//@ compile-flags: --diagnostic-width=100 -Zwrite-long-types-to-disk=yes trait ToOpt: Sized { fn to_option(&self) -> Option; @@ -19,7 +20,7 @@ impl ToOpt for Option { fn function(counter: usize, t: T) { if counter > 0 { function(counter - 1, t.to_option()); - //~^ ERROR reached the recursion limit while instantiating `function::>>>>>` - --> $DIR/infinite-instantiation.rs:21:9 +error: reached the recursion limit while instantiating `function>>>>` + --> $DIR/infinite-instantiation.rs:22:9 | LL | function(counter - 1, t.to_option()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `function` defined here - --> $DIR/infinite-instantiation.rs:19:1 + --> $DIR/infinite-instantiation.rs:20:1 | LL | fn function(counter: usize, t: T) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: the full type name has been written to '$TEST_BUILD_DIR/infinite-instantiation.long-type.txt' + = note: the full name for the type has been written to '$TEST_BUILD_DIR/infinite-instantiation.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error: aborting due to 1 previous error diff --git a/tests/ui/inline-const/const-expr-generic-err.stderr b/tests/ui/inline-const/const-expr-generic-err.stderr index 26039ba6d4449..f01b1b4c955ee 100644 --- a/tests/ui/inline-const/const-expr-generic-err.stderr +++ b/tests/ui/inline-const/const-expr-generic-err.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | const { assert!(std::mem::size_of::() == 0); } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn foo::` +note: the above error was encountered while instantiating `fn foo` --> $DIR/const-expr-generic-err.rs:12:5 | LL | foo::(); @@ -36,7 +36,7 @@ LL | const { N - 1 } | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -note: the above error was encountered while instantiating `fn bar::<0>` +note: the above error was encountered while instantiating `fn bar<0>` --> $DIR/const-expr-generic-err.rs:13:5 | LL | bar::<0>(); diff --git a/tests/ui/issues/issue-22638.stderr b/tests/ui/issues/issue-22638.stderr index 96f1794486838..084281c456fa5 100644 --- a/tests/ui/issues/issue-22638.stderr +++ b/tests/ui/issues/issue-22638.stderr @@ -1,4 +1,4 @@ -error: reached the recursion limit while instantiating `A::matches::<{closure@$DIR/issue-22638.rs:42:23: 42:25}>` +error: reached the recursion limit while instantiating `A::matches<{closure@$DIR/issue-22638.rs:42:23: 42:25}>` --> $DIR/issue-22638.rs:54:9 | LL | a.matches(f) diff --git a/tests/ui/issues/issue-37311-type-length-limit/issue-37311.rs b/tests/ui/issues/issue-37311-type-length-limit/issue-37311.rs index 05adde4520442..b978e6eb51919 100644 --- a/tests/ui/issues/issue-37311-type-length-limit/issue-37311.rs +++ b/tests/ui/issues/issue-37311-type-length-limit/issue-37311.rs @@ -1,4 +1,5 @@ //@ build-fail +//@ compile-flags: --diagnostic-width=100 -Zwrite-long-types-to-disk=yes trait Mirror { type Image; diff --git a/tests/ui/issues/issue-37311-type-length-limit/issue-37311.stderr b/tests/ui/issues/issue-37311-type-length-limit/issue-37311.stderr index 945fa605e140c..835f1c6442a78 100644 --- a/tests/ui/issues/issue-37311-type-length-limit/issue-37311.stderr +++ b/tests/ui/issues/issue-37311-type-length-limit/issue-37311.stderr @@ -1,15 +1,16 @@ -error: reached the recursion limit while instantiating `<(&(&(..., ...), ...), ...) as Foo>::recurse` - --> $DIR/issue-37311.rs:16:9 +error: reached the recursion limit while instantiating `<(&(&(&..., ...), ...), ...) as Foo>::recurse` + --> $DIR/issue-37311.rs:17:9 | LL | (self, self).recurse(); | ^^^^^^^^^^^^^^^^^^^^^^ | note: `::recurse` defined here - --> $DIR/issue-37311.rs:15:5 + --> $DIR/issue-37311.rs:16:5 | LL | fn recurse(&self) { | ^^^^^^^^^^^^^^^^^ - = note: the full type name has been written to '$TEST_BUILD_DIR/issue-37311.long-type.txt' + = note: the full name for the type has been written to '$TEST_BUILD_DIR/issue-37311.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error: aborting due to 1 previous error diff --git a/tests/ui/issues/issue-8727.rs b/tests/ui/issues/issue-8727.rs index 1883287f1407c..39b7de532a2fc 100644 --- a/tests/ui/issues/issue-8727.rs +++ b/tests/ui/issues/issue-8727.rs @@ -2,11 +2,12 @@ // recursions. //@ build-fail +//@ compile-flags: --diagnostic-width=100 -Zwrite-long-types-to-disk=yes fn generic() { //~ WARN function cannot return without recursing generic::>(); } -//~^^ ERROR reached the recursion limit while instantiating `generic:: $DIR/issue-8727.rs:6:1 + --> $DIR/issue-8727.rs:7:1 | LL | fn generic() { | ^^^^^^^^^^^^^^^ cannot return without recursing @@ -9,18 +9,19 @@ LL | generic::>(); = help: a `loop` may express intention better if this is on purpose = note: `#[warn(unconditional_recursion)]` on by default -error: reached the recursion limit while instantiating `generic::>>>>>` - --> $DIR/issue-8727.rs:7:5 +error: reached the recursion limit while instantiating `generic>>>>` + --> $DIR/issue-8727.rs:8:5 | LL | generic::>(); | ^^^^^^^^^^^^^^^^^^^^^^ | note: `generic` defined here - --> $DIR/issue-8727.rs:6:1 + --> $DIR/issue-8727.rs:7:1 | LL | fn generic() { | ^^^^^^^^^^^^^^^ - = note: the full type name has been written to '$TEST_BUILD_DIR/issue-8727.long-type.txt' + = note: the full name for the type has been written to '$TEST_BUILD_DIR/issue-8727.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error: aborting due to 1 previous error; 1 warning emitted diff --git a/tests/ui/layout/post-mono-layout-cycle.stderr b/tests/ui/layout/post-mono-layout-cycle.stderr index 7f246b3d409ad..4369703c2ca19 100644 --- a/tests/ui/layout/post-mono-layout-cycle.stderr +++ b/tests/ui/layout/post-mono-layout-cycle.stderr @@ -5,7 +5,7 @@ error[E0391]: cycle detected when computing layout of `Wrapper<()>` = note: cycle used when computing layout of `core::option::Option>` = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information -note: the above error was encountered while instantiating `fn abi::<()>` +note: the above error was encountered while instantiating `fn abi<()>` --> $DIR/post-mono-layout-cycle.rs:19:5 | LL | abi::(None); diff --git a/tests/ui/limits/type-length-limit-enforcement.rs b/tests/ui/limits/type-length-limit-enforcement.rs index 3b34d6eb5c855..604435dc326b2 100644 --- a/tests/ui/limits/type-length-limit-enforcement.rs +++ b/tests/ui/limits/type-length-limit-enforcement.rs @@ -3,7 +3,7 @@ //! Checks the enforcement of the type-length limit //! and its configurability via `#![type_length_limit]`. -//@ compile-flags: -Copt-level=0 -Zenforce-type-length-limit +//@ compile-flags: -Copt-level=0 -Zenforce-type-length-limit --diagnostic-width=100 -Zwrite-long-types-to-disk=yes //@ build-fail diff --git a/tests/ui/limits/type-length-limit-enforcement.stderr b/tests/ui/limits/type-length-limit-enforcement.stderr index 516230ae832dc..da2931246ef4b 100644 --- a/tests/ui/limits/type-length-limit-enforcement.stderr +++ b/tests/ui/limits/type-length-limit-enforcement.stderr @@ -1,11 +1,12 @@ -error: reached the type-length limit while instantiating `std::mem::drop::>` +error: reached the type-length limit while instantiating `drop>` --> $DIR/type-length-limit-enforcement.rs:34:5 | LL | drop::>(None); | ^^^^^^^^^^^^^^^^^^^^^^^ | = help: consider adding a `#![type_length_limit="4010"]` attribute to your crate - = note: the full type name has been written to '$TEST_BUILD_DIR/type-length-limit-enforcement.long-type.txt' + = 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@rt::lang_start<()>::{closure#0}} as FnMut<()>>::call_mut` | diff --git a/tests/ui/recursion/recursion.rs b/tests/ui/recursion/recursion.rs index 5cd4012a9d2d9..ae927b1b4c601 100644 --- a/tests/ui/recursion/recursion.rs +++ b/tests/ui/recursion/recursion.rs @@ -1,5 +1,5 @@ //@ build-fail -//@ compile-flags:-C overflow-checks=off +//@ compile-flags:-C overflow-checks=off --diagnostic-width=100 -Zwrite-long-types-to-disk=yes enum Nil {NilValue} struct Cons {head:isize, tail:T} diff --git a/tests/ui/recursion/recursion.stderr b/tests/ui/recursion/recursion.stderr index f959805defc64..92bf7b77ee330 100644 --- a/tests/ui/recursion/recursion.stderr +++ b/tests/ui/recursion/recursion.stderr @@ -1,4 +1,4 @@ -error: reached the recursion limit while instantiating `test::>>>>>` +error: reached the recursion limit while instantiating `test>>>>>>` --> $DIR/recursion.rs:17:11 | LL | _ => {test (n-1, i+1, Cons {head:2*i+1, tail:first}, Cons{head:i*i, tail:second})} @@ -9,7 +9,8 @@ note: `test` defined here | LL | fn test (n:isize, i:isize, first:T, second:T) ->isize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: the full type name has been written to '$TEST_BUILD_DIR/recursion.long-type.txt' + = note: the full name for the type has been written to '$TEST_BUILD_DIR/recursion.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error: aborting due to 1 previous error diff --git a/tests/ui/recursion/recursive-impl-trait-iterator-by-ref-67552.rs b/tests/ui/recursion/recursive-impl-trait-iterator-by-ref-67552.rs index 0875d385ddcb5..4abca9164239f 100644 --- a/tests/ui/recursion/recursive-impl-trait-iterator-by-ref-67552.rs +++ b/tests/ui/recursion/recursive-impl-trait-iterator-by-ref-67552.rs @@ -1,5 +1,5 @@ //@ build-fail -//@ compile-flags: -Copt-level=0 +//@ compile-flags: -Copt-level=0 --diagnostic-width=100 -Zwrite-long-types-to-disk=yes fn main() { rec(Empty); diff --git a/tests/ui/recursion/recursive-impl-trait-iterator-by-ref-67552.stderr b/tests/ui/recursion/recursive-impl-trait-iterator-by-ref-67552.stderr index fe005984fab24..48029e0d62917 100644 --- a/tests/ui/recursion/recursive-impl-trait-iterator-by-ref-67552.stderr +++ b/tests/ui/recursion/recursive-impl-trait-iterator-by-ref-67552.stderr @@ -1,4 +1,4 @@ -error: reached the recursion limit while instantiating `rec::<&mut &mut &mut &mut &mut ...>` +error: reached the recursion limit while instantiating `rec<&mut &mut &mut &mut &mut &mut &mut &mut ...>` --> $DIR/recursive-impl-trait-iterator-by-ref-67552.rs:28:9 | LL | rec(identity(&mut it)) @@ -11,7 +11,8 @@ LL | / fn rec(mut it: T) LL | | where LL | | T: Iterator, | |________________^ - = note: the full type name has been written to '$TEST_BUILD_DIR/recursive-impl-trait-iterator-by-ref-67552.long-type.txt' + = note: the full name for the type has been written to '$TEST_BUILD_DIR/recursive-impl-trait-iterator-by-ref-67552.long-type-$LONG_TYPE_HASH.txt' + = note: consider using `--verbose` to print the full type name to the console error: aborting due to 1 previous error diff --git a/tests/ui/simd/const-err-trumps-simd-err.stderr b/tests/ui/simd/const-err-trumps-simd-err.stderr index 93d1fce637f2f..d5ba686ccdaff 100644 --- a/tests/ui/simd/const-err-trumps-simd-err.stderr +++ b/tests/ui/simd/const-err-trumps-simd-err.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | const { assert!(LANE < 4); } // the error should be here... | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn get_elem::<4>` +note: the above error was encountered while instantiating `fn get_elem<4>` --> $DIR/const-err-trumps-simd-err.rs:23:5 | LL | get_elem::<4>(int8x4_t([0, 0, 0, 0])); diff --git a/tests/ui/structs/default-field-values/post-mono.indirect.stderr b/tests/ui/structs/default-field-values/post-mono.indirect.stderr index c8af9c959c103..7f4fecb94595a 100644 --- a/tests/ui/structs/default-field-values/post-mono.indirect.stderr +++ b/tests/ui/structs/default-field-values/post-mono.indirect.stderr @@ -18,7 +18,7 @@ LL | let x: Z = Z { .. }; | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -note: the above error was encountered while instantiating `fn indirect::<1>` +note: the above error was encountered while instantiating `fn indirect<1>` --> $DIR/post-mono.rs:22:5 | LL | indirect::<1>(); From 5963f7aefec489327a6f549c1fc86e52a0154ace Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 29 Jul 2025 16:15:12 +0000 Subject: [PATCH 13/13] Revert rendering of short `ty::Instance` to use `Value` NS --- compiler/rustc_middle/src/ty/diagnostics.rs | 4 +-- compiler/rustc_middle/src/ty/error.rs | 34 +++++++++++++------ .../post-mono-higher-ranked-hang-2.stderr | 2 +- .../post-mono-higher-ranked-hang.stderr | 2 +- .../index-out-of-bounds-never-type.stderr | 2 +- .../const-eval/issue-50814-2.normal.stderr | 2 +- tests/ui/consts/const-eval/issue-50814.stderr | 2 +- tests/ui/consts/const-eval/issue-85155.stderr | 2 +- .../mono-reachable-invalid-const.stderr | 2 +- .../collect-in-called-fn.noopt.stderr | 2 +- .../collect-in-called-fn.opt.stderr | 2 +- .../collect-in-dead-closure.noopt.stderr | 2 +- .../collect-in-dead-closure.opt.stderr | 2 +- ...-in-dead-fn-behind-assoc-type.noopt.stderr | 2 +- ...ct-in-dead-fn-behind-assoc-type.opt.stderr | 2 +- ...ect-in-dead-fn-behind-generic.noopt.stderr | 2 +- ...llect-in-dead-fn-behind-generic.opt.stderr | 2 +- ...in-dead-fn-behind-opaque-type.noopt.stderr | 2 +- ...t-in-dead-fn-behind-opaque-type.opt.stderr | 2 +- .../collect-in-dead-fn.noopt.stderr | 2 +- .../collect-in-dead-fn.opt.stderr | 2 +- ...ollect-in-dead-fnptr-in-const.noopt.stderr | 2 +- .../collect-in-dead-fnptr-in-const.opt.stderr | 2 +- .../collect-in-dead-fnptr.noopt.stderr | 2 +- .../collect-in-dead-fnptr.opt.stderr | 2 +- .../collect-in-promoted-const.noopt.stderr | 2 +- .../collect-in-promoted-const.opt.stderr | 2 +- .../post_monomorphization_error_backtrace.rs | 4 +-- ...st_monomorphization_error_backtrace.stderr | 4 +-- ...nstantiation-struct-tail-ice-114484.stderr | 6 ++-- tests/ui/infinite/infinite-instantiation.rs | 2 +- .../ui/infinite/infinite-instantiation.stderr | 2 +- .../const-expr-generic-err.stderr | 4 +-- tests/ui/issues/issue-22638.stderr | 2 +- tests/ui/issues/issue-8727.rs | 2 +- tests/ui/issues/issue-8727.stderr | 2 +- tests/ui/layout/post-mono-layout-cycle.stderr | 2 +- .../type-length-limit-enforcement.stderr | 2 +- tests/ui/recursion/recursion.stderr | 2 +- ...ve-impl-trait-iterator-by-ref-67552.stderr | 2 +- .../ui/simd/const-err-trumps-simd-err.stderr | 2 +- .../post-mono.indirect.stderr | 2 +- 42 files changed, 70 insertions(+), 58 deletions(-) diff --git a/compiler/rustc_middle/src/ty/diagnostics.rs b/compiler/rustc_middle/src/ty/diagnostics.rs index 6dcda44798e95..b3042904a296d 100644 --- a/compiler/rustc_middle/src/ty/diagnostics.rs +++ b/compiler/rustc_middle/src/ty/diagnostics.rs @@ -7,7 +7,7 @@ use rustc_data_structures::fx::FxIndexMap; use rustc_errors::{ Applicability, Diag, DiagArgValue, IntoDiagArg, into_diag_arg_using_display, listify, pluralize, }; -use rustc_hir::def::DefKind; +use rustc_hir::def::{DefKind, Namespace}; use rustc_hir::def_id::DefId; use rustc_hir::{self as hir, AmbigArg, LangItem, PredicateOrigin, WherePredicateKind}; use rustc_span::{BytePos, Span}; @@ -31,7 +31,7 @@ impl IntoDiagArg for Ty<'_> { impl IntoDiagArg for Instance<'_> { fn into_diag_arg(self, path: &mut Option) -> rustc_errors::DiagArgValue { ty::tls::with(|tcx| { - let instance = tcx.short_string(self, path); + let instance = tcx.short_string_namespace(self, path, Namespace::ValueNS); rustc_errors::DiagArgValue::Str(std::borrow::Cow::Owned(instance)) }) } diff --git a/compiler/rustc_middle/src/ty/error.rs b/compiler/rustc_middle/src/ty/error.rs index 13723874ad3a1..70980c98f770a 100644 --- a/compiler/rustc_middle/src/ty/error.rs +++ b/compiler/rustc_middle/src/ty/error.rs @@ -160,7 +160,11 @@ impl<'tcx> Ty<'tcx> { _ => { let width = tcx.sess.diagnostic_width(); let length_limit = std::cmp::max(width / 4, 40); - format!("`{}`", tcx.string_with_limit(self, length_limit)).into() + format!( + "`{}`", + tcx.string_with_limit(self, length_limit, hir::def::Namespace::TypeNS) + ) + .into() } } } @@ -213,12 +217,12 @@ impl<'tcx> Ty<'tcx> { } impl<'tcx> TyCtxt<'tcx> { - pub fn string_with_limit(self, p: T, length_limit: usize) -> String + pub fn string_with_limit(self, p: T, length_limit: usize, ns: hir::def::Namespace) -> String where T: Copy + for<'a, 'b> Lift, Lifted: Print<'b, FmtPrinter<'a, 'b>>>, { let mut type_limit = 50; - let regular = FmtPrinter::print_string(self, hir::def::Namespace::TypeNS, |cx| { + let regular = FmtPrinter::print_string(self, ns, |cx| { self.lift(p).expect("could not lift for printing").print(cx) }) .expect("could not write to `String`"); @@ -229,11 +233,7 @@ impl<'tcx> TyCtxt<'tcx> { loop { // Look for the longest properly trimmed path that still fits in length_limit. short = with_forced_trimmed_paths!({ - let mut cx = FmtPrinter::new_with_limit( - self, - hir::def::Namespace::TypeNS, - rustc_session::Limit(type_limit), - ); + let mut cx = FmtPrinter::new_with_limit(self, ns, rustc_session::Limit(type_limit)); self.lift(p) .expect("could not lift for printing") .print(&mut cx) @@ -248,15 +248,27 @@ impl<'tcx> TyCtxt<'tcx> { short } + pub fn short_string(self, p: T, path: &mut Option) -> String + where + T: Copy + Hash + for<'a, 'b> Lift, Lifted: Print<'b, FmtPrinter<'a, 'b>>>, + { + self.short_string_namespace(p, path, hir::def::Namespace::TypeNS) + } + /// When calling this after a `Diag` is constructed, the preferred way of doing so is /// `tcx.short_string(ty, diag.long_ty_path())`. The diagnostic itself is the one that keeps /// the existence of a "long type" anywhere in the diagnostic, so the note telling the user /// where we wrote the file to is only printed once. - pub fn short_string(self, p: T, path: &mut Option) -> String + pub fn short_string_namespace( + self, + p: T, + path: &mut Option, + namespace: hir::def::Namespace, + ) -> String where T: Copy + Hash + for<'a, 'b> Lift, Lifted: Print<'b, FmtPrinter<'a, 'b>>>, { - let regular = FmtPrinter::print_string(self, hir::def::Namespace::TypeNS, |cx| { + let regular = FmtPrinter::print_string(self, namespace, |cx| { self.lift(p).expect("could not lift for printing").print(cx) }) .expect("could not write to `String`"); @@ -270,7 +282,7 @@ impl<'tcx> TyCtxt<'tcx> { if regular.len() <= width * 2 / 3 { return regular; } - let short = self.string_with_limit(p, length_limit); + let short = self.string_with_limit(p, length_limit, namespace); if regular == short { return regular; } diff --git a/tests/ui/async-await/async-closures/post-mono-higher-ranked-hang-2.stderr b/tests/ui/async-await/async-closures/post-mono-higher-ranked-hang-2.stderr index 64d80a692e7cd..64f4665225ffe 100644 --- a/tests/ui/async-await/async-closures/post-mono-higher-ranked-hang-2.stderr +++ b/tests/ui/async-await/async-closures/post-mono-higher-ranked-hang-2.stderr @@ -1,4 +1,4 @@ -error: reached the recursion limit while instantiating `recur<{async closure@$DIR/post-mono-higher-ranked-hang-2.rs:13:24: 13:32}>` +error: reached the recursion limit while instantiating `recur::<{async closure@$DIR/post-mono-higher-ranked-hang-2.rs:13:24: 13:32}>` --> $DIR/post-mono-higher-ranked-hang-2.rs:13:17 | LL | let _ = recur(&async || { diff --git a/tests/ui/async-await/async-closures/post-mono-higher-ranked-hang.stderr b/tests/ui/async-await/async-closures/post-mono-higher-ranked-hang.stderr index efb061f054fb3..486e5f9416550 100644 --- a/tests/ui/async-await/async-closures/post-mono-higher-ranked-hang.stderr +++ b/tests/ui/async-await/async-closures/post-mono-higher-ranked-hang.stderr @@ -1,4 +1,4 @@ -error: reached the recursion limit while instantiating `ToChain<'_, '_>::perm_pairs<{async closure@$DIR/post-mono-higher-ranked-hang.rs:43:45: 43:67}>` +error: reached the recursion limit while instantiating `ToChain::<'_, '_>::perm_pairs::<{async closure@$DIR/post-mono-higher-ranked-hang.rs:43:45: 43:67}>` --> $DIR/post-mono-higher-ranked-hang.rs:43:21 | LL | / self.perm_pairs(l, &mut async move |left_pair| { diff --git a/tests/ui/consts/const-eval/index-out-of-bounds-never-type.stderr b/tests/ui/consts/const-eval/index-out-of-bounds-never-type.stderr index f408f48ffb094..7e57e16aa4f03 100644 --- a/tests/ui/consts/const-eval/index-out-of-bounds-never-type.stderr +++ b/tests/ui/consts/const-eval/index-out-of-bounds-never-type.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = PrintName::::VOID; | ^^^^^^^^^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn f<()>` +note: the above error was encountered while instantiating `fn f::<()>` --> $DIR/index-out-of-bounds-never-type.rs:20:5 | LL | f::<()>(); diff --git a/tests/ui/consts/const-eval/issue-50814-2.normal.stderr b/tests/ui/consts/const-eval/issue-50814-2.normal.stderr index d24b7014b8949..749c9dde1ce19 100644 --- a/tests/ui/consts/const-eval/issue-50814-2.normal.stderr +++ b/tests/ui/consts/const-eval/issue-50814-2.normal.stderr @@ -24,7 +24,7 @@ LL | & as Foo>::BAR | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -note: the above error was encountered while instantiating `fn foo<()>` +note: the above error was encountered while instantiating `fn foo::<()>` --> $DIR/issue-50814-2.rs:33:22 | LL | println!("{:x}", foo::<()>() as *const usize as usize); diff --git a/tests/ui/consts/const-eval/issue-50814.stderr b/tests/ui/consts/const-eval/issue-50814.stderr index c22c4e73ff63c..1287c83ae0ff8 100644 --- a/tests/ui/consts/const-eval/issue-50814.stderr +++ b/tests/ui/consts/const-eval/issue-50814.stderr @@ -40,7 +40,7 @@ LL | &Sum::::MAX | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -note: the above error was encountered while instantiating `fn foo` +note: the above error was encountered while instantiating `fn foo::` --> $DIR/issue-50814.rs:27:5 | LL | foo(0); diff --git a/tests/ui/consts/const-eval/issue-85155.stderr b/tests/ui/consts/const-eval/issue-85155.stderr index 91149aa505f21..486d2adaf8cde 100644 --- a/tests/ui/consts/const-eval/issue-85155.stderr +++ b/tests/ui/consts/const-eval/issue-85155.stderr @@ -12,7 +12,7 @@ LL | static_assert_imm1!(IMM1); | = note: this note originates in the macro `static_assert_imm1` (in Nightly builds, run with -Z macro-backtrace for more info) -note: the above error was encountered while instantiating `fn stdarch_intrinsic<2>` +note: the above error was encountered while instantiating `fn stdarch_intrinsic::<2>` --> $DIR/issue-85155.rs:19:5 | LL | post_monomorphization_error::stdarch_intrinsic::<2>(); diff --git a/tests/ui/consts/mono-reachable-invalid-const.stderr b/tests/ui/consts/mono-reachable-invalid-const.stderr index c80b24f8b96bc..e357fd096fdfa 100644 --- a/tests/ui/consts/mono-reachable-invalid-const.stderr +++ b/tests/ui/consts/mono-reachable-invalid-const.stderr @@ -18,7 +18,7 @@ LL | let val = Self::ASSERT; | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -note: the above error was encountered while instantiating `fn Bar<0>::assert` +note: the above error was encountered while instantiating `fn Bar::<0>::assert` --> $DIR/mono-reachable-invalid-const.rs:21:5 | LL | Bar::<0>::assert(); diff --git a/tests/ui/consts/required-consts/collect-in-called-fn.noopt.stderr b/tests/ui/consts/required-consts/collect-in-called-fn.noopt.stderr index bb87252108cd6..7d7bbbc5e36c7 100644 --- a/tests/ui/consts/required-consts/collect-in-called-fn.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-called-fn.noopt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn called` +note: the above error was encountered while instantiating `fn called::` --> $DIR/collect-in-called-fn.rs:24:5 | LL | called::(); diff --git a/tests/ui/consts/required-consts/collect-in-called-fn.opt.stderr b/tests/ui/consts/required-consts/collect-in-called-fn.opt.stderr index bb87252108cd6..7d7bbbc5e36c7 100644 --- a/tests/ui/consts/required-consts/collect-in-called-fn.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-called-fn.opt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn called` +note: the above error was encountered while instantiating `fn called::` --> $DIR/collect-in-called-fn.rs:24:5 | LL | called::(); diff --git a/tests/ui/consts/required-consts/collect-in-dead-closure.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-closure.noopt.stderr index c3f46eb5acde7..239e9cb147238 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-closure.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-closure.noopt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn not_called` +note: the above error was encountered while instantiating `fn not_called::` --> $DIR/collect-in-dead-closure.rs:24:33 | LL | let _closure: fn() = || not_called::(); diff --git a/tests/ui/consts/required-consts/collect-in-dead-closure.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-closure.opt.stderr index c3f46eb5acde7..239e9cb147238 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-closure.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-closure.opt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn not_called` +note: the above error was encountered while instantiating `fn not_called::` --> $DIR/collect-in-dead-closure.rs:24:33 | LL | let _closure: fn() = || not_called::(); diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.noopt.stderr index 75c74dcf06a6c..e1a82fd52310b 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.noopt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn not_called` +note: the above error was encountered while instantiating `fn not_called::` --> $SRC_DIR/core/src/ops/function.rs:LL:COL error: aborting due to 1 previous error diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.opt.stderr index 75c74dcf06a6c..e1a82fd52310b 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.opt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn not_called` +note: the above error was encountered while instantiating `fn not_called::` --> $SRC_DIR/core/src/ops/function.rs:LL:COL error: aborting due to 1 previous error diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.noopt.stderr index 950bac2fe9282..1d2af342a4435 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.noopt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn not_called` +note: the above error was encountered while instantiating `fn not_called::` --> $SRC_DIR/core/src/ops/function.rs:LL:COL error: aborting due to 1 previous error diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.opt.stderr index 950bac2fe9282..1d2af342a4435 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.opt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn not_called` +note: the above error was encountered while instantiating `fn not_called::` --> $SRC_DIR/core/src/ops/function.rs:LL:COL error: aborting due to 1 previous error diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.noopt.stderr index 1d23c6b90cbdb..42a4ca2fd9d7c 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.noopt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn not_called` +note: the above error was encountered while instantiating `fn not_called::` --> $SRC_DIR/core/src/ops/function.rs:LL:COL error: aborting due to 1 previous error diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.opt.stderr index 1d23c6b90cbdb..42a4ca2fd9d7c 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.opt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn not_called` +note: the above error was encountered while instantiating `fn not_called::` --> $SRC_DIR/core/src/ops/function.rs:LL:COL error: aborting due to 1 previous error diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn.noopt.stderr index 94112a47b270c..f253a7cbbee38 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn.noopt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn not_called` +note: the above error was encountered while instantiating `fn not_called::` --> $DIR/collect-in-dead-fn.rs:26:9 | LL | not_called::(); diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn.opt.stderr index 94112a47b270c..f253a7cbbee38 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn.opt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn not_called` +note: the above error was encountered while instantiating `fn not_called::` --> $DIR/collect-in-dead-fn.rs:26:9 | LL | not_called::(); diff --git a/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.noopt.stderr index e4182379398d1..b962630ca016c 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.noopt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | const FNPTR: fn() = || Self::FAIL; | ^^^^^^^^^^ -note: the above error was encountered while instantiating `fn Late::FNPTR::{closure#0}` +note: the above error was encountered while instantiating `fn Late::::FNPTR::{closure#0}` --> $SRC_DIR/core/src/ops/function.rs:LL:COL error: aborting due to 1 previous error diff --git a/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.opt.stderr index e4182379398d1..b962630ca016c 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.opt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | const FNPTR: fn() = || Self::FAIL; | ^^^^^^^^^^ -note: the above error was encountered while instantiating `fn Late::FNPTR::{closure#0}` +note: the above error was encountered while instantiating `fn Late::::FNPTR::{closure#0}` --> $SRC_DIR/core/src/ops/function.rs:LL:COL error: aborting due to 1 previous error diff --git a/tests/ui/consts/required-consts/collect-in-dead-fnptr.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fnptr.noopt.stderr index 365d4eb274c99..29e6711153c9e 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fnptr.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fnptr.noopt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn not_called` +note: the above error was encountered while instantiating `fn not_called::` --> $DIR/collect-in-dead-fnptr.rs:27:28 | LL | let _fnptr: fn() = not_called::; diff --git a/tests/ui/consts/required-consts/collect-in-dead-fnptr.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fnptr.opt.stderr index 365d4eb274c99..29e6711153c9e 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fnptr.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fnptr.opt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _ = Fail::::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn not_called` +note: the above error was encountered while instantiating `fn not_called::` --> $DIR/collect-in-dead-fnptr.rs:27:28 | LL | let _fnptr: fn() = not_called::; diff --git a/tests/ui/consts/required-consts/collect-in-promoted-const.noopt.stderr b/tests/ui/consts/required-consts/collect-in-promoted-const.noopt.stderr index eb1ae14a38d9b..67f5009c4ffcf 100644 --- a/tests/ui/consts/required-consts/collect-in-promoted-const.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-promoted-const.noopt.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | let _val = &Fail::::C; | ^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn f` +note: the above error was encountered while instantiating `fn f::` --> $DIR/collect-in-promoted-const.rs:25:5 | LL | f::(); diff --git a/tests/ui/consts/required-consts/collect-in-promoted-const.opt.stderr b/tests/ui/consts/required-consts/collect-in-promoted-const.opt.stderr index d8ae1460569d3..5c3edf68d95f7 100644 --- a/tests/ui/consts/required-consts/collect-in-promoted-const.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-promoted-const.opt.stderr @@ -24,7 +24,7 @@ LL | let _val = &Fail::::C; | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -note: the above error was encountered while instantiating `fn f` +note: the above error was encountered while instantiating `fn f::` --> $DIR/collect-in-promoted-const.rs:25:5 | LL | f::(); diff --git a/tests/ui/generics/post_monomorphization_error_backtrace.rs b/tests/ui/generics/post_monomorphization_error_backtrace.rs index 5ff2eca756d5c..9f53751584b1e 100644 --- a/tests/ui/generics/post_monomorphization_error_backtrace.rs +++ b/tests/ui/generics/post_monomorphization_error_backtrace.rs @@ -19,8 +19,8 @@ fn assert_zst() { fn foo() { assert_zst::() - //~^ NOTE: the above error was encountered while instantiating `fn assert_zst` - //~| NOTE: the above error was encountered while instantiating `fn assert_zst` + //~^ NOTE: the above error was encountered while instantiating `fn assert_zst::` + //~| NOTE: the above error was encountered while instantiating `fn assert_zst::` } fn bar() { diff --git a/tests/ui/generics/post_monomorphization_error_backtrace.stderr b/tests/ui/generics/post_monomorphization_error_backtrace.stderr index fad0858698634..6953414f0c235 100644 --- a/tests/ui/generics/post_monomorphization_error_backtrace.stderr +++ b/tests/ui/generics/post_monomorphization_error_backtrace.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | F::::V; | ^^^^^^^^^ -note: the above error was encountered while instantiating `fn assert_zst` +note: the above error was encountered while instantiating `fn assert_zst::` --> $DIR/post_monomorphization_error_backtrace.rs:21:5 | LL | assert_zst::() @@ -30,7 +30,7 @@ LL | F::::V; | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -note: the above error was encountered while instantiating `fn assert_zst` +note: the above error was encountered while instantiating `fn assert_zst::` --> $DIR/post_monomorphization_error_backtrace.rs:21:5 | LL | assert_zst::() diff --git a/tests/ui/infinite/infinite-instantiation-struct-tail-ice-114484.stderr b/tests/ui/infinite/infinite-instantiation-struct-tail-ice-114484.stderr index fb2ff6f7327fb..faf9cbe2318c4 100644 --- a/tests/ui/infinite/infinite-instantiation-struct-tail-ice-114484.stderr +++ b/tests/ui/infinite/infinite-instantiation-struct-tail-ice-114484.stderr @@ -17,7 +17,7 @@ error: reached the recursion limit finding the struct tail for `[u8; 256]` = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -note: the above error was encountered while instantiating `fn virtualize_my_trait>` +note: the above error was encountered while instantiating `fn virtualize_my_trait::>` --> $DIR/infinite-instantiation-struct-tail-ice-114484.rs:25:18 | LL | unsafe { virtualize_my_trait(L, self) } @@ -45,7 +45,7 @@ error: reached the recursion limit finding the struct tail for `SomeData<256>` = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -note: the above error was encountered while instantiating `fn virtualize_my_trait>` +note: the above error was encountered while instantiating `fn virtualize_my_trait::>` --> $DIR/infinite-instantiation-struct-tail-ice-114484.rs:25:18 | LL | unsafe { virtualize_my_trait(L, self) } @@ -73,7 +73,7 @@ error: reached the recursion limit finding the struct tail for `VirtualWrapper>` +note: the above error was encountered while instantiating `fn virtualize_my_trait::>` --> $DIR/infinite-instantiation-struct-tail-ice-114484.rs:25:18 | LL | unsafe { virtualize_my_trait(L, self) } diff --git a/tests/ui/infinite/infinite-instantiation.rs b/tests/ui/infinite/infinite-instantiation.rs index 83cd8c55210d5..4f86f70ad14da 100644 --- a/tests/ui/infinite/infinite-instantiation.rs +++ b/tests/ui/infinite/infinite-instantiation.rs @@ -20,7 +20,7 @@ impl ToOpt for Option { fn function(counter: usize, t: T) { if counter > 0 { function(counter - 1, t.to_option()); - //~^ ERROR reached the recursion limit while instantiating `function>>>>` +error: reached the recursion limit while instantiating `function::>>>>` --> $DIR/infinite-instantiation.rs:22:9 | LL | function(counter - 1, t.to_option()); diff --git a/tests/ui/inline-const/const-expr-generic-err.stderr b/tests/ui/inline-const/const-expr-generic-err.stderr index f01b1b4c955ee..26039ba6d4449 100644 --- a/tests/ui/inline-const/const-expr-generic-err.stderr +++ b/tests/ui/inline-const/const-expr-generic-err.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | const { assert!(std::mem::size_of::() == 0); } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn foo` +note: the above error was encountered while instantiating `fn foo::` --> $DIR/const-expr-generic-err.rs:12:5 | LL | foo::(); @@ -36,7 +36,7 @@ LL | const { N - 1 } | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -note: the above error was encountered while instantiating `fn bar<0>` +note: the above error was encountered while instantiating `fn bar::<0>` --> $DIR/const-expr-generic-err.rs:13:5 | LL | bar::<0>(); diff --git a/tests/ui/issues/issue-22638.stderr b/tests/ui/issues/issue-22638.stderr index 084281c456fa5..96f1794486838 100644 --- a/tests/ui/issues/issue-22638.stderr +++ b/tests/ui/issues/issue-22638.stderr @@ -1,4 +1,4 @@ -error: reached the recursion limit while instantiating `A::matches<{closure@$DIR/issue-22638.rs:42:23: 42:25}>` +error: reached the recursion limit while instantiating `A::matches::<{closure@$DIR/issue-22638.rs:42:23: 42:25}>` --> $DIR/issue-22638.rs:54:9 | LL | a.matches(f) diff --git a/tests/ui/issues/issue-8727.rs b/tests/ui/issues/issue-8727.rs index 39b7de532a2fc..c1b60e8e08509 100644 --- a/tests/ui/issues/issue-8727.rs +++ b/tests/ui/issues/issue-8727.rs @@ -7,7 +7,7 @@ fn generic() { //~ WARN function cannot return without recursing generic::>(); } -//~^^ ERROR reached the recursion limit while instantiating `generic>(); = help: a `loop` may express intention better if this is on purpose = note: `#[warn(unconditional_recursion)]` on by default -error: reached the recursion limit while instantiating `generic>>>>` +error: reached the recursion limit while instantiating `generic::>>>>` --> $DIR/issue-8727.rs:8:5 | LL | generic::>(); diff --git a/tests/ui/layout/post-mono-layout-cycle.stderr b/tests/ui/layout/post-mono-layout-cycle.stderr index 4369703c2ca19..7f246b3d409ad 100644 --- a/tests/ui/layout/post-mono-layout-cycle.stderr +++ b/tests/ui/layout/post-mono-layout-cycle.stderr @@ -5,7 +5,7 @@ error[E0391]: cycle detected when computing layout of `Wrapper<()>` = note: cycle used when computing layout of `core::option::Option>` = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information -note: the above error was encountered while instantiating `fn abi<()>` +note: the above error was encountered while instantiating `fn abi::<()>` --> $DIR/post-mono-layout-cycle.rs:19:5 | LL | abi::(None); diff --git a/tests/ui/limits/type-length-limit-enforcement.stderr b/tests/ui/limits/type-length-limit-enforcement.stderr index da2931246ef4b..bfea0b5a4482a 100644 --- a/tests/ui/limits/type-length-limit-enforcement.stderr +++ b/tests/ui/limits/type-length-limit-enforcement.stderr @@ -1,4 +1,4 @@ -error: reached the type-length limit while instantiating `drop>` +error: reached the type-length limit while instantiating `drop::>` --> $DIR/type-length-limit-enforcement.rs:34:5 | LL | drop::>(None); diff --git a/tests/ui/recursion/recursion.stderr b/tests/ui/recursion/recursion.stderr index 92bf7b77ee330..974f18ed103d1 100644 --- a/tests/ui/recursion/recursion.stderr +++ b/tests/ui/recursion/recursion.stderr @@ -1,4 +1,4 @@ -error: reached the recursion limit while instantiating `test>>>>>>` +error: reached the recursion limit while instantiating `test::>>>>>>` --> $DIR/recursion.rs:17:11 | LL | _ => {test (n-1, i+1, Cons {head:2*i+1, tail:first}, Cons{head:i*i, tail:second})} diff --git a/tests/ui/recursion/recursive-impl-trait-iterator-by-ref-67552.stderr b/tests/ui/recursion/recursive-impl-trait-iterator-by-ref-67552.stderr index 48029e0d62917..8d6d44dcbe2fb 100644 --- a/tests/ui/recursion/recursive-impl-trait-iterator-by-ref-67552.stderr +++ b/tests/ui/recursion/recursive-impl-trait-iterator-by-ref-67552.stderr @@ -1,4 +1,4 @@ -error: reached the recursion limit while instantiating `rec<&mut &mut &mut &mut &mut &mut &mut &mut ...>` +error: reached the recursion limit while instantiating `rec::<&mut &mut &mut &mut &mut &mut &mut &mut ...>` --> $DIR/recursive-impl-trait-iterator-by-ref-67552.rs:28:9 | LL | rec(identity(&mut it)) diff --git a/tests/ui/simd/const-err-trumps-simd-err.stderr b/tests/ui/simd/const-err-trumps-simd-err.stderr index d5ba686ccdaff..93d1fce637f2f 100644 --- a/tests/ui/simd/const-err-trumps-simd-err.stderr +++ b/tests/ui/simd/const-err-trumps-simd-err.stderr @@ -10,7 +10,7 @@ note: erroneous constant encountered LL | const { assert!(LANE < 4); } // the error should be here... | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: the above error was encountered while instantiating `fn get_elem<4>` +note: the above error was encountered while instantiating `fn get_elem::<4>` --> $DIR/const-err-trumps-simd-err.rs:23:5 | LL | get_elem::<4>(int8x4_t([0, 0, 0, 0])); diff --git a/tests/ui/structs/default-field-values/post-mono.indirect.stderr b/tests/ui/structs/default-field-values/post-mono.indirect.stderr index 7f4fecb94595a..c8af9c959c103 100644 --- a/tests/ui/structs/default-field-values/post-mono.indirect.stderr +++ b/tests/ui/structs/default-field-values/post-mono.indirect.stderr @@ -18,7 +18,7 @@ LL | let x: Z = Z { .. }; | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -note: the above error was encountered while instantiating `fn indirect<1>` +note: the above error was encountered while instantiating `fn indirect::<1>` --> $DIR/post-mono.rs:22:5 | LL | indirect::<1>();