about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-01-31 16:24:07 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-01-31 16:51:42 +0000
commita6b1e433dad909d24c931a289b2daa493804769d (patch)
treef9d3108013c653d3cdce867c50335e408a4f1c92
parentf7531f18b8279141d1afc20d016c82e6c627eab0 (diff)
downloadrust-a6b1e433dad909d24c931a289b2daa493804769d.tar.gz
rust-a6b1e433dad909d24c931a289b2daa493804769d.zip
Remove a has_errors check that only hides errors after unrelated items have errored.
-rw-r--r--compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs3
-rw-r--r--tests/ui/closures/issue-78720.rs1
-rw-r--r--tests/ui/closures/issue-78720.stderr16
-rw-r--r--tests/ui/const-generics/defaults/rp_impl_trait_fail.rs2
-rw-r--r--tests/ui/const-generics/defaults/rp_impl_trait_fail.stderr16
-rw-r--r--tests/ui/const-generics/generic_const_exprs/issue-62504.full.stderr16
-rw-r--r--tests/ui/const-generics/generic_const_exprs/issue-62504.min.stderr16
-rw-r--r--tests/ui/const-generics/generic_const_exprs/issue-62504.rs1
-rw-r--r--tests/ui/consts/issue-104609.rs1
-rw-r--r--tests/ui/consts/issue-104609.stderr11
-rw-r--r--tests/ui/inference/need_type_info/type-alias.rs2
-rw-r--r--tests/ui/inference/need_type_info/type-alias.stderr8
-rw-r--r--tests/ui/typeck/issue-104510-ice.rs2
-rw-r--r--tests/ui/typeck/issue-104510-ice.stderr16
14 files changed, 89 insertions, 22 deletions
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 4f372eff823..c437b97b03e 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
@@ -2624,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,
diff --git a/tests/ui/closures/issue-78720.rs b/tests/ui/closures/issue-78720.rs
index 4cdb9f49113..0e1f78ae3c6 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 5d65c87b0fd..d8d3811af5a 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<Segment2, F> {
    |                     +++
 
+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<F>(self, f: F) -> Map2<F> {}
    |                                       ^^ expected `Map2<F>`, found `()`
@@ -32,7 +38,7 @@ LL |     fn map2<F>(self, f: F) -> Map2<F> {}
            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<F>(self, f: F) -> Map2<F> {}
    |                ^^^^ 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<F>(&self, f: F) -> Map2<F> {}
    |                +
 
-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 80013e7b4b2..ba41bf38a33 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 a46bd53520b..4ed1c0ded9f 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::<N>();
+   |        +++++
+
+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 0742db398c9..87e26ce85dc 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<X>`
+  --> $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<X> = 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 65822856e1d..1664669eee0 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<const X: usize>([u32; X]);
    |        ^^^^^^^^^^^
 
-error: aborting due to 2 previous errors
+error[E0282]: type annotations needed for `ArrayHolder<X>`
+  --> $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<X> = 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 a97f4b8ff31..6f40a9abfa7 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<const X: usize> ArrayHolder<X> {
 
 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 01fd1c48cf8..9ee83b409c1 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 8d0526978ed..fe84d83725f 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/inference/need_type_info/type-alias.rs b/tests/ui/inference/need_type_info/type-alias.rs
index f921b046b6c..b24af2d4849 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<T> = Ty<Box<T>>;
 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 cc7053bf385..2c39a3f5646 100644
--- a/tests/ui/inference/need_type_info/type-alias.stderr
+++ b/tests/ui/inference/need_type_info/type-alias.stderr
@@ -5,11 +5,17 @@ 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/typeck/issue-104510-ice.rs b/tests/ui/typeck/issue-104510-ice.rs
index 157bdf07e38..635cc8fad66 100644
--- a/tests/ui/typeck/issue-104510-ice.rs
+++ b/tests/ui/typeck/issue-104510-ice.rs
@@ -6,7 +6,7 @@ struct W<T: ?Sized>(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 143139b2c08..774e5268184 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<T: ?Sized>(Oops);
    |                     ^^^^ not found in this scope
 
-error: aborting due to 1 previous error
+error[E0282]: type annotations needed for `*const W<T>`
+  --> $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<T> = &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`.