Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bail in collect_trait_impl_trait_tys if signatures reference errors #105711

Merged
merged 1 commit into from
Dec 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions compiler/rustc_hir_analysis/src/check/compare_method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,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
Expand All @@ -387,6 +388,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(
Expand Down
16 changes: 16 additions & 0 deletions src/test/ui/async-await/in-trait/bad-signatures.rs
Original file line number Diff line number Diff line change
@@ -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() {}
26 changes: 26 additions & 0 deletions src/test/ui/async-await/in-trait/bad-signatures.stderr
Original file line number Diff line number Diff line change
@@ -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