about summary refs log tree commit diff
path: root/src/test/ui/thinlto
diff options
context:
space:
mode:
authorAaron Hill <aa1ronham@gmail.com>2019-03-26 15:30:41 -0400
committerAaron Hill <aa1ronham@gmail.com>2019-03-31 20:09:29 -0400
commit512069f8e51c975aac6bab662d9fccbf019d2a27 (patch)
treeb4c8e57f7bd38dde579246ef0d50e6633cd6ac62 /src/test/ui/thinlto
parent4fac5c98b22faa7fce2d5d64bf34c61340883302 (diff)
downloadrust-512069f8e51c975aac6bab662d9fccbf019d2a27.tar.gz
rust-512069f8e51c975aac6bab662d9fccbf019d2a27.zip
Fix stack overflow when generating debuginfo for 'recursive' type
By using 'impl trait', it's possible to create a self-referential
type as follows:

fn foo() -> impl Copy { foo }

This is a function which returns itself.
Normally, the signature of this function would be impossible
to write - it would look like 'fn foo() -> fn() -> fn() ...'
e.g. a function which returns a function, which returns a function...

Using 'impl trait' allows us to avoid writing this infinitely long
type. While it's useless for practical purposes, it does compile and run

However, issues arise when we try to generate llvm debuginfo for such a
type. All 'impl trait' types (e.g. ty::Opaque) are resolved when we
generate debuginfo, which can lead to us recursing back to the original
'fn' type when we try to process its return type.

To resolve this, I've modified debuginfo generation to account for these
kinds of weird types. Unfortunately, there's no 'correct' debuginfo that
we can generate - 'impl trait' does not exist in debuginfo, and this
kind of recursive type is impossible to directly represent.

To ensure that we emit *something*, this commit emits dummy
debuginfo/type names whenever it encounters a self-reference. In
practice, this should never happen - it's just to ensure that we can
emit some kind of debuginfo, even if it's not particularly meaningful

Fixes #58463
Diffstat (limited to 'src/test/ui/thinlto')
0 files changed, 0 insertions, 0 deletions