Skip to content

Commit d2a021f

Browse files
committed
Keep error types around, even in obligations.
These help silence follow up errors
1 parent e927184 commit d2a021f

File tree

8 files changed

+11
-54
lines changed

8 files changed

+11
-54
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-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn gather_from_file(dir_entry: &foo::MissingItem) -> impl Iterator<Item = Lint>
1515

1616
fn lint_files() -> impl Iterator<Item = foo::MissingItem> {
1717
//~^ ERROR: failed to resolve
18-
unimplemented!()
18+
std::iter::empty()
1919
}
2020

2121
fn main() {}

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)