Skip to content

Commit

Permalink
Add ui test of nonconst construction
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Nov 10, 2021
1 parent b499293 commit 8291011
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/ui/submit-nonconst.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
struct Thing;

impl Thing {
fn new() -> Self {
Thing
}
}

inventory::collect!(Thing);

inventory::submit!(Thing::new());

fn main() {}
5 changes: 5 additions & 0 deletions tests/ui/submit-nonconst.stderr
Original file line number Diff line number Diff line change
@@ -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());
| ^^^^^^^^^^^^

0 comments on commit 8291011

Please sign in to comment.