diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-03-22 19:06:46 +0100 |
|---|---|---|
| committer | Matthias Krüger <matthias.krueger@famsik.de> | 2024-03-24 09:23:13 +0100 |
| commit | 57f500512bec1e29dbae876499899b579273aa2a (patch) | |
| tree | bd46c0a1870935c84235767a99277baefb30c4d1 /tests/ui/sized/stack-overflow-trait-infer-98842.rs | |
| parent | 5ae90256daff3442ffe823035b79001b49c28ee1 (diff) | |
| download | rust-57f500512bec1e29dbae876499899b579273aa2a.tar.gz rust-57f500512bec1e29dbae876499899b579273aa2a.zip | |
add test for stack overflow with recursive type #98842
Fixes #98842
Diffstat (limited to 'tests/ui/sized/stack-overflow-trait-infer-98842.rs')
| -rw-r--r-- | tests/ui/sized/stack-overflow-trait-infer-98842.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/ui/sized/stack-overflow-trait-infer-98842.rs b/tests/ui/sized/stack-overflow-trait-infer-98842.rs new file mode 100644 index 00000000000..2bba0777be4 --- /dev/null +++ b/tests/ui/sized/stack-overflow-trait-infer-98842.rs @@ -0,0 +1,15 @@ +// #98842 stack overflow in trait inference +//@ check-fail +//@ edition:2021 +//~^^^ ERROR cycle detected when computing layout of `Foo` + +// If the inner `Foo` is named through an associated type, +// the "infinite size" error does not occur. +struct Foo(<&'static Foo as ::core::ops::Deref>::Target); +// But Rust will be unable to know whether `Foo` is sized or not, +// and it will infinitely recurse somewhere trying to figure out the +// size of this pointer (is my guess): +const _: *const Foo = 0 as _; +//~^ ERROR it is undefined behavior to use this value + +pub fn main() {} |
