From 8291011e711d387878f76bd0fd23ddc748859874 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Tue, 9 Nov 2021 20:46:35 -0800 Subject: [PATCH] Add ui test of nonconst construction --- tests/ui/submit-nonconst.rs | 13 +++++++++++++ tests/ui/submit-nonconst.stderr | 5 +++++ 2 files changed, 18 insertions(+) create mode 100644 tests/ui/submit-nonconst.rs create mode 100644 tests/ui/submit-nonconst.stderr diff --git a/tests/ui/submit-nonconst.rs b/tests/ui/submit-nonconst.rs new file mode 100644 index 0000000..c8774dc --- /dev/null +++ b/tests/ui/submit-nonconst.rs @@ -0,0 +1,13 @@ +struct Thing; + +impl Thing { + fn new() -> Self { + Thing + } +} + +inventory::collect!(Thing); + +inventory::submit!(Thing::new()); + +fn main() {} diff --git a/tests/ui/submit-nonconst.stderr b/tests/ui/submit-nonconst.stderr new file mode 100644 index 0000000..c2ac5d8 --- /dev/null +++ b/tests/ui/submit-nonconst.stderr @@ -0,0 +1,5 @@ +error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants + --> tests/ui/submit-nonconst.rs:11:20 + | +11 | inventory::submit!(Thing::new()); + | ^^^^^^^^^^^^