Skip to content

Commit 6e3a3de

Browse files
authored
Rollup merge of #108915 - spastorino:new-rpitit-8, r=compiler-errors
Remove some direct calls to local_def_id_to_hir_id on diagnostics Was playing with `tests/ui/impl-trait/in-trait/default-body-with-rpit.rs` and was able to remove some ICEs. Still getting ... ``` error[E0277]: `impl Future<Output = Foo::{opaque#0}>` is not a future --> tests/ui/impl-trait/in-trait/default-body-with-rpit.rs:10:28 | 10 | async fn baz(&self) -> impl Debug { | ^^^^^^^^^^ `impl Future<Output = Foo::{opaque#0}>` is not a future | = help: the trait `Future` is not implemented for `impl Future<Output = Foo::{opaque#0}>` = note: impl Future<Output = Foo::{opaque#0}> must be a future or must implement `IntoFuture` to be awaited note: required by a bound in `Foo::{opaque#1}` --> tests/ui/impl-trait/in-trait/default-body-with-rpit.rs:10:28 | 10 | async fn baz(&self) -> impl Debug { | ^^^^^^^^^^ required by this bound in `Foo::{opaque#1}` error[E0277]: the size for values of type `impl Future<Output = Foo::{opaque#0}>` cannot be known at compilation time --> tests/ui/impl-trait/in-trait/default-body-with-rpit.rs:10:28 | 10 | async fn baz(&self) -> impl Debug { | ^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `impl Future<Output = Foo::{opaque#0}>` note: required by a bound in `Foo::{opaque#1}` --> tests/ui/impl-trait/in-trait/default-body-with-rpit.rs:10:28 | 10 | async fn baz(&self) -> impl Debug { | ^^^^^^^^^^ required by this bound in `Foo::{opaque#1}` error: internal compiler error: compiler/rustc_hir_typeck/src/closure.rs:724:18: async fn generator return type not an inference variable: Foo::{opaque#1}<'_> --> tests/ui/impl-trait/in-trait/default-body-with-rpit.rs:10:39 | 10 | async fn baz(&self) -> impl Debug { | _______________________________________^ 11 | | "" 12 | | } | |_____^ ``` But I guess this is a little bit of progress anyway. This one goes on top of #108700 and #108945 r? `@compiler-errors`
2 parents 48934c4 + 4824363 commit 6e3a3de

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

compiler/rustc_middle/src/hir/map/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ impl<'hir> Map<'hir> {
316316
/// Retrieves the `Node` corresponding to `id`, returning `None` if cannot be found.
317317
#[inline]
318318
pub fn find_by_def_id(self, id: LocalDefId) -> Option<Node<'hir>> {
319-
self.find(self.local_def_id_to_hir_id(id))
319+
self.find(self.tcx.opt_local_def_id_to_hir_id(id)?)
320320
}
321321

322322
/// Retrieves the `Node` corresponding to `id`, panicking if it cannot be found.
@@ -333,7 +333,7 @@ impl<'hir> Map<'hir> {
333333
}
334334

335335
pub fn get_if_local(self, id: DefId) -> Option<Node<'hir>> {
336-
id.as_local().and_then(|id| self.find(self.local_def_id_to_hir_id(id)))
336+
id.as_local().and_then(|id| self.find(self.tcx.opt_local_def_id_to_hir_id(id)?))
337337
}
338338

339339
pub fn get_generics(self, id: LocalDefId) -> Option<&'hir Generics<'hir>> {

compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs

+4
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
144144
trait_ref: ty::PolyTraitRef<'tcx>,
145145
obligation: &PredicateObligation<'tcx>,
146146
) -> OnUnimplementedNote {
147+
if self.tcx.opt_rpitit_info(obligation.cause.body_id.to_def_id()).is_some() {
148+
return OnUnimplementedNote::default();
149+
}
150+
147151
let (def_id, substs) = self
148152
.impl_similar_to(trait_ref, obligation)
149153
.unwrap_or_else(|| (trait_ref.def_id(), trait_ref.skip_binder().substs));

0 commit comments

Comments
 (0)