diff options
| author | Ralf Jung <post@ralfj.de> | 2024-02-12 08:51:41 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2024-02-12 09:48:14 +0100 |
| commit | 5fa69deb006aaec28e5e9aba6ca1faf66e36ae1f (patch) | |
| tree | a14001aab2e1b7d0283eb51cd89fed6795e83739 /tests | |
| parent | 084ce5bdb5f7dc1c725f6770a8de281165ba3b0a (diff) | |
| download | rust-5fa69deb006aaec28e5e9aba6ca1faf66e36ae1f.tar.gz rust-5fa69deb006aaec28e5e9aba6ca1faf66e36ae1f.zip | |
fix cycle error when a static and a promoted are mutually recursive
This also now allows promoteds everywhere to point to 'extern static', because why not? We still check that constants cannot transitively reach 'extern static' through references. (We allow it through raw pointers.)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/consts/cycle-static-promoted.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/ui/consts/cycle-static-promoted.rs b/tests/ui/consts/cycle-static-promoted.rs new file mode 100644 index 00000000000..5838dc58a3a --- /dev/null +++ b/tests/ui/consts/cycle-static-promoted.rs @@ -0,0 +1,12 @@ +// check-pass + +struct Value { + values: &'static [&'static Value], +} + +// This `static` recursively points to itself through a promoted (the slice). +static VALUE: Value = Value { + values: &[&VALUE], +}; + +fn main() {} |
