Skip to content

Commit 009feeb

Browse files
Fix rustc_hidden_type_of_opaques for RPITITs with no default body
1 parent 7b31983 commit 009feeb

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

compiler/rustc_hir_analysis/src/collect/dump.rs

+9
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ pub(crate) fn opaque_hidden_types(tcx: TyCtxt<'_>) {
1111
}
1212

1313
for id in tcx.hir_crate_items(()).opaques() {
14+
if let hir::OpaqueTyOrigin::FnReturn { parent: fn_def_id, .. }
15+
| hir::OpaqueTyOrigin::AsyncFn { parent: fn_def_id, .. } =
16+
tcx.hir().expect_opaque_ty(id).origin
17+
&& let hir::Node::TraitItem(trait_item) = tcx.hir_node_by_def_id(fn_def_id)
18+
&& let (_, hir::TraitFn::Required(..)) = trait_item.expect_fn()
19+
{
20+
continue;
21+
}
22+
1423
let ty = tcx.type_of(id).instantiate_identity();
1524
let span = tcx.def_span(id);
1625
tcx.dcx().emit_err(crate::errors::TypeOf { span, ty });

tests/ui/impl-trait/in-trait/dump.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//@ compile-flags: -Zverbose-internals
2+
3+
#![feature(precise_capturing_in_traits, rustc_attrs)]
4+
#![rustc_hidden_type_of_opaques]
5+
6+
trait Foo {
7+
fn hello(&self) -> impl Sized;
8+
}
9+
10+
fn hello<'s, T: Foo>(x: &'s T) -> impl Sized + use<'s, T> {
11+
//~^ ERROR <T as Foo>::{synthetic#0}<'s/#1>
12+
x.hello()
13+
}
14+
15+
fn main() {}
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: <T as Foo>::{synthetic#0}<'s/#1>
2+
--> $DIR/dump.rs:10:35
3+
|
4+
LL | fn hello<'s, T: Foo>(x: &'s T) -> impl Sized + use<'s, T> {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^
6+
7+
error: aborting due to 1 previous error
8+

0 commit comments

Comments
 (0)