diff options
| author | Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> | 2022-11-09 22:00:13 +0100 |
|---|---|---|
| committer | Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> | 2022-11-09 22:01:58 +0100 |
| commit | cedaaa640edfa2854ea213148a7c0f5ee5dd2f74 (patch) | |
| tree | 5458f9c1616aa2b152541873164500e75f6818dc /src | |
| parent | cc9b259b5e94e4543b96dca236e3a1af5ec496c9 (diff) | |
| download | rust-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.rs | 23 | ||||
| -rw-r--r-- | src/test/ui/traits/invalid_operator_trait.stderr | 8 |
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 + |
