Skip to content

Commit bcaf210

Browse files
bail in collect_trait_impl_trait_tys if signatures reference errors
1 parent ba64ba8 commit bcaf210

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

Diff for: compiler/rustc_hir_analysis/src/check/compare_method.rs

+2
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ pub fn collect_trait_impl_trait_tys<'tcx>(
373373
tcx.fn_sig(impl_m.def_id),
374374
),
375375
);
376+
impl_sig.error_reported()?;
376377
let impl_return_ty = impl_sig.output();
377378

378379
// Normalize the trait signature with liberated bound vars, passing it through
@@ -387,6 +388,7 @@ pub fn collect_trait_impl_trait_tys<'tcx>(
387388
)
388389
.fold_with(&mut collector);
389390
let trait_sig = ocx.normalize(&norm_cause, param_env, unnormalized_trait_sig);
391+
trait_sig.error_reported()?;
390392
let trait_return_ty = trait_sig.output();
391393

392394
let wf_tys = FxIndexSet::from_iter(

Diff for: src/test/ui/async-await/in-trait/bad-signatures.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// edition:2021
2+
3+
#![feature(async_fn_in_trait)]
4+
//~^ WARN the feature `async_fn_in_trait` is incomplete
5+
6+
trait MyTrait {
7+
async fn bar(&abc self);
8+
//~^ ERROR expected identifier, found keyword `self`
9+
//~| ERROR expected one of `:`, `@`, or `|`, found keyword `self`
10+
}
11+
12+
impl MyTrait for () {
13+
async fn bar(&self) {}
14+
}
15+
16+
fn main() {}
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
error: expected identifier, found keyword `self`
2+
--> $DIR/bad-signatures.rs:7:23
3+
|
4+
LL | async fn bar(&abc self);
5+
| ^^^^ expected identifier, found keyword
6+
7+
error: expected one of `:`, `@`, or `|`, found keyword `self`
8+
--> $DIR/bad-signatures.rs:7:23
9+
|
10+
LL | async fn bar(&abc self);
11+
| -----^^^^
12+
| | |
13+
| | expected one of `:`, `@`, or `|`
14+
| help: declare the type after the parameter binding: `<identifier>: <type>`
15+
16+
warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
17+
--> $DIR/bad-signatures.rs:3:12
18+
|
19+
LL | #![feature(async_fn_in_trait)]
20+
| ^^^^^^^^^^^^^^^^^
21+
|
22+
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
23+
= note: `#[warn(incomplete_features)]` on by default
24+
25+
error: aborting due to 2 previous errors; 1 warning emitted
26+

0 commit comments

Comments
 (0)