diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs index dee3e14f3c918..bfe6392177530 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs @@ -448,8 +448,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { // FIXME(effects) let predicate_is_const = false; - if let Some(guar) = self.dcx().has_errors() - && trait_predicate.references_error() + if let Err(guar) = trait_predicate.error_reported() { return guar; } @@ -2625,9 +2624,6 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> { if let Some(e) = self.tainted_by_errors() { return e; } - if let Some(e) = self.dcx().has_errors() { - return e; - } self.emit_inference_failure_err( obligation.cause.body_id, @@ -2645,10 +2641,6 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> { if let Some(e) = self.tainted_by_errors() { return e; } - if let Some(e) = self.dcx().has_errors() { - // no need to overload user in such cases - return e; - } let SubtypePredicate { a_is_expected: _, a, b } = data; // both must be type variables, or the other would've been instantiated assert!(a.is_ty_var() && b.is_ty_var()); @@ -2728,10 +2720,6 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> { if let Some(e) = self.tainted_by_errors() { return e; } - if let Some(e) = self.dcx().has_errors() { - // no need to overload user in such cases - return e; - } struct_span_code_err!( self.dcx(), span, diff --git a/tests/ui/closures/issue-78720.rs b/tests/ui/closures/issue-78720.rs index 4cdb9f491130c..0e1f78ae3c69b 100644 --- a/tests/ui/closures/issue-78720.rs +++ b/tests/ui/closures/issue-78720.rs @@ -1,6 +1,7 @@ fn server() -> impl { //~^ ERROR at least one trait must be specified ().map2(|| "") + //~^ ERROR type annotations needed } trait FilterBase2 { diff --git a/tests/ui/closures/issue-78720.stderr b/tests/ui/closures/issue-78720.stderr index 5d65c87b0fd61..d8d3811af5a74 100644 --- a/tests/ui/closures/issue-78720.stderr +++ b/tests/ui/closures/issue-78720.stderr @@ -5,7 +5,7 @@ LL | fn server() -> impl { | ^^^^ error[E0412]: cannot find type `F` in this scope - --> $DIR/issue-78720.rs:13:12 + --> $DIR/issue-78720.rs:14:12 | LL | _func: F, | ^ @@ -22,8 +22,14 @@ help: you might be missing a type parameter LL | struct Map2 { | +++ +error[E0282]: type annotations needed + --> $DIR/issue-78720.rs:3:5 + | +LL | ().map2(|| "") + | ^^^^^^^^^^^^^^ cannot infer type + error[E0308]: mismatched types - --> $DIR/issue-78720.rs:7:39 + --> $DIR/issue-78720.rs:8:39 | LL | fn map2(self, f: F) -> Map2 {} | ^^ expected `Map2`, found `()` @@ -32,7 +38,7 @@ LL | fn map2(self, f: F) -> Map2 {} found unit type `()` error[E0277]: the size for values of type `Self` cannot be known at compilation time - --> $DIR/issue-78720.rs:7:16 + --> $DIR/issue-78720.rs:8:16 | LL | fn map2(self, f: F) -> Map2 {} | ^^^^ doesn't have a size known at compile-time @@ -47,7 +53,7 @@ help: function arguments must have a statically known size, borrowed types alway LL | fn map2(&self, f: F) -> Map2 {} | + -error: aborting due to 4 previous errors +error: aborting due to 5 previous errors -Some errors have detailed explanations: E0277, E0308, E0412. +Some errors have detailed explanations: E0277, E0282, E0308, E0412. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/const-generics/defaults/rp_impl_trait_fail.rs b/tests/ui/const-generics/defaults/rp_impl_trait_fail.rs index 80013e7b4b230..ba41bf38a3379 100644 --- a/tests/ui/const-generics/defaults/rp_impl_trait_fail.rs +++ b/tests/ui/const-generics/defaults/rp_impl_trait_fail.rs @@ -25,6 +25,6 @@ fn owo() -> impl Traitor { fn main() { rawr(); - uwu(); + uwu(); //~ ERROR: type annotations needed owo(); } diff --git a/tests/ui/const-generics/defaults/rp_impl_trait_fail.stderr b/tests/ui/const-generics/defaults/rp_impl_trait_fail.stderr index a46bd53520b53..4ed1c0ded9f86 100644 --- a/tests/ui/const-generics/defaults/rp_impl_trait_fail.stderr +++ b/tests/ui/const-generics/defaults/rp_impl_trait_fail.stderr @@ -31,6 +31,18 @@ LL | 1_u64 | = help: the trait `Traitor<1, 2>` is implemented for `u64` -error: aborting due to 3 previous errors +error[E0282]: type annotations needed + --> $DIR/rp_impl_trait_fail.rs:28:5 + | +LL | uwu(); + | ^^^ cannot infer the value of the const parameter `N` declared on the function `uwu` + | +help: consider specifying the generic argument + | +LL | uwu::(); + | +++++ + +error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0277, E0282. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/const-generics/generic_const_exprs/issue-62504.full.stderr b/tests/ui/const-generics/generic_const_exprs/issue-62504.full.stderr index 0742db398c9c4..87e26ce85dcfd 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-62504.full.stderr +++ b/tests/ui/const-generics/generic_const_exprs/issue-62504.full.stderr @@ -15,6 +15,18 @@ LL | ArrayHolder([0; Self::SIZE]) | = help: try adding a `where` bound using this expression: `where [(); Self::SIZE]:` -error: aborting due to 2 previous errors +error[E0282]: type annotations needed for `ArrayHolder` + --> $DIR/issue-62504.rs:26:9 + | +LL | let mut array = ArrayHolder::new(); + | ^^^^^^^^^ + | +help: consider giving `array` an explicit type, where the value of const parameter `X` is specified + | +LL | let mut array: ArrayHolder = ArrayHolder::new(); + | ++++++++++++++++ + +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0308`. +Some errors have detailed explanations: E0282, E0308. +For more information about an error, try `rustc --explain E0282`. diff --git a/tests/ui/const-generics/generic_const_exprs/issue-62504.min.stderr b/tests/ui/const-generics/generic_const_exprs/issue-62504.min.stderr index 65822856e1d7c..1664669eee05a 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-62504.min.stderr +++ b/tests/ui/const-generics/generic_const_exprs/issue-62504.min.stderr @@ -22,6 +22,18 @@ note: tuple struct defined here LL | struct ArrayHolder([u32; X]); | ^^^^^^^^^^^ -error: aborting due to 2 previous errors +error[E0282]: type annotations needed for `ArrayHolder` + --> $DIR/issue-62504.rs:26:9 + | +LL | let mut array = ArrayHolder::new(); + | ^^^^^^^^^ + | +help: consider giving `array` an explicit type, where the value of const parameter `X` is specified + | +LL | let mut array: ArrayHolder = ArrayHolder::new(); + | ++++++++++++++++ + +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0308`. +Some errors have detailed explanations: E0282, E0308. +For more information about an error, try `rustc --explain E0282`. diff --git a/tests/ui/const-generics/generic_const_exprs/issue-62504.rs b/tests/ui/const-generics/generic_const_exprs/issue-62504.rs index a97f4b8ff3131..6f40a9abfa796 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-62504.rs +++ b/tests/ui/const-generics/generic_const_exprs/issue-62504.rs @@ -24,4 +24,5 @@ impl ArrayHolder { fn main() { let mut array = ArrayHolder::new(); + //~^ ERROR: type annotations needed } diff --git a/tests/ui/consts/issue-104609.rs b/tests/ui/consts/issue-104609.rs index 01fd1c48cf803..9ee83b409c16f 100644 --- a/tests/ui/consts/issue-104609.rs +++ b/tests/ui/consts/issue-104609.rs @@ -5,6 +5,7 @@ fn foo() { unsafe fn bar() { std::mem::transmute::<_, *mut _>(1_u8); + //~^ ERROR: type annotations needed } fn main() {} diff --git a/tests/ui/consts/issue-104609.stderr b/tests/ui/consts/issue-104609.stderr index 8d0526978ed9e..fe84d83725fd2 100644 --- a/tests/ui/consts/issue-104609.stderr +++ b/tests/ui/consts/issue-104609.stderr @@ -4,6 +4,13 @@ error[E0425]: cannot find value `oops` in this scope LL | oops; | ^^^^ not found in this scope -error: aborting due to 1 previous error +error[E0282]: type annotations needed + --> $DIR/issue-104609.rs:7:5 + | +LL | std::mem::transmute::<_, *mut _>(1_u8); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `Dst` declared on the function `transmute` + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0425`. +Some errors have detailed explanations: E0282, E0425. +For more information about an error, try `rustc --explain E0282`. diff --git a/tests/ui/generic-const-items/parameter-defaults.stderr b/tests/ui/generic-const-items/parameter-defaults.stderr index 697423e8dc399..b8220af5d0e93 100644 --- a/tests/ui/generic-const-items/parameter-defaults.stderr +++ b/tests/ui/generic-const-items/parameter-defaults.stderr @@ -8,7 +8,7 @@ error[E0282]: type annotations needed for `Option` --> $DIR/parameter-defaults.rs:13:9 | LL | let _ = NONE; - | ^ + | ^ ---- type must be known at this point | help: consider giving this pattern a type, where the type for type parameter `T` is specified | diff --git a/tests/ui/inference/need_type_info/type-alias.rs b/tests/ui/inference/need_type_info/type-alias.rs index f921b046b6cac..b24af2d484954 100644 --- a/tests/ui/inference/need_type_info/type-alias.rs +++ b/tests/ui/inference/need_type_info/type-alias.rs @@ -15,7 +15,7 @@ fn direct_alias() { type IndirectAlias = Ty>; fn indirect_alias() { - IndirectAlias::new(); + IndirectAlias::new(); //~ ERROR: type annotations needed // FIXME: This should also emit an error. // // Added it separately as `type-alias-indirect.rs` diff --git a/tests/ui/inference/need_type_info/type-alias.stderr b/tests/ui/inference/need_type_info/type-alias.stderr index cc7053bf385ff..2c39a3f56466f 100644 --- a/tests/ui/inference/need_type_info/type-alias.stderr +++ b/tests/ui/inference/need_type_info/type-alias.stderr @@ -4,12 +4,18 @@ error[E0282]: type annotations needed LL | DirectAlias::new() | ^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `T` +error[E0282]: type annotations needed + --> $DIR/type-alias.rs:18:5 + | +LL | IndirectAlias::new(); + | ^^^^^^^^^^^^^ cannot infer type for type parameter `T` declared on the type alias `IndirectAlias` + error[E0282]: type annotations needed --> $DIR/type-alias.rs:32:5 | LL | DirectButWithDefaultAlias::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `T` -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/parser/issues/issue-89574.rs b/tests/ui/parser/issues/issue-89574.rs index 0a477f1aa5fb6..bafb0ce5e6680 100644 --- a/tests/ui/parser/issues/issue-89574.rs +++ b/tests/ui/parser/issues/issue-89574.rs @@ -1,4 +1,6 @@ fn main() { const EMPTY_ARRAY = []; //~^ missing type for `const` item + //~| ERROR type annotations needed + //~| ERROR type annotations needed } diff --git a/tests/ui/parser/issues/issue-89574.stderr b/tests/ui/parser/issues/issue-89574.stderr index 5f8f6f9396938..a0586d41e2e59 100644 --- a/tests/ui/parser/issues/issue-89574.stderr +++ b/tests/ui/parser/issues/issue-89574.stderr @@ -1,8 +1,23 @@ +error[E0282]: type annotations needed + --> $DIR/issue-89574.rs:2:25 + | +LL | const EMPTY_ARRAY = []; + | ^^ cannot infer type + error: missing type for `const` item --> $DIR/issue-89574.rs:2:22 | LL | const EMPTY_ARRAY = []; | ^ help: provide a type for the item: `: ` -error: aborting due to 1 previous error +error[E0282]: type annotations needed + --> $DIR/issue-89574.rs:2:25 + | +LL | const EMPTY_ARRAY = []; + | ^^ cannot infer type + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 3 previous errors +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/parser/missing-closing-angle-bracket-eq-constraint.stderr b/tests/ui/parser/missing-closing-angle-bracket-eq-constraint.stderr index e40d985826282..b21e788aa7300 100644 --- a/tests/ui/parser/missing-closing-angle-bracket-eq-constraint.stderr +++ b/tests/ui/parser/missing-closing-angle-bracket-eq-constraint.stderr @@ -41,7 +41,7 @@ error[E0282]: type annotations needed for `Vec<_>` --> $DIR/missing-closing-angle-bracket-eq-constraint.rs:7:7 | LL | let v : Vec<(u32,_) = vec![]; - | ^ + | ^ ------ type must be known at this point | help: consider giving `v` an explicit type, where the placeholders `_` are specified | @@ -52,7 +52,7 @@ error[E0282]: type annotations needed for `Vec<_>` --> $DIR/missing-closing-angle-bracket-eq-constraint.rs:18:7 | LL | let v : Vec<'a = vec![]; - | ^ + | ^ ------ type must be known at this point | help: consider giving `v` an explicit type, where the placeholders `_` are specified | diff --git a/tests/ui/traits/next-solver/specialization-transmute.rs b/tests/ui/traits/next-solver/specialization-transmute.rs index e7de564877d09..6f93a1d3f40dc 100644 --- a/tests/ui/traits/next-solver/specialization-transmute.rs +++ b/tests/ui/traits/next-solver/specialization-transmute.rs @@ -14,6 +14,7 @@ impl Default for T { default type Id = T; //~ ERROR type annotations needed // This will be fixed by #111994 fn intu(&self) -> &Self::Id { + //~^ ERROR type annotations needed self } } diff --git a/tests/ui/traits/next-solver/specialization-transmute.stderr b/tests/ui/traits/next-solver/specialization-transmute.stderr index a1cf5b761e34f..946a7cbaa808f 100644 --- a/tests/ui/traits/next-solver/specialization-transmute.stderr +++ b/tests/ui/traits/next-solver/specialization-transmute.stderr @@ -10,12 +10,19 @@ LL | #![feature(specialization)] error: cannot normalize `::Id` +error[E0284]: type annotations needed: cannot satisfy `::Id == _` + --> $DIR/specialization-transmute.rs:16:23 + | +LL | fn intu(&self) -> &Self::Id { + | ^^^^^^^^^ cannot satisfy `::Id == _` + error[E0282]: type annotations needed --> $DIR/specialization-transmute.rs:14:23 | LL | default type Id = T; | ^ cannot infer type for associated type `::Id` -error: aborting due to 2 previous errors; 1 warning emitted +error: aborting due to 3 previous errors; 1 warning emitted -For more information about this error, try `rustc --explain E0282`. +Some errors have detailed explanations: E0282, E0284. +For more information about an error, try `rustc --explain E0282`. diff --git a/tests/ui/typeck/issue-104510-ice.rs b/tests/ui/typeck/issue-104510-ice.rs index 157bdf07e3826..635cc8fad66f1 100644 --- a/tests/ui/typeck/issue-104510-ice.rs +++ b/tests/ui/typeck/issue-104510-ice.rs @@ -6,7 +6,7 @@ struct W(Oops); unsafe fn test() { let j = W(()); - let pointer = &j as *const _; + let pointer = &j as *const _; //~ ERROR type annotations needed core::arch::asm!( "nop", in("eax") pointer, diff --git a/tests/ui/typeck/issue-104510-ice.stderr b/tests/ui/typeck/issue-104510-ice.stderr index 143139b2c089c..774e52681849f 100644 --- a/tests/ui/typeck/issue-104510-ice.stderr +++ b/tests/ui/typeck/issue-104510-ice.stderr @@ -4,6 +4,18 @@ error[E0412]: cannot find type `Oops` in this scope LL | struct W(Oops); | ^^^^ not found in this scope -error: aborting due to 1 previous error +error[E0282]: type annotations needed for `*const W` + --> $DIR/issue-104510-ice.rs:9:9 + | +LL | let pointer = &j as *const _; + | ^^^^^^^ + | +help: consider giving `pointer` an explicit type, where the type for type parameter `T` is specified + | +LL | let pointer: *const W = &j as *const _; + | +++++++++++++ + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0412`. +Some errors have detailed explanations: E0282, E0412. +For more information about an error, try `rustc --explain E0282`.