about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNilstrieb <48135649+Nilstrieb@users.noreply.github.com>2022-11-09 22:00:13 +0100
committerNilstrieb <48135649+Nilstrieb@users.noreply.github.com>2022-11-09 22:01:58 +0100
commitcedaaa640edfa2854ea213148a7c0f5ee5dd2f74 (patch)
tree5458f9c1616aa2b152541873164500e75f6818dc /src
parentcc9b259b5e94e4543b96dca236e3a1af5ec496c9 (diff)
downloadrust-cedaaa640edfa2854ea213148a7c0f5ee5dd2f74.tar.gz
rust-cedaaa640edfa2854ea213148a7c0f5ee5dd2f74.zip
Don't ICE on operator trait methods with generic methods
Emit a fatal error instead.
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/traits/invalid_operator_trait.rs23
-rw-r--r--src/test/ui/traits/invalid_operator_trait.stderr8
2 files changed, 31 insertions, 0 deletions
diff --git a/src/test/ui/traits/invalid_operator_trait.rs b/src/test/ui/traits/invalid_operator_trait.rs
new file mode 100644
index 00000000000..7ea3b0d5bac
--- /dev/null
+++ b/src/test/ui/traits/invalid_operator_trait.rs
@@ -0,0 +1,23 @@
+#![crate_type = "lib"]
+#![feature(lang_items)]
+#![feature(no_core)]
+#![no_core]
+
+#[lang="sized"]
+pub trait Sized {
+    // Empty.
+}
+
+#[lang = "add"]
+trait Add<RHS=Self> {
+    type Output;
+
+    fn add<Y>(self, _: RHS) -> Self::Output;
+    //~^ ERROR `add` must not have any generic parameters
+}
+
+#[allow(unreachable_code)]
+fn ice(a: usize) {
+    let r = loop {};
+    r = r + a;
+}
diff --git a/src/test/ui/traits/invalid_operator_trait.stderr b/src/test/ui/traits/invalid_operator_trait.stderr
new file mode 100644
index 00000000000..8c6e3695905
--- /dev/null
+++ b/src/test/ui/traits/invalid_operator_trait.stderr
@@ -0,0 +1,8 @@
+error: `add` must not have any generic parameters
+  --> $DIR/invalid_operator_trait.rs:15:5
+   |
+LL |     fn add<Y>(self, _: RHS) -> Self::Output;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+