From 1c382187ea6af7ec127f2add5c354663ee691bf0 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Tue, 11 Jun 2024 13:11:58 +0000 Subject: [PATCH] Do not fail `method_autoderef_steps` on infer types. Let method resolution handle it --- .../rustc_hir_typeck/src/method/confirm.rs | 7 ++-- compiler/rustc_hir_typeck/src/method/probe.rs | 1 + tests/crashes/121613-2.rs | 28 ------------- ...mismatch_on_associatedtype_constructor.rs} | 8 +++- ...match_on_associatedtype_constructor.stderr | 22 ++++++++++ .../deref-ambiguity-becomes-nonambiguous.rs | 2 +- ...eref-ambiguity-becomes-nonambiguous.stderr | 21 +++++----- ...tion-with-leaking-placeholders.next.stderr | 2 +- .../hidden-type-is-opaque-2.default.stderr | 30 ++++--------- .../hidden-type-is-opaque-2.next.stderr | 30 ++++--------- .../ui/impl-trait/hidden-type-is-opaque-2.rs | 4 +- .../recursive-bound-eval.current.stderr | 42 ------------------- .../recursive-bound-eval.next.stderr | 4 +- tests/ui/impl-trait/recursive-bound-eval.rs | 5 +-- .../recursive-coroutine-boxed.next.stderr | 40 ------------------ .../impl-trait/recursive-coroutine-boxed.rs | 8 +--- tests/ui/issues/issue-20261.stderr | 4 +- tests/ui/issues/issue-2151.stderr | 2 +- tests/ui/issues/issue-7092.rs | 1 - tests/ui/issues/issue-7092.stderr | 11 +---- .../branches3.stderr | 8 ++-- ...t-method-on-call-for-ambig-receiver.stderr | 6 +++ ...ary-self-from-method-substs.default.stderr | 1 - ...ue-42234-unknown-receiver-type.full.stderr | 20 +++------ ...4-unknown-receiver-type.generic_arg.stderr | 20 +++------ .../span/issue-42234-unknown-receiver-type.rs | 3 +- .../closures_in_branches.stderr | 4 +- tests/ui/typeck/issue-13853.rs | 2 +- tests/ui/typeck/issue-13853.stderr | 18 ++++++-- 29 files changed, 115 insertions(+), 239 deletions(-) delete mode 100644 tests/crashes/121613-2.rs rename tests/{crashes/121613.rs => ui/associated-types/param_mismatch_on_associatedtype_constructor.rs} (51%) create mode 100644 tests/ui/associated-types/param_mismatch_on_associatedtype_constructor.stderr delete mode 100644 tests/ui/impl-trait/recursive-bound-eval.current.stderr delete mode 100644 tests/ui/impl-trait/recursive-coroutine-boxed.next.stderr diff --git a/compiler/rustc_hir_typeck/src/method/confirm.rs b/compiler/rustc_hir_typeck/src/method/confirm.rs index 3c9a49e91a3f9..7920a2796cd3a 100644 --- a/compiler/rustc_hir_typeck/src/method/confirm.rs +++ b/compiler/rustc_hir_typeck/src/method/confirm.rs @@ -510,9 +510,10 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { .report_mismatched_types(&cause, method_self_ty, self_ty, terr) .emit(); } else { - error!("{self_ty} was a subtype of {method_self_ty} but now is not?"); - // This must already have errored elsewhere. - self.dcx().has_errors().unwrap(); + self.dcx().span_delayed_bug( + self.self_expr.span, + format!("{self_ty} was a subtype of {method_self_ty} but now is not?"), + ); } } } diff --git a/compiler/rustc_hir_typeck/src/method/probe.rs b/compiler/rustc_hir_typeck/src/method/probe.rs index e842bba34bf82..bdb6c047b0754 100644 --- a/compiler/rustc_hir_typeck/src/method/probe.rs +++ b/compiler/rustc_hir_typeck/src/method/probe.rs @@ -528,6 +528,7 @@ fn method_autoderef_steps<'tcx>( let final_ty = autoderef.final_ty(true); let opt_bad_ty = match final_ty.kind() { + ty::Infer(ty::TyVar(_)) if !reached_raw_pointer => None, ty::Infer(ty::TyVar(_)) | ty::Error(_) => Some(MethodAutoderefBadTy { reached_raw_pointer, ty: infcx.make_query_response_ignoring_pending_obligations(inference_vars, final_ty), diff --git a/tests/crashes/121613-2.rs b/tests/crashes/121613-2.rs deleted file mode 100644 index ddc4f37c96a2f..0000000000000 --- a/tests/crashes/121613-2.rs +++ /dev/null @@ -1,28 +0,0 @@ -//@ known-bug: #121613 -fn main() { - // destructure through a qualified path - let ::Assoc { br } = StructStruct { br: 2 }; - //~^ ERROR usage of qualified paths in this context is experimental - let _ = ::Assoc { br: 2 }; - //~^ ERROR usage of qualified paths in this context is experimental - let ::V(..) = E::V(|a, b| a.cmp(b)); - //~^ ERROR usage of qualified paths in this context is experimental -} - -struct StructStruct { - br: i8, -} - -struct Foo; - -trait A { - type Assoc; -} - -impl A for Foo { - type Assoc = StructStruct; -} - -enum E { - V(u8) -} diff --git a/tests/crashes/121613.rs b/tests/ui/associated-types/param_mismatch_on_associatedtype_constructor.rs similarity index 51% rename from tests/crashes/121613.rs rename to tests/ui/associated-types/param_mismatch_on_associatedtype_constructor.rs index ec9ba82a68c5f..be3adfe8665fe 100644 --- a/tests/crashes/121613.rs +++ b/tests/ui/associated-types/param_mismatch_on_associatedtype_constructor.rs @@ -1,8 +1,14 @@ -//@ known-bug: #121613 +//! This test used to ICE #121613 +//! Using a generic parameter where there are none expected +//! caused an ICE, hiding the important later errors. + +#![feature(more_qualified_paths)] + fn main() { let _ = ::Assoc { br: 2 }; let ::V(..) = E::V(|a, b| a.cmp(b)); + //~^ ERROR: multiple applicable items in scope } struct StructStruct { diff --git a/tests/ui/associated-types/param_mismatch_on_associatedtype_constructor.stderr b/tests/ui/associated-types/param_mismatch_on_associatedtype_constructor.stderr new file mode 100644 index 0000000000000..babb350f62915 --- /dev/null +++ b/tests/ui/associated-types/param_mismatch_on_associatedtype_constructor.stderr @@ -0,0 +1,22 @@ +error[E0034]: multiple applicable items in scope + --> $DIR/param_mismatch_on_associatedtype_constructor.rs:10:36 + | +LL | let ::V(..) = E::V(|a, b| a.cmp(b)); + | ^^^ multiple `cmp` found + | +note: candidate #1 is defined in the trait `Iterator` + --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL +note: candidate #2 is defined in the trait `Ord` + --> $SRC_DIR/core/src/cmp.rs:LL:COL +help: disambiguate the method for candidate #1 + | +LL | let ::V(..) = E::V(|a, b| Iterator::cmp(a, b)); + | ~~~~~~~~~~~~~~~~~~~ +help: disambiguate the method for candidate #2 + | +LL | let ::V(..) = E::V(|a, b| Ord::cmp(&a, b)); + | ~~~~~~~~~~~~~~~ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0034`. diff --git a/tests/ui/autoref-autoderef/deref-ambiguity-becomes-nonambiguous.rs b/tests/ui/autoref-autoderef/deref-ambiguity-becomes-nonambiguous.rs index d8034d57e8d56..98140510f0a48 100644 --- a/tests/ui/autoref-autoderef/deref-ambiguity-becomes-nonambiguous.rs +++ b/tests/ui/autoref-autoderef/deref-ambiguity-becomes-nonambiguous.rs @@ -29,7 +29,6 @@ impl Deref for Value> { fn main() { let var_fn = Value::wrap(); - //~^ ERROR type annotations needed for `Value>` // The combination of `Value: Wrap` obligation plus the autoderef steps // (caused by the `Deref` impl above) actually means that the self type @@ -37,4 +36,5 @@ fn main() { // However, that's only known to us on the error path -- we still need // to emit an ambiguity error, though. let _ = var_fn.clone(); + //~^ ERROR: the size for values of type `dyn Fn(_, _) -> _` cannot be known } diff --git a/tests/ui/autoref-autoderef/deref-ambiguity-becomes-nonambiguous.stderr b/tests/ui/autoref-autoderef/deref-ambiguity-becomes-nonambiguous.stderr index 19c3c64181985..9df15b801e42c 100644 --- a/tests/ui/autoref-autoderef/deref-ambiguity-becomes-nonambiguous.stderr +++ b/tests/ui/autoref-autoderef/deref-ambiguity-becomes-nonambiguous.stderr @@ -1,17 +1,18 @@ -error[E0282]: type annotations needed for `Value>` - --> $DIR/deref-ambiguity-becomes-nonambiguous.rs:31:9 +error[E0277]: the size for values of type `dyn Fn(_, _) -> _` cannot be known at compilation time + --> $DIR/deref-ambiguity-becomes-nonambiguous.rs:38:13 | -LL | let var_fn = Value::wrap(); - | ^^^^^^ -... LL | let _ = var_fn.clone(); - | ----- type must be known at this point + | ^^^^^^^^^^^^^^ doesn't have a size known at compile-time | -help: consider giving `var_fn` an explicit type, where the placeholders `_` are specified + = help: the trait `Sized` is not implemented for `dyn Fn(_, _) -> _`, which is required by `Value>: Deref` +note: required for `Value _>>` to implement `Deref` + --> $DIR/deref-ambiguity-becomes-nonambiguous.rs:22:9 | -LL | let var_fn: Value> = Value::wrap(); - | ++++++++++++++ +LL | impl Deref for Value> { + | - ^^^^^ ^^^^^^^^^^^^ + | | + | unsatisfied trait bound introduced here error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0282`. +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/closures/deduce-signature/obligation-with-leaking-placeholders.next.stderr b/tests/ui/closures/deduce-signature/obligation-with-leaking-placeholders.next.stderr index 4bb9047b3035d..481a0889a0662 100644 --- a/tests/ui/closures/deduce-signature/obligation-with-leaking-placeholders.next.stderr +++ b/tests/ui/closures/deduce-signature/obligation-with-leaking-placeholders.next.stderr @@ -5,7 +5,7 @@ LL | needs_foo(|x| { | ^ ... LL | x.to_string(); - | --------- type must be known at this point + | ------------- type must be known at this point | help: consider giving this closure parameter an explicit type | diff --git a/tests/ui/impl-trait/hidden-type-is-opaque-2.default.stderr b/tests/ui/impl-trait/hidden-type-is-opaque-2.default.stderr index 554979408aba8..41281b22895a4 100644 --- a/tests/ui/impl-trait/hidden-type-is-opaque-2.default.stderr +++ b/tests/ui/impl-trait/hidden-type-is-opaque-2.default.stderr @@ -1,31 +1,15 @@ -error[E0282]: type annotations needed - --> $DIR/hidden-type-is-opaque-2.rs:10:17 +error[E0599]: no method named `reify_as` found for type `_` in the current scope + --> $DIR/hidden-type-is-opaque-2.rs:11:14 | -LL | Thunk::new(|mut cont| { - | ^^^^^^^^ -LL | LL | cont.reify_as(); - | -------- type must be known at this point - | -help: consider giving this closure parameter an explicit type - | -LL | Thunk::new(|mut cont: /* Type */| { - | ++++++++++++ + | ^^^^^^^^ method not found in `_` -error[E0282]: type annotations needed - --> $DIR/hidden-type-is-opaque-2.rs:20:17 +error[E0599]: no method named `reify_as` found for type `_` in the current scope + --> $DIR/hidden-type-is-opaque-2.rs:21:14 | -LL | Thunk::new(|mut cont| { - | ^^^^^^^^ -LL | LL | cont.reify_as(); - | -------- type must be known at this point - | -help: consider giving this closure parameter an explicit type - | -LL | Thunk::new(|mut cont: /* Type */| { - | ++++++++++++ + | ^^^^^^^^ method not found in `_` error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0282`. +For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/impl-trait/hidden-type-is-opaque-2.next.stderr b/tests/ui/impl-trait/hidden-type-is-opaque-2.next.stderr index 554979408aba8..41281b22895a4 100644 --- a/tests/ui/impl-trait/hidden-type-is-opaque-2.next.stderr +++ b/tests/ui/impl-trait/hidden-type-is-opaque-2.next.stderr @@ -1,31 +1,15 @@ -error[E0282]: type annotations needed - --> $DIR/hidden-type-is-opaque-2.rs:10:17 +error[E0599]: no method named `reify_as` found for type `_` in the current scope + --> $DIR/hidden-type-is-opaque-2.rs:11:14 | -LL | Thunk::new(|mut cont| { - | ^^^^^^^^ -LL | LL | cont.reify_as(); - | -------- type must be known at this point - | -help: consider giving this closure parameter an explicit type - | -LL | Thunk::new(|mut cont: /* Type */| { - | ++++++++++++ + | ^^^^^^^^ method not found in `_` -error[E0282]: type annotations needed - --> $DIR/hidden-type-is-opaque-2.rs:20:17 +error[E0599]: no method named `reify_as` found for type `_` in the current scope + --> $DIR/hidden-type-is-opaque-2.rs:21:14 | -LL | Thunk::new(|mut cont| { - | ^^^^^^^^ -LL | LL | cont.reify_as(); - | -------- type must be known at this point - | -help: consider giving this closure parameter an explicit type - | -LL | Thunk::new(|mut cont: /* Type */| { - | ++++++++++++ + | ^^^^^^^^ method not found in `_` error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0282`. +For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/impl-trait/hidden-type-is-opaque-2.rs b/tests/ui/impl-trait/hidden-type-is-opaque-2.rs index 78ac8363ba930..bc5945c6d120d 100644 --- a/tests/ui/impl-trait/hidden-type-is-opaque-2.rs +++ b/tests/ui/impl-trait/hidden-type-is-opaque-2.rs @@ -8,8 +8,8 @@ fn reify_as() -> Thunk Continuation> { Thunk::new(|mut cont| { - //~^ ERROR type annotations needed cont.reify_as(); + //~^ ERROR: no method named `reify_as` found for type `_` cont }) } @@ -18,8 +18,8 @@ type Tait = impl FnOnce(Continuation) -> Continuation; fn reify_as_tait() -> Thunk { Thunk::new(|mut cont| { - //~^ ERROR type annotations needed cont.reify_as(); + //~^ ERROR: no method named `reify_as` found for type `_` cont }) } diff --git a/tests/ui/impl-trait/recursive-bound-eval.current.stderr b/tests/ui/impl-trait/recursive-bound-eval.current.stderr deleted file mode 100644 index f446e4eb3bc4b..0000000000000 --- a/tests/ui/impl-trait/recursive-bound-eval.current.stderr +++ /dev/null @@ -1,42 +0,0 @@ -error[E0282]: type annotations needed - --> $DIR/recursive-bound-eval.rs:19:28 - | -LL | move || recursive_fn().parse() - | ^^^^^ cannot infer type - -error[E0599]: no method named `parse` found for opaque type `impl Parser<_>` in the current scope - --> $DIR/recursive-bound-eval.rs:19:28 - | -LL | move || recursive_fn().parse() - | ^^^^^ method not found in `impl Parser<_>` - | - = help: items from traits can only be used if the trait is implemented and in scope -help: trait `Parser` which provides `parse` is implemented but not in scope; perhaps you want to import it - | -LL + use Parser; - | - -error[E0391]: cycle detected when computing type of opaque `recursive_fn::{opaque#0}` - --> $DIR/recursive-bound-eval.rs:17:29 - | -LL | pub fn recursive_fn() -> impl Parser { - | ^^^^^^^^^^^^^^ - | -note: ...which requires type-checking `recursive_fn`... - --> $DIR/recursive-bound-eval.rs:19:13 - | -LL | move || recursive_fn().parse() - | ^^^^^^^^^^^^^^ - = note: ...which requires evaluating trait selection obligation `recursive_fn::{opaque#0}: core::marker::Unpin`... - = note: ...which again requires computing type of opaque `recursive_fn::{opaque#0}`, completing the cycle -note: cycle used when computing type of `recursive_fn::{opaque#0}` - --> $DIR/recursive-bound-eval.rs:17:29 - | -LL | pub fn recursive_fn() -> impl Parser { - | ^^^^^^^^^^^^^^ - = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0282, E0391, E0599. -For more information about an error, try `rustc --explain E0282`. diff --git a/tests/ui/impl-trait/recursive-bound-eval.next.stderr b/tests/ui/impl-trait/recursive-bound-eval.next.stderr index ea0a044ed5326..b44c9c921522f 100644 --- a/tests/ui/impl-trait/recursive-bound-eval.next.stderr +++ b/tests/ui/impl-trait/recursive-bound-eval.next.stderr @@ -1,8 +1,8 @@ error[E0282]: type annotations needed - --> $DIR/recursive-bound-eval.rs:19:28 + --> $DIR/recursive-bound-eval.rs:19:13 | LL | move || recursive_fn().parse() - | ^^^^^ cannot infer type + | ^^^^^^^^^^^^^^^^^^^^^^ cannot infer type error: aborting due to 1 previous error diff --git a/tests/ui/impl-trait/recursive-bound-eval.rs b/tests/ui/impl-trait/recursive-bound-eval.rs index b8c9c50903f7c..95e555f9b38c3 100644 --- a/tests/ui/impl-trait/recursive-bound-eval.rs +++ b/tests/ui/impl-trait/recursive-bound-eval.rs @@ -3,6 +3,7 @@ //@revisions: next current //@[next] compile-flags: -Znext-solver +//@[current] check-pass pub trait Parser { fn parse(&self) -> E; @@ -15,10 +16,8 @@ impl E> Parser for T { } pub fn recursive_fn() -> impl Parser { - //[current]~^ ERROR: cycle detected move || recursive_fn().parse() - //~^ ERROR: type annotations needed - //[current]~^^ ERROR: no method named `parse` found for opaque type + //[next]~^ ERROR: type annotations needed } fn main() {} diff --git a/tests/ui/impl-trait/recursive-coroutine-boxed.next.stderr b/tests/ui/impl-trait/recursive-coroutine-boxed.next.stderr deleted file mode 100644 index 96db2030a405c..0000000000000 --- a/tests/ui/impl-trait/recursive-coroutine-boxed.next.stderr +++ /dev/null @@ -1,40 +0,0 @@ -error[E0282]: type annotations needed - --> $DIR/recursive-coroutine-boxed.rs:15:23 - | -LL | let mut gen = Box::pin(foo()); - | ^^^^^^^^ cannot infer type of the type parameter `T` declared on the struct `Box` -LL | -LL | let mut r = gen.as_mut().resume(()); - | ------ type must be known at this point - | -help: consider specifying the generic argument - | -LL | let mut gen = Box::::pin(foo()); - | +++++ - -error[E0308]: mismatched types - --> $DIR/recursive-coroutine-boxed.rs:14:18 - | -LL | fn foo() -> impl Coroutine { - | --------------------------------------- - | | - | the expected opaque type - | expected `impl Coroutine` because of return type -... -LL | #[coroutine] || { - | __________________^ -LL | | let mut gen = Box::pin(foo()); -LL | | -LL | | let mut r = gen.as_mut().resume(()); -... | -LL | | } -LL | | } - | |_____^ types differ - | - = note: expected opaque type `impl Coroutine` - found coroutine `{coroutine@$DIR/recursive-coroutine-boxed.rs:14:18: 14:20}` - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0282, E0308. -For more information about an error, try `rustc --explain E0282`. diff --git a/tests/ui/impl-trait/recursive-coroutine-boxed.rs b/tests/ui/impl-trait/recursive-coroutine-boxed.rs index 24a77d7311419..3f7495679a907 100644 --- a/tests/ui/impl-trait/recursive-coroutine-boxed.rs +++ b/tests/ui/impl-trait/recursive-coroutine-boxed.rs @@ -1,19 +1,15 @@ //@ revisions: current next //@ ignore-compare-mode-next-solver (explicit revisions) -//@[current] check-pass +//@ check-pass //@[next] compile-flags: -Znext-solver #![feature(coroutines, coroutine_trait)] use std::ops::{Coroutine, CoroutineState}; fn foo() -> impl Coroutine { - // FIXME(-Znext-solver): this fails with a mismatched types as the - // hidden type of the opaque ends up as {type error}. We should not - // emit errors for such goals. - #[coroutine] || { //[next]~ ERROR mismatched types + #[coroutine] || { let mut gen = Box::pin(foo()); - //[next]~^ ERROR type annotations needed let mut r = gen.as_mut().resume(()); while let CoroutineState::Yielded(v) = r { yield v; diff --git a/tests/ui/issues/issue-20261.stderr b/tests/ui/issues/issue-20261.stderr index 6738708ca225d..02c2ac124a603 100644 --- a/tests/ui/issues/issue-20261.stderr +++ b/tests/ui/issues/issue-20261.stderr @@ -1,8 +1,8 @@ error[E0282]: type annotations needed - --> $DIR/issue-20261.rs:4:11 + --> $DIR/issue-20261.rs:4:9 | LL | i.clone(); - | ^^^^^ cannot infer type + | ^^^^^^^^^ cannot infer type error: aborting due to 1 previous error diff --git a/tests/ui/issues/issue-2151.stderr b/tests/ui/issues/issue-2151.stderr index 59fef42eb5e8b..b739f4a627c24 100644 --- a/tests/ui/issues/issue-2151.stderr +++ b/tests/ui/issues/issue-2151.stderr @@ -4,7 +4,7 @@ error[E0282]: type annotations needed LL | let x = panic!(); | ^ LL | x.clone(); - | ----- type must be known at this point + | --------- type must be known at this point | help: consider giving `x` an explicit type | diff --git a/tests/ui/issues/issue-7092.rs b/tests/ui/issues/issue-7092.rs index efe8bbb6eccc5..c3c96c7d3f61d 100644 --- a/tests/ui/issues/issue-7092.rs +++ b/tests/ui/issues/issue-7092.rs @@ -9,7 +9,6 @@ fn foo(x: Whatever) { //~| expected enum `Whatever` //~| found enum `Option<_>` field.access(), - //~^ ERROR: type annotations needed } } diff --git a/tests/ui/issues/issue-7092.stderr b/tests/ui/issues/issue-7092.stderr index 8f750c237c904..e2e5748674615 100644 --- a/tests/ui/issues/issue-7092.stderr +++ b/tests/ui/issues/issue-7092.stderr @@ -9,13 +9,6 @@ LL | Some(field) => = note: expected enum `Whatever` found enum `Option<_>` -error[E0282]: type annotations needed - --> $DIR/issue-7092.rs:11:19 - | -LL | field.access(), - | ^^^^^^ cannot infer type - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error -Some errors have detailed explanations: E0282, E0308. -For more information about an error, try `rustc --explain E0282`. +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/lazy-type-alias-impl-trait/branches3.stderr b/tests/ui/lazy-type-alias-impl-trait/branches3.stderr index 270fbfa81bb89..79a95553994a9 100644 --- a/tests/ui/lazy-type-alias-impl-trait/branches3.stderr +++ b/tests/ui/lazy-type-alias-impl-trait/branches3.stderr @@ -2,7 +2,7 @@ error[E0282]: type annotations needed --> $DIR/branches3.rs:8:10 | LL | |s| s.len() - | ^ --- type must be known at this point + | ^ ------- type must be known at this point | help: consider giving this closure parameter an explicit type | @@ -13,7 +13,7 @@ error[E0282]: type annotations needed --> $DIR/branches3.rs:15:10 | LL | |s| s.len() - | ^ --- type must be known at this point + | ^ ------- type must be known at this point | help: consider giving this closure parameter an explicit type | @@ -24,7 +24,7 @@ error[E0282]: type annotations needed --> $DIR/branches3.rs:23:10 | LL | |s| s.len() - | ^ --- type must be known at this point + | ^ ------- type must be known at this point | help: consider giving this closure parameter an explicit type | @@ -35,7 +35,7 @@ error[E0282]: type annotations needed --> $DIR/branches3.rs:30:10 | LL | |s| s.len() - | ^ --- type must be known at this point + | ^ ------- type must be known at this point | help: consider giving this closure parameter an explicit type | diff --git a/tests/ui/methods/suggest-method-on-call-for-ambig-receiver.stderr b/tests/ui/methods/suggest-method-on-call-for-ambig-receiver.stderr index 40d8301c24e5c..54edeb2443a23 100644 --- a/tests/ui/methods/suggest-method-on-call-for-ambig-receiver.stderr +++ b/tests/ui/methods/suggest-method-on-call-for-ambig-receiver.stderr @@ -3,6 +3,12 @@ error[E0425]: cannot find function `consume` in this scope | LL | consume(right); | ^^^^^^^ not found in this scope + | +help: use the `.` operator to call the method `BufRead::consume` on `&mut _` + | +LL - consume(right); +LL + right.consume(); + | error: aborting due to 1 previous error diff --git a/tests/ui/self/arbitrary-self-from-method-substs.default.stderr b/tests/ui/self/arbitrary-self-from-method-substs.default.stderr index 6fff086a89c2e..4cc69666b8876 100644 --- a/tests/ui/self/arbitrary-self-from-method-substs.default.stderr +++ b/tests/ui/self/arbitrary-self-from-method-substs.default.stderr @@ -9,7 +9,6 @@ LL | fn get>(self: R) -> u32 { = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date = help: consider changing to `self`, `&self`, `&mut self`, `self: Box`, `self: Rc`, `self: Arc`, or `self: Pin

` (where P is one of the previous types except `Self`) - ERROR rustc_hir_typeck::method::confirm Foo was a subtype of &Foo but now is not? error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/span/issue-42234-unknown-receiver-type.full.stderr b/tests/ui/span/issue-42234-unknown-receiver-type.full.stderr index 6435a7b84bc19..ddf11c74908aa 100644 --- a/tests/ui/span/issue-42234-unknown-receiver-type.full.stderr +++ b/tests/ui/span/issue-42234-unknown-receiver-type.full.stderr @@ -1,23 +1,14 @@ -error[E0282]: type annotations needed - --> $DIR/issue-42234-unknown-receiver-type.rs:9:24 +error[E0599]: no method named `method_that_could_exist_on_some_type` found for type `_` in the current scope + --> $DIR/issue-42234-unknown-receiver-type.rs:10:16 | -LL | let x: Option<_> = None; - | ^^^^ cannot infer type of the type parameter `T` declared on the enum `Option` LL | x.unwrap().method_that_could_exist_on_some_type(); - | ------------------------------------ type must be known at this point - | -help: consider specifying the generic argument - | -LL | let x: Option<_> = None::; - | +++++ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method not found in `_` error[E0282]: type annotations needed - --> $DIR/issue-42234-unknown-receiver-type.rs:15:10 + --> $DIR/issue-42234-unknown-receiver-type.rs:16:10 | LL | .sum::<_>() | ^^^ cannot infer type of the type parameter `S` declared on the method `sum` -LL | .to_string() - | --------- type must be known at this point | help: consider specifying the generic argument | @@ -26,4 +17,5 @@ LL | .sum::<_>() error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0282`. +Some errors have detailed explanations: E0282, E0599. +For more information about an error, try `rustc --explain E0282`. diff --git a/tests/ui/span/issue-42234-unknown-receiver-type.generic_arg.stderr b/tests/ui/span/issue-42234-unknown-receiver-type.generic_arg.stderr index 74c46f6471237..8177b21904fa0 100644 --- a/tests/ui/span/issue-42234-unknown-receiver-type.generic_arg.stderr +++ b/tests/ui/span/issue-42234-unknown-receiver-type.generic_arg.stderr @@ -1,23 +1,14 @@ -error[E0282]: type annotations needed - --> $DIR/issue-42234-unknown-receiver-type.rs:9:24 +error[E0599]: no method named `method_that_could_exist_on_some_type` found for type `_` in the current scope + --> $DIR/issue-42234-unknown-receiver-type.rs:10:16 | -LL | let x: Option<_> = None; - | ^^^^ cannot infer type of the type parameter `T` declared on the enum `Option` LL | x.unwrap().method_that_could_exist_on_some_type(); - | ------------------------------------ type must be known at this point - | -help: consider specifying the generic argument - | -LL | let x: Option<_> = None::; - | +++++ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method not found in `_` error[E0282]: type annotations needed - --> $DIR/issue-42234-unknown-receiver-type.rs:15:10 + --> $DIR/issue-42234-unknown-receiver-type.rs:16:10 | LL | .sum::<_>() | ^^^ cannot infer type of the type parameter `S` declared on the method `sum` -LL | .to_string() - | --------- type must be known at this point | help: consider specifying the generic argument | @@ -26,4 +17,5 @@ LL | .sum::() error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0282`. +Some errors have detailed explanations: E0282, E0599. +For more information about an error, try `rustc --explain E0282`. diff --git a/tests/ui/span/issue-42234-unknown-receiver-type.rs b/tests/ui/span/issue-42234-unknown-receiver-type.rs index 53d1e3eed820e..3712305e8f16c 100644 --- a/tests/ui/span/issue-42234-unknown-receiver-type.rs +++ b/tests/ui/span/issue-42234-unknown-receiver-type.rs @@ -6,8 +6,9 @@ // the fix of which this tests). fn shines_a_beacon_through_the_darkness() { - let x: Option<_> = None; //~ ERROR type annotations needed + let x: Option<_> = None; x.unwrap().method_that_could_exist_on_some_type(); + //~^ ERROR no method named `method_that_could_exist_on_some_type` found for type `_` } fn courier_to_des_moines_and_points_west(data: &[u32]) -> String { diff --git a/tests/ui/type-alias-impl-trait/closures_in_branches.stderr b/tests/ui/type-alias-impl-trait/closures_in_branches.stderr index d6defe35866c5..1df9ad9354fe7 100644 --- a/tests/ui/type-alias-impl-trait/closures_in_branches.stderr +++ b/tests/ui/type-alias-impl-trait/closures_in_branches.stderr @@ -2,7 +2,7 @@ error[E0282]: type annotations needed --> $DIR/closures_in_branches.rs:7:10 | LL | |x| x.len() - | ^ --- type must be known at this point + | ^ ------- type must be known at this point | help: consider giving this closure parameter an explicit type | @@ -13,7 +13,7 @@ error[E0282]: type annotations needed --> $DIR/closures_in_branches.rs:21:10 | LL | |x| x.len() - | ^ --- type must be known at this point + | ^ ------- type must be known at this point | help: consider giving this closure parameter an explicit type | diff --git a/tests/ui/typeck/issue-13853.rs b/tests/ui/typeck/issue-13853.rs index ed44d5062614f..dc3bc556ddbfb 100644 --- a/tests/ui/typeck/issue-13853.rs +++ b/tests/ui/typeck/issue-13853.rs @@ -25,7 +25,7 @@ impl Node for Stuff { fn iterate>(graph: &G) { for node in graph.iter() { //~ ERROR no method named `iter` found - node.zomg(); //~ ERROR type annotations needed + node.zomg(); //~ ERROR no method named `zomg` found for type `_` } } diff --git a/tests/ui/typeck/issue-13853.stderr b/tests/ui/typeck/issue-13853.stderr index 9b8698d6ed2c0..a61308579e25a 100644 --- a/tests/ui/typeck/issue-13853.stderr +++ b/tests/ui/typeck/issue-13853.stderr @@ -17,11 +17,21 @@ error[E0599]: no method named `iter` found for reference `&G` in the current sco LL | for node in graph.iter() { | ^^^^ method not found in `&G` -error[E0282]: type annotations needed +error[E0599]: no method named `zomg` found for type `_` in the current scope --> $DIR/issue-13853.rs:28:14 | LL | node.zomg(); - | ^^^^ cannot infer type + | -----^^^^-- + | | | + | | this is an associated function, not a method + | help: use associated function syntax instead: `_::zomg()` + | + = note: found the following associated functions; to be used as methods, functions must have a `self` parameter +note: the candidate is defined in the trait `Node` + --> $DIR/issue-13853.rs:2:5 + | +LL | fn zomg(); + | ^^^^^^^^^^ error[E0308]: mismatched types --> $DIR/issue-13853.rs:37:13 @@ -45,5 +55,5 @@ LL | iterate(&graph); error: aborting due to 4 previous errors -Some errors have detailed explanations: E0282, E0308, E0599. -For more information about an error, try `rustc --explain E0282`. +Some errors have detailed explanations: E0308, E0599. +For more information about an error, try `rustc --explain E0308`.