about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-06-17 08:15:43 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-06-18 15:43:27 +0000
commita183989e88f2154770de1afd860bffb387c4b525 (patch)
treec45530c798caf391d17da16dd5ed8d8733d3a015
parentaf3d1004c766fc1413f7ad8ad052b77c077b83a1 (diff)
downloadrust-a183989e88f2154770de1afd860bffb387c4b525.tar.gz
rust-a183989e88f2154770de1afd860bffb387c4b525.zip
Only check locally for reported errors
-rw-r--r--compiler/rustc_hir_typeck/src/writeback.rs2
-rw-r--r--tests/ui/sized/ensure-overriding-bindings-in-pattern-with-ty-err-doesnt-ice.rs1
-rw-r--r--tests/ui/sized/ensure-overriding-bindings-in-pattern-with-ty-err-doesnt-ice.stderr15
-rw-r--r--tests/ui/wf/conflicting-impls.rs2
-rw-r--r--tests/ui/wf/conflicting-impls.stderr27
5 files changed, 41 insertions, 6 deletions
diff --git a/compiler/rustc_hir_typeck/src/writeback.rs b/compiler/rustc_hir_typeck/src/writeback.rs
index b67d29fce92..2714be1f9b4 100644
--- a/compiler/rustc_hir_typeck/src/writeback.rs
+++ b/compiler/rustc_hir_typeck/src/writeback.rs
@@ -793,7 +793,7 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
     }
 
     fn report_error(&self, p: impl Into<ty::GenericArg<'tcx>>) -> ErrorGuaranteed {
-        if let Some(guar) = self.fcx.dcx().has_errors() {
+        if let Some(guar) = self.fcx.tainted_by_errors() {
             guar
         } else {
             self.fcx
diff --git a/tests/ui/sized/ensure-overriding-bindings-in-pattern-with-ty-err-doesnt-ice.rs b/tests/ui/sized/ensure-overriding-bindings-in-pattern-with-ty-err-doesnt-ice.rs
index 196da30b864..d0bf5078165 100644
--- a/tests/ui/sized/ensure-overriding-bindings-in-pattern-with-ty-err-doesnt-ice.rs
+++ b/tests/ui/sized/ensure-overriding-bindings-in-pattern-with-ty-err-doesnt-ice.rs
@@ -4,4 +4,5 @@ fn main() {
 //~| ERROR cannot find type `T` in this scope
 //~| ERROR const and type arguments are not allowed on builtin type `str`
 //~| ERROR expected unit struct, unit variant or constant, found associated function `str<
+//~| ERROR type annotations needed
 }
diff --git a/tests/ui/sized/ensure-overriding-bindings-in-pattern-with-ty-err-doesnt-ice.stderr b/tests/ui/sized/ensure-overriding-bindings-in-pattern-with-ty-err-doesnt-ice.stderr
index 99f8dbd9a6c..fc431eb1412 100644
--- a/tests/ui/sized/ensure-overriding-bindings-in-pattern-with-ty-err-doesnt-ice.stderr
+++ b/tests/ui/sized/ensure-overriding-bindings-in-pattern-with-ty-err-doesnt-ice.stderr
@@ -32,7 +32,18 @@ error[E0533]: expected unit struct, unit variant or constant, found associated f
 LL |     let str::<{fn str() { let str::T>>::as_bytes; }}, T>::as_bytes;
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a unit struct, unit variant or constant
 
-error: aborting due to 4 previous errors
+error[E0282]: type annotations needed
+  --> $DIR/ensure-overriding-bindings-in-pattern-with-ty-err-doesnt-ice.rs:2:31
+   |
+LL |     let str::<{fn str() { let str::T>>::as_bytes; }}, T>::as_bytes;
+   |                               ^^^^^^^^^^^^^^^^^^
+   |
+help: consider giving this pattern a type
+   |
+LL |     let str::<{fn str() { let str::T>>::as_bytes: /* Type */; }}, T>::as_bytes;
+   |                                                 ++++++++++++
+
+error: aborting due to 5 previous errors
 
-Some errors have detailed explanations: E0109, E0412, E0533.
+Some errors have detailed explanations: E0109, E0282, E0412, E0533.
 For more information about an error, try `rustc --explain E0109`.
diff --git a/tests/ui/wf/conflicting-impls.rs b/tests/ui/wf/conflicting-impls.rs
index 8054eb7c594..c387199a8bf 100644
--- a/tests/ui/wf/conflicting-impls.rs
+++ b/tests/ui/wf/conflicting-impls.rs
@@ -5,6 +5,7 @@ struct Ty;
 impl TryFrom<Ty> for u8 {
     type Error = Ty;
     fn try_from(_: Ty) -> Result<Self, Self::Error> {
+        //~^ ERROR type annotations needed
         loop {}
     }
 }
@@ -13,6 +14,7 @@ impl TryFrom<Ty> for u8 {
     //~^ ERROR conflicting implementations of trait
     type Error = Ty;
     fn try_from(_: Ty) -> Result<Self, Self::Error> {
+        //~^ ERROR type annotations needed
         loop {}
     }
 }
diff --git a/tests/ui/wf/conflicting-impls.stderr b/tests/ui/wf/conflicting-impls.stderr
index d31ae17aa8f..15222a9b2cc 100644
--- a/tests/ui/wf/conflicting-impls.stderr
+++ b/tests/ui/wf/conflicting-impls.stderr
@@ -1,5 +1,5 @@
 error[E0119]: conflicting implementations of trait `TryFrom<Ty>` for type `u8`
-  --> $DIR/conflicting-impls.rs:12:1
+  --> $DIR/conflicting-impls.rs:13:1
    |
 LL | impl TryFrom<Ty> for u8 {
    | ----------------------- first implementation here
@@ -7,6 +7,27 @@ LL | impl TryFrom<Ty> for u8 {
 LL | impl TryFrom<Ty> for u8 {
    | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `u8`
 
-error: aborting due to 1 previous error
+error[E0282]: type annotations needed
+  --> $DIR/conflicting-impls.rs:7:53
+   |
+LL |       fn try_from(_: Ty) -> Result<Self, Self::Error> {
+   |  _____________________________________________________^
+LL | |
+LL | |         loop {}
+LL | |     }
+   | |_____^ cannot infer type for enum `Result<u8, _>`
+
+error[E0282]: type annotations needed
+  --> $DIR/conflicting-impls.rs:16:53
+   |
+LL |       fn try_from(_: Ty) -> Result<Self, Self::Error> {
+   |  _____________________________________________________^
+LL | |
+LL | |         loop {}
+LL | |     }
+   | |_____^ cannot infer type for enum `Result<u8, _>`
+
+error: aborting due to 3 previous errors
 
-For more information about this error, try `rustc --explain E0119`.
+Some errors have detailed explanations: E0119, E0282.
+For more information about an error, try `rustc --explain E0119`.