ignore error params

This commit is contained in:
Ali MJ Al-Nasrawy 2024-03-19 19:23:47 +00:00
parent 4ecdf5ff00
commit c337825d6d
5 changed files with 14 additions and 41 deletions

View File

@ -478,6 +478,10 @@ fn check_opaque_type_parameter_valid<'tcx>(
let opaque_param = opaque_generics.param_at(i, tcx);
let kind = opaque_param.kind.descr();
if let Err(guar) = opaque_env.param_is_error(i) {
return Err(guar);
}
return Err(tcx.dcx().emit_err(NonGenericOpaqueTypeParam {
ty: arg,
kind,
@ -536,6 +540,10 @@ impl<'tcx> LazyOpaqueTyEnv<'tcx> {
canonical_args[param1] == canonical_args[param2]
}
pub fn param_is_error(&self, param_index: usize) -> Result<(), ErrorGuaranteed> {
self.get_canonical_args()[param_index].error_reported()
}
fn get_canonical_args(&self) -> ty::GenericArgsRef<'tcx> {
use rustc_hir as hir;
use rustc_infer::infer::outlives::env::OutlivesEnvironment;

View File

@ -11,7 +11,6 @@ fn free_fn_capture_hrtb_in_impl_trait()
//~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from `dyn` type
{
Box::new(())
//~^ ERROR expected generic lifetime parameter, found `'static`
}
struct Foo;
@ -21,7 +20,6 @@ impl Foo {
//~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from `dyn` type
{
Box::new(())
//~^ ERROR expected generic lifetime parameter, found `'static`
}
}

View File

@ -10,37 +10,18 @@ note: lifetime declared here
LL | -> Box<for<'a> Id<impl Lt<'a>>>
| ^^
error[E0792]: expected generic lifetime parameter, found `'static`
--> $DIR/E0657.rs:13:5
|
LL | -> Box<for<'a> Id<impl Lt<'a>>>
| -- cannot use static lifetime; use a bound lifetime instead or remove the lifetime parameter from the opaque type
...
LL | Box::new(())
| ^^^^^^^^^^^^
error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from `dyn` type
--> $DIR/E0657.rs:20:35
--> $DIR/E0657.rs:19:35
|
LL | -> Box<for<'a> Id<impl Lt<'a>>>
| ^^
|
note: lifetime declared here
--> $DIR/E0657.rs:20:20
--> $DIR/E0657.rs:19:20
|
LL | -> Box<for<'a> Id<impl Lt<'a>>>
| ^^
error[E0792]: expected generic lifetime parameter, found `'static`
--> $DIR/E0657.rs:23:9
|
LL | -> Box<for<'a> Id<impl Lt<'a>>>
| -- cannot use static lifetime; use a bound lifetime instead or remove the lifetime parameter from the opaque type
...
LL | Box::new(())
| ^^^^^^^^^^^^
error: aborting due to 2 previous errors
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0657, E0792.
For more information about an error, try `rustc --explain E0657`.
For more information about this error, try `rustc --explain E0657`.

View File

@ -17,10 +17,6 @@ impl Test<'_> for () {}
fn constrain() -> Foo {
()
//~^ ERROR expected generic lifetime parameter, found `'static`
// FIXME(aliemjay): Undesirable error message appears because error regions
// are converterted internally into `'?0` which corresponds to `'static`
// This should be fixed in a later commit.
}
fn main() {}

View File

@ -10,16 +10,6 @@ note: lifetime declared here
LL | pub type Foo = impl for<'a> Trait<'a, Assoc = impl Test<'a>>;
| ^^
error[E0792]: expected generic lifetime parameter, found `'static`
--> $DIR/escaping-bound-var.rs:19:5
|
LL | pub type Foo = impl for<'a> Trait<'a, Assoc = impl Test<'a>>;
| -- cannot use static lifetime; use a bound lifetime instead or remove the lifetime parameter from the opaque type
...
LL | ()
| ^^
error: aborting due to 1 previous error
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0657, E0792.
For more information about an error, try `rustc --explain E0657`.
For more information about this error, try `rustc --explain E0657`.