about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBryanskiy <ivakin.kir@gmail.com>2025-03-12 15:59:21 +0300
committerBryanskiy <ivakin.kir@gmail.com>2025-03-12 15:59:37 +0300
commit7bfe2136e4ffa5b5f6c85f0544a5d7ef8ab2b705 (patch)
tree940ebd909e64ad401150b8cb77e05abf2c44180d
parent57a4736e9f4b7e8089b2db60583607f3b550c862 (diff)
downloadrust-7bfe2136e4ffa5b5f6c85f0544a5d7ef8ab2b705.tar.gz
rust-7bfe2136e4ffa5b5f6c85f0544a5d7ef8ab2b705.zip
Delegation: one more ICE fix for `MethodCall` generation
-rw-r--r--compiler/rustc_ast_lowering/src/delegation.rs1
-rw-r--r--tests/ui/delegation/ice-issue-138362.rs15
-rw-r--r--tests/ui/delegation/ice-issue-138362.stderr19
3 files changed, 35 insertions, 0 deletions
diff --git a/compiler/rustc_ast_lowering/src/delegation.rs b/compiler/rustc_ast_lowering/src/delegation.rs
index 571172be4ed..946f2cafa15 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 00000000000..c3066009855
--- /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 00000000000..9feddc9feae
--- /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`.