Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quietly fail if an error has already occurred #117214

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use rustc_infer::infer::InferCtxt;
use rustc_middle::mir::ConstraintCategory;
use rustc_middle::traits::query::OutlivesBound;
use rustc_middle::ty::{self, RegionVid, Ty};
use rustc_span::{Span, DUMMY_SP};
use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP};
use rustc_trait_selection::traits::query::type_op::{self, TypeOp};
use std::rc::Rc;
use type_op::TypeOpOutput;
Expand Down Expand Up @@ -318,7 +318,8 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
.param_env
.and(type_op::implied_outlives_bounds::ImpliedOutlivesBounds { ty })
.fully_perform(self.infcx, DUMMY_SP)
.unwrap_or_else(|_| bug!("failed to compute implied bounds {:?}", ty));
.map_err(|_: ErrorGuaranteed| debug!("failed to compute implied bounds {:?}", ty))
.ok()?;
debug!(?bounds, ?constraints);
self.add_outlives_bounds(bounds);
constraints
Expand Down
19 changes: 19 additions & 0 deletions tests/ui/lifetimes/issue-76168-hr-outlives-3.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// edition:2018

#![feature(unboxed_closures)]
use std::future::Future;

async fn wrapper<F>(f: F)
//~^ ERROR: expected a `FnOnce<(&'a mut i32,)>` closure, found `i32`
//~| ERROR: expected a `FnOnce<(&'a mut i32,)>` closure, found `i32`
//~| ERROR: expected a `FnOnce<(&'a mut i32,)>` closure, found `i32`
where
F:,
for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a,
{
//~^ ERROR: expected a `FnOnce<(&'a mut i32,)>` closure, found `i32`
let mut i = 41;
&mut i;
}

fn main() {}
51 changes: 51 additions & 0 deletions tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
error[E0277]: expected a `FnOnce<(&'a mut i32,)>` closure, found `i32`
--> $DIR/issue-76168-hr-outlives-3.rs:6:1
|
LL | / async fn wrapper<F>(f: F)
LL | |
LL | |
LL | |
LL | | where
LL | | F:,
LL | | for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a,
| |______________________________________________________________________________^ expected an `FnOnce<(&'a mut i32,)>` closure, found `i32`
|
= help: the trait `for<'a> FnOnce<(&'a mut i32,)>` is not implemented for `i32`

error[E0277]: expected a `FnOnce<(&'a mut i32,)>` closure, found `i32`
--> $DIR/issue-76168-hr-outlives-3.rs:6:10
|
LL | async fn wrapper<F>(f: F)
| ^^^^^^^ expected an `FnOnce<(&'a mut i32,)>` closure, found `i32`
|
= help: the trait `for<'a> FnOnce<(&'a mut i32,)>` is not implemented for `i32`

error[E0277]: expected a `FnOnce<(&'a mut i32,)>` closure, found `i32`
--> $DIR/issue-76168-hr-outlives-3.rs:13:1
|
LL | / {
LL | |
LL | | let mut i = 41;
LL | | &mut i;
LL | | }
| |_^ expected an `FnOnce<(&'a mut i32,)>` closure, found `i32`
|
= help: the trait `for<'a> FnOnce<(&'a mut i32,)>` is not implemented for `i32`

error[E0277]: expected a `FnOnce<(&'a mut i32,)>` closure, found `i32`
--> $DIR/issue-76168-hr-outlives-3.rs:6:1
|
LL | / async fn wrapper<F>(f: F)
LL | |
LL | |
LL | |
LL | | where
LL | | F:,
LL | | for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a,
| |______________________________________________________________________________^ expected an `FnOnce<(&'a mut i32,)>` closure, found `i32`
|
= help: the trait `for<'a> FnOnce<(&'a mut i32,)>` is not implemented for `i32`

error: aborting due to 4 previous errors

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