Skip to content

Commit e29a510

Browse files
authored
Rollup merge of #105318 - compiler-errors:issue-105304, r=jackh726
Make `get_impl_future_output_ty` work with AFIT Fixes #105304
2 parents 61189b6 + da929fa commit e29a510

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

compiler/rustc_infer/src/infer/error_reporting/mod.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,15 @@ pub fn unexpected_hidden_region_diagnostic<'tcx>(
341341

342342
impl<'tcx> InferCtxt<'tcx> {
343343
pub fn get_impl_future_output_ty(&self, ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
344-
let ty::Opaque(def_id, substs) = *ty.kind() else { return None; };
344+
let (def_id, substs) = match *ty.kind() {
345+
ty::Opaque(def_id, substs) => (def_id, substs),
346+
ty::Projection(data)
347+
if self.tcx.def_kind(data.item_def_id) == DefKind::ImplTraitPlaceholder =>
348+
{
349+
(data.item_def_id, data.substs)
350+
}
351+
_ => return None,
352+
};
345353

346354
let future_trait = self.tcx.require_lang_item(LangItem::Future, None);
347355
let item_def_id = self.tcx.associated_item_def_ids(future_trait)[0];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// edition: 2021
2+
3+
#![feature(async_fn_in_trait)]
4+
//~^ WARN the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
5+
6+
trait A {
7+
async fn e() {
8+
Ok(())
9+
//~^ ERROR mismatched types
10+
//~| HELP consider using a semicolon here
11+
}
12+
}
13+
14+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/return-type-suggestion.rs:3:12
3+
|
4+
LL | #![feature(async_fn_in_trait)]
5+
| ^^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
8+
= note: `#[warn(incomplete_features)]` on by default
9+
10+
error[E0308]: mismatched types
11+
--> $DIR/return-type-suggestion.rs:8:9
12+
|
13+
LL | Ok(())
14+
| ^^^^^^- help: consider using a semicolon here: `;`
15+
| |
16+
| expected `()`, found enum `Result`
17+
|
18+
= note: expected unit type `()`
19+
found enum `Result<(), _>`
20+
21+
error: aborting due to previous error; 1 warning emitted
22+
23+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)