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).

When we don't actually print out a shortened type we don't need the "use `--verbose`" note.

On E0599 show type identity to avoid expanding the receiver's generic parameters.

Unify wording on `long_ty_path` everywhere.
This commit is contained in:
Esteban Küber 2025-07-16 19:45:07 +00:00
parent 2fd855fbfc
commit 99196657fc
68 changed files with 397 additions and 339 deletions

View file

@ -1382,6 +1382,11 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
&mut self.long_ty_path &mut self.long_ty_path
} }
pub fn with_long_ty_path(mut self, long_ty_path: Option<PathBuf>) -> Self {
self.long_ty_path = long_ty_path;
self
}
/// Most `emit_producing_guarantee` functions use this as a starting point. /// Most `emit_producing_guarantee` functions use this as a starting point.
fn emit_producing_nothing(mut self) { fn emit_producing_nothing(mut self) {
let diag = self.take_diag(); let diag = self.take_diag();

View file

@ -1135,9 +1135,10 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
); );
} }
} else { } else {
let trait_ =
tcx.short_string(bound.print_only_trait_path(), err.long_ty_path());
err.note(format!( err.note(format!(
"associated {assoc_kind_str} `{assoc_ident}` could derive from `{}`", "associated {assoc_kind_str} `{assoc_ident}` could derive from `{trait_}`",
bound.print_only_trait_path(),
)); ));
} }
} }

View file

@ -159,7 +159,7 @@ hir_typeck_lossy_provenance_ptr2int =
.suggestion = use `.addr()` to obtain the address of a pointer .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 .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 = hir_typeck_naked_asm_outside_naked_fn =
the `naked_asm!` macro can only be used in functions marked with `#[unsafe(naked)]` 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 hir_typeck_never_type_fallback_flowing_into_unsafe_union_field = never type fallback affects this union access
.help = specify the type explicitly .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] {""} [true] {""}
*[other] {" "}in the current scope *[other] {" "}in the current scope
} }

View file

@ -200,11 +200,11 @@ pub(crate) enum ExplicitDestructorCallSugg {
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(hir_typeck_missing_parentheses_in_range, code = E0689)] #[diag(hir_typeck_missing_parentheses_in_range, code = E0689)]
pub(crate) struct MissingParenthesesInRange { pub(crate) struct MissingParenthesesInRange<'tcx> {
#[primary_span] #[primary_span]
#[label(hir_typeck_missing_parentheses_in_range)] #[label(hir_typeck_missing_parentheses_in_range)]
pub span: Span, pub span: Span,
pub ty_str: String, pub ty: Ty<'tcx>,
pub method_name: String, pub method_name: String,
#[subdiagnostic] #[subdiagnostic]
pub add_missing_parentheses: Option<AddMissingParenthesesInRange>, pub add_missing_parentheses: Option<AddMissingParenthesesInRange>,
@ -828,13 +828,13 @@ pub(crate) struct UnlabeledCfInWhileCondition<'a> {
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(hir_typeck_no_associated_item, code = E0599)] #[diag(hir_typeck_no_associated_item, code = E0599)]
pub(crate) struct NoAssociatedItem { pub(crate) struct NoAssociatedItem<'tcx> {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
pub item_kind: &'static str, pub item_kind: &'static str,
pub item_ident: Ident, pub item_ident: Ident,
pub ty_prefix: Cow<'static, str>, pub ty_prefix: Cow<'static, str>,
pub ty_str: String, pub ty: Ty<'tcx>,
pub trait_missing_method: bool, pub trait_missing_method: bool,
} }

View file

