diff options
| author | Jubilee <workingjubilee@gmail.com> | 2025-02-05 19:53:47 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-05 19:53:47 -0800 |
| commit | 1361ef37ff3e1901fc13147d8e795e356b52b7f8 (patch) | |
| tree | 1b7695f70f1fbdc0ca0af854a9b4f42e65c4c1a1 | |
| parent | b9bacc4da5541c2092a878e344943c8325e716a4 (diff) | |
| parent | 009feeb83e8e1c9637467e87207e9322cca307d4 (diff) | |
| download | rust-1361ef37ff3e1901fc13147d8e795e356b52b7f8.tar.gz rust-1361ef37ff3e1901fc13147d8e795e356b52b7f8.zip | |
Rollup merge of #136550 - compiler-errors:rpitit-empty-body, r=oli-obk
Fix `rustc_hidden_type_of_opaques` for RPITITs with no default body Needed this when debugging something
| -rw-r--r-- | compiler/rustc_hir_analysis/src/collect/dump.rs | 9 | ||||
| -rw-r--r-- | tests/ui/impl-trait/in-trait/dump.rs | 15 | ||||
| -rw-r--r-- | tests/ui/impl-trait/in-trait/dump.stderr | 8 |
3 files changed, 32 insertions, 0 deletions
diff --git a/compiler/rustc_hir_analysis/src/collect/dump.rs b/compiler/rustc_hir_analysis/src/collect/dump.rs index 4a508fc0cf6..41f8465ae91 100644 --- a/compiler/rustc_hir_analysis/src/collect/dump.rs +++ b/compiler/rustc_hir_analysis/src/collect/dump.rs @@ -11,6 +11,15 @@ pub(crate) fn opaque_hidden_types(tcx: TyCtxt<'_>) { } for id in tcx.hir_crate_items(()).opaques() { + if let hir::OpaqueTyOrigin::FnReturn { parent: fn_def_id, .. } + | hir::OpaqueTyOrigin::AsyncFn { parent: fn_def_id, .. } = + tcx.hir().expect_opaque_ty(id).origin + && let hir::Node::TraitItem(trait_item) = tcx.hir_node_by_def_id(fn_def_id) + && let (_, hir::TraitFn::Required(..)) = trait_item.expect_fn() + { + continue; + } + let ty = tcx.type_of(id).instantiate_identity(); let span = tcx.def_span(id); tcx.dcx().emit_err(crate::errors::TypeOf { span, ty }); diff --git a/tests/ui/impl-trait/in-trait/dump.rs b/tests/ui/impl-trait/in-trait/dump.rs new file mode 100644 index 00000000000..47198d51150 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/dump.rs @@ -0,0 +1,15 @@ +//@ compile-flags: -Zverbose-internals + +#![feature(precise_capturing_in_traits, rustc_attrs)] +#![rustc_hidden_type_of_opaques] + +trait Foo { + fn hello(&self) -> impl Sized; +} + +fn hello<'s, T: Foo>(x: &'s T) -> impl Sized + use<'s, T> { +//~^ ERROR <T as Foo>::{synthetic#0}<'s/#1> + x.hello() +} + +fn main() {} diff --git a/tests/ui/impl-trait/in-trait/dump.stderr b/tests/ui/impl-trait/in-trait/dump.stderr new file mode 100644 index 00000000000..95805840385 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/dump.stderr @@ -0,0 +1,8 @@ +error: <T as Foo>::{synthetic#0}<'s/#1> + --> $DIR/dump.rs:10:35 + | +LL | fn hello<'s, T: Foo>(x: &'s T) -> impl Sized + use<'s, T> { + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + |
