Skip to content

Commit c337825

Browse files
committed
ignore error params
1 parent 4ecdf5f commit c337825

File tree

5 files changed

+14
-41
lines changed

5 files changed

+14
-41
lines changed

compiler/rustc_borrowck/src/region_infer/opaque_types.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff 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;

tests/ui/error-codes/E0657.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff 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

1716
struct 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

tests/ui/error-codes/E0657.stderr

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,37 +10,18 @@ note: lifetime declared here
1010
LL | -> 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-
2213
error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from `dyn` type
23-
--> $DIR/E0657.rs:20:35
14+
--> $DIR/E0657.rs:19:35
2415
|
2516
LL | -> Box<for<'a> Id<impl Lt<'a>>>
2617
| ^^
2718
|
2819
note: lifetime declared here
29-
--> $DIR/E0657.rs:20:20
20+
--> $DIR/E0657.rs:19:20
3021
|
3122
LL | -> 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`.

tests/ui/type-alias-impl-trait/escaping-bound-var.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ impl Test<'_> for () {}
1717

1818
fn 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

2622
fn main() {}

tests/ui/type-alias-impl-trait/escaping-bound-var.stderr

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,6 @@ note: lifetime declared here
1010
LL | 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`.

0 commit comments

Comments
 (0)