From ed019dc58d9e675942cf4cfc35d7fede28d88ad5 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 24 Jul 2024 08:55:49 +0000 Subject: [PATCH] Taint obligations in confirmation --- .../rustc_hir_typeck/src/method/suggest.rs | 4 ++ compiler/rustc_middle/src/ty/generic_args.rs | 9 +++ .../src/traits/select/mod.rs | 12 ++++ tests/crashes/123141.rs | 23 ------- tests/crashes/124350.rs | 17 ----- tests/crashes/125874.rs | 22 ------ tests/crashes/126942.rs | 11 --- .../unconstrained_impl_param.rs | 18 +++++ .../unconstrained_impl_param.stderr | 9 +++ tests/ui/const-generics/kind_mismatch2.rs | 14 ++++ tests/ui/const-generics/kind_mismatch2.stderr | 9 +++ .../bugs/issue-87735.stderr | 68 +------------------ .../in-trait/refine-resolution-errors.rs | 2 +- .../in-trait/refine-resolution-errors.stderr | 22 ++++-- tests/ui/impl-trait/issues/issue-87340.rs | 2 - tests/ui/impl-trait/issues/issue-87340.stderr | 17 +---- tests/ui/impl-unused-tps.rs | 7 +- tests/ui/impl-unused-tps.stderr | 53 ++++++++++----- ...e-failed-to-resolve-instance-for-110696.rs | 1 - ...iled-to-resolve-instance-for-110696.stderr | 15 +--- .../impl-with-unconstrained-param.rs | 2 - .../impl-with-unconstrained-param.stderr | 17 +---- tests/ui/type-alias-impl-trait/issue-74244.rs | 1 - .../type-alias-impl-trait/issue-74244.stderr | 11 +-- 24 files changed, 138 insertions(+), 228 deletions(-) delete mode 100644 tests/crashes/123141.rs delete mode 100644 tests/crashes/124350.rs delete mode 100644 tests/crashes/125874.rs delete mode 100644 tests/crashes/126942.rs create mode 100644 tests/ui/associated-item/unconstrained_impl_param.rs create mode 100644 tests/ui/associated-item/unconstrained_impl_param.stderr create mode 100644 tests/ui/const-generics/kind_mismatch2.rs create mode 100644 tests/ui/const-generics/kind_mismatch2.stderr diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index 94133357a3eb5..2910f4f24c0a3 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -629,6 +629,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; let is_method = mode == Mode::MethodCall; let unsatisfied_predicates = &no_match_data.unsatisfied_predicates; + if let Err(guar) = unsatisfied_predicates.error_reported() { + return guar; + } + let similar_candidate = no_match_data.similar_candidate; let item_kind = if is_method { "method" diff --git a/compiler/rustc_middle/src/ty/generic_args.rs b/compiler/rustc_middle/src/ty/generic_args.rs index 80c31e236e2c2..28e457fb52255 100644 --- a/compiler/rustc_middle/src/ty/generic_args.rs +++ b/compiler/rustc_middle/src/ty/generic_args.rs @@ -13,6 +13,7 @@ use rustc_errors::{DiagArgValue, IntoDiagArg}; use rustc_hir::def_id::DefId; use rustc_macros::{extension, HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable}; use rustc_serialize::{Decodable, Encodable}; +use rustc_span::ErrorGuaranteed; use rustc_type_ir::WithCachedTypeInfo; use smallvec::SmallVec; @@ -302,6 +303,14 @@ impl<'tcx> GenericArg<'tcx> { GenericArgKind::Const(ct) => ct.is_ct_infer(), } } + + pub fn to_error(self, tcx: TyCtxt<'tcx>, guar: ErrorGuaranteed) -> Self { + match self.unpack() { + ty::GenericArgKind::Lifetime(_) => ty::Region::new_error(tcx, guar).into(), + ty::GenericArgKind::Type(_) => Ty::new_error(tcx, guar).into(), + ty::GenericArgKind::Const(_) => ty::Const::new_error(tcx, guar).into(), + } + } } impl<'a, 'tcx> Lift> for GenericArg<'a> { diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index cc9174d3aad52..8ba4cb776d7a1 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -2766,6 +2766,18 @@ impl<'tcx> SelectionContext<'_, 'tcx> { // `$1: Copy`, so we must ensure the obligations are emitted in // that order. let predicates = tcx.predicates_of(def_id); + if let Err(guar) = predicates.errored_due_to_unconstrained_params { + self.infcx.set_tainted_by_errors(guar); + // Constrain any inference variables to their error variant to ensure unconstrained + // generic parameters don't leak as they'll never get constrained. + for arg in args { + let _ = self.infcx.at(cause, param_env).eq( + DefineOpaqueTypes::Yes, + arg, + arg.to_error(tcx, guar), + ); + } + } assert_eq!(predicates.parent, None); let predicates = predicates.instantiate_own(tcx, args); let mut obligations = Vec::with_capacity(predicates.len()); diff --git a/tests/crashes/123141.rs b/tests/crashes/123141.rs deleted file mode 100644 index 07181387e0450..0000000000000 --- a/tests/crashes/123141.rs +++ /dev/null @@ -1,23 +0,0 @@ -//@ known-bug: #123141 - -trait Trait { - fn next(self) -> Self::Item; - type Item; -} - -struct Foo(T); - -impl Trait for Foo { - type Item = Foo; - fn next(self) -> Self::Item { - loop {} - } -} - -fn opaque() -> impl Trait { - Foo::<_>(10_u32) -} - -fn main() { - opaque().next(); -} diff --git a/tests/crashes/124350.rs b/tests/crashes/124350.rs deleted file mode 100644 index d6038f280cf81..0000000000000 --- a/tests/crashes/124350.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ known-bug: #124350 - -struct Node {} - -impl Node -where - SmallVec<{ D * 2 }>:, -{ - fn new() -> Self { - let mut node = Node::new(); - (&a, 0)(); - - node - } -} - -struct SmallVec {} diff --git a/tests/crashes/125874.rs b/tests/crashes/125874.rs deleted file mode 100644 index 6a2713cd7c896..0000000000000 --- a/tests/crashes/125874.rs +++ /dev/null @@ -1,22 +0,0 @@ -//@ known-bug: rust-lang/rust#125874 -pub trait A {} - -pub trait Mirror { - type Assoc: ?Sized; -} -impl Mirror for dyn A { - type Assoc = T; -} - -struct Bar { - foo: ::Assoc, -} - -pub fn main() { - let strct = Bar { foo: 3 }; - - match strct { - Bar { foo: 1, .. } => {} - _ => (), - }; -} diff --git a/tests/crashes/126942.rs b/tests/crashes/126942.rs deleted file mode 100644 index e4adc8fab287e..0000000000000 --- a/tests/crashes/126942.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ known-bug: rust-lang/rust#126942 -struct Thing; - -pub trait Every { - type Assoc; -} -impl Every for Thing { - type Assoc = T; -} - -static I: ::Assoc = 3; diff --git a/tests/ui/associated-item/unconstrained_impl_param.rs b/tests/ui/associated-item/unconstrained_impl_param.rs new file mode 100644 index 0000000000000..4a3cda6b4d6d4 --- /dev/null +++ b/tests/ui/associated-item/unconstrained_impl_param.rs @@ -0,0 +1,18 @@ +//! This test used to ICE during the normalization of +//! `I`'s type, because of the mismatch of generic parameters +//! on the impl with the generic parameters the projection can +//! fulfill. + +struct Thing; + +pub trait Every { + type Assoc; +} +impl Every for Thing { + //~^ ERROR: `T` is not constrained + type Assoc = T; +} + +static I: ::Assoc = 3; + +fn main() {} diff --git a/tests/ui/associated-item/unconstrained_impl_param.stderr b/tests/ui/associated-item/unconstrained_impl_param.stderr new file mode 100644 index 0000000000000..b7c76266cf237 --- /dev/null +++ b/tests/ui/associated-item/unconstrained_impl_param.stderr @@ -0,0 +1,9 @@ +error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates + --> $DIR/unconstrained_impl_param.rs:11:6 + | +LL | impl Every for Thing { + | ^ unconstrained type parameter + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0207`. diff --git a/tests/ui/const-generics/kind_mismatch2.rs b/tests/ui/const-generics/kind_mismatch2.rs new file mode 100644 index 0000000000000..9df9d15286e01 --- /dev/null +++ b/tests/ui/const-generics/kind_mismatch2.rs @@ -0,0 +1,14 @@ +struct Node {} + +impl Node<{ D }> +where + SmallVec:, //~ ERROR: constant provided when a type was expected +{ + fn new() {} +} + +struct SmallVec(T); + +fn main() { + Node::new(); +} diff --git a/tests/ui/const-generics/kind_mismatch2.stderr b/tests/ui/const-generics/kind_mismatch2.stderr new file mode 100644 index 0000000000000..6ad32f2763e83 --- /dev/null +++ b/tests/ui/const-generics/kind_mismatch2.stderr @@ -0,0 +1,9 @@ +error[E0747]: constant provided when a type was expected + --> $DIR/kind_mismatch2.rs:5:14 + | +LL | SmallVec:, + | ^ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0747`. diff --git a/tests/ui/generic-associated-types/bugs/issue-87735.stderr b/tests/ui/generic-associated-types/bugs/issue-87735.stderr index d80050652389d..1b95543136303 100644 --- a/tests/ui/generic-associated-types/bugs/issue-87735.stderr +++ b/tests/ui/generic-associated-types/bugs/issue-87735.stderr @@ -22,73 +22,7 @@ help: consider adding an explicit lifetime bound LL | type Output<'a> = FooRef<'a, U> where Self: 'a, U: 'a; | +++++++ -error[E0309]: the parameter type `T` may not live long enough - --> $DIR/issue-87735.rs:31:15 - | -LL | impl<'b, T, U> AsRef2 for Foo - | -- the parameter type `T` must be valid for the lifetime `'b` as defined here... -... -LL | T: AsRef2 = &'b [U]>, - | ^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds... - | -note: ...that is required by this bound - --> $DIR/issue-87735.rs:7:31 - | -LL | type Output<'a> where Self: 'a; - | ^^ -help: consider adding an explicit lifetime bound - | -LL | T: AsRef2 = &'b [U]> + 'b, - | ++++ - -error[E0309]: the parameter type `T` may not live long enough - --> $DIR/issue-87735.rs:36:31 - | -LL | impl<'b, T, U> AsRef2 for Foo - | -- the parameter type `T` must be valid for the lifetime `'b` as defined here... -... -LL | fn as_ref2<'a>(&'a self) -> Self::Output<'a> { - | ^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds... - | -note: ...that is required by this bound - --> $DIR/issue-87735.rs:7:31 - | -LL | type Output<'a> where Self: 'a; - | ^^ -help: consider adding an explicit lifetime bound - | -LL | T: AsRef2 = &'b [U]> + 'b, - | ++++ - -error: lifetime may not live long enough - --> $DIR/issue-87735.rs:37:5 - | -LL | impl<'b, T, U> AsRef2 for Foo - | -- lifetime `'b` defined here -... -LL | fn as_ref2<'a>(&'a self) -> Self::Output<'a> { - | -- lifetime `'a` defined here -LL | FooRef(self.0.as_ref2()) - | ^^^^^^^^^^^^^^^^^^^^^^^^ method was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b` - | - = help: consider adding the following bound: `'b: 'a` - -error: lifetime may not live long enough - --> $DIR/issue-87735.rs:37:12 - | -LL | impl<'b, T, U> AsRef2 for Foo - | -- lifetime `'b` defined here -... -LL | fn as_ref2<'a>(&'a self) -> Self::Output<'a> { - | -- lifetime `'a` defined here -LL | FooRef(self.0.as_ref2()) - | ^^^^^^^^^^^^^^^^ argument requires that `'a` must outlive `'b` - | - = help: consider adding the following bound: `'a: 'b` - -help: `'b` and `'a` must be the same: replace one with the other - -error: aborting due to 6 previous errors +error: aborting due to 2 previous errors Some errors have detailed explanations: E0207, E0309. For more information about an error, try `rustc --explain E0207`. diff --git a/tests/ui/impl-trait/in-trait/refine-resolution-errors.rs b/tests/ui/impl-trait/in-trait/refine-resolution-errors.rs index a9936c7bc3fee..d0fa1d536da71 100644 --- a/tests/ui/impl-trait/in-trait/refine-resolution-errors.rs +++ b/tests/ui/impl-trait/in-trait/refine-resolution-errors.rs @@ -13,11 +13,11 @@ impl Mirror for () { pub trait First { async fn first() -> <() as Mirror>::Assoc; - //~^ ERROR type annotations needed } impl First for () { async fn first() {} + //~^ WARN does not match trait method signature } fn main() {} diff --git a/tests/ui/impl-trait/in-trait/refine-resolution-errors.stderr b/tests/ui/impl-trait/in-trait/refine-resolution-errors.stderr index 0f5573dda04c1..69875559eef1c 100644 --- a/tests/ui/impl-trait/in-trait/refine-resolution-errors.stderr +++ b/tests/ui/impl-trait/in-trait/refine-resolution-errors.stderr @@ -4,13 +4,23 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self LL | impl Mirror for () { | ^ unconstrained type parameter -error[E0282]: type annotations needed - --> $DIR/refine-resolution-errors.rs:15:5 +warning: impl trait in impl method signature does not match trait method signature + --> $DIR/refine-resolution-errors.rs:19:5 | LL | async fn first() -> <() as Mirror>::Assoc; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type + | ------------------------------------------ return type from trait method defined here +... +LL | async fn first() {} + | ^^^^^^^^^^^^^^^^ this bound is stronger than that defined on the trait + | + = note: add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate + = note: we are soliciting feedback, see issue #121718 for more information + = note: `#[warn(refining_impl_trait_reachable)]` on by default +help: replace the return type so that it matches the trait + | +LL | <() as Mirror>::Assoc {} + | ~~~~~~~~~~~~~~~~~~~~~ -error: aborting due to 2 previous errors +error: aborting due to 1 previous error; 1 warning emitted -Some errors have detailed explanations: E0207, E0282. -For more information about an error, try `rustc --explain E0207`. +For more information about this error, try `rustc --explain E0207`. diff --git a/tests/ui/impl-trait/issues/issue-87340.rs b/tests/ui/impl-trait/issues/issue-87340.rs index b1baaaa6ba5c1..705a4addcb704 100644 --- a/tests/ui/impl-trait/issues/issue-87340.rs +++ b/tests/ui/impl-trait/issues/issue-87340.rs @@ -9,8 +9,6 @@ impl X for () { //~^ ERROR `T` is not constrained by the impl trait, self type, or predicates type I = impl Sized; fn f() -> Self::I {} - //~^ ERROR type annotations needed - //~| ERROR type annotations needed } fn main() {} diff --git a/tests/ui/impl-trait/issues/issue-87340.stderr b/tests/ui/impl-trait/issues/issue-87340.stderr index 1be4087be4242..8513cb2881e1f 100644 --- a/tests/ui/impl-trait/issues/issue-87340.stderr +++ b/tests/ui/impl-trait/issues/issue-87340.stderr @@ -4,19 +4,6 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self LL | impl X for () { | ^ unconstrained type parameter -error[E0282]: type annotations needed - --> $DIR/issue-87340.rs:11:23 - | -LL | fn f() -> Self::I {} - | ^^ cannot infer type for type parameter `T` - -error[E0282]: type annotations needed - --> $DIR/issue-87340.rs:11:15 - | -LL | fn f() -> Self::I {} - | ^^^^^^^ cannot infer type for type parameter `T` - -error: aborting due to 3 previous errors +error: aborting due to 1 previous error -Some errors have detailed explanations: E0207, E0282. -For more information about an error, try `rustc --explain E0207`. +For more information about this error, try `rustc --explain E0207`. diff --git a/tests/ui/impl-unused-tps.rs b/tests/ui/impl-unused-tps.rs index 3eb9daedf76d7..3870d23dd9eec 100644 --- a/tests/ui/impl-unused-tps.rs +++ b/tests/ui/impl-unused-tps.rs @@ -1,5 +1,3 @@ -//~ ERROR overflow evaluating the requirement `([isize; 0], _): Sized - trait Foo { fn get(&self, A: &A) { } } @@ -36,7 +34,7 @@ impl Bar for T { // Using `U` in an associated type within the impl is not good enough! } -impl Bar for T +impl Bar for T //~ ERROR conflicting implementations where T : Bar { //~^^^ ERROR the type parameter `U` is not constrained @@ -49,12 +47,13 @@ impl Foo for T { //~^^^ ERROR the type parameter `U` is not constrained //~| ERROR the type parameter `V` is not constrained + //~| ERROR conflicting implementations // Here, `V` is bound by an output type parameter, but the inputs // are not themselves constrained. } -impl Foo<(T,U)> for T +impl Foo<(T,U)> for T //~ ERROR conflicting implementations where (T,U): Bar { // As above, but both T and U ARE constrained. diff --git a/tests/ui/impl-unused-tps.stderr b/tests/ui/impl-unused-tps.stderr index 0df46b04c9c67..4df1c40749582 100644 --- a/tests/ui/impl-unused-tps.stderr +++ b/tests/ui/impl-unused-tps.stderr @@ -1,29 +1,29 @@ error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates - --> $DIR/impl-unused-tps.rs:47:8 + --> $DIR/impl-unused-tps.rs:45:8 | LL | impl Foo for T | ^ unconstrained type parameter error[E0207]: the type parameter `V` is not constrained by the impl trait, self type, or predicates - --> $DIR/impl-unused-tps.rs:47:10 + --> $DIR/impl-unused-tps.rs:45:10 | LL | impl Foo for T | ^ unconstrained type parameter error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates - --> $DIR/impl-unused-tps.rs:31:8 + --> $DIR/impl-unused-tps.rs:29:8 | LL | impl Bar for T { | ^ unconstrained type parameter error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates - --> $DIR/impl-unused-tps.rs:39:8 + --> $DIR/impl-unused-tps.rs:37:8 | LL | impl Bar for T | ^ unconstrained type parameter error[E0119]: conflicting implementations of trait `Foo<_>` for type `[isize; 0]` - --> $DIR/impl-unused-tps.rs:27:1 + --> $DIR/impl-unused-tps.rs:25:1 | LL | impl Foo for [isize;0] { | ---------------------------- first implementation here @@ -31,26 +31,43 @@ LL | impl Foo for [isize;0] { LL | impl Foo for U { | ^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `[isize; 0]` -error[E0275]: overflow evaluating the requirement `([isize; 0], _): Sized` +error[E0119]: conflicting implementations of trait `Foo<[isize; 0]>` for type `[isize; 0]` + --> $DIR/impl-unused-tps.rs:45:1 | - = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`impl_unused_tps`) -note: required for `([isize; 0], _)` to implement `Bar` - --> $DIR/impl-unused-tps.rs:31:11 +LL | impl Foo for [isize;0] { + | ---------------------------- first implementation here +... +LL | / impl Foo for T +LL | | where (T,U): Bar + | |___________________________^ conflicting implementation for `[isize; 0]` + +error[E0119]: conflicting implementations of trait `Foo<([isize; 0], _)>` for type `[isize; 0]` + --> $DIR/impl-unused-tps.rs:56:1 | -LL | impl Bar for T { - | - ^^^ ^ - | | - | unsatisfied trait bound introduced here - = note: 126 redundant requirements hidden - = note: required for `([isize; 0], _)` to implement `Bar` +LL | impl Foo for [isize;0] { + | ---------------------------- first implementation here +... +LL | / impl Foo<(T,U)> for T +LL | | where (T,U): Bar + | |___________________________^ conflicting implementation for `[isize; 0]` error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates - --> $DIR/impl-unused-tps.rs:15:8 + --> $DIR/impl-unused-tps.rs:13:8 | LL | impl Foo for [isize;1] { | ^ unconstrained type parameter -error: aborting due to 7 previous errors +error[E0119]: conflicting implementations of trait `Bar` + --> $DIR/impl-unused-tps.rs:37:1 + | +LL | impl Bar for T { + | ------------------- first implementation here +... +LL | / impl Bar for T +LL | | where T : Bar + | |________________________^ conflicting implementation + +error: aborting due to 9 previous errors -Some errors have detailed explanations: E0119, E0207, E0275. +Some errors have detailed explanations: E0119, E0207. For more information about an error, try `rustc --explain E0119`. diff --git a/tests/ui/type-alias-impl-trait/ice-failed-to-resolve-instance-for-110696.rs b/tests/ui/type-alias-impl-trait/ice-failed-to-resolve-instance-for-110696.rs index 0ee188d825f0d..2bcb8f06f4fd6 100644 --- a/tests/ui/type-alias-impl-trait/ice-failed-to-resolve-instance-for-110696.rs +++ b/tests/ui/type-alias-impl-trait/ice-failed-to-resolve-instance-for-110696.rs @@ -42,7 +42,6 @@ impl>>, U> MyIndex> for Scope { //~^ ERROR the type parameter `T` is not constrained by the impl type O = T; fn my_index(self) -> Self::O { - //~^ ERROR item does not constrain MyFrom::my_from(self.0).ok().unwrap() } } diff --git a/tests/ui/type-alias-impl-trait/ice-failed-to-resolve-instance-for-110696.stderr b/tests/ui/type-alias-impl-trait/ice-failed-to-resolve-instance-for-110696.stderr index 70675b446d126..3dd78cfda97e5 100644 --- a/tests/ui/type-alias-impl-trait/ice-failed-to-resolve-instance-for-110696.stderr +++ b/tests/ui/type-alias-impl-trait/ice-failed-to-resolve-instance-for-110696.stderr @@ -17,19 +17,6 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self LL | impl>>, U> MyIndex> for Scope { | ^ unconstrained type parameter -error: item does not constrain `DummyT::{opaque#0}`, but has it in its signature - --> $DIR/ice-failed-to-resolve-instance-for-110696.rs:44:8 - | -LL | fn my_index(self) -> Self::O { - | ^^^^^^^^ - | - = note: consider moving the opaque type's declaration and defining uses into a separate module -note: this opaque type is in the signature - --> $DIR/ice-failed-to-resolve-instance-for-110696.rs:20:18 - | -LL | type DummyT = impl F; - | ^^^^^^ - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0207`. diff --git a/tests/ui/type-alias-impl-trait/impl-with-unconstrained-param.rs b/tests/ui/type-alias-impl-trait/impl-with-unconstrained-param.rs index fcac83500ec4f..1824ff5e2fb82 100644 --- a/tests/ui/type-alias-impl-trait/impl-with-unconstrained-param.rs +++ b/tests/ui/type-alias-impl-trait/impl-with-unconstrained-param.rs @@ -12,8 +12,6 @@ impl X for () { //~^ ERROR the type parameter `T` is not constrained type I = impl Sized; fn f() -> Self::I {} - //~^ ERROR type annotations needed - //~| ERROR type annotations needed } fn main() {} diff --git a/tests/ui/type-alias-impl-trait/impl-with-unconstrained-param.stderr b/tests/ui/type-alias-impl-trait/impl-with-unconstrained-param.stderr index bb0e11d314c33..137a4db81b563 100644 --- a/tests/ui/type-alias-impl-trait/impl-with-unconstrained-param.stderr +++ b/tests/ui/type-alias-impl-trait/impl-with-unconstrained-param.stderr @@ -4,19 +4,6 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self LL | impl X for () { | ^ unconstrained type parameter -error[E0282]: type annotations needed - --> $DIR/impl-with-unconstrained-param.rs:14:23 - | -LL | fn f() -> Self::I {} - | ^^ cannot infer type for type parameter `T` - -error[E0282]: type annotations needed - --> $DIR/impl-with-unconstrained-param.rs:14:15 - | -LL | fn f() -> Self::I {} - | ^^^^^^^ cannot infer type for type parameter `T` - -error: aborting due to 3 previous errors +error: aborting due to 1 previous error -Some errors have detailed explanations: E0207, E0282. -For more information about an error, try `rustc --explain E0207`. +For more information about this error, try `rustc --explain E0207`. diff --git a/tests/ui/type-alias-impl-trait/issue-74244.rs b/tests/ui/type-alias-impl-trait/issue-74244.rs index ce8a38a3361f8..bb4104b3d2519 100644 --- a/tests/ui/type-alias-impl-trait/issue-74244.rs +++ b/tests/ui/type-alias-impl-trait/issue-74244.rs @@ -14,7 +14,6 @@ impl Allocator for DefaultAllocator { type A = impl Fn(::Buffer); fn foo() -> A { - //~^ ERROR: type annotations needed |_| () } diff --git a/tests/ui/type-alias-impl-trait/issue-74244.stderr b/tests/ui/type-alias-impl-trait/issue-74244.stderr index d2b50ffd86b59..f5ca56bacccf6 100644 --- a/tests/ui/type-alias-impl-trait/issue-74244.stderr +++ b/tests/ui/type-alias-impl-trait/issue-74244.stderr @@ -4,13 +4,6 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self LL | impl Allocator for DefaultAllocator { | ^ unconstrained type parameter -error[E0282]: type annotations needed - --> $DIR/issue-74244.rs:16:13 - | -LL | fn foo() -> A { - | ^ cannot infer type for type parameter `T` - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error -Some errors have detailed explanations: E0207, E0282. -For more information about an error, try `rustc --explain E0207`. +For more information about this error, try `rustc --explain E0207`.