Skip to content

Commit 17bc6ca

Browse files
committed
Keep error types around, even in obligations.
These help silence follow up errors
1 parent 3a6bf35 commit 17bc6ca

File tree

9 files changed

+22
-55
lines changed

9 files changed

+22
-55
lines changed

compiler/rustc_infer/src/infer/opaque_types.rs

-7
Original file line numberDiff line numberDiff line change
@@ -631,13 +631,6 @@ impl<'tcx> InferCtxt<'tcx> {
631631
ct_op: |ct| ct,
632632
});
633633

634-
if let ty::ClauseKind::Projection(projection) = predicate.kind().skip_binder() {
635-
if projection.term.references_error() {
636-
// No point on adding any obligations since there's a type error involved.
637-
obligations.clear();
638-
return;
639-
}
640-
}
641634
// Require that the predicate holds for the concrete type.
642635
debug!(?predicate);
643636
obligations.push(traits::Obligation::new(

tests/ui/async-await/issues/issue-65159.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
async fn copy() -> Result<()>
66
//~^ ERROR enum takes 2 generic arguments
77
{
8-
Ok(()) //~ ERROR: type annotations needed
8+
Ok(())
99
}
1010

11-
fn main() { }
11+
fn main() {}

tests/ui/async-await/issues/issue-65159.stderr

+2-14
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,6 @@ help: add missing generic argument
1111
LL | async fn copy() -> Result<(), E>
1212
| +++
1313

14-
error[E0282]: type annotations needed
15-
--> $DIR/issue-65159.rs:8:5
16-
|
17-
LL | Ok(())
18-
| ^^ cannot infer type of the type parameter `E` declared on the enum `Result`
19-
|
20-
help: consider specifying the generic arguments
21-
|
22-
LL | Ok::<(), E>(())
23-
| +++++++++
24-
25-
error: aborting due to 2 previous errors
14+
error: aborting due to 1 previous error
2615

27-
Some errors have detailed explanations: E0107, E0282.
28-
For more information about an error, try `rustc --explain E0107`.
16+
For more information about this error, try `rustc --explain E0107`.

tests/ui/borrowck/issue-82126-mismatched-subst-and-hir.rs

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ async fn buy_lock(coroutine: &Mutex<MarketMultiplier>) -> LockedMarket<'_> {
1717
//~^ ERROR struct takes 0 lifetime arguments but 1 lifetime argument was supplied
1818
//~^^ ERROR struct takes 1 generic argument but 0 generic arguments were supplied
1919
LockedMarket(coroutine.lock().unwrap().buy())
20-
//~^ ERROR: cannot return value referencing temporary value
2120
}
2221

2322
struct LockedMarket<T>(T);

tests/ui/borrowck/issue-82126-mismatched-subst-and-hir.stderr

+4-14
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | async fn buy_lock(coroutine: &Mutex<MarketMultiplier>) -> LockedMarket<'_>
77
| expected 0 lifetime arguments
88
|
99
note: struct defined here, with 0 lifetime parameters
10-
--> $DIR/issue-82126-mismatched-subst-and-hir.rs:23:8
10+
--> $DIR/issue-82126-mismatched-subst-and-hir.rs:22:8
1111
|
1212
LL | struct LockedMarket<T>(T);
1313
| ^^^^^^^^^^^^
@@ -19,7 +19,7 @@ LL | async fn buy_lock(coroutine: &Mutex<MarketMultiplier>) -> LockedMarket<'_>
1919
| ^^^^^^^^^^^^ expected 1 generic argument
2020
|
2121
note: struct defined here, with 1 generic parameter: `T`
22-
--> $DIR/issue-82126-mismatched-subst-and-hir.rs:23:8
22+
--> $DIR/issue-82126-mismatched-subst-and-hir.rs:22:8
2323
|
2424
LL | struct LockedMarket<T>(T);
2525
| ^^^^^^^^^^^^ -
@@ -28,16 +28,6 @@ help: add missing generic argument
2828
LL | async fn buy_lock(coroutine: &Mutex<MarketMultiplier>) -> LockedMarket<'_, T> {
2929
| +++
3030

31-
error[E0515]: cannot return value referencing temporary value
32-
--> $DIR/issue-82126-mismatched-subst-and-hir.rs:19:5
33-
|
34-
LL | LockedMarket(coroutine.lock().unwrap().buy())
35-
| ^^^^^^^^^^^^^-------------------------^^^^^^^
36-
| | |
37-
| | temporary value created here
38-
| returns a value referencing data owned by the current function
39-
40-
error: aborting due to 3 previous errors
31+
error: aborting due to 2 previous errors
4132

42-
Some errors have detailed explanations: E0107, E0515.
43-
For more information about an error, try `rustc --explain E0107`.
33+
For more information about this error, try `rustc --explain E0107`.

tests/ui/impl-trait/issue-72911.rs

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ fn gather_from_file(dir_entry: &foo::MissingItem) -> impl Iterator<Item = Lint>
1616
fn lint_files() -> impl Iterator<Item = foo::MissingItem> {
1717
//~^ ERROR: failed to resolve
1818
unimplemented!()
19+
//~^ ERROR: `()` is not an iterator
1920
}
2021

2122
fn main() {}

tests/ui/impl-trait/issue-72911.stderr

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
error[E0277]: `()` is not an iterator
2+
--> $DIR/issue-72911.rs:16:20
3+
|
4+
LL | fn lint_files() -> impl Iterator<Item = foo::MissingItem> {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not an iterator
6+
|
7+
= help: the trait `Iterator` is not implemented for `()`
8+
19
error[E0433]: failed to resolve: use of undeclared crate or module `foo`
210
--> $DIR/issue-72911.rs:11:33
311
|
@@ -10,6 +18,7 @@ error[E0433]: failed to resolve: use of undeclared crate or module `foo`
1018
LL | fn lint_files() -> impl Iterator<Item = foo::MissingItem> {
1119
| ^^^ use of undeclared crate or module `foo`
1220

13-
error: aborting due to 2 previous errors
21+
error: aborting due to 3 previous errors
1422

15-
For more information about this error, try `rustc --explain E0433`.
23+
Some errors have detailed explanations: E0277, E0433.
24+
For more information about an error, try `rustc --explain E0277`.

tests/ui/impl-trait/issues/issue-92305.rs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use std::iter;
55
fn f<T>(data: &[T]) -> impl Iterator<Item = Vec> {
66
//~^ ERROR: missing generics for struct `Vec` [E0107]
77
iter::empty()
8-
//~^ ERROR: type annotations needed
98
}
109

1110
fn g<T>(data: &[T], target: T) -> impl Iterator<Item = Vec<T>> {

tests/ui/impl-trait/issues/issue-92305.stderr

+2-14
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,6 @@ help: add missing generic argument
99
LL | fn f<T>(data: &[T]) -> impl Iterator<Item = Vec<T>> {
1010
| +++
1111

12-
error[E0282]: type annotations needed
13-
--> $DIR/issue-92305.rs:7:5
14-
|
15-
LL | iter::empty()
16-
| ^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `empty`
17-
|
18-
help: consider specifying the generic argument
19-
|
20-
LL | iter::empty::<T>()
21-
| +++++
22-
23-
error: aborting due to 2 previous errors
12+
error: aborting due to 1 previous error
2413

25-
Some errors have detailed explanations: E0107, E0282.
26-
For more information about an error, try `rustc --explain E0107`.
14+
For more information about this error, try `rustc --explain E0107`.

0 commit comments

Comments
 (0)