diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-12-17 00:45:52 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-17 00:45:52 +0100 |
| commit | a6c6a8d216b28b713a90a177a1c9bfe357f7ef77 (patch) | |
| tree | e6b12d31f083caa0bd7654384343691355081011 | |
| parent | 86bbc2014615a276a4c6b267c303b8773c0c54fb (diff) | |
| parent | bcaf210575f8b8ca4ea7fd37ef2ef40e7c263ad9 (diff) | |
| download | rust-a6c6a8d216b28b713a90a177a1c9bfe357f7ef77.tar.gz rust-a6c6a8d216b28b713a90a177a1c9bfe357f7ef77.zip | |
Rollup merge of #105711 - compiler-errors:rpitit-references-errors, r=eholk
bail in `collect_trait_impl_trait_tys` if signatures reference errors Fixes #105290
| -rw-r--r-- | compiler/rustc_hir_analysis/src/check/compare_method.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/async-await/in-trait/bad-signatures.rs | 16 | ||||
| -rw-r--r-- | src/test/ui/async-await/in-trait/bad-signatures.stderr | 26 |
3 files changed, 44 insertions, 0 deletions
diff --git a/compiler/rustc_hir_analysis/src/check/compare_method.rs b/compiler/rustc_hir_analysis/src/check/compare_method.rs index 6b9ce9a4599..b69728c24aa 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_method.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_method.rs @@ -405,6 +405,7 @@ pub fn collect_trait_impl_trait_tys<'tcx>( tcx.fn_sig(impl_m.def_id), ), ); + impl_sig.error_reported()?; let impl_return_ty = impl_sig.output(); // Normalize the trait signature with liberated bound vars, passing it through @@ -419,6 +420,7 @@ pub fn collect_trait_impl_trait_tys<'tcx>( ) .fold_with(&mut collector); let trait_sig = ocx.normalize(&norm_cause, param_env, unnormalized_trait_sig); + trait_sig.error_reported()?; let trait_return_ty = trait_sig.output(); let wf_tys = FxIndexSet::from_iter( diff --git a/src/test/ui/async-await/in-trait/bad-signatures.rs b/src/test/ui/async-await/in-trait/bad-signatures.rs new file mode 100644 index 00000000000..b86f1d1c135 --- /dev/null +++ b/src/test/ui/async-await/in-trait/bad-signatures.rs @@ -0,0 +1,16 @@ +// edition:2021 + +#![feature(async_fn_in_trait)] +//~^ WARN the feature `async_fn_in_trait` is incomplete + +trait MyTrait { + async fn bar(&abc self); + //~^ ERROR expected identifier, found keyword `self` + //~| ERROR expected one of `:`, `@`, or `|`, found keyword `self` +} + +impl MyTrait for () { + async fn bar(&self) {} +} + +fn main() {} diff --git a/src/test/ui/async-await/in-trait/bad-signatures.stderr b/src/test/ui/async-await/in-trait/bad-signatures.stderr new file mode 100644 index 00000000000..e0ba7b53ec4 --- /dev/null +++ b/src/test/ui/async-await/in-trait/bad-signatures.stderr @@ -0,0 +1,26 @@ +error: expected identifier, found keyword `self` + --> $DIR/bad-signatures.rs:7:23 + | +LL | async fn bar(&abc self); + | ^^^^ expected identifier, found keyword + +error: expected one of `:`, `@`, or `|`, found keyword `self` + --> $DIR/bad-signatures.rs:7:23 + | +LL | async fn bar(&abc self); + | -----^^^^ + | | | + | | expected one of `:`, `@`, or `|` + | help: declare the type after the parameter binding: `<identifier>: <type>` + +warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/bad-signatures.rs:3:12 + | +LL | #![feature(async_fn_in_trait)] + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = note: `#[warn(incomplete_features)]` on by default + +error: aborting due to 2 previous errors; 1 warning emitted + |