@ -376,16 +376,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} }
} }
fn suggest_missing_writer(&self, rcvr_ty: Ty<'tcx>, rcvr_expr: &hir::Expr<'tcx>) -> Diag<'_> { fn suggest_missing_writer(
let mut file = None; &self,
rcvr_ty: Ty<'tcx>,
rcvr_expr: &hir::Expr<'tcx>,
mut long_ty_path: Option<PathBuf>,
) -> Diag<'_> {
let mut err = struct_span_code_err!( let mut err = struct_span_code_err!(
self.dcx(), self.dcx(),
rcvr_expr.span, rcvr_expr.span,
E0599, E0599,
"cannot write into `{}`", "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( err.span_note(
rcvr_expr.span, rcvr_expr.span,
"must implement `io::Write`, `fmt::Write`, or have a `write_fmt` method", "must implement `io::Write`, `fmt::Write`, or have a `write_fmt` method",
@ -403,7 +407,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&self, &self,
self_source: SelfSource<'tcx>, self_source: SelfSource<'tcx>,
method_name: Ident, method_name: Ident,
ty_str_reported: &str, ty: Ty<'tcx>,
err: &mut Diag<'_>, err: &mut Diag<'_>,
) { ) {
#[derive(Debug)] #[derive(Debug)]
@ -478,7 +482,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} }
// If the shadowed binding has an itializer expression, // 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();`, // For example like: `let mut x = Vec::new();`,
// `Vec::new()` is the itializer expression. // `Vec::new()` is the itializer expression.
if let Some(self_ty) = self.fcx.node_ty_opt(binding.init_hir_id) if let Some(self_ty) = self.fcx.node_ty_opt(binding.init_hir_id)
@ -566,17 +570,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let mut span = MultiSpan::from_span(sugg_let.span); let mut span = MultiSpan::from_span(sugg_let.span);
span.push_span_label(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")); format!("`{rcvr_name}` of type `{self_ty}` that has method `{method_name}` defined earlier here"));
let ty = self.tcx.short_string(ty, err.long_ty_path());
span.push_span_label( span.push_span_label(
self.tcx.hir_span(recv_id), self.tcx.hir_span(recv_id),
format!( format!("earlier `{rcvr_name}` shadowed here with type `{ty}`"),
"earlier `{rcvr_name}` shadowed here with type `{ty_str_reported}`"
),
); );
err.span_note( err.span_note(
span, span,
format!( format!(
"there's an earlier shadowed binding `{rcvr_name}` of type `{self_ty}` \ "there's an earlier shadowed binding `{rcvr_name}` of type `{self_ty}` \
that has method `{method_name}` available" that has method `{method_name}` available"
), ),
); );
} }
@ -602,15 +606,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let tcx = self.tcx; let tcx = self.tcx;
let rcvr_ty = self.resolve_vars_if_possible(rcvr_ty); let rcvr_ty = self.resolve_vars_if_possible(rcvr_ty);
let mut ty_file = None; 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 is_method = mode == Mode::MethodCall;
let unsatisfied_predicates = &no_match_data.unsatisfied_predicates; let unsatisfied_predicates = &no_match_data.unsatisfied_predicates;
let similar_candidate = no_match_data.similar_candidate; let similar_candidate = no_match_data.similar_candidate;
@ -629,15 +624,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// We could pass the file for long types into these two, but it isn't strictly necessary // We could pass the file for long types into these two, but it isn't strictly necessary
// given how targeted they are. // given how targeted they are.
if let Err(guar) = self.report_failed_method_call_on_range_end( if let Err(guar) =
tcx, self.report_failed_method_call_on_range_end(tcx, rcvr_ty, source, span, item_ident)
rcvr_ty, {
source,
span,
item_ident,
&short_ty_str,
&mut ty_file,
) {
return guar; return guar;
} }
if let Err(guar) = self.report_failed_method_call_on_numerical_infer_var( if let Err(guar) = self.report_failed_method_call_on_numerical_infer_var(
@ -647,44 +636,42 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
span, span,
item_kind, item_kind,
item_ident, item_ident,
&short_ty_str,
&mut ty_file, &mut ty_file,
) { ) {
return guar; return guar;
} }
span = item_ident.span; 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| { 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::write_macro, def_id)
|| tcx.is_diagnostic_item(sym::writeln_macro, def_id) || tcx.is_diagnostic_item(sym::writeln_macro, def_id)
}) && item_ident.name == sym::write_fmt; }) && item_ident.name == sym::write_fmt;
let mut err = if is_write && let SelfSource::MethodCall(rcvr_expr) = source { 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 { } 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 { let mut err = self.dcx().create_err(NoAssociatedItem {
span, span,
item_kind, item_kind,
@ -695,16 +682,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} else { } else {
rcvr_ty.prefix_string(self.tcx) rcvr_ty.prefix_string(self.tcx)
}, },
ty_str: ty_str_reported.clone(), ty,
trait_missing_method, trait_missing_method,
}); });
if is_method { if is_method {
self.suggest_use_shadowed_binding_with_method( self.suggest_use_shadowed_binding_with_method(
source, source, item_ident, rcvr_ty, &mut err,
item_ident,
&ty_str_reported,
&mut err,
); );
} }
@ -734,6 +718,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
err err
}; };
if tcx.sess.source_map().is_multiline(sugg_span) { if tcx.sess.source_map().is_multiline(sugg_span) {
err.span_label(sugg_span.with_hi(span.lo()), ""); err.span_label(sugg_span.with_hi(span.lo()), "");
} }
@ -750,6 +735,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} }
if tcx.ty_is_opaque_future(rcvr_ty) && item_ident.name == sym::poll { 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!( err.help(format!(
"method `poll` found on `Pin<&mut {ty_str}>`, \ "method `poll` found on `Pin<&mut {ty_str}>`, \
see documentation for `std::pin::Pin`" see documentation for `std::pin::Pin`"
@ -1339,7 +1325,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} }
let OnUnimplementedNote { message, label, notes, .. } = self let OnUnimplementedNote { message, label, notes, .. } = self
.err_ctxt() .err_ctxt()
.on_unimplemented_note(trait_ref, &obligation, &mut ty_file); .on_unimplemented_note(trait_ref, &obligation, err.long_ty_path());
(message, label, notes) (message, label, notes)
}) })
.unwrap() .unwrap()
@ -1347,6 +1333,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
(None, None, Vec::new()) (None, None, Vec::new())
}; };
let primary_message = primary_message.unwrap_or_else(|| { let primary_message = primary_message.unwrap_or_else(|| {
let ty_str = self.tcx.short_string(rcvr_ty, err.long_ty_path());
format!( format!(
"the {item_kind} `{item_ident}` exists for {actual_prefix} `{ty_str}`, \ "the {item_kind} `{item_ident}` exists for {actual_prefix} `{ty_str}`, \
but its trait bounds were not satisfied" but its trait bounds were not satisfied"
@ -1409,6 +1396,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let mut find_candidate_for_method = false; let mut find_candidate_for_method = false;
let mut label_span_not_found = |err: &mut Diag<'_>| { 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() { if unsatisfied_predicates.is_empty() {
err.span_label(span, format!("{item_kind} not found in `{ty_str}`")); err.span_label(span, format!("{item_kind} not found in `{ty_str}`"));
let is_string_or_ref_str = match rcvr_ty.kind() { let is_string_or_ref_str = match rcvr_ty.kind() {
@ -2520,8 +2508,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
source: SelfSource<'tcx>, source: SelfSource<'tcx>,
span: Span, span: Span,
item_name: Ident, item_name: Ident,
ty_str: &str,
long_ty_path: &mut Option<PathBuf>,
) -> Result<(), ErrorGuaranteed> { ) -> Result<(), ErrorGuaranteed> {
if let SelfSource::MethodCall(expr) = source { if let SelfSource::MethodCall(expr) = source {
for (_, parent) in tcx.hir_parent_iter(expr.hir_id).take(5) { for (_, parent) in tcx.hir_parent_iter(expr.hir_id).take(5) {
@ -2583,18 +2569,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
); );
if pick.is_ok() { if pick.is_ok() {
let range_span = parent_expr.span.with_hi(expr.span.hi()); 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, span,
ty_str: ty_str.to_string(), ty: actual,
method_name: item_name.as_str().to_string(), method_name: item_name.as_str().to_string(),
add_missing_parentheses: Some(errors::AddMissingParenthesesInRange { add_missing_parentheses: Some(errors::AddMissingParenthesesInRange {
func_name: item_name.name.as_str().to_string(), func_name: item_name.name.as_str().to_string(),
left: range_span.shrink_to_lo(), left: range_span.shrink_to_lo(),
right: range_span.shrink_to_hi(), right: range_span.shrink_to_hi(),
}), }),
}); }));
*err.long_ty_path() = long_ty_path.take();
return Err(err.emit());
} }
} }
} }
@ -2610,7 +2594,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
span: Span, span: Span,
item_kind: &str, item_kind: &str,
item_name: Ident, item_name: Ident,
ty_str: &str,
long_ty_path: &mut Option<PathBuf>, long_ty_path: &mut Option<PathBuf>,
) -> Result<(), ErrorGuaranteed> { ) -> Result<(), ErrorGuaranteed> {
let found_candidate = all_traits(self.tcx) let found_candidate = all_traits(self.tcx)
@ -2643,14 +2626,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&& !actual.has_concrete_skeleton() && !actual.has_concrete_skeleton()
&& let SelfSource::MethodCall(expr) = source && let SelfSource::MethodCall(expr) = source
{ {
let ty_str = self.tcx.short_string(actual, long_ty_path);
let mut err = struct_span_code_err!( let mut err = struct_span_code_err!(
self.dcx(), self.dcx(),
span, span,
E0689, E0689,
"can't call {} `{}` on ambiguous numeric type `{}`", "can't call {item_kind} `{item_name}` on ambiguous numeric type `{ty_str}`"
item_kind,
item_name,
ty_str
); );
*err.long_ty_path() = long_ty_path.take(); *err.long_ty_path() = long_ty_path.take();
let concrete_type = if actual.is_integral() { "i32" } else { "f32" }; let concrete_type = if actual.is_integral() { "i32" } else { "f32" };

View file

@ -2987,7 +2987,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>); pub struct TraitPredPrintModifiersAndPath<'tcx>(ty::TraitPredicate<'tcx>);
impl<'tcx> fmt::Debug for TraitPredPrintModifiersAndPath<'tcx> { impl<'tcx> fmt::Debug for TraitPredPrintModifiersAndPath<'tcx> {

View file

@ -171,8 +171,6 @@ trait_selection_fps_remove_ref = consider removing the reference
trait_selection_fps_use_ref = consider using a 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_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}` trait_selection_ignored_diagnostic_option = `{$option_name}` is ignored due to previous definition of `{$option_name}`
.other_label = `{$option_name}` is first declared here .other_label = `{$option_name}` is first declared here
.label = `{$option_name}` is already declared here .label = `{$option_name}` is already declared here

View file

@ -1930,7 +1930,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
&self, &self,
trace: &TypeTrace<'tcx>, trace: &TypeTrace<'tcx>,
terr: TypeError<'tcx>, terr: TypeError<'tcx>,
path: &mut Option<PathBuf>, long_ty_path: &mut Option<PathBuf>,
) -> Vec<TypeErrorAdditionalDiags> { ) -> Vec<TypeErrorAdditionalDiags> {
let mut suggestions = Vec::new(); let mut suggestions = Vec::new();
let span = trace.cause.span; let span = trace.cause.span;
@ -2009,7 +2009,8 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
}) })
| ObligationCauseCode::BlockTailExpression(.., source)) = code | ObligationCauseCode::BlockTailExpression(.., source)) = code
&& let hir::MatchSource::TryDesugar(_) = source && 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 { suggestions.push(TypeErrorAdditionalDiags::TryCannotConvert {
found: found_ty.content(), found: found_ty.content(),
@ -2139,11 +2140,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
&self, &self,
values: ValuePairs<'tcx>, values: ValuePairs<'tcx>,
cause: &ObligationCause<'tcx>, cause: &ObligationCause<'tcx>,
file: &mut Option<PathBuf>, long_ty_path: &mut Option<PathBuf>,
) -> Option<(DiagStyledString, DiagStyledString)> { ) -> Option<(DiagStyledString, DiagStyledString)> {
match values { match values {
ValuePairs::Regions(exp_found) => self.expected_found_str(exp_found), 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::Aliases(exp_found) => self.expected_found_str(exp_found),
ValuePairs::ExistentialTraitRef(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), ValuePairs::ExistentialProjection(exp_found) => self.expected_found_str(exp_found),
@ -2183,7 +2184,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
fn expected_found_str_term( fn expected_found_str_term(
&self, &self,
exp_found: ty::error::ExpectedFound<ty::Term<'tcx>>, exp_found: ty::error::ExpectedFound<ty::Term<'tcx>>,
path: &mut Option<PathBuf>, long_ty_path: &mut Option<PathBuf>,
) -> Option<(DiagStyledString, DiagStyledString)> { ) -> Option<(DiagStyledString, DiagStyledString)> {
let exp_found = self.resolve_vars_if_possible(exp_found); let exp_found = self.resolve_vars_if_possible(exp_found);
if exp_found.references_error() { if exp_found.references_error() {
@ -2200,11 +2201,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
let exp_s = exp.content(); let exp_s = exp.content();
let fnd_s = fnd.content(); let fnd_s = fnd.content();
if exp_s.len() > len { 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); exp = DiagStyledString::highlighted(exp_s);
} }
if fnd_s.len() > len { 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); fnd = DiagStyledString::highlighted(fnd_s);
} }
(exp, fnd) (exp, fnd)

View file

@ -436,8 +436,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
infer_subdiags, infer_subdiags,
multi_suggestions, multi_suggestions,
bad_label, bad_label,
was_written: false,
path: Default::default(),
}), }),
TypeAnnotationNeeded::E0283 => self.dcx().create_err(AmbiguousImpl { TypeAnnotationNeeded::E0283 => self.dcx().create_err(AmbiguousImpl {
span, span,
@ -447,8 +445,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
infer_subdiags, infer_subdiags,
multi_suggestions, multi_suggestions,
bad_label, bad_label,
was_written: false,
path: Default::default(),
}), }),
TypeAnnotationNeeded::E0284 => self.dcx().create_err(AmbiguousReturn { TypeAnnotationNeeded::E0284 => self.dcx().create_err(AmbiguousReturn {
span, span,
@ -458,8 +454,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
infer_subdiags, infer_subdiags,
multi_suggestions, multi_suggestions,
bad_label, 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); 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) { let failure_span = if should_label_span && !failure_span.overlaps(span) {
Some(failure_span) Some(failure_span)
} else { } else {
@ -628,7 +622,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
} }
} }
} }
match error_code { let mut err = match error_code {
TypeAnnotationNeeded::E0282 => self.dcx().create_err(AnnotationRequired { TypeAnnotationNeeded::E0282 => self.dcx().create_err(AnnotationRequired {
span, span,
source_kind, source_kind,
@ -637,8 +631,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
infer_subdiags, infer_subdiags,
multi_suggestions, multi_suggestions,
bad_label: None, bad_label: None,
was_written: path.is_some(),
path: path.unwrap_or_default(),
}), }),
TypeAnnotationNeeded::E0283 => self.dcx().create_err(AmbiguousImpl { TypeAnnotationNeeded::E0283 => self.dcx().create_err(AmbiguousImpl {
span, span,
@ -648,8 +640,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
infer_subdiags, infer_subdiags,
multi_suggestions, multi_suggestions,
bad_label: None, bad_label: None,
was_written: path.is_some(),
path: path.unwrap_or_default(),
}), }),
TypeAnnotationNeeded::E0284 => self.dcx().create_err(AmbiguousReturn { TypeAnnotationNeeded::E0284 => self.dcx().create_err(AmbiguousReturn {
span, span,
@ -659,10 +649,10 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
infer_subdiags, infer_subdiags,
multi_suggestions, multi_suggestions,
bad_label: None, bad_label: None,
was_written: path.is_some(),
path: path.unwrap_or_default(),
}), }),
} };
*err.long_ty_path() = long_ty_path;
err
} }
} }
@ -726,22 +716,24 @@ impl<'tcx> InferSource<'tcx> {
impl<'tcx> InferSourceKind<'tcx> { impl<'tcx> InferSourceKind<'tcx> {
fn ty_localized_msg(&self, infcx: &InferCtxt<'tcx>) -> (&'static str, String, Option<PathBuf>) { fn ty_localized_msg(&self, infcx: &InferCtxt<'tcx>) -> (&'static str, String, Option<PathBuf>) {
let mut path = None; let mut long_ty_path = None;
match *self { match *self {
InferSourceKind::LetBinding { ty, .. } InferSourceKind::LetBinding { ty, .. }
| InferSourceKind::ClosureArg { ty, .. } | InferSourceKind::ClosureArg { ty, .. }
| InferSourceKind::ClosureReturn { ty, .. } => { | InferSourceKind::ClosureReturn { ty, .. } => {
if ty.is_closure() { 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() { } 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 { } else {
("other", String::new(), path) ("other", String::new(), long_ty_path)
} }
} }
// FIXME: We should be able to add some additional info here. // FIXME: We should be able to add some additional info here.
InferSourceKind::GenericArg { .. } InferSourceKind::GenericArg { .. }
| InferSourceKind::FullyQualifiedMethodCall { .. } => ("other", String::new(), path), | InferSourceKind::FullyQualifiedMethodCall { .. } => {
("other", String::new(), long_ty_path)
}
} }
} }
} }

View file

@ -169,7 +169,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
let predicate = self.resolve_vars_if_possible(obligation.predicate); let predicate = self.resolve_vars_if_possible(obligation.predicate);
let span = obligation.cause.span; let span = obligation.cause.span;
let mut file = None; let mut long_ty_path = None;
debug!(?predicate, obligation.cause.code = ?obligation.cause.code()); 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()), self.tcx.as_lang_item(trait_pred.def_id()),
Some(LangItem::Sized | LangItem::MetaSized) Some(LangItem::Sized | LangItem::MetaSized)
) { ) {
match self.tainted_by_errors() { return match self.tainted_by_errors() {
None => { None => self
let err = self.emit_inference_failure_err( .emit_inference_failure_err(
obligation.cause.body_id, obligation.cause.body_id,
span, span,
trait_pred.self_ty().skip_binder().into(), trait_pred.self_ty().skip_binder().into(),
TypeAnnotationNeeded::E0282, TypeAnnotationNeeded::E0282,
false, false,
); )
return err.emit(); .emit(),
} Some(e) => e,
Some(e) => return e, };
}
} }
// Typically, this ambiguity should only happen if // Typically, this ambiguity should only happen if
@ -260,8 +259,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
span, span,
E0283, E0283,
"type annotations needed: cannot satisfy `{}`", "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( let mut ambiguities = compute_applicable_impls_for_diagnostics(
@ -307,7 +307,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
err.cancel(); err.cancel();
return e; 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}`")); err.note(format!("cannot satisfy `{pred}`"));
let impl_candidates = let impl_candidates =
self.find_similar_impl_candidates(predicate.as_trait_clause().unwrap()); self.find_similar_impl_candidates(predicate.as_trait_clause().unwrap());
@ -512,6 +512,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
true, true,
) )
} }
ty::PredicateKind::Clause(ty::ClauseKind::Projection(data)) => { ty::PredicateKind::Clause(ty::ClauseKind::Projection(data)) => {
if let Err(e) = predicate.error_reported() { if let Err(e) = predicate.error_reported() {
return e; return e;
@ -536,7 +537,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
.filter_map(ty::GenericArg::as_term) .filter_map(ty::GenericArg::as_term)
.chain([data.term]) .chain([data.term])
.find(|g| g.has_non_region_infer()); .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 { if let Some(term) = term {
self.emit_inference_failure_err( self.emit_inference_failure_err(
obligation.cause.body_id, obligation.cause.body_id,
@ -546,6 +547,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
true, true,
) )
.with_note(format!("cannot satisfy `{predicate}`")) .with_note(format!("cannot satisfy `{predicate}`"))
.with_long_ty_path(long_ty_path)
} else { } else {
// If we can't find a generic parameter, just print a generic error // If we can't find a generic parameter, just print a generic error
struct_span_code_err!( struct_span_code_err!(
@ -555,6 +557,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
"type annotations needed: cannot satisfy `{predicate}`", "type annotations needed: cannot satisfy `{predicate}`",
) )
.with_span_label(span, format!("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 = let term =
data.walk().filter_map(ty::GenericArg::as_term).find(|term| term.is_infer()); data.walk().filter_map(ty::GenericArg::as_term).find(|term| term.is_infer());
if let Some(term) = term { if let Some(term) = term {
let err = self.emit_inference_failure_err( self.emit_inference_failure_err(
obligation.cause.body_id, obligation.cause.body_id,
span, span,
term, term,
TypeAnnotationNeeded::E0284, TypeAnnotationNeeded::E0284,
true, true,
); )
err
} else { } else {
// If we can't find a generic parameter, just print a generic error // 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!( struct_span_code_err!(
self.dcx(), self.dcx(),
span, span,
@ -586,6 +588,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
"type annotations needed: cannot satisfy `{predicate}`", "type annotations needed: cannot satisfy `{predicate}`",
) )
.with_span_label(span, format!("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, TypeAnnotationNeeded::E0284,
true, true,
), ),
ty::PredicateKind::NormalizesTo(ty::NormalizesTo { alias, term }) ty::PredicateKind::NormalizesTo(ty::NormalizesTo { alias, term })
if term.is_infer() => if term.is_infer() =>
{ {
if let Some(e) = self.tainted_by_errors() { if let Some(e) = self.tainted_by_errors() {
return e; 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!( struct_span_code_err!(
self.dcx(), self.dcx(),
span, span,
@ -611,37 +615,34 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
"type annotations needed: cannot normalize `{alias}`", "type annotations needed: cannot normalize `{alias}`",
) )
.with_span_label(span, format!("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)) => { ty::PredicateKind::Clause(ty::ClauseKind::UnstableFeature(sym)) => {
if let Some(e) = self.tainted_by_errors() { if let Some(e) = self.tainted_by_errors() {
return e; return e;
} }
let mut err;
if self.tcx.features().staged_api() { if self.tcx.features().staged_api() {
err = self.dcx().struct_span_err( self.dcx().struct_span_err(
span, span,
format!("unstable feature `{sym}` is used without being enabled."), format!("unstable feature `{sym}` is used without being enabled."),
); ).with_help(format!("The feature can be enabled by marking the current item with `#[unstable_feature_bound({sym})]`"))
err.help(format!("The feature can be enabled by marking the current item with `#[unstable_feature_bound({sym})]`"));
} else { } else {
err = feature_err_unstable_feature_bound( feature_err_unstable_feature_bound(
&self.tcx.sess, &self.tcx.sess,
sym, sym,
span, span,
format!("use of unstable library feature `{sym}`"), format!("use of unstable library feature `{sym}`"),
); )
} }
err
} }
_ => { _ => {
if let Some(e) = self.tainted_by_errors() { if let Some(e) = self.tainted_by_errors() {
return e; 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!( struct_span_code_err!(
self.dcx(), self.dcx(),
span, span,
@ -649,9 +650,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
"type annotations needed: cannot satisfy `{predicate}`", "type annotations needed: cannot satisfy `{predicate}`",
) )
.with_span_label(span, format!("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); self.note_obligation_cause(&mut err, obligation);
err.emit() err.emit()
} }

View file

@ -208,16 +208,19 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
performs a conversion on the error value \ performs a conversion on the error value \
using the `From` trait"; using the `From` trait";
let (message, notes, append_const_msg) = if is_try_conversion { 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()?`. // We have a `-> Result<_, E1>` and `gives_E2()?`.
( (
Some(format!( Some(format!("`?` couldn't convert the error to `{ty}`")),
"`?` couldn't convert the error to `{}`",
main_trait_predicate.skip_binder().self_ty(),
)),
vec![question_mark_message.to_owned()], vec![question_mark_message.to_owned()],
Some(AppendConstMessage::Default), Some(AppendConstMessage::Default),
) )
} else if is_question_mark { } 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 // Similar to the case above, but in this case the conversion is for a
// trait object: `-> Result<_, Box<dyn Error>` and `gives_E()?` when // trait object: `-> Result<_, Box<dyn Error>` and `gives_E()?` when
// `E: Error` isn't met. // `E: Error` isn't met.
@ -233,7 +236,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
(message, notes, append_const_msg) (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, main_trait_predicate,
message, message,
None, None,
@ -258,7 +261,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
); );
} }
GetSafeTransmuteErrorAndReason::Default => { GetSafeTransmuteErrorAndReason::Default => {
(err_msg, None) (default_err_msg(), None)
} }
GetSafeTransmuteErrorAndReason::Error { GetSafeTransmuteErrorAndReason::Error {
err_msg, err_msg,
@ -266,7 +269,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
} => (err_msg, safe_transmute_explanation), } => (err_msg, safe_transmute_explanation),
} }
} else { } else {
(err_msg, None) (default_err_msg(), None)
}; };
let mut err = struct_span_code_err!(self.dcx(), span, E0277, "{}", err_msg); 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 let Some(ret_span) = self.return_type_span(&obligation) {
if is_try_conversion { if is_try_conversion {
let ty = self.tcx.short_string(
main_trait_predicate.skip_binder().self_ty(),
err.long_ty_path(),
);
err.span_label( err.span_label(
ret_span, ret_span,
format!( format!("expected `{ty}` because of this"),
"expected `{}` because of this",
main_trait_predicate.skip_binder().self_ty()
),
); );
} else if is_question_mark { } 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"),
);
} }
} }
@ -303,6 +312,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
&obligation, &obligation,
leaf_trait_predicate, leaf_trait_predicate,
pre_message, pre_message,
err.long_ty_path(),
); );
self.check_for_binding_assigned_block_without_tail_expression( self.check_for_binding_assigned_block_without_tail_expression(
@ -414,11 +424,12 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
} else { } else {
vec![(span.shrink_to_hi(), format!(" as {}", cand.self_ty()))] 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( err.multipart_suggestion(
format!( format!(
"the trait `{}` is implemented for fn pointer `{}`, try casting using `as`", "the trait `{trait_}` is implemented for fn pointer \
cand.print_trait_sugared(), `{ty}`, try casting using `as`",
cand.self_ty(),
), ),
suggestion, suggestion,
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
@ -522,7 +533,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
<https://github.com/rust-lang/rust/issues/48950> \ <https://github.com/rust-lang/rust/issues/48950> \
for more information)", 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 +733,13 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
} }
SelectionError::ConstArgHasWrongType { ct, ct_ty, expected_ty } => { 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( let mut diag = self.dcx().struct_span_err(
span, 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( self.note_type_err(
&mut diag, &mut diag,
@ -1118,9 +1132,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
.must_apply_modulo_regions() .must_apply_modulo_regions()
{ {
if !suggested { 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}>`")); err.span_label(span, format!("this has type `Result<_, {err_ty}>`"));
} }
} else { } else {
let err_ty = self.tcx.short_string(err_ty, err.long_ty_path());
err.span_label( err.span_label(
span, span,
format!( format!(
@ -1156,12 +1172,13 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
); );
} }
(ty::Adt(def, _), None) if def.did().is_local() => { (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( err.span_note(
self.tcx.def_span(def.did()), self.tcx.def_span(def.did()),
format!( format!("`{self_ty}` needs to implement `{trait_path}`"),
"`{self_ty}` needs to implement `{}`",
trait_pred.skip_binder().trait_ref.print_only_trait_path(),
),
); );
} }
(ty::Adt(def, _), Some(ty)) if def.did().is_local() => { (ty::Adt(def, _), Some(ty)) if def.did().is_local() => {
@ -1195,13 +1212,15 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
bug!() bug!()
}; };
let mut file = None;
let ty_str = self.tcx.short_string(ty, &mut file);
let mut diag = match ty.kind() { let mut diag = match ty.kind() {
ty::Float(_) => { ty::Float(_) => {
struct_span_code_err!( struct_span_code_err!(
self.dcx(), self.dcx(),
span, span,
E0741, 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(..) => { ty::FnPtr(..) => {
@ -1226,7 +1245,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
self.dcx(), self.dcx(),
span, span,
E0741, 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, // Only suggest derive if this isn't a derived obligation,
// and the struct is local. // and the struct is local.
@ -1258,21 +1277,22 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
self.dcx(), self.dcx(),
span, span,
E0741, 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 code = obligation.cause.code();
let mut pred = obligation.predicate.as_trait_clause(); let mut pred = obligation.predicate.as_trait_clause();
while let Some((next_code, next_pred)) = code.parent_with_predicate() { while let Some((next_code, next_pred)) = code.parent_with_predicate() {
if let Some(pred) = pred { if let Some(pred) = pred {
self.enter_forall(pred, |pred| { self.enter_forall(pred, |pred| {
diag.note(format!( let ty = self.tcx.short_string(pred.self_ty(), diag.long_ty_path());
"`{}` must implement `{}`, but it does not", let trait_path = self
pred.self_ty(), .tcx
pred.print_modifiers_and_trait_path() .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; code = next_code;
@ -1584,7 +1604,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
projection_term: ty::AliasTerm<'tcx>, projection_term: ty::AliasTerm<'tcx>,
normalized_ty: ty::Term<'tcx>, normalized_ty: ty::Term<'tcx>,
expected_ty: ty::Term<'tcx>, expected_ty: ty::Term<'tcx>,
file: &mut Option<PathBuf>, long_ty_path: &mut Option<PathBuf>,
) -> Option<(String, Span, Option<Span>)> { ) -> Option<(String, Span, Option<Span>)> {
let trait_def_id = projection_term.trait_def_id(self.tcx); let trait_def_id = projection_term.trait_def_id(self.tcx);
let self_ty = projection_term.self_ty(); let self_ty = projection_term.self_ty();
@ -1624,17 +1644,25 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
}; };
let item = match self_ty.kind() { let item = match self_ty.kind() {
ty::FnDef(def, _) => self.tcx.item_name(*def).to_string(), 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, long_ty_path);
let normalized_ty = self.tcx.short_string(normalized_ty, long_ty_path);
Some((format!( Some((format!(
"expected `{item}` to return `{expected_ty}`, but it returns `{normalized_ty}`", "expected `{item}` to return `{expected_ty}`, but it returns `{normalized_ty}`",
), span, closure_span)) ), span, closure_span))
} else if self.tcx.is_lang_item(trait_def_id, LangItem::Future) { } else if self.tcx.is_lang_item(trait_def_id, LangItem::Future) {
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!( Some((format!(
"expected `{self_ty}` to be a future that resolves to `{expected_ty}`, but it \ "expected `{self_ty}` to be a future that resolves to `{expected_ty}`, but it \
resolves to `{normalized_ty}`" resolves to `{normalized_ty}`"
), span, None)) ), span, None))
} else if Some(trait_def_id) == self.tcx.get_diagnostic_item(sym::Iterator) { } else if Some(trait_def_id) == self.tcx.get_diagnostic_item(sym::Iterator) {
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!( Some((format!(
"expected `{self_ty}` to be an iterator that yields `{expected_ty}`, but it \ "expected `{self_ty}` to be an iterator that yields `{expected_ty}`, but it \
yields `{normalized_ty}`" yields `{normalized_ty}`"
@ -2097,12 +2125,15 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
if let [TypeError::Sorts(exp_found)] = &terrs[..] { if let [TypeError::Sorts(exp_found)] = &terrs[..] {
let exp_found = self.resolve_vars_if_possible(*exp_found); 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![ err.highlighted_help(vec![
StringPart::normal("for that trait implementation, "), StringPart::normal("for that trait implementation, "),
StringPart::normal("expected `"), StringPart::normal("expected `"),
StringPart::highlighted(exp_found.expected.to_string()), StringPart::highlighted(expected),
StringPart::normal("`, found `"), StringPart::normal("`, found `"),
StringPart::highlighted(exp_found.found.to_string()), StringPart::highlighted(found),
StringPart::normal("`"), StringPart::normal("`"),
]); ]);
self.suggest_function_pointers_impl(None, &exp_found, err); self.suggest_function_pointers_impl(None, &exp_found, err);
@ -2135,11 +2166,13 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
(ty::FnPtr(..), _) => (" implemented for fn pointer `", ""), (ty::FnPtr(..), _) => (" implemented for fn pointer `", ""),
_ => (" implemented for `", ""), _ => (" 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![ err.highlighted_help(vec![
StringPart::normal(format!("the trait `{}` ", cand.print_trait_sugared())), StringPart::normal(format!("the trait `{trait_}` ",)),
StringPart::highlighted("is"), StringPart::highlighted("is"),
StringPart::normal(desc), StringPart::normal(desc),
StringPart::highlighted(cand.self_ty().to_string()), StringPart::highlighted(self_ty),
StringPart::normal("`"), StringPart::normal("`"),
StringPart::normal(mention_castable), StringPart::normal(mention_castable),
]); ]);
@ -2159,9 +2192,13 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
.into_iter() .into_iter()
.map(|c| { .map(|c| {
if all_traits_equal { if all_traits_equal {
format!("\n {}", c.self_ty()) format!("\n {}", self.tcx.short_string(c.self_ty(), err.long_ty_path()))
} else { } 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(); .collect();
@ -2477,7 +2514,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
predicate_constness: Option<ty::BoundConstness>, predicate_constness: Option<ty::BoundConstness>,
append_const_msg: Option<AppendConstMessage>, append_const_msg: Option<AppendConstMessage>,
post_message: String, post_message: String,
long_ty_file: &mut Option<PathBuf>, long_ty_path: &mut Option<PathBuf>,
) -> String { ) -> String {
message message
.and_then(|cannot_do_this| { .and_then(|cannot_do_this| {
@ -2503,7 +2540,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
"the trait bound `{}` is not satisfied{post_message}", "the trait bound `{}` is not satisfied{post_message}",
self.tcx.short_string( self.tcx.short_string(
trait_predicate.print_with_bound_constness(predicate_constness), trait_predicate.print_with_bound_constness(predicate_constness),
long_ty_file, long_ty_path,
), ),
) )
}) })
@ -2608,8 +2645,8 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
dst_min_align, dst_min_align,
} => { } => {
format!( format!(
"the minimum alignment of `{src}` ({src_min_align}) should \ "the minimum alignment of `{src}` ({src_min_align}) should be \
be greater than that of `{dst}` ({dst_min_align})" greater than that of `{dst}` ({dst_min_align})"
) )
} }
rustc_transmute::Reason::DstIsMoreUnique => { rustc_transmute::Reason::DstIsMoreUnique => {

View file

@ -99,7 +99,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
&self, &self,
trait_pred: ty::PolyTraitPredicate<'tcx>, trait_pred: ty::PolyTraitPredicate<'tcx>,
obligation: &PredicateObligation<'tcx>, obligation: &PredicateObligation<'tcx>,
long_ty_file: &mut Option<PathBuf>, long_ty_path: &mut Option<PathBuf>,
) -> OnUnimplementedNote { ) -> OnUnimplementedNote {
if trait_pred.polarity() != ty::PredicatePolarity::Positive { if trait_pred.polarity() != ty::PredicatePolarity::Positive {
return OnUnimplementedNote::default(); return OnUnimplementedNote::default();
@ -281,7 +281,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
GenericParamDefKind::Type { .. } | GenericParamDefKind::Const { .. } => { GenericParamDefKind::Type { .. } | GenericParamDefKind::Const { .. } => {
if let Some(ty) = trait_pred.trait_ref.args[param.index as usize].as_type() 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 { } else {
trait_pred.trait_ref.args[param.index as usize].to_string() trait_pred.trait_ref.args[param.index as usize].to_string()
} }

View file

@ -3,6 +3,7 @@
use std::assert_matches::debug_assert_matches; use std::assert_matches::debug_assert_matches;
use std::borrow::Cow; use std::borrow::Cow;
use std::iter; use std::iter;
use std::path::PathBuf;
use itertools::{EitherOrBoth, Itertools}; use itertools::{EitherOrBoth, Itertools};
use rustc_abi::ExternAbi; use rustc_abi::ExternAbi;
@ -1369,6 +1370,10 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
); );
let self_ty_str = let self_ty_str =
self.tcx.short_string(old_pred.self_ty().skip_binder(), err.long_ty_path()); 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 { if has_custom_message {
err.note(msg); err.note(msg);
} else { } else {
@ -1376,10 +1381,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
} }
err.span_label( err.span_label(
span, span,
format!( format!("the trait `{trait_path}` is not implemented for `{self_ty_str}`"),
"the trait `{}` is not implemented for `{self_ty_str}`",
old_pred.print_modifiers_and_trait_path()
),
); );
}; };
@ -3333,17 +3335,22 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
tcx.async_fn_trait_kind_from_def_id(data.parent_trait_pred.def_id()).is_some(); 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 { if !is_upvar_tys_infer_tuple && !is_builtin_async_fn_trait {
let ty_str = tcx.short_string(ty, err.long_ty_path()); let mut msg = || {
let msg = format!("required because it appears within the type `{ty_str}`"); let ty_str = tcx.short_string(ty, err.long_ty_path());
format!("required because it appears within the type `{ty_str}`")
};
match ty.kind() { match ty.kind() {
ty::Adt(def, _) => match tcx.opt_item_ident(def.did()) { ty::Adt(def, _) => {
Some(ident) => { let msg = msg();
err.span_note(ident.span, msg); match tcx.opt_item_ident(def.did()) {
Some(ident) => {
err.span_note(ident.span, msg);
}
None => {
err.note(msg);
}
} }
None => { }
err.note(msg);
}
},
ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) => { 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. // 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). // Avoid printing it twice (it was already printed in the `ty::Coroutine` arm below).
@ -3363,6 +3370,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
{ {
// See comment above; skip printing twice. // See comment above; skip printing twice.
} else { } else {
let msg = msg();
err.span_note(tcx.def_span(def_id), msg); err.span_note(tcx.def_span(def_id), msg);
} }
} }
@ -3392,6 +3400,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
err.note("`str` is considered to contain a `[u8]` slice for auto trait purposes"); err.note("`str` is considered to contain a `[u8]` slice for auto trait purposes");
} }
_ => { _ => {
let msg = msg();
err.note(msg); err.note(msg);
} }
}; };
@ -3441,7 +3450,10 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
} }
let self_ty_str = let self_ty_str =
tcx.short_string(parent_trait_pred.skip_binder().self_ty(), err.long_ty_path()); 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 msg = format!("required for `{self_ty_str}` to implement `{trait_name}`");
let mut is_auto_trait = false; let mut is_auto_trait = false;
match tcx.hir_get_if_local(data.impl_or_alias_def_id) { match tcx.hir_get_if_local(data.impl_or_alias_def_id) {
@ -3539,10 +3551,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
parent_trait_pred.skip_binder().self_ty(), parent_trait_pred.skip_binder().self_ty(),
err.long_ty_path(), err.long_ty_path(),
); );
err.note(format!( let trait_path = tcx.short_string(
"required for `{self_ty}` to implement `{}`", parent_trait_pred.print_modifiers_and_trait_path(),
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 // #74711: avoid a stack overflow
ensure_sufficient_stack(|| { ensure_sufficient_stack(|| {
@ -3558,15 +3571,20 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
}); });
} }
ObligationCauseCode::ImplDerivedHost(ref data) => { ObligationCauseCode::ImplDerivedHost(ref data) => {
let self_ty = let self_ty = tcx.short_string(
self.resolve_vars_if_possible(data.derived.parent_host_pred.self_ty()); self.resolve_vars_if_possible(data.derived.parent_host_pred.self_ty()),
let msg = format!( err.long_ty_path(),
"required for `{self_ty}` to implement `{} {}`", );
data.derived.parent_host_pred.skip_binder().constness, let trait_path = tcx.short_string(
data.derived data.derived
.parent_host_pred .parent_host_pred
.map_bound(|pred| pred.trait_ref) .map_bound(|pred| pred.trait_ref)
.print_only_trait_path(), .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) { match tcx.hir_get_if_local(data.impl_def_id) {
Some(Node::Item(hir::Item { Some(Node::Item(hir::Item {
@ -5351,6 +5369,7 @@ pub(super) fn get_explanation_based_on_obligation<'tcx>(
obligation: &PredicateObligation<'tcx>, obligation: &PredicateObligation<'tcx>,
trait_predicate: ty::PolyTraitPredicate<'tcx>, trait_predicate: ty::PolyTraitPredicate<'tcx>,
pre_message: String, pre_message: String,
long_ty_path: &mut Option<PathBuf>,
) -> String { ) -> String {
if let ObligationCauseCode::MainFunctionType = obligation.cause.code() { if let ObligationCauseCode::MainFunctionType = obligation.cause.code() {
"consider using `()`, or a `Result`".to_owned() "consider using `()`, or a `Result`".to_owned()
@ -5369,7 +5388,7 @@ pub(super) fn get_explanation_based_on_obligation<'tcx>(
format!( format!(
"{pre_message}the trait `{}` is not implemented for{desc} `{}`", "{pre_message}the trait `{}` is not implemented for{desc} `{}`",
trait_predicate.print_modifiers_and_trait_path(), 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(), long_ty_path),
) )
} else { } else {
// "the trait bound `T: !Send` is not satisfied" reads better than "`!Send` is // "the trait bound `T: !Send` is not satisfied" reads better than "`!Send` is

View file

@ -1,5 +1,3 @@
use std::path::PathBuf;
use rustc_ast::Path; use rustc_ast::Path;
use rustc_data_structures::fx::{FxHashSet, FxIndexSet}; use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
use rustc_errors::codes::*; use rustc_errors::codes::*;
@ -224,9 +222,6 @@ pub struct AnnotationRequired<'a> {
pub infer_subdiags: Vec<SourceKindSubdiag<'a>>, pub infer_subdiags: Vec<SourceKindSubdiag<'a>>,
#[subdiagnostic] #[subdiagnostic]
pub multi_suggestions: Vec<SourceKindMultiSuggestion<'a>>, pub multi_suggestions: Vec<SourceKindMultiSuggestion<'a>>,
#[note(trait_selection_full_type_written)]
pub was_written: bool,
pub path: PathBuf,
} }
// Copy of `AnnotationRequired` for E0283 // Copy of `AnnotationRequired` for E0283
@ -245,9 +240,6 @@ pub struct AmbiguousImpl<'a> {
pub infer_subdiags: Vec<SourceKindSubdiag<'a>>, pub infer_subdiags: Vec<SourceKindSubdiag<'a>>,
#[subdiagnostic] #[subdiagnostic]
pub multi_suggestions: Vec<SourceKindMultiSuggestion<'a>>, pub multi_suggestions: Vec<SourceKindMultiSuggestion<'a>>,
#[note(trait_selection_full_type_written)]
pub was_written: bool,
pub path: PathBuf,
} }
// Copy of `AnnotationRequired` for E0284 // Copy of `AnnotationRequired` for E0284
@ -266,9 +258,6 @@ pub struct AmbiguousReturn<'a> {
pub infer_subdiags: Vec<SourceKindSubdiag<'a>>, pub infer_subdiags: Vec<SourceKindSubdiag<'a>>,
#[subdiagnostic] #[subdiagnostic]
pub multi_suggestions: Vec<SourceKindMultiSuggestion<'a>>, pub multi_suggestions: Vec<SourceKindMultiSuggestion<'a>>,
#[note(trait_selection_full_type_written)]
pub was_written: bool,
pub path: PathBuf,
} }
// Used when a better one isn't available // Used when a better one isn't available

View file

@ -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<T, A>` in the current scope
--> $DIR/rustc_confusables_std_cases.rs:6:7 --> $DIR/rustc_confusables_std_cases.rs:6:7
| |
LL | x.push(1); LL | x.push(1);
@ -22,7 +22,7 @@ LL - x.push_back(1);
LL + x.push(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<T, A>` in the current scope
--> $DIR/rustc_confusables_std_cases.rs:12:7 --> $DIR/rustc_confusables_std_cases.rs:12:7
| |
LL | x.push(1); LL | x.push(1);
@ -35,7 +35,7 @@ LL | let mut x = Vec::new();
| ^^^^^ `x` of type `Vec<_>` that has method `push` defined earlier here | ^^^^^ `x` of type `Vec<_>` that has method `push` defined earlier here
... ...
LL | let mut x = VecDeque::new(); 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` help: you might have meant to use `push_back`
| |
LL | x.push_back(1); LL | x.push_back(1);

View file

@ -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 //@ build-fail
//@ compile-flags: -Zwrite-long-types-to-disk=yes
#![recursion_limit = "32"] #![recursion_limit = "32"]

View file

@ -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`) = help: consider increasing the recursion limit by adding a `#![recursion_limit = "64"]` attribute to your crate (`overflow_during_mono`)
= note: required for `Filter<std::array::IntoIter<i32, 11>, {closure@$DIR/overflow-during-mono.rs:13:41: 13:44}>` to implement `Iterator` = note: required for `Filter<IntoIter<i32, 11>, {closure@overflow-during-mono.rs:14:41}>` to implement `Iterator`
= note: 31 redundant requirements hidden = note: 31 redundant requirements hidden
= note: required for `Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<std::array::IntoIter<i32, 11>, {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<Filter<Filter<Filter<Filter<..., ...>, ...>, ...>, ...>, ...>` to implement `Iterator`
= note: required for `Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<Filter<std::array::IntoIter<i32, 11>, {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<Filter<Filter<Filter<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 error: aborting due to 1 previous error

View file

@ -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<F>` in the current scope
--> $DIR/issue-18343.rs:7:7 --> $DIR/issue-18343.rs:7:7
| |
LL | struct Obj<F> where F: FnMut() -> u32 { LL | struct Obj<F> where F: FnMut() -> u32 {

View file

@ -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<F>` in the current scope
--> $DIR/issue-2392.rs:36:15 --> $DIR/issue-2392.rs:36:15
| |
LL | struct Obj<F> where F: FnOnce() -> u32 { LL | struct Obj<F> 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)(); LL | (o_closure.closure)();
| + + | + +
error[E0599]: no method named `not_closure` found for struct `Obj` in the current scope error[E0599]: no method named `not_closure` found for struct `Obj<F>` in the current scope
--> $DIR/issue-2392.rs:38:15 --> $DIR/issue-2392.rs:38:15
| |
LL | struct Obj<F> where F: FnOnce() -> u32 { LL | struct Obj<F> where F: FnOnce() -> u32 {
@ -23,7 +23,7 @@ LL | o_closure.not_closure();
| | | |
| field, not a method | field, not a method
error[E0599]: no method named `closure` found for struct `Obj` in the current scope error[E0599]: no method named `closure` found for struct `Obj<F>` in the current scope
--> $DIR/issue-2392.rs:42:12 --> $DIR/issue-2392.rs:42:12
| |
LL | struct Obj<F> where F: FnOnce() -> u32 { LL | struct Obj<F> 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)(); LL | (boxed_closure.boxed_closure)();
| + + | + +
error[E0599]: no method named `closure` found for struct `Obj` in the current scope error[E0599]: no method named `closure` found for struct `Obj<F>` in the current scope
--> $DIR/issue-2392.rs:53:12 --> $DIR/issue-2392.rs:53:12
| |
LL | struct Obj<F> where F: FnOnce() -> u32 { LL | struct Obj<F> 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)(); LL | (w.wrap.closure)();
| + + | + +
error[E0599]: no method named `not_closure` found for struct `Obj` in the current scope error[E0599]: no method named `not_closure` found for struct `Obj<F>` in the current scope
--> $DIR/issue-2392.rs:55:12 --> $DIR/issue-2392.rs:55:12
| |
LL | struct Obj<F> where F: FnOnce() -> u32 { LL | struct Obj<F> where F: FnOnce() -> u32 {
@ -90,7 +90,7 @@ LL | w.wrap.not_closure();
| | | |
| field, not a method | field, not a method
error[E0599]: no method named `closure` found for struct `Obj` in the current scope error[E0599]: no method named `closure` found for struct `Obj<F>` in the current scope
--> $DIR/issue-2392.rs:58:24 --> $DIR/issue-2392.rs:58:24
| |
LL | struct Obj<F> where F: FnOnce() -> u32 { LL | struct Obj<F> where F: FnOnce() -> u32 {

View file

@ -43,7 +43,7 @@ help: consider introducing lifetime `'a` here
LL | impl<'a> Trait for Z { 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 --> $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>); LL | pub struct InvariantRef<'a, T: ?Sized>(&'a T, PhantomData<&'a mut &'a T>);

View file

@ -1,5 +1,6 @@
// Issue 22443: Reject code using non-regular types that would // Issue 22443: Reject code using non-regular types that would
// otherwise cause dropck to loop infinitely. // otherwise cause dropck to loop infinitely.
//@ compile-flags: -Zwrite-long-types-to-disk=yes
use std::marker::PhantomData; use std::marker::PhantomData;

View file

@ -1,10 +1,12 @@
error[E0320]: overflow while adding drop-check rules for `FingerTree<i32>` error[E0320]: overflow while adding drop-check rules for `FingerTree<i32>`
--> $DIR/dropck_no_diverge_on_nonregular_1.rs:24:9 --> $DIR/dropck_no_diverge_on_nonregular_1.rs:25:9
| |
LL | let ft = LL | let ft =
| ^^ | ^^
| |
= note: overflowed on `FingerTree<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<Node<i32>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` = note: overflowed on `FingerTree<Node<Node<Node<Node<Node<Node<Node<Node<Node<...>>>>>>>>>>`
= 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 error: aborting due to 1 previous error

View file

@ -5,7 +5,7 @@ LL | true => Default::default(),
| ^^^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `!` | ^^^^^^^^^^^^^^^^^^ 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 <https://github.com/rust-lang/rust/issues/48950> for more information) = note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 <https://github.com/rust-lang/rust/issues/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 error[E0277]: the trait bound `!: Default` is not satisfied
--> $DIR/never-type-fallback-breaking.rs:37:5 --> $DIR/never-type-fallback-breaking.rs:37:5
@ -14,7 +14,7 @@ LL | deserialize()?;
| ^^^^^^^^^^^^^ the trait `Default` is not implemented for `!` | ^^^^^^^^^^^^^ 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 <https://github.com/rust-lang/rust/issues/48950> for more information) = note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 <https://github.com/rust-lang/rust/issues/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` note: required by a bound in `deserialize`
--> $DIR/never-type-fallback-breaking.rs:33:23 --> $DIR/never-type-fallback-breaking.rs:33:23
| |
@ -51,7 +51,7 @@ LL | takes_apit(|| Default::default())?;
| ^^^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `!` | ^^^^^^^^^^^^^^^^^^ 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 <https://github.com/rust-lang/rust/issues/48950> for more information) = note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 <https://github.com/rust-lang/rust/issues/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 error[E0277]: the trait bound `!: Default` is not satisfied
--> $DIR/never-type-fallback-breaking.rs:76:17 --> $DIR/never-type-fallback-breaking.rs:76:17
@ -62,7 +62,7 @@ LL | takes_apit2(mk()?);
| required by a bound introduced by this call | 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 <https://github.com/rust-lang/rust/issues/48950> for more information) = note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 <https://github.com/rust-lang/rust/issues/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` note: required by a bound in `takes_apit2`
--> $DIR/never-type-fallback-breaking.rs:71:25 --> $DIR/never-type-fallback-breaking.rs:71:25
| |

View file

@ -1,3 +1,4 @@
//@ compile-flags: -Zwrite-long-types-to-disk=yes
trait Foo {} trait Foo {}
struct Bar<T>(T); struct Bar<T>(T);

View file

@ -1,17 +1,19 @@
error[E0275]: overflow evaluating the requirement `Bar<Bar<Bar<Bar<Bar<Bar<Bar<...>>>>>>>: Foo` error[E0275]: overflow evaluating the requirement `Bar<Bar<Bar<Bar<Bar<Bar<Bar<...>>>>>>>: Foo`
--> $DIR/E0275.rs:5:33 --> $DIR/E0275.rs:6:33
| |
LL | impl<T> Foo for T where Bar<T>: Foo {} LL | impl<T> Foo for T where Bar<T>: Foo {}
| ^^^ | ^^^
| |
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`E0275`) = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`E0275`)
note: required for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` to implement `Foo` note: required for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<...>>>>>>>>>>>>>` to implement `Foo`
--> $DIR/E0275.rs:5:9 --> $DIR/E0275.rs:6:9
| |
LL | impl<T> Foo for T where Bar<T>: Foo {} LL | impl<T> Foo for T where Bar<T>: Foo {}
| ^^^ ^ --- unsatisfied trait bound introduced here | ^^^ ^ --- unsatisfied trait bound introduced here
= note: 126 redundant requirements hidden = note: 126 redundant requirements hidden
= note: required for `Bar<T>` to implement `Foo` = note: required for `Bar<T>` 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 error: aborting due to 1 previous error

View file

@ -6,6 +6,8 @@
// This tests double-checks that we do not allow such behavior to leak // This tests double-checks that we do not allow such behavior to leak
// through again. // through again.
//@ compile-flags: -Zwrite-long-types-to-disk=yes
pub trait Stream { pub trait Stream {
type Item; type Item;
fn next(self) -> Option<Self::Item>; fn next(self) -> Option<Self::Item>;

View file

@ -1,5 +1,5 @@
error[E0599]: the method `countx` exists for struct `Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, {closure@$DIR/hrtb-doesnt-borrow-self-2.rs:109:30: 109:37}>`, but its trait bounds were not satisfied error[E0599]: the method `countx` exists for struct `Filter<Map<Repeat, fn(&u64) -> &u64 {identity::<u64>}>, {closure@...}>`, but its trait bounds were not satisfied
--> $DIR/hrtb-doesnt-borrow-self-2.rs:110:24 --> $DIR/hrtb-doesnt-borrow-self-2.rs:112:24
| |
LL | pub struct Filter<S, F> { LL | pub struct Filter<S, F> {
| ----------------------- method `countx` not found for this struct because it doesn't satisfy `_: StreamExt` | ----------------------- 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 | ^^^^^^ method cannot be called due to unsatisfied trait bounds
| |
note: the following trait bounds were not satisfied: note: the following trait bounds were not satisfied:
`&'a mut &Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, {closure@$DIR/hrtb-doesnt-borrow-self-2.rs:109:30: 109:37}>: Stream` `&'a mut &Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, {closure@$DIR/hrtb-doesnt-borrow-self-2.rs:111:30: 111:37}>: Stream`
`&'a mut &mut Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, {closure@$DIR/hrtb-doesnt-borrow-self-2.rs:109:30: 109:37}>: Stream` `&'a mut &mut Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, {closure@$DIR/hrtb-doesnt-borrow-self-2.rs:111:30: 111:37}>: Stream`
`&'a mut Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, {closure@$DIR/hrtb-doesnt-borrow-self-2.rs:109:30: 109:37}>: Stream` `&'a mut Filter<Map<Repeat, for<'a> fn(&'a u64) -> &'a u64 {identity::<u64>}>, {closure@$DIR/hrtb-doesnt-borrow-self-2.rs:111:30: 111:37}>: Stream`
--> $DIR/hrtb-doesnt-borrow-self-2.rs:96:50 --> $DIR/hrtb-doesnt-borrow-self-2.rs:98:50
| |
LL | impl<T> StreamExt for T where for<'a> &'a mut T: Stream {} LL | impl<T> StreamExt for T where for<'a> &'a mut T: Stream {}
| --------- - ^^^^^^ unsatisfied trait bound introduced here | --------- - ^^^^^^ unsatisfied trait bound introduced here
= help: items from traits can only be used if the trait is implemented and in scope = 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 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 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 error: aborting due to 1 previous error

View file

@ -1,3 +1,4 @@
//@ compile-flags: -Zwrite-long-types-to-disk=yes
use std::cell::Cell; use std::cell::Cell;
use std::rc::Rc; use std::rc::Rc;

View file

@ -1,5 +1,5 @@
error[E0277]: `Rc<Cell<i32>>` cannot be sent between threads safely error[E0277]: `Rc<Cell<i32>>` cannot be sent between threads safely
--> $DIR/auto-trait-leak2.rs:20:10 --> $DIR/auto-trait-leak2.rs:21:10
| |
LL | fn before() -> impl Fn(i32) { LL | fn before() -> impl Fn(i32) {
| ------------ within this `impl Fn(i32)` | ------------ within this `impl Fn(i32)`
@ -11,23 +11,23 @@ LL | send(before());
| |
= help: within `impl Fn(i32)`, the trait `Send` is not implemented for `Rc<Cell<i32>>` = help: within `impl Fn(i32)`, the trait `Send` is not implemented for `Rc<Cell<i32>>`
note: required because it's used within this closure note: required because it's used within this closure
--> $DIR/auto-trait-leak2.rs:10:5 --> $DIR/auto-trait-leak2.rs:11:5
| |
LL | move |x| p.set(x) LL | move |x| p.set(x)
| ^^^^^^^^ | ^^^^^^^^
note: required because it appears within the type `impl Fn(i32)` note: required because it appears within the type `impl Fn(i32)`
--> $DIR/auto-trait-leak2.rs:5:16 --> $DIR/auto-trait-leak2.rs:6:16
| |
LL | fn before() -> impl Fn(i32) { LL | fn before() -> impl Fn(i32) {
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
note: required by a bound in `send` note: required by a bound in `send`
--> $DIR/auto-trait-leak2.rs:13:12 --> $DIR/auto-trait-leak2.rs:14:12
| |
LL | fn send<T: Send>(_: T) {} LL | fn send<T: Send>(_: T) {}
| ^^^^ required by this bound in `send` | ^^^^ required by this bound in `send`
error[E0277]: `Rc<Cell<i32>>` cannot be sent between threads safely error[E0277]: `Rc<Cell<i32>>` cannot be sent between threads safely
--> $DIR/auto-trait-leak2.rs:25:10 --> $DIR/auto-trait-leak2.rs:26:10
| |
LL | send(after()); LL | send(after());
| ---- ^^^^^^^ `Rc<Cell<i32>>` cannot be sent between threads safely | ---- ^^^^^^^ `Rc<Cell<i32>>` cannot be sent between threads safely
@ -39,17 +39,17 @@ LL | fn after() -> impl Fn(i32) {
| |
= help: within `impl Fn(i32)`, the trait `Send` is not implemented for `Rc<Cell<i32>>` = help: within `impl Fn(i32)`, the trait `Send` is not implemented for `Rc<Cell<i32>>`
note: required because it's used within this closure note: required because it's used within this closure
--> $DIR/auto-trait-leak2.rs:38:5 --> $DIR/auto-trait-leak2.rs:39:5
| |
LL | move |x| p.set(x) LL | move |x| p.set(x)
| ^^^^^^^^ | ^^^^^^^^
note: required because it appears within the type `impl Fn(i32)` note: required because it appears within the type `impl Fn(i32)`
--> $DIR/auto-trait-leak2.rs:33:15 --> $DIR/auto-trait-leak2.rs:34:15
| |
LL | fn after() -> impl Fn(i32) { LL | fn after() -> impl Fn(i32) {
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
note: required by a bound in `send` note: required by a bound in `send`
--> $DIR/auto-trait-leak2.rs:13:12 --> $DIR/auto-trait-leak2.rs:14:12
| |
LL | fn send<T: Send>(_: T) {} LL | fn send<T: Send>(_: T) {}
| ^^^^ required by this bound in `send` | ^^^^ required by this bound in `send`

View file

@ -1,3 +1,4 @@
//@ compile-flags: -Zwrite-long-types-to-disk=yes
type A = (i32, i32, i32, i32); type A = (i32, i32, i32, i32);
type B = (A, A, A, A); type B = (A, A, A, A);
type C = (B, B, B, B); type C = (B, B, B, B);

View file

@ -1,9 +1,11 @@
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))))>` error[E0282]: type annotations needed for `Result<_, (((..., ..., ..., ...), ..., ..., ...), ..., ..., ...)>`
--> $DIR/really-long-type-in-let-binding-without-sufficient-type-info.rs:7:9 --> $DIR/really-long-type-in-let-binding-without-sufficient-type-info.rs:8:9
| |
LL | let y = Err(x); LL | let y = Err(x);
| ^ ------ type must be known at this point | ^ ------ type must be known at this point
| |
= 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 help: consider giving `y` an explicit type, where the type for type parameter `T` is specified
| |
LL | let y: Result<T, _> = Err(x); LL | let y: Result<T, _> = Err(x);

View file

@ -1,3 +1,4 @@
//@ compile-flags: -Zwrite-long-types-to-disk=yes
use std::cell::Cell; use std::cell::Cell;
use std::panic::catch_unwind; use std::panic::catch_unwind;
fn main() { fn main() {

View file

@ -1,5 +1,5 @@
error[E0277]: the type `UnsafeCell<i32>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary error[E0277]: the type `UnsafeCell<i32>` 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:6:18
| |
LL | catch_unwind(|| { x.set(23); }); LL | catch_unwind(|| { x.set(23); });
| ------------ ^^^^^^^^^^^^^^^^^ `UnsafeCell<i32>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary | ------------ ^^^^^^^^^^^^^^^^^ `UnsafeCell<i32>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
@ -11,7 +11,7 @@ note: required because it appears within the type `Cell<i32>`
--> $SRC_DIR/core/src/cell.rs:LL:COL --> $SRC_DIR/core/src/cell.rs:LL:COL
= note: required for `&Cell<i32>` to implement `UnwindSafe` = note: required for `&Cell<i32>` to implement `UnwindSafe`
note: required because it's used within this closure note: required because it's used within this closure
--> $DIR/interior-mutability.rs:5:18 --> $DIR/interior-mutability.rs:6:18
| |
LL | catch_unwind(|| { x.set(23); }); LL | catch_unwind(|| { x.set(23); });
| ^^ | ^^

View file

@ -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<T, F>` in the current scope
--> $DIR/issue-41880.rs:27:24 --> $DIR/issue-41880.rs:27:24
| |
LL | pub struct Iterate<T, F> { LL | pub struct Iterate<T, F> {

View file

@ -44,5 +44,5 @@ fn main() {
// our resolution logic needs to be able to call methods such as foo() // our resolution logic needs to be able to call methods such as foo()
// on the outer type even if the inner type is ambiguous. // on the outer type even if the inner type is ambiguous.
let _c = (ptr as SmartPtr<_>).read(); let _c = (ptr as SmartPtr<_>).read();
//~^ ERROR no method named `read` found for struct `SmartPtr` //~^ ERROR no method named `read` found for struct `SmartPtr<T>`
} }

View file

@ -10,7 +10,7 @@ error[E0282]: type annotations needed
LL | let _b = (rc as std::rc::Rc<_>).read(); LL | let _b = (rc as std::rc::Rc<_>).read();
| ^^^^ cannot infer type | ^^^^ 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<T>` in the current scope
--> $DIR/call_method_unknown_referent.rs:46:35 --> $DIR/call_method_unknown_referent.rs:46:35
| |
LL | struct SmartPtr<T>(T); LL | struct SmartPtr<T>(T);

View file

@ -1,3 +1,4 @@
//@ compile-flags: -Zwrite-long-types-to-disk=yes
// Fixes #110131 // Fixes #110131
// //
// The issue is that we were constructing an `ImplDerived` cause code for the // The issue is that we were constructing an `ImplDerived` cause code for the

View file

@ -1,5 +1,5 @@
error[E0277]: `Helper<'a, T>` is not an iterator 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>; LL | type IntoIter = Helper<'a, T>;
| ^^^^^^^^^^^^^ `Helper<'a, T>` is not an iterator | ^^^^^^^^^^^^^ `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 --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
error[E0275]: overflow evaluating the requirement `&_: IntoIterator` 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) 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`) = 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` 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<T> LL | impl<'a, T> IntoIterator for &'a BitReaderWrapper<T>
| ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^
@ -24,15 +24,17 @@ LL | where
LL | &'a T: IntoIterator<Item = &'a u8>, LL | &'a T: IntoIterator<Item = &'a u8>,
| ------------- unsatisfied trait bound introduced here | ------------- unsatisfied trait bound introduced here
= note: 126 redundant requirements hidden = note: 126 redundant requirements hidden
= note: required for `&BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<_>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` to implement `IntoIterator` = note: required for `&BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<...>>>` to implement `IntoIterator`
note: required by a bound in `Helper` 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> LL | struct Helper<'a, T>
| ------ required by a bound in this struct | ------ required by a bound in this struct
LL | where LL | where
LL | &'a T: IntoIterator<Item = &'a u8>, LL | &'a T: IntoIterator<Item = &'a u8>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Helper` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 error: aborting due to 2 previous errors

View file

@ -10,7 +10,7 @@ LL | let d = point_i32.distance();
= note: the method was found for = note: the method was found for
- `Point<f64>` - `Point<f64>`
error[E0599]: no method named `other` found for struct `Point` in the current scope error[E0599]: no method named `other` found for struct `Point<T>` in the current scope
--> $DIR/method-not-found-generic-arg-elision.rs:84:23 --> $DIR/method-not-found-generic-arg-elision.rs:84:23
| |
LL | struct Point<T> { LL | struct Point<T> {
@ -19,7 +19,7 @@ LL | struct Point<T> {
LL | let d = point_i32.other(); LL | let d = point_i32.other();
| ^^^^^ method not found in `Point<i32>` | ^^^^^ method not found in `Point<i32>`
error[E0599]: no method named `extend` found for struct `Map` in the current scope error[E0599]: no method named `extend` found for struct `Map<I, F>` in the current scope
--> $DIR/method-not-found-generic-arg-elision.rs:87:67 --> $DIR/method-not-found-generic-arg-elision.rs:87:67
| |
LL | v.iter().map(Box::new(|x| x * x) as Box<dyn Fn(&i32) -> i32>).extend(std::iter::once(100)); LL | v.iter().map(Box::new(|x| x * x) as Box<dyn Fn(&i32) -> i32>).extend(std::iter::once(100));
@ -41,7 +41,7 @@ LL | wrapper.method();
- `Wrapper<i8>` - `Wrapper<i8>`
and 2 more types 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<T>` in the current scope
--> $DIR/method-not-found-generic-arg-elision.rs:92:13 --> $DIR/method-not-found-generic-arg-elision.rs:92:13
| |
LL | struct Wrapper<T>(T); LL | struct Wrapper<T>(T);
@ -64,7 +64,7 @@ LL | wrapper.method();
- `Wrapper2<'a, i32, C>` - `Wrapper2<'a, i32, C>`
- `Wrapper2<'a, i8, 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<'a, T, C>` in the current scope
--> $DIR/method-not-found-generic-arg-elision.rs:98:13 --> $DIR/method-not-found-generic-arg-elision.rs:98:13
| |
LL | struct Wrapper2<'a, T, const C: usize> { LL | struct Wrapper2<'a, T, const C: usize> {

View file

@ -1,3 +1,4 @@
//@ compile-flags: -Zwrite-long-types-to-disk=yes
use std::ops::Deref; use std::ops::Deref;
// Make sure that method probe error reporting doesn't get too tangled up // Make sure that method probe error reporting doesn't get too tangled up

View file

@ -1,13 +1,15 @@
error[E0055]: reached the recursion limit while auto-dereferencing `Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<{integer}>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` error[E0055]: reached the recursion limit while auto-dereferencing `Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<Wrap<...>>>>>>>>>>>`
--> $DIR/probe-error-on-infinite-deref.rs:13:13 --> $DIR/probe-error-on-infinite-deref.rs:14:13
| |
LL | Wrap(1).lmao(); LL | Wrap(1).lmao();
| ^^^^ deref recursion limit reached | ^^^^ 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`) = 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 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>(T); LL | struct Wrap<T>(T);
| -------------- method `lmao` not found for this struct | -------------- method `lmao` not found for this struct

View file

@ -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<T, E>` in the current scope
--> $DIR/untrimmed-path-type.rs:5:11 --> $DIR/untrimmed-path-type.rs:5:11
| |
LL | meow().unknown(); LL | meow().unknown();

View file

@ -8,7 +8,7 @@ LL | foo(_x);
| |
= help: the trait `ImplementedForUnitButNotNever` is implemented for `()` = 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 <https://github.com/rust-lang/rust/issues/48950> for more information) = note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 <https://github.com/rust-lang/rust/issues/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` note: required by a bound in `foo`
--> $DIR/defaulted-never-note.rs:25:11 --> $DIR/defaulted-never-note.rs:25:11
| |

View file

@ -35,7 +35,7 @@ fn smeg() {
//[fallback]~| HELP trait `ImplementedForUnitButNotNever` is implemented for `()` //[fallback]~| HELP trait `ImplementedForUnitButNotNever` is implemented for `()`
//[fallback]~| NOTE this error might have been caused //[fallback]~| NOTE this error might have been caused
//[fallback]~| NOTE required by a bound introduced by this call //[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() { fn main() {

View file

@ -10,7 +10,7 @@ LL | unconstrained_arg(return);
() ()
i32 i32
= note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 <https://github.com/rust-lang/rust/issues/48950> for more information) = note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 <https://github.com/rust-lang/rust/issues/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` note: required by a bound in `unconstrained_arg`
--> $DIR/diverging-fallback-no-leak.rs:12:25 --> $DIR/diverging-fallback-no-leak.rs:12:25
| |

View file

@ -1,3 +1,4 @@
//@ compile-flags: -Zwrite-long-types-to-disk=yes
trait Next { trait Next {
type Next: Next; type Next: Next;
} }

View file

@ -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` 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 = <GetNext<T::Next> as Next>::Next; LL | type Next = <GetNext<T::Next> as Next>::Next;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_23122_2`) = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_23122_2`)
note: required for `GetNext<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<T 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 as Next>::Next>` to implement `Next` note: required for `GetNext<<<<... as Next>::Next as Next>::Next as Next>::Next>` to implement `Next`
--> $DIR/issue-23122-2.rs:9:15 --> $DIR/issue-23122-2.rs:10:15
| |
LL | impl<T: Next> Next for GetNext<T> { LL | impl<T: Next> Next for GetNext<T> {
| - ^^^^ ^^^^^^^^^^ | - ^^^^ ^^^^^^^^^^
| | | |
| unsatisfied trait bound introduced here | 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 error: aborting due to 1 previous error

View file

@ -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 // `S` is infinitely recursing so it's not possible to generate a finite
// drop impl. // drop impl.
// //

View file

@ -1,10 +1,12 @@
error[E0320]: overflow while adding drop-check rules for `S<u32>` error[E0320]: overflow while adding drop-check rules for `S<u32>`
--> $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<u32>) {} LL | fn f(x: S<u32>) {}
| ^ | ^
| |
= note: overflowed on `S<fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(u32)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))>` = note: overflowed on `S<fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(fn(...))))))))))))))))>`
= 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 error: aborting due to 1 previous error

View file

@ -1,6 +1,6 @@
//~ ERROR overflow evaluating the requirement `Map<&mut std::ops::Range<u8>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>: Iterator` //~ ERROR overflow evaluating the requirement `Map<&mut std::ops::Range<u8>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>: Iterator`
//@ build-fail //@ build-fail
//@ compile-flags: -Copt-level=0 //@ compile-flags: -Copt-level=0 -Zwrite-long-types-to-disk=yes
fn main() { fn main() {
let mut iter = 0u8..1; let mut iter = 0u8..1;

View file

@ -13,9 +13,11 @@ LL | func(&mut iter.map(|x| x + 1))
error[E0275]: overflow evaluating the requirement `Map<&mut std::ops::Range<u8>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>: Iterator` error[E0275]: overflow evaluating the requirement `Map<&mut std::ops::Range<u8>, {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`) = 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<u8>, {closure@$DIR/issue-83150.rs:12:24: 12:27}>` to implement `Iterator` = note: required for `&mut Map<&mut Range<u8>, {closure@issue-83150.rs:12:24}>` to implement `Iterator`
= note: 65 redundant requirements hidden = 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<u8>, {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 error: aborting due to 1 previous error; 1 warning emitted

View file

@ -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`) = 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<T>` in the current scope
--> $DIR/arbitrary_self_type_infinite_recursion.rs:21:5 --> $DIR/arbitrary_self_type_infinite_recursion.rs:21:5
| |
LL | struct MySmartPtr<T>(T); LL | struct MySmartPtr<T>(T);

View file

@ -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<T>` in the current scope
--> $DIR/arbitrary_self_types_not_allow_call_with_no_deref.rs:29:17 --> $DIR/arbitrary_self_types_not_allow_call_with_no_deref.rs:29:17
| |
LL | struct CppRef<T>(T); LL | struct CppRef<T>(T);
@ -16,7 +16,7 @@ help: there is a method `frobnicate_cpp_ref` with a similar name
LL | foo_cpp_ref.frobnicate_cpp_ref(); 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<T>` in the current scope
--> $DIR/arbitrary_self_types_not_allow_call_with_no_deref.rs:32:17 --> $DIR/arbitrary_self_types_not_allow_call_with_no_deref.rs:32:17
| |
LL | struct CppRef<T>(T); LL | struct CppRef<T>(T);

View file

@ -9,5 +9,5 @@ impl S {
fn main() { fn main() {
Pin::new(S).x(); Pin::new(S).x();
//~^ ERROR the trait bound `S: Deref` is not satisfied //~^ 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<Ptr>` in the current scope
} }

View file

@ -15,7 +15,7 @@ LL | Pin::new(&S).x();
LL | Pin::new(&mut 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<Ptr>` in the current scope
--> $DIR/arbitrary_self_types_pin_needing_borrow.rs:10:17 --> $DIR/arbitrary_self_types_pin_needing_borrow.rs:10:17
| |
LL | Pin::new(S).x(); LL | Pin::new(S).x();

View file

@ -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<T, N>` in the current scope
--> $DIR/libm_no_std_cant_float.rs:15:17 --> $DIR/libm_no_std_cant_float.rs:15:17
| |
LL | let _xc = x.ceil(); LL | let _xc = x.ceil();
| ^^^^ method not found in `Simd<f32, 4>` | ^^^^ method not found in `Simd<f32, 4>`
error[E0599]: no method named `floor` found for struct `Simd` in the current scope error[E0599]: no method named `floor` found for struct `Simd<T, N>` in the current scope
--> $DIR/libm_no_std_cant_float.rs:16:17 --> $DIR/libm_no_std_cant_float.rs:16:17
| |
LL | let _xf = x.floor(); LL | let _xf = x.floor();
| ^^^^^ method not found in `Simd<f32, 4>` | ^^^^^ method not found in `Simd<f32, 4>`
error[E0599]: no method named `round` found for struct `Simd` in the current scope error[E0599]: no method named `round` found for struct `Simd<T, N>` in the current scope
--> $DIR/libm_no_std_cant_float.rs:17:17 --> $DIR/libm_no_std_cant_float.rs:17:17
| |
LL | let _xr = x.round(); LL | let _xr = x.round();
| ^^^^^ method not found in `Simd<f32, 4>` | ^^^^^ method not found in `Simd<f32, 4>`
error[E0599]: no method named `trunc` found for struct `Simd` in the current scope error[E0599]: no method named `trunc` found for struct `Simd<T, N>` in the current scope
--> $DIR/libm_no_std_cant_float.rs:18:17 --> $DIR/libm_no_std_cant_float.rs:18:17
| |
LL | let _xt = x.trunc(); LL | let _xt = x.trunc();
| ^^^^^ method not found in `Simd<f32, 4>` | ^^^^^ method not found in `Simd<f32, 4>`
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<T, N>` in the current scope
--> $DIR/libm_no_std_cant_float.rs:19:19 --> $DIR/libm_no_std_cant_float.rs:19:19
| |
LL | let _xfma = x.mul_add(x, x); LL | let _xfma = x.mul_add(x, x);
| ^^^^^^^ method not found in `Simd<f32, 4>` | ^^^^^^^ method not found in `Simd<f32, 4>`
error[E0599]: no method named `sqrt` found for struct `Simd` in the current scope error[E0599]: no method named `sqrt` found for struct `Simd<T, N>` in the current scope
--> $DIR/libm_no_std_cant_float.rs:20:20 --> $DIR/libm_no_std_cant_float.rs:20:20
| |
LL | let _xsqrt = x.sqrt(); LL | let _xsqrt = x.sqrt();

View file

@ -14,7 +14,7 @@ impl Foo {
fn test_result_in_result() -> Result<(), ()> { fn test_result_in_result() -> Result<(), ()> {
let res: Result<_, ()> = Ok(Foo); let res: Result<_, ()> = Ok(Foo);
res?.get(); res?.get();
//~^ ERROR no method named `get` found for enum `Result` in the current scope //~^ ERROR no method named `get` found for enum `Result<T, E>` in the current scope
//~| HELP use the `?` operator //~| HELP use the `?` operator
Ok(()) Ok(())
} }
@ -22,7 +22,7 @@ fn test_result_in_result() -> Result<(), ()> {
async fn async_test_result_in_result() -> Result<(), ()> { async fn async_test_result_in_result() -> Result<(), ()> {
let res: Result<_, ()> = Ok(Foo); let res: Result<_, ()> = Ok(Foo);
res?.get(); res?.get();
//~^ ERROR no method named `get` found for enum `Result` in the current scope //~^ ERROR no method named `get` found for enum `Result<T, E>` in the current scope
//~| HELP use the `?` operator //~| HELP use the `?` operator
Ok(()) Ok(())
} }
@ -30,21 +30,21 @@ async fn async_test_result_in_result() -> Result<(), ()> {
fn test_result_in_unit_return() { fn test_result_in_unit_return() {
let res: Result<_, ()> = Ok(Foo); let res: Result<_, ()> = Ok(Foo);
res.expect("REASON").get(); 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<T, E>` in the current scope
//~| HELP consider using `Result::expect` to unwrap the `Foo` value, panicking if the value is a `Result::Err` //~| 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() { async fn async_test_result_in_unit_return() {
let res: Result<_, ()> = Ok(Foo); let res: Result<_, ()> = Ok(Foo);
res.expect("REASON").get(); 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<T, E>` in the current scope
//~| HELP consider using `Result::expect` to unwrap the `Foo` value, panicking if the value is a `Result::Err` //~| HELP consider using `Result::expect` to unwrap the `Foo` value, panicking if the value is a `Result::Err`
} }
fn test_option_in_option() -> Option<()> { fn test_option_in_option() -> Option<()> {
let res: Option<_> = Some(Foo); let res: Option<_> = Some(Foo);
res?.get(); res?.get();
//~^ ERROR no method named `get` found for enum `Option` in the current scope //~^ ERROR no method named `get` found for enum `Option<T>` in the current scope
//~| HELP use the `?` operator //~| HELP use the `?` operator
Some(()) Some(())
} }
@ -52,7 +52,7 @@ fn test_option_in_option() -> Option<()> {
fn test_option_in_unit_return() { fn test_option_in_unit_return() {
let res: Option<_> = Some(Foo); let res: Option<_> = Some(Foo);
res.expect("REASON").get(); 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<T>` in the current scope
//~| HELP consider using `Option::expect` to unwrap the `Foo` value, panicking if the value is an `Option::None` //~| HELP consider using `Option::expect` to unwrap the `Foo` value, panicking if the value is an `Option::None`
} }

View file

@ -14,7 +14,7 @@ impl Foo {
fn test_result_in_result() -> Result<(), ()> { fn test_result_in_result() -> Result<(), ()> {
let res: Result<_, ()> = Ok(Foo); let res: Result<_, ()> = Ok(Foo);
res.get(); res.get();
//~^ ERROR no method named `get` found for enum `Result` in the current scope //~^ ERROR no method named `get` found for enum `Result<T, E>` in the current scope
//~| HELP use the `?` operator //~| HELP use the `?` operator
Ok(()) Ok(())
} }
@ -22,7 +22,7 @@ fn test_result_in_result() -> Result<(), ()> {
async fn async_test_result_in_result() -> Result<(), ()> { async fn async_test_result_in_result() -> Result<(), ()> {
let res: Result<_, ()> = Ok(Foo); let res: Result<_, ()> = Ok(Foo);
res.get(); res.get();
//~^ ERROR no method named `get` found for enum `Result` in the current scope //~^ ERROR no method named `get` found for enum `Result<T, E>` in the current scope
//~| HELP use the `?` operator //~| HELP use the `?` operator
Ok(()) Ok(())
} }
@ -30,21 +30,21 @@ async fn async_test_result_in_result() -> Result<(), ()> {
fn test_result_in_unit_return() { fn test_result_in_unit_return() {
let res: Result<_, ()> = Ok(Foo); let res: Result<_, ()> = Ok(Foo);
res.get(); res.get();
//~^ ERROR no method named `get` found for enum `Result` in the current scope //~^ ERROR no method named `get` found for enum `Result<T, E>` in the current scope
//~| HELP consider using `Result::expect` to unwrap the `Foo` value, panicking if the value is a `Result::Err` //~| 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() { async fn async_test_result_in_unit_return() {
let res: Result<_, ()> = Ok(Foo); let res: Result<_, ()> = Ok(Foo);
res.get(); res.get();
//~^ ERROR no method named `get` found for enum `Result` in the current scope //~^ ERROR no method named `get` found for enum `Result<T, E>` in the current scope
//~| HELP consider using `Result::expect` to unwrap the `Foo` value, panicking if the value is a `Result::Err` //~| HELP consider using `Result::expect` to unwrap the `Foo` value, panicking if the value is a `Result::Err`
} }
fn test_option_in_option() -> Option<()> { fn test_option_in_option() -> Option<()> {
let res: Option<_> = Some(Foo); let res: Option<_> = Some(Foo);
res.get(); res.get();
//~^ ERROR no method named `get` found for enum `Option` in the current scope //~^ ERROR no method named `get` found for enum `Option<T>` in the current scope
//~| HELP use the `?` operator //~| HELP use the `?` operator
Some(()) Some(())
} }
@ -52,7 +52,7 @@ fn test_option_in_option() -> Option<()> {
fn test_option_in_unit_return() { fn test_option_in_unit_return() {
let res: Option<_> = Some(Foo); let res: Option<_> = Some(Foo);
res.get(); res.get();
//~^ ERROR no method named `get` found for enum `Option` in the current scope //~^ ERROR no method named `get` found for enum `Option<T>` in the current scope
//~| HELP consider using `Option::expect` to unwrap the `Foo` value, panicking if the value is an `Option::None` //~| HELP consider using `Option::expect` to unwrap the `Foo` value, panicking if the value is an `Option::None`
} }

View file

@ -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<T, E>` in the current scope
--> $DIR/enum-method-probe.rs:24:9 --> $DIR/enum-method-probe.rs:24:9
| |
LL | res.get(); LL | res.get();
@ -14,7 +14,7 @@ help: use the `?` operator to extract the `Foo` value, propagating a `Result::Er
LL | res?.get(); 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<T, E>` in the current scope
--> $DIR/enum-method-probe.rs:39:9 --> $DIR/enum-method-probe.rs:39:9
| |
LL | res.get(); 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(); 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<T, E>` in the current scope
--> $DIR/enum-method-probe.rs:16:9 --> $DIR/enum-method-probe.rs:16:9
| |
LL | res.get(); LL | res.get();
@ -46,7 +46,7 @@ help: use the `?` operator to extract the `Foo` value, propagating a `Result::Er
LL | res?.get(); 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<T, E>` in the current scope
--> $DIR/enum-method-probe.rs:32:9 --> $DIR/enum-method-probe.rs:32:9
| |
LL | res.get(); 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(); 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<T>` in the current scope
--> $DIR/enum-method-probe.rs:46:9 --> $DIR/enum-method-probe.rs:46:9
| |
LL | res.get(); LL | res.get();
@ -78,7 +78,7 @@ help: use the `?` operator to extract the `Foo` value, propagating an `Option::N
LL | res?.get(); 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<T>` in the current scope
--> $DIR/enum-method-probe.rs:54:9 --> $DIR/enum-method-probe.rs:54:9
| |
LL | res.get(); LL | res.get();

View file

@ -17,7 +17,7 @@ struct InferOk<T> {
fn foo(i: InferOk<Ty>) { fn foo(i: InferOk<Ty>) {
let k = i.kind(); 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<T>` in the current scope
} }
fn main() {} fn main() {}

View file

@ -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<T>` in the current scope
--> $DIR/field-has-method.rs:19:15 --> $DIR/field-has-method.rs:19:15
| |
LL | struct InferOk<T> { LL | struct InferOk<T> {

View file

@ -15,26 +15,26 @@ fn main() {
let other_item = std::cell::RefCell::new(Struct { p: 42_u32 }); let other_item = std::cell::RefCell::new(Struct { p: 42_u32 });
other_item.borrow().method(); 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<T>` in the current scope [E0599]
//~| HELP use `.borrow()` to borrow the `Struct<u32>`, panicking if a mutable borrow exists //~| HELP use `.borrow()` to borrow the `Struct<u32>`, panicking if a mutable borrow exists
other_item.borrow_mut().some_mutable_method(); 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<T>` in the current scope [E0599]
//~| HELP .borrow_mut()` to mutably borrow the `Struct<u32>`, panicking if any borrows exist //~| HELP .borrow_mut()` to mutably borrow the `Struct<u32>`, panicking if any borrows exist
let another_item = std::sync::Mutex::new(Struct { p: 42_u32 }); let another_item = std::sync::Mutex::new(Struct { p: 42_u32 });
another_item.lock().unwrap().method(); 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<T>` in the current scope [E0599]
//~| HELP use `.lock().unwrap()` to borrow the `Struct<u32>`, blocking the current thread until it can be acquired //~| HELP use `.lock().unwrap()` to borrow the `Struct<u32>`, blocking the current thread until it can be acquired
let another_item = std::sync::RwLock::new(Struct { p: 42_u32 }); let another_item = std::sync::RwLock::new(Struct { p: 42_u32 });
another_item.read().unwrap().method(); 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<T>` in the current scope [E0599]
//~| HELP use `.read().unwrap()` to borrow the `Struct<u32>`, blocking the current thread until it can be acquired //~| HELP use `.read().unwrap()` to borrow the `Struct<u32>`, blocking the current thread until it can be acquired
another_item.write().unwrap().some_mutable_method(); 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<T>` in the current scope [E0599]
//~| HELP use `.write().unwrap()` to mutably borrow the `Struct<u32>`, blocking the current thread until it can be acquired //~| HELP use `.write().unwrap()` to mutably borrow the `Struct<u32>`, blocking the current thread until it can be acquired
} }

View file

@ -15,26 +15,26 @@ fn main() {
let other_item = std::cell::RefCell::new(Struct { p: 42_u32 }); let other_item = std::cell::RefCell::new(Struct { p: 42_u32 });
other_item.method(); 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<T>` in the current scope [E0599]
//~| HELP use `.borrow()` to borrow the `Struct<u32>`, panicking if a mutable borrow exists //~| HELP use `.borrow()` to borrow the `Struct<u32>`, panicking if a mutable borrow exists
other_item.some_mutable_method(); 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<T>` in the current scope [E0599]
//~| HELP .borrow_mut()` to mutably borrow the `Struct<u32>`, panicking if any borrows exist //~| HELP .borrow_mut()` to mutably borrow the `Struct<u32>`, panicking if any borrows exist
let another_item = std::sync::Mutex::new(Struct { p: 42_u32 }); let another_item = std::sync::Mutex::new(Struct { p: 42_u32 });
another_item.method(); 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<T>` in the current scope [E0599]
//~| HELP use `.lock().unwrap()` to borrow the `Struct<u32>`, blocking the current thread until it can be acquired //~| HELP use `.lock().unwrap()` to borrow the `Struct<u32>`, blocking the current thread until it can be acquired
let another_item = std::sync::RwLock::new(Struct { p: 42_u32 }); let another_item = std::sync::RwLock::new(Struct { p: 42_u32 });
another_item.method(); 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<T>` in the current scope [E0599]
//~| HELP use `.read().unwrap()` to borrow the `Struct<u32>`, blocking the current thread until it can be acquired //~| HELP use `.read().unwrap()` to borrow the `Struct<u32>`, blocking the current thread until it can be acquired
another_item.some_mutable_method(); 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<T>` in the current scope [E0599]
//~| HELP use `.write().unwrap()` to mutably borrow the `Struct<u32>`, blocking the current thread until it can be acquired //~| HELP use `.write().unwrap()` to mutably borrow the `Struct<u32>`, blocking the current thread until it can be acquired
} }

View file

@ -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<T>` in the current scope
--> $DIR/inner_type.rs:17:16 --> $DIR/inner_type.rs:17:16
| |
LL | other_item.method(); LL | other_item.method();
@ -14,7 +14,7 @@ help: use `.borrow()` to borrow the `Struct<u32>`, panicking if a mutable borrow
LL | other_item.borrow().method(); 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<T>` in the current scope
--> $DIR/inner_type.rs:21:16 --> $DIR/inner_type.rs:21:16
| |
LL | other_item.some_mutable_method(); LL | other_item.some_mutable_method();
@ -30,7 +30,7 @@ help: use `.borrow_mut()` to mutably borrow the `Struct<u32>`, panicking if any
LL | other_item.borrow_mut().some_mutable_method(); 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<T>` in the current scope
--> $DIR/inner_type.rs:27:18 --> $DIR/inner_type.rs:27:18
| |
LL | another_item.method(); LL | another_item.method();
@ -46,7 +46,7 @@ help: use `.lock().unwrap()` to borrow the `Struct<u32>`, blocking the current t
LL | another_item.lock().unwrap().method(); 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<T>` in the current scope
--> $DIR/inner_type.rs:33:18 --> $DIR/inner_type.rs:33:18
| |
LL | another_item.method(); LL | another_item.method();
@ -62,7 +62,7 @@ help: use `.read().unwrap()` to borrow the `Struct<u32>`, blocking the current t
LL | another_item.read().unwrap().method(); 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<T>` in the current scope
--> $DIR/inner_type.rs:37:18 --> $DIR/inner_type.rs:37:18
| |
LL | another_item.some_mutable_method(); LL | another_item.some_mutable_method();

View file

@ -16,11 +16,11 @@ thread_local! {
fn main() { fn main() {
STRUCT.method(); 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<T>` in the current scope [E0599]
//~| HELP use `with` or `try_with` to access thread local storage //~| HELP use `with` or `try_with` to access thread local storage
let item = std::mem::MaybeUninit::new(Struct { p: 42_u32 }); let item = std::mem::MaybeUninit::new(Struct { p: 42_u32 });
item.method(); 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<T>` in the current scope [E0599]
//~| HELP if this `MaybeUninit<Struct<u32>>` has been initialized, use one of the `assume_init` methods to access the inner value //~| HELP if this `MaybeUninit<Struct<u32>>` has been initialized, use one of the `assume_init` methods to access the inner value
} }

View file

@ -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<T>` in the current scope
--> $DIR/inner_type2.rs:18:12 --> $DIR/inner_type2.rs:18:12
| |
LL | STRUCT.method(); LL | STRUCT.method();
@ -11,7 +11,7 @@ note: the method `method` exists on the type `Struct<u32>`
LL | pub fn method(&self) {} 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<T>` in the current scope
--> $DIR/inner_type2.rs:23:10 --> $DIR/inner_type2.rs:23:10
| |
LL | item.method(); LL | item.method();

View file

@ -1,6 +1,6 @@
//~ ERROR overflow evaluating the requirement `<std::iter::Empty<()> as Iterator>::Item == ()` //~ ERROR overflow evaluating the requirement `<std::iter::Empty<()> as Iterator>::Item == ()`
//@ build-fail //@ build-fail
//@ compile-flags: -Zinline-mir=no //@ compile-flags: -Zinline-mir=no -Zwrite-long-types-to-disk=yes
// Regression test for #91949. // Regression test for #91949.
// This hanged *forever* on 1.56, fixed by #90423. // This hanged *forever* on 1.56, fixed by #90423.

File diff suppressed because one or more lines are too long