File tree Expand file tree Collapse file tree 5 files changed +14
-41
lines changed
compiler/rustc_borrowck/src/region_infer Expand file tree Collapse file tree 5 files changed +14
-41
lines changed Original file line number Diff line number Diff line change @@ -478,6 +478,10 @@ fn check_opaque_type_parameter_valid<'tcx>(
478478 let opaque_param = opaque_generics. param_at ( i, tcx) ;
479479 let kind = opaque_param. kind . descr ( ) ;
480480
481+ if let Err ( guar) = opaque_env. param_is_error ( i) {
482+ return Err ( guar) ;
483+ }
484+
481485 return Err ( tcx. dcx ( ) . emit_err ( NonGenericOpaqueTypeParam {
482486 ty : arg,
483487 kind,
@@ -536,6 +540,10 @@ impl<'tcx> LazyOpaqueTyEnv<'tcx> {
536540 canonical_args[ param1] == canonical_args[ param2]
537541 }
538542
543+ pub fn param_is_error ( & self , param_index : usize ) -> Result < ( ) , ErrorGuaranteed > {
544+ self . get_canonical_args ( ) [ param_index] . error_reported ( )
545+ }
546+
539547 fn get_canonical_args ( & self ) -> ty:: GenericArgsRef < ' tcx > {
540548 use rustc_hir as hir;
541549 use rustc_infer:: infer:: outlives:: env:: OutlivesEnvironment ;
Original file line number Diff line number Diff line change @@ -11,7 +11,6 @@ fn free_fn_capture_hrtb_in_impl_trait()
1111 //~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from `dyn` type
1212{
1313 Box :: new ( ( ) )
14- //~^ ERROR expected generic lifetime parameter, found `'static`
1514}
1615
1716struct Foo ;
@@ -21,7 +20,6 @@ impl Foo {
2120 //~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from `dyn` type
2221 {
2322 Box :: new ( ( ) )
24- //~^ ERROR expected generic lifetime parameter, found `'static`
2523 }
2624}
2725
Original file line number Diff line number Diff line change @@ -10,37 +10,18 @@ note: lifetime declared here
1010LL | -> Box<for<'a> Id<impl Lt<'a>>>
1111 | ^^
1212
13- error[E0792]: expected generic lifetime parameter, found `'static`
14- --> $DIR/E0657.rs:13:5
15- |
16- LL | -> Box<for<'a> Id<impl Lt<'a>>>
17- | -- cannot use static lifetime; use a bound lifetime instead or remove the lifetime parameter from the opaque type
18- ...
19- LL | Box::new(())
20- | ^^^^^^^^^^^^
21-
2213error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from `dyn` type
23- --> $DIR/E0657.rs:20 :35
14+ --> $DIR/E0657.rs:19 :35
2415 |
2516LL | -> Box<for<'a> Id<impl Lt<'a>>>
2617 | ^^
2718 |
2819note: lifetime declared here
29- --> $DIR/E0657.rs:20 :20
20+ --> $DIR/E0657.rs:19 :20
3021 |
3122LL | -> Box<for<'a> Id<impl Lt<'a>>>
3223 | ^^
3324
34- error[E0792]: expected generic lifetime parameter, found `'static`
35- --> $DIR/E0657.rs:23:9
36- |
37- LL | -> Box<for<'a> Id<impl Lt<'a>>>
38- | -- cannot use static lifetime; use a bound lifetime instead or remove the lifetime parameter from the opaque type
39- ...
40- LL | Box::new(())
41- | ^^^^^^^^^^^^
42-
43- error: aborting due to 4 previous errors
25+ error: aborting due to 2 previous errors
4426
45- Some errors have detailed explanations: E0657, E0792.
46- For more information about an error, try `rustc --explain E0657`.
27+ For more information about this error, try `rustc --explain E0657`.
Original file line number Diff line number Diff line change @@ -17,10 +17,6 @@ impl Test<'_> for () {}
1717
1818fn constrain ( ) -> Foo {
1919 ( )
20- //~^ ERROR expected generic lifetime parameter, found `'static`
21- // FIXME(aliemjay): Undesirable error message appears because error regions
22- // are converterted internally into `'?0` which corresponds to `'static`
23- // This should be fixed in a later commit.
2420}
2521
2622fn main ( ) { }
Original file line number Diff line number Diff line change @@ -10,16 +10,6 @@ note: lifetime declared here
1010LL | pub type Foo = impl for<'a> Trait<'a, Assoc = impl Test<'a>>;
1111 | ^^
1212
13- error[E0792]: expected generic lifetime parameter, found `'static`
14- --> $DIR/escaping-bound-var.rs:19:5
15- |
16- LL | pub type Foo = impl for<'a> Trait<'a, Assoc = impl Test<'a>>;
17- | -- cannot use static lifetime; use a bound lifetime instead or remove the lifetime parameter from the opaque type
18- ...
19- LL | ()
20- | ^^
21-
22- error: aborting due to 2 previous errors
13+ error: aborting due to 1 previous error
2314
24- Some errors have detailed explanations: E0657, E0792.
25- For more information about an error, try `rustc --explain E0657`.
15+ For more information about this error, try `rustc --explain E0657`.
You can’t perform that action at this time.
0 commit comments