Rollup merge of #126236 - Bryanskiy:delegation-no-entry-ice-2, r=petrochenkov

Delegation: fix ICE on recursive delegation

fixes https://github.com/rust-lang/rust/issues/124347

r? `@petrochenkov`
This commit is contained in:
许杰友 Jieyou Xu (Joe) 2024-06-11 14:16:46 +01:00 committed by GitHub
commit 279d2b73f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 29 additions and 5 deletions

View File

@ -67,7 +67,9 @@ pub(crate) fn delegation_has_self(&self, item_id: NodeId, path_id: NodeId, span:
return false;
};
if let Some(local_sig_id) = sig_id.as_local() {
self.resolver.delegation_fn_sigs[&local_sig_id].has_self
// The value may be missing due to recursive delegation.
// Error will be emmited later during HIR ty lowering.
self.resolver.delegation_fn_sigs.get(&local_sig_id).map_or(false, |sig| sig.has_self)
} else {
match self.tcx.def_kind(sig_id) {
DefKind::Fn => false,

View File

@ -1,4 +0,0 @@
//@ known-bug: #124347
trait Trait: ToReuse {
reuse Trait::lolno { &self.0 };
}

View File

@ -0,0 +1,12 @@
#![feature(fn_delegation)]
#![allow(incomplete_features)]
trait Trait {
reuse Trait::foo { &self.0 }
//~^ ERROR recursive delegation is not supported yet
}
reuse foo;
//~^ ERROR recursive delegation is not supported yet
fn main() {}

View File

@ -0,0 +1,14 @@
error: recursive delegation is not supported yet
--> $DIR/ice-issue-124347.rs:5:18
|
LL | reuse Trait::foo { &self.0 }
| ^^^ callee defined here
error: recursive delegation is not supported yet
--> $DIR/ice-issue-124347.rs:9:7
|
LL | reuse foo;
| ^^^ callee defined here
error: aborting due to 2 previous errors