diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 9bb1a6a2b140e..93aa516557c05 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -505,6 +505,7 @@ pub enum StashKey { CallAssocMethod, TraitMissingMethod, OpaqueHiddenTypeMismatch, + MaybeForgetReturn, } fn default_track_diagnostic(d: &mut Diagnostic, f: &mut dyn FnMut(&mut Diagnostic)) { diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index 28fe2e062e589..3e2e6a7e4a3a7 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -580,6 +580,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if !errors.is_empty() { self.adjust_fulfillment_errors_for_expr_obligation(&mut errors); self.err_ctxt().report_fulfillment_errors(&errors); + self.collect_unused_for_coerce_return_ty(&mut errors); } } diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs index 4def78673841c..0e7bbe144ffca 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs @@ -11,7 +11,7 @@ use crate::{ use rustc_ast as ast; use rustc_data_structures::fx::FxIndexSet; use rustc_errors::{ - pluralize, Applicability, Diagnostic, DiagnosticId, ErrorGuaranteed, MultiSpan, + pluralize, Applicability, Diagnostic, DiagnosticId, ErrorGuaranteed, MultiSpan, StashKey, }; use rustc_hir as hir; use rustc_hir::def::{CtorOf, DefKind, Res}; @@ -26,6 +26,7 @@ use rustc_infer::infer::error_reporting::{FailureCode, ObligationCauseExt}; use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; use rustc_infer::infer::TypeTrace; use rustc_infer::infer::{DefineOpaqueTypes, InferOk}; +use rustc_middle::traits::ObligationCauseCode::ExprBindingObligation; use rustc_middle::ty::adjustment::AllowTwoPhase; use rustc_middle::ty::visit::TypeVisitableExt; use rustc_middle::ty::{self, IsSuggestable, Ty}; @@ -1834,6 +1835,58 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } + pub(super) fn collect_unused_for_coerce_return_ty( + &self, + errors: &[traits::FulfillmentError<'tcx>], + ) { + for fillment_error in &*errors { + let obligation = &fillment_error.obligation; + let span = obligation.cause.span; + + let Some(mut diag) = + self.tcx.sess.diagnostic().steal_diagnostic(span, StashKey::MaybeForgetReturn) + else { + continue; + }; + + let root_obligation = &fillment_error.root_obligation; + if let Some(fn_sig) = self.body_fn_sig() + && let ExprBindingObligation(_, _, hir_id, ..) = root_obligation.cause.code() + && !fn_sig.output().is_unit() { + let mut block_num = 0; + let mut found_semi = false; + for (_, node) in self.tcx.hir().parent_iter(*hir_id) { + match node { + hir::Node::Stmt(stmt) => if let hir::StmtKind::Semi(ref expr) = stmt.kind { + let expr_ty = self.typeck_results.borrow().expr_ty(expr); + let return_ty = fn_sig.output(); + if !matches!(expr.kind, hir::ExprKind::Ret(..)) && + self.can_coerce(expr_ty, return_ty) { + found_semi = true; + } + }, + hir::Node::Block(_block) => if found_semi { + block_num += 1; + } + hir::Node::Item(item) => if let hir::ItemKind::Fn(..) = item.kind { + break; + } + _ => {} + } + } + if block_num > 1 && found_semi { + diag.span_suggestion_verbose( + span.shrink_to_lo(), + "you might have meant to return this to infer its type parameters", + "return ", + Applicability::MaybeIncorrect, + ); + } + } + diag.emit(); + } + } + /// Given a vector of fulfillment errors, try to adjust the spans of the /// errors to more accurately point at the cause of the failure. /// diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index 457d5420ca3c9..2f5b67b3edd16 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -19,7 +19,7 @@ use on_unimplemented::{AppendConstMessage, OnUnimplementedNote, TypeErrCtxtExt a use rustc_data_structures::fx::{FxHashMap, FxIndexMap}; use rustc_errors::{ pluralize, struct_span_err, Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, - MultiSpan, Style, + MultiSpan, StashKey, Style, }; use rustc_hir as hir; use rustc_hir::def::Namespace; @@ -2236,14 +2236,14 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> { // begin with in those cases. if self.tcx.lang_items().sized_trait() == Some(trait_ref.def_id()) { if let None = self.tainted_by_errors() { - self.emit_inference_failure_err( + let err = self.emit_inference_failure_err( obligation.cause.body_id, span, trait_ref.self_ty().skip_binder().into(), ErrorCode::E0282, false, - ) - .emit(); + ); + err.stash(span, StashKey::MaybeForgetReturn); } return; } diff --git a/tests/ui/error-codes/E0401.stderr b/tests/ui/error-codes/E0401.stderr index fa4b91cacef72..6369d4b4ea951 100644 --- a/tests/ui/error-codes/E0401.stderr +++ b/tests/ui/error-codes/E0401.stderr @@ -32,17 +32,6 @@ LL | fn helper(sel: &Self) -> u8 { | use of generic parameter from outer function | use a type here instead -error[E0282]: type annotations needed - --> $DIR/E0401.rs:11:5 - | -LL | bfnr(x); - | ^^^^ cannot infer type of the type parameter `U` declared on the function `bfnr` - | -help: consider specifying the generic arguments - | -LL | bfnr::(x); - | +++++++++++ - error[E0283]: type annotations needed --> $DIR/E0401.rs:11:5 | @@ -64,6 +53,17 @@ help: consider specifying the generic arguments LL | bfnr::(x); | +++++++++++ +error[E0282]: type annotations needed + --> $DIR/E0401.rs:11:5 + | +LL | bfnr(x); + | ^^^^ cannot infer type of the type parameter `U` declared on the function `bfnr` + | +help: consider specifying the generic arguments + | +LL | bfnr::(x); + | +++++++++++ + error: aborting due to 5 previous errors Some errors have detailed explanations: E0282, E0283, E0401. diff --git a/tests/ui/inference/issue-72690.stderr b/tests/ui/inference/issue-72690.stderr index 225558805e08a..4617f0339226f 100644 --- a/tests/ui/inference/issue-72690.stderr +++ b/tests/ui/inference/issue-72690.stderr @@ -24,17 +24,6 @@ help: try using a fully qualified path to specify the expected types LL | String::from(>::as_ref("x")); | ++++++++++++++++++++++++++ ~ -error[E0282]: type annotations needed - --> $DIR/issue-72690.rs:12:6 - | -LL | |x| String::from("x".as_ref()); - | ^ - | -help: consider giving this closure parameter an explicit type - | -LL | |x: /* Type */| String::from("x".as_ref()); - | ++++++++++++ - error[E0283]: type annotations needed --> $DIR/issue-72690.rs:12:26 | @@ -51,6 +40,17 @@ help: try using a fully qualified path to specify the expected types LL | |x| String::from(>::as_ref("x")); | ++++++++++++++++++++++++++ ~ +error[E0282]: type annotations needed + --> $DIR/issue-72690.rs:12:6 + | +LL | |x| String::from("x".as_ref()); + | ^ + | +help: consider giving this closure parameter an explicit type + | +LL | |x: /* Type */| String::from("x".as_ref()); + | ++++++++++++ + error[E0283]: type annotations needed for `&T` --> $DIR/issue-72690.rs:17:9 | diff --git a/tests/ui/inference/issue-86094-suggest-add-return-to-coerce-ret-ty.rs b/tests/ui/inference/issue-86094-suggest-add-return-to-coerce-ret-ty.rs new file mode 100644 index 0000000000000..4544c898ab856 --- /dev/null +++ b/tests/ui/inference/issue-86094-suggest-add-return-to-coerce-ret-ty.rs @@ -0,0 +1,61 @@ +struct MyError; + +fn foo(x: bool) -> Result<(), MyError> { + if x { + Err(MyError); + //~^ ERROR type annotations needed + } + + Ok(()) +} + +fn bar(x: bool) -> Result<(), MyError> { + if x { + Ok(()); + //~^ ERROR type annotations needed + } + + Ok(()) +} + +fn baz(x: bool) -> Result<(), MyError> { + //~^ ERROR mismatched types + if x { + 1; + } + + Err(MyError); +} + +fn error() -> Result<(), MyError> { + Err(MyError) +} + +fn bak(x: bool) -> Result<(), MyError> { + if x { + //~^ ERROR mismatched types + error(); + } else { + //~^ ERROR mismatched types + error(); + } +} + +fn bad(x: bool) -> Result<(), MyError> { + Err(MyError); //~ ERROR type annotations needed + Ok(()) +} + +fn with_closure(_: F) -> i32 +where + F: FnOnce(A, B), +{ + 0 +} + +fn a() -> i32 { + with_closure(|x: u32, y| {}); //~ ERROR type annotations needed + 0 +} + +fn main() {} diff --git a/tests/ui/inference/issue-86094-suggest-add-return-to-coerce-ret-ty.stderr b/tests/ui/inference/issue-86094-suggest-add-return-to-coerce-ret-ty.stderr new file mode 100644 index 0000000000000..1fea73529a8a2 --- /dev/null +++ b/tests/ui/inference/issue-86094-suggest-add-return-to-coerce-ret-ty.stderr @@ -0,0 +1,98 @@ +error[E0282]: type annotations needed + --> $DIR/issue-86094-suggest-add-return-to-coerce-ret-ty.rs:5:9 + | +LL | Err(MyError); + | ^^^ cannot infer type of the type parameter `T` declared on the enum `Result` + | +help: consider specifying the generic arguments + | +LL | Err::(MyError); + | ++++++++++++++ +help: you might have meant to return this to infer its type parameters + | +LL | return Err(MyError); + | ++++++ + +error[E0282]: type annotations needed + --> $DIR/issue-86094-suggest-add-return-to-coerce-ret-ty.rs:14:9 + | +LL | Ok(()); + | ^^ cannot infer type of the type parameter `E` declared on the enum `Result` + | +help: consider specifying the generic arguments + | +LL | Ok::<(), E>(()); + | +++++++++ +help: you might have meant to return this to infer its type parameters + | +LL | return Ok(()); + | ++++++ + +error[E0308]: mismatched types + --> $DIR/issue-86094-suggest-add-return-to-coerce-ret-ty.rs:21:20 + | +LL | fn baz(x: bool) -> Result<(), MyError> { + | --- ^^^^^^^^^^^^^^^^^^^ expected `Result<(), MyError>`, found `()` + | | + | implicitly returns `()` as its body has no tail or `return` expression +... +LL | Err(MyError); + | - help: remove this semicolon to return this value + | + = note: expected enum `Result<(), MyError>` + found unit type `()` + +error[E0308]: mismatched types + --> $DIR/issue-86094-suggest-add-return-to-coerce-ret-ty.rs:35:10 + | +LL | if x { + | __________^ +LL | | +LL | | error(); + | | - help: remove this semicolon to return this value +LL | | } else { + | |_____^ expected `Result<(), MyError>`, found `()` + | + = note: expected enum `Result<(), MyError>` + found unit type `()` + +error[E0308]: mismatched types + --> $DIR/issue-86094-suggest-add-return-to-coerce-ret-ty.rs:38:12 + | +LL | } else { + | ____________^ +LL | | +LL | | error(); + | | - help: remove this semicolon to return this value +LL | | } + | |_____^ expected `Result<(), MyError>`, found `()` + | + = note: expected enum `Result<(), MyError>` + found unit type `()` + +error[E0282]: type annotations needed + --> $DIR/issue-86094-suggest-add-return-to-coerce-ret-ty.rs:45:5 + | +LL | Err(MyError); + | ^^^ cannot infer type of the type parameter `T` declared on the enum `Result` + | +help: consider specifying the generic arguments + | +LL | Err::(MyError); + | ++++++++++++++ + +error[E0282]: type annotations needed + --> $DIR/issue-86094-suggest-add-return-to-coerce-ret-ty.rs:57:27 + | +LL | with_closure(|x: u32, y| {}); + | ^ + | +help: consider giving this closure parameter an explicit type + | +LL | with_closure(|x: u32, y: /* Type */| {}); + | ++++++++++++ + +error: aborting due to 7 previous errors + +Some errors have detailed explanations: E0282, E0308. +For more information about an error, try `rustc --explain E0282`. diff --git a/tests/ui/methods/method-ambig-one-trait-unknown-int-type.stderr b/tests/ui/methods/method-ambig-one-trait-unknown-int-type.stderr index e0f8a5447b081..3dbdfcfa6da57 100644 --- a/tests/ui/methods/method-ambig-one-trait-unknown-int-type.stderr +++ b/tests/ui/methods/method-ambig-one-trait-unknown-int-type.stderr @@ -1,14 +1,3 @@ -error[E0282]: type annotations needed for `Vec` - --> $DIR/method-ambig-one-trait-unknown-int-type.rs:24:9 - | -LL | let mut x = Vec::new(); - | ^^^^^ - | -help: consider giving `x` an explicit type, where the type for type parameter `T` is specified - | -LL | let mut x: Vec = Vec::new(); - | ++++++++ - error[E0283]: type annotations needed --> $DIR/method-ambig-one-trait-unknown-int-type.rs:26:7 | @@ -28,6 +17,17 @@ help: try using a fully qualified path to specify the expected types LL | as Foo>::foo(&x); | ++++++++++++++++++++++ ~ +error[E0282]: type annotations needed for `Vec` + --> $DIR/method-ambig-one-trait-unknown-int-type.rs:24:9 + | +LL | let mut x = Vec::new(); + | ^^^^^ + | +help: consider giving `x` an explicit type, where the type for type parameter `T` is specified + | +LL | let mut x: Vec = Vec::new(); + | ++++++++ + error[E0308]: mismatched types --> $DIR/method-ambig-one-trait-unknown-int-type.rs:33:20 | diff --git a/tests/ui/traits/do-not-mention-type-params-by-name-in-suggestion-issue-96292.stderr b/tests/ui/traits/do-not-mention-type-params-by-name-in-suggestion-issue-96292.stderr index 57b2587ae5ccd..61669eb67874b 100644 --- a/tests/ui/traits/do-not-mention-type-params-by-name-in-suggestion-issue-96292.stderr +++ b/tests/ui/traits/do-not-mention-type-params-by-name-in-suggestion-issue-96292.stderr @@ -1,28 +1,28 @@ -error[E0282]: type annotations needed +error[E0283]: type annotations needed --> $DIR/do-not-mention-type-params-by-name-in-suggestion-issue-96292.rs:17:11 | LL | thing.method(42); | ^^^^^^ | +note: multiple `impl`s satisfying `Thing: Method<_>` found + --> $DIR/do-not-mention-type-params-by-name-in-suggestion-issue-96292.rs:7:1 + | +LL | impl Method for Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | impl Method for Thing { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using a fully qualified path to specify the expected types | LL | as Method>::method(thing, 42); | +++++++++++++++++++++++++++++++++++ ~ -error[E0283]: type annotations needed +error[E0282]: type annotations needed --> $DIR/do-not-mention-type-params-by-name-in-suggestion-issue-96292.rs:17:11 | LL | thing.method(42); | ^^^^^^ | -note: multiple `impl`s satisfying `Thing: Method<_>` found - --> $DIR/do-not-mention-type-params-by-name-in-suggestion-issue-96292.rs:7:1 - | -LL | impl Method for Thing { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -... -LL | impl Method for Thing { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using a fully qualified path to specify the expected types | LL | as Method>::method(thing, 42); diff --git a/tests/ui/traits/multidispatch-convert-ambig-dest.stderr b/tests/ui/traits/multidispatch-convert-ambig-dest.stderr index e927f26e96dd9..abc7f176dca94 100644 --- a/tests/ui/traits/multidispatch-convert-ambig-dest.stderr +++ b/tests/ui/traits/multidispatch-convert-ambig-dest.stderr @@ -1,14 +1,3 @@ -error[E0282]: type annotations needed - --> $DIR/multidispatch-convert-ambig-dest.rs:26:5 - | -LL | test(22, std::default::Default::default()); - | ^^^^ cannot infer type of the type parameter `U` declared on the function `test` - | -help: consider specifying the generic arguments - | -LL | test::(22, std::default::Default::default()); - | ++++++++++ - error[E0283]: type annotations needed --> $DIR/multidispatch-convert-ambig-dest.rs:26:5 | @@ -37,6 +26,17 @@ help: consider specifying the generic arguments LL | test::(22, std::default::Default::default()); | ++++++++++ +error[E0282]: type annotations needed + --> $DIR/multidispatch-convert-ambig-dest.rs:26:5 + | +LL | test(22, std::default::Default::default()); + | ^^^^ cannot infer type of the type parameter `U` declared on the function `test` + | +help: consider specifying the generic arguments + | +LL | test::(22, std::default::Default::default()); + | ++++++++++ + error: aborting due to 2 previous errors Some errors have detailed explanations: E0282, E0283. diff --git a/tests/ui/traits/new-solver/alias-bound-unsound.stderr b/tests/ui/traits/new-solver/alias-bound-unsound.stderr index abc6677c1323a..74d32cc588294 100644 --- a/tests/ui/traits/new-solver/alias-bound-unsound.stderr +++ b/tests/ui/traits/new-solver/alias-bound-unsound.stderr @@ -11,17 +11,6 @@ note: required by a bound in `Foo::Item` LL | type Item: Copy | ^^^^ required by this bound in `Foo::Item` -error[E0282]: type annotations needed - --> $DIR/alias-bound-unsound.rs:24:5 - | -LL | drop(<() as Foo>::copy_me(&x)); - | ^^^^ cannot infer type of the type parameter `T` declared on the function `drop` - | -help: consider specifying the generic argument - | -LL | drop::(<() as Foo>::copy_me(&x)); - | +++++ - error[E0275]: overflow evaluating the requirement `&<() as Foo>::Item well-formed` --> $DIR/alias-bound-unsound.rs:24:31 | @@ -63,6 +52,17 @@ LL | drop(<() as Foo>::copy_me(&x)); = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`alias_bound_unsound`) = note: the return type of a function must have a statically known size +error[E0282]: type annotations needed + --> $DIR/alias-bound-unsound.rs:24:5 + | +LL | drop(<() as Foo>::copy_me(&x)); + | ^^^^ cannot infer type of the type parameter `T` declared on the function `drop` + | +help: consider specifying the generic argument + | +LL | drop::(<() as Foo>::copy_me(&x)); + | +++++ + error: aborting due to 7 previous errors Some errors have detailed explanations: E0275, E0282. diff --git a/tests/ui/traits/new-solver/specialization-unconstrained.stderr b/tests/ui/traits/new-solver/specialization-unconstrained.stderr index 9915da1a27a6a..ed4dafa1484c2 100644 --- a/tests/ui/traits/new-solver/specialization-unconstrained.stderr +++ b/tests/ui/traits/new-solver/specialization-unconstrained.stderr @@ -8,12 +8,6 @@ LL | #![feature(specialization)] = help: consider using `min_specialization` instead, which is more stable and complete = note: `#[warn(incomplete_features)]` on by default -error[E0282]: type annotations needed - --> $DIR/specialization-unconstrained.rs:14:22 - | -LL | default type Id = T; - | ^ cannot infer type for associated type `::Id` - error[E0284]: type annotations needed: cannot satisfy `::Id == ()` --> $DIR/specialization-unconstrained.rs:20:5 | @@ -26,6 +20,12 @@ note: required by a bound in `test` LL | fn test, U>() {} | ^^^^^^ required by this bound in `test` +error[E0282]: type annotations needed + --> $DIR/specialization-unconstrained.rs:14:22 + | +LL | default type Id = T; + | ^ cannot infer type for associated type `::Id` + error: aborting due to 2 previous errors; 1 warning emitted Some errors have detailed explanations: E0282, E0284. diff --git a/tests/ui/traits/not-suggest-non-existing-fully-qualified-path.stderr b/tests/ui/traits/not-suggest-non-existing-fully-qualified-path.stderr index 92d9d32cf9c70..7f94ad93aa78d 100644 --- a/tests/ui/traits/not-suggest-non-existing-fully-qualified-path.stderr +++ b/tests/ui/traits/not-suggest-non-existing-fully-qualified-path.stderr @@ -1,14 +1,3 @@ -error[E0282]: type annotations needed - --> $DIR/not-suggest-non-existing-fully-qualified-path.rs:21:7 - | -LL | a.method(); - | ^^^^^^ - | -help: try using a fully qualified path to specify the expected types - | -LL | as V>::method(a); - | +++++++++++++++++++++++ ~ - error[E0283]: type annotations needed --> $DIR/not-suggest-non-existing-fully-qualified-path.rs:21:7 | @@ -35,6 +24,17 @@ help: try using a fully qualified path to specify the expected types LL | as V>::method(a); | +++++++++++++++++++++++ ~ +error[E0282]: type annotations needed + --> $DIR/not-suggest-non-existing-fully-qualified-path.rs:21:7 + | +LL | a.method(); + | ^^^^^^ + | +help: try using a fully qualified path to specify the expected types + | +LL | as V>::method(a); + | +++++++++++++++++++++++ ~ + error: aborting due to 2 previous errors Some errors have detailed explanations: E0282, E0283. diff --git a/tests/ui/traits/suggest-fully-qualified-closure.stderr b/tests/ui/traits/suggest-fully-qualified-closure.stderr index 3df623c14c3d6..e86aee727d5fa 100644 --- a/tests/ui/traits/suggest-fully-qualified-closure.stderr +++ b/tests/ui/traits/suggest-fully-qualified-closure.stderr @@ -1,28 +1,28 @@ -error[E0282]: type annotations needed +error[E0283]: type annotations needed --> $DIR/suggest-fully-qualified-closure.rs:23:7 | LL | q.lol(||()); | ^^^ | +note: multiple `impl`s satisfying `Qqq: MyTrait<_>` found + --> $DIR/suggest-fully-qualified-closure.rs:14:1 + | +LL | impl MyTrait for Qqq{ + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | impl MyTrait for Qqq{ + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using a fully qualified path to specify the expected types | LL | >::lol::<[closure@]>(&q, ||()); | +++ ~ -error[E0283]: type annotations needed +error[E0282]: type annotations needed --> $DIR/suggest-fully-qualified-closure.rs:23:7 | LL | q.lol(||()); | ^^^ | -note: multiple `impl`s satisfying `Qqq: MyTrait<_>` found - --> $DIR/suggest-fully-qualified-closure.rs:14:1 - | -LL | impl MyTrait for Qqq{ - | ^^^^^^^^^^^^^^^^^^^^^^^^^ -... -LL | impl MyTrait for Qqq{ - | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using a fully qualified path to specify the expected types | LL | >::lol::<[closure@]>(&q, ||()); diff --git a/tests/ui/traits/suggest-fully-qualified-path-with-adjustment.stderr b/tests/ui/traits/suggest-fully-qualified-path-with-adjustment.stderr index 68b31a1ca34e3..381feac76cd29 100644 --- a/tests/ui/traits/suggest-fully-qualified-path-with-adjustment.stderr +++ b/tests/ui/traits/suggest-fully-qualified-path-with-adjustment.stderr @@ -1,14 +1,3 @@ -error[E0282]: type annotations needed - --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:45:11 - | -LL | thing.method(); - | ^^^^^^ - | -help: try using a fully qualified path to specify the expected types - | -LL | >::method(&thing); - | ++++++++++++++++++++++++++++++ ~ - error[E0283]: type annotations needed --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:45:11 | @@ -180,6 +169,17 @@ help: try using a fully qualified path to specify the expected types LL | <&Thing as MethodRef>::by_self(&deref_deref_to); | +++++++++++++++++++++++++++++++++++ ~ +error[E0282]: type annotations needed + --> $DIR/suggest-fully-qualified-path-with-adjustment.rs:45:11 + | +LL | thing.method(); + | ^^^^^^ + | +help: try using a fully qualified path to specify the expected types + | +LL | >::method(&thing); + | ++++++++++++++++++++++++++++++ ~ + error: aborting due to 10 previous errors Some errors have detailed explanations: E0282, E0283. diff --git a/tests/ui/traits/suggest-fully-qualified-path-without-adjustment.stderr b/tests/ui/traits/suggest-fully-qualified-path-without-adjustment.stderr index 27518a54e7507..c02f6bff14add 100644 --- a/tests/ui/traits/suggest-fully-qualified-path-without-adjustment.stderr +++ b/tests/ui/traits/suggest-fully-qualified-path-without-adjustment.stderr @@ -1,14 +1,3 @@ -error[E0282]: type annotations needed - --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:45:15 - | -LL | ref_thing.method(); - | ^^^^^^ - | -help: try using a fully qualified path to specify the expected types - | -LL | >::method(ref_thing); - | +++++++++++++++++++++++++++++ ~ - error[E0283]: type annotations needed --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:45:15 | @@ -218,6 +207,17 @@ help: try using a fully qualified path to specify the expected types LL | <&Thing as MethodRef>::by_self(deref_deref_to); | ++++++++++++++++++++++++++++++++++ ~ +error[E0282]: type annotations needed + --> $DIR/suggest-fully-qualified-path-without-adjustment.rs:45:15 + | +LL | ref_thing.method(); + | ^^^^^^ + | +help: try using a fully qualified path to specify the expected types + | +LL | >::method(ref_thing); + | +++++++++++++++++++++++++++++ ~ + error: aborting due to 12 previous errors Some errors have detailed explanations: E0282, E0283.