ignore error params
This commit is contained in:
parent
4ecdf5ff00
commit
c337825d6d
5 changed files with 14 additions and 41 deletions
|
@ -478,6 +478,10 @@ fn check_opaque_type_parameter_valid<'tcx>(
|
||||||
let opaque_param = opaque_generics.param_at(i, tcx);
|
let opaque_param = opaque_generics.param_at(i, tcx);
|
||||||
let kind = opaque_param.kind.descr();
|
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 {
|
return Err(tcx.dcx().emit_err(NonGenericOpaqueTypeParam {
|
||||||
ty: arg,
|
ty: arg,
|
||||||
kind,
|
kind,
|
||||||
|
@ -536,6 +540,10 @@ impl<'tcx> LazyOpaqueTyEnv<'tcx> {
|
||||||
canonical_args[param1] == canonical_args[param2]
|
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> {
|
fn get_canonical_args(&self) -> ty::GenericArgsRef<'tcx> {
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_infer::infer::outlives::env::OutlivesEnvironment;
|
use rustc_infer::infer::outlives::env::OutlivesEnvironment;
|
||||||
|
|
|
@ -11,7 +11,6 @@ fn free_fn_capture_hrtb_in_impl_trait()
|
||||||
//~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from `dyn` type
|
//~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from `dyn` type
|
||||||
{
|
{
|
||||||
Box::new(())
|
Box::new(())
|
||||||
//~^ ERROR expected generic lifetime parameter, found `'static`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Foo;
|
struct Foo;
|
||||||
|
@ -21,7 +20,6 @@ impl Foo {
|
||||||
//~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from `dyn` type
|
//~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from `dyn` type
|
||||||
{
|
{
|
||||||
Box::new(())
|
Box::new(())
|
||||||
//~^ ERROR expected generic lifetime parameter, found `'static`
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,37 +10,18 @@ note: lifetime declared here
|
||||||
LL | -> Box<for<'a> Id<impl Lt<'a>>>
|
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
|
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>>>
|
LL | -> Box<for<'a> Id<impl Lt<'a>>>
|
||||||
| ^^
|
| ^^
|
||||||
|
|
|
|
||||||
note: lifetime declared here
|
note: lifetime declared here
|
||||||
--> $DIR/E0657.rs:20:20
|
--> $DIR/E0657.rs:19:20
|
||||||
|
|
|
|
||||||
LL | -> Box<for<'a> Id<impl Lt<'a>>>
|
LL | -> Box<for<'a> Id<impl Lt<'a>>>
|
||||||
| ^^
|
| ^^
|
||||||
|
|
||||||
error[E0792]: expected generic lifetime parameter, found `'static`
|
error: aborting due to 2 previous errors
|
||||||
--> $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 4 previous errors
|
For more information about this error, try `rustc --explain E0657`.
|
||||||
|
|
||||||
Some errors have detailed explanations: E0657, E0792.
|
|
||||||
For more information about an error, try `rustc --explain E0657`.
|
|
||||||
|
|
|
@ -17,10 +17,6 @@ impl Test<'_> for () {}
|
||||||
|
|
||||||
fn constrain() -> Foo {
|
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() {}
|
fn main() {}
|
||||||
|
|
|
@ -10,16 +10,6 @@ note: lifetime declared here
|
||||||
LL | pub type Foo = impl for<'a> Trait<'a, Assoc = impl Test<'a>>;
|
LL | pub type Foo = impl for<'a> Trait<'a, Assoc = impl Test<'a>>;
|
||||||
| ^^
|
| ^^
|
||||||
|
|
||||||
error[E0792]: expected generic lifetime parameter, found `'static`
|
error: aborting due to 1 previous error
|
||||||
--> $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 2 previous errors
|
For more information about this error, try `rustc --explain E0657`.
|
||||||
|
|
||||||
Some errors have detailed explanations: E0657, E0792.
|
|
||||||
For more information about an error, try `rustc --explain E0657`.
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue