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>(
478
478
let opaque_param = opaque_generics. param_at ( i, tcx) ;
479
479
let kind = opaque_param. kind . descr ( ) ;
480
480
481
+ if let Err ( guar) = opaque_env. param_is_error ( i) {
482
+ return Err ( guar) ;
483
+ }
484
+
481
485
return Err ( tcx. dcx ( ) . emit_err ( NonGenericOpaqueTypeParam {
482
486
ty : arg,
483
487
kind,
@@ -536,6 +540,10 @@ impl<'tcx> LazyOpaqueTyEnv<'tcx> {
536
540
canonical_args[ param1] == canonical_args[ param2]
537
541
}
538
542
543
+ pub fn param_is_error ( & self , param_index : usize ) -> Result < ( ) , ErrorGuaranteed > {
544
+ self . get_canonical_args ( ) [ param_index] . error_reported ( )
545
+ }
546
+
539
547
fn get_canonical_args ( & self ) -> ty:: GenericArgsRef < ' tcx > {
540
548
use rustc_hir as hir;
541
549
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()
11
11
//~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from `dyn` type
12
12
{
13
13
Box :: new ( ( ) )
14
- //~^ ERROR expected generic lifetime parameter, found `'static`
15
14
}
16
15
17
16
struct Foo ;
@@ -21,7 +20,6 @@ impl Foo {
21
20
//~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from `dyn` type
22
21
{
23
22
Box :: new ( ( ) )
24
- //~^ ERROR expected generic lifetime parameter, found `'static`
25
23
}
26
24
}
27
25
Original file line number Diff line number Diff line change @@ -10,37 +10,18 @@ note: lifetime declared here
10
10
LL | -> Box<for<'a> Id<impl Lt<'a>>>
11
11
| ^^
12
12
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
-
22
13
error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from `dyn` type
23
- --> $DIR/E0657.rs:20 :35
14
+ --> $DIR/E0657.rs:19 :35
24
15
|
25
16
LL | -> Box<for<'a> Id<impl Lt<'a>>>
26
17
| ^^
27
18
|
28
19
note: lifetime declared here
29
- --> $DIR/E0657.rs:20 :20
20
+ --> $DIR/E0657.rs:19 :20
30
21
|
31
22
LL | -> Box<for<'a> Id<impl Lt<'a>>>
32
23
| ^^
33
24
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
44
26
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 () {}
17
17
18
18
fn constrain ( ) -> Foo {
19
19
( )
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.
24
20
}
25
21
26
22
fn main ( ) { }
Original file line number Diff line number Diff line change @@ -10,16 +10,6 @@ note: lifetime declared here
10
10
LL | pub type Foo = impl for<'a> Trait<'a, Assoc = impl Test<'a>>;
11
11
| ^^
12
12
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
23
14
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