diff options
| author | Michael Goulet <michael@errs.io> | 2024-02-06 16:01:54 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2024-02-06 16:01:54 +0000 |
| commit | d9cd0d4d1180f09ea67be012848ff295a4681961 (patch) | |
| tree | 9220937b7d7cca3ed34f5fd52f426815f92fc316 | |
| parent | 037f515caf46846d2bffae55883eebc6c1ccb861 (diff) | |
| download | rust-d9cd0d4d1180f09ea67be012848ff295a4681961.tar.gz rust-d9cd0d4d1180f09ea67be012848ff295a4681961.zip | |
Don't expect early-bound region to be local in RPITIT well-formedness
| -rw-r--r-- | compiler/rustc_middle/src/ty/context.rs | 2 | ||||
| -rw-r--r-- | tests/ui/async-await/in-trait/auxiliary/bad-region.rs | 7 | ||||
| -rw-r--r-- | tests/ui/async-await/in-trait/bad-region.rs | 17 | ||||
| -rw-r--r-- | tests/ui/async-await/in-trait/bad-region.stderr | 14 |
4 files changed, 39 insertions, 1 deletions
diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 0d53870a0ba..70c6811e539 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -1193,7 +1193,7 @@ impl<'tcx> TyCtxt<'tcx> { let (suitable_region_binding_scope, bound_region) = loop { let def_id = match region.kind() { ty::ReLateParam(fr) => fr.bound_region.get_id()?.as_local()?, - ty::ReEarlyParam(ebr) => ebr.def_id.expect_local(), + ty::ReEarlyParam(ebr) => ebr.def_id.as_local()?, _ => return None, // not a free region }; let scope = self.local_parent(def_id); diff --git a/tests/ui/async-await/in-trait/auxiliary/bad-region.rs b/tests/ui/async-await/in-trait/auxiliary/bad-region.rs new file mode 100644 index 00000000000..02dc25aaa16 --- /dev/null +++ b/tests/ui/async-await/in-trait/auxiliary/bad-region.rs @@ -0,0 +1,7 @@ +// edition:2021 + +#[allow(async_fn_in_trait)] + +pub trait BleRadio<'a> { + async fn transmit(&mut self); +} diff --git a/tests/ui/async-await/in-trait/bad-region.rs b/tests/ui/async-await/in-trait/bad-region.rs new file mode 100644 index 00000000000..444368e21a4 --- /dev/null +++ b/tests/ui/async-await/in-trait/bad-region.rs @@ -0,0 +1,17 @@ +// aux-build:bad-region.rs +// edition:2021 + +#![allow(async_fn_in_trait)] + +extern crate bad_region as jewel; + +use jewel::BleRadio; + +pub struct Radio {} + +impl BleRadio for Radio { +//~^ ERROR implicit elided lifetime not allowed here + async fn transmit(&mut self) {} +} + +fn main() {} diff --git a/tests/ui/async-await/in-trait/bad-region.stderr b/tests/ui/async-await/in-trait/bad-region.stderr new file mode 100644 index 00000000000..9203fd790af --- /dev/null +++ b/tests/ui/async-await/in-trait/bad-region.stderr @@ -0,0 +1,14 @@ +error[E0726]: implicit elided lifetime not allowed here + --> $DIR/bad-region.rs:12:6 + | +LL | impl BleRadio for Radio { + | ^^^^^^^^ expected lifetime parameter + | +help: indicate the anonymous lifetime + | +LL | impl BleRadio<'_> for Radio { + | ++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0726`. |
