From 7bfe2136e4ffa5b5f6c85f0544a5d7ef8ab2b705 Mon Sep 17 00:00:00 2001 From: Bryanskiy Date: Wed, 12 Mar 2025 15:59:21 +0300 Subject: [PATCH] Delegation: one more ICE fix for `MethodCall` generation --- compiler/rustc_ast_lowering/src/delegation.rs | 1 + tests/ui/delegation/ice-issue-138362.rs | 15 +++++++++++++++ tests/ui/delegation/ice-issue-138362.stderr | 19 +++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 tests/ui/delegation/ice-issue-138362.rs create mode 100644 tests/ui/delegation/ice-issue-138362.stderr diff --git a/compiler/rustc_ast_lowering/src/delegation.rs b/compiler/rustc_ast_lowering/src/delegation.rs index 571172be4ed16..946f2cafa15f2 100644 --- a/compiler/rustc_ast_lowering/src/delegation.rs +++ b/compiler/rustc_ast_lowering/src/delegation.rs @@ -330,6 +330,7 @@ impl<'hir> LoweringContext<'_, 'hir> { .unwrap_or_default() && delegation.qself.is_none() && !has_generic_args + && !args.is_empty() { let ast_segment = delegation.path.segments.last().unwrap(); let segment = self.lower_path_segment( diff --git a/tests/ui/delegation/ice-issue-138362.rs b/tests/ui/delegation/ice-issue-138362.rs new file mode 100644 index 0000000000000..c30660098555b --- /dev/null +++ b/tests/ui/delegation/ice-issue-138362.rs @@ -0,0 +1,15 @@ +#![feature(fn_delegation)] +#![allow(incomplete_features)] + +trait HasSelf { + fn method(self); +} +trait NoSelf { + fn method(); +} +impl NoSelf for u8 { + reuse HasSelf::method; + //~^ ERROR this function takes 1 argument but 0 arguments were supplied +} + +fn main() {} diff --git a/tests/ui/delegation/ice-issue-138362.stderr b/tests/ui/delegation/ice-issue-138362.stderr new file mode 100644 index 0000000000000..9feddc9feaec3 --- /dev/null +++ b/tests/ui/delegation/ice-issue-138362.stderr @@ -0,0 +1,19 @@ +error[E0061]: this function takes 1 argument but 0 arguments were supplied + --> $DIR/ice-issue-138362.rs:11:20 + | +LL | reuse HasSelf::method; + | ^^^^^^ argument #1 is missing + | +note: method defined here + --> $DIR/ice-issue-138362.rs:5:8 + | +LL | fn method(self); + | ^^^^^^ ---- +help: provide the argument + | +LL | reuse HasSelf::method(/* value */); + | +++++++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0061`.