Skip to content

Commit

Permalink
Keep error types around, even in obligations.
Browse files Browse the repository at this point in the history
These help silence follow up errors
  • Loading branch information
oli-obk committed Jan 10, 2024
1 parent e927184 commit d2a021f
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 54 deletions.
7 changes: 0 additions & 7 deletions compiler/rustc_infer/src/infer/opaque_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,13 +631,6 @@ impl<'tcx> InferCtxt<'tcx> {
ct_op: |ct| ct,
});

if let ty::ClauseKind::Projection(projection) = predicate.kind().skip_binder() {
if projection.term.references_error() {
// No point on adding any obligations since there's a type error involved.
obligations.clear();
return;
}
}
// Require that the predicate holds for the concrete type.
debug!(?predicate);
obligations.push(traits::Obligation::new(
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/async-await/issues/issue-65159.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
async fn copy() -> Result<()>
//~^ ERROR enum takes 2 generic arguments
{
Ok(()) //~ ERROR: type annotations needed
Ok(())
}

fn main() { }
fn main() {}
16 changes: 2 additions & 14 deletions tests/ui/async-await/issues/issue-65159.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,6 @@ help: add missing generic argument
LL | async fn copy() -> Result<(), E>
| +++

error[E0282]: type annotations needed
--> $DIR/issue-65159.rs:8:5
|
LL | Ok(())
| ^^ cannot infer type of the type parameter `E` declared on the enum `Result`
|
help: consider specifying the generic arguments
|
LL | Ok::<(), E>(())
| +++++++++

error: aborting due to 2 previous errors
error: aborting due to 1 previous error

Some errors have detailed explanations: E0107, E0282.
For more information about an error, try `rustc --explain E0107`.
For more information about this error, try `rustc --explain E0107`.
1 change: 0 additions & 1 deletion tests/ui/borrowck/issue-82126-mismatched-subst-and-hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ async fn buy_lock(coroutine: &Mutex<MarketMultiplier>) -> LockedMarket<'_> {
//~^ ERROR struct takes 0 lifetime arguments but 1 lifetime argument was supplied
//~^^ ERROR struct takes 1 generic argument but 0 generic arguments were supplied
LockedMarket(coroutine.lock().unwrap().buy())
//~^ ERROR: cannot return value referencing temporary value
}

struct LockedMarket<T>(T);
Expand Down
18 changes: 4 additions & 14 deletions tests/ui/borrowck/issue-82126-mismatched-subst-and-hir.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LL | async fn buy_lock(coroutine: &Mutex<MarketMultiplier>) -> LockedMarket<'_>
| expected 0 lifetime arguments
|
note: struct defined here, with 0 lifetime parameters
--> $DIR/issue-82126-mismatched-subst-and-hir.rs:23:8
--> $DIR/issue-82126-mismatched-subst-and-hir.rs:22:8
|
LL | struct LockedMarket<T>(T);
| ^^^^^^^^^^^^
Expand All @@ -19,7 +19,7 @@ LL | async fn buy_lock(coroutine: &Mutex<MarketMultiplier>) -> LockedMarket<'_>
| ^^^^^^^^^^^^ expected 1 generic argument
|
note: struct defined here, with 1 generic parameter: `T`
--> $DIR/issue-82126-mismatched-subst-and-hir.rs:23:8
--> $DIR/issue-82126-mismatched-subst-and-hir.rs:22:8
|
LL | struct LockedMarket<T>(T);
| ^^^^^^^^^^^^ -
Expand All @@ -28,16 +28,6 @@ help: add missing generic argument
LL | async fn buy_lock(coroutine: &Mutex<MarketMultiplier>) -> LockedMarket<'_, T> {
| +++

error[E0515]: cannot return value referencing temporary value
--> $DIR/issue-82126-mismatched-subst-and-hir.rs:19:5
|
LL | LockedMarket(coroutine.lock().unwrap().buy())
| ^^^^^^^^^^^^^-------------------------^^^^^^^
| | |
| | temporary value created here
| returns a value referencing data owned by the current function

error: aborting due to 3 previous errors
error: aborting due to 2 previous errors

Some errors have detailed explanations: E0107, E0515.
For more information about an error, try `rustc --explain E0107`.
For more information about this error, try `rustc --explain E0107`.
2 changes: 1 addition & 1 deletion tests/ui/impl-trait/issue-72911.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fn gather_from_file(dir_entry: &foo::MissingItem) -> impl Iterator<Item = Lint>

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

fn main() {}
1 change: 0 additions & 1 deletion tests/ui/impl-trait/issues/issue-92305.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::iter;
fn f<T>(data: &[T]) -> impl Iterator<Item = Vec> {
//~^ ERROR: missing generics for struct `Vec` [E0107]
iter::empty()
//~^ ERROR: type annotations needed
}

fn g<T>(data: &[T], target: T) -> impl Iterator<Item = Vec<T>> {
Expand Down
16 changes: 2 additions & 14 deletions tests/ui/impl-trait/issues/issue-92305.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,6 @@ help: add missing generic argument
LL | fn f<T>(data: &[T]) -> impl Iterator<Item = Vec<T>> {
| +++

error[E0282]: type annotations needed
--> $DIR/issue-92305.rs:7:5
|
LL | iter::empty()
| ^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `empty`
|
help: consider specifying the generic argument
|
LL | iter::empty::<T>()
| +++++

error: aborting due to 2 previous errors
error: aborting due to 1 previous error

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

0 comments on commit d2a021f

Please sign in to comment.