Skip to content

Commit d572729

Browse files
committed
Quietly fail if an error has already occurred
1 parent ccb160d commit d572729

File tree

3 files changed

+73
-2
lines changed

3 files changed

+73
-2
lines changed

compiler/rustc_borrowck/src/type_check/free_region_relations.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_infer::infer::InferCtxt;
88
use rustc_middle::mir::ConstraintCategory;
99
use rustc_middle::traits::query::OutlivesBound;
1010
use rustc_middle::ty::{self, RegionVid, Ty};
11-
use rustc_span::{Span, DUMMY_SP};
11+
use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP};
1212
use rustc_trait_selection::traits::query::type_op::{self, TypeOp};
1313
use std::rc::Rc;
1414
use type_op::TypeOpOutput;
@@ -318,7 +318,8 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
318318
.param_env
319319
.and(type_op::implied_outlives_bounds::ImpliedOutlivesBounds { ty })
320320
.fully_perform(self.infcx, DUMMY_SP)
321-
.unwrap_or_else(|_| bug!("failed to compute implied bounds {:?}", ty));
321+
.map_err(|_: ErrorGuaranteed| debug!("failed to compute implied bounds {:?}", ty))
322+
.ok()?;
322323
debug!(?bounds, ?constraints);
323324
self.add_outlives_bounds(bounds);
324325
constraints
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// edition:2018
2+
3+
#![feature(unboxed_closures)]
4+
use std::future::Future;
5+
6+
async fn wrapper<F>(f: F)
7+
//~^ ERROR: expected a `FnOnce<(&'a mut i32,)>` closure, found `i32`
8+
//~| ERROR: expected a `FnOnce<(&'a mut i32,)>` closure, found `i32`
9+
//~| ERROR: expected a `FnOnce<(&'a mut i32,)>` closure, found `i32`
10+
where
11+
F:,
12+
for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a,
13+
{
14+
//~^ ERROR: expected a `FnOnce<(&'a mut i32,)>` closure, found `i32`
15+
let mut i = 41;
16+
&mut i;
17+
}
18+
19+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
error[E0277]: expected a `FnOnce<(&'a mut i32,)>` closure, found `i32`
2+
--> $DIR/issue-76168-hr-outlives-3.rs:6:1
3+
|
4+
LL | / async fn wrapper<F>(f: F)
5+
LL | |
6+
LL | |
7+
LL | |
8+
LL | | where
9+
LL | | F:,
10+
LL | | for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a,
11+
| |______________________________________________________________________________^ expected an `FnOnce<(&'a mut i32,)>` closure, found `i32`
12+
|
13+
= help: the trait `for<'a> FnOnce<(&'a mut i32,)>` is not implemented for `i32`
14+
15+
error[E0277]: expected a `FnOnce<(&'a mut i32,)>` closure, found `i32`
16+
--> $DIR/issue-76168-hr-outlives-3.rs:6:10
17+
|
18+
LL | async fn wrapper<F>(f: F)
19+
| ^^^^^^^ expected an `FnOnce<(&'a mut i32,)>` closure, found `i32`
20+
|
21+
= help: the trait `for<'a> FnOnce<(&'a mut i32,)>` is not implemented for `i32`
22+
23+
error[E0277]: expected a `FnOnce<(&'a mut i32,)>` closure, found `i32`
24+
--> $DIR/issue-76168-hr-outlives-3.rs:13:1
25+
|
26+
LL | / {
27+
LL | |
28+
LL | | let mut i = 41;
29+
LL | | &mut i;
30+
LL | | }
31+
| |_^ expected an `FnOnce<(&'a mut i32,)>` closure, found `i32`
32+
|
33+
= help: the trait `for<'a> FnOnce<(&'a mut i32,)>` is not implemented for `i32`
34+
35+
error[E0277]: expected a `FnOnce<(&'a mut i32,)>` closure, found `i32`
36+
--> $DIR/issue-76168-hr-outlives-3.rs:6:1
37+
|
38+
LL | / async fn wrapper<F>(f: F)
39+
LL | |
40+
LL | |
41+
LL | |
42+
LL | | where
43+
LL | | F:,
44+
LL | | for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a,
45+
| |______________________________________________________________________________^ expected an `FnOnce<(&'a mut i32,)>` closure, found `i32`
46+
|
47+
= help: the trait `for<'a> FnOnce<(&'a mut i32,)>` is not implemented for `i32`
48+
49+
error: aborting due to 4 previous errors
50+
51+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)