Skip to content

Commit a4c25f5

Browse files
committed
Only check locally for reported errors
1 parent f873ae0 commit a4c25f5

5 files changed

+41
-6
lines changed

compiler/rustc_hir_typeck/src/writeback.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
793793
}
794794

795795
fn report_error(&self, p: impl Into<ty::GenericArg<'tcx>>) -> ErrorGuaranteed {
796-
if let Some(guar) = self.fcx.dcx().has_errors() {
796+
if let Some(guar) = self.fcx.tainted_by_errors() {
797797
guar
798798
} else {
799799
self.fcx

tests/ui/sized/ensure-overriding-bindings-in-pattern-with-ty-err-doesnt-ice.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ fn main() {
44
//~| ERROR cannot find type `T` in this scope
55
//~| ERROR const and type arguments are not allowed on builtin type `str`
66
//~| ERROR expected unit struct, unit variant or constant, found associated function `str<
7+
//~| ERROR type annotations needed
78
}

tests/ui/sized/ensure-overriding-bindings-in-pattern-with-ty-err-doesnt-ice.stderr

+13-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,18 @@ error[E0533]: expected unit struct, unit variant or constant, found associated f
3232
LL | let str::<{fn str() { let str::T>>::as_bytes; }}, T>::as_bytes;
3333
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a unit struct, unit variant or constant
3434

35-
error: aborting due to 4 previous errors
35+
error[E0282]: type annotations needed
36+
--> $DIR/ensure-overriding-bindings-in-pattern-with-ty-err-doesnt-ice.rs:2:31
37+
|
38+
LL | let str::<{fn str() { let str::T>>::as_bytes; }}, T>::as_bytes;
39+
| ^^^^^^^^^^^^^^^^^^
40+
|
41+
help: consider giving this pattern a type
42+
|
43+
LL | let str::<{fn str() { let str::T>>::as_bytes: /* Type */; }}, T>::as_bytes;
44+
| ++++++++++++
45+
46+
error: aborting due to 5 previous errors
3647

37-
Some errors have detailed explanations: E0109, E0412, E0533.
48+
Some errors have detailed explanations: E0109, E0282, E0412, E0533.
3849
For more information about an error, try `rustc --explain E0109`.

tests/ui/wf/conflicting-impls.rs

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ struct Ty;
55
impl TryFrom<Ty> for u8 {
66
type Error = Ty;
77
fn try_from(_: Ty) -> Result<Self, Self::Error> {
8+
//~^ ERROR type annotations needed
89
loop {}
910
}
1011
}
@@ -13,6 +14,7 @@ impl TryFrom<Ty> for u8 {
1314
//~^ ERROR conflicting implementations of trait
1415
type Error = Ty;
1516
fn try_from(_: Ty) -> Result<Self, Self::Error> {
17+
//~^ ERROR type annotations needed
1618
loop {}
1719
}
1820
}

tests/ui/wf/conflicting-impls.stderr

+24-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,33 @@
11
error[E0119]: conflicting implementations of trait `TryFrom<Ty>` for type `u8`
2-
--> $DIR/conflicting-impls.rs:12:1
2+
--> $DIR/conflicting-impls.rs:13:1
33
|
44
LL | impl TryFrom<Ty> for u8 {
55
| ----------------------- first implementation here
66
...
77
LL | impl TryFrom<Ty> for u8 {
88
| ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `u8`
99

10-
error: aborting due to 1 previous error
10+
error[E0282]: type annotations needed
11+
--> $DIR/conflicting-impls.rs:7:53
12+
|
13+
LL | fn try_from(_: Ty) -> Result<Self, Self::Error> {
14+
| _____________________________________________________^
15+
LL | |
16+
LL | | loop {}
17+
LL | | }
18+
| |_____^ cannot infer type for enum `Result<u8, _>`
19+
20+
error[E0282]: type annotations needed
21+
--> $DIR/conflicting-impls.rs:16:53
22+
|
23+
LL | fn try_from(_: Ty) -> Result<Self, Self::Error> {
24+
| _____________________________________________________^
25+
LL | |
26+
LL | | loop {}
27+
LL | | }
28+
| |_____^ cannot infer type for enum `Result<u8, _>`
29+
30+
error: aborting due to 3 previous errors
1131

12-
For more information about this error, try `rustc --explain E0119`.
32+
Some errors have detailed explanations: E0119, E0282.
33+
For more information about an error, try `rustc --explain E0119`.

0 commit comments

Comments
 (0)