Skip to content

Commit a6b1e43

Browse files
committed
Remove a has_errors check that only hides errors after unrelated items have errored.
1 parent f7531f1 commit a6b1e43

File tree

14 files changed

+89
-22
lines changed

14 files changed

+89
-22
lines changed

compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs

-3
Original file line numberDiff line numberDiff line change
@@ -2624,9 +2624,6 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
26242624
if let Some(e) = self.tainted_by_errors() {
26252625
return e;
26262626
}
2627-
if let Some(e) = self.dcx().has_errors() {
2628-
return e;
2629-
}
26302627

26312628
self.emit_inference_failure_err(
26322629
obligation.cause.body_id,

tests/ui/closures/issue-78720.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
fn server() -> impl {
22
//~^ ERROR at least one trait must be specified
33
().map2(|| "")
4+
//~^ ERROR type annotations needed
45
}
56

67
trait FilterBase2 {

tests/ui/closures/issue-78720.stderr

+11-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | fn server() -> impl {
55
| ^^^^
66

77
error[E0412]: cannot find type `F` in this scope
8-
--> $DIR/issue-78720.rs:13:12
8+
--> $DIR/issue-78720.rs:14:12
99
|
1010
LL | _func: F,
1111
| ^
@@ -22,8 +22,14 @@ help: you might be missing a type parameter
2222
LL | struct Map2<Segment2, F> {
2323
| +++
2424

25+
error[E0282]: type annotations needed
26+
--> $DIR/issue-78720.rs:3:5
27+
|
28+
LL | ().map2(|| "")
29+
| ^^^^^^^^^^^^^^ cannot infer type
30+
2531
error[E0308]: mismatched types
26-
--> $DIR/issue-78720.rs:7:39
32+
--> $DIR/issue-78720.rs:8:39
2733
|
2834
LL | fn map2<F>(self, f: F) -> Map2<F> {}
2935
| ^^ expected `Map2<F>`, found `()`
@@ -32,7 +38,7 @@ LL | fn map2<F>(self, f: F) -> Map2<F> {}
3238
found unit type `()`
3339

3440
error[E0277]: the size for values of type `Self` cannot be known at compilation time
35-
--> $DIR/issue-78720.rs:7:16
41+
--> $DIR/issue-78720.rs:8:16
3642
|
3743
LL | fn map2<F>(self, f: F) -> Map2<F> {}
3844
| ^^^^ 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
4753
LL | fn map2<F>(&self, f: F) -> Map2<F> {}
4854
| +
4955

50-
error: aborting due to 4 previous errors
56+
error: aborting due to 5 previous errors
5157

52-
Some errors have detailed explanations: E0277, E0308, E0412.
58+
Some errors have detailed explanations: E0277, E0282, E0308, E0412.
5359
For more information about an error, try `rustc --explain E0277`.

tests/ui/const-generics/defaults/rp_impl_trait_fail.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ fn owo() -> impl Traitor {
2525

2626
fn main() {
2727
rawr();
28-
uwu();
28+
uwu(); //~ ERROR: type annotations needed
2929
owo();
3030
}

tests/ui/const-generics/defaults/rp_impl_trait_fail.stderr

+14-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ LL | 1_u64
3131
|
3232
= help: the trait `Traitor<1, 2>` is implemented for `u64`
3333

34-
error: aborting due to 3 previous errors
34+
error[E0282]: type annotations needed
35+
--> $DIR/rp_impl_trait_fail.rs:28:5
36+
|
37+
LL | uwu();
38+
| ^^^ cannot infer the value of the const parameter `N` declared on the function `uwu`
39+
|
40+
help: consider specifying the generic argument
41+
|
42+
LL | uwu::<N>();
43+
| +++++
44+
45+
error: aborting due to 4 previous errors
3546

36-
For more information about this error, try `rustc --explain E0277`.
47+
Some errors have detailed explanations: E0277, E0282.
48+
For more information about an error, try `rustc --explain E0277`.

tests/ui/const-generics/generic_const_exprs/issue-62504.full.stderr

+14-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ LL | ArrayHolder([0; Self::SIZE])
1515
|
1616
= help: try adding a `where` bound using this expression: `where [(); Self::SIZE]:`
1717

18-
error: aborting due to 2 previous errors
18+
error[E0282]: type annotations needed for `ArrayHolder<X>`
19+
--> $DIR/issue-62504.rs:26:9
20+
|
21+
LL | let mut array = ArrayHolder::new();
22+
| ^^^^^^^^^
23+
|
24+
help: consider giving `array` an explicit type, where the value of const parameter `X` is specified
25+
|
26+
LL | let mut array: ArrayHolder<X> = ArrayHolder::new();
27+
| ++++++++++++++++
28+
29+
error: aborting due to 3 previous errors
1930

20-
For more information about this error, try `rustc --explain E0308`.
31+
Some errors have detailed explanations: E0282, E0308.
32+
For more information about an error, try `rustc --explain E0282`.

tests/ui/const-generics/generic_const_exprs/issue-62504.min.stderr

+14-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ note: tuple struct defined here
2222
LL | struct ArrayHolder<const X: usize>([u32; X]);
2323
| ^^^^^^^^^^^
2424

25-
error: aborting due to 2 previous errors
25+
error[E0282]: type annotations needed for `ArrayHolder<X>`
26+
--> $DIR/issue-62504.rs:26:9
27+
|
28+
LL | let mut array = ArrayHolder::new();
29+
| ^^^^^^^^^
30+
|
31+
help: consider giving `array` an explicit type, where the value of const parameter `X` is specified
32+
|
33+
LL | let mut array: ArrayHolder<X> = ArrayHolder::new();
34+
| ++++++++++++++++
35+
36+
error: aborting due to 3 previous errors
2637

27-
For more information about this error, try `rustc --explain E0308`.
38+
Some errors have detailed explanations: E0282, E0308.
39+
For more information about an error, try `rustc --explain E0282`.

tests/ui/const-generics/generic_const_exprs/issue-62504.rs

+1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ impl<const X: usize> ArrayHolder<X> {
2424

2525
fn main() {
2626
let mut array = ArrayHolder::new();
27+
//~^ ERROR: type annotations needed
2728
}

tests/ui/consts/issue-104609.rs

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ fn foo() {
55

66
unsafe fn bar() {
77
std::mem::transmute::<_, *mut _>(1_u8);
8+
//~^ ERROR: type annotations needed
89
}
910

1011
fn main() {}

tests/ui/consts/issue-104609.stderr

+9-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ error[E0425]: cannot find value `oops` in this scope
44
LL | oops;
55
| ^^^^ not found in this scope
66

7-
error: aborting due to 1 previous error
7+
error[E0282]: type annotations needed
8+
--> $DIR/issue-104609.rs:7:5
9+
|
10+
LL | std::mem::transmute::<_, *mut _>(1_u8);
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `Dst` declared on the function `transmute`
12+
13+
error: aborting due to 2 previous errors
814

9-
For more information about this error, try `rustc --explain E0425`.
15+
Some errors have detailed explanations: E0282, E0425.
16+
For more information about an error, try `rustc --explain E0282`.

tests/ui/inference/need_type_info/type-alias.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn direct_alias() {
1515

1616
type IndirectAlias<T> = Ty<Box<T>>;
1717
fn indirect_alias() {
18-
IndirectAlias::new();
18+
IndirectAlias::new(); //~ ERROR: type annotations needed
1919
// FIXME: This should also emit an error.
2020
//
2121
// Added it separately as `type-alias-indirect.rs`

tests/ui/inference/need_type_info/type-alias.stderr

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,18 @@ error[E0282]: type annotations needed
44
LL | DirectAlias::new()
55
| ^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `T`
66

7+
error[E0282]: type annotations needed
8+
--> $DIR/type-alias.rs:18:5
9+
|
10+
LL | IndirectAlias::new();
11+
| ^^^^^^^^^^^^^ cannot infer type for type parameter `T` declared on the type alias `IndirectAlias`
12+
713
error[E0282]: type annotations needed
814
--> $DIR/type-alias.rs:32:5
915
|
1016
LL | DirectButWithDefaultAlias::new();
1117
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `T`
1218

13-
error: aborting due to 2 previous errors
19+
error: aborting due to 3 previous errors
1420

1521
For more information about this error, try `rustc --explain E0282`.

tests/ui/typeck/issue-104510-ice.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ struct W<T: ?Sized>(Oops);
66

77
unsafe fn test() {
88
let j = W(());
9-
let pointer = &j as *const _;
9+
let pointer = &j as *const _; //~ ERROR type annotations needed
1010
core::arch::asm!(
1111
"nop",
1212
in("eax") pointer,

tests/ui/typeck/issue-104510-ice.stderr

+14-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ error[E0412]: cannot find type `Oops` in this scope
44
LL | struct W<T: ?Sized>(Oops);
55
| ^^^^ not found in this scope
66

7-
error: aborting due to 1 previous error
7+
error[E0282]: type annotations needed for `*const W<T>`
8+
--> $DIR/issue-104510-ice.rs:9:9
9+
|
10+
LL | let pointer = &j as *const _;
11+
| ^^^^^^^
12+
|
13+
help: consider giving `pointer` an explicit type, where the type for type parameter `T` is specified
14+
|
15+
LL | let pointer: *const W<T> = &j as *const _;
16+
| +++++++++++++
17+
18+
error: aborting due to 2 previous errors
819

9-
For more information about this error, try `rustc --explain E0412`.
20+
Some errors have detailed explanations: E0282, E0412.
21+
For more information about an error, try `rustc --explain E0282`.

0 commit comments

Comments
 (0)